/* Generated by Cython 3.2.9 */

/* BEGIN: Cython Metadata
{
    "distutils": {
        "extra_compile_args": [
            "/O2"
        ],
        "name": "ws_package.controllers.activity_controller",
        "sources": [
            "C:\\Users\\yash\\Desktop\\Saver_win_visible\\workstatus-python\\workstatus\\ws_package\\controllers\\activity_controller.py"
        ]
    },
    "module_name": "ws_package.controllers.activity_controller"
}
END: Cython Metadata */

#ifndef PY_SSIZE_T_CLEAN
#define PY_SSIZE_T_CLEAN
#endif /* PY_SSIZE_T_CLEAN */
/* InitLimitedAPI */
#if defined(Py_LIMITED_API)
  #if !defined(CYTHON_LIMITED_API)
  #define CYTHON_LIMITED_API 1
  #endif
#elif defined(CYTHON_LIMITED_API)
  #ifdef _MSC_VER
  #pragma message ("Limited API usage is enabled with 'CYTHON_LIMITED_API' but 'Py_LIMITED_API' does not define a Python target version. Consider setting 'Py_LIMITED_API' instead.")
  #else
  #warning Limited API usage is enabled with 'CYTHON_LIMITED_API' but 'Py_LIMITED_API' does not define a Python target version. Consider setting 'Py_LIMITED_API' instead.
  #endif
#endif

#include "Python.h"
#ifndef Py_PYTHON_H
    #error Python headers needed to compile C extensions, please install development version of Python.
#elif PY_VERSION_HEX < 0x03080000
    #error Cython requires Python 3.8+.
#else
#define __PYX_ABI_VERSION "3_2_9"
#define CYTHON_HEX_VERSION 0x030209F0
#define CYTHON_FUTURE_DIVISION 1
/* CModulePreamble */
#include <stddef.h>
#ifndef offsetof
  #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
#endif
#if !defined(_WIN32) && !defined(WIN32) && !defined(MS_WINDOWS)
  #ifndef __stdcall
    #define __stdcall
  #endif
  #ifndef __cdecl
    #define __cdecl
  #endif
  #ifndef __fastcall
    #define __fastcall
  #endif
#endif
#ifndef DL_IMPORT
  #define DL_IMPORT(t) t
#endif
#ifndef DL_EXPORT
  #define DL_EXPORT(t) t
#endif
#define __PYX_COMMA ,
#ifndef PY_LONG_LONG
  #define PY_LONG_LONG LONG_LONG
#endif
#ifndef Py_HUGE_VAL
  #define Py_HUGE_VAL HUGE_VAL
#endif
#define __PYX_LIMITED_VERSION_HEX PY_VERSION_HEX
#if defined(GRAALVM_PYTHON)
  /* For very preliminary testing purposes. Most variables are set the same as PyPy.
     The existence of this section does not imply that anything works or is even tested */
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #define CYTHON_COMPILING_IN_LIMITED_API 0
  #define CYTHON_COMPILING_IN_GRAAL 1
  #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0
  #undef CYTHON_USE_TYPE_SLOTS
  #define CYTHON_USE_TYPE_SLOTS 0
  #undef CYTHON_USE_TYPE_SPECS
  #define CYTHON_USE_TYPE_SPECS 0
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #undef CYTHON_USE_UNICODE_INTERNALS
  #define CYTHON_USE_UNICODE_INTERNALS 0
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #undef CYTHON_AVOID_BORROWED_REFS
  #define CYTHON_AVOID_BORROWED_REFS 1
  #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0
  #undef CYTHON_ASSUME_SAFE_MACROS
  #define CYTHON_ASSUME_SAFE_MACROS 0
  #undef CYTHON_ASSUME_SAFE_SIZE
  #define CYTHON_ASSUME_SAFE_SIZE 0
  #undef CYTHON_UNPACK_METHODS
  #define CYTHON_UNPACK_METHODS 0
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_GIL
  #define CYTHON_FAST_GIL 0
  #undef CYTHON_METH_FASTCALL
  #define CYTHON_METH_FASTCALL 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #ifndef CYTHON_PEP487_INIT_SUBCLASS
    #define CYTHON_PEP487_INIT_SUBCLASS 1
  #endif
  #undef CYTHON_PEP489_MULTI_PHASE_INIT
  #define CYTHON_PEP489_MULTI_PHASE_INIT 1
  #undef CYTHON_USE_MODULE_STATE
  #define CYTHON_USE_MODULE_STATE 0
  #undef CYTHON_USE_SYS_MONITORING
  #define CYTHON_USE_SYS_MONITORING 0
  #undef CYTHON_USE_TP_FINALIZE
  #define CYTHON_USE_TP_FINALIZE 0
  #undef CYTHON_USE_AM_SEND
  #define CYTHON_USE_AM_SEND 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 1
  #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
    #define CYTHON_UPDATE_DESCRIPTOR_DOC 0
  #endif
  #undef CYTHON_USE_FREELISTS
  #define CYTHON_USE_FREELISTS 0
  #undef CYTHON_IMMORTAL_CONSTANTS
  #define CYTHON_IMMORTAL_CONSTANTS 0
#elif defined(PYPY_VERSION)
  #define CYTHON_COMPILING_IN_PYPY 1
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #define CYTHON_COMPILING_IN_LIMITED_API 0
  #define CYTHON_COMPILING_IN_GRAAL 0
  #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0
  #undef CYTHON_USE_TYPE_SLOTS
  #define CYTHON_USE_TYPE_SLOTS 1
  #ifndef CYTHON_USE_TYPE_SPECS
    #define CYTHON_USE_TYPE_SPECS 0
  #endif
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #undef CYTHON_USE_UNICODE_INTERNALS
  #define CYTHON_USE_UNICODE_INTERNALS 0
  #undef CYTHON_USE_UNICODE_WRITER
  #define CYTHON_USE_UNICODE_WRITER 0
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #undef CYTHON_AVOID_BORROWED_REFS
  #define CYTHON_AVOID_BORROWED_REFS 1
  #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 1
  #undef CYTHON_ASSUME_SAFE_MACROS
  #define CYTHON_ASSUME_SAFE_MACROS 0
  #ifndef CYTHON_ASSUME_SAFE_SIZE
    #define CYTHON_ASSUME_SAFE_SIZE 1
  #endif
  #undef CYTHON_UNPACK_METHODS
  #define CYTHON_UNPACK_METHODS 0
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_GIL
  #define CYTHON_FAST_GIL 0
  #undef CYTHON_METH_FASTCALL
  #define CYTHON_METH_FASTCALL 0
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #ifndef CYTHON_PEP487_INIT_SUBCLASS
    #define CYTHON_PEP487_INIT_SUBCLASS 1
  #endif
  #if PY_VERSION_HEX < 0x03090000
    #undef CYTHON_PEP489_MULTI_PHASE_INIT
    #define CYTHON_PEP489_MULTI_PHASE_INIT 0
  #elif !defined(CYTHON_PEP489_MULTI_PHASE_INIT)
    #define CYTHON_PEP489_MULTI_PHASE_INIT 1
  #endif
  #undef CYTHON_USE_MODULE_STATE
  #define CYTHON_USE_MODULE_STATE 0
  #undef CYTHON_USE_SYS_MONITORING
  #define CYTHON_USE_SYS_MONITORING 0
  #ifndef CYTHON_USE_TP_FINALIZE
    #define CYTHON_USE_TP_FINALIZE (PYPY_VERSION_NUM >= 0x07030C00)
  #endif
  #undef CYTHON_USE_AM_SEND
  #define CYTHON_USE_AM_SEND 0
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
  #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
    #define CYTHON_UPDATE_DESCRIPTOR_DOC (PYPY_VERSION_NUM >= 0x07031100)
  #endif
  #undef CYTHON_USE_FREELISTS
  #define CYTHON_USE_FREELISTS 0
  #undef CYTHON_IMMORTAL_CONSTANTS
  #define CYTHON_IMMORTAL_CONSTANTS 0
#elif defined(CYTHON_LIMITED_API)
  #ifdef Py_LIMITED_API
    #undef __PYX_LIMITED_VERSION_HEX
    #define __PYX_LIMITED_VERSION_HEX Py_LIMITED_API
  #endif
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_CPYTHON 0
  #define CYTHON_COMPILING_IN_LIMITED_API 1
  #define CYTHON_COMPILING_IN_GRAAL 0
  #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0
  #undef CYTHON_USE_TYPE_SLOTS
  #define CYTHON_USE_TYPE_SLOTS 0
  #undef CYTHON_USE_TYPE_SPECS
  #define CYTHON_USE_TYPE_SPECS 1
  #undef CYTHON_USE_PYTYPE_LOOKUP
  #define CYTHON_USE_PYTYPE_LOOKUP 0
  #undef CYTHON_USE_PYLIST_INTERNALS
  #define CYTHON_USE_PYLIST_INTERNALS 0
  #undef CYTHON_USE_UNICODE_INTERNALS
  #define CYTHON_USE_UNICODE_INTERNALS 0
  #ifndef CYTHON_USE_UNICODE_WRITER
    #define CYTHON_USE_UNICODE_WRITER 0
  #endif
  #undef CYTHON_USE_PYLONG_INTERNALS
  #define CYTHON_USE_PYLONG_INTERNALS 0
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
    #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0
  #endif
  #undef CYTHON_ASSUME_SAFE_MACROS
  #define CYTHON_ASSUME_SAFE_MACROS 0
  #undef CYTHON_ASSUME_SAFE_SIZE
  #define CYTHON_ASSUME_SAFE_SIZE 0
  #undef CYTHON_UNPACK_METHODS
  #define CYTHON_UNPACK_METHODS 0
  #undef CYTHON_FAST_THREAD_STATE
  #define CYTHON_FAST_THREAD_STATE 0
  #undef CYTHON_FAST_GIL
  #define CYTHON_FAST_GIL 0
  #undef CYTHON_METH_FASTCALL
  #define CYTHON_METH_FASTCALL (__PYX_LIMITED_VERSION_HEX >= 0x030C0000)
  #undef CYTHON_FAST_PYCALL
  #define CYTHON_FAST_PYCALL 0
  #ifndef CYTHON_PEP487_INIT_SUBCLASS
    #define CYTHON_PEP487_INIT_SUBCLASS 1
  #endif
  #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
    #define CYTHON_PEP489_MULTI_PHASE_INIT 1
  #endif
  #ifndef CYTHON_USE_MODULE_STATE
    #define CYTHON_USE_MODULE_STATE 0
  #endif
  #undef CYTHON_USE_SYS_MONITORING
  #define CYTHON_USE_SYS_MONITORING 0
  #ifndef CYTHON_USE_TP_FINALIZE
    #define CYTHON_USE_TP_FINALIZE 0
  #endif
  #ifndef CYTHON_USE_AM_SEND
    #define CYTHON_USE_AM_SEND (__PYX_LIMITED_VERSION_HEX >= 0x030A0000)
  #endif
  #undef CYTHON_USE_DICT_VERSIONS
  #define CYTHON_USE_DICT_VERSIONS 0
  #undef CYTHON_USE_EXC_INFO_STACK
  #define CYTHON_USE_EXC_INFO_STACK 0
  #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
    #define CYTHON_UPDATE_DESCRIPTOR_DOC 0
  #endif
  #ifndef CYTHON_USE_FREELISTS
  #define CYTHON_USE_FREELISTS 1
  #endif
  #undef CYTHON_IMMORTAL_CONSTANTS
  #define CYTHON_IMMORTAL_CONSTANTS 0
#else
  #define CYTHON_COMPILING_IN_PYPY 0
  #define CYTHON_COMPILING_IN_CPYTHON 1
  #define CYTHON_COMPILING_IN_LIMITED_API 0
  #define CYTHON_COMPILING_IN_GRAAL 0
  #ifdef Py_GIL_DISABLED
    #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 1
  #else
    #define CYTHON_COMPILING_IN_CPYTHON_FREETHREADING 0
  #endif
  #if PY_VERSION_HEX < 0x030A0000
    #undef CYTHON_USE_TYPE_SLOTS
    #define CYTHON_USE_TYPE_SLOTS 1
  #elif !defined(CYTHON_USE_TYPE_SLOTS)
    #define CYTHON_USE_TYPE_SLOTS 1
  #endif
  #ifndef CYTHON_USE_TYPE_SPECS
    #define CYTHON_USE_TYPE_SPECS 0
  #endif
  #ifndef CYTHON_USE_PYTYPE_LOOKUP
    #define CYTHON_USE_PYTYPE_LOOKUP 1
  #endif
  #ifndef CYTHON_USE_PYLONG_INTERNALS
    #define CYTHON_USE_PYLONG_INTERNALS 1
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
    #undef CYTHON_USE_PYLIST_INTERNALS
    #define CYTHON_USE_PYLIST_INTERNALS 0
  #elif !defined(CYTHON_USE_PYLIST_INTERNALS)
    #define CYTHON_USE_PYLIST_INTERNALS 1
  #endif
  #ifndef CYTHON_USE_UNICODE_INTERNALS
    #define CYTHON_USE_UNICODE_INTERNALS 1
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING || PY_VERSION_HEX >= 0x030B00A2
    #undef CYTHON_USE_UNICODE_WRITER
    #define CYTHON_USE_UNICODE_WRITER 0
  #elif !defined(CYTHON_USE_UNICODE_WRITER)
    #define CYTHON_USE_UNICODE_WRITER 1
  #endif
  #ifndef CYTHON_AVOID_BORROWED_REFS
    #define CYTHON_AVOID_BORROWED_REFS 0
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
    #undef CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
    #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 1
  #elif !defined(CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS)
    #define CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS 0
  #endif
  #ifndef CYTHON_ASSUME_SAFE_MACROS
    #define CYTHON_ASSUME_SAFE_MACROS 1
  #endif
  #ifndef CYTHON_ASSUME_SAFE_SIZE
    #define CYTHON_ASSUME_SAFE_SIZE 1
  #endif
  #ifndef CYTHON_UNPACK_METHODS
    #define CYTHON_UNPACK_METHODS 1
  #endif
  #ifndef CYTHON_FAST_THREAD_STATE
    #define CYTHON_FAST_THREAD_STATE 1
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
    #undef CYTHON_FAST_GIL
    #define CYTHON_FAST_GIL 0
  #elif !defined(CYTHON_FAST_GIL)
    #define CYTHON_FAST_GIL (PY_VERSION_HEX < 0x030C00A6)
  #endif
  #ifndef CYTHON_METH_FASTCALL
    #define CYTHON_METH_FASTCALL 1
  #endif
  #ifndef CYTHON_FAST_PYCALL
    #define CYTHON_FAST_PYCALL 1
  #endif
  #ifndef CYTHON_PEP487_INIT_SUBCLASS
    #define CYTHON_PEP487_INIT_SUBCLASS 1
  #endif
  #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
    #define CYTHON_PEP489_MULTI_PHASE_INIT 1
  #endif
  #ifndef CYTHON_USE_MODULE_STATE
    #define CYTHON_USE_MODULE_STATE 0
  #endif
  #ifndef CYTHON_USE_SYS_MONITORING
    #define CYTHON_USE_SYS_MONITORING (PY_VERSION_HEX >= 0x030d00B1)
  #endif
  #ifndef CYTHON_USE_TP_FINALIZE
    #define CYTHON_USE_TP_FINALIZE 1
  #endif
  #ifndef CYTHON_USE_AM_SEND
    #define CYTHON_USE_AM_SEND 1
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
    #undef CYTHON_USE_DICT_VERSIONS
    #define CYTHON_USE_DICT_VERSIONS 0
  #elif !defined(CYTHON_USE_DICT_VERSIONS)
    #define CYTHON_USE_DICT_VERSIONS  (PY_VERSION_HEX < 0x030C00A5 && !CYTHON_USE_MODULE_STATE)
  #endif
  #ifndef CYTHON_USE_EXC_INFO_STACK
    #define CYTHON_USE_EXC_INFO_STACK 1
  #endif
  #ifndef CYTHON_UPDATE_DESCRIPTOR_DOC
    #define CYTHON_UPDATE_DESCRIPTOR_DOC 1
  #endif
  #ifndef CYTHON_USE_FREELISTS
    #define CYTHON_USE_FREELISTS (!CYTHON_COMPILING_IN_CPYTHON_FREETHREADING)
  #endif
  #if defined(CYTHON_IMMORTAL_CONSTANTS) && PY_VERSION_HEX < 0x030C0000
    #undef CYTHON_IMMORTAL_CONSTANTS
    #define CYTHON_IMMORTAL_CONSTANTS 0  // definitely won't work
  #elif !defined(CYTHON_IMMORTAL_CONSTANTS)
    #define CYTHON_IMMORTAL_CONSTANTS (PY_VERSION_HEX >= 0x030C0000 && !CYTHON_USE_MODULE_STATE && CYTHON_COMPILING_IN_CPYTHON_FREETHREADING)
  #endif
#endif
#ifndef CYTHON_COMPRESS_STRINGS
  #define CYTHON_COMPRESS_STRINGS 1
#endif
#ifndef CYTHON_FAST_PYCCALL
#define CYTHON_FAST_PYCCALL  CYTHON_FAST_PYCALL
#endif
#ifndef CYTHON_VECTORCALL
#if CYTHON_COMPILING_IN_LIMITED_API
#define CYTHON_VECTORCALL  (__PYX_LIMITED_VERSION_HEX >= 0x030C0000)
#else
#define CYTHON_VECTORCALL  (CYTHON_FAST_PYCCALL)
#endif
#endif
#if CYTHON_USE_PYLONG_INTERNALS
  #undef SHIFT
  #undef BASE
  #undef MASK
  #ifdef SIZEOF_VOID_P
    enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
  #endif
#endif
#ifndef __has_attribute
  #define __has_attribute(x) 0
#endif
#ifndef __has_cpp_attribute
  #define __has_cpp_attribute(x) 0
#endif
#ifndef CYTHON_RESTRICT
  #if defined(__GNUC__)
    #define CYTHON_RESTRICT __restrict__
  #elif defined(_MSC_VER) && _MSC_VER >= 1400
    #define CYTHON_RESTRICT __restrict
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_RESTRICT restrict
  #else
    #define CYTHON_RESTRICT
  #endif
#endif
#ifndef CYTHON_UNUSED
  #if defined(__cplusplus)
    /* for clang __has_cpp_attribute(maybe_unused) is true even before C++17
     * but leads to warnings with -pedantic, since it is a C++17 feature */
    #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
      #if __has_cpp_attribute(maybe_unused)
        #define CYTHON_UNUSED [[maybe_unused]]
      #endif
    #endif
  #endif
#endif
#ifndef CYTHON_UNUSED
# if defined(__GNUC__)
#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
#     define CYTHON_UNUSED __attribute__ ((__unused__))
#   else
#     define CYTHON_UNUSED
#   endif
# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
#   define CYTHON_UNUSED __attribute__ ((__unused__))
# else
#   define CYTHON_UNUSED
# endif
#endif
#ifndef CYTHON_UNUSED_VAR
#  if defined(__cplusplus)
     template<class T> void CYTHON_UNUSED_VAR( const T& ) { }
#  else
#    define CYTHON_UNUSED_VAR(x) (void)(x)
#  endif
#endif
#ifndef CYTHON_MAYBE_UNUSED_VAR
  #define CYTHON_MAYBE_UNUSED_VAR(x) CYTHON_UNUSED_VAR(x)
#endif
#ifndef CYTHON_NCP_UNUSED
# if CYTHON_COMPILING_IN_CPYTHON && !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
#  define CYTHON_NCP_UNUSED
# else
#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
# endif
#endif
#ifndef CYTHON_USE_CPP_STD_MOVE
  #if defined(__cplusplus) && (\
    __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600))
    #define CYTHON_USE_CPP_STD_MOVE 1
  #else
    #define CYTHON_USE_CPP_STD_MOVE 0
  #endif
#endif
#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
#include <stdint.h>
typedef uintptr_t  __pyx_uintptr_t;
#ifndef CYTHON_FALLTHROUGH
  #if defined(__cplusplus)
    /* for clang __has_cpp_attribute(fallthrough) is true even before C++17
     * but leads to warnings with -pedantic, since it is a C++17 feature */
    #if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
      #if __has_cpp_attribute(fallthrough)
        #define CYTHON_FALLTHROUGH [[fallthrough]]
      #endif
    #endif
    #ifndef CYTHON_FALLTHROUGH
      #if __has_cpp_attribute(clang::fallthrough)
        #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
      #elif __has_cpp_attribute(gnu::fallthrough)
        #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
      #endif
    #endif
  #endif
  #ifndef CYTHON_FALLTHROUGH
    #if __has_attribute(fallthrough)
      #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
    #else
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
  #if defined(__clang__) && defined(__apple_build_version__)
    #if __apple_build_version__ < 7000000
      #undef  CYTHON_FALLTHROUGH
      #define CYTHON_FALLTHROUGH
    #endif
  #endif
#endif
#ifndef Py_UNREACHABLE
  #define Py_UNREACHABLE()  assert(0); abort()
#endif
#ifdef __cplusplus
  template <typename T>
  struct __PYX_IS_UNSIGNED_IMPL {static const bool value = T(0) < T(-1);};
  #define __PYX_IS_UNSIGNED(type) (__PYX_IS_UNSIGNED_IMPL<type>::value)
#else
  #define __PYX_IS_UNSIGNED(type) (((type)-1) > 0)
#endif
#if CYTHON_COMPILING_IN_PYPY == 1
  #define __PYX_NEED_TP_PRINT_SLOT  (PY_VERSION_HEX < 0x030A0000)
#else
  #define __PYX_NEED_TP_PRINT_SLOT  (PY_VERSION_HEX < 0x03090000)
#endif
#define __PYX_REINTERPRET_FUNCION(func_pointer, other_pointer) ((func_pointer)(void(*)(void))(other_pointer))

/* CInitCode */
#ifndef CYTHON_INLINE
  #if defined(__clang__)
    #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
  #elif defined(__GNUC__)
    #define CYTHON_INLINE __inline__
  #elif defined(_MSC_VER)
    #define CYTHON_INLINE __inline
  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define CYTHON_INLINE inline
  #else
    #define CYTHON_INLINE
  #endif
#endif

/* PythonCompatibility */
#define __PYX_BUILD_PY_SSIZE_T "n"
#define CYTHON_FORMAT_SSIZE_T "z"
#define __Pyx_BUILTIN_MODULE_NAME "builtins"
#define __Pyx_DefaultClassType PyType_Type
#if CYTHON_COMPILING_IN_LIMITED_API
    #ifndef CO_OPTIMIZED
    static int CO_OPTIMIZED;
    #endif
    #ifndef CO_NEWLOCALS
    static int CO_NEWLOCALS;
    #endif
    #ifndef CO_VARARGS
    static int CO_VARARGS;
    #endif
    #ifndef CO_VARKEYWORDS
    static int CO_VARKEYWORDS;
    #endif
    #ifndef CO_ASYNC_GENERATOR
    static int CO_ASYNC_GENERATOR;
    #endif
    #ifndef CO_GENERATOR
    static int CO_GENERATOR;
    #endif
    #ifndef CO_COROUTINE
    static int CO_COROUTINE;
    #endif
#else
    #ifndef CO_COROUTINE
      #define CO_COROUTINE 0x80
    #endif
    #ifndef CO_ASYNC_GENERATOR
      #define CO_ASYNC_GENERATOR 0x200
    #endif
#endif
static int __Pyx_init_co_variables(void);
#if PY_VERSION_HEX >= 0x030900A4 || defined(Py_IS_TYPE)
  #define __Pyx_IS_TYPE(ob, type) Py_IS_TYPE(ob, type)
#else
  #define __Pyx_IS_TYPE(ob, type) (((const PyObject*)ob)->ob_type == (type))
#endif
#if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_Is)
  #define __Pyx_Py_Is(x, y)  Py_Is(x, y)
#else
  #define __Pyx_Py_Is(x, y) ((x) == (y))
#endif
#if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsNone)
  #define __Pyx_Py_IsNone(ob) Py_IsNone(ob)
#else
  #define __Pyx_Py_IsNone(ob) __Pyx_Py_Is((ob), Py_None)
#endif
#if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsTrue)
  #define __Pyx_Py_IsTrue(ob) Py_IsTrue(ob)
#else
  #define __Pyx_Py_IsTrue(ob) __Pyx_Py_Is((ob), Py_True)
#endif
#if PY_VERSION_HEX >= 0x030A00B1 || defined(Py_IsFalse)
  #define __Pyx_Py_IsFalse(ob) Py_IsFalse(ob)
#else
  #define __Pyx_Py_IsFalse(ob) __Pyx_Py_Is((ob), Py_False)
#endif
#define __Pyx_NoneAsNull(obj)  (__Pyx_Py_IsNone(obj) ? NULL : (obj))
#if PY_VERSION_HEX >= 0x030900F0 && !CYTHON_COMPILING_IN_PYPY
  #define __Pyx_PyObject_GC_IsFinalized(o) PyObject_GC_IsFinalized(o)
#else
  #define __Pyx_PyObject_GC_IsFinalized(o) _PyGC_FINALIZED(o)
#endif
#ifndef Py_TPFLAGS_CHECKTYPES
  #define Py_TPFLAGS_CHECKTYPES 0
#endif
#ifndef Py_TPFLAGS_HAVE_INDEX
  #define Py_TPFLAGS_HAVE_INDEX 0
#endif
#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
#endif
#ifndef Py_TPFLAGS_HAVE_FINALIZE
  #define Py_TPFLAGS_HAVE_FINALIZE 0
#endif
#ifndef Py_TPFLAGS_SEQUENCE
  #define Py_TPFLAGS_SEQUENCE 0
#endif
#ifndef Py_TPFLAGS_MAPPING
  #define Py_TPFLAGS_MAPPING 0
#endif
#ifndef Py_TPFLAGS_IMMUTABLETYPE
  #define Py_TPFLAGS_IMMUTABLETYPE (1UL << 8)
#endif
#ifndef Py_TPFLAGS_DISALLOW_INSTANTIATION
  #define Py_TPFLAGS_DISALLOW_INSTANTIATION (1UL << 7)
#endif
#ifndef METH_STACKLESS
  #define METH_STACKLESS 0
#endif
#ifndef METH_FASTCALL
  #ifndef METH_FASTCALL
     #define METH_FASTCALL 0x80
  #endif
  typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
  typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
                                                          Py_ssize_t nargs, PyObject *kwnames);
#else
  #if PY_VERSION_HEX >= 0x030d00A4
  #  define __Pyx_PyCFunctionFast PyCFunctionFast
  #  define __Pyx_PyCFunctionFastWithKeywords PyCFunctionFastWithKeywords
  #else
  #  define __Pyx_PyCFunctionFast _PyCFunctionFast
  #  define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
  #endif
#endif
#if CYTHON_METH_FASTCALL
  #define __Pyx_METH_FASTCALL METH_FASTCALL
  #define __Pyx_PyCFunction_FastCall __Pyx_PyCFunctionFast
  #define __Pyx_PyCFunction_FastCallWithKeywords __Pyx_PyCFunctionFastWithKeywords
#else
  #define __Pyx_METH_FASTCALL METH_VARARGS
  #define __Pyx_PyCFunction_FastCall PyCFunction
  #define __Pyx_PyCFunction_FastCallWithKeywords PyCFunctionWithKeywords
#endif
#if CYTHON_VECTORCALL
  #define __pyx_vectorcallfunc vectorcallfunc
  #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET  PY_VECTORCALL_ARGUMENTS_OFFSET
  #define __Pyx_PyVectorcall_NARGS(n)  PyVectorcall_NARGS((size_t)(n))
#else
  #define __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET  0
  #define __Pyx_PyVectorcall_NARGS(n)  ((Py_ssize_t)(n))
#endif
#if PY_VERSION_HEX >= 0x030900B1
#define __Pyx_PyCFunction_CheckExact(func)  PyCFunction_CheckExact(func)
#else
#define __Pyx_PyCFunction_CheckExact(func)  PyCFunction_Check(func)
#endif
#define __Pyx_CyOrPyCFunction_Check(func)  PyCFunction_Check(func)
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_CyOrPyCFunction_GET_FUNCTION(func)  (((PyCFunctionObject*)(func))->m_ml->ml_meth)
#elif !CYTHON_COMPILING_IN_LIMITED_API
#define __Pyx_CyOrPyCFunction_GET_FUNCTION(func)  PyCFunction_GET_FUNCTION(func)
#endif
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_CyOrPyCFunction_GET_FLAGS(func)  (((PyCFunctionObject*)(func))->m_ml->ml_flags)
static CYTHON_INLINE PyObject* __Pyx_CyOrPyCFunction_GET_SELF(PyObject *func) {
    return (__Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_STATIC) ? NULL : ((PyCFunctionObject*)func)->m_self;
}
#endif
static CYTHON_INLINE int __Pyx__IsSameCFunction(PyObject *func, void (*cfunc)(void)) {
#if CYTHON_COMPILING_IN_LIMITED_API
    return PyCFunction_Check(func) && PyCFunction_GetFunction(func) == (PyCFunction) cfunc;
#else
    return PyCFunction_Check(func) && PyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc;
#endif
}
#define __Pyx_IsSameCFunction(func, cfunc)   __Pyx__IsSameCFunction(func, cfunc)
#if PY_VERSION_HEX < 0x03090000 || (CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000)
  #define __Pyx_PyType_FromModuleAndSpec(m, s, b)  ((void)m, PyType_FromSpecWithBases(s, b))
  typedef PyObject *(*__Pyx_PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *, size_t, PyObject *);
#else
  #define __Pyx_PyType_FromModuleAndSpec(m, s, b)  PyType_FromModuleAndSpec(m, s, b)
  #define __Pyx_PyCMethod  PyCMethod
#endif
#ifndef METH_METHOD
  #define METH_METHOD 0x200
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
  #define PyObject_Malloc(s)   PyMem_Malloc(s)
  #define PyObject_Free(p)     PyMem_Free(p)
  #define PyObject_Realloc(p)  PyMem_Realloc(p)
#endif
#if CYTHON_COMPILING_IN_LIMITED_API
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno)
#elif CYTHON_COMPILING_IN_GRAAL && defined(GRAALPY_VERSION_NUM) && GRAALPY_VERSION_NUM > 0x19000000
  #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno) GraalPyFrame_SetLineNumber((frame), (lineno))
#elif CYTHON_COMPILING_IN_GRAAL
  #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno) _PyFrame_SetLineNumber((frame), (lineno))
#else
  #define __Pyx_PyCode_HasFreeVars(co)  (PyCode_GetNumFree(co) > 0)
  #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
#endif
#if CYTHON_COMPILING_IN_LIMITED_API
  #define __Pyx_PyThreadState_Current PyThreadState_Get()
#elif !CYTHON_FAST_THREAD_STATE
  #define __Pyx_PyThreadState_Current PyThreadState_GET()
#elif PY_VERSION_HEX >= 0x030d00A1
  #define __Pyx_PyThreadState_Current PyThreadState_GetUnchecked()
#else
  #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
#endif
#if CYTHON_USE_MODULE_STATE
static CYTHON_INLINE void *__Pyx__PyModule_GetState(PyObject *op)
{
    void *result;
    result = PyModule_GetState(op);
    if (!result)
        Py_FatalError("Couldn't find the module state");
    return result;
}
#define __Pyx_PyModule_GetState(o) (__pyx_mstatetype *)__Pyx__PyModule_GetState(o)
#else
#define __Pyx_PyModule_GetState(op) ((void)op,__pyx_mstate_global)
#endif
#define __Pyx_PyObject_GetSlot(obj, name, func_ctype)  __Pyx_PyType_GetSlot(Py_TYPE((PyObject *) obj), name, func_ctype)
#define __Pyx_PyObject_TryGetSlot(obj, name, func_ctype) __Pyx_PyType_TryGetSlot(Py_TYPE(obj), name, func_ctype)
#define __Pyx_PyObject_GetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_GetSubSlot(Py_TYPE(obj), sub, name, func_ctype)
#define __Pyx_PyObject_TryGetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_TryGetSubSlot(Py_TYPE(obj), sub, name, func_ctype)
#if CYTHON_USE_TYPE_SLOTS
  #define __Pyx_PyType_GetSlot(type, name, func_ctype)  ((type)->name)
  #define __Pyx_PyType_TryGetSlot(type, name, func_ctype) __Pyx_PyType_GetSlot(type, name, func_ctype)
  #define __Pyx_PyType_GetSubSlot(type, sub, name, func_ctype) (((type)->sub) ? ((type)->sub->name) : NULL)
  #define __Pyx_PyType_TryGetSubSlot(type, sub, name, func_ctype) __Pyx_PyType_GetSubSlot(type, sub, name, func_ctype)
#else
  #define __Pyx_PyType_GetSlot(type, name, func_ctype)  ((func_ctype) PyType_GetSlot((type), Py_##name))
  #define __Pyx_PyType_TryGetSlot(type, name, func_ctype)\
    ((__PYX_LIMITED_VERSION_HEX >= 0x030A0000 ||\
     (PyType_GetFlags(type) & Py_TPFLAGS_HEAPTYPE) || __Pyx_get_runtime_version() >= 0x030A0000) ?\
     __Pyx_PyType_GetSlot(type, name, func_ctype) : NULL)
  #define __Pyx_PyType_GetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_GetSlot(obj, name, func_ctype)
  #define __Pyx_PyType_TryGetSubSlot(obj, sub, name, func_ctype) __Pyx_PyType_TryGetSlot(obj, name, func_ctype)
#endif
#if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
#define __Pyx_PyDict_NewPresized(n)  ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
#else
#define __Pyx_PyDict_NewPresized(n)  PyDict_New()
#endif
#define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
#define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_UNICODE_INTERNALS
#define __Pyx_PyDict_GetItemStrWithError(dict, name)  _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStr(PyObject *dict, PyObject *name) {
    PyObject *res = __Pyx_PyDict_GetItemStrWithError(dict, name);
    if (res == NULL) PyErr_Clear();
    return res;
}
#elif !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07020000
#define __Pyx_PyDict_GetItemStrWithError  PyDict_GetItemWithError
#define __Pyx_PyDict_GetItemStr           PyDict_GetItem
#else
static CYTHON_INLINE PyObject * __Pyx_PyDict_GetItemStrWithError(PyObject *dict, PyObject *name) {
#if CYTHON_COMPILING_IN_PYPY
    return PyDict_GetItem(dict, name);
#else
    PyDictEntry *ep;
    PyDictObject *mp = (PyDictObject*) dict;
    long hash = ((PyStringObject *) name)->ob_shash;
    assert(hash != -1);
    ep = (mp->ma_lookup)(mp, name, hash);
    if (ep == NULL) {
        return NULL;
    }
    return ep->me_value;
#endif
}
#define __Pyx_PyDict_GetItemStr           PyDict_GetItem
#endif
#if CYTHON_USE_TYPE_SLOTS
  #define __Pyx_PyType_GetFlags(tp)   (((PyTypeObject *)tp)->tp_flags)
  #define __Pyx_PyType_HasFeature(type, feature)  ((__Pyx_PyType_GetFlags(type) & (feature)) != 0)
#else
  #define __Pyx_PyType_GetFlags(tp)   (PyType_GetFlags((PyTypeObject *)tp))
  #define __Pyx_PyType_HasFeature(type, feature)  PyType_HasFeature(type, feature)
#endif
#define __Pyx_PyObject_GetIterNextFunc(iterator)  __Pyx_PyObject_GetSlot(iterator, tp_iternext, iternextfunc)
#if CYTHON_USE_TYPE_SPECS
#define __Pyx_PyHeapTypeObject_GC_Del(obj)  {\
    PyTypeObject *type = Py_TYPE((PyObject*)obj);\
    assert(__Pyx_PyType_HasFeature(type, Py_TPFLAGS_HEAPTYPE));\
    PyObject_GC_Del(obj);\
    Py_DECREF(type);\
}
#else
#define __Pyx_PyHeapTypeObject_GC_Del(obj)  PyObject_GC_Del(obj)
#endif
#if CYTHON_COMPILING_IN_LIMITED_API
  #define __Pyx_PyUnicode_READY(op)       (0)
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_ReadChar(u, i)
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   ((void)u, 1114111U)
  #define __Pyx_PyUnicode_KIND(u)         ((void)u, (0))
  #define __Pyx_PyUnicode_DATA(u)         ((void*)u)
  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)k, PyUnicode_ReadChar((PyObject*)(d), i))
  #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GetLength(u))
#else
  #if PY_VERSION_HEX >= 0x030C0000
    #define __Pyx_PyUnicode_READY(op)       (0)
  #else
    #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ?\
                                                0 : _PyUnicode_Ready((PyObject *)(op)))
  #endif
  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
  #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u)   PyUnicode_MAX_CHAR_VALUE(u)
  #define __Pyx_PyUnicode_KIND(u)         ((int)PyUnicode_KIND(u))
  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
  #define __Pyx_PyUnicode_WRITE(k, d, i, ch)  PyUnicode_WRITE(k, d, i, (Py_UCS4) ch)
  #if PY_VERSION_HEX >= 0x030C0000
    #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != PyUnicode_GET_LENGTH(u))
  #else
    #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x03090000
    #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : ((PyCompactUnicodeObject *)(u))->wstr_length))
    #else
    #define __Pyx_PyUnicode_IS_TRUE(u)      (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
    #endif
  #endif
#endif
#if CYTHON_COMPILING_IN_PYPY
  #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
#else
  #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
  #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
      PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
#endif
#if CYTHON_COMPILING_IN_PYPY
  #if !defined(PyUnicode_DecodeUnicodeEscape)
    #define PyUnicode_DecodeUnicodeEscape(s, size, errors)  PyUnicode_Decode(s, size, "unicode_escape", errors)
  #endif
  #if !defined(PyUnicode_Contains)
    #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
  #endif
  #if !defined(PyByteArray_Check)
    #define PyByteArray_Check(obj)  PyObject_TypeCheck(obj, &PyByteArray_Type)
  #endif
  #if !defined(PyObject_Format)
    #define PyObject_Format(obj, fmt)  PyObject_CallMethod(obj, "__format__", "O", fmt)
  #endif
#endif
#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  #define __Pyx_PySequence_ListKeepNew(obj)\
    (likely(PyList_CheckExact(obj) && PyUnstable_Object_IsUniquelyReferenced(obj)) ? __Pyx_NewRef(obj) : PySequence_List(obj))
#elif CYTHON_COMPILING_IN_CPYTHON
  #define __Pyx_PySequence_ListKeepNew(obj)\
    (likely(PyList_CheckExact(obj) && Py_REFCNT(obj) == 1) ? __Pyx_NewRef(obj) : PySequence_List(obj))
#else
  #define __Pyx_PySequence_ListKeepNew(obj)  PySequence_List(obj)
#endif
#ifndef PySet_CheckExact
  #define PySet_CheckExact(obj)        __Pyx_IS_TYPE(obj, &PySet_Type)
#endif
#if PY_VERSION_HEX >= 0x030900A4
  #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
  #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
#else
  #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
  #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
#endif
enum __Pyx_ReferenceSharing {
  __Pyx_ReferenceSharing_DefinitelyUnique, // We created it so we know it's unshared - no need to check
  __Pyx_ReferenceSharing_OwnStrongReference,
  __Pyx_ReferenceSharing_FunctionArgument,
  __Pyx_ReferenceSharing_SharedReference, // Never trust it to be unshared because it's a global or similar
};
#if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && PY_VERSION_HEX >= 0x030E0000
#define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing)\
    (sharing == __Pyx_ReferenceSharing_DefinitelyUnique ? 1 :\
      (sharing == __Pyx_ReferenceSharing_FunctionArgument ? PyUnstable_Object_IsUniqueReferencedTemporary(o) :\
      (sharing == __Pyx_ReferenceSharing_OwnStrongReference ? PyUnstable_Object_IsUniquelyReferenced(o) : 0)))
#elif (CYTHON_COMPILING_IN_CPYTHON && !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING) || CYTHON_COMPILING_IN_LIMITED_API
#define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing) (((void)sharing), Py_REFCNT(o) == 1)
#else
#define __Pyx_IS_UNIQUELY_REFERENCED(o, sharing) (((void)o), ((void)sharing), 0)
#endif
#if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  #define __Pyx_PyList_GetItemRef(o, i) PyList_GetItemRef(o, i)
#elif CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  #if CYTHON_COMPILING_IN_LIMITED_API || !CYTHON_ASSUME_SAFE_MACROS
    #define __Pyx_PyList_GetItemRef(o, i) (likely((i) >= 0) ? PySequence_GetItem(o, i) : (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
  #else
    #define __Pyx_PyList_GetItemRef(o, i) PySequence_ITEM(o, i)
  #endif
#elif CYTHON_COMPILING_IN_LIMITED_API || !(CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE)
  #define __Pyx_PyList_GetItemRef(o, i) __Pyx_XNewRef(PyList_GetItem(o, i))
#else
  #define __Pyx_PyList_GetItemRef(o, i) (likely(__Pyx_is_valid_index(i, PyList_GET_SIZE(o))) ?\
    __Pyx_NewRef(PyList_GET_ITEM(o, i)) : (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
#endif
#if CYTHON_AVOID_BORROWED_REFS || CYTHON_COMPILING_IN_LIMITED_API
  #define __Pyx_PyList_GET_ITEM_REF(o, i, unsafe_shared)  ((void)(unsafe_shared),\
      __Pyx_PyList_GetItemRef(o, i))
#elif CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
  #if CYTHON_ASSUME_SAFE_MACROS
  #define __Pyx_PyList_GET_ITEM_REF(o, i, unsafe_shared) (\
      __Pyx_IS_UNIQUELY_REFERENCED(o, unsafe_shared) ?\
      __Pyx_NewRef(PyList_GET_ITEM(o, i)) : __Pyx_PyList_GetItemRef(o, i))
  #else
  #define __Pyx_PyList_GET_ITEM_REF(o, i, unsafe_shared) (\
      __Pyx_IS_UNIQUELY_REFERENCED(o, unsafe_shared) ?\
      __Pyx_XNewRef(PyList_GetItem(o, i)) : __Pyx_PyList_GetItemRef(o, i))
  #endif
#elif CYTHON_ASSUME_SAFE_MACROS
  #define __Pyx_PyList_GET_ITEM_REF(o, i, unsafe_shared)  ((void)(unsafe_shared),\
      __Pyx_NewRef(PyList_GET_ITEM(o, i)))
#else
  #define __Pyx_PyList_GET_ITEM_REF(o, i, unsafe_shared)  ((void)(unsafe_shared),\
      __Pyx_XNewRef(PyList_GetItem(o, i)))
#endif
#if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
#define __Pyx_PyDict_GetItemRef(dict, key, result) PyDict_GetItemRef(dict, key, result)
#elif CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
static CYTHON_INLINE int __Pyx_PyDict_GetItemRef(PyObject *dict, PyObject *key, PyObject **result) {
  *result = PyObject_GetItem(dict, key);
  if (*result == NULL) {
    if (PyErr_ExceptionMatches(PyExc_KeyError)) {
      PyErr_Clear();
      return 0;
    }
    return -1;
  }
  return 1;
}
#else
static CYTHON_INLINE int __Pyx_PyDict_GetItemRef(PyObject *dict, PyObject *key, PyObject **result) {
  *result = PyDict_GetItemWithError(dict, key);
  if (*result == NULL) {
    return PyErr_Occurred() ? -1 : 0;
  }
  Py_INCREF(*result);
  return 1;
}
#endif
#if defined(CYTHON_DEBUG_VISIT_CONST) && CYTHON_DEBUG_VISIT_CONST
  #define __Pyx_VISIT_CONST(obj)  Py_VISIT(obj)
#else
  #define __Pyx_VISIT_CONST(obj)
#endif
#if CYTHON_ASSUME_SAFE_MACROS
  #define __Pyx_PySequence_ITEM(o, i) PySequence_ITEM(o, i)
  #define __Pyx_PySequence_SIZE(seq)  Py_SIZE(seq)
  #define __Pyx_PyTuple_SET_ITEM(o, i, v) (PyTuple_SET_ITEM(o, i, v), (0))
  #define __Pyx_PyTuple_GET_ITEM(o, i) PyTuple_GET_ITEM(o, i)
  #define __Pyx_PyList_SET_ITEM(o, i, v) (PyList_SET_ITEM(o, i, v), (0))
  #define __Pyx_PyList_GET_ITEM(o, i) PyList_GET_ITEM(o, i)
#else
  #define __Pyx_PySequence_ITEM(o, i) PySequence_GetItem(o, i)
  #define __Pyx_PySequence_SIZE(seq)  PySequence_Size(seq)
  #define __Pyx_PyTuple_SET_ITEM(o, i, v) PyTuple_SetItem(o, i, v)
  #define __Pyx_PyTuple_GET_ITEM(o, i) PyTuple_GetItem(o, i)
  #define __Pyx_PyList_SET_ITEM(o, i, v) PyList_SetItem(o, i, v)
  #define __Pyx_PyList_GET_ITEM(o, i) PyList_GetItem(o, i)
#endif
#if CYTHON_ASSUME_SAFE_SIZE
  #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_GET_SIZE(o)
  #define __Pyx_PyList_GET_SIZE(o) PyList_GET_SIZE(o)
  #define __Pyx_PySet_GET_SIZE(o) PySet_GET_SIZE(o)
  #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_GET_SIZE(o)
  #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_GET_SIZE(o)
  #define __Pyx_PyUnicode_GET_LENGTH(o) PyUnicode_GET_LENGTH(o)
#else
  #define __Pyx_PyTuple_GET_SIZE(o) PyTuple_Size(o)
  #define __Pyx_PyList_GET_SIZE(o) PyList_Size(o)
  #define __Pyx_PySet_GET_SIZE(o) PySet_Size(o)
  #define __Pyx_PyBytes_GET_SIZE(o) PyBytes_Size(o)
  #define __Pyx_PyByteArray_GET_SIZE(o) PyByteArray_Size(o)
  #define __Pyx_PyUnicode_GET_LENGTH(o) PyUnicode_GetLength(o)
#endif
#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_InternFromString)
  #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
#endif
#define __Pyx_PyLong_FromHash_t PyLong_FromSsize_t
#define __Pyx_PyLong_AsHash_t   __Pyx_PyIndex_AsSsize_t
#if __PYX_LIMITED_VERSION_HEX >= 0x030A0000
    #define __Pyx_PySendResult PySendResult
#else
    typedef enum {
        PYGEN_RETURN = 0,
        PYGEN_ERROR = -1,
        PYGEN_NEXT = 1,
    } __Pyx_PySendResult;
#endif
#if CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX < 0x030A00A3
  typedef __Pyx_PySendResult (*__Pyx_pyiter_sendfunc)(PyObject *iter, PyObject *value, PyObject **result);
#else
  #define __Pyx_pyiter_sendfunc sendfunc
#endif
#if !CYTHON_USE_AM_SEND
#define __PYX_HAS_PY_AM_SEND 0
#elif __PYX_LIMITED_VERSION_HEX >= 0x030A0000
#define __PYX_HAS_PY_AM_SEND 1
#else
#define __PYX_HAS_PY_AM_SEND 2  // our own backported implementation
#endif
#if __PYX_HAS_PY_AM_SEND < 2
    #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
#else
    typedef struct {
        unaryfunc am_await;
        unaryfunc am_aiter;
        unaryfunc am_anext;
        __Pyx_pyiter_sendfunc am_send;
    } __Pyx_PyAsyncMethodsStruct;
    #define __Pyx_SlotTpAsAsync(s) ((PyAsyncMethods*)(s))
#endif
#if CYTHON_USE_AM_SEND && PY_VERSION_HEX < 0x030A00F0
    #define __Pyx_TPFLAGS_HAVE_AM_SEND (1UL << 21)
#else
    #define __Pyx_TPFLAGS_HAVE_AM_SEND (0)
#endif
#if PY_VERSION_HEX >= 0x03090000
#define __Pyx_PyInterpreterState_Get() PyInterpreterState_Get()
#else
#define __Pyx_PyInterpreterState_Get() PyThreadState_Get()->interp
#endif
#if CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030A0000
#ifdef __cplusplus
extern "C"
#endif
PyAPI_FUNC(void *) PyMem_Calloc(size_t nelem, size_t elsize);
#endif
#if CYTHON_COMPILING_IN_LIMITED_API
static int __Pyx_init_co_variable(PyObject *inspect, const char* name, int *write_to) {
    int value;
    PyObject *py_value = PyObject_GetAttrString(inspect, name);
    if (!py_value) return 0;
    value = (int) PyLong_AsLong(py_value);
    Py_DECREF(py_value);
    *write_to = value;
    return value != -1 || !PyErr_Occurred();
}
static int __Pyx_init_co_variables(void) {
    PyObject *inspect;
    int result;
    inspect = PyImport_ImportModule("inspect");
    result =
#if !defined(CO_OPTIMIZED)
        __Pyx_init_co_variable(inspect, "CO_OPTIMIZED", &CO_OPTIMIZED) &&
#endif
#if !defined(CO_NEWLOCALS)
        __Pyx_init_co_variable(inspect, "CO_NEWLOCALS", &CO_NEWLOCALS) &&
#endif
#if !defined(CO_VARARGS)
        __Pyx_init_co_variable(inspect, "CO_VARARGS", &CO_VARARGS) &&
#endif
#if !defined(CO_VARKEYWORDS)
        __Pyx_init_co_variable(inspect, "CO_VARKEYWORDS", &CO_VARKEYWORDS) &&
#endif
#if !defined(CO_ASYNC_GENERATOR)
        __Pyx_init_co_variable(inspect, "CO_ASYNC_GENERATOR", &CO_ASYNC_GENERATOR) &&
#endif
#if !defined(CO_GENERATOR)
        __Pyx_init_co_variable(inspect, "CO_GENERATOR", &CO_GENERATOR) &&
#endif
#if !defined(CO_COROUTINE)
        __Pyx_init_co_variable(inspect, "CO_COROUTINE", &CO_COROUTINE) &&
#endif
        1;
    Py_DECREF(inspect);
    return result ? 0 : -1;
}
#else
static int __Pyx_init_co_variables(void) {
    return 0;  // It's a limited API-only feature
}
#endif

/* MathInitCode */
#if defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)
  #ifndef _USE_MATH_DEFINES
    #define _USE_MATH_DEFINES
  #endif
#endif
#include <math.h>
#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
#define __Pyx_truncl trunc
#else
#define __Pyx_truncl truncl
#endif

#ifndef CYTHON_CLINE_IN_TRACEBACK_RUNTIME
#define CYTHON_CLINE_IN_TRACEBACK_RUNTIME 0
#endif
#ifndef CYTHON_CLINE_IN_TRACEBACK
#define CYTHON_CLINE_IN_TRACEBACK CYTHON_CLINE_IN_TRACEBACK_RUNTIME
#endif
#if CYTHON_CLINE_IN_TRACEBACK
#define __PYX_MARK_ERR_POS(f_index, lineno)  { __pyx_filename = __pyx_f[f_index]; (void) __pyx_filename; __pyx_lineno = lineno; (void) __pyx_lineno; __pyx_clineno = __LINE__; (void) __pyx_clineno; }
#else
#define __PYX_MARK_ERR_POS(f_index, lineno)  { __pyx_filename = __pyx_f[f_index]; (void) __pyx_filename; __pyx_lineno = lineno; (void) __pyx_lineno; (void) __pyx_clineno; }
#endif
#define __PYX_ERR(f_index, lineno, Ln_error) \
    { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }

#ifdef CYTHON_EXTERN_C
    #undef __PYX_EXTERN_C
    #define __PYX_EXTERN_C CYTHON_EXTERN_C
#elif defined(__PYX_EXTERN_C)
    #ifdef _MSC_VER
    #pragma message ("Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead.")
    #else
    #warning Please do not define the '__PYX_EXTERN_C' macro externally. Use 'CYTHON_EXTERN_C' instead.
    #endif
#else
  #ifdef __cplusplus
    #define __PYX_EXTERN_C extern "C"
  #else
    #define __PYX_EXTERN_C extern
  #endif
#endif

#define __PYX_HAVE__ws_package__controllers__activity_controller
#define __PYX_HAVE_API__ws_package__controllers__activity_controller
/* Early includes */
#ifdef _OPENMP
#include <omp.h>
#endif /* _OPENMP */

#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
#define CYTHON_WITHOUT_ASSERTIONS
#endif

#ifdef CYTHON_FREETHREADING_COMPATIBLE
#if CYTHON_FREETHREADING_COMPATIBLE
#define __Pyx_FREETHREADING_COMPATIBLE Py_MOD_GIL_NOT_USED
#else
#define __Pyx_FREETHREADING_COMPATIBLE Py_MOD_GIL_USED
#endif
#else
#define __Pyx_FREETHREADING_COMPATIBLE Py_MOD_GIL_USED
#endif
#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
#define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
#define __PYX_DEFAULT_STRING_ENCODING ""
#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
#define __Pyx_uchar_cast(c) ((unsigned char)c)
#define __Pyx_long_cast(x) ((long)x)
#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (\
    (sizeof(type) < sizeof(Py_ssize_t))  ||\
    (sizeof(type) > sizeof(Py_ssize_t) &&\
          likely(v < (type)PY_SSIZE_T_MAX ||\
                 v == (type)PY_SSIZE_T_MAX)  &&\
          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
                                v == (type)PY_SSIZE_T_MIN)))  ||\
    (sizeof(type) == sizeof(Py_ssize_t) &&\
          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
                               v == (type)PY_SSIZE_T_MAX)))  )
static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
    return (size_t) i < (size_t) limit;
}
#if defined (__cplusplus) && __cplusplus >= 201103L
    #include <cstdlib>
    #define __Pyx_sst_abs(value) std::abs(value)
#elif SIZEOF_INT >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) abs(value)
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
    #define __Pyx_sst_abs(value) labs(value)
#elif defined (_MSC_VER)
    #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
    #define __Pyx_sst_abs(value) llabs(value)
#elif defined (__GNUC__)
    #define __Pyx_sst_abs(value) __builtin_llabs(value)
#else
    #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
#endif
static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s);
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char*);
#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
#define __Pyx_PyBytes_FromString        PyBytes_FromString
#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
#if CYTHON_ASSUME_SAFE_MACROS
    #define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AS_STRING(s))
    #define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AS_STRING(s))
    #define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AS_STRING(s))
    #define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AS_STRING(s))
    #define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AS_STRING(s))
    #define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AS_STRING(s))
    #define __Pyx_PyByteArray_AsString(s) PyByteArray_AS_STRING(s)
#else
    #define __Pyx_PyBytes_AsWritableString(s)     ((char*) PyBytes_AsString(s))
    #define __Pyx_PyBytes_AsWritableSString(s)    ((signed char*) PyBytes_AsString(s))
    #define __Pyx_PyBytes_AsWritableUString(s)    ((unsigned char*) PyBytes_AsString(s))
    #define __Pyx_PyBytes_AsString(s)     ((const char*) PyBytes_AsString(s))
    #define __Pyx_PyBytes_AsSString(s)    ((const signed char*) PyBytes_AsString(s))
    #define __Pyx_PyBytes_AsUString(s)    ((const unsigned char*) PyBytes_AsString(s))
    #define __Pyx_PyByteArray_AsString(s) PyByteArray_AsString(s)
#endif
#define __Pyx_PyObject_AsWritableString(s)    ((char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableSString(s)    ((signed char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsWritableUString(s)    ((unsigned char*)(__pyx_uintptr_t) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsSString(s)    ((const signed char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_AsUString(s)    ((const unsigned char*) __Pyx_PyObject_AsString(s))
#define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
#define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
#define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
#define __Pyx_PyUnicode_FromOrdinal(o)       PyUnicode_FromOrdinal((int)o)
#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
static CYTHON_INLINE PyObject *__Pyx_NewRef(PyObject *obj) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030a0000 || defined(Py_NewRef)
    return Py_NewRef(obj);
#else
    Py_INCREF(obj);
    return obj;
#endif
}
static CYTHON_INLINE PyObject *__Pyx_XNewRef(PyObject *obj) {
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030a0000 || defined(Py_XNewRef)
    return Py_XNewRef(obj);
#else
    Py_XINCREF(obj);
    return obj;
#endif
}
static CYTHON_INLINE PyObject *__Pyx_Owned_Py_None(int b);
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Long(PyObject* x);
#define __Pyx_PySequence_Tuple(obj)\
    (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
static CYTHON_INLINE PyObject * __Pyx_PyLong_FromSize_t(size_t);
static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*);
#if CYTHON_ASSUME_SAFE_MACROS
#define __Pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
#define __Pyx_PyFloat_AS_DOUBLE(x) PyFloat_AS_DOUBLE(x)
#else
#define __Pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
#define __Pyx_PyFloat_AS_DOUBLE(x) PyFloat_AsDouble(x)
#endif
#define __Pyx_PyFloat_AsFloat(x) ((float) __Pyx_PyFloat_AsDouble(x))
#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
#if CYTHON_USE_PYLONG_INTERNALS
  #if PY_VERSION_HEX >= 0x030C00A7
  #ifndef _PyLong_SIGN_MASK
    #define _PyLong_SIGN_MASK 3
  #endif
  #ifndef _PyLong_NON_SIZE_BITS
    #define _PyLong_NON_SIZE_BITS 3
  #endif
  #define __Pyx_PyLong_Sign(x)  (((PyLongObject*)x)->long_value.lv_tag & _PyLong_SIGN_MASK)
  #define __Pyx_PyLong_IsNeg(x)  ((__Pyx_PyLong_Sign(x) & 2) != 0)
  #define __Pyx_PyLong_IsNonNeg(x)  (!__Pyx_PyLong_IsNeg(x))
  #define __Pyx_PyLong_IsZero(x)  (__Pyx_PyLong_Sign(x) & 1)
  #define __Pyx_PyLong_IsPos(x)  (__Pyx_PyLong_Sign(x) == 0)
  #define __Pyx_PyLong_CompactValueUnsigned(x)  (__Pyx_PyLong_Digits(x)[0])
  #define __Pyx_PyLong_DigitCount(x)  ((Py_ssize_t) (((PyLongObject*)x)->long_value.lv_tag >> _PyLong_NON_SIZE_BITS))
  #define __Pyx_PyLong_SignedDigitCount(x)\
        ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * __Pyx_PyLong_DigitCount(x))
  #if defined(PyUnstable_Long_IsCompact) && defined(PyUnstable_Long_CompactValue)
    #define __Pyx_PyLong_IsCompact(x)     PyUnstable_Long_IsCompact((PyLongObject*) x)
    #define __Pyx_PyLong_CompactValue(x)  PyUnstable_Long_CompactValue((PyLongObject*) x)
  #else
    #define __Pyx_PyLong_IsCompact(x)     (((PyLongObject*)x)->long_value.lv_tag < (2 << _PyLong_NON_SIZE_BITS))
    #define __Pyx_PyLong_CompactValue(x)  ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * (Py_ssize_t) __Pyx_PyLong_Digits(x)[0])
  #endif
  typedef Py_ssize_t  __Pyx_compact_pylong;
  typedef size_t  __Pyx_compact_upylong;
  #else
  #define __Pyx_PyLong_IsNeg(x)  (Py_SIZE(x) < 0)
  #define __Pyx_PyLong_IsNonNeg(x)  (Py_SIZE(x) >= 0)
  #define __Pyx_PyLong_IsZero(x)  (Py_SIZE(x) == 0)
  #define __Pyx_PyLong_IsPos(x)  (Py_SIZE(x) > 0)
  #define __Pyx_PyLong_CompactValueUnsigned(x)  ((Py_SIZE(x) == 0) ? 0 : __Pyx_PyLong_Digits(x)[0])
  #define __Pyx_PyLong_DigitCount(x)  __Pyx_sst_abs(Py_SIZE(x))
  #define __Pyx_PyLong_SignedDigitCount(x)  Py_SIZE(x)
  #define __Pyx_PyLong_IsCompact(x)  (Py_SIZE(x) == 0 || Py_SIZE(x) == 1 || Py_SIZE(x) == -1)
  #define __Pyx_PyLong_CompactValue(x)\
        ((Py_SIZE(x) == 0) ? (sdigit) 0 : ((Py_SIZE(x) < 0) ? -(sdigit)__Pyx_PyLong_Digits(x)[0] : (sdigit)__Pyx_PyLong_Digits(x)[0]))
  typedef sdigit  __Pyx_compact_pylong;
  typedef digit  __Pyx_compact_upylong;
  #endif
  #if PY_VERSION_HEX >= 0x030C00A5
  #define __Pyx_PyLong_Digits(x)  (((PyLongObject*)x)->long_value.ob_digit)
  #else
  #define __Pyx_PyLong_Digits(x)  (((PyLongObject*)x)->ob_digit)
  #endif
#endif
#if __PYX_DEFAULT_STRING_ENCODING_IS_UTF8
  #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
#elif __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
  #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeASCII(c_str, size, NULL)
#else
  #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
#endif


/* Test for GCC > 2.95 */
#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
  #define likely(x)   __builtin_expect(!!(x), 1)
  #define unlikely(x) __builtin_expect(!!(x), 0)
#else /* !__GNUC__ or GCC < 2.95 */
  #define likely(x)   (x)
  #define unlikely(x) (x)
#endif /* __GNUC__ */
/* PretendToInitialize */
#ifdef __cplusplus
#if __cplusplus > 201103L
#include <type_traits>
#endif
template <typename T>
static void __Pyx_pretend_to_initialize(T* ptr) {
#if __cplusplus > 201103L
    if ((std::is_trivially_default_constructible<T>::value))
#endif
        *ptr = T();
    (void)ptr;
}
#else
static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
#endif


#if !CYTHON_USE_MODULE_STATE
static PyObject *__pyx_m = NULL;
#endif
static int __pyx_lineno;
static int __pyx_clineno = 0;
static const char * const __pyx_cfilenm = __FILE__;
static const char *__pyx_filename;

/* #### Code section: filename_table ### */

static const char* const __pyx_f[] = {
  "ws_package/controllers/activity_controller.py",
};
/* #### Code section: utility_code_proto_before_types ### */
/* Atomics.proto (used by UnpackUnboundCMethod) */
#include <pythread.h>
#ifndef CYTHON_ATOMICS
    #define CYTHON_ATOMICS 1
#endif
#define __PYX_CYTHON_ATOMICS_ENABLED() CYTHON_ATOMICS
#define __PYX_GET_CYTHON_COMPILING_IN_CPYTHON_FREETHREADING() CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
#define __pyx_atomic_int_type int
#define __pyx_nonatomic_int_type int
#if CYTHON_ATOMICS && (defined(__STDC_VERSION__) &&\
                        (__STDC_VERSION__ >= 201112L) &&\
                        !defined(__STDC_NO_ATOMICS__))
    #include <stdatomic.h>
#elif CYTHON_ATOMICS && (defined(__cplusplus) && (\
                    (__cplusplus >= 201103L) ||\
                    (defined(_MSC_VER) && _MSC_VER >= 1700)))
    #include <atomic>
#endif
#if CYTHON_ATOMICS && (defined(__STDC_VERSION__) &&\
                        (__STDC_VERSION__ >= 201112L) &&\
                        !defined(__STDC_NO_ATOMICS__) &&\
                       ATOMIC_INT_LOCK_FREE == 2)
    #undef __pyx_atomic_int_type
    #define __pyx_atomic_int_type atomic_int
    #define __pyx_atomic_ptr_type atomic_uintptr_t
    #define __pyx_nonatomic_ptr_type uintptr_t
    #define __pyx_atomic_incr_relaxed(value) atomic_fetch_add_explicit(value, 1, memory_order_relaxed)
    #define __pyx_atomic_incr_acq_rel(value) atomic_fetch_add_explicit(value, 1, memory_order_acq_rel)
    #define __pyx_atomic_decr_acq_rel(value) atomic_fetch_sub_explicit(value, 1, memory_order_acq_rel)
    #define __pyx_atomic_sub(value, arg) atomic_fetch_sub(value, arg)
    #define __pyx_atomic_int_cmp_exchange(value, expected, desired) atomic_compare_exchange_strong(value, expected, desired)
    #define __pyx_atomic_load(value) atomic_load(value)
    #define __pyx_atomic_store(value, new_value) atomic_store(value, new_value)
    #define __pyx_atomic_pointer_load_relaxed(value) atomic_load_explicit(value, memory_order_relaxed)
    #define __pyx_atomic_pointer_load_acquire(value) atomic_load_explicit(value, memory_order_acquire)
    #define __pyx_atomic_pointer_exchange(value, new_value) atomic_exchange(value, (__pyx_nonatomic_ptr_type)new_value)
    #define __pyx_atomic_pointer_cmp_exchange(value, expected, desired) atomic_compare_exchange_strong(value, expected, desired)
    #if defined(__PYX_DEBUG_ATOMICS) && defined(_MSC_VER)
        #pragma message ("Using standard C atomics")
    #elif defined(__PYX_DEBUG_ATOMICS)
        #warning "Using standard C atomics"
    #endif
#elif CYTHON_ATOMICS && (defined(__cplusplus) && (\
                    (__cplusplus >= 201103L) ||\
\
                    (defined(_MSC_VER) && _MSC_VER >= 1700)) &&\
                    ATOMIC_INT_LOCK_FREE == 2)
    #undef __pyx_atomic_int_type
    #define __pyx_atomic_int_type std::atomic_int
    #define __pyx_atomic_ptr_type std::atomic_uintptr_t
    #define __pyx_nonatomic_ptr_type uintptr_t
    #define __pyx_atomic_incr_relaxed(value) std::atomic_fetch_add_explicit(value, 1, std::memory_order_relaxed)
    #define __pyx_atomic_incr_acq_rel(value) std::atomic_fetch_add_explicit(value, 1, std::memory_order_acq_rel)
    #define __pyx_atomic_decr_acq_rel(value) std::atomic_fetch_sub_explicit(value, 1, std::memory_order_acq_rel)
    #define __pyx_atomic_sub(value, arg) std::atomic_fetch_sub(value, arg)
    #define __pyx_atomic_int_cmp_exchange(value, expected, desired) std::atomic_compare_exchange_strong(value, expected, desired)
    #define __pyx_atomic_load(value) std::atomic_load(value)
    #define __pyx_atomic_store(value, new_value) std::atomic_store(value, new_value)
    #define __pyx_atomic_pointer_load_relaxed(value) std::atomic_load_explicit(value, std::memory_order_relaxed)
    #define __pyx_atomic_pointer_load_acquire(value) std::atomic_load_explicit(value, std::memory_order_acquire)
    #define __pyx_atomic_pointer_exchange(value, new_value) std::atomic_exchange(value, (__pyx_nonatomic_ptr_type)new_value)
    #define __pyx_atomic_pointer_cmp_exchange(value, expected, desired) std::atomic_compare_exchange_strong(value, expected, desired)
    #if defined(__PYX_DEBUG_ATOMICS) && defined(_MSC_VER)
        #pragma message ("Using standard C++ atomics")
    #elif defined(__PYX_DEBUG_ATOMICS)
        #warning "Using standard C++ atomics"
    #endif
#elif CYTHON_ATOMICS && (__GNUC__ >= 5 || (__GNUC__ == 4 &&\
                    (__GNUC_MINOR__ > 1 ||\
                    (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ >= 2))))
    #define __pyx_atomic_ptr_type void*
    #define __pyx_nonatomic_ptr_type void*
    #define __pyx_atomic_incr_relaxed(value) __sync_fetch_and_add(value, 1)
    #define __pyx_atomic_incr_acq_rel(value) __sync_fetch_and_add(value, 1)
    #define __pyx_atomic_decr_acq_rel(value) __sync_fetch_and_sub(value, 1)
    #define __pyx_atomic_sub(value, arg) __sync_fetch_and_sub(value, arg)
    static CYTHON_INLINE int __pyx_atomic_int_cmp_exchange(__pyx_atomic_int_type* value, __pyx_nonatomic_int_type* expected, __pyx_nonatomic_int_type desired) {
        __pyx_nonatomic_int_type old = __sync_val_compare_and_swap(value, *expected, desired);
        int result = old == *expected;
        *expected = old;
        return result;
    }
    #define __pyx_atomic_load(value) __sync_fetch_and_add(value, 0)
    #define __pyx_atomic_store(value, new_value) __sync_lock_test_and_set(value, new_value)
    #define __pyx_atomic_pointer_load_relaxed(value) __sync_fetch_and_add(value, 0)
    #define __pyx_atomic_pointer_load_acquire(value) __sync_fetch_and_add(value, 0)
    #define __pyx_atomic_pointer_exchange(value, new_value) __sync_lock_test_and_set(value, (__pyx_atomic_ptr_type)new_value)
    static CYTHON_INLINE int __pyx_atomic_pointer_cmp_exchange(__pyx_atomic_ptr_type* value, __pyx_nonatomic_ptr_type* expected, __pyx_nonatomic_ptr_type desired) {
        __pyx_nonatomic_ptr_type old = __sync_val_compare_and_swap(value, *expected, desired);
        int result = old == *expected;
        *expected = old;
        return result;
    }
    #ifdef __PYX_DEBUG_ATOMICS
        #warning "Using GNU atomics"
    #endif
#elif CYTHON_ATOMICS && defined(_MSC_VER)
    #include <intrin.h>
    #undef __pyx_atomic_int_type
    #define __pyx_atomic_int_type long
    #define __pyx_atomic_ptr_type void*
    #undef __pyx_nonatomic_int_type
    #define __pyx_nonatomic_int_type long
    #define __pyx_nonatomic_ptr_type void*
    #pragma intrinsic (_InterlockedExchangeAdd, _InterlockedExchange, _InterlockedCompareExchange, _InterlockedCompareExchangePointer, _InterlockedExchangePointer)
    #define __pyx_atomic_incr_relaxed(value) _InterlockedExchangeAdd(value, 1)
    #define __pyx_atomic_incr_acq_rel(value) _InterlockedExchangeAdd(value, 1)
    #define __pyx_atomic_decr_acq_rel(value) _InterlockedExchangeAdd(value, -1)
    #define __pyx_atomic_sub(value, arg) _InterlockedExchangeAdd(value, -arg)
    static CYTHON_INLINE int __pyx_atomic_int_cmp_exchange(__pyx_atomic_int_type* value, __pyx_nonatomic_int_type* expected, __pyx_nonatomic_int_type desired) {
        __pyx_nonatomic_int_type old = _InterlockedCompareExchange(value, desired, *expected);
        int result = old == *expected;
        *expected = old;
        return result;
    }
    #define __pyx_atomic_load(value) _InterlockedExchangeAdd(value, 0)
    #define __pyx_atomic_store(value, new_value) _InterlockedExchange(value, new_value)
    #define __pyx_atomic_pointer_load_relaxed(value) *(void * volatile *)value
    #define __pyx_atomic_pointer_load_acquire(value) _InterlockedCompareExchangePointer(value, 0, 0)
    #define __pyx_atomic_pointer_exchange(value, new_value) _InterlockedExchangePointer(value, (__pyx_atomic_ptr_type)new_value)
    static CYTHON_INLINE int __pyx_atomic_pointer_cmp_exchange(__pyx_atomic_ptr_type* value, __pyx_nonatomic_ptr_type* expected, __pyx_nonatomic_ptr_type desired) {
        __pyx_atomic_ptr_type old = _InterlockedCompareExchangePointer(value, desired, *expected);
        int result = old == *expected;
        *expected = old;
        return result;
    }
    #ifdef __PYX_DEBUG_ATOMICS
        #pragma message ("Using MSVC atomics")
    #endif
#else
    #undef CYTHON_ATOMICS
    #define CYTHON_ATOMICS 0
    #ifdef __PYX_DEBUG_ATOMICS
        #warning "Not using atomics"
    #endif
#endif

/* CriticalSectionsDefinition.proto (used by CriticalSections) */
#if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
#define __Pyx_PyCriticalSection void*
#define __Pyx_PyCriticalSection2 void*
#define __Pyx_PyCriticalSection_End(cs)
#define __Pyx_PyCriticalSection2_End(cs)
#else
#define __Pyx_PyCriticalSection PyCriticalSection
#define __Pyx_PyCriticalSection2 PyCriticalSection2
#define __Pyx_PyCriticalSection_End PyCriticalSection_End
#define __Pyx_PyCriticalSection2_End PyCriticalSection2_End
#endif

/* CriticalSections.proto (used by ParseKeywordsImpl) */
#if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
#define __Pyx_PyCriticalSection_Begin(cs, arg) (void)(cs)
#define __Pyx_PyCriticalSection2_Begin(cs, arg1, arg2) (void)(cs)
#else
#define __Pyx_PyCriticalSection_Begin PyCriticalSection_Begin
#define __Pyx_PyCriticalSection2_Begin PyCriticalSection2_Begin
#endif
#if PY_VERSION_HEX < 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API
#define __Pyx_BEGIN_CRITICAL_SECTION(o) {
#define __Pyx_END_CRITICAL_SECTION() }
#else
#define __Pyx_BEGIN_CRITICAL_SECTION Py_BEGIN_CRITICAL_SECTION
#define __Pyx_END_CRITICAL_SECTION Py_END_CRITICAL_SECTION
#endif

/* IncludeStructmemberH.proto (used by FixUpExtensionType) */
#include <structmember.h>

/* #### Code section: numeric_typedefs ### */
/* #### Code section: complex_type_declarations ### */
/* #### Code section: type_declarations ### */

/*--- Type declarations ---*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr;
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign;

/* "ws_package/controllers/activity_controller.py":554
 *         return (datetime.datetime.now() - last_bump).total_seconds() < within_seconds
 * 
 *     async def has_recent_intervals_on_write_counter(self, within_seconds: int = 45) -> bool:             # <<<<<<<<<<<<<<
 *         """True if the current write counter already has intervals ended very recently (start retry)."""
 *         DB_OPERATION_TIMEOUT = 5.0
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter {
  PyObject_HEAD
  double __pyx_v_DB_OPERATION_TIMEOUT;
  PyObject *__pyx_v_cutoff;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_query;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_session;
  PyObject *__pyx_v_within_seconds;
  PyObject *__pyx_v_write_counter;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
  PyObject *__pyx_t_9;
  PyObject *__pyx_t_10;
  PyObject *__pyx_t_11;
};


/* "ws_package/controllers/activity_controller.py":608
 *         )
 * 
 *     async def _trim_open_partial_at_project_switch(             # <<<<<<<<<<<<<<
 *         self, switch_time: datetime.datetime
 *     ):
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch {
  PyObject_HEAD
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_interval;
  PyObject *__pyx_v_old_end;
  PyObject *__pyx_v_query;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_session;
  PyObject *__pyx_v_switch_time;
  PyObject *__pyx_v_write_counter;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
  PyObject *__pyx_t_9;
  PyObject *__pyx_t_10;
  PyObject *__pyx_t_11;
  PyObject *__pyx_t_12;
  PyObject *__pyx_t_13;
  PyObject *__pyx_t_14;
};


/* "ws_package/controllers/activity_controller.py":654
 *             return None
 * 
 *     async def _try_finalize_post_switch_slot_interval(             # <<<<<<<<<<<<<<
 *         self, user_entity: UserEntity
 *     ) -> bool:
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval {
  PyObject_HEAD
  PyObject *__pyx_v_activity_level;
  PyObject *__pyx_v_current_break_id;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_existing;
  PyObject *__pyx_v_interval_minutes;
  PyObject *__pyx_v_interval_start;
  PyObject *__pyx_v_last_end;
  PyObject *__pyx_v_now;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_session_start;
  PyObject *__pyx_v_slot_end;
  PyObject *__pyx_v_slot_start;
  PyObject *__pyx_v_user_entity;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
};


/* "ws_package/controllers/activity_controller.py":721
 *         return True
 * 
 *     async def _create_segment_dummy_entry(self, segment_start: datetime.datetime) -> None:             # <<<<<<<<<<<<<<
 *         """Create is_uploaded=True marker interval at a new session boundary (project switch, etc.)."""
 *         empty_activity_level = {"mouse": "1", "keyboard": "0.0", "average": "0.0"}
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry {
  PyObject_HEAD
  PyObject *__pyx_v_current_break_id;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_empty_activity_level;
  PyObject *__pyx_v_processed_count;
  PyObject *__pyx_v_query;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_segment_start;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_session;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
  PyObject *__pyx_t_9;
  PyObject *__pyx_t_10;
  PyObject *__pyx_t_11;
  PyObject *__pyx_t_12;
  PyObject *__pyx_t_13;
  PyObject *__pyx_t_14;
};


/* "ws_package/controllers/activity_controller.py":779
 *             logger.error("Error handling S3 time error: %s", e)
 * 
 *     async def inrange(self, start_date, end_date):             # <<<<<<<<<<<<<<
 *         if start_date is None or end_date is None:
 *             logger.info("Start date or end date is None")
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange {
  PyObject_HEAD
  PyObject *__pyx_v_end_date;
  PyObject *__pyx_v_end_date_y;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_start_date;
  PyObject *__pyx_v_start_date_y;
};


/* "ws_package/controllers/activity_controller.py":836
 *         return s_limit_start, s_limit_end
 * 
 *     async def update_tracking_duration(self, user_entity:UserEntity):             # <<<<<<<<<<<<<<
 *         """
 *         Update tracking duration from stealth mode API.
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration {
  PyObject_HEAD
  int __pyx_v_api_call_made;
  PyObject *__pyx_v_current_time;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_mode_entity;
  PyObject *__pyx_v_response;
  PyObject *__pyx_v_s_limit_end;
  PyObject *__pyx_v_s_limit_start;
  PyObject *__pyx_v_self;
  int __pyx_v_should_refresh;
  PyObject *__pyx_v_time_since_last_call;
  PyObject *__pyx_v_user_entity;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
};


/* "ws_package/controllers/activity_controller.py":941
 *                 logger.info("No tracking scenerio found")
 * 
 *     async def midnight(self, user_entity: UserEntity, last_count):             # <<<<<<<<<<<<<<
 *         # Use centralized read lock for database read operations
 *         # Database operation timeout constant
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight {
  PyObject_HEAD
  double __pyx_v_DB_OPERATION_TIMEOUT;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_last_count;
  PyObject *__pyx_v_last_entry;
  PyObject *__pyx_v_query;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_session;
  PyObject *__pyx_v_user_entity;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
  PyObject *__pyx_t_9;
  PyObject *__pyx_t_10;
  PyObject *__pyx_t_11;
};


/* "ws_package/controllers/activity_controller.py":1035
 *             logger.error("[WAKE] Error handling S3 bucket update on wake: %s", e, exc_info=True)
 * 
 *     async def _check_and_update_s3_on_startup(self, user_entity):             # <<<<<<<<<<<<<<
 *         """
 *         Check if it's a new day on app startup and update S3 bucket config if needed.
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup {
  PyObject_HEAD
  double __pyx_v_DB_OPERATION_TIMEOUT;
  PyObject *__pyx_v_credentials_stale;
  PyObject *__pyx_v_current_date;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_last_entry;
  PyObject *__pyx_v_last_entry_date;
  PyObject *__pyx_v_query;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_session;
  PyObject *__pyx_v_user_entity;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
  PyObject *__pyx_t_9;
  PyObject *__pyx_t_10;
  PyObject *__pyx_t_11;
  PyObject *__pyx_t_12;
  PyObject *__pyx_t_13;
  PyObject *__pyx_t_14;
};


/* "ws_package/controllers/activity_controller.py":1080
 *             logger.error("[STARTUP] Error checking/updating S3 bucket on startup: %s", e, exc_info=True)
 * 
 *     async def _check_and_update_s3_on_wake(self, user_entity):             # <<<<<<<<<<<<<<
 *         """
 *         Check if it's a new day and update S3 bucket config if needed.
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake {
  PyObject_HEAD
  double __pyx_v_DB_OPERATION_TIMEOUT;
  PyObject *__pyx_v_credentials_stale;
  PyObject *__pyx_v_current_date;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_last_entry;
  PyObject *__pyx_v_last_entry_date;
  PyObject *__pyx_v_query;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_session;
  PyObject *__pyx_v_user_entity;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
  PyObject *__pyx_t_9;
  PyObject *__pyx_t_10;
  PyObject *__pyx_t_11;
  PyObject *__pyx_t_12;
  PyObject *__pyx_t_13;
  PyObject *__pyx_t_14;
};


/* "ws_package/controllers/activity_controller.py":1125
 *             logger.error("[WAKE] Error checking/updating S3 bucket on wake: %s", e, exc_info=True)
 * 
 *     async def _s3_credentials_need_refresh(self, user_entity: UserEntity) -> bool:             # <<<<<<<<<<<<<<
 *         """True when stored STS credentials are missing or past expire_time."""
 *         if user_entity is None:
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh {
  PyObject_HEAD
  PyObject *__pyx_v_existing;
  PyObject *__pyx_v_s3_credentials_expired;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_user_entity;
};


/* "ws_package/controllers/activity_controller.py":1134
 *         return existing is None or s3_credentials_expired(existing)
 * 
 *     async def ensure_s3_credentials_fresh(self, user_entity: UserEntity) -> S3BucketEntity | None:             # <<<<<<<<<<<<<<
 *         """Refresh S3 credentials from sts/keys when expire_time has passed."""
 *         return await self.server_controller.ensure_fresh_s3_bucket(user_entity)
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh {
  PyObject_HEAD
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_user_entity;
};


/* "ws_package/controllers/activity_controller.py":1138
 *         return await self.server_controller.ensure_fresh_s3_bucket(user_entity)
 * 
 *     async def get_bucket_in_every_interval(self, user_entity: UserEntity) -> S3BucketEntity | None:             # <<<<<<<<<<<<<<
 *         """Refresh S3 bucket credentials from the remote API when needed.
 * 
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval {
  PyObject_HEAD
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_user_entity;
};


/* "ws_package/controllers/activity_controller.py":1149
 *         return await self.ensure_s3_credentials_fresh(user_entity)
 * 
 *     async def update_interval(self, user_entity: UserEntity):             # <<<<<<<<<<<<<<
 *         """Refresh org settings (interval, screenshot frequency, limits) from the remote API.
 * 
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval {
  PyObject_HEAD
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_loop;
  PyObject *__pyx_v_normalize_timezone_preference;
  PyObject *__pyx_v_org_entity;
  PyObject *__pyx_v_org_id;
  PyObject *__pyx_v_payload;
  PyObject *__pyx_v_response_data;
  PyObject *__pyx_v_sd_token;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_user_entity;
  PyObject *__pyx_v_user_id;
  PyObject *__pyx_v_weekly_limit_data;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
};


/* "ws_package/controllers/activity_controller.py":1301
 *             logger.warning("[TimezonePref] Failed to toggle time monitor: %s", e)
 * 
 *     async def _load_org_settings_from_db(self):             # <<<<<<<<<<<<<<
 *         """Load organization settings from local database as fallback."""
 *         try:
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db {
  PyObject_HEAD
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_query;
  PyObject *__pyx_v_record;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_session;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
  PyObject *__pyx_t_9;
  PyObject *__pyx_t_10;
  PyObject *__pyx_t_11;
  PyObject *__pyx_t_12;
  PyObject *__pyx_t_13;
  PyObject *__pyx_t_14;
};


/* "ws_package/controllers/activity_controller.py":1342
 *             return False
 * 
 *     async def _check_and_handle_limits(self, user_entity: UserEntity, org_entity: OrgEntity):             # <<<<<<<<<<<<<<
 *         """
 *         Check if daily or weekly limits are exceeded and handle accordingly.
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits {
  PyObject_HEAD
  PyObject *__pyx_v_daily_exceeded;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_limit_type;
  PyObject *__pyx_v_limits_check;
  PyObject *__pyx_v_notification_service;
  PyObject *__pyx_v_org_entity;
  PyObject *__pyx_v_report_in_background;
  PyObject *__pyx_v_report_thread;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_today;
  PyObject *__pyx_v_user_entity;
  PyObject *__pyx_v_weekly_exceeded;
};


/* "ws_package/controllers/activity_controller.py":1466
 *             logger.error("Failed to send subscription expiration error to Electron: %s", e)
 * 
 *     async def start_screenshot_activity(self, user_entity: UserEntity, stop_event=None):             # <<<<<<<<<<<<<<
 *         await precise_sleep(10)
 *         logger.info("Starting screenshot activity with interval: %s and ss frequency: %s blur intensity: %s status: %s limit start: %s limit end: %s no of days: %s", self.interval, self.screenshot_interval, self.blur_intensity, self.status, self.limit_start, self.limit_end, self.no_of_days)
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity {
  PyObject_HEAD
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_stop_event;
  PyObject *__pyx_v_user_entity;
};


/* "ws_package/controllers/activity_controller.py":1481
 *         )
 * 
 *     async def start_device_activity(self, user_entity: UserEntity, stop_event: Optional[asyncio.Event] = None) -> None:             # <<<<<<<<<<<<<<
 *         self.user_entity = user_entity
 *         """
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity {
  PyObject_HEAD
  PyObject *__pyx_v_current_loop;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_minute_timer_task;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_stop_event;
  PyObject *__pyx_v_task;
  PyObject *__pyx_v_task_loop;
  PyObject *__pyx_v_user_entity;
};


/* "ws_package/controllers/activity_controller.py":1554
 *     # This method is no longer needed - reminder logic is now handled entirely in the Electron renderer
 * 
 *     async def getStartingSlot(self) -> Tuple[datetime.datetime, datetime.datetime]:             # <<<<<<<<<<<<<<
 *         """
 *         Calculate the starting time slot for activity monitoring.
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot {
  PyObject_HEAD
  PyObject *__pyx_v_end_time;
  PyObject *__pyx_v_hr;
  long __pyx_v_last_minute;
  PyObject *__pyx_v_minute;
  PyObject *__pyx_v_next_day;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_start_time;
};


/* "ws_package/controllers/activity_controller.py":1592
 *         return start_time,end_time
 * 
 *     async def getCurrentSlot(self):             # <<<<<<<<<<<<<<
 *         start_date = datetime.datetime.now()
 *         self.tzmain = start_date
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot {
  PyObject_HEAD
  PyObject *__pyx_v_end_date;
  PyObject *__pyx_v_minute;
  PyObject *__pyx_v_rounded_minute;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_start_date;
};


/* "ws_package/controllers/activity_controller.py":1625
 *         return aligned_time
 * 
 *     def is_browser(self, app_name):             # <<<<<<<<<<<<<<
 *         # Normalize and clean string
 *         normalized_name = unicodedata.normalize("NFKD", app_name)
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser {
  PyObject_HEAD
  PyObject *__pyx_v_cleaned_name_lower;
};


/* "ws_package/controllers/activity_controller.py":1628
 *         # Normalize and clean string
 *         normalized_name = unicodedata.normalize("NFKD", app_name)
 *         cleaned_name = ''.join(c for c in normalized_name if c.isprintable())             # <<<<<<<<<<<<<<
 *         cleaned_name = re.sub(r'[\u200B-\u200D\uFEFF]', '', cleaned_name)  # Remove zero-width chars
 * 
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr {
  PyObject_HEAD
  PyObject *__pyx_genexpr_arg_0;
  PyObject *__pyx_v_c;
};


/* "ws_package/controllers/activity_controller.py":1636
 *         browsers = ['Google Chrome', 'Mozilla Firefox', 'Safari', 'Microsoft Edge', 'Opera', 'Msedge', 'Chrome', 'Firefox', 'Brave Browser']
 *         # Case-insensitive matching
 *         return any(browser.lower() in cleaned_name_lower for browser in browsers)             # <<<<<<<<<<<<<<
 * 
 *     async def __start_minute_activity_timer(self, stop_event):
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr {
  PyObject_HEAD
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser *__pyx_outer_scope;
  PyObject *__pyx_genexpr_arg_0;
  PyObject *__pyx_v_browser;
};


/* "ws_package/controllers/activity_controller.py":1638
 *         return any(browser.lower() in cleaned_name_lower for browser in browsers)
 * 
 *     async def __start_minute_activity_timer(self, stop_event):             # <<<<<<<<<<<<<<
 *         """Start minute-by-minute activity rolling average timer"""
 *         logger.info("Starting minute-by-minute activity rolling average timer")
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer {
  PyObject_HEAD
  PyObject *__pyx_v__;
  PyObject *__pyx_v_current_break_id;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_minute_activity_level;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_stop_event;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
};


/* "ws_package/controllers/activity_controller.py":1686
 *         logger.info("Minute activity timer stopped")
 * 
 *     async def __start_device_activity(self, user_entity:UserEntity, stop_event):             # <<<<<<<<<<<<<<
 * 
 *         # Update start_date to actual timer start time (when user clicks Start)
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity {
  PyObject_HEAD
  PyObject *__pyx_v_ErrorCode;
  PyObject *__pyx_v__;
  PyObject *__pyx_v__WOT;
  PyObject *__pyx_v__WOT2;
  PyObject *__pyx_v__d;
  PyObject *__pyx_v__d2;
  PyObject *__pyx_v__dwq;
  PyObject *__pyx_v__dwq2;
  PyObject *__pyx_v__on_time_error;
  PyObject *__pyx_v__pe;
  PyObject *__pyx_v__pe2;
  PyObject *__pyx_v__pi;
  PyObject *__pyx_v__pi2;
  PyObject *__pyx_v__ps;
  PyObject *__pyx_v__ps2;
  PyObject *__pyx_v_active_app_ui_task;
  PyObject *__pyx_v_active_app_ui_task_done_callback;
  PyObject *__pyx_v_active_app_url;
  PyObject *__pyx_v_activityLevel;
  PyObject *__pyx_v_activity_error;
  PyObject *__pyx_v_activity_percentage_end;
  PyObject *__pyx_v_activity_percentage_end_seconds;
  PyObject *__pyx_v_activity_percentage_entity;
  PyObject *__pyx_v_activity_percentage_key;
  PyObject *__pyx_v_activity_percentage_start;
  PyObject *__pyx_v_activity_percentage_start_seconds;
  PyObject *__pyx_v_app_listener;
  PyObject *__pyx_v_apply_desktop_key;
  double __pyx_v_average_activity;
  int __pyx_v_break_interval_overlaps;
  PyObject *__pyx_v_break_intervals;
  PyObject *__pyx_v_break_intervals_after_trim;
  PyObject *__pyx_v_break_start_time;
  PyObject *__pyx_v_break_stop_attr;
  PyObject *__pyx_v_break_stop_time_attr;
  PyObject *__pyx_v_check_idle_after_delay;
  PyObject *__pyx_v_check_query;
  PyObject *__pyx_v_chunk_duration;
  PyObject *__pyx_v_chunks;
  PyObject *__pyx_v_current_break_id;
  PyObject *__pyx_v_current_break_id_slot;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_effective_end;
  PyObject *__pyx_v_effective_start;
  PyObject *__pyx_v_empty_activity_level;
  PyObject *__pyx_v_enable_hourly_log_upload;
  PyObject *__pyx_v_end_date;
  PyObject *__pyx_v_end_date_seconds;
  PyObject *__pyx_v_end_sec;
  PyObject *__pyx_v_enqueued;
  PyObject *__pyx_v_error_data;
  PyObject *__pyx_v_existing;
  PyObject *__pyx_v_existing_dummy;
  PyObject *__pyx_v_existing_interval_in_db;
  PyObject *__pyx_v_existing_record;
  PyObject *__pyx_v_fallback_error;
  PyObject *__pyx_v_first_entry;
  PyObject *__pyx_v_first_entry_note;
  PyObject *__pyx_v_flush_error;
  PyObject *__pyx_v_has_any_activity;
  PyObject *__pyx_v_has_zero_activity;
  PyObject *__pyx_v_headers;
  PyObject *__pyx_v_in_range;
  double __pyx_v_initial_average;
  double __pyx_v_initial_mouse;
  int __pyx_v_interval_exists;
  PyObject *__pyx_v_interval_key;
  int __pyx_v_is_break_interval;
  int __pyx_v_is_first_entry;
  PyObject *__pyx_v_is_idle;
  PyObject *__pyx_8genexpr2__pyx_v_iv;
  PyObject *__pyx_8genexpr3__pyx_v_iv;
  PyObject *__pyx_8genexpr4__pyx_v_iv;
  PyObject *__pyx_8genexpr5__pyx_v_iv;
  PyObject *__pyx_8genexpr6__pyx_v_iv;
  PyObject *__pyx_8genexpr7__pyx_v_iv;
  PyObject *__pyx_8genexpr8__pyx_v_iv;
  PyObject *__pyx_8genexpr9__pyx_v_iv;
  PyObject *__pyx_v_keyboard_active;
  double __pyx_v_keyboard_activity;
  PyObject *__pyx_v_keyboard_verified;
  PyObject *__pyx_v_last_app_monitor_time;
  PyObject *__pyx_v_last_end;
  PyObject *__pyx_v_latest_record;
  PyObject *__pyx_v_minimal_activity;
  PyObject *__pyx_v_monitor_active_app_for_ui;
  PyObject *__pyx_v_monitor_active_apps;
  PyObject *__pyx_v_monitor_task;
  PyObject *__pyx_v_mouse_active;
  double __pyx_v_mouse_activity;
  PyObject *__pyx_v_mouse_verified;
  PyObject *__pyx_v_now;
  PyObject *__pyx_v_overlap_query;
  PyObject *__pyx_v_overlap_query_after_trim;
  PyObject *__pyx_v_overlap_result;
  PyObject *__pyx_v_overlap_result_after_trim;
  PyObject *__pyx_v_overlapping_details;
  PyObject *__pyx_v_overlapping_details_after_trim;
  PyObject *__pyx_v_overlapping_intervals;
  PyObject *__pyx_v_overlapping_intervals_after_trim;
  PyObject *__pyx_v_payload;
  PyObject *__pyx_v_popup_is_active;
  PyObject *__pyx_v_processed_count;
  PyObject *__pyx_v_query;
  PyObject *__pyx_v_queue_size;
  PyObject *__pyx_v_recovery_error;
  int __pyx_v_regular_interval_overlaps;
  PyObject *__pyx_v_regular_intervals;
  PyObject *__pyx_v_regular_intervals_after_trim;
  PyObject *__pyx_v_remove_after_delay;
  PyObject *__pyx_v_resolving_policy;
  PyObject *__pyx_v_response;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_script_path;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_session;
  PyObject *__pyx_v_session_start;
  PyObject *__pyx_v_sleep_seconds;
  PyObject *__pyx_v_slot_end;
  PyObject *__pyx_v_start_date;
  PyObject *__pyx_v_start_date_seconds;
  PyObject *__pyx_v_start_sec;
  PyObject *__pyx_v_stop_event;
  PyObject *__pyx_v_stop_listeners;
  PyObject *__pyx_v_target_directory;
  PyObject *__pyx_v_target_directory_stealth;
  PyObject *__pyx_v_task_done_callback;
  int __pyx_v_timecheck_failed;
  PyObject *__pyx_v_today;
  PyObject *__pyx_v_total_sleep;
  PyObject *__pyx_v_trim_to;
  PyObject *__pyx_v_url;
  PyObject *__pyx_v_user_entity;
  PyObject *__pyx_v_work_session_start;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
  PyObject *__pyx_t_9;
  PyObject *__pyx_t_10;
  PyObject *__pyx_t_11;
  PyObject *__pyx_t_12;
  PyObject *__pyx_t_13;
  PyObject *__pyx_t_14;
  PyObject *(*__pyx_t_15)(PyObject *);
  PyObject *__pyx_t_16;
  PyObject *__pyx_t_17;
  PyObject *__pyx_t_18;
  int __pyx_t_19;
};


/* "ws_package/controllers/activity_controller.py":1810
 *         # No complex time monitoring needed - using S3 error detection
 * 
 *         async def monitor_active_apps():             # <<<<<<<<<<<<<<
 *             nonlocal last_app_monitor_time
 *             logger.info(
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps {
  PyObject_HEAD
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *__pyx_outer_scope;
  PyObject *__pyx_v_active_app_url;
  PyObject *__pyx_v_app_name;
  PyObject *__pyx_v_detected_app;
  PyObject *__pyx_v_display_name;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_i2t;
  PyObject *__pyx_v_row;
  PyObject *__pyx_v_url;
  PyObject *__pyx_v_url_result;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
};


/* "ws_package/controllers/activity_controller.py":1976
 * 
 *         # Monitor active app changes for UI display (real-time updates)
 *         async def monitor_active_app_for_ui():             # <<<<<<<<<<<<<<
 *             """Monitor active app changes and send updates to Electron for UI display."""
 *             while not stop_event.is_set():
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui {
  PyObject_HEAD
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *__pyx_outer_scope;
  PyObject *__pyx_v_active_windows;
  PyObject *__pyx_v_app_icon;
  PyObject *__pyx_v_current_app_data;
  PyObject *__pyx_v_current_app_name;
  PyObject *__pyx_v_current_app_path;
  PyObject *__pyx_v_e;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
};


/* "ws_package/controllers/activity_controller.py":2454
 *                                     activity_percentage_entity.minute)
 *                                 # Remove from set after a delay to allow database write to complete
 *                                 async def remove_after_delay():             # <<<<<<<<<<<<<<
 *                                     await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                                     self._creating_activity_percentages.discard(activity_percentage_key)
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay {
  PyObject_HEAD
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *__pyx_outer_scope;
};


/* "ws_package/controllers/activity_controller.py":2644
 *                         # Check for idle detection after break interval is saved
 *                         # NEW REQUIREMENT: Check for 2 consecutive idle intervals and trigger popup
 *                         async def check_idle_after_delay():             # <<<<<<<<<<<<<<
 *                             await asyncio.sleep(1)  # Wait for DB write to complete
 *                             logger.info("[IdleDetection] Checking for idle after break interval save")
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay {
  PyObject_HEAD
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *__pyx_outer_scope;
};


/* "ws_package/controllers/activity_controller.py":2655
 *                     finally:
 *                         # Remove from set after a delay to allow database write to complete
 *                         async def remove_after_delay():             # <<<<<<<<<<<<<<
 *                             await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                             self._creating_intervals.discard(interval_key)
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay {
  PyObject_HEAD
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *__pyx_outer_scope;
};

struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay {
  PyObject_HEAD
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *__pyx_outer_scope;
};


/* "ws_package/controllers/activity_controller.py":2849
 *                         finally:
 *                             # Remove from set after a delay to allow database write to complete
 *                             async def remove_after_delay():             # <<<<<<<<<<<<<<
 *                                 await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                                 self._creating_intervals.discard(interval_key)
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay {
  PyObject_HEAD
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *__pyx_outer_scope;
};

struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay {
  PyObject_HEAD
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *__pyx_outer_scope;
};


/* "ws_package/controllers/activity_controller.py":2897
 *                     # Check for idle detection after out-of-range interval is saved
 *                     # NEW REQUIREMENT: Check for 2 consecutive idle intervals and trigger popup
 *                     async def check_idle_after_delay():             # <<<<<<<<<<<<<<
 *                         await asyncio.sleep(1)  # Wait for DB write to complete
 *                         logger.info("[IdleDetection] Checking for idle after interval save (out of range)")
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay {
  PyObject_HEAD
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *__pyx_outer_scope;
};


/* "ws_package/controllers/activity_controller.py":2969
 *                 continue
 * 
 *     async def empty_interval(self, user_entity: UserEntity):             # <<<<<<<<<<<<<<
 *         logger.info("Running push empty intervals")
 *         current = self.last_count + 1
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval {
  PyObject_HEAD
  PyObject *__pyx_v_break_id;
  PyObject *__pyx_v_current;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_gap_end;
  PyObject *__pyx_v_gap_level;
  PyObject *__pyx_v_gap_seconds;
  PyObject *__pyx_v_gap_start;
  PyObject *__pyx_v_genexpr;
  PyObject *__pyx_v_interval_end_time;
  PyObject *__pyx_v_missing_intervals;
  PyObject *__pyx_v_overlapping;
  PyObject *__pyx_v_seg_end;
  PyObject *__pyx_v_seg_start;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_sent;
  PyObject *__pyx_v_sleep_minutes;
  PyObject *__pyx_v_start_time;
  PyObject *__pyx_v_sub_segments;
  PyObject *__pyx_v_total_fill_seconds;
  PyObject *__pyx_v_user_entity;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
  PyObject *__pyx_t_3;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  int __pyx_t_6;
};


/* "ws_package/controllers/activity_controller.py":2997
 *             # slot intervals and uploaded like regular activity  no session stop/open.
 *             if gap_seconds > 3600 and not is_silent_build():
 *                 total_fill_seconds = sum((e - s).total_seconds() for s, e in sub_segments)             # <<<<<<<<<<<<<<
 *                 logger.info(
 *                     "Sleep gap > 1 hour (gap_seconds=%.0f, fill_seconds=%.0f) - "
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr {
  PyObject_HEAD
  PyObject *__pyx_genexpr_arg_0;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_s;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
};


/* "ws_package/controllers/activity_controller.py":3086
 * 
 * 
 *     async def _push_activity_log(self, user_entity: UserEntity, stop_event=None):             # <<<<<<<<<<<<<<
 *         while not stop_event.is_set():
 *             try:
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log {
  PyObject_HEAD
  PyObject *__pyx_v_ErrorCode;
  PyObject *__pyx_v__response;
  PyObject *__pyx_v_active_app_url;
  PyObject *__pyx_v_appVersion;
  PyObject *__pyx_v_apply_desktop_key;
  PyObject *__pyx_v_current_break_id;
  PyObject *__pyx_v_current_counter;
  PyObject *__pyx_v_current_counter_held;
  PyObject *__pyx_v_current_session_counter;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_error_data;
  Py_ssize_t __pyx_v_excluded;
  PyObject *__pyx_v_filtered_intervals;
  PyObject *__pyx_v_force_upload_after_pause_cap;
  PyObject *__pyx_v_headers;
  PyObject *__pyx_9genexpr13__pyx_v_held;
  PyObject *__pyx_v_held_interval_ids;
  PyObject *__pyx_v_held_intervals;
  PyObject *__pyx_v_held_sent_count;
  PyObject *__pyx_v_idle_popup_blocking;
  PyObject *__pyx_v_interval;
  PyObject *__pyx_v_interval_payload;
  PyObject *__pyx_v_intervals;
  PyObject *__pyx_9genexpr11__pyx_v_iv;
  PyObject *__pyx_9genexpr12__pyx_v_iv;
  PyObject *__pyx_9genexpr14__pyx_v_iv;
  PyObject *__pyx_v_last_wake_time;
  PyObject *__pyx_v_org_id;
  PyObject *__pyx_v_os_type;
  PyObject *__pyx_v_payload;
  PyObject *__pyx_v_prev_day_unsent;
  PyObject *__pyx_v_response;
  PyObject *__pyx_v_screen_url;
  PyObject *__pyx_v_sd_token;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_sending_held_intervals;
  PyObject *__pyx_v_sending_intervals;
  PyObject *__pyx_v_should_pause_api;
  PyObject *__pyx_v_start;
  PyObject *__pyx_v_stop_event;
  int __pyx_v_sync_failed;
  PyObject *__pyx_v_time_since_wake;
  PyObject *__pyx_v_timeout_reached;
  PyObject *__pyx_v_url;
  PyObject *__pyx_v_user_entity;
  PyObject *__pyx_v_user_id;
  PyObject *__pyx_v_wake_detector;
  PyObject *__pyx_v_wake_stats;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  Py_ssize_t __pyx_t_7;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
};


/* "ws_package/controllers/activity_controller.py":3414
 *         return self.screenshot_manager.forward_ss(ss)
 * 
 *     async def ss(self, interval_start_time, interval_end_time, user_entity: UserEntity): # This is a validator chck if screenshot is link or not everytime and renaming before uploading             # <<<<<<<<<<<<<<
 *         ss_array = await self.activity_service.get_screenshots(interval_start_time, interval_end_time)
 *         ans_array = []
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss {
  PyObject_HEAD
  PyObject *__pyx_v_ans_array;
  PyObject *__pyx_v_del_e;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_error_message;
  PyObject *__pyx_v_interval_end_time;
  PyObject *__pyx_v_interval_start_time;
  PyObject *__pyx_v_particular_timestamp;
  PyObject *__pyx_v_response;
  PyObject *__pyx_v_s3_upload_link;
  PyObject *__pyx_v_screenshot_dir;
  PyObject *__pyx_v_screenshot_entity;
  PyObject *__pyx_v_screenshot_name;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_ss;
  PyObject *__pyx_v_ss_array;
  PyObject *__pyx_v_task;
  PyObject *__pyx_v_user_entity;
  PyObject *__pyx_t_0;
  Py_ssize_t __pyx_t_1;
  PyObject *(*__pyx_t_2)(PyObject *);
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
};


/* "ws_package/controllers/activity_controller.py":3606
 *         return False
 * 
 *     async def _verify_user_activity_during_period(self, start_time: datetime.datetime, end_time: datetime.datetime) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Verify if there was actual user activity (keyboard/mouse) during a time period.
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period {
  PyObject_HEAD
  PyObject *__pyx_v_app_data;
  PyObject *__pyx_v_current_time;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_end_time;
  PyObject *__pyx_v_idle_time_ns;
  double __pyx_v_idle_time_seconds;
  PyObject *__pyx_v_ioreg_output;
  PyObject *__pyx_v_line;
  PyObject *__pyx_v_period_duration;
  PyObject *__pyx_v_query;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_session;
  PyObject *__pyx_v_start_time;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
  PyObject *__pyx_t_9;
  PyObject *__pyx_t_10;
  PyObject *__pyx_t_11;
  PyObject *__pyx_t_12;
  PyObject *__pyx_t_13;
  PyObject *__pyx_t_14;
  PyObject *__pyx_t_15;
  PyObject *__pyx_t_16;
  PyObject *__pyx_t_17;
};


/* "ws_package/controllers/activity_controller.py":3769
 *         return ActivityIntervalMixin._get_activity_level_from_interval(self, interval)
 * 
 *     async def get_activity_level_from_db(self, start_time, end_time):             # <<<<<<<<<<<<<<
 *         return await ActivityIntervalMixin.get_activity_level_from_db(self, start_time, end_time)
 * 
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db {
  PyObject_HEAD
  PyObject *__pyx_v_end_time;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_start_time;
};


/* "ws_package/controllers/activity_controller.py":3772
 *         return await ActivityIntervalMixin.get_activity_level_from_db(self, start_time, end_time)
 * 
 *     async def _is_app_monitor_data_stale(self, app_monitor_time: datetime.datetime, wake_time: Optional[datetime.datetime]) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Check if app monitor data is stale (from before system wake).
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale {
  PyObject_HEAD
  PyObject *__pyx_v_app_monitor_time;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_time_diff;
  PyObject *__pyx_v_wake_time;
};


/* "ws_package/controllers/activity_controller.py":3790
 *         return time_diff < 30  # Within 30 seconds of wake = likely stale
 * 
 *     async def _has_any_activity_in_interval(self, start_time: datetime.datetime, end_time: datetime.datetime, counter: int) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Check if there was ANY activity (keyboard, mouse, or app monitor) during an interval.
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval {
  PyObject_HEAD
  PyObject *__pyx_v_app_data;
  double __pyx_v_average_activity;
  PyObject *__pyx_v_counter;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_end_time;
  double __pyx_v_keyboard_activity;
  double __pyx_v_mouse_activity;
  PyObject *__pyx_v_query;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_session;
  PyObject *__pyx_v_start_time;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
  PyObject *__pyx_t_9;
  PyObject *__pyx_t_10;
  PyObject *__pyx_t_11;
  PyObject *__pyx_t_12;
  PyObject *__pyx_t_13;
  PyObject *__pyx_t_14;
};


/* "ws_package/controllers/activity_controller.py":3836
 *             return False  # Fail-safe: if we can't check, assume no activity
 * 
 *     async def process_intervals_bulk(             # <<<<<<<<<<<<<<
 *         self,
 *         intervals,
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk {
  PyObject_HEAD
  PyObject *__pyx_v__dt_match;
  PyObject *__pyx_v_activity_level;
  PyObject *__pyx_v_align_stop;
  double __pyx_v_average;
  PyObject *__pyx_v_day_intervals;
  PyObject *__pyx_v_day_start_time;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_e2;
  PyObject *__pyx_v_effective_start_time;
  PyObject *__pyx_v_file_path;
  PyObject *__pyx_v_filtered_count;
  PyObject *__pyx_v_filtered_intervals;
  PyObject *__pyx_v_force_stop_time;
  PyObject *__pyx_v_gap_seconds;
  PyObject *__pyx_v_genexpr;
  PyObject *__pyx_v_grouped_intervals;
  PyObject *__pyx_v_idle_note_url;
  PyObject *__pyx_9genexpr15__pyx_v_interval;
  PyObject *__pyx_v_interval;
  PyObject *__pyx_v_interval_file_map;
  PyObject *__pyx_v_interval_id;
  PyObject *__pyx_v_interval_ids;
  PyObject *__pyx_v_interval_note_map;
  PyObject *__pyx_v_interval_payload;
  PyObject *__pyx_v_interval_payloads;
  PyObject *__pyx_v_intervals;
  int __pyx_v_is_sleep_interval;
  double __pyx_v_keyboard;
  PyObject *__pyx_v_last_in_this_day;
  PyObject *__pyx_v_last_interval;
  PyObject *__pyx_v_last_match;
  double __pyx_v_mouse;
  PyObject *__pyx_v_notes_entries;
  PyObject *__pyx_v_notes_entry;
  PyObject *__pyx_v_notes_query;
  PyObject *__pyx_v_notes_result;
  PyObject *__pyx_v_org_id;
  PyObject *__pyx_v_payload;
  PyObject *__pyx_v_payload_from;
  PyObject *__pyx_v_payload_project_id;
  PyObject *__pyx_v_payload_task_id;
  PyObject *__pyx_v_payload_to;
  PyObject *__pyx_v_pinned_start;
  PyObject *__pyx_v_project_id;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_session;
  PyObject *__pyx_v_ss_end_time;
  PyObject *__pyx_v_stop_dt;
  PyObject *__pyx_v_stop_dt_for_intervals;
  PyObject *__pyx_v_stop_value;
  PyObject *__pyx_v_target_date;
  PyObject *__pyx_v_task_id;
  PyObject *__pyx_v_user_entity;
  Py_ssize_t __pyx_t_0;
  PyObject *__pyx_t_1;
  Py_ssize_t __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
  PyObject *__pyx_t_9;
  PyObject *__pyx_t_10;
  PyObject *__pyx_t_11;
  PyObject *__pyx_t_12;
  PyObject *__pyx_t_13;
  PyObject *__pyx_t_14;
  PyObject *__pyx_t_15;
  PyObject *__pyx_t_16;
  PyObject *__pyx_t_17;
  PyObject *__pyx_t_18;
  Py_ssize_t __pyx_t_19;
  PyObject *(*__pyx_t_20)(PyObject *);
};


/* "ws_package/controllers/activity_controller.py":4076
 *                     last_in_this_day = any(
 *                         _dt_match(getattr(iv, 'start_time', None), getattr(last_interval, 'start_time', None))
 *                         and _dt_match(getattr(iv, 'end_time', None), getattr(last_interval, 'end_time', None))             # <<<<<<<<<<<<<<
 *                         and getattr(iv, 'counter', None) == getattr(last_interval, 'counter', None)
 *                         for iv in day_intervals
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr {
  PyObject_HEAD
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk *__pyx_outer_scope;
  PyObject *__pyx_genexpr_arg_0;
  PyObject *__pyx_v_iv;
};


/* "ws_package/controllers/activity_controller.py":4132
 *             yield payload, day_intervals
 * 
 *     async def delete_old_data_and_screenshots(self):             # <<<<<<<<<<<<<<
 *         """
 *         Delete old data and screenshots older than 7 days.
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots {
  PyObject_HEAD
  double __pyx_v_DB_OPERATION_TIMEOUT;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_file_location;
  PyObject *__pyx_v_file_name;
  PyObject *__pyx_v_idx;
  PyObject *__pyx_v_old_screenshots;
  PyObject *__pyx_v_result;
  PyObject *__pyx_9genexpr17__pyx_v_s;
  PyObject *__pyx_v_screenshot;
  PyObject *__pyx_v_screenshot_data;
  PyObject *__pyx_v_screenshot_ids;
  PyObject *__pyx_v_screenshot_query;
  PyObject *__pyx_v_screenshots_to_delete;
  PyObject *__pyx_v_script_path;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_session;
  PyObject *__pyx_v_seven_days_ago;
  PyObject *__pyx_v_target_directory;
  PyObject *__pyx_v_target_directory_mac;
  PyObject *__pyx_v_target_directory_stealth;
  PyObject *__pyx_v_target_directoryw;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
  PyObject *__pyx_t_9;
  PyObject *__pyx_t_10;
  PyObject *__pyx_t_11;
  PyObject *__pyx_t_12;
  PyObject *__pyx_t_13;
  PyObject *__pyx_t_14;
  PyObject *__pyx_t_15;
  PyObject *__pyx_t_16;
};


/* "ws_package/controllers/activity_controller.py":4291
 *             logger.error("Error in deleting old data and screenshots: %s", e, exc_info=True)
 * 
 *     async def start_status_activity(self, user_entity: UserEntity, stop_event):             # <<<<<<<<<<<<<<
 *         if user_entity is None:
 *             logger.error("start_status_activity called with None user_entity, cannot proceed")
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity {
  PyObject_HEAD
  PyObject *__pyx_v_ErrorCode;
  PyObject *__pyx_v__;
  PyObject *__pyx_v_chunk_duration;
  PyObject *__pyx_v_chunks;
  PyObject *__pyx_v_cleanup_enabled;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_logs_path;
  PyObject *__pyx_v_mac_log;
  PyObject *__pyx_v_perform_comprehensive_log_cleanup;
  PyObject *__pyx_v_s3_key;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_stop_event;
  PyObject *__pyx_v_task;
  PyObject *__pyx_v_timestamp;
  PyObject *__pyx_v_total_sleep;
  PyObject *__pyx_v_user_entity;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
  PyObject *__pyx_t_9;
};


/* "ws_package/controllers/activity_controller.py":4400
 *         self.timezone_manager.set_local_timezone(user_entity)
 * 
 *     async def db_to_server(self, user_entity: UserEntity):             # <<<<<<<<<<<<<<
 *         logger.info("Running db to server")
 *         if getattr(sys, 'frozen', False) and platform.system() == "Linux":
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server {
  PyObject_HEAD
  PyObject *__pyx_v_copy_error;
  PyObject *__pyx_v_copy_size;
  PyObject *__pyx_v_database_dir;
  PyObject *__pyx_v_database_server;
  PyObject *__pyx_v_dt_obj;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_original_size;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_script_path;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_target_directory;
  PyObject *__pyx_v_temp_file;
  PyObject *__pyx_v_temp_file_path;
  PyObject *__pyx_v_timestamp_db;
  PyObject *__pyx_v_unix_timestamp;
  PyObject *__pyx_v_upload_error;
  PyObject *__pyx_v_user_entity;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
};


/* "ws_package/controllers/activity_controller.py":4512
 *             # Continue processing - don't fail the entire operation
 * 
 *     async def getting_unsent_interval(self, user_entity: UserEntity):             # <<<<<<<<<<<<<<
 *         """Return unsent (``is_uploaded=False``) non-break activity intervals eligible for upload.
 * 
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval {
  PyObject_HEAD
  double __pyx_v_DB_OPERATION_TIMEOUT;
  PyObject *__pyx_v_current_counter;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_first_date;
  PyObject *__pyx_v_first_entry;
  PyObject *__pyx_v_first_entry_counter;
  PyObject *__pyx_v_intervals;
  PyObject *__pyx_v_query;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_session;
  PyObject *__pyx_v_today;
  PyObject *__pyx_v_user_entity;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
  PyObject *__pyx_t_9;
  PyObject *__pyx_t_10;
  PyObject *__pyx_t_11;
};


/* "ws_package/controllers/activity_controller.py":4608
 *                     return []
 * 
 *     async def sending_unsent_intervals(self, start, prev_day_unsent, user_entity: UserEntity):             # <<<<<<<<<<<<<<
 *         logger.info("Sending previous day unsent intervals")
 *         try:
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals {
  PyObject_HEAD
  PyObject *__pyx_v__response;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_final_payload;
  PyObject *__pyx_v_interval;
  PyObject *__pyx_v_interval_id;
  PyObject *__pyx_v_interval_payload;
  PyObject *__pyx_v_org_id;
  PyObject *__pyx_v_payload;
  PyObject *__pyx_v_prev_day_unsent;
  PyObject *__pyx_v_project_id;
  PyObject *__pyx_v_response;
  PyObject *__pyx_v_screen_url;
  PyObject *__pyx_v_sd_token;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_start;
  PyObject *__pyx_v_task_id;
  PyObject *__pyx_v_user_entity;
  PyObject *__pyx_v_user_id;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  Py_ssize_t __pyx_t_7;
};


/* "ws_package/controllers/activity_controller.py":4831
 *         return work_stop.replace(microsecond=0) + datetime.timedelta(seconds=1)
 * 
 *     async def last_api_call(             # <<<<<<<<<<<<<<
 *         self,
 *         user_entity: UserEntity,
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call {
  PyObject_HEAD
  PyObject *__pyx_v_close_time;
  int __pyx_v_keep_idle_time;
  PyObject *__pyx_v_payload_project_id;
  PyObject *__pyx_v_payload_task_id;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_user_entity;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
};


/* "ws_package/controllers/activity_controller.py":4850
 *             )
 * 
 *     async def _last_api_call_impl(             # <<<<<<<<<<<<<<
 *         self,
 *         user_entity: UserEntity,
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl {
  PyObject_HEAD
  PyObject *__pyx_v__response;
  PyObject *__pyx_v_activityLevel;
  PyObject *__pyx_v_activity_level;
  PyObject *__pyx_v_activity_queue_size;
  PyObject *__pyx_v_already_in_list;
  int __pyx_v_at_least_one_batch_successful;
  PyObject *__pyx_v_attempt;
  double __pyx_v_average;
  PyObject *__pyx_v_break_start_time;
  PyObject *__pyx_v_close_time;
  PyObject *__pyx_v_current_break_id;
  PyObject *__pyx_v_current_session_counter;
  PyObject *__pyx_v_current_session_counter_for_last;
  PyObject *__pyx_v_datetime_matches;
  PyObject *__pyx_v_datetime_matches_final;
  PyObject *__pyx_v_db_interval;
  PyObject *__pyx_v_db_last;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_end_date;
  PyObject *__pyx_v_et;
  PyObject *__pyx_v_fallback_error;
  PyObject *__pyx_v_gap_seconds;
  PyObject *__pyx_v_genexpr;
  PyObject *__pyx_v_has_zero_activity;
  PyObject *__pyx_v_idx;
  PyObject *__pyx_v_interval;
  PyObject *__pyx_v_interval_end_date;
  int __pyx_v_interval_is_uploaded;
  PyObject *__pyx_v_interval_payload;
  PyObject *__pyx_v_interval_to_update;
  int __pyx_v_interval_verified;
  PyObject *__pyx_v_intervals;
  PyObject *__pyx_v_intervals_to_update;
  PyObject *__pyx_v_intervals_updated_count;
  PyObject *__pyx_v_is_idle;
  int __pyx_v_is_sleep_interval;
  int __pyx_v_is_sleep_interval_for_manual_check;
  int __pyx_v_keep_idle_time;
  double __pyx_v_keyboard;
  PyObject *__pyx_v_last_interval;
  PyObject *__pyx_v_last_interval_end;
  PyObject *__pyx_v_last_interval_found;
  PyObject *__pyx_v_last_interval_id;
  PyObject *__pyx_v_last_interval_in_list;
  PyObject *__pyx_v_last_interval_obj;
  int __pyx_v_last_interval_updated;
  PyObject *__pyx_v_last_interval_was_sent;
  PyObject *__pyx_v_last_ss_urls;
  PyObject *__pyx_v_max_retries;
  PyObject *__pyx_v_max_verification_retries;
  double __pyx_v_mouse;
  PyObject *__pyx_v_payload_project_id;
  PyObject *__pyx_v_payload_task_id;
  PyObject *__pyx_v_popup_is_active;
  PyObject *__pyx_v_processed_count;
  PyObject *__pyx_v_q;
  PyObject *__pyx_v_query;
  PyObject *__pyx_v_res;
  PyObject *__pyx_v_response;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_retry_delays;
  PyObject *__pyx_v_screen_url;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_sending_intervals;
  PyObject *__pyx_v_session;
  int __pyx_v_should_upload;
  PyObject *__pyx_v_st;
  PyObject *__pyx_v_start_date;
  PyObject *__pyx_v_time_diff_seconds;
  PyObject *__pyx_v_tol;
  PyObject *__pyx_v_total_queue_size;
  PyObject *__pyx_v_trimmed_partial;
  int __pyx_v_trimmed_partial_used;
  PyObject *__pyx_v_unsent_intervals;
  PyObject *__pyx_v_updated_interval_ids;
  PyObject *__pyx_v_user_entity;
  double __pyx_v_verification_delay;
  PyObject *__pyx_v_verify_attempt;
  PyObject *__pyx_v_verify_error;
  PyObject *__pyx_v_work_stop;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
  PyObject *__pyx_t_9;
  PyObject *__pyx_t_10;
  PyObject *__pyx_t_11;
  PyObject *__pyx_t_12;
  PyObject *__pyx_t_13;
  PyObject *__pyx_t_14;
  PyObject *__pyx_t_15;
  PyObject *__pyx_t_16;
  PyObject *__pyx_t_17;
  PyObject *(*__pyx_t_18)(PyObject *);
  PyObject *__pyx_t_19;
  PyObject *__pyx_t_20;
  PyObject *__pyx_t_21;
  PyObject *__pyx_t_22;
  Py_ssize_t __pyx_t_23;
  PyObject *(*__pyx_t_24)(PyObject *);
  Py_ssize_t __pyx_t_25;
};


/* "ws_package/controllers/activity_controller.py":5173
 *                         # This handles datetime precision differences between saved and queried intervals
 *                         last_interval_found = any(
 *                             datetime_matches(getattr(interval, 'start_time', None), last_interval.start_time) and             # <<<<<<<<<<<<<<
 *                             datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                             getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr {
  PyObject_HEAD
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl *__pyx_outer_scope;
  PyObject *__pyx_genexpr_arg_0;
  PyObject *__pyx_v_interval;
};


/* "ws_package/controllers/activity_controller.py":5258
 *                                 # Check if last_interval is already in the list (might have been added by another process)
 *                                 already_in_list = any(
 *                                     datetime_matches(getattr(interval, 'start_time', None), last_interval.start_time) and             # <<<<<<<<<<<<<<
 *                                     datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                                     getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr {
  PyObject_HEAD
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl *__pyx_outer_scope;
  PyObject *__pyx_genexpr_arg_0;
  PyObject *__pyx_v_interval;
};


/* "ws_package/controllers/activity_controller.py":5299
 * 
 *                     last_interval_in_list = any(
 *                         datetime_matches_final(getattr(interval, 'start_time', None), last_interval.start_time) and             # <<<<<<<<<<<<<<
 *                         datetime_matches_final(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                         getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr {
  PyObject_HEAD
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl *__pyx_outer_scope;
  PyObject *__pyx_genexpr_arg_0;
  PyObject *__pyx_v_interval;
};


/* "ws_package/controllers/activity_controller.py":5472
 *                 # Verify last_interval was actually sent by checking if it's in the original intervals list
 *                 last_interval_was_sent = any(
 *                     (hasattr(interval, 'start_time') and hasattr(last_interval, 'start_time') and             # <<<<<<<<<<<<<<
 *                      hasattr(interval, 'end_time') and hasattr(last_interval, 'end_time') and
 *                      hasattr(interval, 'counter') and hasattr(last_interval, 'counter') and
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr {
  PyObject_HEAD
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl *__pyx_outer_scope;
  PyObject *__pyx_genexpr_arg_0;
  PyObject *__pyx_v_interval;
};


/* "ws_package/controllers/activity_controller.py":5643
 *             raise  # Re-raise to let caller know it failed
 * 
 *     async def stop_event(self, user_entity: UserEntity, keep_idle_time: bool = True):             # <<<<<<<<<<<<<<
 *         """Stop all activity monitoring and cleanup resources"""
 *         try:
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event {
  PyObject_HEAD
  PyObject *__pyx_v_break_error;
  PyObject *__pyx_v_e;
  int __pyx_v_keep_idle_time;
  PyObject *__pyx_v_query;
  PyObject *__pyx_v_remaining_break_intervals;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_session;
  int __pyx_v_should_skip_break_processing;
  PyObject *__pyx_v_time_since_break_stop;
  PyObject *__pyx_v_user_entity;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
  PyObject *__pyx_t_9;
  PyObject *__pyx_t_10;
  PyObject *__pyx_t_11;
  PyObject *__pyx_t_12;
  PyObject *__pyx_t_13;
  PyObject *__pyx_t_14;
  PyObject *__pyx_t_15;
  PyObject *__pyx_t_16;
  PyObject *__pyx_t_17;
};


/* "ws_package/controllers/activity_controller.py":5716
 *             return False
 * 
 *     async def _send_active_app_update_to_electron(self, app_name: str, app_icon: Optional[str] = None):             # <<<<<<<<<<<<<<
 *         """
 *         Send active app update to Electron for UI display.
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron {
  PyObject_HEAD
  PyObject *__pyx_v_app_icon;
  PyObject *__pyx_v_app_name;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_electron_comm;
  PyObject *__pyx_v_message_data;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_success;
};


/* "ws_package/controllers/activity_controller.py":5752
 *             logger.error("Error sending active app update to Electron: %s", e, exc_info=True)
 * 
 *     async def _send_file_upload_success_to_electron(self, s3_url: str):             # <<<<<<<<<<<<<<
 *         """Sends file upload success message to Electron for UI notification."""
 *         try:
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron {
  PyObject_HEAD
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_electron_comm;
  PyObject *__pyx_v_message_data;
  PyObject *__pyx_v_s3_url;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_success;
};


/* "ws_package/controllers/activity_controller.py":5783
 *             return False
 * 
 *     async def _send_file_upload_failure_to_electron(self):             # <<<<<<<<<<<<<<
 *         """Sends file upload failure message to Electron for UI notification."""
 *         try:
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron {
  PyObject_HEAD
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_electron_comm;
  PyObject *__pyx_v_message_data;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_success;
};


/* "ws_package/controllers/activity_controller.py":5813
 *             return False
 * 
 *     async def check_idle_popup_timeout(self) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Check if 60 minutes have passed since idle popup was triggered.
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout {
  PyObject_HEAD
  PyObject *__pyx_v_activity_count;
  PyObject *__pyx_v_all_intervals;
  PyObject *__pyx_v_current_time;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_elapsed_seconds;
  PyObject *__pyx_v_electron_comm;
  PyObject *__pyx_v_idle_count;
  PyObject *__pyx_v_interval;
  PyObject *__pyx_v_interval_ids;
  PyObject *__pyx_v_query;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_session;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
  PyObject *__pyx_t_9;
  PyObject *__pyx_t_10;
  PyObject *__pyx_t_11;
  PyObject *__pyx_t_12;
  PyObject *__pyx_t_13;
  PyObject *__pyx_t_14;
};


/* "ws_package/controllers/activity_controller.py":5906
 *             return False
 * 
 *     async def arise_idle_popup(self):             # <<<<<<<<<<<<<<
 *         """
 *         Trigger idle popup in Electron app.
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup {
  PyObject_HEAD
  PyObject *__pyx_v_attempt;
  PyObject *__pyx_v_consecutive_idle_count;
  PyObject *__pyx_v_current_break_id;
  PyObject *__pyx_v_current_time;
  PyObject *__pyx_v_delay;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_electron_comm;
  PyObject *__pyx_v_is_connected;
  PyObject *__pyx_v_max_retries;
  PyObject *__pyx_v_retry_delays;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_success;
  PyObject *__pyx_v_timeout_reached;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *(*__pyx_t_4)(PyObject *);
};


/* "ws_package/controllers/activity_controller.py":6021
 *             logger.error("Error triggering idle popup: %s", e, exc_info=True)
 * 
 *     async def _has_zero_activity_for_interval(self, start_date: datetime.datetime, end_date: datetime.datetime) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Check if an interval has zero activity in both activityLevel and activity_percentage.
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval {
  PyObject_HEAD
  PyObject *__pyx_v_activityLevel;
  PyObject *__pyx_v_activity_percentage;
  double __pyx_v_average;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_end_date;
  PyObject *__pyx_v_has_activity_level_activity;
  PyObject *__pyx_v_has_activity_percentage_activity;
  double __pyx_v_keyboard;
  double __pyx_v_mouse;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_start_date;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
};


/* "ws_package/controllers/activity_controller.py":6062
 *             return False
 * 
 *     async def handle_idle_popup_response(self, keep_idle_time: bool, action: str, project_id: Optional[str] = None, task_id: Optional[str] = None, note: Optional[str] = None, file_path: Optional[str] = None):             # <<<<<<<<<<<<<<
 *         """
 *         Handle idle popup response from Electron.
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response {
  PyObject_HEAD
  long __pyx_v_MAX_NOTE_LENGTH;
  PyObject *__pyx_v_action;
  PyObject *__pyx_v_current_counter;
  PyObject *__pyx_v_current_counter_held;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_file_path;
  int __pyx_v_file_upload_success;
  PyObject *__pyx_v_interval;
  PyObject *__pyx_9genexpr22__pyx_v_iv;
  PyObject *__pyx_9genexpr23__pyx_v_iv;
  PyObject *__pyx_9genexpr24__pyx_v_iv;
  int __pyx_v_keep_idle_time;
  PyObject *__pyx_v_note;
  PyObject *__pyx_v_note_text;
  Py_ssize_t __pyx_v_original_length;
  PyObject *__pyx_v_project_id;
  PyObject *__pyx_v_s3_file_url;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_task_id;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
};


/* "ws_package/controllers/activity_controller.py":6207
 *         logger.debug("Idle popup shown confirmed by Electron (cooldown removed)")
 * 
 *     async def sync_activity_immediately(self):             # <<<<<<<<<<<<<<
 *         """
 *         Immediately sync all unuploaded activity intervals to the server.
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately {
  PyObject_HEAD
  PyObject *__pyx_v_api_response;
  PyObject *__pyx_v_batch_intervals;
  PyObject *__pyx_v_current_session_counter;
  PyObject *__pyx_v_day_payload;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_interval;
  PyObject *__pyx_v_interval_data;
  PyObject *__pyx_v_intervals;
  PyObject *__pyx_v_org_id;
  PyObject *__pyx_v_payload;
  PyObject *__pyx_v_response;
  PyObject *__pyx_v_screen_url;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_user_entity;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
  PyObject *__pyx_t_9;
  PyObject *__pyx_t_10;
  Py_ssize_t __pyx_t_11;
  PyObject *(*__pyx_t_12)(PyObject *);
};


/* "ws_package/controllers/activity_controller.py":6280
 *             logger.error("Error in sync_activity_immediately: %s", e, exc_info=True)
 * 
 *     async def _mark_idle_intervals_as_uploaded(self):             # <<<<<<<<<<<<<<
 *         """
 *         Mark idle intervals as is_uploaded=True so they are never sent to the server.
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded {
  PyObject_HEAD
  PyObject *__pyx_v_all_query;
  PyObject *__pyx_v_all_result;
  PyObject *__pyx_v_current_counter;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_has_zero;
  PyObject *__pyx_v_idle_flag_query;
  PyObject *__pyx_v_idle_flag_result;
  PyObject *__pyx_9genexpr25__pyx_v_iid;
  PyObject *__pyx_v_interval;
  PyObject *__pyx_v_interval_id_list;
  PyObject *__pyx_v_interval_ids;
  PyObject *__pyx_v_popup_query;
  PyObject *__pyx_v_popup_result;
  PyObject *__pyx_v_popup_triggered_at;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_session;
  PyObject *__pyx_v_updates;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
  PyObject *__pyx_t_9;
  PyObject *__pyx_t_10;
  PyObject *__pyx_t_11;
  Py_ssize_t __pyx_t_12;
  PyObject *(*__pyx_t_13)(PyObject *);
  PyObject *__pyx_t_14;
  PyObject *__pyx_t_15;
  PyObject *__pyx_t_16;
};


/* "ws_package/controllers/activity_controller.py":6380
 *             logger.error("Error marking idle intervals as uploaded: %s", e, exc_info=True)
 * 
 *     async def _upload_file_to_s3(self, local_file_path: str) -> Optional[str]:             # <<<<<<<<<<<<<<
 *         """
 *         Upload a file to S3 and return the S3 URL.
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3 {
  PyObject_HEAD
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_file_name;
  PyObject *__pyx_v_local_file_path;
  PyObject *__pyx_v_org_id;
  PyObject *__pyx_v_s3_config;
  PyObject *__pyx_v_s3_dest_path;
  PyObject *__pyx_v_s3_sync;
  PyObject *__pyx_v_s3_url;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_timestamp;
  PyObject *__pyx_v_user_entity;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
};


/* "ws_package/controllers/activity_controller.py":6447
 *             return None
 * 
 *     async def _save_note_to_idle_intervals(self, note: str, file_path: Optional[str] = None):             # <<<<<<<<<<<<<<
 *         """
 *         Save note to Notes table with array of idle interval IDs.
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals {
  PyObject_HEAD
  PyObject *__pyx_v_all_intervals;
  PyObject *__pyx_v_current_counter;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_file_path;
  PyObject *__pyx_v_has_zero_activity;
  PyObject *__pyx_v_idle_intervals;
  PyObject *__pyx_v_idle_intervals_by_flag;
  PyObject *__pyx_9genexpr26__pyx_v_interval;
  PyObject *__pyx_v_interval;
  PyObject *__pyx_v_interval_ids;
  PyObject *__pyx_v_intervals_to_mark;
  PyObject *__pyx_v_note;
  PyObject *__pyx_v_note_data;
  PyObject *__pyx_v_query_all;
  PyObject *__pyx_v_query_by_flag;
  PyObject *__pyx_v_result_all;
  PyObject *__pyx_v_result_by_flag;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_session;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
  PyObject *__pyx_t_9;
  PyObject *__pyx_t_10;
  PyObject *__pyx_t_11;
  Py_ssize_t __pyx_t_12;
  PyObject *(*__pyx_t_13)(PyObject *);
  PyObject *__pyx_t_14;
  PyObject *__pyx_t_15;
  PyObject *__pyx_t_16;
};


/* "ws_package/controllers/activity_controller.py":6536
 *             logger.error("Error saving note to Notes table: %s", e, exc_info=True)
 * 
 *     async def _save_note_to_current_interval(self, note: str, file_path: Optional[str] = None):             # <<<<<<<<<<<<<<
 *         """
 *         Save note to Notes table with current running interval ID.
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval {
  PyObject_HEAD
  PyObject *__pyx_v_current_counter;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_enqueue_success;
  PyObject *__pyx_v_file_path;
  PyObject *__pyx_v_latest_interval;
  PyObject *__pyx_v_note;
  PyObject *__pyx_v_note_data;
  PyObject *__pyx_v_query;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_session;
  PyObject *__pyx_v_target_interval_id;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
  PyObject *__pyx_t_9;
  PyObject *__pyx_t_10;
  PyObject *__pyx_t_11;
  PyObject *__pyx_t_12;
  PyObject *__pyx_t_13;
  PyObject *__pyx_t_14;
};


/* "ws_package/controllers/activity_controller.py":6606
 * 
 * 
 *     async def _should_pause_api_calls(self, intervals: list) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Check if API calls should be paused.
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls {
  PyObject_HEAD
  PyObject *__pyx_v_activity_level;
  double __pyx_v_average;
  PyObject *__pyx_v_current_counter;
  PyObject *__pyx_v_current_counter_intervals;
  PyObject *__pyx_v_db_interval;
  PyObject *__pyx_v_db_intervals;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_genexpr;
  PyObject *__pyx_v_idle_intervals;
  PyObject *__pyx_v_interval;
  PyObject *__pyx_v_interval_ids_in_list;
  PyObject *__pyx_v_intervals;
  PyObject *__pyx_9genexpr27__pyx_v_iv;
  PyObject *__pyx_9genexpr28__pyx_v_iv;
  double __pyx_v_keyboard;
  double __pyx_v_mouse;
  PyObject *__pyx_v_non_idle_intervals;
  PyObject *__pyx_v_query;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_session;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
  PyObject *__pyx_t_9;
  PyObject *__pyx_t_10;
  PyObject *__pyx_t_11;
  PyObject *__pyx_t_12;
  PyObject *__pyx_t_13;
  PyObject *__pyx_t_14;
  PyObject *__pyx_t_15;
  PyObject *__pyx_t_16;
  PyObject *__pyx_t_17;
};


/* "ws_package/controllers/activity_controller.py":6707
 *                 for interval in idle_intervals:
 *                     # Check if already held (by ID to avoid duplicates)
 *                     if not any(getattr(held, 'id', None) == getattr(interval, 'id', None) for held in self._held_idle_intervals):             # <<<<<<<<<<<<<<
 *                         self._held_idle_intervals.append(interval)
 *                         logger.info("[APIBlock] Holding idle interval (id=%s, counter=%s, start=%s, end=%s) - will send when non-idle interval found or popup handled", interval.id, getattr(interval, 'counter', 'N/A'), interval.start_time, interval.end_time)
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr {
  PyObject_HEAD
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls *__pyx_outer_scope;
  PyObject *__pyx_genexpr_arg_0;
  PyObject *__pyx_v_held;
};


/* "ws_package/controllers/activity_controller.py":6729
 * 
 * 
 *     async def _idle_reassign(self, project_id: str, task_id: Optional[str] = None):             # <<<<<<<<<<<<<<
 *         """
 *         Reassign idle intervals to a new project and task by sending them to the API with the new project/task IDs.
*/
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign {
  PyObject_HEAD
  PyObject *__pyx_v_activity_level;
  PyObject *__pyx_v_activity_manager;
  PyObject *__pyx_v_app_and_urls;
  PyObject *__pyx_v_day_intervals;
  PyObject *__pyx_v_day_start_time;
  PyObject *__pyx_v_e;
  PyObject *__pyx_v_effective_start_time;
  PyObject *__pyx_v_failed_count;
  PyObject *__pyx_v_grouped_intervals;
  PyObject *__pyx_v_idle_intervals;
  PyObject *__pyx_9genexpr30__pyx_v_interval;
  PyObject *__pyx_v_interval;
  PyObject *__pyx_v_interval_id;
  PyObject *__pyx_v_interval_ids;
  PyObject *__pyx_v_interval_note_map;
  PyObject *__pyx_v_interval_payload;
  PyObject *__pyx_v_interval_payloads;
  PyObject *__pyx_v_notes_entries;
  PyObject *__pyx_v_notes_entry;
  PyObject *__pyx_v_notes_query;
  PyObject *__pyx_v_notes_result;
  PyObject *__pyx_v_payload;
  PyObject *__pyx_v_payload_from;
  PyObject *__pyx_v_payload_to;
  PyObject *__pyx_v_project_id;
  PyObject *__pyx_v_project_id_str;
  PyObject *__pyx_v_query;
  PyObject *__pyx_v_response;
  PyObject *__pyx_v_result;
  PyObject *__pyx_v_screen_url;
  PyObject *__pyx_v_self;
  PyObject *__pyx_v_session;
  PyObject *__pyx_v_success_count;
  PyObject *__pyx_v_target_date;
  PyObject *__pyx_v_task_id;
  PyObject *__pyx_v_task_id_str;
  PyObject *__pyx_t_0;
  PyObject *__pyx_t_1;
  PyObject *__pyx_t_2;
  PyObject *__pyx_t_3;
  PyObject *__pyx_t_4;
  PyObject *__pyx_t_5;
  PyObject *__pyx_t_6;
  PyObject *__pyx_t_7;
  PyObject *__pyx_t_8;
  PyObject *__pyx_t_9;
  PyObject *__pyx_t_10;
  PyObject *__pyx_t_11;
  PyObject *__pyx_t_12;
  PyObject *__pyx_t_13;
  PyObject *__pyx_t_14;
  Py_ssize_t __pyx_t_15;
  Py_ssize_t __pyx_t_16;
  int __pyx_t_17;
  PyObject *__pyx_t_18;
  PyObject *__pyx_t_19;
  PyObject *__pyx_t_20;
  PyObject *__pyx_t_21;
  PyObject *__pyx_t_22;
  PyObject *__pyx_t_23;
  PyObject *__pyx_t_24;
  Py_ssize_t __pyx_t_25;
  PyObject *(*__pyx_t_26)(PyObject *);
};

/* #### Code section: utility_code_proto ### */

/* --- Runtime support code (head) --- */
/* Refnanny.proto */
#ifndef CYTHON_REFNANNY
  #define CYTHON_REFNANNY 0
#endif
#if CYTHON_REFNANNY
  typedef struct {
    void (*INCREF)(void*, PyObject*, Py_ssize_t);
    void (*DECREF)(void*, PyObject*, Py_ssize_t);
    void (*GOTREF)(void*, PyObject*, Py_ssize_t);
    void (*GIVEREF)(void*, PyObject*, Py_ssize_t);
    void* (*SetupContext)(const char*, Py_ssize_t, const char*);
    void (*FinishContext)(void**);
  } __Pyx_RefNannyAPIStruct;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
  #define __Pyx_RefNannySetupContext(name, acquire_gil)\
          if (acquire_gil) {\
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\
              PyGILState_Release(__pyx_gilstate_save);\
          } else {\
              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), (__LINE__), (__FILE__));\
          }
  #define __Pyx_RefNannyFinishContextNogil() {\
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
              __Pyx_RefNannyFinishContext();\
              PyGILState_Release(__pyx_gilstate_save);\
          }
  #define __Pyx_RefNannyFinishContextNogil() {\
              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
              __Pyx_RefNannyFinishContext();\
              PyGILState_Release(__pyx_gilstate_save);\
          }
  #define __Pyx_RefNannyFinishContext()\
          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), (__LINE__))
  #define __Pyx_XINCREF(r)  do { if((r) == NULL); else {__Pyx_INCREF(r); }} while(0)
  #define __Pyx_XDECREF(r)  do { if((r) == NULL); else {__Pyx_DECREF(r); }} while(0)
  #define __Pyx_XGOTREF(r)  do { if((r) == NULL); else {__Pyx_GOTREF(r); }} while(0)
  #define __Pyx_XGIVEREF(r) do { if((r) == NULL); else {__Pyx_GIVEREF(r);}} while(0)
#else
  #define __Pyx_RefNannyDeclarations
  #define __Pyx_RefNannySetupContext(name, acquire_gil)
  #define __Pyx_RefNannyFinishContextNogil()
  #define __Pyx_RefNannyFinishContext()
  #define __Pyx_INCREF(r) Py_INCREF(r)
  #define __Pyx_DECREF(r) Py_DECREF(r)
  #define __Pyx_GOTREF(r)
  #define __Pyx_GIVEREF(r)
  #define __Pyx_XINCREF(r) Py_XINCREF(r)
  #define __Pyx_XDECREF(r) Py_XDECREF(r)
  #define __Pyx_XGOTREF(r)
  #define __Pyx_XGIVEREF(r)
#endif
#define __Pyx_Py_XDECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; Py_XDECREF(tmp);\
    } while (0)
#define __Pyx_XDECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_XDECREF(tmp);\
    } while (0)
#define __Pyx_DECREF_SET(r, v) do {\
        PyObject *tmp = (PyObject *) r;\
        r = v; __Pyx_DECREF(tmp);\
    } while (0)
#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)

/* PyErrExceptionMatches.proto (used by PyObjectGetAttrStrNoError) */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
#else
#define __Pyx_PyErr_ExceptionMatches(err)  PyErr_ExceptionMatches(err)
#endif

/* PyThreadStateGet.proto (used by PyErrFetchRestore) */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyThreadState_declare  PyThreadState *__pyx_tstate;
#define __Pyx_PyThreadState_assign  __pyx_tstate = __Pyx_PyThreadState_Current;
#if PY_VERSION_HEX >= 0x030C00A6
#define __Pyx_PyErr_Occurred()  (__pyx_tstate->current_exception != NULL)
#define __Pyx_PyErr_CurrentExceptionType()  (__pyx_tstate->current_exception ? (PyObject*) Py_TYPE(__pyx_tstate->current_exception) : (PyObject*) NULL)
#else
#define __Pyx_PyErr_Occurred()  (__pyx_tstate->curexc_type != NULL)
#define __Pyx_PyErr_CurrentExceptionType()  (__pyx_tstate->curexc_type)
#endif
#else
#define __Pyx_PyThreadState_declare
#define __Pyx_PyThreadState_assign
#define __Pyx_PyErr_Occurred()  (PyErr_Occurred() != NULL)
#define __Pyx_PyErr_CurrentExceptionType()  PyErr_Occurred()
#endif

/* PyErrFetchRestore.proto (used by PyObjectGetAttrStrNoError) */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
#define __Pyx_ErrRestoreWithState(type, value, tb)  __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)    __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)    __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A6
#define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
#else
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#endif
#else
#define __Pyx_PyErr_Clear() PyErr_Clear()
#define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
#define __Pyx_ErrRestoreWithState(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchWithState(type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestoreInState(tstate, type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetchInState(tstate, type, value, tb)  PyErr_Fetch(type, value, tb)
#define __Pyx_ErrRestore(type, value, tb)  PyErr_Restore(type, value, tb)
#define __Pyx_ErrFetch(type, value, tb)  PyErr_Fetch(type, value, tb)
#endif

/* PyObjectGetAttrStr.proto (used by PyObjectGetAttrStrNoError) */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
#else
#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
#endif

/* PyObjectGetAttrStrNoError.proto (used by GetBuiltinName) */
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name);

/* GetBuiltinName.proto */
static PyObject *__Pyx_GetBuiltinName(PyObject *name);

/* TupleAndListFromArray.proto (used by fastcall) */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n);
#endif
#if CYTHON_COMPILING_IN_CPYTHON || CYTHON_METH_FASTCALL
static CYTHON_INLINE PyObject* __Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n);
#endif

/* IncludeStringH.proto (used by BytesEquals) */
#include <string.h>

/* BytesEquals.proto (used by UnicodeEquals) */
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);

/* UnicodeEquals.proto (used by fastcall) */
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);

/* fastcall.proto */
#if CYTHON_AVOID_BORROWED_REFS
    #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_PySequence_ITEM(args, i)
#elif CYTHON_ASSUME_SAFE_MACROS
    #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_NewRef(__Pyx_PyTuple_GET_ITEM(args, i))
#else
    #define __Pyx_ArgRef_VARARGS(args, i) __Pyx_XNewRef(PyTuple_GetItem(args, i))
#endif
#define __Pyx_NumKwargs_VARARGS(kwds) PyDict_Size(kwds)
#define __Pyx_KwValues_VARARGS(args, nargs) NULL
#define __Pyx_GetKwValue_VARARGS(kw, kwvalues, s) __Pyx_PyDict_GetItemStrWithError(kw, s)
#define __Pyx_KwargsAsDict_VARARGS(kw, kwvalues) PyDict_Copy(kw)
#if CYTHON_METH_FASTCALL
    #define __Pyx_ArgRef_FASTCALL(args, i) __Pyx_NewRef(args[i])
    #define __Pyx_NumKwargs_FASTCALL(kwds) __Pyx_PyTuple_GET_SIZE(kwds)
    #define __Pyx_KwValues_FASTCALL(args, nargs) ((args) + (nargs))
    static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API
    CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues);
  #else
    #define __Pyx_KwargsAsDict_FASTCALL(kw, kwvalues) _PyStack_AsDict(kwvalues, kw)
  #endif
#else
    #define __Pyx_ArgRef_FASTCALL __Pyx_ArgRef_VARARGS
    #define __Pyx_NumKwargs_FASTCALL __Pyx_NumKwargs_VARARGS
    #define __Pyx_KwValues_FASTCALL __Pyx_KwValues_VARARGS
    #define __Pyx_GetKwValue_FASTCALL __Pyx_GetKwValue_VARARGS
    #define __Pyx_KwargsAsDict_FASTCALL __Pyx_KwargsAsDict_VARARGS
#endif
#define __Pyx_ArgsSlice_VARARGS(args, start, stop) PyTuple_GetSlice(args, start, stop)
#if CYTHON_METH_FASTCALL
#define __Pyx_ArgsSlice_FASTCALL(args, start, stop) __Pyx_PyTuple_FromArray(args + start, stop - start)
#else
#define __Pyx_ArgsSlice_FASTCALL __Pyx_ArgsSlice_VARARGS
#endif

/* py_dict_items.proto (used by OwnedDictNext) */
static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d);

/* CallCFunction.proto (used by CallUnboundCMethod0) */
#define __Pyx_CallCFunction(cfunc, self, args)\
    ((PyCFunction)(void(*)(void))(cfunc)->func)(self, args)
#define __Pyx_CallCFunctionWithKeywords(cfunc, self, args, kwargs)\
    ((PyCFunctionWithKeywords)(void(*)(void))(cfunc)->func)(self, args, kwargs)
#define __Pyx_CallCFunctionFast(cfunc, self, args, nargs)\
    ((__Pyx_PyCFunctionFast)(void(*)(void))(PyCFunction)(cfunc)->func)(self, args, nargs)
#define __Pyx_CallCFunctionFastWithKeywords(cfunc, self, args, nargs, kwnames)\
    ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))(PyCFunction)(cfunc)->func)(self, args, nargs, kwnames)

/* PyObjectCall.proto (used by PyObjectFastCall) */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
#else
#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
#endif

/* PyObjectCallMethO.proto (used by PyObjectFastCall) */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
#endif

/* PyObjectFastCall.proto (used by PyObjectCallOneArg) */
#define __Pyx_PyObject_FastCall(func, args, nargs)  __Pyx_PyObject_FastCallDict(func, args, (size_t)(nargs), NULL)
static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject * const*args, size_t nargs, PyObject *kwargs);

/* PyObjectCallOneArg.proto (used by CallUnboundCMethod0) */
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);

/* UnpackUnboundCMethod.proto (used by CallUnboundCMethod0) */
typedef struct {
    PyObject *type;
    PyObject **method_name;
#if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && CYTHON_ATOMICS
    __pyx_atomic_int_type initialized;
#endif
    PyCFunction func;
    PyObject *method;
    int flag;
} __Pyx_CachedCFunction;
#if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
static CYTHON_INLINE int __Pyx_CachedCFunction_GetAndSetInitializing(__Pyx_CachedCFunction *cfunc) {
#if !CYTHON_ATOMICS
    return 1;
#else
    __pyx_nonatomic_int_type expected = 0;
    if (__pyx_atomic_int_cmp_exchange(&cfunc->initialized, &expected, 1)) {
        return 0;
    }
    return expected;
#endif
}
static CYTHON_INLINE void __Pyx_CachedCFunction_SetFinishedInitializing(__Pyx_CachedCFunction *cfunc) {
#if CYTHON_ATOMICS
    __pyx_atomic_store(&cfunc->initialized, 2);
#endif
}
#else
#define __Pyx_CachedCFunction_GetAndSetInitializing(cfunc) 2
#define __Pyx_CachedCFunction_SetFinishedInitializing(cfunc)
#endif

/* CallUnboundCMethod0.proto */
CYTHON_UNUSED
static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self);
#else
#define __Pyx_CallUnboundCMethod0(cfunc, self)  __Pyx__CallUnboundCMethod0(cfunc, self)
#endif

/* py_dict_values.proto (used by OwnedDictNext) */
static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d);

/* OwnedDictNext.proto (used by ParseKeywordsImpl) */
#if CYTHON_AVOID_BORROWED_REFS
static int __Pyx_PyDict_NextRef(PyObject *p, PyObject **ppos, PyObject **pkey, PyObject **pvalue);
#else
CYTHON_INLINE
static int __Pyx_PyDict_NextRef(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue);
#endif

/* RaiseDoubleKeywords.proto (used by ParseKeywordsImpl) */
static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);

/* ParseKeywordsImpl.export */
static int __Pyx_ParseKeywordsTuple(
    PyObject *kwds,
    PyObject * const *kwvalues,
    PyObject ** const argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    Py_ssize_t num_kwargs,
    const char* function_name,
    int ignore_unknown_kwargs
);
static int __Pyx_ParseKeywordDictToDict(
    PyObject *kwds,
    PyObject ** const argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name
);
static int __Pyx_ParseKeywordDict(
    PyObject *kwds,
    PyObject ** const argnames[],
    PyObject *values[],
    Py_ssize_t num_pos_args,
    Py_ssize_t num_kwargs,
    const char* function_name,
    int ignore_unknown_kwargs
);

/* CallUnboundCMethod2.proto */
CYTHON_UNUSED
static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2);
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2);
#else
#define __Pyx_CallUnboundCMethod2(cfunc, self, arg1, arg2)  __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2)
#endif

/* ParseKeywords.proto */
static CYTHON_INLINE int __Pyx_ParseKeywords(
    PyObject *kwds, PyObject *const *kwvalues, PyObject ** const argnames[],
    PyObject *kwds2, PyObject *values[],
    Py_ssize_t num_pos_args, Py_ssize_t num_kwargs,
    const char* function_name,
    int ignore_unknown_kwargs
);

/* RaiseArgTupleInvalid.proto */
static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);

/* GetTopmostException.proto (used by SaveResetException) */
#if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE
static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
#endif

/* SaveResetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSave(type, value, tb)  __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#define __Pyx_ExceptionReset(type, value, tb)  __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
#else
#define __Pyx_ExceptionSave(type, value, tb)   PyErr_GetExcInfo(type, value, tb)
#define __Pyx_ExceptionReset(type, value, tb)  PyErr_SetExcInfo(type, value, tb)
#endif

/* PyTypeError_Check.proto */
#define __Pyx_PyExc_TypeError_Check(obj)  __Pyx_TypeCheck(obj, PyExc_TypeError)

/* PyValueError_Check.proto */
#define __Pyx_PyExc_ValueError_Check(obj)  __Pyx_TypeCheck(obj, PyExc_ValueError)

/* FastTypeChecks.proto */
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
#define __Pyx_TypeCheck2(obj, type1, type2) __Pyx_IsAnySubtype2(Py_TYPE(obj), (PyTypeObject *)type1, (PyTypeObject *)type2)
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
#else
#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
#define __Pyx_TypeCheck2(obj, type1, type2) (PyObject_TypeCheck(obj, (PyTypeObject *)type1) || PyObject_TypeCheck(obj, (PyTypeObject *)type2))
#define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2) {
    return PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2);
}
#endif
#define __Pyx_PyErr_ExceptionMatches2(err1, err2)  __Pyx_PyErr_GivenExceptionMatches2(__Pyx_PyErr_CurrentExceptionType(), err1, err2)
#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
#ifdef PyExceptionInstance_Check
  #define __Pyx_PyBaseException_Check(obj) PyExceptionInstance_Check(obj)
#else
  #define __Pyx_PyBaseException_Check(obj) __Pyx_TypeCheck(obj, PyExc_BaseException)
#endif

/* HasAttr.proto (used by ImportImpl) */
#if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
#define __Pyx_HasAttr(o, n)  PyObject_HasAttrWithError(o, n)
#else
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *, PyObject *);
#endif

/* ImportImpl.export */
static PyObject *__Pyx__Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, PyObject *moddict, int level);

/* Import.proto */
static CYTHON_INLINE PyObject *__Pyx_Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, int level);

/* ImportFrom.proto */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);

/* pyint_simplify.proto */
static CYTHON_INLINE int __Pyx_PyInt_FromNumber(PyObject **number_var, const char *argname, int accept_none);

/* ArgTypeTestFunc.export */
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact);

/* ArgTypeTest.proto */
#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\
    ((likely(__Pyx_IS_TYPE(obj, type) | (none_allowed && (obj == Py_None)))) ? 1 :\
        __Pyx__ArgTypeTest(obj, type, name, exact))

/* PyObjectDelAttr.proto (used by PyObjectSetAttrStr) */
#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000
#define __Pyx_PyObject_DelAttr(o, n) PyObject_SetAttr(o, n, NULL)
#else
#define __Pyx_PyObject_DelAttr(o, n) PyObject_DelAttr(o, n)
#endif

/* PyObjectSetAttrStr.proto */
#if CYTHON_USE_TYPE_SLOTS
#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
#else
#define __Pyx_PyObject_DelAttrStr(o,n)   __Pyx_PyObject_DelAttr(o,n)
#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
#endif

/* PyDictVersioning.proto (used by GetModuleGlobalName) */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
#define __PYX_DICT_VERSION_INIT  ((PY_UINT64_T) -1)
#define __PYX_GET_DICT_VERSION(dict)  (((PyDictObject*)(dict))->ma_version_tag)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
    (version_var) = __PYX_GET_DICT_VERSION(dict);\
    (cache_var) = (value);
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
        (VAR) = __Pyx_XNewRef(__pyx_dict_cached_value);\
    } else {\
        (VAR) = __pyx_dict_cached_value = (LOOKUP);\
        __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
    }\
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
#else
#define __PYX_GET_DICT_VERSION(dict)  (0)
#define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
#define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP)  (VAR) = (LOOKUP);
#endif

/* GetModuleGlobalName.proto */
#if CYTHON_USE_DICT_VERSIONS
#define __Pyx_GetModuleGlobalName(var, name)  do {\
    static PY_UINT64_T __pyx_dict_version = 0;\
    static PyObject *__pyx_dict_cached_value = NULL;\
    (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_mstate_global->__pyx_d))) ?\
        (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
        __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
} while(0)
#define __Pyx_GetModuleGlobalNameUncached(var, name)  do {\
    PY_UINT64_T __pyx_dict_version;\
    PyObject *__pyx_dict_cached_value;\
    (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
} while(0)
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
#else
#define __Pyx_GetModuleGlobalName(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
#define __Pyx_GetModuleGlobalNameUncached(var, name)  (var) = __Pyx__GetModuleGlobalName(name)
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
#endif

/* PyLongBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static CYTHON_INLINE PyObject* __Pyx_PyLong_TrueDivideObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyLong_TrueDivideObjC(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceTrueDivide(op1, op2) : PyNumber_TrueDivide(op1, op2))
#endif

/* PyAttributeError_Check.proto */
#define __Pyx_PyExc_AttributeError_Check(obj)  __Pyx_TypeCheck(obj, PyExc_AttributeError)

/* PyLongBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static CYTHON_INLINE PyObject* __Pyx_PyLong_MultiplyObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyLong_MultiplyObjC(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceMultiply(op1, op2) : PyNumber_Multiply(op1, op2))
#endif

/* PyObjectFastCallMethod.proto */
#if CYTHON_VECTORCALL && PY_VERSION_HEX >= 0x03090000
#define __Pyx_PyObject_FastCallMethod(name, args, nargsf) PyObject_VectorcallMethod(name, args, nargsf, NULL)
#else
static PyObject *__Pyx_PyObject_FastCallMethod(PyObject *name, PyObject *const *args, size_t nargsf);
#endif

/* PyPermissionError_Check.proto */
#define __Pyx_PyExc_PermissionError_Check(obj)  __Pyx_TypeCheck(obj, PyExc_PermissionError)

/* PyOSError_Check.proto */
#define __Pyx_PyExc_OSError_Check(obj)  __Pyx_TypeCheck(obj, PyExc_OSError)

/* GetException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_GetException(type, value, tb)  __Pyx__GetException(__pyx_tstate, type, value, tb)
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
#endif

/* PyObjectFormatAndDecref.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatSimpleAndDecref(PyObject* s, PyObject* f);
static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatAndDecref(PyObject* s, PyObject* f);

/* PyObject_Unicode.proto */
#define __Pyx_PyObject_Unicode(obj)\
    (likely(PyUnicode_CheckExact(obj)) ? __Pyx_NewRef(obj) : PyObject_Str(obj))

/* PyObjectVectorCallKwBuilder.proto */
CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n);
#if CYTHON_VECTORCALL
#if PY_VERSION_HEX >= 0x03090000
#define __Pyx_Object_Vectorcall_CallFromBuilder PyObject_Vectorcall
#else
#define __Pyx_Object_Vectorcall_CallFromBuilder _PyObject_Vectorcall
#endif
#define __Pyx_MakeVectorcallBuilderKwds(n) PyTuple_New(n)
static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n);
static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n);
#else
#define __Pyx_Object_Vectorcall_CallFromBuilder __Pyx_PyObject_FastCallDict
#define __Pyx_MakeVectorcallBuilderKwds(n) __Pyx_PyDict_NewPresized(n)
#define __Pyx_VectorcallBuilder_AddArg(key, value, builder, args, n) PyDict_SetItem(builder, key, value)
#define __Pyx_VectorcallBuilder_AddArgStr(key, value, builder, args, n) PyDict_SetItemString(builder, key, value)
#endif

/* RaiseException.export */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);

/* SwapException.proto */
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_ExceptionSwap(type, value, tb)  __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
#endif

/* PyFileNotFoundError_Check.proto */
#define __Pyx_PyExc_FileNotFoundError_Check(obj)  __Pyx_TypeCheck(obj, PyExc_FileNotFoundError)

/* PyImportError_Check.proto */
#define __Pyx_PyExc_ImportError_Check(obj)  __Pyx_TypeCheck(obj, PyExc_ImportError)

/* PyLongCompare.proto */
static CYTHON_INLINE int __Pyx_PyLong_BoolNeObjC(PyObject *op1, PyObject *op2, long intval, long inplace);

/* PyLongBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static CYTHON_INLINE PyObject* __Pyx_PyLong_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyLong_AddObjC(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceAdd(op1, op2) : PyNumber_Add(op1, op2))
#endif

/* PyObjectVectorCallMethodKwBuilder.proto */
#if CYTHON_VECTORCALL && PY_VERSION_HEX >= 0x03090000
#define __Pyx_Object_VectorcallMethod_CallFromBuilder PyObject_VectorcallMethod
#else
static PyObject *__Pyx_Object_VectorcallMethod_CallFromBuilder(PyObject *name, PyObject *const *args, size_t nargsf, PyObject *kwnames);
#endif

/* GetAttr3.proto */
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *, PyObject *, PyObject *);

/* PyObjectLookupSpecial.proto */
#if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
#define __Pyx_PyObject_LookupSpecialNoError(obj, attr_name)  __Pyx__PyObject_LookupSpecial(obj, attr_name, 0)
#define __Pyx_PyObject_LookupSpecial(obj, attr_name)  __Pyx__PyObject_LookupSpecial(obj, attr_name, 1)
static CYTHON_INLINE PyObject* __Pyx__PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name, int with_error);
#else
#define __Pyx_PyObject_LookupSpecialNoError(o,n) __Pyx_PyObject_GetAttrStrNoError(o,n)
#define __Pyx_PyObject_LookupSpecial(o,n) __Pyx_PyObject_GetAttrStr(o,n)
#endif

/* dict_setdefault.proto (used by FetchCommonType) */
static CYTHON_INLINE PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *default_value);

/* LimitedApiGetTypeDict.proto (used by SetItemOnTypeDict) */
#if CYTHON_COMPILING_IN_LIMITED_API
static PyObject *__Pyx_GetTypeDict(PyTypeObject *tp);
#endif

/* SetItemOnTypeDict.proto (used by FixUpExtensionType) */
static int __Pyx__SetItemOnTypeDict(PyTypeObject *tp, PyObject *k, PyObject *v);
#define __Pyx_SetItemOnTypeDict(tp, k, v) __Pyx__SetItemOnTypeDict((PyTypeObject*)tp, k, v)

/* FixUpExtensionType.proto (used by FetchCommonType) */
static CYTHON_INLINE int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type);

/* AddModuleRef.proto (used by FetchSharedCythonModule) */
#if ((CYTHON_COMPILING_IN_CPYTHON_FREETHREADING ) ||\
     __PYX_LIMITED_VERSION_HEX < 0x030d0000)
  static PyObject *__Pyx_PyImport_AddModuleRef(const char *name);
#else
  #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name)
#endif

/* FetchSharedCythonModule.proto (used by FetchCommonType) */
static PyObject *__Pyx_FetchSharedCythonABIModule(void);

/* FetchCommonType.proto (used by CommonTypesMetaclass) */
static PyTypeObject* __Pyx_FetchCommonTypeFromSpec(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases);

/* CommonTypesMetaclass.proto (used by CoroutineBase) */
static int __pyx_CommonTypesMetaclass_init(PyObject *module);
#define __Pyx_CommonTypesMetaclass_USED

/* CallTypeTraverse.proto (used by CoroutineBase) */
#if !CYTHON_USE_TYPE_SPECS || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x03090000)
#define __Pyx_call_type_traverse(o, always_call, visit, arg) 0
#else
static int __Pyx_call_type_traverse(PyObject *o, int always_call, visitproc visit, void *arg);
#endif

/* IterNextPlain.proto (used by CoroutineBase) */
static CYTHON_INLINE PyObject *__Pyx_PyIter_Next_Plain(PyObject *iterator);
#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
static PyObject *__Pyx_GetBuiltinNext_LimitedAPI(void);
#endif

/* PyObjectCall2Args.proto (used by PyObjectCallMethod1) */
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);

/* PyObjectGetMethod.proto (used by PyObjectCallMethod1) */
#if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000)))
static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);
#endif

/* PyObjectCallMethod1.proto (used by CoroutineBase) */
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);

/* PyObjectCallNoArg.proto (used by CoroutineBase) */
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);

/* ReturnWithStopIteration.proto (used by CoroutineBase) */
static CYTHON_INLINE void __Pyx_ReturnWithStopIteration(PyObject* value, int async, int iternext);

/* CoroutineBase.proto (used by Coroutine) */
struct __pyx_CoroutineObject;
typedef PyObject *(*__pyx_coroutine_body_t)(struct __pyx_CoroutineObject *, PyThreadState *, PyObject *);
#if CYTHON_USE_EXC_INFO_STACK
#define __Pyx_ExcInfoStruct  _PyErr_StackItem
#else
typedef struct {
    PyObject *exc_type;
    PyObject *exc_value;
    PyObject *exc_traceback;
} __Pyx_ExcInfoStruct;
#endif
typedef struct __pyx_CoroutineObject {
    PyObject_HEAD
    __pyx_coroutine_body_t body;
    PyObject *closure;
    __Pyx_ExcInfoStruct gi_exc_state;
#if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
    PyObject *gi_weakreflist;
#endif
    PyObject *classobj;
    PyObject *yieldfrom;
    __Pyx_pyiter_sendfunc yieldfrom_am_send;
    PyObject *gi_name;
    PyObject *gi_qualname;
    PyObject *gi_modulename;
    PyObject *gi_code;
    PyObject *gi_frame;
#if CYTHON_USE_SYS_MONITORING && (CYTHON_PROFILE || CYTHON_TRACE)
    PyMonitoringState __pyx_pymonitoring_state[__Pyx_MonitoringEventTypes_CyGen_count];
    uint64_t __pyx_pymonitoring_version;
#endif
    int resume_label;
    char is_running;
} __pyx_CoroutineObject;
static __pyx_CoroutineObject *__Pyx__Coroutine_New(
    PyTypeObject *type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
    PyObject *name, PyObject *qualname, PyObject *module_name);
static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
            __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name);
static CYTHON_INLINE void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *self);
static int __Pyx_Coroutine_clear(PyObject *self);
static __Pyx_PySendResult __Pyx_Coroutine_AmSend(PyObject *self, PyObject *value, PyObject **retval);
static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value);
static __Pyx_PySendResult __Pyx_Coroutine_Close(PyObject *self, PyObject **retval);
static PyObject *__Pyx_Coroutine_Throw(PyObject *gen, PyObject *args);
#if CYTHON_USE_EXC_INFO_STACK
#define __Pyx_Coroutine_SwapException(self)
#define __Pyx_Coroutine_ResetAndClearException(self)  __Pyx_Coroutine_ExceptionClear(&(self)->gi_exc_state)
#else
#define __Pyx_Coroutine_SwapException(self) {\
    __Pyx_ExceptionSwap(&(self)->gi_exc_state.exc_type, &(self)->gi_exc_state.exc_value, &(self)->gi_exc_state.exc_traceback);\
    __Pyx_Coroutine_ResetFrameBackpointer(&(self)->gi_exc_state);\
    }
#define __Pyx_Coroutine_ResetAndClearException(self) {\
    __Pyx_ExceptionReset((self)->gi_exc_state.exc_type, (self)->gi_exc_state.exc_value, (self)->gi_exc_state.exc_traceback);\
    (self)->gi_exc_state.exc_type = (self)->gi_exc_state.exc_value = (self)->gi_exc_state.exc_traceback = NULL;\
    }
#endif
#if CYTHON_FAST_THREAD_STATE
#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
    __Pyx_PyGen__FetchStopIterationValue(__pyx_tstate, pvalue)
#else
#define __Pyx_PyGen_FetchStopIterationValue(pvalue)\
    __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, pvalue)
#endif
static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *tstate, PyObject **pvalue);
static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state);
static char __Pyx_Coroutine_test_and_set_is_running(__pyx_CoroutineObject *gen);
static void __Pyx_Coroutine_unset_is_running(__pyx_CoroutineObject *gen);
static char __Pyx_Coroutine_get_is_running(__pyx_CoroutineObject *gen);
static PyObject *__Pyx_Coroutine_get_is_running_getter(PyObject *gen, void *closure);
#if __PYX_HAS_PY_AM_SEND == 2
static void __Pyx_SetBackportTypeAmSend(PyTypeObject *type, __Pyx_PyAsyncMethodsStruct *static_amsend_methods, __Pyx_pyiter_sendfunc am_send);
#endif
static PyObject *__Pyx_Coroutine_fail_reduce_ex(PyObject *self, PyObject *arg);

/* Coroutine.proto (used by CoroutineYieldFrom) */
#define __Pyx_Coroutine_USED
#define __Pyx_Coroutine_CheckExact(obj) __Pyx_IS_TYPE(obj, __pyx_mstate_global->__pyx_CoroutineType)
#define __Pyx_Coroutine_Check(obj) __Pyx_Coroutine_CheckExact(obj)
#define __Pyx_CoroutineAwait_CheckExact(obj) __Pyx_IS_TYPE(obj, __pyx_mstate_global->__pyx_CoroutineAwaitType)
#define __Pyx_Coroutine_New(body, code, closure, name, qualname, module_name)\
    __Pyx__Coroutine_New(__pyx_mstate_global->__pyx_CoroutineType, body, code, closure, name, qualname, module_name)
static int __pyx_Coroutine_init(PyObject *module);
static PyObject *__Pyx__Coroutine_await(PyObject *coroutine);
typedef struct {
    PyObject_HEAD
    PyObject *coroutine;
} __pyx_CoroutineAwaitObject;
static __Pyx_PySendResult __Pyx_CoroutineAwait_Close(__pyx_CoroutineAwaitObject *self);

/* Coro_CheckExact.proto (used by GetAwaitIter) */
#if CYTHON_COMPILING_IN_LIMITED_API
static int __Pyx_PyCoro_CheckExact(PyObject *o);
#else
#define __Pyx_PyCoro_CheckExact PyCoro_CheckExact
#endif

/* GetAwaitIter.proto (used by CoroutineYieldFrom) */
static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAwaitableIter(PyObject *o);
static PyObject *__Pyx__Coroutine_GetAwaitableIter(PyObject *o);

/* CoroutineYieldFrom.proto */
static CYTHON_INLINE __Pyx_PySendResult __Pyx_Coroutine_Yield_From(__pyx_CoroutineObject *gen, PyObject *source, PyObject **retval);

/* pep479.proto */
static void __Pyx_Generator_Replace_StopIteration(int in_async_gen);

/* PyUnicode_Unicode.proto */
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Unicode(PyObject *obj);

/* PyLongCompare.proto */
static CYTHON_INLINE PyObject* __Pyx_PyLong_EqObjC(PyObject *op1, PyObject *op2, long intval, long inplace);

/* RaiseUnexpectedTypeError.proto */
static int __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj);

/* PySequenceContains.proto */
static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) {
    int result = PySequence_Contains(seq, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

/* dict_getitem_default.proto */
static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value);

/* CallUnboundCMethod1.proto */
CYTHON_UNUSED
static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg);
#else
#define __Pyx_CallUnboundCMethod1(cfunc, self, arg)  __Pyx__CallUnboundCMethod1(cfunc, self, arg)
#endif

/* RaiseTooManyValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);

/* RaiseNeedMoreValuesToUnpack.proto */
static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);

/* IterFinish.proto */
static CYTHON_INLINE int __Pyx_IterFinish(void);

/* UnpackItemEndCheck.proto */
static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);

/* PyUnicode_Substring.proto */
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Substring(
            PyObject* text, Py_ssize_t start, Py_ssize_t stop);

/* PyLongCompare.proto */
static CYTHON_INLINE int __Pyx_PyLong_BoolEqObjC(PyObject *op1, PyObject *op2, long intval, long inplace);

/* SliceObject.proto */
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
        PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
        PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
        int has_cstart, int has_cstop, int wraparound);

/* GetItemInt.proto */
#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck, unsafe_shared) :\
    (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
               __Pyx_GetItemInt_Generic(o, to_py_func(i))))
#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck, unsafe_shared) :\
    (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck, int unsafe_shared);
#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck, has_gil, unsafe_shared)\
    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
    __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck, unsafe_shared) :\
    (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                              int wraparound, int boundscheck, int unsafe_shared);
static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
                                                     int is_list, int wraparound, int boundscheck, int unsafe_shared);

/* ObjectGetItem.proto */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject *key);
#else
#define __Pyx_PyObject_GetItem(obj, key)  PyObject_GetItem(obj, key)
#endif

/* PyObjectFormatSimple.proto */
#if CYTHON_COMPILING_IN_PYPY
    #define __Pyx_PyObject_FormatSimple(s, f) (\
        likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\
        PyObject_Format(s, f))
#elif CYTHON_USE_TYPE_SLOTS
    #define __Pyx_PyObject_FormatSimple(s, f) (\
        likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\
        likely(PyLong_CheckExact(s)) ? PyLong_Type.tp_repr(s) :\
        likely(PyFloat_CheckExact(s)) ? PyFloat_Type.tp_repr(s) :\
        PyObject_Format(s, f))
#else
    #define __Pyx_PyObject_FormatSimple(s, f) (\
        likely(PyUnicode_CheckExact(s)) ? (Py_INCREF(s), s) :\
        PyObject_Format(s, f))
#endif

/* PyUnicodeDecodeError_Check.proto */
#define __Pyx_PyExc_UnicodeDecodeError_Check(obj)  __Pyx_TypeCheck(obj, PyExc_UnicodeDecodeError)

/* PyRuntimeError_Check.proto */
#define __Pyx_PyExc_RuntimeError_Check(obj)  __Pyx_TypeCheck(obj, PyExc_RuntimeError)

/* RaiseUnboundLocalError.proto */
static void __Pyx_RaiseUnboundLocalError(const char *varname);

/* RaiseClosureNameError.proto */
static void __Pyx_RaiseClosureNameError(const char *varname);

/* PyMethodNew.proto (used by CythonFunctionShared) */
static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ);

/* PyVectorcallFastCallDict.proto (used by CythonFunctionShared) */
#if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL
static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw);
#endif

/* CythonFunctionShared.proto (used by CythonFunction) */
#define __Pyx_CyFunction_USED
#define __Pyx_CYFUNCTION_STATICMETHOD  0x01
#define __Pyx_CYFUNCTION_CLASSMETHOD   0x02
#define __Pyx_CYFUNCTION_CCLASS        0x04
#define __Pyx_CYFUNCTION_COROUTINE     0x08
#define __Pyx_CyFunction_GetClosure(f)\
    (((__pyx_CyFunctionObject *) (f))->func_closure)
#if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
  #define __Pyx_CyFunction_GetClassObj(f)\
      (((__pyx_CyFunctionObject *) (f))->func_classobj)
#else
  #define __Pyx_CyFunction_GetClassObj(f)\
      ((PyObject*) ((PyCMethodObject *) (f))->mm_class)
#endif
#define __Pyx_CyFunction_SetClassObj(f, classobj)\
    __Pyx__CyFunction_SetClassObj((__pyx_CyFunctionObject *) (f), (classobj))
#define __Pyx_CyFunction_Defaults(type, f)\
    ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
#define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
    ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
typedef struct {
#if CYTHON_COMPILING_IN_LIMITED_API
    PyObject_HEAD
    PyObject *func;
#elif PY_VERSION_HEX < 0x030900B1
    PyCFunctionObject func;
#else
    PyCMethodObject func;
#endif
#if CYTHON_COMPILING_IN_LIMITED_API && CYTHON_METH_FASTCALL
    __pyx_vectorcallfunc func_vectorcall;
#endif
#if CYTHON_COMPILING_IN_LIMITED_API
    PyObject *func_weakreflist;
#endif
#if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
    PyObject *func_dict;
#endif
    PyObject *func_name;
    PyObject *func_qualname;
    PyObject *func_doc;
    PyObject *func_globals;
    PyObject *func_code;
    PyObject *func_closure;
#if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
    PyObject *func_classobj;
#endif
    PyObject *defaults;
    int flags;
    PyObject *defaults_tuple;
    PyObject *defaults_kwdict;
    PyObject *(*defaults_getter)(PyObject *);
    PyObject *func_annotations;
    PyObject *func_is_coroutine;
} __pyx_CyFunctionObject;
#undef __Pyx_CyOrPyCFunction_Check
#define __Pyx_CyFunction_Check(obj)  __Pyx_TypeCheck(obj, __pyx_mstate_global->__pyx_CyFunctionType)
#define __Pyx_CyOrPyCFunction_Check(obj)  __Pyx_TypeCheck2(obj, __pyx_mstate_global->__pyx_CyFunctionType, &PyCFunction_Type)
#define __Pyx_CyFunction_CheckExact(obj)  __Pyx_IS_TYPE(obj, __pyx_mstate_global->__pyx_CyFunctionType)
static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void));
#undef __Pyx_IsSameCFunction
#define __Pyx_IsSameCFunction(func, cfunc)   __Pyx__IsSameCyOrCFunction(func, cfunc)
static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml,
                                      int flags, PyObject* qualname,
                                      PyObject *closure,
                                      PyObject *module, PyObject *globals,
                                      PyObject* code);
static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj);
static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func,
                                                         PyTypeObject *defaults_type);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
                                                            PyObject *tuple);
static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
                                                             PyObject *dict);
static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
                                                              PyObject *dict);
static int __pyx_CyFunction_init(PyObject *module);
#if CYTHON_METH_FASTCALL
static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames);
#if CYTHON_COMPILING_IN_LIMITED_API
#define __Pyx_CyFunction_func_vectorcall(f) (((__pyx_CyFunctionObject*)f)->func_vectorcall)
#else
#define __Pyx_CyFunction_func_vectorcall(f) (((PyCFunctionObject*)f)->vectorcall)
#endif
#endif

/* CythonFunction.proto */
static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml,
                                      int flags, PyObject* qualname,
                                      PyObject *closure,
                                      PyObject *module, PyObject *globals,
                                      PyObject* code);

/* DictGetItem.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key);
#define __Pyx_PyObject_Dict_GetItem(obj, name)\
    (likely(PyDict_CheckExact(obj)) ?\
     __Pyx_PyDict_GetItem(obj, name) : PyObject_GetItem(obj, name))
#else
#define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
#define __Pyx_PyObject_Dict_GetItem(obj, name)  PyObject_GetItem(obj, name)
#endif

/* JoinPyUnicode.export */
static PyObject* __Pyx_PyUnicode_Join(PyObject** values, Py_ssize_t value_count, Py_ssize_t result_ulength,
                                      Py_UCS4 max_char);

/* RaiseMappingExpected.proto */
static void __Pyx_RaiseMappingExpectedError(PyObject* arg);

/* ListCompAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len)) {
        Py_INCREF(x);
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000
        L->ob_item[len] = x;
        #else
        PyList_SET_ITEM(list, len, x);
        #endif
        __Pyx_SET_SIZE(list, len + 1);
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x)
#endif

/* pybytes_as_double.proto (used by pynumber_float) */
static double __Pyx_SlowPyString_AsDouble(PyObject *obj);
static double __Pyx__PyBytes_AsDouble(PyObject *obj, const char* start, Py_ssize_t length);
static CYTHON_INLINE double __Pyx_PyBytes_AsDouble(PyObject *obj) {
    char* as_c_string;
    Py_ssize_t size;
#if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
    as_c_string = PyBytes_AS_STRING(obj);
    size = PyBytes_GET_SIZE(obj);
#else
    if (PyBytes_AsStringAndSize(obj, &as_c_string, &size) < 0) {
        return (double)-1;
    }
#endif
    return __Pyx__PyBytes_AsDouble(obj, as_c_string, size);
}
static CYTHON_INLINE double __Pyx_PyByteArray_AsDouble(PyObject *obj) {
    char* as_c_string;
    Py_ssize_t size;
#if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
    as_c_string = PyByteArray_AS_STRING(obj);
    size = PyByteArray_GET_SIZE(obj);
#else
    as_c_string = PyByteArray_AsString(obj);
    if (as_c_string == NULL) {
        return (double)-1;
    }
    size = PyByteArray_Size(obj);
#endif
    return __Pyx__PyBytes_AsDouble(obj, as_c_string, size);
}

/* pyunicode_as_double.proto (used by pynumber_float) */
#if !CYTHON_COMPILING_IN_PYPY && CYTHON_ASSUME_SAFE_MACROS
static const char* __Pyx__PyUnicode_AsDouble_Copy(const void* data, const int kind, char* buffer, Py_ssize_t start, Py_ssize_t end) {
    int last_was_punctuation;
    Py_ssize_t i;
    last_was_punctuation = 1;
    for (i=start; i <= end; i++) {
        Py_UCS4 chr = PyUnicode_READ(kind, data, i);
        int is_punctuation = (chr == '_') | (chr == '.');
        *buffer = (char)chr;
        buffer += (chr != '_');
        if (unlikely(chr > 127)) goto parse_failure;
        if (unlikely(last_was_punctuation & is_punctuation)) goto parse_failure;
        last_was_punctuation = is_punctuation;
    }
    if (unlikely(last_was_punctuation)) goto parse_failure;
    *buffer = '\0';
    return buffer;
parse_failure:
    return NULL;
}
static double __Pyx__PyUnicode_AsDouble_inf_nan(const void* data, int kind, Py_ssize_t start, Py_ssize_t length) {
    int matches = 1;
    Py_UCS4 chr;
    Py_UCS4 sign = PyUnicode_READ(kind, data, start);
    int is_signed = (sign == '-') | (sign == '+');
    start += is_signed;
    length -= is_signed;
    switch (PyUnicode_READ(kind, data, start)) {
        #ifdef Py_NAN
        case 'n':
        case 'N':
            if (unlikely(length != 3)) goto parse_failure;
            chr = PyUnicode_READ(kind, data, start+1);
            matches &= (chr == 'a') | (chr == 'A');
            chr = PyUnicode_READ(kind, data, start+2);
            matches &= (chr == 'n') | (chr == 'N');
            if (unlikely(!matches)) goto parse_failure;
            return (sign == '-') ? -Py_NAN : Py_NAN;
        #endif
        case 'i':
        case 'I':
            if (unlikely(length < 3)) goto parse_failure;
            chr = PyUnicode_READ(kind, data, start+1);
            matches &= (chr == 'n') | (chr == 'N');
            chr = PyUnicode_READ(kind, data, start+2);
            matches &= (chr == 'f') | (chr == 'F');
            if (likely(length == 3 && matches))
                return (sign == '-') ? -Py_HUGE_VAL : Py_HUGE_VAL;
            if (unlikely(length != 8)) goto parse_failure;
            chr = PyUnicode_READ(kind, data, start+3);
            matches &= (chr == 'i') | (chr == 'I');
            chr = PyUnicode_READ(kind, data, start+4);
            matches &= (chr == 'n') | (chr == 'N');
            chr = PyUnicode_READ(kind, data, start+5);
            matches &= (chr == 'i') | (chr == 'I');
            chr = PyUnicode_READ(kind, data, start+6);
            matches &= (chr == 't') | (chr == 'T');
            chr = PyUnicode_READ(kind, data, start+7);
            matches &= (chr == 'y') | (chr == 'Y');
            if (unlikely(!matches)) goto parse_failure;
            return (sign == '-') ? -Py_HUGE_VAL : Py_HUGE_VAL;
        case '.': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
            break;
        default:
            goto parse_failure;
    }
    return 0.0;
parse_failure:
    return -1.0;
}
static double __Pyx_PyUnicode_AsDouble_WithSpaces(PyObject *obj) {
    double value;
    const char *last;
    char *end;
    Py_ssize_t start, length = PyUnicode_GET_LENGTH(obj);
    const int kind = PyUnicode_KIND(obj);
    const void* data = PyUnicode_DATA(obj);
    start = 0;
    while (Py_UNICODE_ISSPACE(PyUnicode_READ(kind, data, start)))
        start++;
    while (start < length - 1 && Py_UNICODE_ISSPACE(PyUnicode_READ(kind, data, length - 1)))
        length--;
    length -= start;
    if (unlikely(length <= 0)) goto fallback;
    value = __Pyx__PyUnicode_AsDouble_inf_nan(data, kind, start, length);
    if (unlikely(value == -1.0)) goto fallback;
    if (value != 0.0) return value;
    if (length < 40) {
        char number[40];
        last = __Pyx__PyUnicode_AsDouble_Copy(data, kind, number, start, start + length);
        if (unlikely(!last)) goto fallback;
        value = PyOS_string_to_double(number, &end, NULL);
    } else {
        char *number = (char*) PyMem_Malloc((length + 1) * sizeof(char));
        if (unlikely(!number)) goto fallback;
        last = __Pyx__PyUnicode_AsDouble_Copy(data, kind, number, start, start + length);
        if (unlikely(!last)) {
            PyMem_Free(number);
            goto fallback;
        }
        value = PyOS_string_to_double(number, &end, NULL);
        PyMem_Free(number);
    }
    if (likely(end == last) || (value == (double)-1 && PyErr_Occurred())) {
        return value;
    }
fallback:
    return __Pyx_SlowPyString_AsDouble(obj);
}
#endif
static CYTHON_INLINE double __Pyx_PyUnicode_AsDouble(PyObject *obj) {
#if !CYTHON_COMPILING_IN_PYPY && CYTHON_ASSUME_SAFE_MACROS
    if (unlikely(__Pyx_PyUnicode_READY(obj) == -1))
        return (double)-1;
    if (likely(PyUnicode_IS_ASCII(obj))) {
        const char *s;
        Py_ssize_t length;
        s = PyUnicode_AsUTF8AndSize(obj, &length);
        return __Pyx__PyBytes_AsDouble(obj, s, length);
    }
    return __Pyx_PyUnicode_AsDouble_WithSpaces(obj);
#else
    return __Pyx_SlowPyString_AsDouble(obj);
#endif
}

/* pynumber_float.proto */
static CYTHON_INLINE PyObject* __Pyx__PyNumber_Float(PyObject* obj);
#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : __Pyx__PyNumber_Float(x))

/* UnicodeConcatInPlace.proto */
# if CYTHON_COMPILING_IN_CPYTHON
    #if CYTHON_REFNANNY
        #define __Pyx_PyUnicode_ConcatInPlace(left, right, unsafe_shared) __Pyx_PyUnicode_ConcatInPlaceImpl(&left, right, unsafe_shared, __pyx_refnanny)
    #else
        #define __Pyx_PyUnicode_ConcatInPlace(left, right, unsafe_shared) __Pyx_PyUnicode_ConcatInPlaceImpl(&left, right, unsafe_shared)
    #endif
    #define __Pyx_PyUnicode_Concat__Pyx_ReferenceSharing_DefinitelyUniqueInPlace(left, right) __Pyx_PyUnicode_ConcatInPlace(left, right, __Pyx_ReferenceSharing_DefinitelyUnique)
    #define __Pyx_PyUnicode_Concat__Pyx_ReferenceSharing_OwnStrongReferenceInPlace(left, right) __Pyx_PyUnicode_ConcatInPlace(left, right, __Pyx_ReferenceSharing_OwnStrongReference)
    #define __Pyx_PyUnicode_Concat__Pyx_ReferenceSharing_FunctionArgumentInPlace(left, right) __Pyx_PyUnicode_ConcatInPlace(left, right, __Pyx_ReferenceSharing_FunctionArgument)
    #define __Pyx_PyUnicode_Concat__Pyx_ReferenceSharing_SharedReferenceInPlace(left, right) __Pyx_PyUnicode_ConcatInPlace(left, right, __Pyx_ReferenceSharing_SharedReference)
    static CYTHON_INLINE PyObject *__Pyx_PyUnicode_ConcatInPlaceImpl(PyObject **p_left, PyObject *right, int unsafe_shared
        #if CYTHON_REFNANNY
        , void* __pyx_refnanny
        #endif
    );
#else
#define __Pyx_PyUnicode_Concat__Pyx_ReferenceSharing_DefinitelyUniqueInPlace __Pyx_PyUnicode_Concat
#define __Pyx_PyUnicode_Concat__Pyx_ReferenceSharing_OwnStrongReferenceInPlace __Pyx_PyUnicode_Concat
#define __Pyx_PyUnicode_Concat__Pyx_ReferenceSharing_FunctionArgumentInPlace __Pyx_PyUnicode_Concat
#define __Pyx_PyUnicode_Concat__Pyx_ReferenceSharing_SharedReferenceInPlace __Pyx_PyUnicode_Concat
#endif
#define __Pyx_PyUnicode_Concat__Pyx_ReferenceSharing_DefinitelyUniqueInPlaceSafe(left, right)\
    ((unlikely((left) == Py_None) || unlikely((right) == Py_None)) ?\
    PyNumber_InPlaceAdd(left, right) : __Pyx_PyUnicode_Concat__Pyx_ReferenceSharing_DefinitelyUniqueInPlace(left, right))
#define __Pyx_PyUnicode_Concat__Pyx_ReferenceSharing_OwnStrongReferenceInPlaceSafe(left, right)\
    ((unlikely((left) == Py_None) || unlikely((right) == Py_None)) ?\
    PyNumber_InPlaceAdd(left, right) : __Pyx_PyUnicode_Concat__Pyx_ReferenceSharing_OwnStrongReferenceInPlace(left, right))
#define __Pyx_PyUnicode_Concat__Pyx_ReferenceSharing_FunctionArgumentInPlaceSafe(left, right)\
    ((unlikely((left) == Py_None) || unlikely((right) == Py_None)) ?\
    PyNumber_InPlaceAdd(left, right) : __Pyx_PyUnicode_Concat__Pyx_ReferenceSharing_FunctionArgumentInPlace(left, right))
#define __Pyx_PyUnicode_Concat__Pyx_ReferenceSharing_SharedReferenceInPlaceSafe(left, right)\
    ((unlikely((left) == Py_None) || unlikely((right) == Py_None)) ?\
    PyNumber_InPlaceAdd(left, right) : __Pyx_PyUnicode_Concat__Pyx_ReferenceSharing_SharedReferenceInPlace(left, right))

/* PyRange_Check.proto */
#if CYTHON_COMPILING_IN_PYPY && !defined(PyRange_Check)
  #define PyRange_Check(obj)  __Pyx_TypeCheck((obj), &PyRange_Type)
#endif

/* pyobject_as_double.proto */
static double __Pyx__PyObject_AsDouble(PyObject* obj);
#if CYTHON_COMPILING_IN_PYPY
#define __Pyx_PyObject_AsDouble(obj)\
(likely(PyFloat_CheckExact(obj)) ? PyFloat_AS_DOUBLE(obj) :\
 likely(PyLong_CheckExact(obj)) ?\
 PyFloat_AsDouble(obj) : __Pyx__PyObject_AsDouble(obj))
#else
#define __Pyx_PyObject_AsDouble(obj)\
((likely(PyFloat_CheckExact(obj))) ?  __Pyx_PyFloat_AS_DOUBLE(obj) :\
 likely(PyLong_CheckExact(obj)) ?\
 PyLong_AsDouble(obj) : __Pyx__PyObject_AsDouble(obj))
#endif

/* FloatExceptionCheck.proto */
#define __PYX_CHECK_FLOAT_EXCEPTION(value, error_value)\
    ((error_value) == (error_value) ?\
     (value) == (error_value) :\
     (value) != (value))

/* PyDictContains.proto */
static CYTHON_INLINE int __Pyx_PyDict_ContainsTF(PyObject* item, PyObject* dict, int eq) {
    int result = PyDict_Contains(dict, item);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

/* AsyncIter.proto */
static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAsyncIter(PyObject *o);
static CYTHON_INLINE PyObject *__Pyx_Coroutine_AsyncIterNext(PyObject *o);

/* pyfrozenset_new.proto (used by PySetContains) */
static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it);

/* PySetContains.proto */
static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq);

/* ListAppend.proto */
#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
    PyListObject* L = (PyListObject*) list;
    Py_ssize_t len = Py_SIZE(list);
    if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
        Py_INCREF(x);
        #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000
        L->ob_item[len] = x;
        #else
        PyList_SET_ITEM(list, len, x);
        #endif
        __Pyx_SET_SIZE(list, len + 1);
        return 0;
    }
    return PyList_Append(list, x);
}
#else
#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
#endif

/* PyUnicodeContains.proto */
static CYTHON_INLINE int __Pyx_PyUnicode_ContainsTF(PyObject* substring, PyObject* text, int eq) {
    int result = PyUnicode_Contains(text, substring);
    return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
}

/* append.proto */
static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x);

/* PyFloatBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_PyFloat_TrueDivideObjC(PyObject *op1, PyObject *op2, double floatval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyFloat_TrueDivideObjC(op1, op2, floatval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceTrueDivide(op1, op2) : PyNumber_TrueDivide(op1, op2))
#endif

/* PyObjectFormat.proto */
#if CYTHON_USE_UNICODE_WRITER
static PyObject* __Pyx_PyObject_Format(PyObject* s, PyObject* f);
#else
#define __Pyx_PyObject_Format(s, f) PyObject_Format(s, f)
#endif

/* PyIndexError_Check.proto */
#define __Pyx_PyExc_IndexError_Check(obj)  __Pyx_TypeCheck(obj, PyExc_IndexError)

/* PyLongBinop.proto */
#if !CYTHON_COMPILING_IN_PYPY
static CYTHON_INLINE PyObject* __Pyx_PyLong_SubtractObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check);
#else
#define __Pyx_PyLong_SubtractObjC(op1, op2, intval, inplace, zerodivision_check)\
    (inplace ? PyNumber_InPlaceSubtract(op1, op2) : PyNumber_Subtract(op1, op2))
#endif

/* py_abs.proto */
#if CYTHON_USE_PYLONG_INTERNALS
static PyObject *__Pyx_PyLong_AbsNeg(PyObject *num);
#define __Pyx_PyNumber_Absolute(x)\
    ((likely(PyLong_CheckExact(x))) ?\
         (likely(__Pyx_PyLong_IsNonNeg(x)) ? __Pyx_NewRef(x) : __Pyx_PyLong_AbsNeg(x)) :\
         PyNumber_Absolute(x))
#else
#define __Pyx_PyNumber_Absolute(x)  PyNumber_Absolute(x)
#endif

/* PyObjectCallMethod0.proto (used by dict_iter) */
static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);

/* RaiseNoneIterError.proto (used by UnpackTupleError) */
static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);

/* UnpackTupleError.proto (used by UnpackTuple2) */
static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index);

/* UnpackTuple2.proto (used by dict_iter) */
static CYTHON_INLINE int __Pyx_unpack_tuple2(
    PyObject* tuple, PyObject** value1, PyObject** value2, int is_tuple, int has_known_size, int decref_tuple);
static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
    PyObject* tuple, PyObject** value1, PyObject** value2, int decref_tuple);
static int __Pyx_unpack_tuple2_generic(
    PyObject* tuple, PyObject** value1, PyObject** value2, int has_known_size, int decref_tuple);

/* dict_iter.proto */
static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* dict, int is_dict, PyObject* method_name,
                                                   Py_ssize_t* p_orig_length, int* p_is_dict);
static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* dict_or_iter, Py_ssize_t orig_length, Py_ssize_t* ppos,
                                              PyObject** pkey, PyObject** pvalue, PyObject** pitem, int is_dict);

/* PyLongCompare.proto */
static CYTHON_INLINE PyObject* __Pyx_PyLong_NeObjC(PyObject *op1, PyObject *op2, long intval, long inplace);

/* SliceTupleAndList.proto */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(PyObject* src, Py_ssize_t start, Py_ssize_t stop);
#else
#define __Pyx_PyList_GetSlice(seq, start, stop)   PySequence_GetSlice(seq, start, stop)
#define __Pyx_PyTuple_GetSlice(seq, start, stop)  PySequence_GetSlice(seq, start, stop)
#endif

/* py_dict_keys.proto */
static CYTHON_INLINE PyObject* __Pyx_PyDict_Keys(PyObject* d);

/* CheckTypeForFreelists.proto */
#if CYTHON_USE_FREELISTS
#if CYTHON_USE_TYPE_SPECS
#define __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, expected_tp, expected_size) ((int) ((t) == (expected_tp)))
#define __PYX_CHECK_TYPE_FOR_FREELIST_FLAGS  Py_TPFLAGS_IS_ABSTRACT
#else
#define __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, expected_tp, expected_size) ((int) ((t)->tp_basicsize == (expected_size)))
#define __PYX_CHECK_TYPE_FOR_FREELIST_FLAGS  (Py_TPFLAGS_IS_ABSTRACT | Py_TPFLAGS_HEAPTYPE)
#endif
#define __PYX_CHECK_TYPE_FOR_FREELISTS(t, expected_tp, expected_size)\
    (__PYX_CHECK_FINAL_TYPE_FOR_FREELISTS((t), (expected_tp), (expected_size)) &\
     (int) (!__Pyx_PyType_HasFeature((t), __PYX_CHECK_TYPE_FOR_FREELIST_FLAGS)))
#endif

/* AllocateExtensionType.proto */
static PyObject *__Pyx_AllocateExtensionType(PyTypeObject *t, int is_final);

/* ValidateBasesTuple.proto (used by PyType_Ready) */
#if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_USE_TYPE_SPECS
static int __Pyx_validate_bases_tuple(const char *type_name, Py_ssize_t dictoffset, PyObject *bases);
#endif

/* PyType_Ready.proto */
CYTHON_UNUSED static int __Pyx_PyType_Ready(PyTypeObject *t);

/* Py3UpdateBases.proto */
static PyObject* __Pyx_PEP560_update_bases(PyObject *bases);

/* CalculateMetaclass.proto */
static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);

/* SetNameInClass.proto */
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030d0000
#define __Pyx_SetNameInClass(ns, name, value)\
    (likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value))
#elif CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_SetNameInClass(ns, name, value)\
    (likely(PyDict_CheckExact(ns)) ? PyDict_SetItem(ns, name, value) : PyObject_SetItem(ns, name, value))
#else
#define __Pyx_SetNameInClass(ns, name, value)  PyObject_SetItem(ns, name, value)
#endif

/* Py3ClassCreate.proto */
static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
                                           PyObject *mkw, PyObject *modname, PyObject *doc);
static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
                                      PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass);

/* CLineInTraceback.proto (used by AddTraceback) */
#if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME
static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
#else
#define __Pyx_CLineForTraceback(tstate, c_line)  (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
#endif

/* CodeObjectCache.proto (used by AddTraceback) */
#if CYTHON_COMPILING_IN_LIMITED_API
typedef PyObject __Pyx_CachedCodeObjectType;
#else
typedef PyCodeObject __Pyx_CachedCodeObjectType;
#endif
typedef struct {
    __Pyx_CachedCodeObjectType* code_object;
    int code_line;
} __Pyx_CodeObjectCacheEntry;
struct __Pyx_CodeObjectCache {
    int count;
    int max_count;
    __Pyx_CodeObjectCacheEntry* entries;
  #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
    __pyx_atomic_int_type accessor_count;
  #endif
};
static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
static __Pyx_CachedCodeObjectType *__pyx_find_code_object(int code_line);
static void __pyx_insert_code_object(int code_line, __Pyx_CachedCodeObjectType* code_object);

/* AddTraceback.proto */
static void __Pyx_AddTraceback(const char *funcname, int c_line,
                               int py_line, const char *filename);

/* GCCDiagnostics.proto */
#if !defined(__INTEL_COMPILER) && defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
#define __Pyx_HAS_GCC_DIAGNOSTIC
#endif

/* CIntToPy.proto */
static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value);

/* FormatTypeName.proto */
#if CYTHON_COMPILING_IN_LIMITED_API
typedef PyObject *__Pyx_TypeName;
#define __Pyx_FMT_TYPENAME "%U"
#define __Pyx_DECREF_TypeName(obj) Py_XDECREF(obj)
#if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
#define __Pyx_PyType_GetFullyQualifiedName PyType_GetFullyQualifiedName
#else
static __Pyx_TypeName __Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp);
#endif
#else  // !LIMITED_API
typedef const char *__Pyx_TypeName;
#define __Pyx_FMT_TYPENAME "%.200s"
#define __Pyx_PyType_GetFullyQualifiedName(tp) ((tp)->tp_name)
#define __Pyx_DECREF_TypeName(obj)
#endif

/* CIntFromPy.proto */
static CYTHON_INLINE long __Pyx_PyLong_As_long(PyObject *);

/* CIntFromPy.proto */
static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *);

/* GetRuntimeVersion.proto */
#if __PYX_LIMITED_VERSION_HEX < 0x030b0000
static unsigned long __Pyx_cached_runtime_version = 0;
static void __Pyx_init_runtime_version(void);
#else
#define __Pyx_init_runtime_version()
#endif
static unsigned long __Pyx_get_runtime_version(void);

/* Generator.proto */
#define __Pyx_Generator_USED
#define __Pyx_Generator_CheckExact(obj) __Pyx_IS_TYPE(obj, __pyx_mstate_global->__pyx_GeneratorType)
#define __Pyx_Generator_New(body, code, closure, name, qualname, module_name)\
    __Pyx__Coroutine_New(__pyx_mstate_global->__pyx_GeneratorType, body, code, closure, name, qualname, module_name)
static PyObject *__Pyx_Generator_Next(PyObject *self);
static int __pyx_Generator_init(PyObject *module);
static CYTHON_INLINE PyObject *__Pyx_Generator_GetInlinedResult(PyObject *self);

/* AsyncGenerator.proto (used by AsyncGen) */
#define __Pyx_AsyncGen_USED
typedef struct {
    __pyx_CoroutineObject coro;
    PyObject *ag_finalizer;
    int ag_hooks_inited;
    int ag_closed;
    int ag_running_async;
} __pyx_PyAsyncGenObject;
#define __Pyx_AsyncGen_CheckExact(obj) __Pyx_IS_TYPE(obj, __pyx_mstate_global->__pyx_AsyncGenType)
#define __pyx_PyAsyncGenASend_CheckExact(o)\
                    __Pyx_IS_TYPE(o, __pyx_mstate_global->__pyx__PyAsyncGenASendType)
#define __pyx_PyAsyncGenAThrow_CheckExact(o)\
                    __Pyx_IS_TYPE(o, __pyx_mstate_global->__pyx__PyAsyncGenAThrowType)
static PyObject *__Pyx_async_gen_anext(PyObject *o);
static CYTHON_INLINE PyObject *__Pyx_async_gen_asend_iternext(PyObject *o);
static PyObject *__Pyx_async_gen_asend_send(PyObject *g, PyObject *arg);
static PyObject *__Pyx_async_gen_asend_close(PyObject *o, PyObject *args);
static PyObject *__Pyx_async_gen_athrow_close(PyObject *o, PyObject *args);
static PyObject *__Pyx__PyAsyncGenValueWrapperNew(PyObject *val);
static __pyx_CoroutineObject *__Pyx_AsyncGen_New(
            __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name);
static int __pyx_AsyncGen_init(PyObject *module);
static void __Pyx_PyAsyncGen_Fini(void);
#if CYTHON_USE_FREELISTS && !defined(_PyAsyncGen_MAXFREELIST)
#define _PyAsyncGen_MAXFREELIST 80
#endif
struct __pyx__PyAsyncGenWrappedValue;
struct __pyx_PyAsyncGenASend;

/* CheckBinaryVersion.proto */
static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer);

/* DecompressString.proto */
static PyObject *__Pyx_DecompressString(const char *s, Py_ssize_t length, int algo);

/* MultiPhaseInitModuleState.proto */
#if CYTHON_PEP489_MULTI_PHASE_INIT && CYTHON_USE_MODULE_STATE
static PyObject *__Pyx_State_FindModule(void*);
static int __Pyx_State_AddModule(PyObject* module, void*);
static int __Pyx_State_RemoveModule(void*);
#elif CYTHON_USE_MODULE_STATE
#define __Pyx_State_FindModule PyState_FindModule
#define __Pyx_State_AddModule PyState_AddModule
#define __Pyx_State_RemoveModule PyState_RemoveModule
#endif

/* #### Code section: module_declarations ### */
/* CythonABIVersion.proto */
#if CYTHON_COMPILING_IN_LIMITED_API
    #if CYTHON_METH_FASTCALL
        #define __PYX_FASTCALL_ABI_SUFFIX  "_fastcall"
    #else
        #define __PYX_FASTCALL_ABI_SUFFIX
    #endif
    #define __PYX_LIMITED_ABI_SUFFIX "limited" __PYX_FASTCALL_ABI_SUFFIX __PYX_AM_SEND_ABI_SUFFIX
#else
    #define __PYX_LIMITED_ABI_SUFFIX
#endif
#if __PYX_HAS_PY_AM_SEND == 1
    #define __PYX_AM_SEND_ABI_SUFFIX
#elif __PYX_HAS_PY_AM_SEND == 2
    #define __PYX_AM_SEND_ABI_SUFFIX "amsendbackport"
#else
    #define __PYX_AM_SEND_ABI_SUFFIX "noamsend"
#endif
#ifndef __PYX_MONITORING_ABI_SUFFIX
    #define __PYX_MONITORING_ABI_SUFFIX
#endif
#if CYTHON_USE_TP_FINALIZE
    #define __PYX_TP_FINALIZE_ABI_SUFFIX
#else
    #define __PYX_TP_FINALIZE_ABI_SUFFIX "nofinalize"
#endif
#if CYTHON_USE_FREELISTS || !defined(__Pyx_AsyncGen_USED)
    #define __PYX_FREELISTS_ABI_SUFFIX
#else
    #define __PYX_FREELISTS_ABI_SUFFIX "nofreelists"
#endif
#define CYTHON_ABI  __PYX_ABI_VERSION __PYX_LIMITED_ABI_SUFFIX __PYX_MONITORING_ABI_SUFFIX __PYX_TP_FINALIZE_ABI_SUFFIX __PYX_FREELISTS_ABI_SUFFIX __PYX_AM_SEND_ABI_SUFFIX
#define __PYX_ABI_MODULE_NAME "_cython_" CYTHON_ABI
#define __PYX_TYPE_MODULE_PREFIX __PYX_ABI_MODULE_NAME "."


/* Module declarations from "ws_package.controllers.activity_controller" */
/* #### Code section: typeinfo ### */
/* #### Code section: before_global_var ### */
#define __Pyx_MODULE_NAME "ws_package.controllers.activity_controller"
extern int __pyx_module_is_main_ws_package__controllers__activity_controller;
int __pyx_module_is_main_ws_package__controllers__activity_controller = 0;

/* Implementation of "ws_package.controllers.activity_controller" */
/* #### Code section: global_var ### */
static PyObject *__pyx_builtin_staticmethod;
static PyObject *__pyx_builtin_sum;
static PyObject *__pyx_builtin_sorted;
static PyObject *__pyx_builtin_enumerate;
/* #### Code section: string_decls ### */
/* #### Code section: decls ### */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller__to_int(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_val, PyObject *__pyx_v_default); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_2_get_electron_comm_lazy(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_last_count); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_2_handle_wake_session_counter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_4_get_electron_comm(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_6_send_to_electron_if_connected(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_channel, PyObject *__pyx_v_data); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_8_is_system_sleeping(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_10boundary_time(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_interval); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_12_seconds_until_datetime(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_target); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_14increment_session_counter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_reason); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_16should_skip_counter_bump_dedup(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_within_seconds); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_18has_recent_intervals_on_write_counter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_within_seconds); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_21set_project_task_ids(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_project_id, PyObject *__pyx_v_task_id, int __pyx_v_update_segment_start); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23_trim_open_partial_at_project_switch(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_switch_time); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_26_try_finalize_post_switch_slot_interval(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_user_entity); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_29_create_segment_dummy_entry(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_segment_start); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_32get_os_type_caps(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_34handle_s3_time_error(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_error_message); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_36inrange(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_start_date, PyObject *__pyx_v_end_date); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_39_normalize_hhmmss(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_value); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_41_parse_fixed_mode_window(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_response); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_43update_tracking_duration(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_46midnight(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity, PyObject *__pyx_v_last_count); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_49decrypt(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_encrypted_key); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_51_handle_wake_s3_update(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_53_check_and_update_s3_on_startup(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_56_check_and_update_s3_on_wake(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_59_s3_credentials_need_refresh(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_62ensure_s3_credentials_fresh(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_65get_bucket_in_every_interval(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_68update_interval(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_71_apply_org_timezone_preference(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_preference, PyObject *__pyx_v_user_entity); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_73_load_org_settings_from_db(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_76_check_and_handle_limits(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity, PyObject *__pyx_v_org_entity); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_24_check_and_handle_limits_report_in_background(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_79_send_subscription_expired_popup(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v__response); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_81start_screenshot_activity(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity, PyObject *__pyx_v_stop_event); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_84start_device_activity(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity, PyObject *__pyx_v_stop_event); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_87getStartingSlot(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_90getCurrentSlot(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_93_align_to_interval_boundary(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_time); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_10is_browser_genexpr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_10is_browser_3genexpr(PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_95is_browser(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_app_name); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_97__start_minute_activity_timer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_stop_event); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_100__start_device_activity(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity, PyObject *__pyx_v_stop_event); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity__on_time_error(PyObject *__pyx_self, PyObject *__pyx_v_error_type); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_2monitor_active_apps(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_5task_done_callback(PyObject *__pyx_self, PyObject *__pyx_v_task); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_7monitor_active_app_for_ui(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_10active_app_ui_task_done_callback(PyObject *__pyx_self, PyObject *__pyx_v_task); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_12remove_after_delay(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_15check_idle_after_delay(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_21remove_after_delay(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_18remove_after_delay(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_27remove_after_delay(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_24remove_after_delay(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_30check_idle_after_delay(PyObject *__pyx_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_14empty_interval_genexpr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_103empty_interval(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_user_entity); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_106_push_activity_log(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity, PyObject *__pyx_v_stop_event); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_109is_link(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_url); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_111forward_ss(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_ss); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_113ss(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_interval_start_time, PyObject *__pyx_v_interval_end_time, PyObject *__pyx_v_user_entity); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_116group_intervals_by_day(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_intervals); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_118_calculate_gap_seconds(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_prev_interval, PyObject *__pyx_v_current_interval); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_120_determine_sleep_reason(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, double __pyx_v_gap_seconds); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_122_log_session_split_reason(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_reason, PyObject *__pyx_v_prev_interval, PyObject *__pyx_v_current_interval, double __pyx_v_gap_seconds); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_124_should_start_new_session(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_prev_interval, PyObject *__pyx_v_current_interval); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_126_verify_user_activity_during_period(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_start_time, PyObject *__pyx_v_end_time); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_129is_idle_interval(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_interval); /* proto */
static PyObject *__pyx_lambda_funcdef_lambda3(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_x); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_131group_intervals_by_session(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_intervals); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_133get_day_start_time(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_target_date, PyObject *__pyx_v_intervals_for_day); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_135_get_activity_level_from_interval(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_interval); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_137get_activity_level_from_db(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_start_time, PyObject *__pyx_v_end_time); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_140_is_app_monitor_data_stale(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_app_monitor_time, PyObject *__pyx_v_wake_time); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_143_has_any_activity_in_interval(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_start_time, PyObject *__pyx_v_end_time, PyObject *__pyx_v_counter); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_22process_intervals_bulk_4genexpr(PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_146process_intervals_bulk(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_intervals, PyObject *__pyx_v_org_id, PyObject *__pyx_v_user_entity, PyObject *__pyx_v_last_interval, PyObject *__pyx_v_payload_project_id, PyObject *__pyx_v_payload_task_id, PyObject *__pyx_v_force_stop_time); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_22process_intervals_bulk__dt_match(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_tol); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_22process_intervals_bulk_2_dt_match(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_tol); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_149delete_old_data_and_screenshots(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_152start_status_activity(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity, PyObject *__pyx_v_stop_event); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_155set_local_timezone(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_157db_to_server(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_160getting_unsent_interval(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_user_entity); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_163sending_unsent_intervals(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_start, PyObject *__pyx_v_prev_day_unsent, PyObject *__pyx_v_user_entity); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_166log_system_resources(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_168check_memory_usage(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_170_finalize_work_stop_time(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_last_interval, PyObject *__pyx_v_intervals, PyObject *__pyx_v_fallback_end); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_172_break_start_after_work_stop(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_174last_api_call(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity, int __pyx_v_keep_idle_time, PyObject *__pyx_v_close_time, PyObject *__pyx_v_payload_project_id, PyObject *__pyx_v_payload_task_id); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_4genexpr(PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_7genexpr(PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_10genexpr(PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_13genexpr(PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_177_last_api_call_impl(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity, int __pyx_v_keep_idle_time, PyObject *__pyx_v_close_time, PyObject *__pyx_v_payload_project_id, PyObject *__pyx_v_payload_task_id); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_datetime_matches(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dt1, PyObject *__pyx_v_dt2, PyObject *__pyx_v_tolerance_seconds); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_2datetime_matches_final(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dt1, PyObject *__pyx_v_dt2, PyObject *__pyx_v_tolerance_seconds); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_180stop_event(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity, int __pyx_v_keep_idle_time); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_183_send_active_app_update_to_electron(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_app_name, PyObject *__pyx_v_app_icon); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_186_send_file_upload_success_to_electron(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_s3_url); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_189_send_file_upload_failure_to_electron(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_192check_idle_popup_timeout(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_195arise_idle_popup(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_198_has_zero_activity_for_interval(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_start_date, PyObject *__pyx_v_end_date); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_201handle_idle_popup_response(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, int __pyx_v_keep_idle_time, PyObject *__pyx_v_action, PyObject *__pyx_v_project_id, PyObject *__pyx_v_task_id, PyObject *__pyx_v_note, PyObject *__pyx_v_file_path); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_204handle_idle_popup_shown(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_206sync_activity_immediately(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_209_mark_idle_intervals_as_uploaded(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_212_upload_file_to_s3(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_local_file_path); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_215_save_note_to_idle_intervals(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_note, PyObject *__pyx_v_file_path); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_218_save_note_to_current_interval(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_note, PyObject *__pyx_v_file_path); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23_should_pause_api_calls_genexpr(PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_221_should_pause_api_calls(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_intervals); /* proto */
static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_224_idle_reassign(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_project_id, PyObject *__pyx_v_task_id); /* proto */
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
/* #### Code section: late_includes ### */
/* #### Code section: module_state ### */
/* SmallCodeConfig */
#ifndef CYTHON_SMALL_CODE
#if defined(__clang__)
    #define CYTHON_SMALL_CODE
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
    #define CYTHON_SMALL_CODE __attribute__((cold))
#else
    #define CYTHON_SMALL_CODE
#endif
#endif

typedef struct {
  PyObject *__pyx_d;
  PyObject *__pyx_b;
  PyObject *__pyx_cython_runtime;
  PyObject *__pyx_empty_tuple;
  PyObject *__pyx_empty_bytes;
  PyObject *__pyx_empty_unicode;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr;
  PyObject *__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr;
  PyTypeObject *__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign;
  __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_get;
  __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_items;
  __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_keys;
  __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_pop;
  __Pyx_CachedCFunction __pyx_umethod_PyDict_Type_values;
  __Pyx_CachedCFunction __pyx_umethod_PyList_Type__copy;
  __Pyx_CachedCFunction __pyx_umethod_PyUnicode_Type__strip;
  __Pyx_CachedCFunction __pyx_umethod_PyUnicode_Type__upper;
  PyObject *__pyx_slice[4];
  PyObject *__pyx_tuple[36];
  PyObject *__pyx_codeobj_tab[117];
  PyObject *__pyx_string_tab[2257];
  PyObject *__pyx_number_tab[42];
/* #### Code section: module_state_contents ### */
/* CommonTypesMetaclass.module_state_decls */
PyTypeObject *__pyx_CommonTypesMetaclassType;

/* IterNextPlain.module_state_decls */
#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
PyObject *__Pyx_GetBuiltinNext_LimitedAPI_cache;
#endif

/* Coroutine.module_state_decls */
PyTypeObject *__pyx_CoroutineType;
PyTypeObject *__pyx_CoroutineAwaitType;

/* Coro_CheckExact.module_state_decls */
#if CYTHON_COMPILING_IN_LIMITED_API
PyObject *__Pyx_CachedCoroType;
#endif

/* CachedMethodType.module_state_decls */
#if CYTHON_COMPILING_IN_LIMITED_API
PyObject *__Pyx_CachedMethodType;
#endif

/* CythonFunctionShared.module_state_decls */
PyTypeObject *__pyx_CyFunctionType;


#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3 *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr;
#endif

#if CYTHON_USE_FREELISTS
struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign *__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign[8];
int __pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign;
#endif
/* CodeObjectCache.module_state_decls */
struct __Pyx_CodeObjectCache __pyx_code_cache;

/* Generator.module_state_decls */
PyTypeObject *__pyx_GeneratorType;

/* AsyncGenerator.module_state_decls */
PyTypeObject *__pyx__PyAsyncGenWrappedValueType;
PyTypeObject *__pyx__PyAsyncGenASendType;
PyTypeObject *__pyx__PyAsyncGenAThrowType;
PyTypeObject *__pyx_AsyncGenType;
#if CYTHON_USE_FREELISTS
struct __pyx__PyAsyncGenWrappedValue *__Pyx_ag_value_freelist[_PyAsyncGen_MAXFREELIST];
int __Pyx_ag_value_freelist_free;
struct __pyx_PyAsyncGenASend *__Pyx_ag_asend_freelist[_PyAsyncGen_MAXFREELIST];
int __Pyx_ag_asend_freelist_free;
#endif

/* #### Code section: module_state_end ### */
} __pyx_mstatetype;

#if CYTHON_USE_MODULE_STATE
#ifdef __cplusplus
namespace {
extern struct PyModuleDef __pyx_moduledef;
} /* anonymous namespace */
#else
static struct PyModuleDef __pyx_moduledef;
#endif

#define __pyx_mstate_global (__Pyx_PyModule_GetState(__Pyx_State_FindModule(&__pyx_moduledef)))

#define __pyx_m (__Pyx_State_FindModule(&__pyx_moduledef))
#else
static __pyx_mstatetype __pyx_mstate_global_static =
#ifdef __cplusplus
    {};
#else
    {0};
#endif
static __pyx_mstatetype * const __pyx_mstate_global = &__pyx_mstate_global_static;
#endif
/* #### Code section: constant_name_defines ### */
#define __pyx_kp_u_ __pyx_string_tab[0]
#define __pyx_kp_u_0 __pyx_string_tab[1]
#define __pyx_kp_u_00_00_00 __pyx_string_tab[2]
#define __pyx_kp_u_0_0 __pyx_string_tab[3]
#define __pyx_kp_u_0f __pyx_string_tab[4]
#define __pyx_kp_u_1 __pyx_string_tab[5]
#define __pyx_kp_u_1001 __pyx_string_tab[6]
#define __pyx_kp_u_15_Min __pyx_string_tab[7]
#define __pyx_kp_u_1_0 __pyx_string_tab[8]
#define __pyx_kp_u_23_59_59 __pyx_string_tab[9]
#define __pyx_kp_u_4 __pyx_string_tab[10]
#define __pyx_kp_u_5_Min __pyx_string_tab[11]
#define __pyx_kp_u_7_0 __pyx_string_tab[12]
#define __pyx_kp_u_ACTIVITY_Sleep_detected_s_minut __pyx_string_tab[13]
#define __pyx_kp_u_ACTIVITY_System_is_responsive_c __pyx_string_tab[14]
#define __pyx_kp_u_ACTIVITY_System_is_sleeping_ski __pyx_string_tab[15]
#define __pyx_kp_u_APIBlock_API_calls_paused_cycle __pyx_string_tab[16]
#define __pyx_kp_u_APIBlock_All_intervals_are_from __pyx_string_tab[17]
#define __pyx_kp_u_APIBlock_Clearing_s_held_idle_i __pyx_string_tab[18]
#define __pyx_kp_u_APIBlock_Error_checking_databas __pyx_string_tab[19]
#define __pyx_kp_u_APIBlock_Error_checking_if_API __pyx_string_tab[20]
#define __pyx_kp_u_APIBlock_Excluded_s_interval_s __pyx_string_tab[21]
#define __pyx_kp_u_APIBlock_Found_unsent_idle_inte __pyx_string_tab[22]
#define __pyx_kp_u_APIBlock_Holding_1_idle_interva __pyx_string_tab[23]
#define __pyx_kp_u_APIBlock_Holding_idle_interval __pyx_string_tab[24]
#define __pyx_kp_u_APIBlock_Holding_s_idle_interva __pyx_string_tab[25]
#define __pyx_kp_u_APIBlock_Max_pause_cycles_d_rea __pyx_string_tab[26]
#define __pyx_kp_u_APIBlock_Non_idle_interval_s_fo __pyx_string_tab[27]
#define __pyx_kp_u_APIBlock_Pausing_uploads_Idle_p __pyx_string_tab[28]
#define __pyx_kp_u_APIBlock_Sending_s_held_idle_in __pyx_string_tab[29]
#define __pyx_kp_u_APIBlock_Successfully_sent_s_he __pyx_string_tab[30]
#define __pyx_kp_u_API_error_uploading_screenshot_s __pyx_string_tab[31]
#define __pyx_kp_u_API_s_request_failed_s __pyx_string_tab[32]
#define __pyx_kp_u_API_s_timeout __pyx_string_tab[33]
#define __pyx_kp_u_Action_is_continue_with_keep_idl __pyx_string_tab[34]
#define __pyx_kp_u_Active_app_changed_s_s __pyx_string_tab[35]
#define __pyx_kp_u_ActivityController_Set_project_i __pyx_string_tab[36]
#define __pyx_kp_u_ActivityController___init___line __pyx_string_tab[37]
#define __pyx_kp_u_ActivityController_getStartingSl_2 __pyx_string_tab[38]
#define __pyx_kp_u_Activity_found_in_activity_perce __pyx_string_tab[39]
#define __pyx_kp_u_Activity_percentage_record_alrea __pyx_string_tab[40]
#define __pyx_kp_u_Activity_percentage_record_alrea_2 __pyx_string_tab[41]
#define __pyx_kp_u_AddNote_Error_saving_note_to_cu __pyx_string_tab[42]
#define __pyx_kp_u_AddNote_Failed_to_enqueue_Notes __pyx_string_tab[43]
#define __pyx_kp_u_AddNote_Flushing_write_queue_to __pyx_string_tab[44]
#define __pyx_kp_u_AddNote_Latest_interval_found_I __pyx_string_tab[45]
#define __pyx_kp_u_AddNote_No_interval_found_with __pyx_string_tab[46]
#define __pyx_kp_u_AddNote_Processing_write_queue __pyx_string_tab[47]
#define __pyx_kp_u_AddNote_Starting_to_save_note_t __pyx_string_tab[48]
#define __pyx_kp_u_AddNote_Successfully_queued_Not __pyx_string_tab[49]
#define __pyx_kp_u_AddNote_Using_counter_s __pyx_string_tab[50]
#define __pyx_kp_u_AddNote_Using_target_interval_I __pyx_string_tab[51]
#define __pyx_kp_u_AddNote_Write_queue_processed_n __pyx_string_tab[52]
#define __pyx_kp_u_Add_Empty_Interval_in_range_of_t __pyx_string_tab[53]
#define __pyx_kp_u_After_trim_pending_break_interva __pyx_string_tab[54]
#define __pyx_kp_u_After_trimming_Break_interval_ov __pyx_string_tab[55]
#define __pyx_kp_u_After_trimming_Regular_interval __pyx_string_tab[56]
#define __pyx_kp_u_All_s_intervals_from_current_ses __pyx_string_tab[57]
#define __pyx_kp_u_AppMonitor_OS_s_appandurlstatus __pyx_string_tab[58]
#define __pyx_kp_u_AppMonitor_Re_enabled_status_s __pyx_string_tab[59]
#define __pyx_kp_u_AppMonitor_Skipping_cycle_statu __pyx_string_tab[60]
#define __pyx_kp_u_AppMonitor_Still_disabled_statu __pyx_string_tab[61]
#define __pyx_kp_u_AppMonitor_monitor_active_apps __pyx_string_tab[62]
#define __pyx_kp_u_App_monitor_activity_found_for_i __pyx_string_tab[63]
#define __pyx_kp_u_App_monitor_activity_found_for_s __pyx_string_tab[64]
#define __pyx_kp_u_Attempting_fallback_restart_of_d __pyx_string_tab[65]
#define __pyx_kp_u_Attempting_to_save_interval_s_to __pyx_string_tab[66]
#define __pyx_kp_u_Background_task_monitor_active_a __pyx_string_tab[67]
#define __pyx_kp_u_Background_task_monitor_active_a_2 __pyx_string_tab[68]
#define __pyx_kp_u_Background_task_monitor_active_a_3 __pyx_string_tab[69]
#define __pyx_kp_u_Background_task_monitor_active_a_4 __pyx_string_tab[70]
#define __pyx_kp_u_Bearer __pyx_string_tab[71]
#define __pyx_kp_u_Brave_Browser __pyx_string_tab[72]
#define __pyx_kp_u_Break_Intervals_will_be_created __pyx_string_tab[73]
#define __pyx_kp_u_Break_Monitoring_CONTINUES_duri __pyx_string_tab[74]
#define __pyx_kp_u_Break_interval_break_id_s_saving __pyx_string_tab[75]
#define __pyx_kp_u_Break_interval_overlaps_with_tim __pyx_string_tab[76]
#define __pyx_kp_u_Break_is_active_break_id_s_and_i __pyx_string_tab[77]
#define __pyx_kp_u_Break_is_active_break_id_s_and_s __pyx_string_tab[78]
#define __pyx_kp_u_Break_is_active_break_id_s_but_i __pyx_string_tab[79]
#define __pyx_kp_u_Break_is_active_break_id_s_but_i_2 __pyx_string_tab[80]
#define __pyx_kp_u_Building_activity_log_stop_field __pyx_string_tab[81]
#define __pyx_kp_u_CRITICAL_Last_interval_not_foun __pyx_string_tab[82]
#define __pyx_kp_u_CRITICAL_org_api_timezone_is_sti __pyx_string_tab[83]
#define __pyx_kp_u_Calculate_the_starting_time_slo __pyx_string_tab[84]
#define __pyx_kp_u_Cannot_create_last_interval_star __pyx_string_tab[85]
#define __pyx_kp_u_Cannot_execute_midnight_operatio __pyx_string_tab[86]
#define __pyx_kp_u_Cannot_send_previous_day_unsent __pyx_string_tab[87]
#define __pyx_kp_u_Cannot_update_interval_user_enti __pyx_string_tab[88]
#define __pyx_kp_u_Cannot_upload_file_to_S3_S3_conf __pyx_string_tab[89]
#define __pyx_kp_u_Cannot_upload_file_to_S3_file_do __pyx_string_tab[90]
#define __pyx_kp_u_Cannot_upload_file_to_S3_org_id __pyx_string_tab[91]
#define __pyx_kp_u_Cannot_upload_file_to_S3_user_en __pyx_string_tab[92]
#define __pyx_kp_u_Checking_for_remaining_break_int __pyx_string_tab[93]
#define __pyx_kp_u_Checking_queue_status_before_que __pyx_string_tab[94]
#define __pyx_kp_u_Cleaned_up_temporary_database_co __pyx_string_tab[95]
#define __pyx_kp_u_Cleaning_function_Build_for_wind __pyx_string_tab[96]
#define __pyx_kp_u_Cleared_idle_popup_active_flag_a __pyx_string_tab[97]
#define __pyx_kp_u_Cleared_log_file_s __pyx_string_tab[98]
#define __pyx_kp_u_Collecting_and_sending_unsend_ac __pyx_string_tab[99]
#define __pyx_kp_u_Content_Type __pyx_string_tab[100]
#define __pyx_kp_u_Context_file_s_dest_s __pyx_string_tab[101]
#define __pyx_kp_u_Context_file_s_dest_s_s __pyx_string_tab[102]
#define __pyx_kp_u_Could_not_check_activityLevel_at __pyx_string_tab[103]
#define __pyx_kp_u_Could_not_check_activity_level_f __pyx_string_tab[104]
#define __pyx_kp_u_Could_not_check_if_last_interval __pyx_string_tab[105]
#define __pyx_kp_u_Could_not_check_if_last_interval_2 __pyx_string_tab[106]
#define __pyx_kp_u_Could_not_check_is_uploaded_stat __pyx_string_tab[107]
#define __pyx_kp_u_Could_not_check_system_sleep_sta __pyx_string_tab[108]
#define __pyx_kp_u_Could_not_check_wake_time_for_sy __pyx_string_tab[109]
#define __pyx_kp_u_Could_not_delete_last_interval_s __pyx_string_tab[110]
#define __pyx_kp_u_Could_not_find_database_record_f __pyx_string_tab[111]
#define __pyx_kp_u_Could_not_find_database_record_f_2 __pyx_string_tab[112]
#define __pyx_kp_u_Could_not_pre_update_last_interv __pyx_string_tab[113]
#define __pyx_kp_u_Could_not_register_sleep_wake_ca __pyx_string_tab[114]
#define __pyx_kp_u_Could_not_stop_disabled_time_mon __pyx_string_tab[115]
#define __pyx_kp_u_Could_not_verify_macOS_user_acti __pyx_string_tab[116]
#define __pyx_kp_u_Could_not_verify_user_activity_v __pyx_string_tab[117]
#define __pyx_kp_u_Created_segment_dummy_entry_at_s __pyx_string_tab[118]
#define __pyx_kp_u_Creating_first_dummy_entry_start __pyx_string_tab[119]
#define __pyx_kp_u_Creating_last_interval_start_dat __pyx_string_tab[120]
#define __pyx_kp_u_Creating_safe_database_copy_for __pyx_string_tab[121]
#define __pyx_kp_u_Current_Interval_Status_s_Screen __pyx_string_tab[122]
#define __pyx_kp_u_Current_idle_time __pyx_string_tab[123]
#define __pyx_kp_u_DATA_SYNC_FAILED_AFTER_SYSTEM_S __pyx_string_tab[124]
#define __pyx_kp_u_DEBUG_Break_State_Break_interva __pyx_string_tab[125]
#define __pyx_kp_u_DEBUG_Break_State_Saving_interv __pyx_string_tab[126]
#define __pyx_kp_u_DEBUG__save_note_to_idle_interv __pyx_string_tab[127]
#define __pyx_kp_u_Daily_Limit_s __pyx_string_tab[128]
#define __pyx_kp_u_Database_copy_size_mismatch_s_vs __pyx_string_tab[129]
#define __pyx_kp_u_Database_file_not_found_for_uplo __pyx_string_tab[130]
#define __pyx_kp_u_Database_operation_timed_out_aft __pyx_string_tab[131]
#define __pyx_kp_u_Database_query_timed_out_after_s __pyx_string_tab[132]
#define __pyx_kp_u_Database_query_timed_out_after_s_2 __pyx_string_tab[133]
#define __pyx_kp_u_Database_query_timed_out_after_s_3 __pyx_string_tab[134]
#define __pyx_kp_u_Database_query_timed_out_after_s_4 __pyx_string_tab[135]
#define __pyx_kp_u_Database_query_timed_out_after_s_5 __pyx_string_tab[136]
#define __pyx_kp_u_Database_upload_failed_s __pyx_string_tab[137]
#define __pyx_kp_u_Database_uploaded_successfully_s __pyx_string_tab[138]
#define __pyx_kp_u_Date_changed_from_s_to_s_resetti __pyx_string_tab[139]
#define __pyx_kp_u_Day_rollover_detected_s_s __pyx_string_tab[140]
#define __pyx_kp_u_Deferred_post_switch_interval_sa __pyx_string_tab[141]
#define __pyx_kp_u_Deleted_old_ActivityInterval_ent __pyx_string_tab[142]
#define __pyx_kp_u_Deleted_old_Appmonitor_entries __pyx_string_tab[143]
#define __pyx_kp_u_Deleted_old_OrgConfigurations_en __pyx_string_tab[144]
#define __pyx_kp_u_Deleted_s_screenshot_database_en __pyx_string_tab[145]
#define __pyx_kp_u_Deleting_s_screenshot_files __pyx_string_tab[146]
#define __pyx_kp_u_Device_Thread __pyx_string_tab[147]
#define __pyx_kp_u_Device_activity_monitoring_stopp __pyx_string_tab[148]
#define __pyx_kp_u_Device_listener_state_after_brea __pyx_string_tab[149]
#define __pyx_kp_u_Device_listeners_restarted_at_st __pyx_string_tab[150]
#define __pyx_kp_u_Device_listeners_restarted_succe __pyx_string_tab[151]
#define __pyx_kp_u_Either_plan_status_Deactivated_u __pyx_string_tab[152]
#define __pyx_kp_u_Either_plan_status_Deactivated_u_2 __pyx_string_tab[153]
#define __pyx_kp_u_Encrypted_key_must_be_a_non_empt __pyx_string_tab[154]
#define __pyx_kp_u_Enqueued_initial_activity_percen __pyx_string_tab[155]
#define __pyx_kp_u_Error_building_payload_for_inter __pyx_string_tab[156]
#define __pyx_kp_u_Error_cancelling_background_task __pyx_string_tab[157]
#define __pyx_kp_u_Error_checking_activity_in_inter __pyx_string_tab[158]
#define __pyx_kp_u_Error_checking_activity_percenta __pyx_string_tab[159]
#define __pyx_kp_u_Error_checking_and_handling_limi __pyx_string_tab[160]
#define __pyx_kp_u_Error_checking_creating_activity __pyx_string_tab[161]
#define __pyx_kp_u_Error_checking_for_existing_firs __pyx_string_tab[162]
#define __pyx_kp_u_Error_checking_for_existing_inte __pyx_string_tab[163]
#define __pyx_kp_u_Error_checking_for_overlaps_afte __pyx_string_tab[164]
#define __pyx_kp_u_Error_checking_memory_usage_s __pyx_string_tab[165]
#define __pyx_kp_u_Error_checking_recent_intervals __pyx_string_tab[166]
#define __pyx_kp_u_Error_checking_segment_dummy_ent __pyx_string_tab[167]
#define __pyx_kp_u_Error_checking_sending_remaining __pyx_string_tab[168]
#define __pyx_kp_u_Error_checking_zero_activity_for __pyx_string_tab[169]
#define __pyx_kp_u_Error_creating_database_copy_s __pyx_string_tab[170]
#define __pyx_kp_u_Error_deleting_database_entries __pyx_string_tab[171]
#define __pyx_kp_u_Error_deleting_screenshot_file_s __pyx_string_tab[172]
#define __pyx_kp_u_Error_deleting_screenshot_s_in_s __pyx_string_tab[173]
#define __pyx_kp_u_Error_deleting_screenshot_s_in_s_2 __pyx_string_tab[174]
#define __pyx_kp_u_Error_during_periodic_log_cleanu __pyx_string_tab[175]
#define __pyx_kp_u_Error_fetching_notes_from_Notes __pyx_string_tab[176]
#define __pyx_kp_u_Error_fetching_user_org_s __pyx_string_tab[177]
#define __pyx_kp_u_Error_flushing_database_write_qu __pyx_string_tab[178]
#define __pyx_kp_u_Error_flushing_database_write_qu_2 __pyx_string_tab[179]
#define __pyx_kp_u_Error_flushing_database_write_qu_3 __pyx_string_tab[180]
#define __pyx_kp_u_Error_flushing_database_write_qu_4 __pyx_string_tab[181]
#define __pyx_kp_u_Error_flushing_database_write_qu_5 __pyx_string_tab[182]
#define __pyx_kp_u_Error_flushing_database_write_qu_6 __pyx_string_tab[183]
#define __pyx_kp_u_Error_flushing_queue_after_break __pyx_string_tab[184]
#define __pyx_kp_u_Error_force_updating_interval_id __pyx_string_tab[185]
#define __pyx_kp_u_Error_getting_activity_for_break __pyx_string_tab[186]
#define __pyx_kp_u_Error_getting_activity_for_defer __pyx_string_tab[187]
#define __pyx_kp_u_Error_getting_activity_for_trimm __pyx_string_tab[188]
#define __pyx_kp_u_Error_getting_last_interval_on_s __pyx_string_tab[189]
#define __pyx_kp_u_Error_getting_last_interval_on_w __pyx_string_tab[190]
#define __pyx_kp_u_Error_getting_last_interval_s __pyx_string_tab[191]
#define __pyx_kp_u_Error_getting_old_screenshots_s __pyx_string_tab[192]
#define __pyx_kp_u_Error_getting_unsent_intervals_s __pyx_string_tab[193]
#define __pyx_kp_u_Error_handling_S3_time_error_s __pyx_string_tab[194]
#define __pyx_kp_u_Error_handling_idle_popup_respon __pyx_string_tab[195]
#define __pyx_kp_u_Error_in__idle_reassign_s __pyx_string_tab[196]
#define __pyx_kp_u_Error_in_background_limit_notifi __pyx_string_tab[197]
#define __pyx_kp_u_Error_in_database_upload_s __pyx_string_tab[198]
#define __pyx_kp_u_Error_in_db_to_server_s __pyx_string_tab[199]
#define __pyx_kp_u_Error_in_deleting_logs_s_in_s_lo __pyx_string_tab[200]
#define __pyx_kp_u_Error_in_deleting_old_data_and_s __pyx_string_tab[201]
#define __pyx_kp_u_Error_in_device_activity_loop __pyx_string_tab[202]
#define __pyx_kp_u_Error_in_fallback_update_s __pyx_string_tab[203]
#define __pyx_kp_u_Error_in_final_verification_step __pyx_string_tab[204]
#define __pyx_kp_u_Error_in_importing_Activity_Cont __pyx_string_tab[205]
#define __pyx_kp_u_Error_in_minute_activity_timer_s __pyx_string_tab[206]
#define __pyx_kp_u_Error_in_monitor_active_app_for __pyx_string_tab[207]
#define __pyx_kp_u_Error_in_monitoring_active_apps __pyx_string_tab[208]
#define __pyx_kp_u_Error_in_periodic_break_queue_fl __pyx_string_tab[209]
#define __pyx_kp_u_Error_in_stop_event_s __pyx_string_tab[210]
#define __pyx_kp_u_Error_in_sync_activity_immediate __pyx_string_tab[211]
#define __pyx_kp_u_Error_in_uploading_MAC_logs_s __pyx_string_tab[212]
#define __pyx_kp_u_Error_initializing_org_settings __pyx_string_tab[213]
#define __pyx_kp_u_Error_loading_org_settings_from __pyx_string_tab[214]
#define __pyx_kp_u_Error_logging_system_resources_s __pyx_string_tab[215]
#define __pyx_kp_u_Error_manually_including_last_in __pyx_string_tab[216]
#define __pyx_kp_u_Error_marking_held_idle_interval __pyx_string_tab[217]
#define __pyx_kp_u_Error_marking_idle_intervals_as __pyx_string_tab[218]
#define __pyx_kp_u_Error_marking_interval_s_as_uplo __pyx_string_tab[219]
#define __pyx_kp_u_Error_posting_open_work_session __pyx_string_tab[220]
#define __pyx_kp_u_Error_processing_day_s_for_reass __pyx_string_tab[221]
#define __pyx_kp_u_Error_querying_database_for_inte __pyx_string_tab[222]
#define __pyx_kp_u_Error_querying_database_for_last __pyx_string_tab[223]
#define __pyx_kp_u_Error_restarting_device_listener __pyx_string_tab[224]
#define __pyx_kp_u_Error_restarting_device_listener_2 __pyx_string_tab[225]
#define __pyx_kp_u_Error_retrieving_activity_level __pyx_string_tab[226]
#define __pyx_kp_u_Error_retrieving_processing_acti __pyx_string_tab[227]
#define __pyx_kp_u_Error_saving_note_to_Notes_table __pyx_string_tab[228]
#define __pyx_kp_u_Error_sending_active_app_update __pyx_string_tab[229]
#define __pyx_kp_u_Error_sending_file_upload_failur __pyx_string_tab[230]
#define __pyx_kp_u_Error_sending_file_upload_succes __pyx_string_tab[231]
#define __pyx_kp_u_Error_sending_idle_intervals_to __pyx_string_tab[232]
#define __pyx_kp_u_Error_sending_sleep_auto_stop_to __pyx_string_tab[233]
#define __pyx_kp_u_Error_starting_time_monitor_s __pyx_string_tab[234]
#define __pyx_kp_u_Error_triggering_idle_popup_s __pyx_string_tab[235]
#define __pyx_kp_u_Error_updating_interval_id_s_s __pyx_string_tab[236]
#define __pyx_kp_u_Error_updating_screenshot_status __pyx_string_tab[237]
#define __pyx_kp_u_Error_uploading_database_copy_s __pyx_string_tab[238]
#define __pyx_kp_u_Error_uploading_file_to_S3_s __pyx_string_tab[239]
#define __pyx_kp_u_Error_verifying_last_interval_in __pyx_string_tab[240]
#define __pyx_kp_u_Error_verifying_user_activity_du __pyx_string_tab[241]
#define __pyx_kp_u_Exception_type_s __pyx_string_tab[242]
#define __pyx_kp_u_Exclude_Empty_Interval_becasue_i __pyx_string_tab[243]
#define __pyx_kp_u_Existing_dummy_entry_start_time __pyx_string_tab[244]
#define __pyx_kp_u_FAILED_Failed_to_send_file_uplo __pyx_string_tab[245]
#define __pyx_kp_u_FAILED_Failed_to_send_file_uplo_2 __pyx_string_tab[246]
#define __pyx_kp_u_FIRST_ENTRY_mouse_1_by_default __pyx_string_tab[247]
#define __pyx_kp_u_Failed_to_calculate_gap_between __pyx_string_tab[248]
#define __pyx_kp_u_Failed_to_clean_up_temp_file_s __pyx_string_tab[249]
#define __pyx_kp_u_Failed_to_create_screenshot_dire __pyx_string_tab[250]
#define __pyx_kp_u_Failed_to_create_screenshot_dire_2 __pyx_string_tab[251]
#define __pyx_kp_u_Failed_to_delete_screenshot_file __pyx_string_tab[252]
#define __pyx_kp_u_Failed_to_enable_hourly_log_uplo __pyx_string_tab[253]
#define __pyx_kp_u_Failed_to_evaluate_idle_interval __pyx_string_tab[254]
#define __pyx_kp_u_Failed_to_extract_icon_for_s_s __pyx_string_tab[255]
#define __pyx_kp_u_Failed_to_extract_timestamp_from __pyx_string_tab[256]
#define __pyx_kp_u_Failed_to_fetch_start_time_from __pyx_string_tab[257]
#define __pyx_kp_u_Failed_to_fetch_start_time_from_2 __pyx_string_tab[258]
#define __pyx_kp_u_Failed_to_save_activity_percenta __pyx_string_tab[259]
#define __pyx_kp_u_Failed_to_save_interval_during_e __pyx_string_tab[260]
#define __pyx_kp_u_Failed_to_send_active_app_update __pyx_string_tab[261]
#define __pyx_kp_u_Failed_to_send_idle_popup_attemp __pyx_string_tab[262]
#define __pyx_kp_u_Failed_to_send_idle_popup_trigge __pyx_string_tab[263]
#define __pyx_kp_u_Failed_to_send_sleep_auto_stop_t __pyx_string_tab[264]
#define __pyx_kp_u_Failed_to_send_subscription_expi __pyx_string_tab[265]
#define __pyx_kp_u_Failed_to_send_time_integrity_er __pyx_string_tab[266]
#define __pyx_kp_u_Failed_to_send_timezone_error_to __pyx_string_tab[267]
#define __pyx_kp_u_Failed_to_trim_partial_interval __pyx_string_tab[268]
#define __pyx_kp_u_Fallback_restart_succeeded __pyx_string_tab[269]
#define __pyx_kp_u_Fetching_latest_org_settings_bef __pyx_string_tab[270]
#define __pyx_kp_u_File_upload_failed __pyx_string_tab[271]
#define __pyx_kp_u_File_upload_success_message_sent __pyx_string_tab[272]
#define __pyx_kp_u_File_upload_to_S3_failed_or_retu __pyx_string_tab[273]
#define __pyx_kp_u_File_uploaded_successfully __pyx_string_tab[274]
#define __pyx_kp_u_File_uploaded_successfully_to_S3 __pyx_string_tab[275]
#define __pyx_kp_u_File_uploaded_to_S3_successfully __pyx_string_tab[276]
#define __pyx_kp_u_Filtered_out_s_interval_s_that_c __pyx_string_tab[277]
#define __pyx_kp_u_Filtering_by_counter_s_to_keep_s __pyx_string_tab[278]
#define __pyx_kp_u_Filtering_intervals_by_current_s __pyx_string_tab[279]
#define __pyx_kp_u_Filtering_intervals_by_current_s_2 __pyx_string_tab[280]
#define __pyx_kp_u_Filtering_out_interval_start_s_e __pyx_string_tab[281]
#define __pyx_kp_u_Final_verification_passed_All_i __pyx_string_tab[282]
#define __pyx_kp_u_First_dummy_entry_already_exists __pyx_string_tab[283]
#define __pyx_kp_u_First_dummy_entry_created_succes __pyx_string_tab[284]
#define __pyx_kp_u_First_entry_detected_No_existing __pyx_string_tab[285]
#define __pyx_kp_u_First_entry_detected_latest_reco __pyx_string_tab[286]
#define __pyx_kp_u_Flushed_s_queued_database_update __pyx_string_tab[287]
#define __pyx_kp_u_Flushed_s_queued_database_update_2 __pyx_string_tab[288]
#define __pyx_kp_u_Flushed_s_queued_database_update_3 __pyx_string_tab[289]
#define __pyx_kp_u_Flushed_s_queued_database_writes __pyx_string_tab[290]
#define __pyx_kp_u_Flushed_s_queued_database_writes_2 __pyx_string_tab[291]
#define __pyx_kp_u_Flushed_s_queued_database_writes_3 __pyx_string_tab[292]
#define __pyx_kp_u_Flushing_database_write_queue_to __pyx_string_tab[293]
#define __pyx_kp_u_Flushing_database_write_queue_to_2 __pyx_string_tab[294]
#define __pyx_kp_u_Flushing_queue_immediately_after __pyx_string_tab[295]
#define __pyx_kp_u_Force_Stop_Status_False_under_Pu __pyx_string_tab[296]
#define __pyx_kp_u_Force_marked_interval_id_s_as_up __pyx_string_tab[297]
#define __pyx_kp_u_Forced_session_close_setting_pay __pyx_string_tab[298]
#define __pyx_kp_u_Found_database_record_for_interv __pyx_string_tab[299]
#define __pyx_kp_u_Found_notes_for_s_intervals __pyx_string_tab[300]
#define __pyx_kp_u_Found_notes_for_s_intervals_s __pyx_string_tab[301]
#define __pyx_kp_u_Found_s_idle_intervals_to_reassi __pyx_string_tab[302]
#define __pyx_kp_u_Found_s_idle_intervals_to_save_n __pyx_string_tab[303]
#define __pyx_kp_u_Found_s_intervals_from_current __pyx_string_tab[304]
#define __pyx_kp_u_Found_s_intervals_to_sync_immedi __pyx_string_tab[305]
#define __pyx_kp_u_Found_s_remaining_break_interval __pyx_string_tab[306]
#define __pyx_kp_u_Found_s_unsent_intervals_from_cu __pyx_string_tab[307]
#define __pyx_kp_u_Found_unsent_non_break_intervals __pyx_string_tab[308]
#define __pyx_kp_u_Generated_payload_for_date_s_wit __pyx_string_tab[309]
#define __pyx_kp_u_Generated_payload_for_previous_d __pyx_string_tab[310]
#define __pyx_kp_u_Getting_last_activity_interval __pyx_string_tab[311]
#define __pyx_kp_u_Google_Chrome __pyx_string_tab[312]
#define __pyx_kp_u_H_M __pyx_string_tab[313]
#define __pyx_kp_u_H_M_S __pyx_string_tab[314]
#define __pyx_kp_u_Hourly_log_upload_enabled_throug __pyx_string_tab[315]
#define __pyx_kp_u_IPC_not_connected_after_s_attemp __pyx_string_tab[316]
#define __pyx_kp_u_IPC_not_connected_for_idle_popup __pyx_string_tab[317]
#define __pyx_kp_u_IPC_not_connected_skipping_activ __pyx_string_tab[318]
#define __pyx_kp_u_IPC_not_connected_skipping_file __pyx_string_tab[319]
#define __pyx_kp_u_IPC_not_connected_skipping_file_2 __pyx_string_tab[320]
#define __pyx_kp_u_IPC_server_not_ready_skipping_ac __pyx_string_tab[321]
#define __pyx_kp_u_IPC_server_not_ready_skipping_fi __pyx_string_tab[322]
#define __pyx_kp_u_IPC_server_not_ready_skipping_fi_2 __pyx_string_tab[323]
#define __pyx_kp_u_IdleDetection_Checking_for_idle __pyx_string_tab[324]
#define __pyx_kp_u_IdleDetection_Checking_for_idle_2 __pyx_string_tab[325]
#define __pyx_kp_u_IdleDetection_Checking_for_idle_3 __pyx_string_tab[326]
#define __pyx_kp_u_IdleDetection_Idle_detected_tri __pyx_string_tab[327]
#define __pyx_kp_u_IdleDetection_No_idle_detected __pyx_string_tab[328]
#define __pyx_kp_u_IdleDetection_No_idle_detected_2 __pyx_string_tab[329]
#define __pyx_kp_u_IdleInterval_ActivityLevel_Keyb __pyx_string_tab[330]
#define __pyx_kp_u_IdleInterval_Interval_marked_as __pyx_string_tab[331]
#define __pyx_kp_u_IdleInterval_Regular_interval_i __pyx_string_tab[332]
#define __pyx_kp_u_IdleInterval_Regular_interval_o __pyx_string_tab[333]
#define __pyx_kp_u_IdleInterval_Saving_break_id_s __pyx_string_tab[334]
#define __pyx_kp_u_IdleInterval_Saving_is_uploaded __pyx_string_tab[335]
#define __pyx_kp_u_IdlePopup_Break_session_is_acti __pyx_string_tab[336]
#define __pyx_kp_u_IdlePopup_Calculated_consecutiv __pyx_string_tab[337]
#define __pyx_kp_u_IdlePopup_IPC_server_is_not_run __pyx_string_tab[338]
#define __pyx_kp_u_IdlePopup_Not_triggered_consecu __pyx_string_tab[339]
#define __pyx_kp_u_IdlePopup_Popup_already_active __pyx_string_tab[340]
#define __pyx_kp_u_IdlePopup_Server_uploads_BLOCKE __pyx_string_tab[341]
#define __pyx_kp_u_IdlePopup_State_active_True_tri __pyx_string_tab[342]
#define __pyx_kp_u_IdlePopup_Timeout_reached_auto __pyx_string_tab[343]
#define __pyx_kp_u_IdlePopup_Trigger_sent_to_Elect __pyx_string_tab[344]
#define __pyx_kp_u_IdlePopup_Triggering_popup_cons __pyx_string_tab[345]
#define __pyx_kp_u_IdlePopup_arise_idle_popup_call __pyx_string_tab[346]
#define __pyx_kp_u_IdleResponse_Clearing_popup_sta __pyx_string_tab[347]
#define __pyx_kp_u_IdleResponse_Clearing_s_held_id __pyx_string_tab[348]
#define __pyx_kp_u_IdleResponse_Handling_idle_popu __pyx_string_tab[349]
#define __pyx_kp_u_IdleResponse_State_cleared_unse __pyx_string_tab[350]
#define __pyx_kp_u_IdleResponse_User_chose_not_to __pyx_string_tab[351]
#define __pyx_kp_u_IdleResponse_User_chose_to_keep __pyx_string_tab[352]
#define __pyx_kp_u_IdleTimeout_Auto_stop_triggered __pyx_string_tab[353]
#define __pyx_kp_u_IdleTimeout_Checking_timeout_el __pyx_string_tab[354]
#define __pyx_kp_u_IdleTimeout_Error_checking_idle __pyx_string_tab[355]
#define __pyx_kp_u_IdleTimeout_Error_sending_auto __pyx_string_tab[356]
#define __pyx_kp_u_IdleTimeout_Marking_s_intervals __pyx_string_tab[357]
#define __pyx_kp_u_IdleTimeout_Sent_auto_stop_sign __pyx_string_tab[358]
#define __pyx_kp_u_IdleTimeout_TIMEOUT_REACHED_ss __pyx_string_tab[359]
#define __pyx_kp_u_IdleTimeout_Timer_stopped_due_t __pyx_string_tab[360]
#define __pyx_kp_u_IdleUnkeep_Committed_is_uploade __pyx_string_tab[361]
#define __pyx_kp_u_IdleUnkeep_Marking_s_interval_s __pyx_string_tab[362]
#define __pyx_kp_u_IdleUnkeep_No_intervals_to_mark __pyx_string_tab[363]
#define __pyx_kp_u_IdleUnkeep_Popup_period_scan_fr __pyx_string_tab[364]
#define __pyx_kp_u_Idle_popup_could_not_be_sent_IPC __pyx_string_tab[365]
#define __pyx_kp_u_Idle_popup_shown_confirmed_by_El __pyx_string_tab[366]
#define __pyx_kp_u_Idle_reassign_completed_s_inter __pyx_string_tab[367]
#define __pyx_kp_u_Ignoring_time_monitor_event_beca __pyx_string_tab[368]
#define __pyx_kp_u_Immediate_sync_API_call_failed_o __pyx_string_tab[369]
#define __pyx_kp_u_Immediate_sync_API_response_s __pyx_string_tab[370]
#define __pyx_kp_u_In_range_of_tracking_senerio __pyx_string_tab[371]
#define __pyx_kp_u_Initialize_ActivityController_w __pyx_string_tab[372]
#define __pyx_kp_u_Interval_already_exists_for_s_to __pyx_string_tab[373]
#define __pyx_kp_u_Interval_missing_id_attribute_s __pyx_string_tab[374]
#define __pyx_kp_u_Interval_s_start_time_s_end_tim __pyx_string_tab[375]
#define __pyx_kp_u_Intervals_found_in_database_firs __pyx_string_tab[376]
#define __pyx_kp_u_Invalid_UTF_8_data_in_encrypted __pyx_string_tab[377]
#define __pyx_kp_u_Invalid_base64_data_in_encrypted __pyx_string_tab[378]
#define __pyx_kp_u_Invalid_encrypted_key_format_emp __pyx_string_tab[379]
#define __pyx_kp_u_Invalid_encrypted_key_format_mis __pyx_string_tab[380]
#define __pyx_kp_u_Keyboard_and_mouse_activity_trac __pyx_string_tab[381]
#define __pyx_kp_u_LIMIT_EXCEEDED_NOTIFICATION_ONL __pyx_string_tab[382]
#define __pyx_kp_u_Last_interval_already_in_list_fo __pyx_string_tab[383]
#define __pyx_kp_u_Last_interval_confirmed_in_quer __pyx_string_tab[384]
#define __pyx_kp_u_Last_interval_details_start_tim __pyx_string_tab[385]
#define __pyx_kp_u_Last_interval_details_start_time __pyx_string_tab[386]
#define __pyx_kp_u_Last_interval_found_in_query_res __pyx_string_tab[387]
#define __pyx_kp_u_Last_interval_id_s_explicitly_up __pyx_string_tab[388]
#define __pyx_kp_u_Last_interval_id_s_explicitly_up_2 __pyx_string_tab[389]
#define __pyx_kp_u_Last_interval_id_s_found_with_to __pyx_string_tab[390]
#define __pyx_kp_u_Last_interval_id_s_was_not_in_th __pyx_string_tab[391]
#define __pyx_kp_u_Last_interval_id_s_was_updated_i __pyx_string_tab[392]
#define __pyx_kp_u_Last_interval_in_this_batch_stop __pyx_string_tab[393]
#define __pyx_kp_u_Last_interval_may_not_be_in_que __pyx_string_tab[394]
#define __pyx_kp_u_Last_interval_not_found_in_query __pyx_string_tab[395]
#define __pyx_kp_u_Last_interval_not_found_in_query_2 __pyx_string_tab[396]
#define __pyx_kp_u_Last_interval_not_found_in_query_3 __pyx_string_tab[397]
#define __pyx_kp_u_Last_interval_saved_start_time_s __pyx_string_tab[398]
#define __pyx_kp_u_Last_interval_saved_with_is_uplo __pyx_string_tab[399]
#define __pyx_kp_u_Last_interval_saved_with_is_uplo_2 __pyx_string_tab[400]
#define __pyx_kp_u_Last_interval_screenshots_update __pyx_string_tab[401]
#define __pyx_kp_u_Last_interval_still_not_found_af __pyx_string_tab[402]
#define __pyx_kp_u_Last_interval_stop_aligning_payl __pyx_string_tab[403]
#define __pyx_kp_u_Last_interval_stop_extending_scr __pyx_string_tab[404]
#define __pyx_kp_u_Last_interval_verified_and_has __pyx_string_tab[405]
#define __pyx_kp_u_Last_interval_was_not_updated_in __pyx_string_tab[406]
#define __pyx_kp_u_Last_saved_interval_details_star __pyx_string_tab[407]
#define __pyx_kp_u_Library_Application_Support_Work __pyx_string_tab[408]
#define __pyx_kp_u_Library_Application_Support_Work_2 __pyx_string_tab[409]
#define __pyx_kp_u_Library_Application_Support_Work_3 __pyx_string_tab[410]
#define __pyx_kp_u_Limit_Action_s __pyx_string_tab[411]
#define __pyx_kp_u_Limit_Type_s __pyx_string_tab[412]
#define __pyx_kp_u_Limited_to_100_intervals_for_dat __pyx_string_tab[413]
#define __pyx_kp_u_Linux_All_URL_detection_methods __pyx_string_tab[414]
#define __pyx_kp_u_Linux_URL_detected_via_comprehe __pyx_string_tab[415]
#define __pyx_kp_u_Loaded_org_settings_from_DB_time __pyx_string_tab[416]
#define __pyx_kp_u_Log_file_s_does_not_exist_skippi __pyx_string_tab[417]
#define __pyx_kp_u_MAC_ErrorLog_file_does_not_exist __pyx_string_tab[418]
#define __pyx_kp_u_MEMORY_WARNING_Memory_usage_hig __pyx_string_tab[419]
#define __pyx_kp_u_Manually_added_last_interval_to __pyx_string_tab[420]
#define __pyx_kp_u_Marked_interval_id_s_counter_s_f __pyx_string_tab[421]
#define __pyx_kp_u_Marked_s_additional_intervals_fr __pyx_string_tab[422]
#define __pyx_kp_u_Microsoft_Edge __pyx_string_tab[423]
#define __pyx_kp_u_Minute_activity_timer_stopped __pyx_string_tab[424]
#define __pyx_kp_u_Mozilla_Firefox __pyx_string_tab[425]
#define __pyx_kp_u_N_A __pyx_string_tab[426]
#define __pyx_kp_u_Network_error_during_screenshot __pyx_string_tab[427]
#define __pyx_kp_u_Network_error_during_screenshot_2 __pyx_string_tab[428]
#define __pyx_kp_u_Network_error_during_screenshot_3 __pyx_string_tab[429]
#define __pyx_kp_u_Network_error_uploading_screensh __pyx_string_tab[430]
#define __pyx_kp_u_New_Tab __pyx_string_tab[431]
#define __pyx_kp_u_No_Connection_for_timestamp_and __pyx_string_tab[432]
#define __pyx_kp_u_No_completed_intervals_to_sync_i __pyx_string_tab[433]
#define __pyx_kp_u_No_idle_intervals_found_to_reass __pyx_string_tab[434]
#define __pyx_kp_u_No_idle_intervals_found_to_save __pyx_string_tab[435]
#define __pyx_kp_u_No_interval_found_in_held_interv __pyx_string_tab[436]
#define __pyx_kp_u_No_interval_found_s __pyx_string_tab[437]
#define __pyx_kp_u_No_interval_payloads_created_for __pyx_string_tab[438]
#define __pyx_kp_u_No_intervals_found_for_the_given __pyx_string_tab[439]
#define __pyx_kp_u_No_intervals_found_in_database_a __pyx_string_tab[440]
#define __pyx_kp_u_No_intervals_found_to_sync_immed __pyx_string_tab[441]
#define __pyx_kp_u_No_intervals_remain_after_filter __pyx_string_tab[442]
#define __pyx_kp_u_No_items_in_queue_last_interval __pyx_string_tab[443]
#define __pyx_kp_u_No_limit_start_or_end_time_or_no __pyx_string_tab[444]
#define __pyx_kp_u_No_missing_intervals __pyx_string_tab[445]
#define __pyx_kp_u_No_org_settings_from_API_rate_li __pyx_string_tab[446]
#define __pyx_kp_u_No_previous_interval_and_no_sess __pyx_string_tab[447]
#define __pyx_kp_u_No_previous_interval_found_using __pyx_string_tab[448]
#define __pyx_kp_u_No_project_selected_in_Python_us __pyx_string_tab[449]
#define __pyx_kp_u_No_remaining_break_intervals_fou __pyx_string_tab[450]
#define __pyx_kp_u_No_response_received_from_server __pyx_string_tab[451]
#define __pyx_kp_u_No_screenshots_older_than_7_days __pyx_string_tab[452]
#define __pyx_kp_u_No_tracking_scenerio_found __pyx_string_tab[453]
#define __pyx_kp_u_No_unsent_intervals_to_send __pyx_string_tab[454]
#define __pyx_kp_u_No_unsent_non_break_intervals_fo __pyx_string_tab[455]
#define __pyx_kp_u_No_user_activity_during_period __pyx_string_tab[456]
#define __pyx_kp_u_None __pyx_string_tab[457]
#define __pyx_kp_u_Not_in_Tracking_days __pyx_string_tab[458]
#define __pyx_kp_u_Note_File_saved_to_idle_interval __pyx_string_tab[459]
#define __pyx_kp_u_Note_that_Cython_is_deliberately __pyx_string_tab[460]
#define __pyx_kp_u_Note_truncated_from_s_to_s_chara __pyx_string_tab[461]
#define __pyx_kp_u_ORG_check_at_every_interval __pyx_string_tab[462]
#define __pyx_kp_u_OS_error_accessing_screenshot_s __pyx_string_tab[463]
#define __pyx_kp_u_On_break_break_id_s_flushing_s_q __pyx_string_tab[464]
#define __pyx_kp_u_Optional_asyncio_Event __pyx_string_tab[465]
#define __pyx_kp_u_Optional_datetime_datetime __pyx_string_tab[466]
#define __pyx_kp_u_Optional_str __pyx_string_tab[467]
#define __pyx_kp_u_Orchestrates_activity_monitorin __pyx_string_tab[468]
#define __pyx_kp_u_Out_of_range_of_tracking_senerio __pyx_string_tab[469]
#define __pyx_kp_u_Pending_break_interval_in_write __pyx_string_tab[470]
#define __pyx_kp_u_Performing_final_verification_ch __pyx_string_tab[471]
#define __pyx_kp_u_Permission_denied_accessing_scre __pyx_string_tab[472]
#define __pyx_kp_u_Previous_day_unsent_intervals_s __pyx_string_tab[473]
#define __pyx_kp_u_Proceeding_to_save_interval_with __pyx_string_tab[474]
#define __pyx_kp_u_Processing_s_idle_intervals_for __pyx_string_tab[475]
#define __pyx_kp_u_Processing_s_pending_queue_items __pyx_string_tab[476]
#define __pyx_kp_u_Processing_s_remaining_queue_ite __pyx_string_tab[477]
#define __pyx_kp_u_Project_switch_close_using_trimm __pyx_string_tab[478]
#define __pyx_kp_u_Push_thread __pyx_string_tab[479]
#define __pyx_kp_u_Python_process_will_remain_alive __pyx_string_tab[480]
#define __pyx_kp_u_Query_returned_0_intervals_last __pyx_string_tab[481]
#define __pyx_kp_u_Queue_is_empty_all_items_already __pyx_string_tab[482]
#define __pyx_kp_u_Queue_status_before_final_flush __pyx_string_tab[483]
#define __pyx_kp_u_Queue_status_before_flush_ACTIVI __pyx_string_tab[484]
#define __pyx_kp_u_Queued_Notes_entry_with_s_interv __pyx_string_tab[485]
#define __pyx_kp_u_Re_queried_after_delay_Found_s_i __pyx_string_tab[486]
#define __pyx_kp_u_Reassign_action_requires_project __pyx_string_tab[487]
#define __pyx_kp_u_Regular_interval_overlaps_with_t __pyx_string_tab[488]
#define __pyx_kp_u_Remaining_break_intervals_sent __pyx_string_tab[489]
#define __pyx_kp_u_Resolving_slot_s_to_s_already_ex __pyx_string_tab[490]
#define __pyx_kp_u_Response_for_held_idle_intervals __pyx_string_tab[491]
#define __pyx_kp_u_Response_s __pyx_string_tab[492]
#define __pyx_kp_u_Restarting_device_listeners_afte __pyx_string_tab[493]
#define __pyx_kp_u_Restarting_device_listeners_at_s __pyx_string_tab[494]
#define __pyx_kp_u_Retrieved_activity_level_for_las __pyx_string_tab[495]
#define __pyx_kp_u_Retrieved_d_unsent_non_break_int __pyx_string_tab[496]
#define __pyx_kp_u_Running_db_to_server __pyx_string_tab[497]
#define __pyx_kp_u_Running_device_activity_force_st __pyx_string_tab[498]
#define __pyx_kp_u_Running_push_empty_intervals __pyx_string_tab[499]
#define __pyx_kp_u_Running_push_logs __pyx_string_tab[500]
#define __pyx_kp_u_Running_push_loop_force_stop_s_t __pyx_string_tab[501]
#define __pyx_kp_u_Running_timecheck_timezone_prefe __pyx_string_tab[502]
#define __pyx_kp_u_Running_unsent_intervals_check_e __pyx_string_tab[503]
#define __pyx_kp_u_S3BucketEntity_None __pyx_string_tab[504]
#define __pyx_kp_u_S3_RequestTimeTooSkewed_system_c __pyx_string_tab[505]
#define __pyx_kp_u_S3_TIME_TAMPERING_DETECTED_durin __pyx_string_tab[506]
#define __pyx_kp_u_S3_upload_returned_no_URL_for_fi __pyx_string_tab[507]
#define __pyx_kp_u_SESSION_COUNTER_Incremented_s_s __pyx_string_tab[508]
#define __pyx_kp_u_SLEEP_Registered_sleep_callback __pyx_string_tab[509]
#define __pyx_kp_u_SLEEP_Skipping_device_listener __pyx_string_tab[510]
#define __pyx_kp_u_STARTUP_Error_checking_updating __pyx_string_tab[511]
#define __pyx_kp_u_STARTUP_New_day_detected_last_s __pyx_string_tab[512]
#define __pyx_kp_u_STARTUP_STS_credentials_expired __pyx_string_tab[513]
#define __pyx_kp_u_STARTUP_Same_day_last_s_current __pyx_string_tab[514]
#define __pyx_kp_u_STEALTH_API_call_failed_will_tr __pyx_string_tab[515]
#define __pyx_kp_u_STEALTH_API_call_successful_cac __pyx_string_tab[516]
#define __pyx_kp_u_STEALTH_Cache_expired_ss_ss_ref __pyx_string_tab[517]
#define __pyx_kp_u_STEALTH_First_stealth_mode_API __pyx_string_tab[518]
#define __pyx_kp_u_STEALTH_Fixed_mode_window_missi __pyx_string_tab[519]
#define __pyx_kp_u_STEALTH_No_cached_response_avai __pyx_string_tab[520]
#define __pyx_kp_u_STEALTH_Using_cached_stealth_mo __pyx_string_tab[521]
#define __pyx_kp_u_STEALTH_Using_cached_stealth_mo_2 __pyx_string_tab[522]
#define __pyx_kp_u_STOPPING_TIMER_DUE_TO_LIMIT_EXC __pyx_string_tab[523]
#define __pyx_kp_u_SUCCESS_Sent_file_upload_failur __pyx_string_tab[524]
#define __pyx_kp_u_SUCCESS_Sent_file_upload_succes __pyx_string_tab[525]
#define __pyx_kp_u_SYSTEM_RESOURCES_Memory_2fMB_1f __pyx_string_tab[526]
#define __pyx_kp_u_Save_last_activity_interval_to_D __pyx_string_tab[527]
#define __pyx_kp_u_Screenshot_file_not_found_s __pyx_string_tab[528]
#define __pyx_kp_u_Screenshot_file_not_found_s_s __pyx_string_tab[529]
#define __pyx_kp_u_Screenshot_file_not_readable_s __pyx_string_tab[530]
#define __pyx_kp_u_Screenshot_sync_error_for_Mac_lo __pyx_string_tab[531]
#define __pyx_kp_u_Screenshot_sync_error_for_databa __pyx_string_tab[532]
#define __pyx_kp_u_Screenshot_sync_error_for_screen __pyx_string_tab[533]
#define __pyx_kp_u_Screenshot_sync_validation_error __pyx_string_tab[534]
#define __pyx_kp_u_Screenshot_sync_validation_error_2 __pyx_string_tab[535]
#define __pyx_kp_u_Screenshot_sync_validation_error_3 __pyx_string_tab[536]
#define __pyx_kp_u_Segment_dummy_entry_already_exis __pyx_string_tab[537]
#define __pyx_kp_u_Sending_immediate_sync_payload_f __pyx_string_tab[538]
#define __pyx_kp_u_Sending_mac_logs_to_server __pyx_string_tab[539]
#define __pyx_kp_u_Sending_previous_day_unsent_inte __pyx_string_tab[540]
#define __pyx_kp_u_Sending_s_idle_intervals_to_API __pyx_string_tab[541]
#define __pyx_kp_u_Sent_active_app_update_to_Electr __pyx_string_tab[542]
#define __pyx_kp_u_Sent_subscription_expiration_err __pyx_string_tab[543]
#define __pyx_kp_u_Sent_timezone_mismatch_error_to __pyx_string_tab[544]
#define __pyx_kp_u_Sent_timezone_mismatch_error_to_2 __pyx_string_tab[545]
#define __pyx_kp_u_Session_split_detected_reason_s __pyx_string_tab[546]
#define __pyx_kp_u_Set_current_project_id_s_task_id __pyx_string_tab[547]
#define __pyx_kp_u_Set_status_True_as_fallback_when __pyx_string_tab[548]
#define __pyx_kp_u_Setting_S3_details_for_db_to_ser __pyx_string_tab[549]
#define __pyx_kp_u_Silent_Sleep_gap_1_hour_0fs_fil __pyx_string_tab[550]
#define __pyx_kp_u_Skip_empty_interval_for __pyx_string_tab[551]
#define __pyx_kp_u_Skip_sleep_gap_fill_interval_alr __pyx_string_tab[552]
#define __pyx_kp_u_Skipping_all_data_sync_operation __pyx_string_tab[553]
#define __pyx_kp_u_Skipping_duplicate_break_interva __pyx_string_tab[554]
#define __pyx_kp_u_Skipping_duplicate_break_interva_2 __pyx_string_tab[555]
#define __pyx_kp_u_Skipping_duplicate_interval_alre __pyx_string_tab[556]
#define __pyx_kp_u_Skipping_duplicate_interval_crea __pyx_string_tab[557]
#define __pyx_kp_u_Skipping_exception_recovery_save __pyx_string_tab[558]
#define __pyx_kp_u_Skipping_exception_recovery_save_2 __pyx_string_tab[559]
#define __pyx_kp_u_Skipping_hourly_log_upload_initi __pyx_string_tab[560]
#define __pyx_kp_u_Skipping_idle_reassignment_inter __pyx_string_tab[561]
#define __pyx_kp_u_Skipping_interval_creation_after __pyx_string_tab[562]
#define __pyx_kp_u_Skipping_interval_creation_after_2 __pyx_string_tab[563]
#define __pyx_kp_u_Skipping_interval_start_s_end_s __pyx_string_tab[564]
#define __pyx_kp_u_Skipping_last_interval_creation __pyx_string_tab[565]
#define __pyx_kp_u_Skipping_regular_interval_creati __pyx_string_tab[566]
#define __pyx_kp_u_Skipping_regular_interval_creati_2 __pyx_string_tab[567]
#define __pyx_kp_u_Skipping_timecheck_org_timezone __pyx_string_tab[568]
#define __pyx_kp_u_Skipping_timecheck_timezone_pref __pyx_string_tab[569]
#define __pyx_kp_u_Skipping_timecheck_user_entity_i __pyx_string_tab[570]
#define __pyx_kp_u_SleepInterval_Detected_sleep_in __pyx_string_tab[571]
#define __pyx_kp_u_SleepInterval_Detected_sleep_in_2 __pyx_string_tab[572]
#define __pyx_kp_u_SleepInterval_Last_interval_is __pyx_string_tab[573]
#define __pyx_kp_u_SleepInterval_Last_interval_is_2 __pyx_string_tab[574]
#define __pyx_kp_u_SleepInterval_Last_interval_was __pyx_string_tab[575]
#define __pyx_kp_u_SleepInterval_Skipping_last_int __pyx_string_tab[576]
#define __pyx_kp_u_SleepInterval_Skipping_manual_i __pyx_string_tab[577]
#define __pyx_kp_u_SleepInterval_Skipping_stop_tim __pyx_string_tab[578]
#define __pyx_kp_u_Sleep_auto_stop_signal_sent_to_E __pyx_string_tab[579]
#define __pyx_kp_u_Sleep_gap __pyx_string_tab[580]
#define __pyx_kp_u_Sleep_gap_1_hour_gap_seconds_0f __pyx_string_tab[581]
#define __pyx_kp_u_Sleep_is_less_than_1_hour_adding __pyx_string_tab[582]
#define __pyx_kp_u_Sleeping_1fs_until_interval_end __pyx_string_tab[583]
#define __pyx_kp_u_Start_date_or_end_date_is_None __pyx_string_tab[584]
#define __pyx_kp_u_Started_app_monitor_flush_task __pyx_string_tab[585]
#define __pyx_kp_u_Starting_deletion_of_old_data_an __pyx_string_tab[586]
#define __pyx_kp_u_Starting_idle_interval_reassign __pyx_string_tab[587]
#define __pyx_kp_u_Starting_last_api_call_normal_st __pyx_string_tab[588]
#define __pyx_kp_u_Starting_minute_by_minute_activi __pyx_string_tab[589]
#define __pyx_kp_u_Starting_screenshot_activity_wit __pyx_string_tab[590]
#define __pyx_kp_u_Starting_time_monitor_s __pyx_string_tab[591]
#define __pyx_kp_u_Stop_event_detected_after_sleep __pyx_string_tab[592]
#define __pyx_kp_u_Stop_event_detected_breaking_loo __pyx_string_tab[593]
#define __pyx_kp_u_Successfully_deleted_old_data_an __pyx_string_tab[594]
#define __pyx_kp_u_Successfully_processed_s_queued __pyx_string_tab[595]
#define __pyx_kp_u_Successfully_saved_interval_afte __pyx_string_tab[596]
#define __pyx_kp_u_Successfully_sent_idle_intervals __pyx_string_tab[597]
#define __pyx_kp_u_System_clock_drift_detected_by_t __pyx_string_tab[598]
#define __pyx_kp_u_System_is_in_sleep_s __pyx_string_tab[599]
#define __pyx_kp_u_Target_date_of_intervals_s __pyx_string_tab[600]
#define __pyx_kp_u_Temporary_database_file_not_avai __pyx_string_tab[601]
#define __pyx_kp_u_Time_integrity_error_detected_s __pyx_string_tab[602]
#define __pyx_kp_u_Time_mismatch_under_activity __pyx_string_tab[603]
#define __pyx_kp_u_Time_monitor_started_timezone_an __pyx_string_tab[604]
#define __pyx_kp_u_Time_tampering_detected __pyx_string_tab[605]
#define __pyx_kp_u_Timeout_checking_recent_interval __pyx_string_tab[606]
#define __pyx_kp_u_Timer_remains_stopped_due_to_lim __pyx_string_tab[607]
#define __pyx_kp_u_Timer_started_at_s_appsandurlsta __pyx_string_tab[608]
#define __pyx_kp_u_Timer_will_remain_stopped_until __pyx_string_tab[609]
#define __pyx_kp_u_TimezonePref_Failed_to_toggle_t __pyx_string_tab[610]
#define __pyx_kp_u_TimezonePref_Time_monitor_start __pyx_string_tab[611]
#define __pyx_kp_u_TimezonePref_Time_monitor_stopp __pyx_string_tab[612]
#define __pyx_kp_u_TimezonePref_org_timezone_prefe __pyx_string_tab[613]
#define __pyx_kp_u_Timezone_Error __pyx_string_tab[614]
#define __pyx_kp_u_Timezone_Mismatch_Detected __pyx_string_tab[615]
#define __pyx_kp_u_Timezone_and_Time_matched_succes __pyx_string_tab[616]
#define __pyx_kp_u_Timezone_change_detected_by_time __pyx_string_tab[617]
#define __pyx_kp_u_Timezone_error_sent_to_Electron __pyx_string_tab[618]
#define __pyx_kp_u_Timezone_mismatch_detected_SKIPP __pyx_string_tab[619]
#define __pyx_kp_u_Timezone_mismatch_detected_in_ac __pyx_string_tab[620]
#define __pyx_kp_u_Timezone_mismatch_under_Push_loo __pyx_string_tab[621]
#define __pyx_kp_u_Timezone_time_monitor_disabled_b __pyx_string_tab[622]
#define __pyx_kp_u_Timing_Python_Creating_first_du __pyx_string_tab[623]
#define __pyx_kp_u_Timing_Python_DB_write_queue_fl __pyx_string_tab[624]
#define __pyx_kp_u_Timing_Python_Fetching_org_sett __pyx_string_tab[625]
#define __pyx_kp_u_Timing_Python_First_dummy_entry __pyx_string_tab[626]
#define __pyx_kp_u_Timing_Python_Flushing_DB_write __pyx_string_tab[627]
#define __pyx_kp_u_Timing_Python_Inside_main_activ __pyx_string_tab[628]
#define __pyx_kp_u_Timing_Python_Org_settings_fetc __pyx_string_tab[629]
#define __pyx_kp_u_Timing_Python_org_api_timezone __pyx_string_tab[630]
#define __pyx_kp_u_Today_is_s_and_tracking_days_are __pyx_string_tab[631]
#define __pyx_kp_u_Token_is_Expired __pyx_string_tab[632]
#define __pyx_kp_u_Traceback_s __pyx_string_tab[633]
#define __pyx_kp_u_Tracker_Activity_calculation_sk __pyx_string_tab[634]
#define __pyx_kp_u_Tracker_Activity_monitoring_pau __pyx_string_tab[635]
#define __pyx_kp_u_Tracker_Persistent_status_is_st __pyx_string_tab[636]
#define __pyx_kp_u_Tracker_Persistent_status_is_st_2 __pyx_string_tab[637]
#define __pyx_kp_u_Tracker_Tracking_RESUMED_activi __pyx_string_tab[638]
#define __pyx_kp_u_Tracker_Tracking_is_STOPPED_wai __pyx_string_tab[639]
#define __pyx_kp_u_Tracker_Tracking_is_disabled_st __pyx_string_tab[640]
#define __pyx_kp_u_Tracker_Tracking_stopped_via_We __pyx_string_tab[641]
#define __pyx_kp_u_Tracker_WebSocket_connection_is __pyx_string_tab[642]
#define __pyx_kp_u_Tracking_will_continue_as_normal __pyx_string_tab[643]
#define __pyx_kp_u_Trimmed_interval_start_after_bre __pyx_string_tab[644]
#define __pyx_kp_u_Trimmed_interval_start_before_sa __pyx_string_tab[645]
#define __pyx_kp_u_Trimmed_open_partial_for_project __pyx_string_tab[646]
#define __pyx_kp_u_Tuple_datetime_datetime_datetime __pyx_string_tab[647]
#define __pyx_kp_u_Unexpected_error_creating_screen __pyx_string_tab[648]
#define __pyx_kp_u_Unexpected_error_creating_screen_2 __pyx_string_tab[649]
#define __pyx_kp_u_Unexpected_error_decrypting_key __pyx_string_tab[650]
#define __pyx_kp_u_Unexpected_error_during_screensh __pyx_string_tab[651]
#define __pyx_kp_u_Unexpected_error_during_screensh_2 __pyx_string_tab[652]
#define __pyx_kp_u_Unexpected_error_in_decryption_s __pyx_string_tab[653]
#define __pyx_kp_u_Unexpected_error_uploading_scree __pyx_string_tab[654]
#define __pyx_kp_u_Unicode_decode_error_in_decrypti __pyx_string_tab[655]
#define __pyx_kp_u_Unsent_interval_id_s_start_time __pyx_string_tab[656]
#define __pyx_kp_u_Updated_idle_time_limit_in_secon __pyx_string_tab[657]
#define __pyx_kp_u_Uploaded_from_s __pyx_string_tab[658]
#define __pyx_kp_u_Uploaded_to_s __pyx_string_tab[659]
#define __pyx_kp_u_Uploading_file_to_S3_s_s __pyx_string_tab[660]
#define __pyx_kp_u_Uploading_to_AWS_bucket __pyx_string_tab[661]
#define __pyx_kp_u_Uploading_to_Hetzner_bucket __pyx_string_tab[662]
#define __pyx_kp_u_User_checked_keep_box_idle_inter __pyx_string_tab[663]
#define __pyx_kp_u_User_entity_is_None_stopping_tra __pyx_string_tab[664]
#define __pyx_kp_u_User_entity_s __pyx_string_tab[665]
#define __pyx_kp_u_Using_fallback_activity_level_ze __pyx_string_tab[666]
#define __pyx_kp_u_Using_last_interval_end_time_as __pyx_string_tab[667]
#define __pyx_kp_u_Using_pinned_activity_log_sessio __pyx_string_tab[668]
#define __pyx_kp_u_Using_project_id_s_task_id_s_for __pyx_string_tab[669]
#define __pyx_kp_u_Using_segment_start_project_task __pyx_string_tab[670]
#define __pyx_kp_u_Using_user_entity_with_org_id_s __pyx_string_tab[671]
#define __pyx_kp_u_Validation_error_with_screenshot __pyx_string_tab[672]
#define __pyx_kp_u_Value_error_in_decryption_s __pyx_string_tab[673]
#define __pyx_kp_u_Verified_all_current_session_int __pyx_string_tab[674]
#define __pyx_kp_u_Verified_interval_updates_are_co __pyx_string_tab[675]
#define __pyx_kp_u_Verified_last_interval_in_datab __pyx_string_tab[676]
#define __pyx_kp_u_Verified_last_interval_update_is __pyx_string_tab[677]
#define __pyx_kp_u_WAKE_Error_checking_updating_S3 __pyx_string_tab[678]
#define __pyx_kp_u_WAKE_Error_handling_S3_bucket_u __pyx_string_tab[679]
#define __pyx_kp_u_WAKE_New_day_detected_last_s_cu __pyx_string_tab[680]
#define __pyx_kp_u_WAKE_No_user_entity_available_f __pyx_string_tab[681]
#define __pyx_kp_u_WAKE_Registered_S3_bucket_updat __pyx_string_tab[682]
#define __pyx_kp_u_WAKE_Registered_session_counter __pyx_string_tab[683]
#define __pyx_kp_u_WAKE_Registered_wake_callback_f __pyx_string_tab[684]
#define __pyx_kp_u_WAKE_STS_credentials_expired_re __pyx_string_tab[685]
#define __pyx_kp_u_WAKE_Same_day_last_s_current_s __pyx_string_tab[686]
#define __pyx_kp_u_WAKE_System_wake_counter_will_i __pyx_string_tab[687]
#define __pyx_kp_u_WARNING_Break_interval_being_sa __pyx_string_tab[688]
#define __pyx_kp_u_Waiting_1_5_seconds_for_database __pyx_string_tab[689]
#define __pyx_kp_u_Waiting_1_second_for_database_co __pyx_string_tab[690]
#define __pyx_kp_u_Weekly_Limit_s __pyx_string_tab[691]
#define __pyx_kp_u_Windows_Break_Fix_Break_has_sta __pyx_string_tab[692]
#define __pyx_kp_u_Windows_Break_Fix_Interval_ends __pyx_string_tab[693]
#define __pyx_kp_u_Windows_Break_Fix_Interval_star __pyx_string_tab[694]
#define __pyx_kp_u_Windows_Break_Fix_Interval_star_2 __pyx_string_tab[695]
#define __pyx_kp_u_Windows_Break_Fix_Last_interval __pyx_string_tab[696]
#define __pyx_kp_u_Windows_Break_Fix_Part_from_s_t __pyx_string_tab[697]
#define __pyx_kp_u_Windows_Break_Fix_interval_end __pyx_string_tab[698]
#define __pyx_kp_u_Work_segment_stop_for_payload_s __pyx_string_tab[699]
#define __pyx_kp_u_Worked_This_Week_s __pyx_string_tab[700]
#define __pyx_kp_u_Worked_Today_s __pyx_string_tab[701]
#define __pyx_kp_u_Wrong_Timestamp __pyx_string_tab[702]
#define __pyx_kp_u_Y_m_d_H_M_S __pyx_string_tab[703]
#define __pyx_kp_u_Y_m_d_H_M_S_2 __pyx_string_tab[704]
#define __pyx_kp_u_Y_m_d__H_M_S __pyx_string_tab[705]
#define __pyx_kp_u_Your_account_is_currently_inacti __pyx_string_tab[706]
#define __pyx_kp_u_Your_system_has_been_idle_for_60 __pyx_string_tab[707]
#define __pyx_kp_u_Your_system_timezone_does_not_ma __pyx_string_tab[708]
#define __pyx_kp_u_Your_system_timezone_must_match __pyx_string_tab[709]
#define __pyx_kp_u_Your_system_was_in_sleep_for_mor __pyx_string_tab[710]
#define __pyx_kp_u__10 __pyx_string_tab[711]
#define __pyx_kp_u__11 __pyx_string_tab[712]
#define __pyx_kp_u__12 __pyx_string_tab[713]
#define __pyx_kp_u__13 __pyx_string_tab[714]
#define __pyx_kp_u__14 __pyx_string_tab[715]
#define __pyx_kp_u__15 __pyx_string_tab[716]
#define __pyx_kp_u__2 __pyx_string_tab[717]
#define __pyx_kp_u__3 __pyx_string_tab[718]
#define __pyx_kp_u__4 __pyx_string_tab[719]
#define __pyx_kp_u__5 __pyx_string_tab[720]
#define __pyx_kp_u__6 __pyx_string_tab[721]
#define __pyx_kp_u__8 __pyx_string_tab[722]
#define __pyx_kp_u__9 __pyx_string_tab[723]
#define __pyx_kp_u_add_note __pyx_string_tab[724]
#define __pyx_kp_u_appVersion_s __pyx_string_tab[725]
#define __pyx_kp_u_application_json __pyx_string_tab[726]
#define __pyx_kp_u_break_stop_event_was_called_ss_a __pyx_string_tab[727]
#define __pyx_kp_u_c __pyx_string_tab[728]
#define __pyx_kp_u_current_Project_id_s_current_tas __pyx_string_tab[729]
#define __pyx_kp_u_current_break_id_s_current_is_br __pyx_string_tab[730]
#define __pyx_kp_u_database __pyx_string_tab[731]
#define __pyx_kp_u_datetime_datetime __pyx_string_tab[732]
#define __pyx_kp_u_db __pyx_string_tab[733]
#define __pyx_kp_u_disable __pyx_string_tab[734]
#define __pyx_kp_u_enable __pyx_string_tab[735]
#define __pyx_kp_u_fully_covered_by_existing_inter __pyx_string_tab[736]
#define __pyx_kp_u_gc __pyx_string_tab[737]
#define __pyx_kp_u_has_on_demand_screenshot_s __pyx_string_tab[738]
#define __pyx_kp_u_http __pyx_string_tab[739]
#define __pyx_kp_u_https __pyx_string_tab[740]
#define __pyx_kp_u_isenabled __pyx_string_tab[741]
#define __pyx_kp_u_last_api_call_COMPLETED_SUCCESS __pyx_string_tab[742]
#define __pyx_kp_u_last_api_call_FAILED_s __pyx_string_tab[743]
#define __pyx_kp_u_last_api_call_STARTED_keep_idle __pyx_string_tab[744]
#define __pyx_kp_u_logs_txt __pyx_string_tab[745]
#define __pyx_kp_u_logsy __pyx_string_tab[746]
#define __pyx_kp_u_macOS_Apps_only_mode_Using_brow __pyx_string_tab[747]
#define __pyx_kp_u_notes __pyx_string_tab[748]
#define __pyx_kp_u_org_api_timezone_is_None_after_u __pyx_string_tab[749]
#define __pyx_kp_u_org_id_set_to_s_for_ScreenshotCo __pyx_string_tab[750]
#define __pyx_kp_u_overlaps_existing_intervals_fil __pyx_string_tab[751]
#define __pyx_kp_u_push_update_tracking_duration_t __pyx_string_tab[752]
#define __pyx_kp_u_s __pyx_string_tab[753]
#define __pyx_kp_u_s_LIMIT_EXCEEDED __pyx_string_tab[754]
#define __pyx_kp_u_s_period_duration __pyx_string_tab[755]
#define __pyx_kp_u_s_s __pyx_string_tab[756]
#define __pyx_kp_u_save_last_active_app_as_true_bec __pyx_string_tab[757]
#define __pyx_kp_u_screenshots_2 __pyx_string_tab[758]
#define __pyx_kp_u_screenshots_3 __pyx_string_tab[759]
#define __pyx_kp_u_start_date_is_None_cannot_create __pyx_string_tab[760]
#define __pyx_kp_u_start_date_not_available_cannot __pyx_string_tab[761]
#define __pyx_kp_u_start_date_s_end_date_s_adjustin __pyx_string_tab[762]
#define __pyx_kp_u_start_status_activity_called_wit __pyx_string_tab[763]
#define __pyx_kp_u_stop_event_called_keep_idle_tim __pyx_string_tab[764]
#define __pyx_kp_u_stop_event_completed_last_api_c __pyx_string_tab[765]
#define __pyx_kp_u_sync_activity_immediately_calle __pyx_string_tab[766]
#define __pyx_kp_u_sync_activity_immediately_compl __pyx_string_tab[767]
#define __pyx_kp_u_u200B_u200D_uFEFF __pyx_string_tab[768]
#define __pyx_kp_u_unchanged __pyx_string_tab[769]
#define __pyx_kp_u_update_interval_org_settings_ss __pyx_string_tab[770]
#define __pyx_kp_u_updated_Screenshot_Controller_s __pyx_string_tab[771]
#define __pyx_kp_u_updated_tracking_scenerio_fixed __pyx_string_tab[772]
#define __pyx_kp_u_updated_tracking_scenerio_from_d __pyx_string_tab[773]
#define __pyx_kp_u_user_main_status_activity_saved __pyx_string_tab[774]
#define __pyx_kp_u_workstatus __pyx_string_tab[775]
#define __pyx_kp_u_workstatus_2 __pyx_string_tab[776]
#define __pyx_kp_u_ws_monitor_db __pyx_string_tab[777]
#define __pyx_kp_u_ws_package_controllers_activity_8 __pyx_string_tab[778]
#define __pyx_n_u_ACTIVITY_INTERVAL __pyx_string_tab[779]
#define __pyx_n_u_ACTIVITY_PERCENTAGE __pyx_string_tab[780]
#define __pyx_n_u_APIError __pyx_string_tab[781]
#define __pyx_n_u_APIRequest __pyx_string_tab[782]
#define __pyx_n_u_Accept __pyx_string_tab[783]
#define __pyx_n_u_AccessDenied __pyx_string_tab[784]
#define __pyx_n_u_ActivityBreakMixin __pyx_string_tab[785]
#define __pyx_n_u_ActivityController __pyx_string_tab[786]
#define __pyx_n_u_ActivityController___init __pyx_string_tab[787]
#define __pyx_n_u_ActivityController___start_devic __pyx_string_tab[788]
#define __pyx_n_u_ActivityController___start_devic_2 __pyx_string_tab[789]
#define __pyx_n_u_ActivityController___start_devic_3 __pyx_string_tab[790]
#define __pyx_n_u_ActivityController___start_devic_4 __pyx_string_tab[791]
#define __pyx_n_u_ActivityController___start_devic_5 __pyx_string_tab[792]
#define __pyx_n_u_ActivityController___start_devic_6 __pyx_string_tab[793]
#define __pyx_n_u_ActivityController___start_devic_7 __pyx_string_tab[794]
#define __pyx_n_u_ActivityController___start_devic_8 __pyx_string_tab[795]
#define __pyx_n_u_ActivityController___start_minut __pyx_string_tab[796]
#define __pyx_n_u_ActivityController__align_to_int __pyx_string_tab[797]
#define __pyx_n_u_ActivityController__apply_org_ti __pyx_string_tab[798]
#define __pyx_n_u_ActivityController__break_start __pyx_string_tab[799]
#define __pyx_n_u_ActivityController__calculate_ga __pyx_string_tab[800]
#define __pyx_n_u_ActivityController__check_and_ha __pyx_string_tab[801]
#define __pyx_n_u_ActivityController__check_and_ha_2 __pyx_string_tab[802]
#define __pyx_n_u_ActivityController__check_and_up __pyx_string_tab[803]
#define __pyx_n_u_ActivityController__check_and_up_2 __pyx_string_tab[804]
#define __pyx_n_u_ActivityController__create_segme __pyx_string_tab[805]
#define __pyx_n_u_ActivityController__determine_sl __pyx_string_tab[806]
#define __pyx_n_u_ActivityController__finalize_wor __pyx_string_tab[807]
#define __pyx_n_u_ActivityController__get_activity __pyx_string_tab[808]
#define __pyx_n_u_ActivityController__get_electron __pyx_string_tab[809]
#define __pyx_n_u_ActivityController__handle_wake __pyx_string_tab[810]
#define __pyx_n_u_ActivityController__handle_wake_2 __pyx_string_tab[811]
#define __pyx_n_u_ActivityController__has_any_acti __pyx_string_tab[812]
#define __pyx_n_u_ActivityController__has_zero_act __pyx_string_tab[813]
#define __pyx_n_u_ActivityController__idle_reassig __pyx_string_tab[814]
#define __pyx_n_u_ActivityController__is_app_monit __pyx_string_tab[815]
#define __pyx_n_u_ActivityController__is_system_sl __pyx_string_tab[816]
#define __pyx_n_u_ActivityController__last_api_cal __pyx_string_tab[817]
#define __pyx_n_u_ActivityController__last_api_cal_2 __pyx_string_tab[818]
#define __pyx_n_u_ActivityController__last_api_cal_3 __pyx_string_tab[819]
#define __pyx_n_u_ActivityController__last_api_cal_4 __pyx_string_tab[820]
#define __pyx_n_u_ActivityController__load_org_set __pyx_string_tab[821]
#define __pyx_n_u_ActivityController__log_session __pyx_string_tab[822]
#define __pyx_n_u_ActivityController__mark_idle_in __pyx_string_tab[823]
#define __pyx_n_u_ActivityController__normalize_hh __pyx_string_tab[824]
#define __pyx_n_u_ActivityController__parse_fixed __pyx_string_tab[825]
#define __pyx_n_u_ActivityController__push_activit __pyx_string_tab[826]
#define __pyx_n_u_ActivityController__s3_credentia __pyx_string_tab[827]
#define __pyx_n_u_ActivityController__save_note_to __pyx_string_tab[828]
#define __pyx_n_u_ActivityController__save_note_to_2 __pyx_string_tab[829]
#define __pyx_n_u_ActivityController__seconds_unti __pyx_string_tab[830]
#define __pyx_n_u_ActivityController__send_active __pyx_string_tab[831]
#define __pyx_n_u_ActivityController__send_file_up __pyx_string_tab[832]
#define __pyx_n_u_ActivityController__send_file_up_2 __pyx_string_tab[833]
#define __pyx_n_u_ActivityController__send_subscri __pyx_string_tab[834]
#define __pyx_n_u_ActivityController__send_to_elec __pyx_string_tab[835]
#define __pyx_n_u_ActivityController__should_pause __pyx_string_tab[836]
#define __pyx_n_u_ActivityController__should_pause_2 __pyx_string_tab[837]
#define __pyx_n_u_ActivityController__should_start __pyx_string_tab[838]
#define __pyx_n_u_ActivityController__start_devic __pyx_string_tab[839]
#define __pyx_n_u_ActivityController__start_minut __pyx_string_tab[840]
#define __pyx_n_u_ActivityController__trim_open_pa __pyx_string_tab[841]
#define __pyx_n_u_ActivityController__try_finalize __pyx_string_tab[842]
#define __pyx_n_u_ActivityController__upload_file __pyx_string_tab[843]
#define __pyx_n_u_ActivityController__verify_user __pyx_string_tab[844]
#define __pyx_n_u_ActivityController_arise_idle_po __pyx_string_tab[845]
#define __pyx_n_u_ActivityController_boundary_time __pyx_string_tab[846]
#define __pyx_n_u_ActivityController_check_idle_po __pyx_string_tab[847]
#define __pyx_n_u_ActivityController_check_memory __pyx_string_tab[848]
#define __pyx_n_u_ActivityController_db_to_server __pyx_string_tab[849]
#define __pyx_n_u_ActivityController_decrypt __pyx_string_tab[850]
#define __pyx_n_u_ActivityController_delete_old_da __pyx_string_tab[851]
#define __pyx_n_u_ActivityController_empty_interva __pyx_string_tab[852]
#define __pyx_n_u_ActivityController_empty_interva_2 __pyx_string_tab[853]
#define __pyx_n_u_ActivityController_ensure_s3_cre __pyx_string_tab[854]
#define __pyx_n_u_ActivityController_forward_ss __pyx_string_tab[855]
#define __pyx_n_u_ActivityController_getCurrentSlo __pyx_string_tab[856]
#define __pyx_n_u_ActivityController_getStartingSl __pyx_string_tab[857]
#define __pyx_n_u_ActivityController_get_activity __pyx_string_tab[858]
#define __pyx_n_u_ActivityController_get_bucket_in __pyx_string_tab[859]
#define __pyx_n_u_ActivityController_get_day_start __pyx_string_tab[860]
#define __pyx_n_u_ActivityController_get_os_type_c __pyx_string_tab[861]
#define __pyx_n_u_ActivityController_getting_unsen __pyx_string_tab[862]
#define __pyx_n_u_ActivityController_group_interva __pyx_string_tab[863]
#define __pyx_n_u_ActivityController_group_interva_2 __pyx_string_tab[864]
#define __pyx_n_u_ActivityController_group_interva_3 __pyx_string_tab[865]
#define __pyx_n_u_ActivityController_handle_idle_p __pyx_string_tab[866]
#define __pyx_n_u_ActivityController_handle_idle_p_2 __pyx_string_tab[867]
#define __pyx_n_u_ActivityController_handle_s3_tim __pyx_string_tab[868]
#define __pyx_n_u_ActivityController_has_recent_in __pyx_string_tab[869]
#define __pyx_n_u_ActivityController_increment_ses __pyx_string_tab[870]
#define __pyx_n_u_ActivityController_inrange __pyx_string_tab[871]
#define __pyx_n_u_ActivityController_is_browser __pyx_string_tab[872]
#define __pyx_n_u_ActivityController_is_browser_lo __pyx_string_tab[873]
#define __pyx_n_u_ActivityController_is_idle_inter __pyx_string_tab[874]
#define __pyx_n_u_ActivityController_is_link __pyx_string_tab[875]
#define __pyx_n_u_ActivityController_last_api_call __pyx_string_tab[876]
#define __pyx_n_u_ActivityController_log_system_re __pyx_string_tab[877]
#define __pyx_n_u_ActivityController_midnight __pyx_string_tab[878]
#define __pyx_n_u_ActivityController_process_inter __pyx_string_tab[879]
#define __pyx_n_u_ActivityController_process_inter_2 __pyx_string_tab[880]
#define __pyx_n_u_ActivityController_process_inter_3 __pyx_string_tab[881]
#define __pyx_n_u_ActivityController_sending_unsen __pyx_string_tab[882]
#define __pyx_n_u_ActivityController_set_local_tim __pyx_string_tab[883]
#define __pyx_n_u_ActivityController_set_project_t __pyx_string_tab[884]
#define __pyx_n_u_ActivityController_should_skip_c __pyx_string_tab[885]
#define __pyx_n_u_ActivityController_ss __pyx_string_tab[886]
#define __pyx_n_u_ActivityController_start_device __pyx_string_tab[887]
#define __pyx_n_u_ActivityController_start_screens __pyx_string_tab[888]
#define __pyx_n_u_ActivityController_start_status __pyx_string_tab[889]
#define __pyx_n_u_ActivityController_stop_event __pyx_string_tab[890]
#define __pyx_n_u_ActivityController_sync_activity __pyx_string_tab[891]
#define __pyx_n_u_ActivityController_update_interv __pyx_string_tab[892]
#define __pyx_n_u_ActivityController_update_tracki __pyx_string_tab[893]
#define __pyx_n_u_ActivityIdleMixin __pyx_string_tab[894]
#define __pyx_n_u_ActivityInterval __pyx_string_tab[895]
#define __pyx_n_u_ActivityIntervalMixin __pyx_string_tab[896]
#define __pyx_n_u_ActivityManager __pyx_string_tab[897]
#define __pyx_n_u_ActivityMonitor __pyx_string_tab[898]
#define __pyx_n_u_ActivityMonitoringError __pyx_string_tab[899]
#define __pyx_n_u_ActivityPercentageEntity __pyx_string_tab[900]
#define __pyx_n_u_ActivityPushMixin __pyx_string_tab[901]
#define __pyx_n_u_ActivityScreenshotMixin __pyx_string_tab[902]
#define __pyx_n_u_ActivityService __pyx_string_tab[903]
#define __pyx_n_u_ActivityTimezoneMixin __pyx_string_tab[904]
#define __pyx_n_u_Application __pyx_string_tab[905]
#define __pyx_n_u_Appmonitor __pyx_string_tab[906]
#define __pyx_n_u_Authorization __pyx_string_tab[907]
#define __pyx_n_u_BULK_UPDATE __pyx_string_tab[908]
#define __pyx_n_u_CancelledError __pyx_string_tab[909]
#define __pyx_n_u_Chrome __pyx_string_tab[910]
#define __pyx_n_u_DB_OPERATION_TIMEOUT __pyx_string_tab[911]
#define __pyx_n_u_DEVICE_LISTENER_DEAD __pyx_string_tab[912]
#define __pyx_n_u_DEVNULL __pyx_string_tab[913]
#define __pyx_n_u_Darwin __pyx_string_tab[914]
#define __pyx_n_u_DataManager __pyx_string_tab[915]
#define __pyx_n_u_DeviceID __pyx_string_tab[916]
#define __pyx_n_u_DeviceListener __pyx_string_tab[917]
#define __pyx_n_u_Entry __pyx_string_tab[918]
#define __pyx_n_u_ErrorCode __pyx_string_tab[919]
#define __pyx_n_u_FileSystemError __pyx_string_tab[920]
#define __pyx_n_u_Firefox __pyx_string_tab[921]
#define __pyx_n_u_FixedMode __pyx_string_tab[922]
#define __pyx_n_u_FixedService __pyx_string_tab[923]
#define __pyx_n_u_Flag __pyx_string_tab[924]
#define __pyx_n_u_Fri __pyx_string_tab[925]
#define __pyx_n_u_GetForegroundWindow __pyx_string_tab[926]
#define __pyx_n_u_HIDIdleTime __pyx_string_tab[927]
#define __pyx_n_u_IOHIDSystem __pyx_string_tab[928]
#define __pyx_n_u_JPEG __pyx_string_tab[929]
#define __pyx_n_u_Linux __pyx_string_tab[930]
#define __pyx_n_u_List __pyx_string_tab[931]
#define __pyx_n_u_LocationEntity __pyx_string_tab[932]
#define __pyx_n_u_LogWriter __pyx_string_tab[933]
#define __pyx_n_u_MAX_API_PAUSE_CYCLES __pyx_string_tab[934]
#define __pyx_n_u_MAX_NOTE_LENGTH __pyx_string_tab[935]
#define __pyx_n_u_Mac __pyx_string_tab[936]
#define __pyx_n_u_ModeEntity __pyx_string_tab[937]
#define __pyx_n_u_Mon __pyx_string_tab[938]
#define __pyx_n_u_Msedge __pyx_string_tab[939]
#define __pyx_n_u_NFKD __pyx_string_tab[940]
#define __pyx_n_u_NOTES __pyx_string_tab[941]
#define __pyx_n_u_NOT_SET __pyx_string_tab[942]
#define __pyx_n_u_NamedTemporaryFile __pyx_string_tab[943]
#define __pyx_n_u_NetworkError __pyx_string_tab[944]
#define __pyx_n_u_None __pyx_string_tab[945]
#define __pyx_n_u_Notes __pyx_string_tab[946]
#define __pyx_n_u_Opera __pyx_string_tab[947]
#define __pyx_n_u_OptimizedWindowsTimeMonitor __pyx_string_tab[948]
#define __pyx_n_u_Optional __pyx_string_tab[949]
#define __pyx_n_u_OrgConfigurations __pyx_string_tab[950]
#define __pyx_n_u_OrgEntity __pyx_string_tab[951]
#define __pyx_n_u_OrgID __pyx_string_tab[952]
#define __pyx_n_u_POST __pyx_string_tab[953]
#define __pyx_n_u_PUSH_LOOP_FAILED __pyx_string_tab[954]
#define __pyx_n_u_Path __pyx_string_tab[955]
#define __pyx_n_u_Process __pyx_string_tab[956]
#define __pyx_n_u_Pyx_PyDict_NextRef __pyx_string_tab[957]
#define __pyx_n_u_RLock __pyx_string_tab[958]
#define __pyx_n_u_R_OK __pyx_string_tab[959]
#define __pyx_n_u_RequestException __pyx_string_tab[960]
#define __pyx_n_u_RequestTimeTooSkewed __pyx_string_tab[961]
#define __pyx_n_u_S3BucketEntity __pyx_string_tab[962]
#define __pyx_n_u_S3_TIME_TAMPERING __pyx_string_tab[963]
#define __pyx_n_u_S3sync __pyx_string_tab[964]
#define __pyx_n_u_SDToken __pyx_string_tab[965]
#define __pyx_n_u_STATUS_LOOP_FAILED __pyx_string_tab[966]
#define __pyx_n_u_Safari __pyx_string_tab[967]
#define __pyx_n_u_Sat __pyx_string_tab[968]
#define __pyx_n_u_Screenshot __pyx_string_tab[969]
#define __pyx_n_u_ScreenshotController __pyx_string_tab[970]
#define __pyx_n_u_ScreenshotEntity __pyx_string_tab[971]
#define __pyx_n_u_ScreenshotError __pyx_string_tab[972]
#define __pyx_n_u_ScreenshotManager __pyx_string_tab[973]
#define __pyx_n_u_Screenshots __pyx_string_tab[974]
#define __pyx_n_u_ServerController __pyx_string_tab[975]
#define __pyx_n_u_StatusController __pyx_string_tab[976]
#define __pyx_n_u_Sun __pyx_string_tab[977]
#define __pyx_n_u_Sync __pyx_string_tab[978]
#define __pyx_n_u_System __pyx_string_tab[979]
#define __pyx_n_u_Thread __pyx_string_tab[980]
#define __pyx_n_u_Thu __pyx_string_tab[981]
#define __pyx_n_u_Timeout __pyx_string_tab[982]
#define __pyx_n_u_TimeoutError __pyx_string_tab[983]
#define __pyx_n_u_TimezoneManager __pyx_string_tab[984]
#define __pyx_n_u_Tue __pyx_string_tab[985]
#define __pyx_n_u_Tuple __pyx_string_tab[986]
#define __pyx_n_u_UPDATE_ACTIVITY_INTERVAL __pyx_string_tab[987]
#define __pyx_n_u_Unknown __pyx_string_tab[988]
#define __pyx_n_u_UserEntity __pyx_string_tab[989]
#define __pyx_n_u_UserID __pyx_string_tab[990]
#define __pyx_n_u_UserService __pyx_string_tab[991]
#define __pyx_n_u_ValidationError __pyx_string_tab[992]
#define __pyx_n_u_WOT __pyx_string_tab[993]
#define __pyx_n_u_WOT2 __pyx_string_tab[994]
#define __pyx_n_u_Wed __pyx_string_tab[995]
#define __pyx_n_u_WeeklyLimitNotification __pyx_string_tab[996]
#define __pyx_n_u_Window __pyx_string_tab[997]
#define __pyx_n_u_Windows __pyx_string_tab[998]
#define __pyx_n_u_WriteOperationType __pyx_string_tab[999]
#define __pyx_n_u__7 __pyx_string_tab[1000]
#define __pyx_n_u_a __pyx_string_tab[1001]
#define __pyx_n_u_access __pyx_string_tab[1002]
#define __pyx_n_u_action __pyx_string_tab[1003]
#define __pyx_n_u_active __pyx_string_tab[1004]
#define __pyx_n_u_active_app __pyx_string_tab[1005]
#define __pyx_n_u_active_app_change __pyx_string_tab[1006]
#define __pyx_n_u_active_app_ui_task __pyx_string_tab[1007]
#define __pyx_n_u_active_app_ui_task_done_callback __pyx_string_tab[1008]
#define __pyx_n_u_active_app_url __pyx_string_tab[1009]
#define __pyx_n_u_active_windows __pyx_string_tab[1010]
#define __pyx_n_u_activity __pyx_string_tab[1011]
#define __pyx_n_u_activityLevel __pyx_string_tab[1012]
#define __pyx_n_u_activity_count __pyx_string_tab[1013]
#define __pyx_n_u_activity_error __pyx_string_tab[1014]
#define __pyx_n_u_activity_interval __pyx_string_tab[1015]
#define __pyx_n_u_activity_interval_id __pyx_string_tab[1016]
#define __pyx_n_u_activity_level __pyx_string_tab[1017]
#define __pyx_n_u_activity_level_for_gap_fill __pyx_string_tab[1018]
#define __pyx_n_u_activity_log_payload_start __pyx_string_tab[1019]
#define __pyx_n_u_activity_manager __pyx_string_tab[1020]
#define __pyx_n_u_activity_percentage __pyx_string_tab[1021]
#define __pyx_n_u_activity_percentage_end __pyx_string_tab[1022]
#define __pyx_n_u_activity_percentage_end_seconds __pyx_string_tab[1023]
#define __pyx_n_u_activity_percentage_entity __pyx_string_tab[1024]
#define __pyx_n_u_activity_percentage_key __pyx_string_tab[1025]
#define __pyx_n_u_activity_percentage_manager __pyx_string_tab[1026]
#define __pyx_n_u_activity_percentage_service __pyx_string_tab[1027]
#define __pyx_n_u_activity_percentage_start __pyx_string_tab[1028]
#define __pyx_n_u_activity_percentage_start_second __pyx_string_tab[1029]
#define __pyx_n_u_activity_queue_size __pyx_string_tab[1030]
#define __pyx_n_u_activity_service __pyx_string_tab[1031]
#define __pyx_n_u_activity_session_wake __pyx_string_tab[1032]
#define __pyx_n_u_add __pyx_string_tab[1033]
#define __pyx_n_u_add_done_callback __pyx_string_tab[1034]
#define __pyx_n_u_aenter __pyx_string_tab[1035]
#define __pyx_n_u_aexit __pyx_string_tab[1036]
#define __pyx_n_u_align_stop __pyx_string_tab[1037]
#define __pyx_n_u_align_to_interval_boundary __pyx_string_tab[1038]
#define __pyx_n_u_aligned_time __pyx_string_tab[1039]
#define __pyx_n_u_all __pyx_string_tab[1040]
#define __pyx_n_u_all_intervals __pyx_string_tab[1041]
#define __pyx_n_u_all_query __pyx_string_tab[1042]
#define __pyx_n_u_all_result __pyx_string_tab[1043]
#define __pyx_n_u_already_in_list __pyx_string_tab[1044]
#define __pyx_n_u_and __pyx_string_tab[1045]
#define __pyx_n_u_annotate __pyx_string_tab[1046]
#define __pyx_n_u_ans_array __pyx_string_tab[1047]
#define __pyx_n_u_api_call_made __pyx_string_tab[1048]
#define __pyx_n_u_api_name_from_url __pyx_string_tab[1049]
#define __pyx_n_u_api_pause_active __pyx_string_tab[1050]
#define __pyx_n_u_api_pause_cycles __pyx_string_tab[1051]
#define __pyx_n_u_api_response __pyx_string_tab[1052]
#define __pyx_n_u_appAndUrls __pyx_string_tab[1053]
#define __pyx_n_u_appVersion __pyx_string_tab[1054]
#define __pyx_n_u_app_and_urls __pyx_string_tab[1055]
#define __pyx_n_u_app_data __pyx_string_tab[1056]
#define __pyx_n_u_app_display_name __pyx_string_tab[1057]
#define __pyx_n_u_app_icon __pyx_string_tab[1058]
#define __pyx_n_u_app_listener __pyx_string_tab[1059]
#define __pyx_n_u_app_monitor_interval_seconds __pyx_string_tab[1060]
#define __pyx_n_u_app_monitor_time __pyx_string_tab[1061]
#define __pyx_n_u_app_name __pyx_string_tab[1062]
#define __pyx_n_u_app_path __pyx_string_tab[1063]
#define __pyx_n_u_appandurlstatus __pyx_string_tab[1064]
#define __pyx_n_u_append __pyx_string_tab[1065]
#define __pyx_n_u_application_activity_log_url __pyx_string_tab[1066]
#define __pyx_n_u_application_org_config_url __pyx_string_tab[1067]
#define __pyx_n_u_application_restart __pyx_string_tab[1068]
#define __pyx_n_u_apply_desktop_key __pyx_string_tab[1069]
#define __pyx_n_u_apply_org_timezone_preference __pyx_string_tab[1070]
#define __pyx_n_u_apply_resolving_slot_save_polic __pyx_string_tab[1071]
#define __pyx_n_u_arise_idle_popup __pyx_string_tab[1072]
#define __pyx_n_u_asc __pyx_string_tab[1073]
#define __pyx_n_u_ascii __pyx_string_tab[1074]
#define __pyx_n_u_async_session __pyx_string_tab[1075]
#define __pyx_n_u_asyncio __pyx_string_tab[1076]
#define __pyx_n_u_asyncio_coroutines __pyx_string_tab[1077]
#define __pyx_n_u_at_least_one_batch_successful __pyx_string_tab[1078]
#define __pyx_n_u_attempt __pyx_string_tab[1079]
#define __pyx_n_u_average __pyx_string_tab[1080]
#define __pyx_n_u_average_activity __pyx_string_tab[1081]
#define __pyx_n_u_average_percentage __pyx_string_tab[1082]
#define __pyx_n_u_await __pyx_string_tab[1083]
#define __pyx_n_u_b __pyx_string_tab[1084]
#define __pyx_n_u_b64decode __pyx_string_tab[1085]
#define __pyx_n_u_background_tasks __pyx_string_tab[1086]
#define __pyx_n_u_base64 __pyx_string_tab[1087]
#define __pyx_n_u_basename __pyx_string_tab[1088]
#define __pyx_n_u_batch_intervals __pyx_string_tab[1089]
#define __pyx_n_u_blur __pyx_string_tab[1090]
#define __pyx_n_u_blur_intensity __pyx_string_tab[1091]
#define __pyx_n_u_bool __pyx_string_tab[1092]
#define __pyx_n_u_boundary_time __pyx_string_tab[1093]
#define __pyx_n_u_break_error __pyx_string_tab[1094]
#define __pyx_n_u_break_id __pyx_string_tab[1095]
#define __pyx_n_u_break_interval_overlaps __pyx_string_tab[1096]
#define __pyx_n_u_break_intervals __pyx_string_tab[1097]
#define __pyx_n_u_break_intervals_after_trim __pyx_string_tab[1098]
#define __pyx_n_u_break_monitoring_logged __pyx_string_tab[1099]
#define __pyx_n_u_break_project_id __pyx_string_tab[1100]
#define __pyx_n_u_break_start_after_work_stop __pyx_string_tab[1101]
#define __pyx_n_u_break_start_time __pyx_string_tab[1102]
#define __pyx_n_u_break_stop_attr __pyx_string_tab[1103]
#define __pyx_n_u_break_stop_event __pyx_string_tab[1104]
#define __pyx_n_u_break_stop_time __pyx_string_tab[1105]
#define __pyx_n_u_break_stop_time_attr __pyx_string_tab[1106]
#define __pyx_n_u_break_task_id __pyx_string_tab[1107]
#define __pyx_n_u_browser __pyx_string_tab[1108]
#define __pyx_n_u_browsers __pyx_string_tab[1109]
#define __pyx_n_u_bucket __pyx_string_tab[1110]
#define __pyx_n_u_bump_counter_on_next_monitoring __pyx_string_tab[1111]
#define __pyx_n_u_c_2 __pyx_string_tab[1112]
#define __pyx_n_u_cached_stealth_response __pyx_string_tab[1113]
#define __pyx_n_u_calculate_and_store_rolling_aver __pyx_string_tab[1114]
#define __pyx_n_u_calculate_gap_seconds __pyx_string_tab[1115]
#define __pyx_n_u_cancel __pyx_string_tab[1116]
#define __pyx_n_u_candidate __pyx_string_tab[1117]
#define __pyx_n_u_category_fields __pyx_string_tab[1118]
#define __pyx_n_u_channel __pyx_string_tab[1119]
#define __pyx_n_u_check_and_handle_limits __pyx_string_tab[1120]
#define __pyx_n_u_check_and_update_s3_on_startup __pyx_string_tab[1121]
#define __pyx_n_u_check_and_update_s3_on_wake __pyx_string_tab[1122]
#define __pyx_n_u_check_existing_interval __pyx_string_tab[1123]
#define __pyx_n_u_check_idle_after_delay __pyx_string_tab[1124]
#define __pyx_n_u_check_idle_detection __pyx_string_tab[1125]
#define __pyx_n_u_check_idle_popup_timeout __pyx_string_tab[1126]
#define __pyx_n_u_check_limits_exceeded __pyx_string_tab[1127]
#define __pyx_n_u_check_memory_usage __pyx_string_tab[1128]
#define __pyx_n_u_check_output __pyx_string_tab[1129]
#define __pyx_n_u_check_query __pyx_string_tab[1130]
#define __pyx_n_u_check_stale_break __pyx_string_tab[1131]
#define __pyx_n_u_chunk_duration __pyx_string_tab[1132]
#define __pyx_n_u_chunks __pyx_string_tab[1133]
#define __pyx_n_u_class_getitem __pyx_string_tab[1134]
#define __pyx_n_u_cleaned_name __pyx_string_tab[1135]
#define __pyx_n_u_cleaned_name_lower __pyx_string_tab[1136]
#define __pyx_n_u_cleanup_enabled __pyx_string_tab[1137]
#define __pyx_n_u_cleanup_old_files __pyx_string_tab[1138]
#define __pyx_n_u_cline_in_traceback __pyx_string_tab[1139]
#define __pyx_n_u_close __pyx_string_tab[1140]
#define __pyx_n_u_close_time __pyx_string_tab[1141]
#define __pyx_n_u_code __pyx_string_tab[1142]
#define __pyx_n_u_collections __pyx_string_tab[1143]
#define __pyx_n_u_combine __pyx_string_tab[1144]
#define __pyx_n_u_commit __pyx_string_tab[1145]
#define __pyx_n_u_config __pyx_string_tab[1146]
#define __pyx_n_u_consecutive_idle_count __pyx_string_tab[1147]
#define __pyx_n_u_context __pyx_string_tab[1148]
#define __pyx_n_u_continue __pyx_string_tab[1149]
#define __pyx_n_u_copy __pyx_string_tab[1150]
#define __pyx_n_u_copy2 __pyx_string_tab[1151]
#define __pyx_n_u_copy_error __pyx_string_tab[1152]
#define __pyx_n_u_copy_size __pyx_string_tab[1153]
#define __pyx_n_u_counter __pyx_string_tab[1154]
#define __pyx_n_u_cpu_percent __pyx_string_tab[1155]
#define __pyx_n_u_create_segment_dummy_entry __pyx_string_tab[1156]
#define __pyx_n_u_create_task __pyx_string_tab[1157]
#define __pyx_n_u_creating_activity_percentages __pyx_string_tab[1158]
#define __pyx_n_u_creating_intervals __pyx_string_tab[1159]
#define __pyx_n_u_credentials_stale __pyx_string_tab[1160]
#define __pyx_n_u_current __pyx_string_tab[1161]
#define __pyx_n_u_current_active_app __pyx_string_tab[1162]
#define __pyx_n_u_current_active_app_icon __pyx_string_tab[1163]
#define __pyx_n_u_current_active_app_path __pyx_string_tab[1164]
#define __pyx_n_u_current_app_data __pyx_string_tab[1165]
#define __pyx_n_u_current_app_name __pyx_string_tab[1166]
#define __pyx_n_u_current_app_path __pyx_string_tab[1167]
#define __pyx_n_u_current_break_id __pyx_string_tab[1168]
#define __pyx_n_u_current_break_id_slot __pyx_string_tab[1169]
#define __pyx_n_u_current_counter __pyx_string_tab[1170]
#define __pyx_n_u_current_counter_held __pyx_string_tab[1171]
#define __pyx_n_u_current_counter_intervals __pyx_string_tab[1172]
#define __pyx_n_u_current_date __pyx_string_tab[1173]
#define __pyx_n_u_current_directory __pyx_string_tab[1174]
#define __pyx_n_u_current_interval __pyx_string_tab[1175]
#define __pyx_n_u_current_loop __pyx_string_tab[1176]
#define __pyx_n_u_current_project_id __pyx_string_tab[1177]
#define __pyx_n_u_current_segment_start_time __pyx_string_tab[1178]
#define __pyx_n_u_current_session __pyx_string_tab[1179]
#define __pyx_n_u_current_session_counter __pyx_string_tab[1180]
#define __pyx_n_u_current_session_counter_for_last __pyx_string_tab[1181]
#define __pyx_n_u_current_session_start_time __pyx_string_tab[1182]
#define __pyx_n_u_current_task_id __pyx_string_tab[1183]
#define __pyx_n_u_current_time __pyx_string_tab[1184]
#define __pyx_n_u_current_timestamp __pyx_string_tab[1185]
#define __pyx_n_u_cutoff __pyx_string_tab[1186]
#define __pyx_n_u_d __pyx_string_tab[1187]
#define __pyx_n_u_d2 __pyx_string_tab[1188]
#define __pyx_n_u_daemon __pyx_string_tab[1189]
#define __pyx_n_u_daily __pyx_string_tab[1190]
#define __pyx_n_u_daily_exceeded __pyx_string_tab[1191]
#define __pyx_n_u_daily_limit __pyx_string_tab[1192]
#define __pyx_n_u_darwin __pyx_string_tab[1193]
#define __pyx_n_u_data __pyx_string_tab[1194]
#define __pyx_n_u_data_manager __pyx_string_tab[1195]
#define __pyx_n_u_database_dir __pyx_string_tab[1196]
#define __pyx_n_u_database_server __pyx_string_tab[1197]
#define __pyx_n_u_date __pyx_string_tab[1198]
#define __pyx_n_u_datetime __pyx_string_tab[1199]
#define __pyx_n_u_datetime_error __pyx_string_tab[1200]
#define __pyx_n_u_datetime_matches __pyx_string_tab[1201]
#define __pyx_n_u_datetime_matches_final __pyx_string_tab[1202]
#define __pyx_n_u_datetime_mismatch __pyx_string_tab[1203]
#define __pyx_n_u_day __pyx_string_tab[1204]
#define __pyx_n_u_day_intervals __pyx_string_tab[1205]
#define __pyx_n_u_day_list __pyx_string_tab[1206]
#define __pyx_n_u_day_payload __pyx_string_tab[1207]
#define __pyx_n_u_day_start_time __pyx_string_tab[1208]
#define __pyx_n_u_days __pyx_string_tab[1209]
#define __pyx_n_u_db_interval __pyx_string_tab[1210]
#define __pyx_n_u_db_intervals __pyx_string_tab[1211]
#define __pyx_n_u_db_last __pyx_string_tab[1212]
#define __pyx_n_u_db_lock_manager __pyx_string_tab[1213]
#define __pyx_n_u_db_to_server __pyx_string_tab[1214]
#define __pyx_n_u_db_write_queue __pyx_string_tab[1215]
#define __pyx_n_u_db_writer_service __pyx_string_tab[1216]
#define __pyx_n_u_debug __pyx_string_tab[1217]
#define __pyx_n_u_decode __pyx_string_tab[1218]
#define __pyx_n_u_decrypt __pyx_string_tab[1219]
#define __pyx_n_u_decrypted_data __pyx_string_tab[1220]
#define __pyx_n_u_default __pyx_string_tab[1221]
#define __pyx_n_u_defaultdict __pyx_string_tab[1222]
#define __pyx_n_u_del_e __pyx_string_tab[1223]
#define __pyx_n_u_delay __pyx_string_tab[1224]
#define __pyx_n_u_delete __pyx_string_tab[1225]
#define __pyx_n_u_delete_old_data_and_screenshots __pyx_string_tab[1226]
#define __pyx_n_u_delete_screenshot __pyx_string_tab[1227]
#define __pyx_n_u_desc __pyx_string_tab[1228]
#define __pyx_n_u_detected_app __pyx_string_tab[1229]
#define __pyx_n_u_determine_sleep_reason __pyx_string_tab[1230]
#define __pyx_n_u_deviceId __pyx_string_tab[1231]
#define __pyx_n_u_deviceType __pyx_string_tab[1232]
#define __pyx_n_u_device_id __pyx_string_tab[1233]
#define __pyx_n_u_device_listener __pyx_string_tab[1234]
#define __pyx_n_u_device_listener_sleep __pyx_string_tab[1235]
#define __pyx_n_u_device_listener_wake __pyx_string_tab[1236]
#define __pyx_n_u_device_type __pyx_string_tab[1237]
#define __pyx_n_u_dict __pyx_string_tab[1238]
#define __pyx_n_u_dirname __pyx_string_tab[1239]
#define __pyx_n_u_discard __pyx_string_tab[1240]
#define __pyx_n_u_display_name __pyx_string_tab[1241]
#define __pyx_n_u_doc __pyx_string_tab[1242]
#define __pyx_n_u_done __pyx_string_tab[1243]
#define __pyx_n_u_dt1 __pyx_string_tab[1244]
#define __pyx_n_u_dt2 __pyx_string_tab[1245]
#define __pyx_n_u_dt_match __pyx_string_tab[1246]
#define __pyx_n_u_dt_obj __pyx_string_tab[1247]
#define __pyx_n_u_dtype __pyx_string_tab[1248]
#define __pyx_n_u_dwq __pyx_string_tab[1249]
#define __pyx_n_u_dwq2 __pyx_string_tab[1250]
#define __pyx_n_u_e __pyx_string_tab[1251]
#define __pyx_n_u_e2 __pyx_string_tab[1252]
#define __pyx_n_u_effective_end __pyx_string_tab[1253]
#define __pyx_n_u_effective_start __pyx_string_tab[1254]
#define __pyx_n_u_effective_start_time __pyx_string_tab[1255]
#define __pyx_n_u_elapsed_seconds __pyx_string_tab[1256]
#define __pyx_n_u_electron_comm __pyx_string_tab[1257]
#define __pyx_n_u_empty_activity_level __pyx_string_tab[1258]
#define __pyx_n_u_empty_interval __pyx_string_tab[1259]
#define __pyx_n_u_empty_interval_break_id __pyx_string_tab[1260]
#define __pyx_n_u_enable_hourly_log_upload __pyx_string_tab[1261]
#define __pyx_n_u_encrypted_key __pyx_string_tab[1262]
#define __pyx_n_u_end_date __pyx_string_tab[1263]
#define __pyx_n_u_end_date_seconds __pyx_string_tab[1264]
#define __pyx_n_u_end_date_y __pyx_string_tab[1265]
#define __pyx_n_u_end_sec __pyx_string_tab[1266]
#define __pyx_n_u_end_time __pyx_string_tab[1267]
#define __pyx_n_u_enqueue __pyx_string_tab[1268]
#define __pyx_n_u_enqueue_success __pyx_string_tab[1269]
#define __pyx_n_u_enqueued __pyx_string_tab[1270]
#define __pyx_n_u_enrich_subscription_payload __pyx_string_tab[1271]
#define __pyx_n_u_ensure_fresh_s3_bucket __pyx_string_tab[1272]
#define __pyx_n_u_ensure_s3_credentials_fresh __pyx_string_tab[1273]
#define __pyx_n_u_enter __pyx_string_tab[1274]
#define __pyx_n_u_enumerate __pyx_string_tab[1275]
#define __pyx_n_u_error __pyx_string_tab[1276]
#define __pyx_n_u_error_data __pyx_string_tab[1277]
#define __pyx_n_u_error_message __pyx_string_tab[1278]
#define __pyx_n_u_error_type __pyx_string_tab[1279]
#define __pyx_n_u_errors __pyx_string_tab[1280]
#define __pyx_n_u_et __pyx_string_tab[1281]
#define __pyx_n_u_exact __pyx_string_tab[1282]
#define __pyx_n_u_exc_info __pyx_string_tab[1283]
#define __pyx_n_u_exception __pyx_string_tab[1284]
#define __pyx_n_u_exceptions __pyx_string_tab[1285]
#define __pyx_n_u_excluded __pyx_string_tab[1286]
#define __pyx_n_u_executable __pyx_string_tab[1287]
#define __pyx_n_u_execute __pyx_string_tab[1288]
#define __pyx_n_u_existing __pyx_string_tab[1289]
#define __pyx_n_u_existing_dummy __pyx_string_tab[1290]
#define __pyx_n_u_existing_interval_in_db __pyx_string_tab[1291]
#define __pyx_n_u_existing_record __pyx_string_tab[1292]
#define __pyx_n_u_exists __pyx_string_tab[1293]
#define __pyx_n_u_exit __pyx_string_tab[1294]
#define __pyx_n_u_extract_datetime_from_filename __pyx_string_tab[1295]
#define __pyx_n_u_failed_count __pyx_string_tab[1296]
#define __pyx_n_u_fallback_end __pyx_string_tab[1297]
#define __pyx_n_u_fallback_error __pyx_string_tab[1298]
#define __pyx_n_u_fd_count __pyx_string_tab[1299]
#define __pyx_n_u_fetch_browser_url __pyx_string_tab[1300]
#define __pyx_n_u_fetch_user_org __pyx_string_tab[1301]
#define __pyx_n_u_file __pyx_string_tab[1302]
#define __pyx_n_u_file_2 __pyx_string_tab[1303]
#define __pyx_n_u_file_location __pyx_string_tab[1304]
#define __pyx_n_u_file_name __pyx_string_tab[1305]
#define __pyx_n_u_file_path __pyx_string_tab[1306]
#define __pyx_n_u_file_size __pyx_string_tab[1307]
#define __pyx_n_u_file_upload_success __pyx_string_tab[1308]
#define __pyx_n_u_filter_gaps_before_session __pyx_string_tab[1309]
#define __pyx_n_u_filter_intervals_excluding_in_p __pyx_string_tab[1310]
#define __pyx_n_u_filtered_count __pyx_string_tab[1311]
#define __pyx_n_u_filtered_intervals __pyx_string_tab[1312]
#define __pyx_n_u_final_payload __pyx_string_tab[1313]
#define __pyx_n_u_finalize_work_stop_time __pyx_string_tab[1314]
#define __pyx_n_u_find __pyx_string_tab[1315]
#define __pyx_n_u_find_missing_timestamps __pyx_string_tab[1316]
#define __pyx_n_u_find_overlapping_activity_percen __pyx_string_tab[1317]
#define __pyx_n_u_first __pyx_string_tab[1318]
#define __pyx_n_u_first_date __pyx_string_tab[1319]
#define __pyx_n_u_first_entry __pyx_string_tab[1320]
#define __pyx_n_u_first_entry_counter __pyx_string_tab[1321]
#define __pyx_n_u_first_entry_note __pyx_string_tab[1322]
#define __pyx_n_u_fixed_mode __pyx_string_tab[1323]
#define __pyx_n_u_flag2 __pyx_string_tab[1324]
#define __pyx_n_u_float __pyx_string_tab[1325]
#define __pyx_n_u_flush_error __pyx_string_tab[1326]
#define __pyx_n_u_fmt __pyx_string_tab[1327]
#define __pyx_n_u_folder __pyx_string_tab[1328]
#define __pyx_n_u_force_stop __pyx_string_tab[1329]
#define __pyx_n_u_force_stop_time __pyx_string_tab[1330]
#define __pyx_n_u_force_upload_after_pause_cap __pyx_string_tab[1331]
#define __pyx_n_u_format_exc __pyx_string_tab[1332]
#define __pyx_n_u_format_ss_name __pyx_string_tab[1333]
#define __pyx_n_u_forward_ss __pyx_string_tab[1334]
#define __pyx_n_u_from __pyx_string_tab[1335]
#define __pyx_n_u_frozen __pyx_string_tab[1336]
#define __pyx_n_u_func __pyx_string_tab[1337]
#define __pyx_n_u_func_2 __pyx_string_tab[1338]
#define __pyx_n_u_gap_end __pyx_string_tab[1339]
#define __pyx_n_u_gap_level __pyx_string_tab[1340]
#define __pyx_n_u_gap_minutes __pyx_string_tab[1341]
#define __pyx_n_u_gap_seconds __pyx_string_tab[1342]
#define __pyx_n_u_gap_start __pyx_string_tab[1343]
#define __pyx_n_u_genexpr __pyx_string_tab[1344]
#define __pyx_n_u_get __pyx_string_tab[1345]
#define __pyx_n_u_getCurrentSlot __pyx_string_tab[1346]
#define __pyx_n_u_getStartingSlot __pyx_string_tab[1347]
#define __pyx_n_u_get_active_windows __pyx_string_tab[1348]
#define __pyx_n_u_get_activity_intervals __pyx_string_tab[1349]
#define __pyx_n_u_get_activity_level __pyx_string_tab[1350]
#define __pyx_n_u_get_activity_level_from_db __pyx_string_tab[1351]
#define __pyx_n_u_get_activity_level_from_interva __pyx_string_tab[1352]
#define __pyx_n_u_get_app_icon __pyx_string_tab[1353]
#define __pyx_n_u_get_apps_urls __pyx_string_tab[1354]
#define __pyx_n_u_get_browser_url_with_fallback __pyx_string_tab[1355]
#define __pyx_n_u_get_bucket_in_every_interval __pyx_string_tab[1356]
#define __pyx_n_u_get_consecutive_idle_count __pyx_string_tab[1357]
#define __pyx_n_u_get_day_start_time __pyx_string_tab[1358]
#define __pyx_n_u_get_electron_comm __pyx_string_tab[1359]
#define __pyx_n_u_get_electron_comm_2 __pyx_string_tab[1360]
#define __pyx_n_u_get_electron_comm_lazy __pyx_string_tab[1361]
#define __pyx_n_u_get_event_loop __pyx_string_tab[1362]
#define __pyx_n_u_get_fixed_slots __pyx_string_tab[1363]
#define __pyx_n_u_get_intervals_overlapping_range __pyx_string_tab[1364]
#define __pyx_n_u_get_ip __pyx_string_tab[1365]
#define __pyx_n_u_get_last_activity_interval __pyx_string_tab[1366]
#define __pyx_n_u_get_latest_activity_percentage __pyx_string_tab[1367]
#define __pyx_n_u_get_localzone __pyx_string_tab[1368]
#define __pyx_n_u_get_loop __pyx_string_tab[1369]
#define __pyx_n_u_get_os_type __pyx_string_tab[1370]
#define __pyx_n_u_get_os_type_caps __pyx_string_tab[1371]
#define __pyx_n_u_get_os_version __pyx_string_tab[1372]
#define __pyx_n_u_get_pending_items __pyx_string_tab[1373]
#define __pyx_n_u_get_pinned_activity_log_session __pyx_string_tab[1374]
#define __pyx_n_u_get_queue_size __pyx_string_tab[1375]
#define __pyx_n_u_get_running_loop __pyx_string_tab[1376]
#define __pyx_n_u_get_s3bucket __pyx_string_tab[1377]
#define __pyx_n_u_get_screenshots __pyx_string_tab[1378]
#define __pyx_n_u_get_stats __pyx_string_tab[1379]
#define __pyx_n_u_get_system_timezone __pyx_string_tab[1380]
#define __pyx_n_u_get_system_wake_detector __pyx_string_tab[1381]
#define __pyx_n_u_get_today_weekday __pyx_string_tab[1382]
#define __pyx_n_u_get_total_queue_size __pyx_string_tab[1383]
#define __pyx_n_u_get_tracker_status __pyx_string_tab[1384]
#define __pyx_n_u_get_weekday __pyx_string_tab[1385]
#define __pyx_n_u_get_weekly_limit_notification_se __pyx_string_tab[1386]
#define __pyx_n_u_getcwd __pyx_string_tab[1387]
#define __pyx_n_u_getloadavg __pyx_string_tab[1388]
#define __pyx_n_u_getting_old_data __pyx_string_tab[1389]
#define __pyx_n_u_getting_unsent_interval __pyx_string_tab[1390]
#define __pyx_n_u_group_intervals_by_day __pyx_string_tab[1391]
#define __pyx_n_u_group_intervals_by_session __pyx_string_tab[1392]
#define __pyx_n_u_grouped_intervals __pyx_string_tab[1393]
#define __pyx_n_u_guid __pyx_string_tab[1394]
#define __pyx_n_u_handle_idle_popup_response __pyx_string_tab[1395]
#define __pyx_n_u_handle_idle_popup_shown __pyx_string_tab[1396]
#define __pyx_n_u_handle_s3_time_error __pyx_string_tab[1397]
#define __pyx_n_u_handle_system_sleep __pyx_string_tab[1398]
#define __pyx_n_u_handle_system_wake __pyx_string_tab[1399]
#define __pyx_n_u_handle_wake_s3_update __pyx_string_tab[1400]
#define __pyx_n_u_handle_wake_session_counter __pyx_string_tab[1401]
#define __pyx_n_u_has_activity_level_activity __pyx_string_tab[1402]
#define __pyx_n_u_has_activity_percentage_activity __pyx_string_tab[1403]
#define __pyx_n_u_has_any_activity __pyx_string_tab[1404]
#define __pyx_n_u_has_any_activity_in_interval __pyx_string_tab[1405]
#define __pyx_n_u_has_on_demand __pyx_string_tab[1406]
#define __pyx_n_u_has_on_demand_screenshot __pyx_string_tab[1407]
#define __pyx_n_u_has_recent_intervals_on_write_co __pyx_string_tab[1408]
#define __pyx_n_u_has_zero __pyx_string_tab[1409]
#define __pyx_n_u_has_zero_activity __pyx_string_tab[1410]
#define __pyx_n_u_has_zero_activity_for_interval __pyx_string_tab[1411]
#define __pyx_n_u_headers __pyx_string_tab[1412]
#define __pyx_n_u_held __pyx_string_tab[1413]
#define __pyx_n_u_held_idle_intervals __pyx_string_tab[1414]
#define __pyx_n_u_held_interval_ids __pyx_string_tab[1415]
#define __pyx_n_u_held_intervals __pyx_string_tab[1416]
#define __pyx_n_u_held_sent_count __pyx_string_tab[1417]
#define __pyx_n_u_hetzner __pyx_string_tab[1418]
#define __pyx_n_u_home __pyx_string_tab[1419]
#define __pyx_n_u_hour __pyx_string_tab[1420]
#define __pyx_n_u_hr __pyx_string_tab[1421]
#define __pyx_n_u_hwnd __pyx_string_tab[1422]
#define __pyx_n_u_i __pyx_string_tab[1423]
#define __pyx_n_u_i2t __pyx_string_tab[1424]
#define __pyx_n_u_id __pyx_string_tab[1425]
#define __pyx_n_u_idleInterval __pyx_string_tab[1426]
#define __pyx_n_u_idle_count __pyx_string_tab[1427]
#define __pyx_n_u_idle_file_upload_failure __pyx_string_tab[1428]
#define __pyx_n_u_idle_file_upload_success __pyx_string_tab[1429]
#define __pyx_n_u_idle_flag_query __pyx_string_tab[1430]
#define __pyx_n_u_idle_flag_result __pyx_string_tab[1431]
#define __pyx_n_u_idle_intervals __pyx_string_tab[1432]
#define __pyx_n_u_idle_intervals_by_flag __pyx_string_tab[1433]
#define __pyx_n_u_idle_note_url __pyx_string_tab[1434]
#define __pyx_n_u_idle_popup_active __pyx_string_tab[1435]
#define __pyx_n_u_idle_popup_blocking __pyx_string_tab[1436]
#define __pyx_n_u_idle_popup_cooldown_seconds __pyx_string_tab[1437]
#define __pyx_n_u_idle_popup_timeout_seconds __pyx_string_tab[1438]
#define __pyx_n_u_idle_popup_trigger __pyx_string_tab[1439]
#define __pyx_n_u_idle_popup_triggered_at __pyx_string_tab[1440]
#define __pyx_n_u_idle_reassign __pyx_string_tab[1441]
#define __pyx_n_u_idle_resolving_slot __pyx_string_tab[1442]
#define __pyx_n_u_idle_threshold __pyx_string_tab[1443]
#define __pyx_n_u_idle_time_limit_in_seconds __pyx_string_tab[1444]
#define __pyx_n_u_idle_time_ns __pyx_string_tab[1445]
#define __pyx_n_u_idle_time_seconds __pyx_string_tab[1446]
#define __pyx_n_u_idle_timeout_auto_stop __pyx_string_tab[1447]
#define __pyx_n_u_idx __pyx_string_tab[1448]
#define __pyx_n_u_ignore __pyx_string_tab[1449]
#define __pyx_n_u_iid __pyx_string_tab[1450]
#define __pyx_n_u_image_url __pyx_string_tab[1451]
#define __pyx_n_u_img_format __pyx_string_tab[1452]
#define __pyx_n_u_img_prefix __pyx_string_tab[1453]
#define __pyx_n_u_img_quality __pyx_string_tab[1454]
#define __pyx_n_u_in __pyx_string_tab[1455]
#define __pyx_n_u_in_range __pyx_string_tab[1456]
#define __pyx_n_u_include_printers __pyx_string_tab[1457]
#define __pyx_n_u_increment_session_counter __pyx_string_tab[1458]
#define __pyx_n_u_info __pyx_string_tab[1459]
#define __pyx_n_u_init __pyx_string_tab[1460]
#define __pyx_n_u_initial_average __pyx_string_tab[1461]
#define __pyx_n_u_initial_mouse __pyx_string_tab[1462]
#define __pyx_n_u_inrange __pyx_string_tab[1463]
#define __pyx_n_u_int __pyx_string_tab[1464]
#define __pyx_n_u_interval __pyx_string_tab[1465]
#define __pyx_n_u_interval_data __pyx_string_tab[1466]
#define __pyx_n_u_interval_date __pyx_string_tab[1467]
#define __pyx_n_u_interval_end_date __pyx_string_tab[1468]
#define __pyx_n_u_interval_end_time __pyx_string_tab[1469]
#define __pyx_n_u_interval_exists __pyx_string_tab[1470]
#define __pyx_n_u_interval_file_map __pyx_string_tab[1471]
#define __pyx_n_u_interval_id __pyx_string_tab[1472]
#define __pyx_n_u_interval_id_list __pyx_string_tab[1473]
#define __pyx_n_u_interval_ids __pyx_string_tab[1474]
#define __pyx_n_u_interval_ids_in_list __pyx_string_tab[1475]
#define __pyx_n_u_interval_is_uploaded __pyx_string_tab[1476]
#define __pyx_n_u_interval_key __pyx_string_tab[1477]
#define __pyx_n_u_interval_minutes __pyx_string_tab[1478]
#define __pyx_n_u_interval_note_map __pyx_string_tab[1479]
#define __pyx_n_u_interval_payload __pyx_string_tab[1480]
#define __pyx_n_u_interval_payloads __pyx_string_tab[1481]
#define __pyx_n_u_interval_start __pyx_string_tab[1482]
#define __pyx_n_u_interval_start_time __pyx_string_tab[1483]
#define __pyx_n_u_interval_time __pyx_string_tab[1484]
#define __pyx_n_u_interval_time_db __pyx_string_tab[1485]
#define __pyx_n_u_interval_to_update __pyx_string_tab[1486]
#define __pyx_n_u_interval_verified __pyx_string_tab[1487]
#define __pyx_n_u_intervals __pyx_string_tab[1488]
#define __pyx_n_u_intervals_for_day __pyx_string_tab[1489]
#define __pyx_n_u_intervals_to_mark __pyx_string_tab[1490]
#define __pyx_n_u_intervals_to_update __pyx_string_tab[1491]
#define __pyx_n_u_intervals_updated_count __pyx_string_tab[1492]
#define __pyx_n_u_ioreg __pyx_string_tab[1493]
#define __pyx_n_u_ioreg_output __pyx_string_tab[1494]
#define __pyx_n_u_ip_address __pyx_string_tab[1495]
#define __pyx_n_u_is __pyx_string_tab[1496]
#define __pyx_n_u_isUploaded __pyx_string_tab[1497]
#define __pyx_n_u_is_app_monitor_data_stale __pyx_string_tab[1498]
#define __pyx_n_u_is_break __pyx_string_tab[1499]
#define __pyx_n_u_is_break_interval __pyx_string_tab[1500]
#define __pyx_n_u_is_browser __pyx_string_tab[1501]
#define __pyx_n_u_is_connected __pyx_string_tab[1502]
#define __pyx_n_u_is_coroutine __pyx_string_tab[1503]
#define __pyx_n_u_is_first_entry __pyx_string_tab[1504]
#define __pyx_n_u_is_idle __pyx_string_tab[1505]
#define __pyx_n_u_is_idle_interval __pyx_string_tab[1506]
#define __pyx_n_u_is_ipc_ready __pyx_string_tab[1507]
#define __pyx_n_u_is_link __pyx_string_tab[1508]
#define __pyx_n_u_is_running __pyx_string_tab[1509]
#define __pyx_n_u_is_s3_uploaded __pyx_string_tab[1510]
#define __pyx_n_u_is_set __pyx_string_tab[1511]
#define __pyx_n_u_is_silent_build __pyx_string_tab[1512]
#define __pyx_n_u_is_sleep_interval __pyx_string_tab[1513]
#define __pyx_n_u_is_sleep_interval_for_manual_che __pyx_string_tab[1514]
#define __pyx_n_u_is_system_sleeping __pyx_string_tab[1515]
#define __pyx_n_u_is_tracking_enabled __pyx_string_tab[1516]
#define __pyx_n_u_is_uploaded __pyx_string_tab[1517]
#define __pyx_n_u_isdeactivated __pyx_string_tab[1518]
#define __pyx_n_u_isdeleted __pyx_string_tab[1519]
#define __pyx_n_u_isoformat __pyx_string_tab[1520]
#define __pyx_n_u_isprintable __pyx_string_tab[1521]
#define __pyx_n_u_items __pyx_string_tab[1522]
#define __pyx_n_u_iv __pyx_string_tab[1523]
#define __pyx_n_u_json __pyx_string_tab[1524]
#define __pyx_n_u_keep_idle_time __pyx_string_tab[1525]
#define __pyx_n_u_key __pyx_string_tab[1526]
#define __pyx_n_u_keyboard __pyx_string_tab[1527]
#define __pyx_n_u_keyboard_active __pyx_string_tab[1528]
#define __pyx_n_u_keyboard_activity __pyx_string_tab[1529]
#define __pyx_n_u_keyboard_listener_active __pyx_string_tab[1530]
#define __pyx_n_u_keyboard_listener_verified __pyx_string_tab[1531]
#define __pyx_n_u_keyboard_percentage __pyx_string_tab[1532]
#define __pyx_n_u_keyboard_verified __pyx_string_tab[1533]
#define __pyx_n_u_keys __pyx_string_tab[1534]
#define __pyx_n_u_lambda __pyx_string_tab[1535]
#define __pyx_n_u_last_active_app_check_time __pyx_string_tab[1536]
#define __pyx_n_u_last_api_call __pyx_string_tab[1537]
#define __pyx_n_u_last_api_call_impl __pyx_string_tab[1538]
#define __pyx_n_u_last_app_monitor_time __pyx_string_tab[1539]
#define __pyx_n_u_last_break_queue_flush __pyx_string_tab[1540]
#define __pyx_n_u_last_break_stop_event_time __pyx_string_tab[1541]
#define __pyx_n_u_last_bump __pyx_string_tab[1542]
#define __pyx_n_u_last_count __pyx_string_tab[1543]
#define __pyx_n_u_last_counter_bump_at __pyx_string_tab[1544]
#define __pyx_n_u_last_end __pyx_string_tab[1545]
#define __pyx_n_u_last_entry __pyx_string_tab[1546]
#define __pyx_n_u_last_entry_date __pyx_string_tab[1547]
#define __pyx_n_u_last_idle_popup_trigger_time __pyx_string_tab[1548]
#define __pyx_n_u_last_idle_resolution_time __pyx_string_tab[1549]
#define __pyx_n_u_last_in_this_day __pyx_string_tab[1550]
#define __pyx_n_u_last_interval __pyx_string_tab[1551]
#define __pyx_n_u_last_interval_end __pyx_string_tab[1552]
#define __pyx_n_u_last_interval_found __pyx_string_tab[1553]
#define __pyx_n_u_last_interval_id __pyx_string_tab[1554]
#define __pyx_n_u_last_interval_in_list __pyx_string_tab[1555]
#define __pyx_n_u_last_interval_obj __pyx_string_tab[1556]
#define __pyx_n_u_last_interval_updated __pyx_string_tab[1557]
#define __pyx_n_u_last_interval_was_sent __pyx_string_tab[1558]
#define __pyx_n_u_last_log_upload_time __pyx_string_tab[1559]
#define __pyx_n_u_last_match __pyx_string_tab[1560]
#define __pyx_n_u_last_minute __pyx_string_tab[1561]
#define __pyx_n_u_last_sleep_time __pyx_string_tab[1562]
#define __pyx_n_u_last_ss_urls __pyx_string_tab[1563]
#define __pyx_n_u_last_stealth_api_call __pyx_string_tab[1564]
#define __pyx_n_u_last_wake_time __pyx_string_tab[1565]
#define __pyx_n_u_last_work_stop_time __pyx_string_tab[1566]
#define __pyx_n_u_lat __pyx_string_tab[1567]
#define __pyx_n_u_latest_interval __pyx_string_tab[1568]
#define __pyx_n_u_latest_record __pyx_string_tab[1569]
#define __pyx_n_u_limit __pyx_string_tab[1570]
#define __pyx_n_u_limit_action __pyx_string_tab[1571]
#define __pyx_n_u_limit_end __pyx_string_tab[1572]
#define __pyx_n_u_limit_start __pyx_string_tab[1573]
#define __pyx_n_u_limit_stopped_date __pyx_string_tab[1574]
#define __pyx_n_u_limit_type __pyx_string_tab[1575]
#define __pyx_n_u_limits_check __pyx_string_tab[1576]
#define __pyx_n_u_line __pyx_string_tab[1577]
#define __pyx_n_u_linux __pyx_string_tab[1578]
#define __pyx_n_u_linux_idle_gap __pyx_string_tab[1579]
#define __pyx_n_u_linux_sleep_or_shutdown __pyx_string_tab[1580]
#define __pyx_n_u_list __pyx_string_tab[1581]
#define __pyx_n_u_load_org_settings_from_db __pyx_string_tab[1582]
#define __pyx_n_u_loads __pyx_string_tab[1583]
#define __pyx_n_u_local_file_path __pyx_string_tab[1584]
#define __pyx_n_u_local_timezone __pyx_string_tab[1585]
#define __pyx_n_u_location __pyx_string_tab[1586]
#define __pyx_n_u_log_api_response_summary __pyx_string_tab[1587]
#define __pyx_n_u_log_cleanup_enabled __pyx_string_tab[1588]
#define __pyx_n_u_log_session_split_reason __pyx_string_tab[1589]
#define __pyx_n_u_log_system_resources __pyx_string_tab[1590]
#define __pyx_n_u_log_testing_request_headers __pyx_string_tab[1591]
#define __pyx_n_u_log_upload_interval_minutes __pyx_string_tab[1592]
#define __pyx_n_u_logger __pyx_string_tab[1593]
#define __pyx_n_u_logs __pyx_string_tab[1594]
#define __pyx_n_u_logs_path __pyx_string_tab[1595]
#define __pyx_n_u_long __pyx_string_tab[1596]
#define __pyx_n_u_loop __pyx_string_tab[1597]
#define __pyx_n_u_lower __pyx_string_tab[1598]
#define __pyx_n_u_mac_log __pyx_string_tab[1599]
#define __pyx_n_u_macos_idle_gap __pyx_string_tab[1600]
#define __pyx_n_u_macos_sleep_or_shutdown __pyx_string_tab[1601]
#define __pyx_n_u_main __pyx_string_tab[1602]
#define __pyx_n_u_main_end_date __pyx_string_tab[1603]
#define __pyx_n_u_main_start_date __pyx_string_tab[1604]
#define __pyx_n_u_mark_idle_intervals_as_uploaded __pyx_string_tab[1605]
#define __pyx_n_u_mark_previous_zero_activity_int __pyx_string_tab[1606]
#define __pyx_n_u_max_retries __pyx_string_tab[1607]
#define __pyx_n_u_max_verification_retries __pyx_string_tab[1608]
#define __pyx_n_u_memory_check_counter __pyx_string_tab[1609]
#define __pyx_n_u_memory_info __pyx_string_tab[1610]
#define __pyx_n_u_memory_limit_mb __pyx_string_tab[1611]
#define __pyx_n_u_memory_mb __pyx_string_tab[1612]
#define __pyx_n_u_memory_percent __pyx_string_tab[1613]
#define __pyx_n_u_message __pyx_string_tab[1614]
#define __pyx_n_u_message_data __pyx_string_tab[1615]
#define __pyx_n_u_metaclass __pyx_string_tab[1616]
#define __pyx_n_u_microsecond __pyx_string_tab[1617]
#define __pyx_n_u_midnight __pyx_string_tab[1618]
#define __pyx_n_u_min __pyx_string_tab[1619]
#define __pyx_n_u_minimal_activity __pyx_string_tab[1620]
#define __pyx_n_u_minimum_percent __pyx_string_tab[1621]
#define __pyx_n_u_minute __pyx_string_tab[1622]
#define __pyx_n_u_minute_activity_level __pyx_string_tab[1623]
#define __pyx_n_u_minute_timer_task __pyx_string_tab[1624]
#define __pyx_n_u_minutes __pyx_string_tab[1625]
#define __pyx_n_u_missing_intervals __pyx_string_tab[1626]
#define __pyx_n_u_mktime __pyx_string_tab[1627]
#define __pyx_n_u_mode __pyx_string_tab[1628]
#define __pyx_n_u_mode_entity __pyx_string_tab[1629]
#define __pyx_n_u_model_dump __pyx_string_tab[1630]
#define __pyx_n_u_module __pyx_string_tab[1631]
#define __pyx_n_u_module_2 __pyx_string_tab[1632]
#define __pyx_n_u_monitor_active_app_for_ui __pyx_string_tab[1633]
#define __pyx_n_u_monitor_active_apps __pyx_string_tab[1634]
#define __pyx_n_u_monitor_task __pyx_string_tab[1635]
#define __pyx_n_u_mouse __pyx_string_tab[1636]
#define __pyx_n_u_mouse_active __pyx_string_tab[1637]
#define __pyx_n_u_mouse_activity __pyx_string_tab[1638]
#define __pyx_n_u_mouse_listener_active __pyx_string_tab[1639]
#define __pyx_n_u_mouse_listener_verified __pyx_string_tab[1640]
#define __pyx_n_u_mouse_percentage __pyx_string_tab[1641]
#define __pyx_n_u_mouse_verified __pyx_string_tab[1642]
#define __pyx_n_u_mro_entries __pyx_string_tab[1643]
#define __pyx_n_u_name __pyx_string_tab[1644]
#define __pyx_n_u_name_2 __pyx_string_tab[1645]
#define __pyx_n_u_new_event_loop __pyx_string_tab[1646]
#define __pyx_n_u_new_session __pyx_string_tab[1647]
#define __pyx_n_u_new_string __pyx_string_tab[1648]
#define __pyx_n_u_next __pyx_string_tab[1649]
#define __pyx_n_u_next_day __pyx_string_tab[1650]
#define __pyx_n_u_no_of_days __pyx_string_tab[1651]
#define __pyx_n_u_node __pyx_string_tab[1652]
#define __pyx_n_u_non_idle_intervals __pyx_string_tab[1653]
#define __pyx_n_u_normalize __pyx_string_tab[1654]
#define __pyx_n_u_normalize_activity_log_start __pyx_string_tab[1655]
#define __pyx_n_u_normalize_hhmmss __pyx_string_tab[1656]
#define __pyx_n_u_normalize_timezone __pyx_string_tab[1657]
#define __pyx_n_u_normalize_timezone_preference __pyx_string_tab[1658]
#define __pyx_n_u_normalized __pyx_string_tab[1659]
#define __pyx_n_u_normalized_name __pyx_string_tab[1660]
#define __pyx_n_u_note __pyx_string_tab[1661]
#define __pyx_n_u_note_data __pyx_string_tab[1662]
#define __pyx_n_u_note_text __pyx_string_tab[1663]
#define __pyx_n_u_notes_2 __pyx_string_tab[1664]
#define __pyx_n_u_notes_entries __pyx_string_tab[1665]
#define __pyx_n_u_notes_entry __pyx_string_tab[1666]
#define __pyx_n_u_notes_query __pyx_string_tab[1667]
#define __pyx_n_u_notes_result __pyx_string_tab[1668]
#define __pyx_n_u_notification_service __pyx_string_tab[1669]
#define __pyx_n_u_notification_status __pyx_string_tab[1670]
#define __pyx_n_u_now __pyx_string_tab[1671]
#define __pyx_n_u_now_ts __pyx_string_tab[1672]
#define __pyx_n_u_null __pyx_string_tab[1673]
#define __pyx_n_u_num_fds __pyx_string_tab[1674]
#define __pyx_n_u_num_threads __pyx_string_tab[1675]
#define __pyx_n_u_old_counter __pyx_string_tab[1676]
#define __pyx_n_u_old_end __pyx_string_tab[1677]
#define __pyx_n_u_old_screenshots __pyx_string_tab[1678]
#define __pyx_n_u_on_time_error __pyx_string_tab[1679]
#define __pyx_n_u_operation_type __pyx_string_tab[1680]
#define __pyx_n_u_or __pyx_string_tab[1681]
#define __pyx_n_u_order_by __pyx_string_tab[1682]
#define __pyx_n_u_org_api_timezone __pyx_string_tab[1683]
#define __pyx_n_u_org_entity __pyx_string_tab[1684]
#define __pyx_n_u_org_id __pyx_string_tab[1685]
#define __pyx_n_u_org_week_start_day __pyx_string_tab[1686]
#define __pyx_n_u_original_length __pyx_string_tab[1687]
#define __pyx_n_u_original_size __pyx_string_tab[1688]
#define __pyx_n_u_os __pyx_string_tab[1689]
#define __pyx_n_u_os_name __pyx_string_tab[1690]
#define __pyx_n_u_os_type __pyx_string_tab[1691]
#define __pyx_n_u_os_version __pyx_string_tab[1692]
#define __pyx_n_u_overlap_query __pyx_string_tab[1693]
#define __pyx_n_u_overlap_query_after_trim __pyx_string_tab[1694]
#define __pyx_n_u_overlap_result __pyx_string_tab[1695]
#define __pyx_n_u_overlap_result_after_trim __pyx_string_tab[1696]
#define __pyx_n_u_overlapping __pyx_string_tab[1697]
#define __pyx_n_u_overlapping_details __pyx_string_tab[1698]
#define __pyx_n_u_overlapping_details_after_trim __pyx_string_tab[1699]
#define __pyx_n_u_overlapping_intervals __pyx_string_tab[1700]
#define __pyx_n_u_overlapping_intervals_after_trim __pyx_string_tab[1701]
#define __pyx_n_u_parents __pyx_string_tab[1702]
#define __pyx_n_u_parse_fixed_mode_window __pyx_string_tab[1703]
#define __pyx_n_u_parsed __pyx_string_tab[1704]
#define __pyx_n_u_particular_timestamp __pyx_string_tab[1705]
#define __pyx_n_u_path __pyx_string_tab[1706]
#define __pyx_n_u_pathlib __pyx_string_tab[1707]
#define __pyx_n_u_payload __pyx_string_tab[1708]
#define __pyx_n_u_payload_from __pyx_string_tab[1709]
#define __pyx_n_u_payload_interval_bounds __pyx_string_tab[1710]
#define __pyx_n_u_payload_project_id __pyx_string_tab[1711]
#define __pyx_n_u_payload_task_id __pyx_string_tab[1712]
#define __pyx_n_u_payload_to __pyx_string_tab[1713]
#define __pyx_n_u_pe __pyx_string_tab[1714]
#define __pyx_n_u_pe2 __pyx_string_tab[1715]
#define __pyx_n_u_perform_comprehensive_log_cleanu __pyx_string_tab[1716]
#define __pyx_n_u_period_duration __pyx_string_tab[1717]
#define __pyx_n_u_persist_idle_popup_intervals_mi __pyx_string_tab[1718]
#define __pyx_n_u_pi __pyx_string_tab[1719]
#define __pyx_n_u_pi2 __pyx_string_tab[1720]
#define __pyx_n_u_pinned __pyx_string_tab[1721]
#define __pyx_n_u_pinned_start __pyx_string_tab[1722]
#define __pyx_n_u_planStatus __pyx_string_tab[1723]
#define __pyx_n_u_platform __pyx_string_tab[1724]
#define __pyx_n_u_platform_name __pyx_string_tab[1725]
#define __pyx_n_u_pop __pyx_string_tab[1726]
#define __pyx_n_u_popup_is_active __pyx_string_tab[1727]
#define __pyx_n_u_popup_query __pyx_string_tab[1728]
#define __pyx_n_u_popup_result __pyx_string_tab[1729]
#define __pyx_n_u_popup_triggered_at __pyx_string_tab[1730]
#define __pyx_n_u_position_of_dollar __pyx_string_tab[1731]
#define __pyx_n_u_post __pyx_string_tab[1732]
#define __pyx_n_u_precise_sleep __pyx_string_tab[1733]
#define __pyx_n_u_preference __pyx_string_tab[1734]
#define __pyx_n_u_prepare __pyx_string_tab[1735]
#define __pyx_n_u_prev_day_unsent __pyx_string_tab[1736]
#define __pyx_n_u_prev_interval __pyx_string_tab[1737]
#define __pyx_n_u_previous __pyx_string_tab[1738]
#define __pyx_n_u_process __pyx_string_tab[1739]
#define __pyx_n_u_process_immediately __pyx_string_tab[1740]
#define __pyx_n_u_process_intervals_bulk __pyx_string_tab[1741]
#define __pyx_n_u_processed_count __pyx_string_tab[1742]
#define __pyx_n_u_processed_last_min_intervals __pyx_string_tab[1743]
#define __pyx_n_u_projectId __pyx_string_tab[1744]
#define __pyx_n_u_project_id __pyx_string_tab[1745]
#define __pyx_n_u_project_id_str __pyx_string_tab[1746]
#define __pyx_n_u_project_switch_in_progress __pyx_string_tab[1747]
#define __pyx_n_u_ps __pyx_string_tab[1748]
#define __pyx_n_u_ps2 __pyx_string_tab[1749]
#define __pyx_n_u_psutil __pyx_string_tab[1750]
#define __pyx_n_u_push_activity_log __pyx_string_tab[1751]
#define __pyx_n_u_push_activity_logs __pyx_string_tab[1752]
#define __pyx_n_u_push_open_session_activity_log __pyx_string_tab[1753]
#define __pyx_n_u_q_4 __pyx_string_tab[1754]
#define __pyx_n_u_qualname __pyx_string_tab[1755]
#define __pyx_n_u_query __pyx_string_tab[1756]
#define __pyx_n_u_query_all __pyx_string_tab[1757]
#define __pyx_n_u_query_by_flag __pyx_string_tab[1758]
#define __pyx_n_u_queue_size __pyx_string_tab[1759]
#define __pyx_n_u_queue_write __pyx_string_tab[1760]
#define __pyx_n_u_raw_end __pyx_string_tab[1761]
#define __pyx_n_u_raw_start __pyx_string_tab[1762]
#define __pyx_n_u_re __pyx_string_tab[1763]
#define __pyx_n_u_read_lock __pyx_string_tab[1764]
#define __pyx_n_u_reason __pyx_string_tab[1765]
#define __pyx_n_u_reassign __pyx_string_tab[1766]
#define __pyx_n_u_record __pyx_string_tab[1767]
#define __pyx_n_u_recoverable __pyx_string_tab[1768]
#define __pyx_n_u_recovery_error __pyx_string_tab[1769]
#define __pyx_n_u_refresh_resolving_slot_if_exist __pyx_string_tab[1770]
#define __pyx_n_u_register_sleep_callback __pyx_string_tab[1771]
#define __pyx_n_u_register_wake_callback __pyx_string_tab[1772]
#define __pyx_n_u_regular_interval_overlaps __pyx_string_tab[1773]
#define __pyx_n_u_regular_intervals __pyx_string_tab[1774]
#define __pyx_n_u_regular_intervals_after_trim __pyx_string_tab[1775]
#define __pyx_n_u_reload_localzone __pyx_string_tab[1776]
#define __pyx_n_u_remainder __pyx_string_tab[1777]
#define __pyx_n_u_remaining_break_intervals __pyx_string_tab[1778]
#define __pyx_n_u_remaining_intervals __pyx_string_tab[1779]
#define __pyx_n_u_remove_after_delay __pyx_string_tab[1780]
#define __pyx_n_u_replace __pyx_string_tab[1781]
#define __pyx_n_u_report_in_background __pyx_string_tab[1782]
#define __pyx_n_u_report_limit_exceeded __pyx_string_tab[1783]
#define __pyx_n_u_report_thread __pyx_string_tab[1784]
#define __pyx_n_u_requests __pyx_string_tab[1785]
#define __pyx_n_u_res __pyx_string_tab[1786]
#define __pyx_n_u_resolve __pyx_string_tab[1787]
#define __pyx_n_u_resolve_screenshot_directory __pyx_string_tab[1788]
#define __pyx_n_u_resolving_policy __pyx_string_tab[1789]
#define __pyx_n_u_response __pyx_string_tab[1790]
#define __pyx_n_u_response_2 __pyx_string_tab[1791]
#define __pyx_n_u_response_data __pyx_string_tab[1792]
#define __pyx_n_u_restart_listeners __pyx_string_tab[1793]
#define __pyx_n_u_result __pyx_string_tab[1794]
#define __pyx_n_u_result_all __pyx_string_tab[1795]
#define __pyx_n_u_result_by_flag __pyx_string_tab[1796]
#define __pyx_n_u_retry_delays __pyx_string_tab[1797]
#define __pyx_n_u_return __pyx_string_tab[1798]
#define __pyx_n_u_rollback __pyx_string_tab[1799]
#define __pyx_n_u_rounded_minute __pyx_string_tab[1800]
#define __pyx_n_u_row __pyx_string_tab[1801]
#define __pyx_n_u_rss __pyx_string_tab[1802]
#define __pyx_n_u_rstrip __pyx_string_tab[1803]
#define __pyx_n_u_run __pyx_string_tab[1804]
#define __pyx_n_u_run_in_executor __pyx_string_tab[1805]
#define __pyx_n_u_run_until_complete __pyx_string_tab[1806]
#define __pyx_n_u_s3_bucket_update_wake __pyx_string_tab[1807]
#define __pyx_n_u_s3_config __pyx_string_tab[1808]
#define __pyx_n_u_s3_credentials_expired __pyx_string_tab[1809]
#define __pyx_n_u_s3_credentials_need_refresh __pyx_string_tab[1810]
#define __pyx_n_u_s3_dest_path __pyx_string_tab[1811]
#define __pyx_n_u_s3_detail __pyx_string_tab[1812]
#define __pyx_n_u_s3_detail_for_upload __pyx_string_tab[1813]
#define __pyx_n_u_s3_file_url __pyx_string_tab[1814]
#define __pyx_n_u_s3_key __pyx_string_tab[1815]
#define __pyx_n_u_s3_logs_path __pyx_string_tab[1816]
#define __pyx_n_u_s3_screenshot_path __pyx_string_tab[1817]
#define __pyx_n_u_s3_sync __pyx_string_tab[1818]
#define __pyx_n_u_s3_upload_link __pyx_string_tab[1819]
#define __pyx_n_u_s3_url __pyx_string_tab[1820]
#define __pyx_n_u_s_2 __pyx_string_tab[1821]
#define __pyx_n_u_s_limit_end __pyx_string_tab[1822]
#define __pyx_n_u_s_limit_start __pyx_string_tab[1823]
#define __pyx_n_u_save_activity_log __pyx_string_tab[1824]
#define __pyx_n_u_save_app_monitors __pyx_string_tab[1825]
#define __pyx_n_u_save_dir __pyx_string_tab[1826]
#define __pyx_n_u_save_first_activity_log __pyx_string_tab[1827]
#define __pyx_n_u_save_fixed_mode __pyx_string_tab[1828]
#define __pyx_n_u_save_note_to_current_interval __pyx_string_tab[1829]
#define __pyx_n_u_save_note_to_idle_intervals __pyx_string_tab[1830]
#define __pyx_n_u_save_user_org __pyx_string_tab[1831]
#define __pyx_n_u_scalar __pyx_string_tab[1832]
#define __pyx_n_u_scalar_one_or_none __pyx_string_tab[1833]
#define __pyx_n_u_scalars __pyx_string_tab[1834]
#define __pyx_n_u_screenUrl __pyx_string_tab[1835]
#define __pyx_n_u_screen_url __pyx_string_tab[1836]
#define __pyx_n_u_screenshot __pyx_string_tab[1837]
#define __pyx_n_u_screenshot_controller __pyx_string_tab[1838]
#define __pyx_n_u_screenshot_ctrl __pyx_string_tab[1839]
#define __pyx_n_u_screenshot_data __pyx_string_tab[1840]
#define __pyx_n_u_screenshot_dir __pyx_string_tab[1841]
#define __pyx_n_u_screenshot_entity __pyx_string_tab[1842]
#define __pyx_n_u_screenshot_folder __pyx_string_tab[1843]
#define __pyx_n_u_screenshot_ids __pyx_string_tab[1844]
#define __pyx_n_u_screenshot_interval __pyx_string_tab[1845]
#define __pyx_n_u_screenshot_manager __pyx_string_tab[1846]
#define __pyx_n_u_screenshot_name __pyx_string_tab[1847]
#define __pyx_n_u_screenshot_query __pyx_string_tab[1848]
#define __pyx_n_u_screenshot_service __pyx_string_tab[1849]
#define __pyx_n_u_screenshotblurstatus __pyx_string_tab[1850]
#define __pyx_n_u_screenshots __pyx_string_tab[1851]
#define __pyx_n_u_screenshots_to_delete __pyx_string_tab[1852]
#define __pyx_n_u_script_path __pyx_string_tab[1853]
#define __pyx_n_u_sd_token __pyx_string_tab[1854]
#define __pyx_n_u_second __pyx_string_tab[1855]
#define __pyx_n_u_seconds __pyx_string_tab[1856]
#define __pyx_n_u_seconds_until_datetime __pyx_string_tab[1857]
#define __pyx_n_u_seg_end __pyx_string_tab[1858]
#define __pyx_n_u_seg_start __pyx_string_tab[1859]
#define __pyx_n_u_segment_start __pyx_string_tab[1860]
#define __pyx_n_u_select __pyx_string_tab[1861]
#define __pyx_n_u_self __pyx_string_tab[1862]
#define __pyx_n_u_selfiVerification __pyx_string_tab[1863]
#define __pyx_n_u_selfi_id __pyx_string_tab[1864]
#define __pyx_n_u_send __pyx_string_tab[1865]
#define __pyx_n_u_send_active_app_update_to_elect __pyx_string_tab[1866]
#define __pyx_n_u_send_file_upload_failure_to_ele __pyx_string_tab[1867]
#define __pyx_n_u_send_file_upload_success_to_ele __pyx_string_tab[1868]
#define __pyx_n_u_send_subscription_expired_popup __pyx_string_tab[1869]
#define __pyx_n_u_send_to_electron __pyx_string_tab[1870]
#define __pyx_n_u_send_to_electron_if_connected __pyx_string_tab[1871]
#define __pyx_n_u_sending_held_intervals __pyx_string_tab[1872]
#define __pyx_n_u_sending_intervals __pyx_string_tab[1873]
#define __pyx_n_u_sending_unsent_intervals __pyx_string_tab[1874]
#define __pyx_n_u_sent __pyx_string_tab[1875]
#define __pyx_n_u_server_controller __pyx_string_tab[1876]
#define __pyx_n_u_server_service __pyx_string_tab[1877]
#define __pyx_n_u_session __pyx_string_tab[1878]
#define __pyx_n_u_session_close_lock __pyx_string_tab[1879]
#define __pyx_n_u_session_gap_minutes __pyx_string_tab[1880]
#define __pyx_n_u_session_gap_threshold_minutes __pyx_string_tab[1881]
#define __pyx_n_u_session_gap_threshold_seconds __pyx_string_tab[1882]
#define __pyx_n_u_session_start __pyx_string_tab[1883]
#define __pyx_n_u_sessions __pyx_string_tab[1884]
#define __pyx_n_u_set_cred __pyx_string_tab[1885]
#define __pyx_n_u_set_event_loop __pyx_string_tab[1886]
#define __pyx_n_u_set_local_timezone __pyx_string_tab[1887]
#define __pyx_n_u_set_name __pyx_string_tab[1888]
#define __pyx_n_u_set_on_time_error_callback __pyx_string_tab[1889]
#define __pyx_n_u_set_project_task_ids __pyx_string_tab[1890]
#define __pyx_n_u_setdefault __pyx_string_tab[1891]
#define __pyx_n_u_seven_days_ago __pyx_string_tab[1892]
#define __pyx_n_u_should_pause_api __pyx_string_tab[1893]
#define __pyx_n_u_should_pause_api_calls __pyx_string_tab[1894]
#define __pyx_n_u_should_refresh __pyx_string_tab[1895]
#define __pyx_n_u_should_skip_break_processing __pyx_string_tab[1896]
#define __pyx_n_u_should_skip_counter_bump_dedup __pyx_string_tab[1897]
#define __pyx_n_u_should_start_new_session __pyx_string_tab[1898]
#define __pyx_n_u_should_upload __pyx_string_tab[1899]
#define __pyx_n_u_shutil __pyx_string_tab[1900]
#define __pyx_n_u_sleep __pyx_string_tab[1901]
#define __pyx_n_u_sleep_auto_stop __pyx_string_tab[1902]
#define __pyx_n_u_sleep_minutes __pyx_string_tab[1903]
#define __pyx_n_u_sleep_seconds __pyx_string_tab[1904]
#define __pyx_n_u_sleep_timestamp __pyx_string_tab[1905]
#define __pyx_n_u_slot __pyx_string_tab[1906]
#define __pyx_n_u_slot_end __pyx_string_tab[1907]
#define __pyx_n_u_slot_start __pyx_string_tab[1908]
#define __pyx_n_u_sorted __pyx_string_tab[1909]
#define __pyx_n_u_sorted_intervals __pyx_string_tab[1910]
#define __pyx_n_u_source __pyx_string_tab[1911]
#define __pyx_n_u_source_type __pyx_string_tab[1912]
#define __pyx_n_u_split __pyx_string_tab[1913]
#define __pyx_n_u_splitlines __pyx_string_tab[1914]
#define __pyx_n_u_sqlalchemy __pyx_string_tab[1915]
#define __pyx_n_u_ss __pyx_string_tab[1916]
#define __pyx_n_u_ss_array __pyx_string_tab[1917]
#define __pyx_n_u_ss_end_time __pyx_string_tab[1918]
#define __pyx_n_u_ssfrequencystatus __pyx_string_tab[1919]
#define __pyx_n_u_st __pyx_string_tab[1920]
#define __pyx_n_u_st_size __pyx_string_tab[1921]
#define __pyx_n_u_start __pyx_string_tab[1922]
#define __pyx_n_u_start_app_monitor_flush_task __pyx_string_tab[1923]
#define __pyx_n_u_start_date __pyx_string_tab[1924]
#define __pyx_n_u_start_date_seconds __pyx_string_tab[1925]
#define __pyx_n_u_start_date_y __pyx_string_tab[1926]
#define __pyx_n_u_start_device_activity __pyx_string_tab[1927]
#define __pyx_n_u_start_device_activity_2 __pyx_string_tab[1928]
#define __pyx_n_u_start_minute_activity_timer __pyx_string_tab[1929]
#define __pyx_n_u_start_monitoring __pyx_string_tab[1930]
#define __pyx_n_u_start_screenshot_activity __pyx_string_tab[1931]
#define __pyx_n_u_start_sec __pyx_string_tab[1932]
#define __pyx_n_u_start_status_activity __pyx_string_tab[1933]
#define __pyx_n_u_start_time __pyx_string_tab[1934]
#define __pyx_n_u_startswith __pyx_string_tab[1935]
#define __pyx_n_u_stat __pyx_string_tab[1936]
#define __pyx_n_u_staticmethod __pyx_string_tab[1937]
#define __pyx_n_u_stats __pyx_string_tab[1938]
#define __pyx_n_u_status __pyx_string_tab[1939]
#define __pyx_n_u_status_code __pyx_string_tab[1940]
#define __pyx_n_u_status_controller __pyx_string_tab[1941]
#define __pyx_n_u_stderr __pyx_string_tab[1942]
#define __pyx_n_u_stealth_api_cache_interval __pyx_string_tab[1943]
#define __pyx_n_u_stop __pyx_string_tab[1944]
#define __pyx_n_u_stop_dt __pyx_string_tab[1945]
#define __pyx_n_u_stop_dt_for_intervals __pyx_string_tab[1946]
#define __pyx_n_u_stop_event __pyx_string_tab[1947]
#define __pyx_n_u_stop_listeners __pyx_string_tab[1948]
#define __pyx_n_u_stop_monitoring __pyx_string_tab[1949]
#define __pyx_n_u_stop_timer __pyx_string_tab[1950]
#define __pyx_n_u_stop_value __pyx_string_tab[1951]
#define __pyx_n_u_str __pyx_string_tab[1952]
#define __pyx_n_u_strftime __pyx_string_tab[1953]
#define __pyx_n_u_strip __pyx_string_tab[1954]
#define __pyx_n_u_strptime __pyx_string_tab[1955]
#define __pyx_n_u_sub __pyx_string_tab[1956]
#define __pyx_n_u_sub_segments __pyx_string_tab[1957]
#define __pyx_n_u_subprocess __pyx_string_tab[1958]
#define __pyx_n_u_subscription_expired __pyx_string_tab[1959]
#define __pyx_n_u_subtract_overlapping_intervals __pyx_string_tab[1960]
#define __pyx_n_u_success __pyx_string_tab[1961]
#define __pyx_n_u_success_count __pyx_string_tab[1962]
#define __pyx_n_u_suffix __pyx_string_tab[1963]
#define __pyx_n_u_sum __pyx_string_tab[1964]
#define __pyx_n_u_switch_time __pyx_string_tab[1965]
#define __pyx_n_u_sync __pyx_string_tab[1966]
#define __pyx_n_u_sync_activity_immediately __pyx_string_tab[1967]
#define __pyx_n_u_sync_failed __pyx_string_tab[1968]
#define __pyx_n_u_sys __pyx_string_tab[1969]
#define __pyx_n_u_system __pyx_string_tab[1970]
#define __pyx_n_u_system_cpu_percent __pyx_string_tab[1971]
#define __pyx_n_u_system_is_responsive __pyx_string_tab[1972]
#define __pyx_n_u_system_name __pyx_string_tab[1973]
#define __pyx_n_u_system_unique_id __pyx_string_tab[1974]
#define __pyx_n_u_tab_title __pyx_string_tab[1975]
#define __pyx_n_u_table_name __pyx_string_tab[1976]
#define __pyx_n_u_target __pyx_string_tab[1977]
#define __pyx_n_u_target_date __pyx_string_tab[1978]
#define __pyx_n_u_target_directory __pyx_string_tab[1979]
#define __pyx_n_u_target_directory_mac __pyx_string_tab[1980]
#define __pyx_n_u_target_directory_stealth __pyx_string_tab[1981]
#define __pyx_n_u_target_directoryw __pyx_string_tab[1982]
#define __pyx_n_u_target_interval_id __pyx_string_tab[1983]
#define __pyx_n_u_task __pyx_string_tab[1984]
#define __pyx_n_u_task_done_callback __pyx_string_tab[1985]
#define __pyx_n_u_task_id __pyx_string_tab[1986]
#define __pyx_n_u_task_id_str __pyx_string_tab[1987]
#define __pyx_n_u_task_loop __pyx_string_tab[1988]
#define __pyx_n_u_temp_file __pyx_string_tab[1989]
#define __pyx_n_u_temp_file_path __pyx_string_tab[1990]
#define __pyx_n_u_tempfile __pyx_string_tab[1991]
#define __pyx_n_u_test __pyx_string_tab[1992]
#define __pyx_n_u_text __pyx_string_tab[1993]
#define __pyx_n_u_thread_count __pyx_string_tab[1994]
#define __pyx_n_u_threading __pyx_string_tab[1995]
#define __pyx_n_u_throw __pyx_string_tab[1996]
#define __pyx_n_u_time __pyx_string_tab[1997]
#define __pyx_n_u_timeInterval __pyx_string_tab[1998]
#define __pyx_n_u_time_diff __pyx_string_tab[1999]
#define __pyx_n_u_time_diff_seconds __pyx_string_tab[2000]
#define __pyx_n_u_time_error_type __pyx_string_tab[2001]
#define __pyx_n_u_time_monitor __pyx_string_tab[2002]
#define __pyx_n_u_time_since_break_stop __pyx_string_tab[2003]
#define __pyx_n_u_time_since_last_call __pyx_string_tab[2004]
#define __pyx_n_u_time_since_sleep __pyx_string_tab[2005]
#define __pyx_n_u_time_since_wake __pyx_string_tab[2006]
#define __pyx_n_u_time_type __pyx_string_tab[2007]
#define __pyx_n_u_timecheck_failed __pyx_string_tab[2008]
#define __pyx_n_u_timecheck_with_recheck __pyx_string_tab[2009]
#define __pyx_n_u_timedelta __pyx_string_tab[2010]
#define __pyx_n_u_timeout __pyx_string_tab[2011]
#define __pyx_n_u_timeout_reached __pyx_string_tab[2012]
#define __pyx_n_u_timestamp __pyx_string_tab[2013]
#define __pyx_n_u_timestamp_db __pyx_string_tab[2014]
#define __pyx_n_u_timetuple __pyx_string_tab[2015]
#define __pyx_n_u_timezone __pyx_string_tab[2016]
#define __pyx_n_u_timezone_checks_enabled __pyx_string_tab[2017]
#define __pyx_n_u_timezone_error __pyx_string_tab[2018]
#define __pyx_n_u_timezone_manager __pyx_string_tab[2019]
#define __pyx_n_u_timezone_mismatch __pyx_string_tab[2020]
#define __pyx_n_u_timezone_mismatch_2 __pyx_string_tab[2021]
#define __pyx_n_u_timezone_preference __pyx_string_tab[2022]
#define __pyx_n_u_title __pyx_string_tab[2023]
#define __pyx_n_u_to __pyx_string_tab[2024]
#define __pyx_n_u_to_int __pyx_string_tab[2025]
#define __pyx_n_u_today __pyx_string_tab[2026]
#define __pyx_n_u_todo_id __pyx_string_tab[2027]
#define __pyx_n_u_tol __pyx_string_tab[2028]
#define __pyx_n_u_tolerance_seconds __pyx_string_tab[2029]
#define __pyx_n_u_total_fill_seconds __pyx_string_tab[2030]
#define __pyx_n_u_total_queue_size __pyx_string_tab[2031]
#define __pyx_n_u_total_seconds __pyx_string_tab[2032]
#define __pyx_n_u_total_sleep __pyx_string_tab[2033]
#define __pyx_n_u_traceback __pyx_string_tab[2034]
#define __pyx_n_u_tracker_status __pyx_string_tab[2035]
#define __pyx_n_u_tracking __pyx_string_tab[2036]
#define __pyx_n_u_tracking_error __pyx_string_tab[2037]
#define __pyx_n_u_tracking_resumed_logged __pyx_string_tab[2038]
#define __pyx_n_u_tracking_scenario __pyx_string_tab[2039]
#define __pyx_n_u_trim_open_partial_at_project_sw __pyx_string_tab[2040]
#define __pyx_n_u_trim_to __pyx_string_tab[2041]
#define __pyx_n_u_trimmed_partial __pyx_string_tab[2042]
#define __pyx_n_u_trimmed_partial_used __pyx_string_tab[2043]
#define __pyx_n_u_try_finalize_post_switch_slot_i __pyx_string_tab[2044]
#define __pyx_n_u_typing __pyx_string_tab[2045]
#define __pyx_n_u_tzlocal __pyx_string_tab[2046]
#define __pyx_n_u_tzmain __pyx_string_tab[2047]
#define __pyx_n_u_unicodedata __pyx_string_tab[2048]
#define __pyx_n_u_unix_format_ss_name __pyx_string_tab[2049]
#define __pyx_n_u_unix_timestamp __pyx_string_tab[2050]
#define __pyx_n_u_unlink __pyx_string_tab[2051]
#define __pyx_n_u_unsent_intervals __pyx_string_tab[2052]
#define __pyx_n_u_update_activity_interval __pyx_string_tab[2053]
#define __pyx_n_u_update_interval __pyx_string_tab[2054]
#define __pyx_n_u_update_screenshots __pyx_string_tab[2055]
#define __pyx_n_u_update_segment_start __pyx_string_tab[2056]
#define __pyx_n_u_update_tracking_duration __pyx_string_tab[2057]
#define __pyx_n_u_updated_interval_ids __pyx_string_tab[2058]
#define __pyx_n_u_updates __pyx_string_tab[2059]
#define __pyx_n_u_upload_error __pyx_string_tab[2060]
#define __pyx_n_u_upload_file __pyx_string_tab[2061]
#define __pyx_n_u_upload_file_to_hetzner __pyx_string_tab[2062]
#define __pyx_n_u_upload_file_to_s3 __pyx_string_tab[2063]
#define __pyx_n_u_upper __pyx_string_tab[2064]
#define __pyx_n_u_url __pyx_string_tab[2065]
#define __pyx_n_u_url_result __pyx_string_tab[2066]
#define __pyx_n_u_userCategory __pyx_string_tab[2067]
#define __pyx_n_u_userCategoryTitle __pyx_string_tab[2068]
#define __pyx_n_u_user_entity __pyx_string_tab[2069]
#define __pyx_n_u_user_entity_for_wake __pyx_string_tab[2070]
#define __pyx_n_u_user_id __pyx_string_tab[2071]
#define __pyx_n_u_user_service __pyx_string_tab[2072]
#define __pyx_n_u_user_timezone __pyx_string_tab[2073]
#define __pyx_n_u_val __pyx_string_tab[2074]
#define __pyx_n_u_value __pyx_string_tab[2075]
#define __pyx_n_u_values __pyx_string_tab[2076]
#define __pyx_n_u_verification_delay __pyx_string_tab[2077]
#define __pyx_n_u_verify_attempt __pyx_string_tab[2078]
#define __pyx_n_u_verify_error __pyx_string_tab[2079]
#define __pyx_n_u_verify_user_activity_during_per __pyx_string_tab[2080]
#define __pyx_n_u_wait_for __pyx_string_tab[2081]
#define __pyx_n_u_wake_detector __pyx_string_tab[2082]
#define __pyx_n_u_wake_stats __pyx_string_tab[2083]
#define __pyx_n_u_wake_time __pyx_string_tab[2084]
#define __pyx_n_u_wake_timestamp __pyx_string_tab[2085]
#define __pyx_n_u_warning __pyx_string_tab[2086]
#define __pyx_n_u_weekly __pyx_string_tab[2087]
#define __pyx_n_u_weekly_exceeded __pyx_string_tab[2088]
#define __pyx_n_u_weekly_limit __pyx_string_tab[2089]
#define __pyx_n_u_weekly_limit_data __pyx_string_tab[2090]
#define __pyx_n_u_weekly_limit_hours __pyx_string_tab[2091]
#define __pyx_n_u_where __pyx_string_tab[2092]
#define __pyx_n_u_win32gui __pyx_string_tab[2093]
#define __pyx_n_u_windows __pyx_string_tab[2094]
#define __pyx_n_u_windows_idle_gap __pyx_string_tab[2095]
#define __pyx_n_u_windows_sleep_or_restart __pyx_string_tab[2096]
#define __pyx_n_u_winreg __pyx_string_tab[2097]
#define __pyx_n_u_within_seconds __pyx_string_tab[2098]
#define __pyx_n_u_work_session_start __pyx_string_tab[2099]
#define __pyx_n_u_work_stop __pyx_string_tab[2100]
#define __pyx_n_u_worked_total_hours_today __pyx_string_tab[2101]
#define __pyx_n_u_worked_total_hours_week __pyx_string_tab[2102]
#define __pyx_n_u_worked_total_hours_week_leaving __pyx_string_tab[2103]
#define __pyx_n_u_write_counter __pyx_string_tab[2104]
#define __pyx_n_u_write_lock __pyx_string_tab[2105]
#define __pyx_n_u_write_text __pyx_string_tab[2106]
#define __pyx_n_u_ws_package_configs __pyx_string_tab[2107]
#define __pyx_n_u_ws_package_controllers_activity __pyx_string_tab[2108]
#define __pyx_n_u_ws_package_controllers_activity_2 __pyx_string_tab[2109]
#define __pyx_n_u_ws_package_controllers_activity_3 __pyx_string_tab[2110]
#define __pyx_n_u_ws_package_controllers_activity_4 __pyx_string_tab[2111]
#define __pyx_n_u_ws_package_controllers_activity_5 __pyx_string_tab[2112]
#define __pyx_n_u_ws_package_controllers_activity_6 __pyx_string_tab[2113]
#define __pyx_n_u_ws_package_controllers_activity_7 __pyx_string_tab[2114]
#define __pyx_n_u_ws_package_controllers_screensho __pyx_string_tab[2115]
#define __pyx_n_u_ws_package_controllers_server_co __pyx_string_tab[2116]
#define __pyx_n_u_ws_package_controllers_status_co __pyx_string_tab[2117]
#define __pyx_n_u_ws_package_entities_activity_ent __pyx_string_tab[2118]
#define __pyx_n_u_ws_package_entities_mode_entity __pyx_string_tab[2119]
#define __pyx_n_u_ws_package_entities_org_entity __pyx_string_tab[2120]
#define __pyx_n_u_ws_package_entities_s3bucket_ent __pyx_string_tab[2121]
#define __pyx_n_u_ws_package_entities_screenshot_e __pyx_string_tab[2122]
#define __pyx_n_u_ws_package_entities_user_entity __pyx_string_tab[2123]
#define __pyx_n_u_ws_package_exceptions_custom_exc __pyx_string_tab[2124]
#define __pyx_n_u_ws_package_log_writer __pyx_string_tab[2125]
#define __pyx_n_u_ws_package_managers __pyx_string_tab[2126]
#define __pyx_n_u_ws_package_models_base __pyx_string_tab[2127]
#define __pyx_n_u_ws_package_monitoring_listeners __pyx_string_tab[2128]
#define __pyx_n_u_ws_package_monitoring_listeners_2 __pyx_string_tab[2129]
#define __pyx_n_u_ws_package_monitoring_time_monit __pyx_string_tab[2130]
#define __pyx_n_u_ws_package_monitoring_windows __pyx_string_tab[2131]
#define __pyx_n_u_ws_package_repositories_activity __pyx_string_tab[2132]
#define __pyx_n_u_ws_package_repositories_activity_2 __pyx_string_tab[2133]
#define __pyx_n_u_ws_package_services_activity_per __pyx_string_tab[2134]
#define __pyx_n_u_ws_package_services_activity_ser __pyx_string_tab[2135]
#define __pyx_n_u_ws_package_services_api_request __pyx_string_tab[2136]
#define __pyx_n_u_ws_package_services_db_writer_se __pyx_string_tab[2137]
#define __pyx_n_u_ws_package_services_mode_service __pyx_string_tab[2138]
#define __pyx_n_u_ws_package_services_user_service __pyx_string_tab[2139]
#define __pyx_n_u_ws_package_services_weekly_limit __pyx_string_tab[2140]
#define __pyx_n_u_ws_package_utils __pyx_string_tab[2141]
#define __pyx_n_u_ws_package_utils_api_log_policy __pyx_string_tab[2142]
#define __pyx_n_u_ws_package_utils_browser_url_det __pyx_string_tab[2143]
#define __pyx_n_u_ws_package_utils_build_mode __pyx_string_tab[2144]
#define __pyx_n_u_ws_package_utils_db_lock_manager __pyx_string_tab[2145]
#define __pyx_n_u_ws_package_utils_db_write_queue __pyx_string_tab[2146]
#define __pyx_n_u_ws_package_utils_desktop_key __pyx_string_tab[2147]
#define __pyx_n_u_ws_package_utils_electron_comm __pyx_string_tab[2148]
#define __pyx_n_u_ws_package_utils_error_codes __pyx_string_tab[2149]
#define __pyx_n_u_ws_package_utils_ipc_server __pyx_string_tab[2150]
#define __pyx_n_u_ws_package_utils_logs __pyx_string_tab[2151]
#define __pyx_n_u_ws_package_utils_s3 __pyx_string_tab[2152]
#define __pyx_n_u_ws_package_utils_system __pyx_string_tab[2153]
#define __pyx_n_u_ws_package_utils_system_wake_det __pyx_string_tab[2154]
#define __pyx_n_u_ws_package_utils_tracker_status __pyx_string_tab[2155]
#define __pyx_n_u_ws_package_utils_user_error_cate __pyx_string_tab[2156]
#define __pyx_n_u_x __pyx_string_tab[2157]
#define __pyx_n_u_zoneinfo __pyx_string_tab[2158]
#define __pyx_kp_b_iso88591_00Fa_3at_Rq_Q_6b_t81G_7_QR_q __pyx_string_tab[2159]
#define __pyx_kp_b_iso88591_00ccmmn_l_F_1_e1_G1_1O_q_1_nA_1 __pyx_string_tab[2160]
#define __pyx_kp_b_iso88591_0H_d_N_b_XYd_6a_N_4r_a_1_A_7_Q __pyx_string_tab[2161]
#define __pyx_kp_b_iso88591_0_2 __pyx_string_tab[2162]
#define __pyx_kp_b_iso88591_1A __pyx_string_tab[2163]
#define __pyx_kp_b_iso88591_1_2 __pyx_string_tab[2164]
#define __pyx_kp_b_iso88591_1_3 __pyx_string_tab[2165]
#define __pyx_kp_b_iso88591_1_HD_S_AQ_aq_83a_hd_1_aq_d_AQ_E __pyx_string_tab[2166]
#define __pyx_kp_b_iso88591_1_t4_8_e1_Ks_t_S_2_fA_ha __pyx_string_tab[2167]
#define __pyx_kp_b_iso88591_1_t5_q_a_A_SSVV __pyx_string_tab[2168]
#define __pyx_kp_b_iso88591_1_t5_q_a_A_YY_eef __pyx_string_tab[2169]
#define __pyx_kp_b_iso88591_2S_S_Q_2S_3b_BnD_1_1 __pyx_string_tab[2170]
#define __pyx_kp_b_iso88591_2_A_Q __pyx_string_tab[2171]
#define __pyx_kp_b_iso88591_3_Q_EQ_hgQ_s_1_S_TTU_s_0_C_SST __pyx_string_tab[2172]
#define __pyx_kp_b_iso88591_4L __pyx_string_tab[2173]
#define __pyx_kp_b_iso88591_4_S_Ja_a_NiWhhkkllzz_e1A_a_oQ_f __pyx_string_tab[2174]
#define __pyx_kp_b_iso88591_6k_q_4_S_M_a_1_Qiq __pyx_string_tab[2175]
#define __pyx_kp_b_iso88591_7_6_C1_1_G1F_1_S_1_S_N_Rq __pyx_string_tab[2176]
#define __pyx_kp_b_iso88591_7_Orrs __pyx_string_tab[2177]
#define __pyx_kp_b_iso88591_7q __pyx_string_tab[2178]
#define __pyx_kp_b_iso88591_7uKq __pyx_string_tab[2179]
#define __pyx_kp_b_iso88591_7y __pyx_string_tab[2180]
#define __pyx_kp_b_iso88591_8 __pyx_string_tab[2181]
#define __pyx_kp_b_iso88591_81_q_B_A_N_q_A_q_31A_q_Kq_Kq_1 __pyx_string_tab[2182]
#define __pyx_kp_b_iso88591_8_2 __pyx_string_tab[2183]
#define __pyx_kp_b_iso88591_9 __pyx_string_tab[2184]
#define __pyx_kp_b_iso88591_9_4s_s_c_1_2T_4_Q_S_1 __pyx_string_tab[2185]
#define __pyx_kp_b_iso88591_9_F_31_7_6_8_2_1_1_wa_a_7_6_gQ __pyx_string_tab[2186]
#define __pyx_kp_b_iso88591_9_k __pyx_string_tab[2187]
#define __pyx_kp_b_iso88591_A __pyx_string_tab[2188]
#define __pyx_kp_b_iso88591_AA___A __pyx_string_tab[2189]
#define __pyx_kp_b_iso88591_A_0 __pyx_string_tab[2190]
#define __pyx_kp_b_iso88591_A_2 __pyx_string_tab[2191]
#define __pyx_kp_b_iso88591_A_4q_1_6_T_1_1A_E_as_Qa_ARr_q_t __pyx_string_tab[2192]
#define __pyx_kp_b_iso88591_A_4q_1_XQ_z_V1A__Cq_E_AYc_A_uA __pyx_string_tab[2193]
#define __pyx_kp_b_iso88591_A_4q_89HA_q_AQ_7_1_s_k_a_G1F_H_W __pyx_string_tab[2194]
#define __pyx_kp_b_iso88591_A_6_A_1_s_6_q_4q_1_G1L_1F_e1_vYa __pyx_string_tab[2195]
#define __pyx_kp_b_iso88591_A_A __pyx_string_tab[2196]
#define __pyx_kp_b_iso88591_A_Kq_L_HKuA_QnG1A_q __pyx_string_tab[2197]
#define __pyx_kp_b_iso88591_A_Zq_r_aq_r_Q_8_A_q_1_8_BTT_ggqq __pyx_string_tab[2198]
#define __pyx_kp_b_iso88591_A_a __pyx_string_tab[2199]
#define __pyx_kp_b_iso88591_A_a_1_T_A_Q_1_a_7_4_3c_9HCvQ_WAT __pyx_string_tab[2200]
#define __pyx_kp_b_iso88591_A_a_7_Q_1_6_4s __pyx_string_tab[2201]
#define __pyx_kp_b_iso88591_A_a_Qo_zQR_s_xwj_1_hit1_e1_I __pyx_string_tab[2202]
#define __pyx_kp_b_iso88591_A_fAQ __pyx_string_tab[2203]
#define __pyx_kp_b_iso88591_A_hit1_AS_G2Q_y_z_G1 __pyx_string_tab[2204]
#define __pyx_kp_b_iso88591_A_hl_5_r_T_hl_1_4x_1_4xxq_F_1_q __pyx_string_tab[2205]
#define __pyx_kp_b_iso88591_A_hl_5_r_z_4q_ha_YYddhhi_q_1_A_A __pyx_string_tab[2206]
#define __pyx_kp_b_iso88591_A_r_E_Bc_r_A_s_Bb_Cq_q __pyx_string_tab[2207]
#define __pyx_kp_b_iso88591_A_t7_6_TAXX_fAQ_a_woQ_4_q_I_4q_A __pyx_string_tab[2208]
#define __pyx_kp_b_iso88591_A_t_haq __pyx_string_tab[2209]
#define __pyx_kp_b_iso88591_A_t_k __pyx_string_tab[2210]
#define __pyx_kp_b_iso88591_B __pyx_string_tab[2211]
#define __pyx_kp_b_iso88591_B_zQR __pyx_string_tab[2212]
#define __pyx_kp_b_iso88591_DDaawwx __pyx_string_tab[2213]
#define __pyx_kp_b_iso88591_I_4_S_A_1_L_z_WX_A_J_1 __pyx_string_tab[2214]
#define __pyx_kp_b_iso88591_J_WX __pyx_string_tab[2215]
#define __pyx_kp_b_iso88591_L8H __pyx_string_tab[2216]
#define __pyx_kp_b_iso88591_LA __pyx_string_tab[2217]
#define __pyx_kp_b_iso88591_LA_4q_1_9C_A_1O1_1_d_1_r_Q_T_1 __pyx_string_tab[2218]
#define __pyx_kp_b_iso88591_Q __pyx_string_tab[2219]
#define __pyx_kp_b_iso88591_Q_4A_q_Zq_t1A_d_1_1_z_381_1_E_9 __pyx_string_tab[2220]
#define __pyx_kp_b_iso88591_Q_FavQ __pyx_string_tab[2221]
#define __pyx_kp_b_iso88591_RRS __pyx_string_tab[2222]
#define __pyx_kp_b_iso88591_RRS_2 __pyx_string_tab[2223]
#define __pyx_kp_b_iso88591_UR_tt_T_T_Z_Z_p_p __pyx_string_tab[2224]
#define __pyx_kp_b_iso88591_UUV __pyx_string_tab[2225]
#define __pyx_kp_b_iso88591__16 __pyx_string_tab[2226]
#define __pyx_kp_b_iso88591__17 __pyx_string_tab[2227]
#define __pyx_kp_b_iso88591__18 __pyx_string_tab[2228]
#define __pyx_kp_b_iso88591__19 __pyx_string_tab[2229]
#define __pyx_kp_b_iso88591__20 __pyx_string_tab[2230]
#define __pyx_kp_b_iso88591__21 __pyx_string_tab[2231]
#define __pyx_kp_b_iso88591__22 __pyx_string_tab[2232]
#define __pyx_kp_b_iso88591__23 __pyx_string_tab[2233]
#define __pyx_kp_b_iso88591_a_2 __pyx_string_tab[2234]
#define __pyx_kp_b_iso88591_a_3 __pyx_string_tab[2235]
#define __pyx_kp_b_iso88591_a_4 __pyx_string_tab[2236]
#define __pyx_kp_b_iso88591_a_5 __pyx_string_tab[2237]
#define __pyx_kp_b_iso88591_a_6 __pyx_string_tab[2238]
#define __pyx_kp_b_iso88591_a_6a_e1 __pyx_string_tab[2239]
#define __pyx_kp_b_iso88591_a_D_c_a_y_S_AXQ __pyx_string_tab[2240]
#define __pyx_kp_b_iso88591_no __pyx_string_tab[2241]
#define __pyx_kp_b_iso88591_oQ __pyx_string_tab[2242]
#define __pyx_kp_b_iso88591_pq __pyx_string_tab[2243]
#define __pyx_kp_b_iso88591_q __pyx_string_tab[2244]
#define __pyx_kp_b_iso88591_q_2 __pyx_string_tab[2245]
#define __pyx_kp_b_iso88591_q_3 __pyx_string_tab[2246]
#define __pyx_kp_b_iso88591_q_A __pyx_string_tab[2247]
#define __pyx_kp_b_iso88591_q_A_q_q __pyx_string_tab[2248]
#define __pyx_kp_b_iso88591_q_q_9_1O1_q_qPQ_1_it1__A_Yd_a_C __pyx_string_tab[2249]
#define __pyx_kp_b_iso88591_q_t3e3d_Q_q_Cr_Rt_z_A_q __pyx_string_tab[2250]
#define __pyx_kp_b_iso88591_s_1_q_q __pyx_string_tab[2251]
#define __pyx_kp_b_iso88591_sst __pyx_string_tab[2252]
#define __pyx_kp_b_iso88591_uIQ __pyx_string_tab[2253]
#define __pyx_kp_b_iso88591_vw __pyx_string_tab[2254]
#define __pyx_kp_b_iso88591_woQ_aq_q_00Fa_A_1_Ja_3_Q_9_1_8 __pyx_string_tab[2255]
#define __pyx_kp_b_iso88591_ww_A __pyx_string_tab[2256]
#define __pyx_float_0_0 __pyx_number_tab[0]
#define __pyx_float_0_1 __pyx_number_tab[1]
#define __pyx_float_0_2 __pyx_number_tab[2]
#define __pyx_float_0_3 __pyx_number_tab[3]
#define __pyx_float_0_5 __pyx_number_tab[4]
#define __pyx_float_1_0 __pyx_number_tab[5]
#define __pyx_float_1_5 __pyx_number_tab[6]
#define __pyx_float_2_0 __pyx_number_tab[7]
#define __pyx_float_3_0 __pyx_number_tab[8]
#define __pyx_float_4_0 __pyx_number_tab[9]
#define __pyx_float_5_0 __pyx_number_tab[10]
#define __pyx_float_6_0 __pyx_number_tab[11]
#define __pyx_float_8_0 __pyx_number_tab[12]
#define __pyx_float_10_0 __pyx_number_tab[13]
#define __pyx_float_60_0 __pyx_number_tab[14]
#define __pyx_float_1000000000_0 __pyx_number_tab[15]
#define __pyx_int_0 __pyx_number_tab[16]
#define __pyx_int_neg_1 __pyx_number_tab[17]
#define __pyx_int_1 __pyx_number_tab[18]
#define __pyx_int_2 __pyx_number_tab[19]
#define __pyx_int_3 __pyx_number_tab[20]
#define __pyx_int_5 __pyx_number_tab[21]
#define __pyx_int_7 __pyx_number_tab[22]
#define __pyx_int_8 __pyx_number_tab[23]
#define __pyx_int_10 __pyx_number_tab[24]
#define __pyx_int_12 __pyx_number_tab[25]
#define __pyx_int_15 __pyx_number_tab[26]
#define __pyx_int_23 __pyx_number_tab[27]
#define __pyx_int_30 __pyx_number_tab[28]
#define __pyx_int_45 __pyx_number_tab[29]
#define __pyx_int_50 __pyx_number_tab[30]
#define __pyx_int_60 __pyx_number_tab[31]
#define __pyx_int_100 __pyx_number_tab[32]
#define __pyx_int_180 __pyx_number_tab[33]
#define __pyx_int_300 __pyx_number_tab[34]
#define __pyx_int_500 __pyx_number_tab[35]
#define __pyx_int_600 __pyx_number_tab[36]
#define __pyx_int_900 __pyx_number_tab[37]
#define __pyx_int_1024 __pyx_number_tab[38]
#define __pyx_int_1800 __pyx_number_tab[39]
#define __pyx_int_3600 __pyx_number_tab[40]
#define __pyx_int_14400 __pyx_number_tab[41]
/* #### Code section: module_state_clear ### */
#if CYTHON_USE_MODULE_STATE
static CYTHON_SMALL_CODE int __pyx_m_clear(PyObject *m) {
  __pyx_mstatetype *clear_module_state = __Pyx_PyModule_GetState(m);
  if (!clear_module_state) return 0;
  Py_CLEAR(clear_module_state->__pyx_d);
  Py_CLEAR(clear_module_state->__pyx_b);
  Py_CLEAR(clear_module_state->__pyx_cython_runtime);
  Py_CLEAR(clear_module_state->__pyx_empty_tuple);
  Py_CLEAR(clear_module_state->__pyx_empty_bytes);
  Py_CLEAR(clear_module_state->__pyx_empty_unicode);
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  __Pyx_State_RemoveModule(NULL);
  #endif
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr);
  Py_CLEAR(clear_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign);
  Py_CLEAR(clear_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign);
  for (int i=0; i<4; ++i) { Py_CLEAR(clear_module_state->__pyx_slice[i]); }
  for (int i=0; i<36; ++i) { Py_CLEAR(clear_module_state->__pyx_tuple[i]); }
  for (int i=0; i<117; ++i) { Py_CLEAR(clear_module_state->__pyx_codeobj_tab[i]); }
  for (int i=0; i<2257; ++i) { Py_CLEAR(clear_module_state->__pyx_string_tab[i]); }
  for (int i=0; i<42; ++i) { Py_CLEAR(clear_module_state->__pyx_number_tab[i]); }
/* #### Code section: module_state_clear_contents ### */
/* CommonTypesMetaclass.module_state_clear */
Py_CLEAR(clear_module_state->__pyx_CommonTypesMetaclassType);

/* Coroutine.module_state_clear */
Py_CLEAR(clear_module_state->__pyx_CoroutineType);
Py_CLEAR(clear_module_state->__pyx_CoroutineAwaitType);

/* CythonFunctionShared.module_state_clear */
Py_CLEAR(clear_module_state->__pyx_CyFunctionType);

/* Generator.module_state_clear */
Py_CLEAR(clear_module_state->__pyx_GeneratorType);

/* AsyncGenerator.module_state_clear */
Py_CLEAR(clear_module_state->__pyx__PyAsyncGenWrappedValueType);
Py_CLEAR(clear_module_state->__pyx__PyAsyncGenASendType);
Py_CLEAR(clear_module_state->__pyx__PyAsyncGenAThrowType);
Py_CLEAR(clear_module_state->__pyx_AsyncGenType);

/* #### Code section: module_state_clear_end ### */
return 0;
}
#endif
/* #### Code section: module_state_traverse ### */
#if CYTHON_USE_MODULE_STATE
static CYTHON_SMALL_CODE int __pyx_m_traverse(PyObject *m, visitproc visit, void *arg) {
  __pyx_mstatetype *traverse_module_state = __Pyx_PyModule_GetState(m);
  if (!traverse_module_state) return 0;
  Py_VISIT(traverse_module_state->__pyx_d);
  Py_VISIT(traverse_module_state->__pyx_b);
  Py_VISIT(traverse_module_state->__pyx_cython_runtime);
  __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_tuple);
  __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_bytes);
  __Pyx_VISIT_CONST(traverse_module_state->__pyx_empty_unicode);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr);
  Py_VISIT(traverse_module_state->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign);
  Py_VISIT(traverse_module_state->__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign);
  for (int i=0; i<4; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_slice[i]); }
  for (int i=0; i<36; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_tuple[i]); }
  for (int i=0; i<117; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_codeobj_tab[i]); }
  for (int i=0; i<2257; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_string_tab[i]); }
  for (int i=0; i<42; ++i) { __Pyx_VISIT_CONST(traverse_module_state->__pyx_number_tab[i]); }
/* #### Code section: module_state_traverse_contents ### */
/* CommonTypesMetaclass.module_state_traverse */
Py_VISIT(traverse_module_state->__pyx_CommonTypesMetaclassType);

/* Coroutine.module_state_traverse */
Py_VISIT(traverse_module_state->__pyx_CoroutineType);
Py_VISIT(traverse_module_state->__pyx_CoroutineAwaitType);

/* CythonFunctionShared.module_state_traverse */
Py_VISIT(traverse_module_state->__pyx_CyFunctionType);

/* Generator.module_state_traverse */
Py_VISIT(traverse_module_state->__pyx_GeneratorType);

/* AsyncGenerator.module_state_traverse */
Py_VISIT(traverse_module_state->__pyx__PyAsyncGenWrappedValueType);
Py_VISIT(traverse_module_state->__pyx__PyAsyncGenASendType);
Py_VISIT(traverse_module_state->__pyx__PyAsyncGenAThrowType);
Py_VISIT(traverse_module_state->__pyx_AsyncGenType);

/* #### Code section: module_state_traverse_end ### */
return 0;
}
#endif
/* #### Code section: module_code ### */

/* "ws_package/controllers/activity_controller.py":100
 * 
 * 
 * def _to_int(val, default=0):             # <<<<<<<<<<<<<<
 *     """Cast an API or DB value to int safely.
 * 
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_1_to_int(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller__to_int, "Cast an API or DB value to int safely.\n\n    API responses and older DB rows may return numeric fields as strings (e.g.\n    \"2\") or omit them entirely (None).  Calling int() on None raises TypeError;\n    calling it on a non-numeric string raises ValueError.  Both are caught here\n    and replaced with `default` (0 = feature disabled) so no caller needs to\n    guard individually.\n\n    Defined at module level (not nested inside methods) so Cython can compile\n    activity_controller.py without closure-related issues.\n    ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_1_to_int = {"_to_int", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_1_to_int, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller__to_int};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_1_to_int(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_val = 0;
  PyObject *__pyx_v_default = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_to_int (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_val,&__pyx_mstate_global->__pyx_n_u_default,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 100, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 100, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 100, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_to_int", 0) < (0)) __PYX_ERR(0, 100, __pyx_L3_error)
      if (!values[1]) values[1] = __Pyx_NewRef(((PyObject *)((PyObject*)__pyx_mstate_global->__pyx_int_0)));
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_to_int", 0, 1, 2, i); __PYX_ERR(0, 100, __pyx_L3_error) }
      }
    } else {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 100, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 100, __pyx_L3_error)
        break;
        default: goto __pyx_L5_argtuple_error;
      }
      if (!values[1]) values[1] = __Pyx_NewRef(((PyObject *)((PyObject*)__pyx_mstate_global->__pyx_int_0)));
    }
    __pyx_v_val = values[0];
    __pyx_v_default = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_to_int", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 100, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller._to_int", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller__to_int(__pyx_self, __pyx_v_val, __pyx_v_default);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller__to_int(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_val, PyObject *__pyx_v_default) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_to_int", 0);

  /* "ws_package/controllers/activity_controller.py":112
 *     activity_controller.py without closure-related issues.
 *     """
 *     try:             # <<<<<<<<<<<<<<
 *         return int(val)
 *     except (TypeError, ValueError):
*/
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":113
 *     """
 *     try:
 *         return int(val)             # <<<<<<<<<<<<<<
 *     except (TypeError, ValueError):
 *         return default
*/
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_4 = __Pyx_PyNumber_Int(__pyx_v_val); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 113, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_r = __pyx_t_4;
      __pyx_t_4 = 0;
      goto __pyx_L7_try_return;

      /* "ws_package/controllers/activity_controller.py":112
 *     activity_controller.py without closure-related issues.
 *     """
 *     try:             # <<<<<<<<<<<<<<
 *         return int(val)
 *     except (TypeError, ValueError):
*/
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "ws_package/controllers/activity_controller.py":114
 *     try:
 *         return int(val)
 *     except (TypeError, ValueError):             # <<<<<<<<<<<<<<
 *         return default
 * 
*/
    __pyx_t_5 = __Pyx_PyErr_ExceptionMatches2(((PyObject *)(((PyTypeObject*)PyExc_TypeError))), ((PyObject *)(((PyTypeObject*)PyExc_ValueError))));
    if (__pyx_t_5) {
      __Pyx_ErrRestore(0,0,0);

      /* "ws_package/controllers/activity_controller.py":115
 *         return int(val)
 *     except (TypeError, ValueError):
 *         return default             # <<<<<<<<<<<<<<
 * 
 * 
*/
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_v_default);
      __pyx_r = __pyx_v_default;
      goto __pyx_L6_except_return;
    }
    goto __pyx_L5_except_error;

    /* "ws_package/controllers/activity_controller.py":112
 *     activity_controller.py without closure-related issues.
 *     """
 *     try:             # <<<<<<<<<<<<<<
 *         return int(val)
 *     except (TypeError, ValueError):
*/
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }

  /* "ws_package/controllers/activity_controller.py":100
 * 
 * 
 * def _to_int(val, default=0):             # <<<<<<<<<<<<<<
 *     """Cast an API or DB value to int safely.
 * 
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller._to_int", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":118
 * 
 * 
 * def _get_electron_comm_lazy():             # <<<<<<<<<<<<<<
 *     """Lazy import to avoid circular imports. Returns the global Electron communicator instance."""
 *     from ws_package.utils.electron_comm import get_electron_comm
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_3_get_electron_comm_lazy(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_2_get_electron_comm_lazy, "Lazy import to avoid circular imports. Returns the global Electron communicator instance.");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_3_get_electron_comm_lazy = {"_get_electron_comm_lazy", (PyCFunction)__pyx_pw_10ws_package_11controllers_19activity_controller_3_get_electron_comm_lazy, METH_NOARGS, __pyx_doc_10ws_package_11controllers_19activity_controller_2_get_electron_comm_lazy};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_3_get_electron_comm_lazy(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_electron_comm_lazy (wrapper)", 0);
  __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_2_get_electron_comm_lazy(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_2_get_electron_comm_lazy(CYTHON_UNUSED PyObject *__pyx_self) {
  PyObject *__pyx_v_get_electron_comm = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  size_t __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_get_electron_comm_lazy", 0);

  /* "ws_package/controllers/activity_controller.py":120
 * def _get_electron_comm_lazy():
 *     """Lazy import to avoid circular imports. Returns the global Electron communicator instance."""
 *     from ws_package.utils.electron_comm import get_electron_comm             # <<<<<<<<<<<<<<
 *     return get_electron_comm()
 * 
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_get_electron_comm};
    __pyx_t_2 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_utils_electron_comm, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 120, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_t_2;
  __Pyx_GOTREF(__pyx_t_1);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_get_electron_comm};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_1, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 120, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      switch (__pyx_t_3) {
        case 0:
        __Pyx_INCREF(__pyx_t_4);
        __pyx_v_get_electron_comm = __pyx_t_4;
        break;
        default:;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":121
 *     """Lazy import to avoid circular imports. Returns the global Electron communicator instance."""
 *     from ws_package.utils.electron_comm import get_electron_comm
 *     return get_electron_comm()             # <<<<<<<<<<<<<<
 * 
 * 
*/
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = NULL;
  __Pyx_INCREF(__pyx_v_get_electron_comm);
  __pyx_t_5 = __pyx_v_get_electron_comm; 
  __pyx_t_6 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
    assert(__pyx_t_4);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
    __pyx_t_6 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "ws_package/controllers/activity_controller.py":118
 * 
 * 
 * def _get_electron_comm_lazy():             # <<<<<<<<<<<<<<
 *     """Lazy import to avoid circular imports. Returns the global Electron communicator instance."""
 *     from ws_package.utils.electron_comm import get_electron_comm
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller._get_electron_comm_lazy", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_get_electron_comm);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":158
 *     """
 * 
 *     def __init__(self, last_count: int) -> None:             # <<<<<<<<<<<<<<
 *         """
 *         Initialize ActivityController with configuration and managers.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_1__init__(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController___init__, "\n        Initialize ActivityController with configuration and managers.\n        \n        Args:\n            last_count (int): Counter value for tracking application restarts.\n                             Used to identify gaps in activity monitoring.\n                             \n        Example:\n            >>> controller = ActivityController(last_count=1)\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_1__init__ = {"__init__", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_1__init__, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController___init__};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_1__init__(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_last_count = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_last_count,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 158, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 158, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 158, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__init__", 0) < (0)) __PYX_ERR(0, 158, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, i); __PYX_ERR(0, 158, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 158, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 158, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    if (__Pyx_PyInt_FromNumber(&values[1], "last_count", 0) < (0)) __PYX_ERR(0, 158, __pyx_L3_error)
    __pyx_v_last_count = ((PyObject*)values[1]);
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__init__", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 158, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_last_count), (&PyLong_Type), 0, "last_count", 2))) __PYX_ERR(0, 158, __pyx_L1_error)
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController___init__(__pyx_self, __pyx_v_self, __pyx_v_last_count);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  goto __pyx_L7_cleaned_up;
  __pyx_L0:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __pyx_L7_cleaned_up:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_last_count) {
  PyObject *__pyx_v_session_gap_minutes = NULL;
  PyObject *__pyx_v_tracker_status = NULL;
  PyObject *__pyx_v_resolve_screenshot_directory = NULL;
  PyObject *__pyx_v_screenshot_folder = NULL;
  PyObject *__pyx_v_e = NULL;
  PyObject *__pyx_v_wake_detector = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  size_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  Py_ssize_t __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_t_18;
  char const *__pyx_t_19;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  char const *__pyx_t_26;
  PyObject *__pyx_t_27 = NULL;
  PyObject *__pyx_t_28 = NULL;
  PyObject *__pyx_t_29 = NULL;
  PyObject *__pyx_t_30 = NULL;
  PyObject *__pyx_t_31 = NULL;
  PyObject *__pyx_t_32 = NULL;
  PyObject *__pyx_t_33 = NULL;
  PyObject *__pyx_t_34 = NULL;
  char const *__pyx_t_35;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__init__", 0);

  /* "ws_package/controllers/activity_controller.py":169
 *             >>> controller = ActivityController(last_count=1)
 *         """
 *         self.last_count: int = last_count             # <<<<<<<<<<<<<<
 *         self._last_counter_bump_at: Optional[datetime.datetime] = None
 *         self._bump_counter_on_next_monitoring_start: bool = False
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count, __pyx_v_last_count) < (0)) __PYX_ERR(0, 169, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":170
 *         """
 *         self.last_count: int = last_count
 *         self._last_counter_bump_at: Optional[datetime.datetime] = None             # <<<<<<<<<<<<<<
 *         self._bump_counter_on_next_monitoring_start: bool = False
 *         # Removed individual db_write_lock - now using centralized db_lock_manager
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_counter_bump_at, Py_None) < (0)) __PYX_ERR(0, 170, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":171
 *         self.last_count: int = last_count
 *         self._last_counter_bump_at: Optional[datetime.datetime] = None
 *         self._bump_counter_on_next_monitoring_start: bool = False             # <<<<<<<<<<<<<<
 *         # Removed individual db_write_lock - now using centralized db_lock_manager
 *         self.appVersion = "7.0"
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_bump_counter_on_next_monitoring, Py_False) < (0)) __PYX_ERR(0, 171, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":173
 *         self._bump_counter_on_next_monitoring_start: bool = False
 *         # Removed individual db_write_lock - now using centralized db_lock_manager
 *         self.appVersion = "7.0"             # <<<<<<<<<<<<<<
 *         self.idle_time_limit_in_seconds: int = 3600  # Default 60 minutes, will be updated from API
 * 
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appVersion, __pyx_mstate_global->__pyx_kp_u_7_0) < (0)) __PYX_ERR(0, 173, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":174
 *         # Removed individual db_write_lock - now using centralized db_lock_manager
 *         self.appVersion = "7.0"
 *         self.idle_time_limit_in_seconds: int = 3600  # Default 60 minutes, will be updated from API             # <<<<<<<<<<<<<<
 * 
 *         # Track background async tasks to prevent silent failures
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_time_limit_in_seconds, __pyx_mstate_global->__pyx_int_3600) < (0)) __PYX_ERR(0, 174, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":178
 *         # Track background async tasks to prevent silent failures
 * 
 *         self._background_tasks = set()             # <<<<<<<<<<<<<<
 *         # Initialize managers
 *         self.timezone_manager = TimezoneManager()
*/
  __pyx_t_1 = PySet_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 178, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_background_tasks, __pyx_t_1) < (0)) __PYX_ERR(0, 178, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":180
 *         self._background_tasks = set()
 *         # Initialize managers
 *         self.timezone_manager = TimezoneManager()             # <<<<<<<<<<<<<<
 *         self.screenshot_manager = ScreenshotManager(last_count)
 *         self.activity_manager = ActivityManager()
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_TimezoneManager); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 180, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
    __pyx_t_4 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_timezone_manager, __pyx_t_1) < (0)) __PYX_ERR(0, 180, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":181
 *         # Initialize managers
 *         self.timezone_manager = TimezoneManager()
 *         self.screenshot_manager = ScreenshotManager(last_count)             # <<<<<<<<<<<<<<
 *         self.activity_manager = ActivityManager()
 *         self.data_manager = DataManager()
*/
  __pyx_t_3 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_ScreenshotManager); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 181, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    assert(__pyx_t_3);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
    __pyx_t_4 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_last_count};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 181, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_manager, __pyx_t_1) < (0)) __PYX_ERR(0, 181, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":182
 *         self.timezone_manager = TimezoneManager()
 *         self.screenshot_manager = ScreenshotManager(last_count)
 *         self.activity_manager = ActivityManager()             # <<<<<<<<<<<<<<
 *         self.data_manager = DataManager()
 * 
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_ActivityManager); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 182, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
    __pyx_t_4 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 182, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_manager, __pyx_t_1) < (0)) __PYX_ERR(0, 182, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":183
 *         self.screenshot_manager = ScreenshotManager(last_count)
 *         self.activity_manager = ActivityManager()
 *         self.data_manager = DataManager()             # <<<<<<<<<<<<<<
 * 
 *         # Initialize services
*/
  __pyx_t_3 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_DataManager); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 183, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    assert(__pyx_t_3);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
    __pyx_t_4 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_data_manager, __pyx_t_1) < (0)) __PYX_ERR(0, 183, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":186
 * 
 *         # Initialize services
 *         self.user_service = UserService()             # <<<<<<<<<<<<<<
 *         self.status_controller = StatusController()
 *         self.fixed_mode = FixedService()
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_UserService); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 186, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
    __pyx_t_4 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 186, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_user_service, __pyx_t_1) < (0)) __PYX_ERR(0, 186, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":187
 *         # Initialize services
 *         self.user_service = UserService()
 *         self.status_controller = StatusController()             # <<<<<<<<<<<<<<
 *         self.fixed_mode = FixedService()
 *         self.activity_service = ActivityService()
*/
  __pyx_t_3 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_StatusController); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 187, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    assert(__pyx_t_3);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
    __pyx_t_4 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 187, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status_controller, __pyx_t_1) < (0)) __PYX_ERR(0, 187, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":188
 *         self.user_service = UserService()
 *         self.status_controller = StatusController()
 *         self.fixed_mode = FixedService()             # <<<<<<<<<<<<<<
 *         self.activity_service = ActivityService()
 *         self.server_controller = ServerController()
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_FixedService); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 188, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
    __pyx_t_4 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 188, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_fixed_mode, __pyx_t_1) < (0)) __PYX_ERR(0, 188, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":189
 *         self.status_controller = StatusController()
 *         self.fixed_mode = FixedService()
 *         self.activity_service = ActivityService()             # <<<<<<<<<<<<<<
 *         self.server_controller = ServerController()
 * 
*/
  __pyx_t_3 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_ActivityService); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 189, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    assert(__pyx_t_3);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
    __pyx_t_4 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 189, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service, __pyx_t_1) < (0)) __PYX_ERR(0, 189, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":190
 *         self.fixed_mode = FixedService()
 *         self.activity_service = ActivityService()
 *         self.server_controller = ServerController()             # <<<<<<<<<<<<<<
 * 
 *         # Configuration
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_ServerController); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 190, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
    __pyx_t_4 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 190, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_server_controller, __pyx_t_1) < (0)) __PYX_ERR(0, 190, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":193
 * 
 *         # Configuration
 *         self.interval: int = 600             # <<<<<<<<<<<<<<
 * 
 *         # Cache for stealth mode API calls to prevent excessive API requests
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval, __pyx_mstate_global->__pyx_int_600) < (0)) __PYX_ERR(0, 193, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":196
 * 
 *         # Cache for stealth mode API calls to prevent excessive API requests
 *         self._last_stealth_api_call: Optional[datetime.datetime] = None             # <<<<<<<<<<<<<<
 *         self._cached_stealth_response: Optional[dict] = None  # Cache the actual response data
 *         self._stealth_api_cache_interval: int = 300  # 5 minutes - only refresh stealth mode every 5 minutes
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_stealth_api_call, Py_None) < (0)) __PYX_ERR(0, 196, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":197
 *         # Cache for stealth mode API calls to prevent excessive API requests
 *         self._last_stealth_api_call: Optional[datetime.datetime] = None
 *         self._cached_stealth_response: Optional[dict] = None  # Cache the actual response data             # <<<<<<<<<<<<<<
 *         self._stealth_api_cache_interval: int = 300  # 5 minutes - only refresh stealth mode every 5 minutes
 *         self.screenshot_interval: int = 1
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_cached_stealth_response, Py_None) < (0)) __PYX_ERR(0, 197, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":198
 *         self._last_stealth_api_call: Optional[datetime.datetime] = None
 *         self._cached_stealth_response: Optional[dict] = None  # Cache the actual response data
 *         self._stealth_api_cache_interval: int = 300  # 5 minutes - only refresh stealth mode every 5 minutes             # <<<<<<<<<<<<<<
 *         self.screenshot_interval: int = 1
 *         self.slot: int = int(self.interval / 60)
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_stealth_api_cache_interval, __pyx_mstate_global->__pyx_int_300) < (0)) __PYX_ERR(0, 198, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":199
 *         self._cached_stealth_response: Optional[dict] = None  # Cache the actual response data
 *         self._stealth_api_cache_interval: int = 300  # 5 minutes - only refresh stealth mode every 5 minutes
 *         self.screenshot_interval: int = 1             # <<<<<<<<<<<<<<
 *         self.slot: int = int(self.interval / 60)
 *         self.appandurlstatus: int = 3
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_interval, __pyx_mstate_global->__pyx_int_1) < (0)) __PYX_ERR(0, 199, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":200
 *         self._stealth_api_cache_interval: int = 300  # 5 minutes - only refresh stealth mode every 5 minutes
 *         self.screenshot_interval: int = 1
 *         self.slot: int = int(self.interval / 60)             # <<<<<<<<<<<<<<
 *         self.appandurlstatus: int = 3
 *         self.app_monitor_interval_seconds: int = 30  # Interval for checking active apps/windows (in seconds)
*/
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyLong_TrueDivideObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_60, 60, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 200, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 200, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_slot, __pyx_t_1) < (0)) __PYX_ERR(0, 200, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":201
 *         self.screenshot_interval: int = 1
 *         self.slot: int = int(self.interval / 60)
 *         self.appandurlstatus: int = 3             # <<<<<<<<<<<<<<
 *         self.app_monitor_interval_seconds: int = 30  # Interval for checking active apps/windows (in seconds)
 *         # Get session gap threshold with graceful fallback (config may not exist)
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus, __pyx_mstate_global->__pyx_int_3) < (0)) __PYX_ERR(0, 201, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":202
 *         self.slot: int = int(self.interval / 60)
 *         self.appandurlstatus: int = 3
 *         self.app_monitor_interval_seconds: int = 30  # Interval for checking active apps/windows (in seconds)             # <<<<<<<<<<<<<<
 *         # Get session gap threshold with graceful fallback (config may not exist)
 *         try:
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_app_monitor_interval_seconds, __pyx_mstate_global->__pyx_int_30) < (0)) __PYX_ERR(0, 202, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":204
 *         self.app_monitor_interval_seconds: int = 30  # Interval for checking active apps/windows (in seconds)
 *         # Get session gap threshold with graceful fallback (config may not exist)
 *         try:             # <<<<<<<<<<<<<<
 *             session_gap_minutes = config('session_gap_threshold_minutes', 'ActivityMonitor', dtype='int')
 *             if session_gap_minutes is None or session_gap_minutes <= 0:
*/
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_7);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":205
 *         # Get session gap threshold with graceful fallback (config may not exist)
 *         try:
 *             session_gap_minutes = config('session_gap_threshold_minutes', 'ActivityMonitor', dtype='int')             # <<<<<<<<<<<<<<
 *             if session_gap_minutes is None or session_gap_minutes <= 0:
 *                 session_gap_minutes = 60  # Default to 1 hour between sessions
*/
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_config); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 205, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_3);
      if (PyDict_SetItem(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_dtype, __pyx_mstate_global->__pyx_n_u_int) < (0)) __PYX_ERR(0, 205, __pyx_L3_error)
      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_mstate_global->__pyx_tuple[0], __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 205, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_v_session_gap_minutes = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "ws_package/controllers/activity_controller.py":206
 *         try:
 *             session_gap_minutes = config('session_gap_threshold_minutes', 'ActivityMonitor', dtype='int')
 *             if session_gap_minutes is None or session_gap_minutes <= 0:             # <<<<<<<<<<<<<<
 *                 session_gap_minutes = 60  # Default to 1 hour between sessions
 *         except (ValueError, TypeError, AttributeError):
*/
      __pyx_t_9 = (__pyx_v_session_gap_minutes == Py_None);
      if (!__pyx_t_9) {
      } else {
        __pyx_t_8 = __pyx_t_9;
        goto __pyx_L10_bool_binop_done;
      }
      __pyx_t_2 = PyObject_RichCompare(__pyx_v_session_gap_minutes, __pyx_mstate_global->__pyx_int_0, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 206, __pyx_L3_error)
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 206, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_8 = __pyx_t_9;
      __pyx_L10_bool_binop_done:;
      if (__pyx_t_8) {

        /* "ws_package/controllers/activity_controller.py":207
 *             session_gap_minutes = config('session_gap_threshold_minutes', 'ActivityMonitor', dtype='int')
 *             if session_gap_minutes is None or session_gap_minutes <= 0:
 *                 session_gap_minutes = 60  # Default to 1 hour between sessions             # <<<<<<<<<<<<<<
 *         except (ValueError, TypeError, AttributeError):
 *             # Config value not found or invalid - use default
*/
        __Pyx_INCREF(__pyx_mstate_global->__pyx_int_60);
        __Pyx_DECREF_SET(__pyx_v_session_gap_minutes, __pyx_mstate_global->__pyx_int_60);

        /* "ws_package/controllers/activity_controller.py":206
 *         try:
 *             session_gap_minutes = config('session_gap_threshold_minutes', 'ActivityMonitor', dtype='int')
 *             if session_gap_minutes is None or session_gap_minutes <= 0:             # <<<<<<<<<<<<<<
 *                 session_gap_minutes = 60  # Default to 1 hour between sessions
 *         except (ValueError, TypeError, AttributeError):
*/
      }

      /* "ws_package/controllers/activity_controller.py":204
 *         self.app_monitor_interval_seconds: int = 30  # Interval for checking active apps/windows (in seconds)
 *         # Get session gap threshold with graceful fallback (config may not exist)
 *         try:             # <<<<<<<<<<<<<<
 *             session_gap_minutes = config('session_gap_threshold_minutes', 'ActivityMonitor', dtype='int')
 *             if session_gap_minutes is None or session_gap_minutes <= 0:
*/
    }
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "ws_package/controllers/activity_controller.py":208
 *             if session_gap_minutes is None or session_gap_minutes <= 0:
 *                 session_gap_minutes = 60  # Default to 1 hour between sessions
 *         except (ValueError, TypeError, AttributeError):             # <<<<<<<<<<<<<<
 *             # Config value not found or invalid - use default
 *             session_gap_minutes = 60  # Default to 1 hour between sessions
*/
    __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_ValueError)))) || __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_TypeError)))) || __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_AttributeError))));
    if (__pyx_t_10) {
      __Pyx_ErrRestore(0,0,0);

      /* "ws_package/controllers/activity_controller.py":210
 *         except (ValueError, TypeError, AttributeError):
 *             # Config value not found or invalid - use default
 *             session_gap_minutes = 60  # Default to 1 hour between sessions             # <<<<<<<<<<<<<<
 *         self.session_gap_threshold_minutes: int = int(session_gap_minutes)
 *         self.session_gap_threshold_seconds: int = session_gap_minutes * 60
*/
      __Pyx_INCREF(__pyx_mstate_global->__pyx_int_60);
      __Pyx_XDECREF_SET(__pyx_v_session_gap_minutes, __pyx_mstate_global->__pyx_int_60);
      goto __pyx_L4_exception_handled;
    }
    goto __pyx_L5_except_error;

    /* "ws_package/controllers/activity_controller.py":204
 *         self.app_monitor_interval_seconds: int = 30  # Interval for checking active apps/windows (in seconds)
 *         # Get session gap threshold with graceful fallback (config may not exist)
 *         try:             # <<<<<<<<<<<<<<
 *             session_gap_minutes = config('session_gap_threshold_minutes', 'ActivityMonitor', dtype='int')
 *             if session_gap_minutes is None or session_gap_minutes <= 0:
*/
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
    __pyx_L8_try_end:;
  }

  /* "ws_package/controllers/activity_controller.py":211
 *             # Config value not found or invalid - use default
 *             session_gap_minutes = 60  # Default to 1 hour between sessions
 *         self.session_gap_threshold_minutes: int = int(session_gap_minutes)             # <<<<<<<<<<<<<<
 *         self.session_gap_threshold_seconds: int = session_gap_minutes * 60
 *         self.s3_screenshot_path: str = config('s3_screenshot_path', 'Sync')
*/
  __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_v_session_gap_minutes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 211, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_session_gap_threshold_minutes, __pyx_t_2) < (0)) __PYX_ERR(0, 211, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":212
 *             session_gap_minutes = 60  # Default to 1 hour between sessions
 *         self.session_gap_threshold_minutes: int = int(session_gap_minutes)
 *         self.session_gap_threshold_seconds: int = session_gap_minutes * 60             # <<<<<<<<<<<<<<
 *         self.s3_screenshot_path: str = config('s3_screenshot_path', 'Sync')
 *         self.s3_logs_path: str = config('s3_logs_path', 'Sync')
*/
  __pyx_t_2 = __Pyx_PyLong_MultiplyObjC(__pyx_v_session_gap_minutes, __pyx_mstate_global->__pyx_int_60, 60, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 212, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_session_gap_threshold_seconds, __pyx_t_2) < (0)) __PYX_ERR(0, 212, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":213
 *         self.session_gap_threshold_minutes: int = int(session_gap_minutes)
 *         self.session_gap_threshold_seconds: int = session_gap_minutes * 60
 *         self.s3_screenshot_path: str = config('s3_screenshot_path', 'Sync')             # <<<<<<<<<<<<<<
 *         self.s3_logs_path: str = config('s3_logs_path', 'Sync')
 *         self.has_on_demand: bool = False
*/
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_config); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_mstate_global->__pyx_tuple[1], NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_s3_screenshot_path, __pyx_t_3) < (0)) __PYX_ERR(0, 213, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "ws_package/controllers/activity_controller.py":214
 *         self.session_gap_threshold_seconds: int = session_gap_minutes * 60
 *         self.s3_screenshot_path: str = config('s3_screenshot_path', 'Sync')
 *         self.s3_logs_path: str = config('s3_logs_path', 'Sync')             # <<<<<<<<<<<<<<
 *         self.has_on_demand: bool = False
 *         # Break status - set from Electron via ws_engine
*/
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_config); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 214, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_mstate_global->__pyx_tuple[2], NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 214, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_s3_logs_path, __pyx_t_2) < (0)) __PYX_ERR(0, 214, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":215
 *         self.s3_screenshot_path: str = config('s3_screenshot_path', 'Sync')
 *         self.s3_logs_path: str = config('s3_logs_path', 'Sync')
 *         self.has_on_demand: bool = False             # <<<<<<<<<<<<<<
 *         # Break status - set from Electron via ws_engine
 *         self.is_break: int = 0
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_has_on_demand, Py_False) < (0)) __PYX_ERR(0, 215, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":217
 *         self.has_on_demand: bool = False
 *         # Break status - set from Electron via ws_engine
 *         self.is_break: int = 0             # <<<<<<<<<<<<<<
 *         self.break_id = 0
 *         self.break_start_time: Optional[datetime.datetime] = None  # Track when current break started
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_is_break, __pyx_mstate_global->__pyx_int_0) < (0)) __PYX_ERR(0, 217, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":218
 *         # Break status - set from Electron via ws_engine
 *         self.is_break: int = 0
 *         self.break_id = 0             # <<<<<<<<<<<<<<
 *         self.break_start_time: Optional[datetime.datetime] = None  # Track when current break started
 *         self.break_project_id: Optional[str] = None  # Store project_id when break starts (for break interval payload)
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_break_id, __pyx_mstate_global->__pyx_int_0) < (0)) __PYX_ERR(0, 218, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":219
 *         self.is_break: int = 0
 *         self.break_id = 0
 *         self.break_start_time: Optional[datetime.datetime] = None  # Track when current break started             # <<<<<<<<<<<<<<
 *         self.break_project_id: Optional[str] = None  # Store project_id when break starts (for break interval payload)
 *         self.break_task_id: Optional[str] = None  # Store task_id when break starts (for break interval payload)
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_break_start_time, Py_None) < (0)) __PYX_ERR(0, 219, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":220
 *         self.break_id = 0
 *         self.break_start_time: Optional[datetime.datetime] = None  # Track when current break started
 *         self.break_project_id: Optional[str] = None  # Store project_id when break starts (for break interval payload)             # <<<<<<<<<<<<<<
 *         self.break_task_id: Optional[str] = None  # Store task_id when break starts (for break interval payload)
 *         self._last_break_queue_flush: Optional[datetime.datetime] = None  # Track last queue flush time
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_break_project_id, Py_None) < (0)) __PYX_ERR(0, 220, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":221
 *         self.break_start_time: Optional[datetime.datetime] = None  # Track when current break started
 *         self.break_project_id: Optional[str] = None  # Store project_id when break starts (for break interval payload)
 *         self.break_task_id: Optional[str] = None  # Store task_id when break starts (for break interval payload)             # <<<<<<<<<<<<<<
 *         self._last_break_queue_flush: Optional[datetime.datetime] = None  # Track last queue flush time
 *         self._last_break_stop_event_time: Optional[datetime.datetime] = None  # Track when break_stop_event was last called to prevent duplicate API calls
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_break_task_id, Py_None) < (0)) __PYX_ERR(0, 221, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":222
 *         self.break_project_id: Optional[str] = None  # Store project_id when break starts (for break interval payload)
 *         self.break_task_id: Optional[str] = None  # Store task_id when break starts (for break interval payload)
 *         self._last_break_queue_flush: Optional[datetime.datetime] = None  # Track last queue flush time             # <<<<<<<<<<<<<<
 *         self._last_break_stop_event_time: Optional[datetime.datetime] = None  # Track when break_stop_event was last called to prevent duplicate API calls
 *         self._break_stop_time: Optional[datetime.datetime] = None  # When break stopped; device loop uses this to trim next interval start so we don't save 17:15-17:20 when stop was 17:17
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_break_queue_flush, Py_None) < (0)) __PYX_ERR(0, 222, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":223
 *         self.break_task_id: Optional[str] = None  # Store task_id when break starts (for break interval payload)
 *         self._last_break_queue_flush: Optional[datetime.datetime] = None  # Track last queue flush time
 *         self._last_break_stop_event_time: Optional[datetime.datetime] = None  # Track when break_stop_event was last called to prevent duplicate API calls             # <<<<<<<<<<<<<<
 *         self._break_stop_time: Optional[datetime.datetime] = None  # When break stopped; device loop uses this to trim next interval start so we don't save 17:15-17:20 when stop was 17:17
 *         self._last_work_stop_time: Optional[datetime.datetime] = None  # Work segment end (last interval end); break start is this + 1s
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_break_stop_event_time, Py_None) < (0)) __PYX_ERR(0, 223, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":224
 *         self._last_break_queue_flush: Optional[datetime.datetime] = None  # Track last queue flush time
 *         self._last_break_stop_event_time: Optional[datetime.datetime] = None  # Track when break_stop_event was last called to prevent duplicate API calls
 *         self._break_stop_time: Optional[datetime.datetime] = None  # When break stopped; device loop uses this to trim next interval start so we don't save 17:15-17:20 when stop was 17:17             # <<<<<<<<<<<<<<
 *         self._last_work_stop_time: Optional[datetime.datetime] = None  # Work segment end (last interval end); break start is this + 1s
 *         self._last_idle_popup_trigger_time: Optional[datetime.datetime] = None  # Track when idle popup was last triggered to prevent duplicates
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_break_stop_time, Py_None) < (0)) __PYX_ERR(0, 224, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":225
 *         self._last_break_stop_event_time: Optional[datetime.datetime] = None  # Track when break_stop_event was last called to prevent duplicate API calls
 *         self._break_stop_time: Optional[datetime.datetime] = None  # When break stopped; device loop uses this to trim next interval start so we don't save 17:15-17:20 when stop was 17:17
 *         self._last_work_stop_time: Optional[datetime.datetime] = None  # Work segment end (last interval end); break start is this + 1s             # <<<<<<<<<<<<<<
 *         self._last_idle_popup_trigger_time: Optional[datetime.datetime] = None  # Track when idle popup was last triggered to prevent duplicates
 *         self._idle_popup_cooldown_seconds: int = 300  # 5 minutes cooldown between idle popup triggers
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_work_stop_time, Py_None) < (0)) __PYX_ERR(0, 225, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":226
 *         self._break_stop_time: Optional[datetime.datetime] = None  # When break stopped; device loop uses this to trim next interval start so we don't save 17:15-17:20 when stop was 17:17
 *         self._last_work_stop_time: Optional[datetime.datetime] = None  # Work segment end (last interval end); break start is this + 1s
 *         self._last_idle_popup_trigger_time: Optional[datetime.datetime] = None  # Track when idle popup was last triggered to prevent duplicates             # <<<<<<<<<<<<<<
 *         self._idle_popup_cooldown_seconds: int = 300  # 5 minutes cooldown between idle popup triggers
 *         self._idle_popup_active: bool = False  # Track if idle popup is currently active
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_idle_popup_trigger_time, Py_None) < (0)) __PYX_ERR(0, 226, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":227
 *         self._last_work_stop_time: Optional[datetime.datetime] = None  # Work segment end (last interval end); break start is this + 1s
 *         self._last_idle_popup_trigger_time: Optional[datetime.datetime] = None  # Track when idle popup was last triggered to prevent duplicates
 *         self._idle_popup_cooldown_seconds: int = 300  # 5 minutes cooldown between idle popup triggers             # <<<<<<<<<<<<<<
 *         self._idle_popup_active: bool = False  # Track if idle popup is currently active
 *         self._idle_popup_triggered_at: Optional[datetime.datetime] = None  # Track when idle popup was triggered (to check if interval started while popup was active)
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_cooldown_seconds, __pyx_mstate_global->__pyx_int_300) < (0)) __PYX_ERR(0, 227, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":228
 *         self._last_idle_popup_trigger_time: Optional[datetime.datetime] = None  # Track when idle popup was last triggered to prevent duplicates
 *         self._idle_popup_cooldown_seconds: int = 300  # 5 minutes cooldown between idle popup triggers
 *         self._idle_popup_active: bool = False  # Track if idle popup is currently active             # <<<<<<<<<<<<<<
 *         self._idle_popup_triggered_at: Optional[datetime.datetime] = None  # Track when idle popup was triggered (to check if interval started while popup was active)
 *         self._last_idle_resolution_time: Optional[datetime.datetime] = None  # Track when last idle period was resolved (Continue/Stop/Reassign) to prevent accumulation across multiple idle periods
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_active, Py_False) < (0)) __PYX_ERR(0, 228, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":229
 *         self._idle_popup_cooldown_seconds: int = 300  # 5 minutes cooldown between idle popup triggers
 *         self._idle_popup_active: bool = False  # Track if idle popup is currently active
 *         self._idle_popup_triggered_at: Optional[datetime.datetime] = None  # Track when idle popup was triggered (to check if interval started while popup was active)             # <<<<<<<<<<<<<<
 *         self._last_idle_resolution_time: Optional[datetime.datetime] = None  # Track when last idle period was resolved (Continue/Stop/Reassign) to prevent accumulation across multiple idle periods
 *         self._api_pause_active: bool = False  # Track if API calls should be paused (for zero activity or idle popup)
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_triggered_at, Py_None) < (0)) __PYX_ERR(0, 229, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":230
 *         self._idle_popup_active: bool = False  # Track if idle popup is currently active
 *         self._idle_popup_triggered_at: Optional[datetime.datetime] = None  # Track when idle popup was triggered (to check if interval started while popup was active)
 *         self._last_idle_resolution_time: Optional[datetime.datetime] = None  # Track when last idle period was resolved (Continue/Stop/Reassign) to prevent accumulation across multiple idle periods             # <<<<<<<<<<<<<<
 *         self._api_pause_active: bool = False  # Track if API calls should be paused (for zero activity or idle popup)
 *         self._api_pause_cycles: int = 0  # Consecutive pause cycles; resets when a push succeeds (max = _MAX_API_PAUSE_CYCLES)
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_idle_resolution_time, Py_None) < (0)) __PYX_ERR(0, 230, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":231
 *         self._idle_popup_triggered_at: Optional[datetime.datetime] = None  # Track when idle popup was triggered (to check if interval started while popup was active)
 *         self._last_idle_resolution_time: Optional[datetime.datetime] = None  # Track when last idle period was resolved (Continue/Stop/Reassign) to prevent accumulation across multiple idle periods
 *         self._api_pause_active: bool = False  # Track if API calls should be paused (for zero activity or idle popup)             # <<<<<<<<<<<<<<
 *         self._api_pause_cycles: int = 0  # Consecutive pause cycles; resets when a push succeeds (max = _MAX_API_PAUSE_CYCLES)
 *         self._MAX_API_PAUSE_CYCLES: int = 3  # After this many consecutive pauses, force a push regardless of idle state
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_api_pause_active, Py_False) < (0)) __PYX_ERR(0, 231, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":232
 *         self._last_idle_resolution_time: Optional[datetime.datetime] = None  # Track when last idle period was resolved (Continue/Stop/Reassign) to prevent accumulation across multiple idle periods
 *         self._api_pause_active: bool = False  # Track if API calls should be paused (for zero activity or idle popup)
 *         self._api_pause_cycles: int = 0  # Consecutive pause cycles; resets when a push succeeds (max = _MAX_API_PAUSE_CYCLES)             # <<<<<<<<<<<<<<
 *         self._MAX_API_PAUSE_CYCLES: int = 3  # After this many consecutive pauses, force a push regardless of idle state
 *         self._idle_popup_timeout_seconds: int = 3600  # 60 minutes timeout for unhandled idle popup (auto-stop)
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_api_pause_cycles, __pyx_mstate_global->__pyx_int_0) < (0)) __PYX_ERR(0, 232, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":233
 *         self._api_pause_active: bool = False  # Track if API calls should be paused (for zero activity or idle popup)
 *         self._api_pause_cycles: int = 0  # Consecutive pause cycles; resets when a push succeeds (max = _MAX_API_PAUSE_CYCLES)
 *         self._MAX_API_PAUSE_CYCLES: int = 3  # After this many consecutive pauses, force a push regardless of idle state             # <<<<<<<<<<<<<<
 *         self._idle_popup_timeout_seconds: int = 3600  # 60 minutes timeout for unhandled idle popup (auto-stop)
 *         self._held_idle_intervals: list = []  # Track held idle intervals (single idle interval held until next non-idle or popup handled)
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_MAX_API_PAUSE_CYCLES, __pyx_mstate_global->__pyx_int_3) < (0)) __PYX_ERR(0, 233, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":234
 *         self._api_pause_cycles: int = 0  # Consecutive pause cycles; resets when a push succeeds (max = _MAX_API_PAUSE_CYCLES)
 *         self._MAX_API_PAUSE_CYCLES: int = 3  # After this many consecutive pauses, force a push regardless of idle state
 *         self._idle_popup_timeout_seconds: int = 3600  # 60 minutes timeout for unhandled idle popup (auto-stop)             # <<<<<<<<<<<<<<
 *         self._held_idle_intervals: list = []  # Track held idle intervals (single idle interval held until next non-idle or popup handled)
 *         # Slot where user handled idle popup / resumed work  only this slot gets minimum activity (not prior idle slots)
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_timeout_seconds, __pyx_mstate_global->__pyx_int_3600) < (0)) __PYX_ERR(0, 234, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":235
 *         self._MAX_API_PAUSE_CYCLES: int = 3  # After this many consecutive pauses, force a push regardless of idle state
 *         self._idle_popup_timeout_seconds: int = 3600  # 60 minutes timeout for unhandled idle popup (auto-stop)
 *         self._held_idle_intervals: list = []  # Track held idle intervals (single idle interval held until next non-idle or popup handled)             # <<<<<<<<<<<<<<
 *         # Slot where user handled idle popup / resumed work  only this slot gets minimum activity (not prior idle slots)
 *         self._idle_resolving_slot: Optional[Tuple[datetime.datetime, datetime.datetime]] = None
*/
  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 235, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_held_idle_intervals, __pyx_t_2) < (0)) __PYX_ERR(0, 235, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":237
 *         self._held_idle_intervals: list = []  # Track held idle intervals (single idle interval held until next non-idle or popup handled)
 *         # Slot where user handled idle popup / resumed work  only this slot gets minimum activity (not prior idle slots)
 *         self._idle_resolving_slot: Optional[Tuple[datetime.datetime, datetime.datetime]] = None             # <<<<<<<<<<<<<<
 * 
 *         # Active app tracking for UI display
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_resolving_slot, Py_None) < (0)) __PYX_ERR(0, 237, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":240
 * 
 *         # Active app tracking for UI display
 *         self._current_active_app: Optional[str] = None             # <<<<<<<<<<<<<<
 *         self._current_active_app_path: Optional[str] = None
 *         self._current_active_app_icon: Optional[str] = None
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_active_app, Py_None) < (0)) __PYX_ERR(0, 240, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":241
 *         # Active app tracking for UI display
 *         self._current_active_app: Optional[str] = None
 *         self._current_active_app_path: Optional[str] = None             # <<<<<<<<<<<<<<
 *         self._current_active_app_icon: Optional[str] = None
 *         self._last_active_app_check_time: Optional[datetime.datetime] = None
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_active_app_path, Py_None) < (0)) __PYX_ERR(0, 241, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":242
 *         self._current_active_app: Optional[str] = None
 *         self._current_active_app_path: Optional[str] = None
 *         self._current_active_app_icon: Optional[str] = None             # <<<<<<<<<<<<<<
 *         self._last_active_app_check_time: Optional[datetime.datetime] = None
 * 
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_active_app_icon, Py_None) < (0)) __PYX_ERR(0, 242, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":243
 *         self._current_active_app_path: Optional[str] = None
 *         self._current_active_app_icon: Optional[str] = None
 *         self._last_active_app_check_time: Optional[datetime.datetime] = None             # <<<<<<<<<<<<<<
 * 
 *         # In-memory tracking to prevent duplicate interval creation with microsecond-different timestamps
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_active_app_check_time, Py_None) < (0)) __PYX_ERR(0, 243, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":247
 *         # In-memory tracking to prevent duplicate interval creation with microsecond-different timestamps
 *         # Stores tuples of (counter, start_date_rounded_to_seconds, end_date_rounded_to_seconds)
 *         self._creating_intervals: set = set()  # Track intervals currently being created             # <<<<<<<<<<<<<<
 *         self._creating_activity_percentages: set = set()  # Track activity percentage records currently being created
 * 
*/
  __pyx_t_2 = PySet_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 247, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_creating_intervals, __pyx_t_2) < (0)) __PYX_ERR(0, 247, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":248
 *         # Stores tuples of (counter, start_date_rounded_to_seconds, end_date_rounded_to_seconds)
 *         self._creating_intervals: set = set()  # Track intervals currently being created
 *         self._creating_activity_percentages: set = set()  # Track activity percentage records currently being created             # <<<<<<<<<<<<<<
 * 
 *         # Time settings
*/
  __pyx_t_2 = PySet_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 248, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_creating_activity_percentages, __pyx_t_2) < (0)) __PYX_ERR(0, 248, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":251
 * 
 *         # Time settings
 *         self.limit_start: datetime.time = datetime.datetime.strptime("00:00:00", "%H:%M:%S").time()             # <<<<<<<<<<<<<<
 *         self.limit_end: datetime.time = datetime.datetime.strptime("23:59:59", "%H:%M:%S").time()
 *         self.no_of_days: List[str] = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
*/
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 251, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 251, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_strptime); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 251, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
  __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_mstate_global->__pyx_tuple[3], NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 251, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __pyx_t_11;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_4 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
    __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_time, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 251, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
  }
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_start, __pyx_t_2) < (0)) __PYX_ERR(0, 251, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":252
 *         # Time settings
 *         self.limit_start: datetime.time = datetime.datetime.strptime("00:00:00", "%H:%M:%S").time()
 *         self.limit_end: datetime.time = datetime.datetime.strptime("23:59:59", "%H:%M:%S").time()             # <<<<<<<<<<<<<<
 *         self.no_of_days: List[str] = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
 * 
*/
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 252, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 252, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_strptime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 252, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_mstate_global->__pyx_tuple[4], NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 252, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_11 = __pyx_t_1;
  __Pyx_INCREF(__pyx_t_11);
  __pyx_t_4 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_11, NULL};
    __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_time, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 252, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
  }
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_end, __pyx_t_2) < (0)) __PYX_ERR(0, 252, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":253
 *         self.limit_start: datetime.time = datetime.datetime.strptime("00:00:00", "%H:%M:%S").time()
 *         self.limit_end: datetime.time = datetime.datetime.strptime("23:59:59", "%H:%M:%S").time()
 *         self.no_of_days: List[str] = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']             # <<<<<<<<<<<<<<
 * 
 *         # State variables
*/
  __pyx_t_2 = PyList_New(7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 253, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_Mon);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_n_u_Mon);
  if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_mstate_global->__pyx_n_u_Mon) != (0)) __PYX_ERR(0, 253, __pyx_L1_error);
  __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_Tue);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_n_u_Tue);
  if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 1, __pyx_mstate_global->__pyx_n_u_Tue) != (0)) __PYX_ERR(0, 253, __pyx_L1_error);
  __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_Wed);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_n_u_Wed);
  if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 2, __pyx_mstate_global->__pyx_n_u_Wed) != (0)) __PYX_ERR(0, 253, __pyx_L1_error);
  __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_Thu);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_n_u_Thu);
  if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 3, __pyx_mstate_global->__pyx_n_u_Thu) != (0)) __PYX_ERR(0, 253, __pyx_L1_error);
  __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_Fri);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_n_u_Fri);
  if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 4, __pyx_mstate_global->__pyx_n_u_Fri) != (0)) __PYX_ERR(0, 253, __pyx_L1_error);
  __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_Sat);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_n_u_Sat);
  if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 5, __pyx_mstate_global->__pyx_n_u_Sat) != (0)) __PYX_ERR(0, 253, __pyx_L1_error);
  __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_Sun);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_n_u_Sun);
  if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 6, __pyx_mstate_global->__pyx_n_u_Sun) != (0)) __PYX_ERR(0, 253, __pyx_L1_error);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_no_of_days, __pyx_t_2) < (0)) __PYX_ERR(0, 253, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":256
 * 
 *         # State variables
 *         self.main_start_date: Optional[datetime.datetime] = None             # <<<<<<<<<<<<<<
 *         self.main_end_date: Optional[datetime.datetime] = None
 *         # When set (after break end), payload "start" for today uses this instead of start_date (new session start time)
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_main_start_date, Py_None) < (0)) __PYX_ERR(0, 256, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":257
 *         # State variables
 *         self.main_start_date: Optional[datetime.datetime] = None
 *         self.main_end_date: Optional[datetime.datetime] = None             # <<<<<<<<<<<<<<
 *         # When set (after break end), payload "start" for today uses this instead of start_date (new session start time)
 *         self.current_session_start_time: Optional[datetime.datetime] = None
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_main_end_date, Py_None) < (0)) __PYX_ERR(0, 257, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":259
 *         self.main_end_date: Optional[datetime.datetime] = None
 *         # When set (after break end), payload "start" for today uses this instead of start_date (new session start time)
 *         self.current_session_start_time: Optional[datetime.datetime] = None             # <<<<<<<<<<<<<<
 *         # Canonical activity/log session start  pinned when empty open session is posted; interval uploads must match
 *         self._activity_log_payload_start: Optional[datetime.datetime] = None
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_session_start_time, Py_None) < (0)) __PYX_ERR(0, 259, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":261
 *         self.current_session_start_time: Optional[datetime.datetime] = None
 *         # Canonical activity/log session start  pinned when empty open session is posted; interval uploads must match
 *         self._activity_log_payload_start: Optional[datetime.datetime] = None             # <<<<<<<<<<<<<<
 * 
 *         # Check persistent tracker status from WebSocket commands
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_log_payload_start, Py_None) < (0)) __PYX_ERR(0, 261, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":264
 * 
 *         # Check persistent tracker status from WebSocket commands
 *         tracker_status = get_tracker_status()             # <<<<<<<<<<<<<<
 *         if tracker_status == 'stop':
 *             self.status: bool = False
*/
  __pyx_t_1 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_get_tracker_status); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 264, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_4 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_11))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_11);
    assert(__pyx_t_1);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_11);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_11, __pyx__function);
    __pyx_t_4 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
    __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_11, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 264, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
  }
  __pyx_v_tracker_status = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":265
 *         # Check persistent tracker status from WebSocket commands
 *         tracker_status = get_tracker_status()
 *         if tracker_status == 'stop':             # <<<<<<<<<<<<<<
 *             self.status: bool = False
 *             self.force_stop = True
*/
  __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_v_tracker_status, __pyx_mstate_global->__pyx_n_u_stop, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 265, __pyx_L1_error)
  if (__pyx_t_8) {

    /* "ws_package/controllers/activity_controller.py":266
 *         tracker_status = get_tracker_status()
 *         if tracker_status == 'stop':
 *             self.status: bool = False             # <<<<<<<<<<<<<<
 *             self.force_stop = True
 *             logger.info("[Tracker] Persistent status is 'stop' - tracking will not start until 'start' command received")
*/
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status, Py_False) < (0)) __PYX_ERR(0, 266, __pyx_L1_error)

    /* "ws_package/controllers/activity_controller.py":267
 *         if tracker_status == 'stop':
 *             self.status: bool = False
 *             self.force_stop = True             # <<<<<<<<<<<<<<
 *             logger.info("[Tracker] Persistent status is 'stop' - tracking will not start until 'start' command received")
 *         else:
*/
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_force_stop, Py_True) < (0)) __PYX_ERR(0, 267, __pyx_L1_error)

    /* "ws_package/controllers/activity_controller.py":268
 *             self.status: bool = False
 *             self.force_stop = True
 *             logger.info("[Tracker] Persistent status is 'stop' - tracking will not start until 'start' command received")             # <<<<<<<<<<<<<<
 *         else:
 *             self.status: bool = True
*/
    __pyx_t_11 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 268, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 268, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_4 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_3);
      assert(__pyx_t_11);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_11);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
      __pyx_t_4 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_11, __pyx_mstate_global->__pyx_kp_u_Tracker_Persistent_status_is_st};
      __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 268, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "ws_package/controllers/activity_controller.py":265
 *         # Check persistent tracker status from WebSocket commands
 *         tracker_status = get_tracker_status()
 *         if tracker_status == 'stop':             # <<<<<<<<<<<<<<
 *             self.status: bool = False
 *             self.force_stop = True
*/
    goto __pyx_L14;
  }

  /* "ws_package/controllers/activity_controller.py":270
 *             logger.info("[Tracker] Persistent status is 'stop' - tracking will not start until 'start' command received")
 *         else:
 *             self.status: bool = True             # <<<<<<<<<<<<<<
 *             self.force_stop = False
 *             logger.info("[Tracker] Persistent status is 'start' - tracking enabled")
*/
  /*else*/ {
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status, Py_True) < (0)) __PYX_ERR(0, 270, __pyx_L1_error)

    /* "ws_package/controllers/activity_controller.py":271
 *         else:
 *             self.status: bool = True
 *             self.force_stop = False             # <<<<<<<<<<<<<<
 *             logger.info("[Tracker] Persistent status is 'start' - tracking enabled")
 * 
*/
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_force_stop, Py_False) < (0)) __PYX_ERR(0, 271, __pyx_L1_error)

    /* "ws_package/controllers/activity_controller.py":272
 *             self.status: bool = True
 *             self.force_stop = False
 *             logger.info("[Tracker] Persistent status is 'start' - tracking enabled")             # <<<<<<<<<<<<<<
 * 
 *         # Keep timezone mismatch separate from generic datetime/time integrity errors.
*/
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 272, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 272, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __pyx_t_4 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
      __pyx_t_4 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Tracker_Persistent_status_is_st_2};
      __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 272, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  }
  __pyx_L14:;

  /* "ws_package/controllers/activity_controller.py":275
 * 
 *         # Keep timezone mismatch separate from generic datetime/time integrity errors.
 *         self._timezone_mismatch = False             # <<<<<<<<<<<<<<
 *         self._datetime_mismatch = False
 *         self._time_error_type = None
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_timezone_mismatch, Py_False) < (0)) __PYX_ERR(0, 275, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":276
 *         # Keep timezone mismatch separate from generic datetime/time integrity errors.
 *         self._timezone_mismatch = False
 *         self._datetime_mismatch = False             # <<<<<<<<<<<<<<
 *         self._time_error_type = None
 * 
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_datetime_mismatch, Py_False) < (0)) __PYX_ERR(0, 276, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":277
 *         self._timezone_mismatch = False
 *         self._datetime_mismatch = False
 *         self._time_error_type = None             # <<<<<<<<<<<<<<
 * 
 *         self.tracking_scenario = None
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_time_error_type, Py_None) < (0)) __PYX_ERR(0, 277, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":279
 *         self._time_error_type = None
 * 
 *         self.tracking_scenario = None             # <<<<<<<<<<<<<<
 *         self.mode = None
 *         self.org_api_timezone = None
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_tracking_scenario, Py_None) < (0)) __PYX_ERR(0, 279, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":280
 * 
 *         self.tracking_scenario = None
 *         self.mode = None             # <<<<<<<<<<<<<<
 *         self.org_api_timezone = None
 *         self.limit_action: Optional[str] = None  # "just_notify" or "stop_timer"
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_mode, Py_None) < (0)) __PYX_ERR(0, 280, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":281
 *         self.tracking_scenario = None
 *         self.mode = None
 *         self.org_api_timezone = None             # <<<<<<<<<<<<<<
 *         self.limit_action: Optional[str] = None  # "just_notify" or "stop_timer"
 *         # From organization settings API; 0=checks ON, 1=checks OFF. None until org settings applied.
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_org_api_timezone, Py_None) < (0)) __PYX_ERR(0, 281, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":282
 *         self.mode = None
 *         self.org_api_timezone = None
 *         self.limit_action: Optional[str] = None  # "just_notify" or "stop_timer"             # <<<<<<<<<<<<<<
 *         # From organization settings API; 0=checks ON, 1=checks OFF. None until org settings applied.
 *         self.timezone_preference: Optional[int] = None
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_action, Py_None) < (0)) __PYX_ERR(0, 282, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":284
 *         self.limit_action: Optional[str] = None  # "just_notify" or "stop_timer"
 *         # From organization settings API; 0=checks ON, 1=checks OFF. None until org settings applied.
 *         self.timezone_preference: Optional[int] = None             # <<<<<<<<<<<<<<
 *         self.limit_stopped_date: Optional[datetime.date] = None  # Track when timer was stopped due to limit
 * 
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_timezone_preference, Py_None) < (0)) __PYX_ERR(0, 284, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":285
 *         # From organization settings API; 0=checks ON, 1=checks OFF. None until org settings applied.
 *         self.timezone_preference: Optional[int] = None
 *         self.limit_stopped_date: Optional[datetime.date] = None  # Track when timer was stopped due to limit             # <<<<<<<<<<<<<<
 * 
 *         # Log upload tracking for more frequent uploads
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_stopped_date, Py_None) < (0)) __PYX_ERR(0, 285, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":288
 * 
 *         # Log upload tracking for more frequent uploads
 *         self.last_log_upload_time: Optional[datetime.datetime] = None             # <<<<<<<<<<<<<<
 *         self.log_upload_interval_minutes: int = 60
 * 
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_log_upload_time, Py_None) < (0)) __PYX_ERR(0, 288, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":289
 *         # Log upload tracking for more frequent uploads
 *         self.last_log_upload_time: Optional[datetime.datetime] = None
 *         self.log_upload_interval_minutes: int = 60             # <<<<<<<<<<<<<<
 * 
 * 
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_log_upload_interval_minutes, __pyx_mstate_global->__pyx_int_60) < (0)) __PYX_ERR(0, 289, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":293
 * 
 *         # Writable screenshot dir (frozen Windows cannot use cwd-relative "screenshots").
 *         from ws_package.utils.system import resolve_screenshot_directory             # <<<<<<<<<<<<<<
 *         screenshot_folder = config('save_dir', 'Screenshot') or "screenshots"
 *         try:
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_resolve_screenshot_directory};
    __pyx_t_7 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_utils_system, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 293, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_7;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_resolve_screenshot_directory};
    __pyx_t_12 = 0; {
      __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_12]); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 293, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      switch (__pyx_t_12) {
        case 0:
        __Pyx_INCREF(__pyx_t_1);
        __pyx_v_resolve_screenshot_directory = __pyx_t_1;
        break;
        default:;
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":294
 *         # Writable screenshot dir (frozen Windows cannot use cwd-relative "screenshots").
 *         from ws_package.utils.system import resolve_screenshot_directory
 *         screenshot_folder = config('save_dir', 'Screenshot') or "screenshots"             # <<<<<<<<<<<<<<
 *         try:
 *             self.save_dir = resolve_screenshot_directory(screenshot_folder)
*/
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_config); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_mstate_global->__pyx_tuple[5], NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 294, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 294, __pyx_L1_error)
  if (!__pyx_t_8) {
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_2 = __pyx_t_3;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L15_bool_binop_done;
  }
  __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_screenshots);
  __pyx_t_2 = __pyx_mstate_global->__pyx_n_u_screenshots;
  __pyx_L15_bool_binop_done:;
  __pyx_v_screenshot_folder = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":295
 *         from ws_package.utils.system import resolve_screenshot_directory
 *         screenshot_folder = config('save_dir', 'Screenshot') or "screenshots"
 *         try:             # <<<<<<<<<<<<<<
 *             self.save_dir = resolve_screenshot_directory(screenshot_folder)
 *         except (PermissionError, OSError) as e:
*/
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_7);
    __Pyx_XGOTREF(__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":296
 *         screenshot_folder = config('save_dir', 'Screenshot') or "screenshots"
 *         try:
 *             self.save_dir = resolve_screenshot_directory(screenshot_folder)             # <<<<<<<<<<<<<<
 *         except (PermissionError, OSError) as e:
 *             logger.error("Failed to create screenshot directory: %s", e)
*/
      __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_v_resolve_screenshot_directory);
      __pyx_t_1 = __pyx_v_resolve_screenshot_directory; 
      __pyx_t_4 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
        assert(__pyx_t_3);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
        __pyx_t_4 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_screenshot_folder};
        __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 296, __pyx_L17_error)
        __Pyx_GOTREF(__pyx_t_2);
      }
      if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_save_dir, __pyx_t_2) < (0)) __PYX_ERR(0, 296, __pyx_L17_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "ws_package/controllers/activity_controller.py":295
 *         from ws_package.utils.system import resolve_screenshot_directory
 *         screenshot_folder = config('save_dir', 'Screenshot') or "screenshots"
 *         try:             # <<<<<<<<<<<<<<
 *             self.save_dir = resolve_screenshot_directory(screenshot_folder)
 *         except (PermissionError, OSError) as e:
*/
    }
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L22_try_end;
    __pyx_L17_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "ws_package/controllers/activity_controller.py":297
 *         try:
 *             self.save_dir = resolve_screenshot_directory(screenshot_folder)
 *         except (PermissionError, OSError) as e:             # <<<<<<<<<<<<<<
 *             logger.error("Failed to create screenshot directory: %s", e)
 *             raise FileSystemError(
*/
    __pyx_t_10 = __Pyx_PyErr_ExceptionMatches2(((PyObject *)(((PyTypeObject*)PyExc_PermissionError))), ((PyObject *)(((PyTypeObject*)PyExc_OSError))));
    if (__pyx_t_10) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_3) < 0) __PYX_ERR(0, 297, __pyx_L19_except_error)
      __Pyx_XGOTREF(__pyx_t_2);
      __Pyx_XGOTREF(__pyx_t_1);
      __Pyx_XGOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_v_e = __pyx_t_1;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":298
 *             self.save_dir = resolve_screenshot_directory(screenshot_folder)
 *         except (PermissionError, OSError) as e:
 *             logger.error("Failed to create screenshot directory: %s", e)             # <<<<<<<<<<<<<<
 *             raise FileSystemError(
 *                 f"Failed to create screenshot directory for folder {screenshot_folder!r}",
*/
        __pyx_t_13 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 298, __pyx_L28_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 298, __pyx_L28_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_15))) {
          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_15);
          assert(__pyx_t_13);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Failed_to_create_screenshot_dire, __pyx_v_e};
          __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 298, __pyx_L28_error)
          __Pyx_GOTREF(__pyx_t_11);
        }
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

        /* "ws_package/controllers/activity_controller.py":299
 *         except (PermissionError, OSError) as e:
 *             logger.error("Failed to create screenshot directory: %s", e)
 *             raise FileSystemError(             # <<<<<<<<<<<<<<
 *                 f"Failed to create screenshot directory for folder {screenshot_folder!r}",
 *                 context={"folder": screenshot_folder, "error": str(e)},
*/
        __pyx_t_15 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_FileSystemError); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 299, __pyx_L28_error)
        __Pyx_GOTREF(__pyx_t_13);

        /* "ws_package/controllers/activity_controller.py":300
 *             logger.error("Failed to create screenshot directory: %s", e)
 *             raise FileSystemError(
 *                 f"Failed to create screenshot directory for folder {screenshot_folder!r}",             # <<<<<<<<<<<<<<
 *                 context={"folder": screenshot_folder, "error": str(e)},
 *             )
*/
        __pyx_t_14 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_screenshot_folder), __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 300, __pyx_L28_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_16 = __Pyx_PyUnicode_Concat(__pyx_mstate_global->__pyx_kp_u_Failed_to_create_screenshot_dire_2, __pyx_t_14); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 300, __pyx_L28_error)
        __Pyx_GOTREF(__pyx_t_16);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

        /* "ws_package/controllers/activity_controller.py":301
 *             raise FileSystemError(
 *                 f"Failed to create screenshot directory for folder {screenshot_folder!r}",
 *                 context={"folder": screenshot_folder, "error": str(e)},             # <<<<<<<<<<<<<<
 *             )
 *         except Exception as e:
*/
        __pyx_t_14 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 301, __pyx_L28_error)
        __Pyx_GOTREF(__pyx_t_14);
        if (PyDict_SetItem(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_folder, __pyx_v_screenshot_folder) < (0)) __PYX_ERR(0, 301, __pyx_L28_error)
        __pyx_t_17 = __Pyx_PyObject_Unicode(__pyx_v_e); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 301, __pyx_L28_error)
        __Pyx_GOTREF(__pyx_t_17);
        if (PyDict_SetItem(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_error, __pyx_t_17) < (0)) __PYX_ERR(0, 301, __pyx_L28_error)
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_13))) {
          __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_13);
          assert(__pyx_t_15);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
          __Pyx_INCREF(__pyx_t_15);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_15, __pyx_t_16};
          __pyx_t_17 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 299, __pyx_L28_error)
          __Pyx_GOTREF(__pyx_t_17);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_context, __pyx_t_14, __pyx_t_17, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 299, __pyx_L28_error)
          __pyx_t_11 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_17);
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 299, __pyx_L28_error)
          __Pyx_GOTREF(__pyx_t_11);
        }
        __Pyx_Raise(__pyx_t_11, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __PYX_ERR(0, 299, __pyx_L28_error)
      }

      /* "ws_package/controllers/activity_controller.py":297
 *         try:
 *             self.save_dir = resolve_screenshot_directory(screenshot_folder)
 *         except (PermissionError, OSError) as e:             # <<<<<<<<<<<<<<
 *             logger.error("Failed to create screenshot directory: %s", e)
 *             raise FileSystemError(
*/
      /*finally:*/ {
        __pyx_L28_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25);
          if ( unlikely(__Pyx_GetException(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22) < 0)) __Pyx_ErrFetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_23);
          __Pyx_XGOTREF(__pyx_t_24);
          __Pyx_XGOTREF(__pyx_t_25);
          __pyx_t_10 = __pyx_lineno; __pyx_t_18 = __pyx_clineno; __pyx_t_19 = __pyx_filename;
          {
            __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_XGIVEREF(__pyx_t_24);
          __Pyx_XGIVEREF(__pyx_t_25);
          __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_24, __pyx_t_25);
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_ErrRestore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
          __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0;
          __pyx_lineno = __pyx_t_10; __pyx_clineno = __pyx_t_18; __pyx_filename = __pyx_t_19;
          goto __pyx_L19_except_error;
        }
      }
    }

    /* "ws_package/controllers/activity_controller.py":303
 *                 context={"folder": screenshot_folder, "error": str(e)},
 *             )
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Unexpected error creating screenshot directory: %s", e)
 *             raise FileSystemError(
*/
    __pyx_t_18 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_18) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_2) < 0) __PYX_ERR(0, 303, __pyx_L19_except_error)
      __Pyx_XGOTREF(__pyx_t_3);
      __Pyx_XGOTREF(__pyx_t_1);
      __Pyx_XGOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __pyx_v_e = __pyx_t_1;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":304
 *             )
 *         except Exception as e:
 *             logger.error("Unexpected error creating screenshot directory: %s", e)             # <<<<<<<<<<<<<<
 *             raise FileSystemError(
 *                 f"Unexpected error creating screenshot directory for folder {screenshot_folder!r}",
*/
        __pyx_t_13 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 304, __pyx_L39_error)
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 304, __pyx_L39_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_14))) {
          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_14);
          assert(__pyx_t_13);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Unexpected_error_creating_screen, __pyx_v_e};
          __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 304, __pyx_L39_error)
          __Pyx_GOTREF(__pyx_t_11);
        }
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

        /* "ws_package/controllers/activity_controller.py":305
 *         except Exception as e:
 *             logger.error("Unexpected error creating screenshot directory: %s", e)
 *             raise FileSystemError(             # <<<<<<<<<<<<<<
 *                 f"Unexpected error creating screenshot directory for folder {screenshot_folder!r}",
 *                 context={"folder": screenshot_folder, "error": str(e)},
*/
        __pyx_t_14 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_FileSystemError); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 305, __pyx_L39_error)
        __Pyx_GOTREF(__pyx_t_13);

        /* "ws_package/controllers/activity_controller.py":306
 *             logger.error("Unexpected error creating screenshot directory: %s", e)
 *             raise FileSystemError(
 *                 f"Unexpected error creating screenshot directory for folder {screenshot_folder!r}",             # <<<<<<<<<<<<<<
 *                 context={"folder": screenshot_folder, "error": str(e)},
 *             )
*/
        __pyx_t_17 = __Pyx_PyObject_FormatSimpleAndDecref(PyObject_Repr(__pyx_v_screenshot_folder), __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 306, __pyx_L39_error)
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_16 = __Pyx_PyUnicode_Concat(__pyx_mstate_global->__pyx_kp_u_Unexpected_error_creating_screen_2, __pyx_t_17); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 306, __pyx_L39_error)
        __Pyx_GOTREF(__pyx_t_16);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

        /* "ws_package/controllers/activity_controller.py":307
 *             raise FileSystemError(
 *                 f"Unexpected error creating screenshot directory for folder {screenshot_folder!r}",
 *                 context={"folder": screenshot_folder, "error": str(e)},             # <<<<<<<<<<<<<<
 *             )
 * 
*/
        __pyx_t_17 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 307, __pyx_L39_error)
        __Pyx_GOTREF(__pyx_t_17);
        if (PyDict_SetItem(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_folder, __pyx_v_screenshot_folder) < (0)) __PYX_ERR(0, 307, __pyx_L39_error)
        __pyx_t_15 = __Pyx_PyObject_Unicode(__pyx_v_e); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 307, __pyx_L39_error)
        __Pyx_GOTREF(__pyx_t_15);
        if (PyDict_SetItem(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_error, __pyx_t_15) < (0)) __PYX_ERR(0, 307, __pyx_L39_error)
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_13))) {
          __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
          assert(__pyx_t_14);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
          __Pyx_INCREF(__pyx_t_14);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_14, __pyx_t_16};
          __pyx_t_15 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 305, __pyx_L39_error)
          __Pyx_GOTREF(__pyx_t_15);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_context, __pyx_t_17, __pyx_t_15, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 305, __pyx_L39_error)
          __pyx_t_11 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_15);
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 305, __pyx_L39_error)
          __Pyx_GOTREF(__pyx_t_11);
        }
        __Pyx_Raise(__pyx_t_11, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __PYX_ERR(0, 305, __pyx_L39_error)
      }

      /* "ws_package/controllers/activity_controller.py":303
 *                 context={"folder": screenshot_folder, "error": str(e)},
 *             )
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Unexpected error creating screenshot directory: %s", e)
 *             raise FileSystemError(
*/
      /*finally:*/ {
        __pyx_L39_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
          if ( unlikely(__Pyx_GetException(&__pyx_t_25, &__pyx_t_24, &__pyx_t_23) < 0)) __Pyx_ErrFetch(&__pyx_t_25, &__pyx_t_24, &__pyx_t_23);
          __Pyx_XGOTREF(__pyx_t_25);
          __Pyx_XGOTREF(__pyx_t_24);
          __Pyx_XGOTREF(__pyx_t_23);
          __Pyx_XGOTREF(__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_20);
          __pyx_t_18 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_26 = __pyx_filename;
          {
            __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_21, __pyx_t_20);
          __Pyx_XGIVEREF(__pyx_t_25);
          __Pyx_XGIVEREF(__pyx_t_24);
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_ErrRestore(__pyx_t_25, __pyx_t_24, __pyx_t_23);
          __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0;
          __pyx_lineno = __pyx_t_18; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_26;
          goto __pyx_L19_except_error;
        }
      }
    }
    goto __pyx_L19_except_error;

    /* "ws_package/controllers/activity_controller.py":295
 *         from ws_package.utils.system import resolve_screenshot_directory
 *         screenshot_folder = config('save_dir', 'Screenshot') or "screenshots"
 *         try:             # <<<<<<<<<<<<<<
 *             self.save_dir = resolve_screenshot_directory(screenshot_folder)
 *         except (PermissionError, OSError) as e:
*/
    __pyx_L19_except_error:;
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_6, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L22_try_end:;
  }

  /* "ws_package/controllers/activity_controller.py":310
 *             )
 * 
 *         self.img_format = config('img_format', 'Screenshot') or 'JPEG'             # <<<<<<<<<<<<<<
 *         self.img_quality = 100
 *         self.blur_intensity = 1
*/
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_config); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_mstate_global->__pyx_tuple[6], NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 310, __pyx_L1_error)
  if (!__pyx_t_8) {
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  } else {
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_2 = __pyx_t_3;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L45_bool_binop_done;
  }
  __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_JPEG);
  __pyx_t_2 = __pyx_mstate_global->__pyx_n_u_JPEG;
  __pyx_L45_bool_binop_done:;
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_img_format, __pyx_t_2) < (0)) __PYX_ERR(0, 310, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":311
 * 
 *         self.img_format = config('img_format', 'Screenshot') or 'JPEG'
 *         self.img_quality = 100             # <<<<<<<<<<<<<<
 *         self.blur_intensity = 1
 *         self.img_prefix = ""
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_img_quality, __pyx_mstate_global->__pyx_int_100) < (0)) __PYX_ERR(0, 311, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":312
 *         self.img_format = config('img_format', 'Screenshot') or 'JPEG'
 *         self.img_quality = 100
 *         self.blur_intensity = 1             # <<<<<<<<<<<<<<
 *         self.img_prefix = ""
 *         self.org_id = None
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_blur_intensity, __pyx_mstate_global->__pyx_int_1) < (0)) __PYX_ERR(0, 312, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":313
 *         self.img_quality = 100
 *         self.blur_intensity = 1
 *         self.img_prefix = ""             # <<<<<<<<<<<<<<
 *         self.org_id = None
 *         self.notification_status = 1
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_img_prefix, __pyx_mstate_global->__pyx_kp_u__2) < (0)) __PYX_ERR(0, 313, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":314
 *         self.blur_intensity = 1
 *         self.img_prefix = ""
 *         self.org_id = None             # <<<<<<<<<<<<<<
 *         self.notification_status = 1
 *         self.start_date = datetime.datetime.now()
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_org_id, Py_None) < (0)) __PYX_ERR(0, 314, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":315
 *         self.img_prefix = ""
 *         self.org_id = None
 *         self.notification_status = 1             # <<<<<<<<<<<<<<
 *         self.start_date = datetime.datetime.now()
 *         # Get current directory with safe fallback for PyInstaller frozen apps
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_notification_status, __pyx_mstate_global->__pyx_int_1) < (0)) __PYX_ERR(0, 315, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":316
 *         self.org_id = None
 *         self.notification_status = 1
 *         self.start_date = datetime.datetime.now()             # <<<<<<<<<<<<<<
 *         # Get current directory with safe fallback for PyInstaller frozen apps
 *         try:
*/
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 316, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 316, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __pyx_t_11;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_4 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
    __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 316, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
  }
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_start_date, __pyx_t_2) < (0)) __PYX_ERR(0, 316, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":318
 *         self.start_date = datetime.datetime.now()
 *         # Get current directory with safe fallback for PyInstaller frozen apps
 *         try:             # <<<<<<<<<<<<<<
 *             self.current_directory = os.getcwd()
 *         except (FileNotFoundError, OSError):
*/
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_7);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":319
 *         # Get current directory with safe fallback for PyInstaller frozen apps
 *         try:
 *             self.current_directory = os.getcwd()             # <<<<<<<<<<<<<<
 *         except (FileNotFoundError, OSError):
 *             # Fallback to Application Support directory or home directory if cwd doesn't exist
*/
      __pyx_t_11 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 319, __pyx_L47_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_getcwd); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 319, __pyx_L47_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_4 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1);
        assert(__pyx_t_11);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
        __pyx_t_4 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_11, NULL};
        __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 319, __pyx_L47_error)
        __Pyx_GOTREF(__pyx_t_2);
      }
      if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_directory, __pyx_t_2) < (0)) __PYX_ERR(0, 319, __pyx_L47_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "ws_package/controllers/activity_controller.py":318
 *         self.start_date = datetime.datetime.now()
 *         # Get current directory with safe fallback for PyInstaller frozen apps
 *         try:             # <<<<<<<<<<<<<<
 *             self.current_directory = os.getcwd()
 *         except (FileNotFoundError, OSError):
*/
    }
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    goto __pyx_L52_try_end;
    __pyx_L47_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "ws_package/controllers/activity_controller.py":320
 *         try:
 *             self.current_directory = os.getcwd()
 *         except (FileNotFoundError, OSError):             # <<<<<<<<<<<<<<
 *             # Fallback to Application Support directory or home directory if cwd doesn't exist
 *             if sys.platform == "darwin":
*/
    __pyx_t_10 = __Pyx_PyErr_ExceptionMatches2(((PyObject *)(((PyTypeObject*)PyExc_FileNotFoundError))), ((PyObject *)(((PyTypeObject*)PyExc_OSError))));
    if (__pyx_t_10) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_11) < 0) __PYX_ERR(0, 320, __pyx_L49_except_error)
      __Pyx_XGOTREF(__pyx_t_2);
      __Pyx_XGOTREF(__pyx_t_1);
      __Pyx_XGOTREF(__pyx_t_11);

      /* "ws_package/controllers/activity_controller.py":322
 *         except (FileNotFoundError, OSError):
 *             # Fallback to Application Support directory or home directory if cwd doesn't exist
 *             if sys.platform == "darwin":             # <<<<<<<<<<<<<<
 *                 self.current_directory = str(Path.home() / "Library/Application Support/Workstatus")
 *             else:
*/
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_sys); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 322, __pyx_L49_except_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 322, __pyx_L49_except_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_darwin, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 322, __pyx_L49_except_error)
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (__pyx_t_8) {

        /* "ws_package/controllers/activity_controller.py":323
 *             # Fallback to Application Support directory or home directory if cwd doesn't exist
 *             if sys.platform == "darwin":
 *                 self.current_directory = str(Path.home() / "Library/Application Support/Workstatus")             # <<<<<<<<<<<<<<
 *             else:
 *                 self.current_directory = str(Path.home())
*/
        __pyx_t_3 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_Path); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 323, __pyx_L49_except_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_home); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 323, __pyx_L49_except_error)
        __Pyx_GOTREF(__pyx_t_17);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_17))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_17);
          assert(__pyx_t_3);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
          __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 323, __pyx_L49_except_error)
          __Pyx_GOTREF(__pyx_t_13);
        }
        __pyx_t_17 = __Pyx_PyNumber_Divide(__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Library_Application_Support_Work); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 323, __pyx_L49_except_error)
        __Pyx_GOTREF(__pyx_t_17);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_13 = __Pyx_PyObject_Unicode(__pyx_t_17); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 323, __pyx_L49_except_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_directory, __pyx_t_13) < (0)) __PYX_ERR(0, 323, __pyx_L49_except_error)
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

        /* "ws_package/controllers/activity_controller.py":322
 *         except (FileNotFoundError, OSError):
 *             # Fallback to Application Support directory or home directory if cwd doesn't exist
 *             if sys.platform == "darwin":             # <<<<<<<<<<<<<<
 *                 self.current_directory = str(Path.home() / "Library/Application Support/Workstatus")
 *             else:
*/
        goto __pyx_L55;
      }

      /* "ws_package/controllers/activity_controller.py":325
 *                 self.current_directory = str(Path.home() / "Library/Application Support/Workstatus")
 *             else:
 *                 self.current_directory = str(Path.home())             # <<<<<<<<<<<<<<
 *         self.system_unique_id = platform.node() if platform.system() == "Windows" else str(guid())
 *         self.Flag = False
*/
      /*else*/ {
        __pyx_t_17 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_Path); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 325, __pyx_L49_except_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_home); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 325, __pyx_L49_except_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_15))) {
          __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_15);
          assert(__pyx_t_17);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
          __Pyx_INCREF(__pyx_t_17);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_17, NULL};
          __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 325, __pyx_L49_except_error)
          __Pyx_GOTREF(__pyx_t_13);
        }
        __pyx_t_15 = __Pyx_PyObject_Unicode(__pyx_t_13); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 325, __pyx_L49_except_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_directory, __pyx_t_15) < (0)) __PYX_ERR(0, 325, __pyx_L49_except_error)
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      }
      __pyx_L55:;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      goto __pyx_L48_exception_handled;
    }
    goto __pyx_L49_except_error;

    /* "ws_package/controllers/activity_controller.py":318
 *         self.start_date = datetime.datetime.now()
 *         # Get current directory with safe fallback for PyInstaller frozen apps
 *         try:             # <<<<<<<<<<<<<<
 *             self.current_directory = os.getcwd()
 *         except (FileNotFoundError, OSError):
*/
    __pyx_L49_except_error:;
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
    goto __pyx_L1_error;
    __pyx_L48_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
    __pyx_L52_try_end:;
  }

  /* "ws_package/controllers/activity_controller.py":326
 *             else:
 *                 self.current_directory = str(Path.home())
 *         self.system_unique_id = platform.node() if platform.system() == "Windows" else str(guid())             # <<<<<<<<<<<<<<
 *         self.Flag = False
 *         self.flag2 = False
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 326, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_system); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 326, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_t_4 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_13))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_13);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
    __pyx_t_4 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_Windows, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 326, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_8) {
    __pyx_t_13 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_node); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_4 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_15))) {
      __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_15);
      assert(__pyx_t_13);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
      __pyx_t_4 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_13, NULL};
      __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 326, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __pyx_t_11 = __pyx_t_1;
    __pyx_t_1 = 0;
  } else {
    __pyx_t_15 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_guid); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_4 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_13))) {
      __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_13);
      assert(__pyx_t_15);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
      __pyx_t_4 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL};
      __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 326, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __pyx_t_13 = __Pyx_PyObject_Unicode(__pyx_t_1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 326, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_11 = __pyx_t_13;
    __pyx_t_13 = 0;
  }
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_system_unique_id, __pyx_t_11) < (0)) __PYX_ERR(0, 326, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "ws_package/controllers/activity_controller.py":327
 *                 self.current_directory = str(Path.home())
 *         self.system_unique_id = platform.node() if platform.system() == "Windows" else str(guid())
 *         self.Flag = False             # <<<<<<<<<<<<<<
 *         self.flag2 = False
 *         # Track processed last min intervals to prevent reprocessing (defensive programming)
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_Flag, Py_False) < (0)) __PYX_ERR(0, 327, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":328
 *         self.system_unique_id = platform.node() if platform.system() == "Windows" else str(guid())
 *         self.Flag = False
 *         self.flag2 = False             # <<<<<<<<<<<<<<
 *         # Track processed last min intervals to prevent reprocessing (defensive programming)
 *         self._processed_last_min_intervals = set()
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_flag2, Py_False) < (0)) __PYX_ERR(0, 328, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":330
 *         self.flag2 = False
 *         # Track processed last min intervals to prevent reprocessing (defensive programming)
 *         self._processed_last_min_intervals = set()             # <<<<<<<<<<<<<<
 * 
 *         # Initialize ScreenshotController
*/
  __pyx_t_11 = PySet_New(0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 330, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_processed_last_min_intervals, __pyx_t_11) < (0)) __PYX_ERR(0, 330, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "ws_package/controllers/activity_controller.py":333
 * 
 *         # Initialize ScreenshotController
 *         self.screenshot_controller = ScreenshotController(             # <<<<<<<<<<<<<<
 *             org_id=self.org_id,
 *             save_dir=self.save_dir,
*/
  __pyx_t_13 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_ScreenshotController); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);

  /* "ws_package/controllers/activity_controller.py":334
 *         # Initialize ScreenshotController
 *         self.screenshot_controller = ScreenshotController(
 *             org_id=self.org_id,             # <<<<<<<<<<<<<<
 *             save_dir=self.save_dir,
 *             img_format=self.img_format,
*/
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_org_id); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 334, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);

  /* "ws_package/controllers/activity_controller.py":335
 *         self.screenshot_controller = ScreenshotController(
 *             org_id=self.org_id,
 *             save_dir=self.save_dir,             # <<<<<<<<<<<<<<
 *             img_format=self.img_format,
 *             img_prefix=self.img_prefix,
*/
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_save_dir); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 335, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "ws_package/controllers/activity_controller.py":336
 *             org_id=self.org_id,
 *             save_dir=self.save_dir,
 *             img_format=self.img_format,             # <<<<<<<<<<<<<<
 *             img_prefix=self.img_prefix,
 *             img_quality=self.img_quality,
*/
  __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_img_format); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 336, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_17);

  /* "ws_package/controllers/activity_controller.py":337
 *             save_dir=self.save_dir,
 *             img_format=self.img_format,
 *             img_prefix=self.img_prefix,             # <<<<<<<<<<<<<<
 *             img_quality=self.img_quality,
 *             blur_intensity=self.blur_intensity,
*/
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_img_prefix); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 337, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "ws_package/controllers/activity_controller.py":338
 *             img_format=self.img_format,
 *             img_prefix=self.img_prefix,
 *             img_quality=self.img_quality,             # <<<<<<<<<<<<<<
 *             blur_intensity=self.blur_intensity,
 *             last_count=self.last_count,
*/
  __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_img_quality); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 338, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);

  /* "ws_package/controllers/activity_controller.py":339
 *             img_prefix=self.img_prefix,
 *             img_quality=self.img_quality,
 *             blur_intensity=self.blur_intensity,             # <<<<<<<<<<<<<<
 *             last_count=self.last_count,
 *             s3_screenshot_path=self.s3_screenshot_path,
*/
  __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_blur_intensity); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 339, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);

  /* "ws_package/controllers/activity_controller.py":340
 *             img_quality=self.img_quality,
 *             blur_intensity=self.blur_intensity,
 *             last_count=self.last_count,             # <<<<<<<<<<<<<<
 *             s3_screenshot_path=self.s3_screenshot_path,
 *             screenshot_interval=self.screenshot_interval,
*/
  __pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 340, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_27);

  /* "ws_package/controllers/activity_controller.py":341
 *             blur_intensity=self.blur_intensity,
 *             last_count=self.last_count,
 *             s3_screenshot_path=self.s3_screenshot_path,             # <<<<<<<<<<<<<<
 *             screenshot_interval=self.screenshot_interval,
 *             interval=self.interval,
*/
  __pyx_t_28 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_s3_screenshot_path); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 341, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_28);

  /* "ws_package/controllers/activity_controller.py":342
 *             last_count=self.last_count,
 *             s3_screenshot_path=self.s3_screenshot_path,
 *             screenshot_interval=self.screenshot_interval,             # <<<<<<<<<<<<<<
 *             interval=self.interval,
 *             limit_start=self.limit_start,
*/
  __pyx_t_29 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_interval); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_29);

  /* "ws_package/controllers/activity_controller.py":343
 *             s3_screenshot_path=self.s3_screenshot_path,
 *             screenshot_interval=self.screenshot_interval,
 *             interval=self.interval,             # <<<<<<<<<<<<<<
 *             limit_start=self.limit_start,
 *             limit_end=self.limit_end,
*/
  __pyx_t_30 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 343, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_30);

  /* "ws_package/controllers/activity_controller.py":344
 *             screenshot_interval=self.screenshot_interval,
 *             interval=self.interval,
 *             limit_start=self.limit_start,             # <<<<<<<<<<<<<<
 *             limit_end=self.limit_end,
 *             no_of_days=self.no_of_days
*/
  __pyx_t_31 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_start); if (unlikely(!__pyx_t_31)) __PYX_ERR(0, 344, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_31);

  /* "ws_package/controllers/activity_controller.py":345
 *             interval=self.interval,
 *             limit_start=self.limit_start,
 *             limit_end=self.limit_end,             # <<<<<<<<<<<<<<
 *             no_of_days=self.no_of_days
 *         )
*/
  __pyx_t_32 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_end); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 345, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_32);

  /* "ws_package/controllers/activity_controller.py":346
 *             limit_start=self.limit_start,
 *             limit_end=self.limit_end,
 *             no_of_days=self.no_of_days             # <<<<<<<<<<<<<<
 *         )
 * 
*/
  __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_no_of_days); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 346, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_33);
  __pyx_t_4 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_1);
    assert(__pyx_t_13);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_13);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
    __pyx_t_4 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 13 : 0)] = {__pyx_t_13, NULL};
    __pyx_t_34 = __Pyx_MakeVectorcallBuilderKwds(13); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 333, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_34);
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_org_id, __pyx_t_15, __pyx_t_34, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 333, __pyx_L1_error)
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_save_dir, __pyx_t_2, __pyx_t_34, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 333, __pyx_L1_error)
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_img_format, __pyx_t_17, __pyx_t_34, __pyx_callargs+1, 2) < (0)) __PYX_ERR(0, 333, __pyx_L1_error)
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_img_prefix, __pyx_t_3, __pyx_t_34, __pyx_callargs+1, 3) < (0)) __PYX_ERR(0, 333, __pyx_L1_error)
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_img_quality, __pyx_t_16, __pyx_t_34, __pyx_callargs+1, 4) < (0)) __PYX_ERR(0, 333, __pyx_L1_error)
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_blur_intensity, __pyx_t_14, __pyx_t_34, __pyx_callargs+1, 5) < (0)) __PYX_ERR(0, 333, __pyx_L1_error)
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_last_count, __pyx_t_27, __pyx_t_34, __pyx_callargs+1, 6) < (0)) __PYX_ERR(0, 333, __pyx_L1_error)
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_s3_screenshot_path, __pyx_t_28, __pyx_t_34, __pyx_callargs+1, 7) < (0)) __PYX_ERR(0, 333, __pyx_L1_error)
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_screenshot_interval, __pyx_t_29, __pyx_t_34, __pyx_callargs+1, 8) < (0)) __PYX_ERR(0, 333, __pyx_L1_error)
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_interval, __pyx_t_30, __pyx_t_34, __pyx_callargs+1, 9) < (0)) __PYX_ERR(0, 333, __pyx_L1_error)
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_limit_start, __pyx_t_31, __pyx_t_34, __pyx_callargs+1, 10) < (0)) __PYX_ERR(0, 333, __pyx_L1_error)
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_limit_end, __pyx_t_32, __pyx_t_34, __pyx_callargs+1, 11) < (0)) __PYX_ERR(0, 333, __pyx_L1_error)
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_no_of_days, __pyx_t_33, __pyx_t_34, __pyx_callargs+1, 12) < (0)) __PYX_ERR(0, 333, __pyx_L1_error)
    __pyx_t_11 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_34);
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
    __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
    __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
    __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
    __Pyx_DECREF(__pyx_t_31); __pyx_t_31 = 0;
    __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0;
    __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
    __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 333, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
  }

  /* "ws_package/controllers/activity_controller.py":333
 * 
 *         # Initialize ScreenshotController
 *         self.screenshot_controller = ScreenshotController(             # <<<<<<<<<<<<<<
 *             org_id=self.org_id,
 *             save_dir=self.save_dir,
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller, __pyx_t_11) < (0)) __PYX_ERR(0, 333, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "ws_package/controllers/activity_controller.py":350
 * 
 *         # Memory and performance monitoring
 *         self.process = psutil.Process()             # <<<<<<<<<<<<<<
 *         self.memory_limit_mb = 500  # Set memory limit
 *         self._memory_check_counter = 0
*/
  __pyx_t_1 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_psutil); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_34);
  __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_Process); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_33);
  __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
  __pyx_t_4 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_33))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_33);
    assert(__pyx_t_1);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
    __pyx_t_4 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
    __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
    if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 350, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
  }
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_process, __pyx_t_11) < (0)) __PYX_ERR(0, 350, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "ws_package/controllers/activity_controller.py":351
 *         # Memory and performance monitoring
 *         self.process = psutil.Process()
 *         self.memory_limit_mb = 500  # Set memory limit             # <<<<<<<<<<<<<<
 *         self._memory_check_counter = 0
 *         self.device_listener = DeviceListener(60)  # 60 seconds = 1 minute
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_memory_limit_mb, __pyx_mstate_global->__pyx_int_500) < (0)) __PYX_ERR(0, 351, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":352
 *         self.process = psutil.Process()
 *         self.memory_limit_mb = 500  # Set memory limit
 *         self._memory_check_counter = 0             # <<<<<<<<<<<<<<
 *         self.device_listener = DeviceListener(60)  # 60 seconds = 1 minute
 * 
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_memory_check_counter, __pyx_mstate_global->__pyx_int_0) < (0)) __PYX_ERR(0, 352, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":353
 *         self.memory_limit_mb = 500  # Set memory limit
 *         self._memory_check_counter = 0
 *         self.device_listener = DeviceListener(60)  # 60 seconds = 1 minute             # <<<<<<<<<<<<<<
 * 
 *         # Project and task IDs from Electron (set when timer starts or changed on running timer)
*/
  __pyx_t_33 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_DeviceListener); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 353, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_1);
    assert(__pyx_t_33);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_33);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
    __pyx_t_4 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_33, __pyx_mstate_global->__pyx_int_60};
    __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 353, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
  }
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_device_listener, __pyx_t_11) < (0)) __PYX_ERR(0, 353, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "ws_package/controllers/activity_controller.py":356
 * 
 *         # Project and task IDs from Electron (set when timer starts or changed on running timer)
 *         self.current_project_id: Optional[str] = None             # <<<<<<<<<<<<<<
 *         self.current_task_id: Optional[str] = None
 *         # When project/task is changed on running timer, segment start = now (used as payload "start" for next send)
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_project_id, Py_None) < (0)) __PYX_ERR(0, 356, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":357
 *         # Project and task IDs from Electron (set when timer starts or changed on running timer)
 *         self.current_project_id: Optional[str] = None
 *         self.current_task_id: Optional[str] = None             # <<<<<<<<<<<<<<
 *         # When project/task is changed on running timer, segment start = now (used as payload "start" for next send)
 *         self.current_segment_start_time: Optional[datetime.datetime] = None
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_task_id, Py_None) < (0)) __PYX_ERR(0, 357, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":359
 *         self.current_task_id: Optional[str] = None
 *         # When project/task is changed on running timer, segment start = now (used as payload "start" for next send)
 *         self.current_segment_start_time: Optional[datetime.datetime] = None             # <<<<<<<<<<<<<<
 *         self._project_switch_in_progress: bool = False
 *         self._session_close_lock = threading.RLock()
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_segment_start_time, Py_None) < (0)) __PYX_ERR(0, 359, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":360
 *         # When project/task is changed on running timer, segment start = now (used as payload "start" for next send)
 *         self.current_segment_start_time: Optional[datetime.datetime] = None
 *         self._project_switch_in_progress: bool = False             # <<<<<<<<<<<<<<
 *         self._session_close_lock = threading.RLock()
 * 
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_project_switch_in_progress, Py_False) < (0)) __PYX_ERR(0, 360, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":361
 *         self.current_segment_start_time: Optional[datetime.datetime] = None
 *         self._project_switch_in_progress: bool = False
 *         self._session_close_lock = threading.RLock()             # <<<<<<<<<<<<<<
 * 
 *         self.user_entity: UserEntity = None
*/
  __pyx_t_1 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_threading); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 361, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_33);
  __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_RLock); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 361, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_34);
  __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
  __pyx_t_4 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_34))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_34);
    assert(__pyx_t_1);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_34);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_34, __pyx__function);
    __pyx_t_4 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
    __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_34, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
    if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 361, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_11);
  }
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_session_close_lock, __pyx_t_11) < (0)) __PYX_ERR(0, 361, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

  /* "ws_package/controllers/activity_controller.py":363
 *         self._session_close_lock = threading.RLock()
 * 
 *         self.user_entity: UserEntity = None             # <<<<<<<<<<<<<<
 *         self._user_entity_for_wake = None  # Store user_entity for wake callback access
 * 
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_user_entity, Py_None) < (0)) __PYX_ERR(0, 363, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":364
 * 
 *         self.user_entity: UserEntity = None
 *         self._user_entity_for_wake = None  # Store user_entity for wake callback access             # <<<<<<<<<<<<<<
 * 
 *         # Register sleep/wake callbacks. On Linux, skip the sleep callback: SystemWakeDetector
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_user_entity_for_wake, Py_None) < (0)) __PYX_ERR(0, 364, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":369
 *         # uses CPU/memory idle heuristics and _check_linux_activity() is a stub (always False),
 *         # so idle desktop time is misreported as sleep and stops pynput listeners.
 *         try:             # <<<<<<<<<<<<<<
 *             wake_detector = get_system_wake_detector()
 *             if wake_detector:
*/
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_7);
    __Pyx_XGOTREF(__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":370
 *         # so idle desktop time is misreported as sleep and stops pynput listeners.
 *         try:
 *             wake_detector = get_system_wake_detector()             # <<<<<<<<<<<<<<
 *             if wake_detector:
 *                 if platform.system() == "Linux":
*/
      __pyx_t_34 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_get_system_wake_detector); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 370, __pyx_L56_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_4 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_34 = PyMethod_GET_SELF(__pyx_t_1);
        assert(__pyx_t_34);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_34);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
        __pyx_t_4 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_34, NULL};
        __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 370, __pyx_L56_error)
        __Pyx_GOTREF(__pyx_t_11);
      }
      __pyx_v_wake_detector = __pyx_t_11;
      __pyx_t_11 = 0;

      /* "ws_package/controllers/activity_controller.py":371
 *         try:
 *             wake_detector = get_system_wake_detector()
 *             if wake_detector:             # <<<<<<<<<<<<<<
 *                 if platform.system() == "Linux":
 *                     logger.info(
*/
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_wake_detector); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 371, __pyx_L56_error)
      if (__pyx_t_8) {

        /* "ws_package/controllers/activity_controller.py":372
 *             wake_detector = get_system_wake_detector()
 *             if wake_detector:
 *                 if platform.system() == "Linux":             # <<<<<<<<<<<<<<
 *                     logger.info(
 *                         "[SLEEP] Skipping device listener sleep callback on Linux "
*/
        __pyx_t_1 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 372, __pyx_L56_error)
        __Pyx_GOTREF(__pyx_t_34);
        __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_system); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 372, __pyx_L56_error)
        __Pyx_GOTREF(__pyx_t_33);
        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_33))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_33);
          assert(__pyx_t_1);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
          __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 372, __pyx_L56_error)
          __Pyx_GOTREF(__pyx_t_11);
        }
        __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_Linux, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 372, __pyx_L56_error)
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        if (__pyx_t_8) {

          /* "ws_package/controllers/activity_controller.py":373
 *             if wake_detector:
 *                 if platform.system() == "Linux":
 *                     logger.info(             # <<<<<<<<<<<<<<
 *                         "[SLEEP] Skipping device listener sleep callback on Linux "
 *                         "(idle-based sleep detection would stop input listeners incorrectly)"
*/
          __pyx_t_33 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 373, __pyx_L56_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 373, __pyx_L56_error)
          __Pyx_GOTREF(__pyx_t_34);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_4 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_34))) {
            __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_34);
            assert(__pyx_t_33);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_34);
            __Pyx_INCREF(__pyx_t_33);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_34, __pyx__function);
            __pyx_t_4 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_33, __pyx_mstate_global->__pyx_kp_u_SLEEP_Skipping_device_listener};
            __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_34, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
            __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
            if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 373, __pyx_L56_error)
            __Pyx_GOTREF(__pyx_t_11);
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

          /* "ws_package/controllers/activity_controller.py":372
 *             wake_detector = get_system_wake_detector()
 *             if wake_detector:
 *                 if platform.system() == "Linux":             # <<<<<<<<<<<<<<
 *                     logger.info(
 *                         "[SLEEP] Skipping device listener sleep callback on Linux "
*/
          goto __pyx_L63;
        }

        /* "ws_package/controllers/activity_controller.py":378
 *                     )
 *                 else:
 *                     wake_detector.register_sleep_callback(             # <<<<<<<<<<<<<<
 *                         "device_listener_sleep",
 *                         self.device_listener.handle_system_sleep
*/
        /*else*/ {
          __pyx_t_34 = __pyx_v_wake_detector;
          __Pyx_INCREF(__pyx_t_34);

          /* "ws_package/controllers/activity_controller.py":380
 *                     wake_detector.register_sleep_callback(
 *                         "device_listener_sleep",
 *                         self.device_listener.handle_system_sleep             # <<<<<<<<<<<<<<
 *                     )
 *                     logger.info("[SLEEP] Registered sleep callback for %s", platform.system())
*/
          __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_device_listener); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 380, __pyx_L56_error)
          __Pyx_GOTREF(__pyx_t_33);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_handle_system_sleep); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 380, __pyx_L56_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
          __pyx_t_4 = 0;
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_34, __pyx_mstate_global->__pyx_n_u_device_listener_sleep, __pyx_t_1};
            __pyx_t_11 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_register_sleep_callback, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 378, __pyx_L56_error)
            __Pyx_GOTREF(__pyx_t_11);
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

          /* "ws_package/controllers/activity_controller.py":382
 *                         self.device_listener.handle_system_sleep
 *                     )
 *                     logger.info("[SLEEP] Registered sleep callback for %s", platform.system())             # <<<<<<<<<<<<<<
 * 
 *                 # Register wake callback to restart listeners
*/
          __pyx_t_1 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 382, __pyx_L56_error)
          __Pyx_GOTREF(__pyx_t_34);
          __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 382, __pyx_L56_error)
          __Pyx_GOTREF(__pyx_t_33);
          __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
          __pyx_t_32 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_31, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_31)) __PYX_ERR(0, 382, __pyx_L56_error)
          __Pyx_GOTREF(__pyx_t_31);
          __pyx_t_30 = __Pyx_PyObject_GetAttrStr(__pyx_t_31, __pyx_mstate_global->__pyx_n_u_system); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 382, __pyx_L56_error)
          __Pyx_GOTREF(__pyx_t_30);
          __Pyx_DECREF(__pyx_t_31); __pyx_t_31 = 0;
          __pyx_t_4 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_30))) {
            __pyx_t_32 = PyMethod_GET_SELF(__pyx_t_30);
            assert(__pyx_t_32);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_30);
            __Pyx_INCREF(__pyx_t_32);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_30, __pyx__function);
            __pyx_t_4 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_32, NULL};
            __pyx_t_34 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_30, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_32); __pyx_t_32 = 0;
            __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
            if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 382, __pyx_L56_error)
            __Pyx_GOTREF(__pyx_t_34);
          }
          __pyx_t_4 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_33))) {
            __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_33);
            assert(__pyx_t_1);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
            __pyx_t_4 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_SLEEP_Registered_sleep_callback, __pyx_t_34};
            __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
            __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
            if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 382, __pyx_L56_error)
            __Pyx_GOTREF(__pyx_t_11);
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
        __pyx_L63:;

        /* "ws_package/controllers/activity_controller.py":385
 * 
 *                 # Register wake callback to restart listeners
 *                 wake_detector.register_wake_callback(             # <<<<<<<<<<<<<<
 *                     "device_listener_wake",
 *                     self.device_listener.handle_system_wake
*/
        __pyx_t_33 = __pyx_v_wake_detector;
        __Pyx_INCREF(__pyx_t_33);

        /* "ws_package/controllers/activity_controller.py":387
 *                 wake_detector.register_wake_callback(
 *                     "device_listener_wake",
 *                     self.device_listener.handle_system_wake             # <<<<<<<<<<<<<<
 *                 )
 *                 logger.info("[WAKE] Registered wake callback for %s", platform.system())
*/
        __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_device_listener); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 387, __pyx_L56_error)
        __Pyx_GOTREF(__pyx_t_34);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_handle_system_wake); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 387, __pyx_L56_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
        __pyx_t_4 = 0;
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_33, __pyx_mstate_global->__pyx_n_u_device_listener_wake, __pyx_t_1};
          __pyx_t_11 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_register_wake_callback, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 385, __pyx_L56_error)
          __Pyx_GOTREF(__pyx_t_11);
        }
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

        /* "ws_package/controllers/activity_controller.py":389
 *                     self.device_listener.handle_system_wake
 *                 )
 *                 logger.info("[WAKE] Registered wake callback for %s", platform.system())             # <<<<<<<<<<<<<<
 * 
 *                 # Register wake callback to update S3 bucket config if new day
*/
        __pyx_t_1 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 389, __pyx_L56_error)
        __Pyx_GOTREF(__pyx_t_33);
        __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 389, __pyx_L56_error)
        __Pyx_GOTREF(__pyx_t_34);
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
        __pyx_t_30 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_32, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 389, __pyx_L56_error)
        __Pyx_GOTREF(__pyx_t_32);
        __pyx_t_31 = __Pyx_PyObject_GetAttrStr(__pyx_t_32, __pyx_mstate_global->__pyx_n_u_system); if (unlikely(!__pyx_t_31)) __PYX_ERR(0, 389, __pyx_L56_error)
        __Pyx_GOTREF(__pyx_t_31);
        __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_31))) {
          __pyx_t_30 = PyMethod_GET_SELF(__pyx_t_31);
          assert(__pyx_t_30);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_31);
          __Pyx_INCREF(__pyx_t_30);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_31, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_30, NULL};
          __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_31, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_30); __pyx_t_30 = 0;
          __Pyx_DECREF(__pyx_t_31); __pyx_t_31 = 0;
          if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 389, __pyx_L56_error)
          __Pyx_GOTREF(__pyx_t_33);
        }
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_34))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_34);
          assert(__pyx_t_1);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_34);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_34, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_WAKE_Registered_wake_callback_f, __pyx_t_33};
          __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_34, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
          __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 389, __pyx_L56_error)
          __Pyx_GOTREF(__pyx_t_11);
        }
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

        /* "ws_package/controllers/activity_controller.py":392
 * 
 *                 # Register wake callback to update S3 bucket config if new day
 *                 wake_detector.register_wake_callback(             # <<<<<<<<<<<<<<
 *                     "s3_bucket_update_wake",
 *                     self._handle_wake_s3_update
*/
        __pyx_t_34 = __pyx_v_wake_detector;
        __Pyx_INCREF(__pyx_t_34);

        /* "ws_package/controllers/activity_controller.py":394
 *                 wake_detector.register_wake_callback(
 *                     "s3_bucket_update_wake",
 *                     self._handle_wake_s3_update             # <<<<<<<<<<<<<<
 *                 )
 *                 logger.info("[WAKE] Registered S3 bucket update wake callback for %s", platform.system())
*/
        __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_handle_wake_s3_update); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 394, __pyx_L56_error)
        __Pyx_GOTREF(__pyx_t_33);
        __pyx_t_4 = 0;
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_34, __pyx_mstate_global->__pyx_n_u_s3_bucket_update_wake, __pyx_t_33};
          __pyx_t_11 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_register_wake_callback, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 392, __pyx_L56_error)
          __Pyx_GOTREF(__pyx_t_11);
        }
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

        /* "ws_package/controllers/activity_controller.py":396
 *                     self._handle_wake_s3_update
 *                 )
 *                 logger.info("[WAKE] Registered S3 bucket update wake callback for %s", platform.system())             # <<<<<<<<<<<<<<
 * 
 *                 wake_detector.register_wake_callback(
*/
        __pyx_t_33 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 396, __pyx_L56_error)
        __Pyx_GOTREF(__pyx_t_34);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 396, __pyx_L56_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
        __pyx_t_31 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_30, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 396, __pyx_L56_error)
        __Pyx_GOTREF(__pyx_t_30);
        __pyx_t_32 = __Pyx_PyObject_GetAttrStr(__pyx_t_30, __pyx_mstate_global->__pyx_n_u_system); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 396, __pyx_L56_error)
        __Pyx_GOTREF(__pyx_t_32);
        __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_32))) {
          __pyx_t_31 = PyMethod_GET_SELF(__pyx_t_32);
          assert(__pyx_t_31);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_32);
          __Pyx_INCREF(__pyx_t_31);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_32, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_31, NULL};
          __pyx_t_34 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_32, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_31); __pyx_t_31 = 0;
          __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0;
          if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 396, __pyx_L56_error)
          __Pyx_GOTREF(__pyx_t_34);
        }
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_1);
          assert(__pyx_t_33);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_33);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_33, __pyx_mstate_global->__pyx_kp_u_WAKE_Registered_S3_bucket_updat, __pyx_t_34};
          __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
          __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 396, __pyx_L56_error)
          __Pyx_GOTREF(__pyx_t_11);
        }
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

        /* "ws_package/controllers/activity_controller.py":398
 *                 logger.info("[WAKE] Registered S3 bucket update wake callback for %s", platform.system())
 * 
 *                 wake_detector.register_wake_callback(             # <<<<<<<<<<<<<<
 *                     "activity_session_wake",
 *                     self._handle_wake_session_counter,
*/
        __pyx_t_1 = __pyx_v_wake_detector;
        __Pyx_INCREF(__pyx_t_1);

        /* "ws_package/controllers/activity_controller.py":400
 *                 wake_detector.register_wake_callback(
 *                     "activity_session_wake",
 *                     self._handle_wake_session_counter,             # <<<<<<<<<<<<<<
 *                 )
 *                 logger.info("[WAKE] Registered session counter wake callback for %s", platform.system())
*/
        __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_handle_wake_session_counter); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 400, __pyx_L56_error)
        __Pyx_GOTREF(__pyx_t_34);
        __pyx_t_4 = 0;
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_mstate_global->__pyx_n_u_activity_session_wake, __pyx_t_34};
          __pyx_t_11 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_register_wake_callback, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 398, __pyx_L56_error)
          __Pyx_GOTREF(__pyx_t_11);
        }
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

        /* "ws_package/controllers/activity_controller.py":402
 *                     self._handle_wake_session_counter,
 *                 )
 *                 logger.info("[WAKE] Registered session counter wake callback for %s", platform.system())             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             logger.warning("Could not register sleep/wake callbacks: %s", e)
*/
        __pyx_t_34 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 402, __pyx_L56_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 402, __pyx_L56_error)
        __Pyx_GOTREF(__pyx_t_33);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_32 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_31, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_31)) __PYX_ERR(0, 402, __pyx_L56_error)
        __Pyx_GOTREF(__pyx_t_31);
        __pyx_t_30 = __Pyx_PyObject_GetAttrStr(__pyx_t_31, __pyx_mstate_global->__pyx_n_u_system); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 402, __pyx_L56_error)
        __Pyx_GOTREF(__pyx_t_30);
        __Pyx_DECREF(__pyx_t_31); __pyx_t_31 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_30))) {
          __pyx_t_32 = PyMethod_GET_SELF(__pyx_t_30);
          assert(__pyx_t_32);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_30);
          __Pyx_INCREF(__pyx_t_32);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_30, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_32, NULL};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_30, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_32); __pyx_t_32 = 0;
          __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 402, __pyx_L56_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_33))) {
          __pyx_t_34 = PyMethod_GET_SELF(__pyx_t_33);
          assert(__pyx_t_34);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
          __Pyx_INCREF(__pyx_t_34);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_34, __pyx_mstate_global->__pyx_kp_u_WAKE_Registered_session_counter, __pyx_t_1};
          __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 402, __pyx_L56_error)
          __Pyx_GOTREF(__pyx_t_11);
        }
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

        /* "ws_package/controllers/activity_controller.py":371
 *         try:
 *             wake_detector = get_system_wake_detector()
 *             if wake_detector:             # <<<<<<<<<<<<<<
 *                 if platform.system() == "Linux":
 *                     logger.info(
*/
      }

      /* "ws_package/controllers/activity_controller.py":369
 *         # uses CPU/memory idle heuristics and _check_linux_activity() is a stub (always False),
 *         # so idle desktop time is misreported as sleep and stops pynput listeners.
 *         try:             # <<<<<<<<<<<<<<
 *             wake_detector = get_system_wake_detector()
 *             if wake_detector:
*/
    }
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    goto __pyx_L61_try_end;
    __pyx_L56_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
    __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
    __Pyx_XDECREF(__pyx_t_29); __pyx_t_29 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_30); __pyx_t_30 = 0;
    __Pyx_XDECREF(__pyx_t_31); __pyx_t_31 = 0;
    __Pyx_XDECREF(__pyx_t_32); __pyx_t_32 = 0;
    __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
    __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;

    /* "ws_package/controllers/activity_controller.py":403
 *                 )
 *                 logger.info("[WAKE] Registered session counter wake callback for %s", platform.system())
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.warning("Could not register sleep/wake callbacks: %s", e)
 * 
*/
    __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_10) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_11, &__pyx_t_33, &__pyx_t_1) < 0) __PYX_ERR(0, 403, __pyx_L58_except_error)
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_33);
      __Pyx_XGOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_33);
      __pyx_v_e = __pyx_t_33;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":404
 *                 logger.info("[WAKE] Registered session counter wake callback for %s", platform.system())
 *         except Exception as e:
 *             logger.warning("Could not register sleep/wake callbacks: %s", e)             # <<<<<<<<<<<<<<
 * 
 *     def _handle_wake_session_counter(self) -> None:
*/
        __pyx_t_30 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_32, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 404, __pyx_L69_error)
        __Pyx_GOTREF(__pyx_t_32);
        __pyx_t_31 = __Pyx_PyObject_GetAttrStr(__pyx_t_32, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_31)) __PYX_ERR(0, 404, __pyx_L69_error)
        __Pyx_GOTREF(__pyx_t_31);
        __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_31))) {
          __pyx_t_30 = PyMethod_GET_SELF(__pyx_t_31);
          assert(__pyx_t_30);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_31);
          __Pyx_INCREF(__pyx_t_30);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_31, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_30, __pyx_mstate_global->__pyx_kp_u_Could_not_register_sleep_wake_ca, __pyx_v_e};
          __pyx_t_34 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_31, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_30); __pyx_t_30 = 0;
          __Pyx_DECREF(__pyx_t_31); __pyx_t_31 = 0;
          if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 404, __pyx_L69_error)
          __Pyx_GOTREF(__pyx_t_34);
        }
        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
      }

      /* "ws_package/controllers/activity_controller.py":403
 *                 )
 *                 logger.info("[WAKE] Registered session counter wake callback for %s", platform.system())
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.warning("Could not register sleep/wake callbacks: %s", e)
 * 
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
          goto __pyx_L70;
        }
        __pyx_L69_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
          __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
          __Pyx_XDECREF(__pyx_t_29); __pyx_t_29 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_30); __pyx_t_30 = 0;
          __Pyx_XDECREF(__pyx_t_31); __pyx_t_31 = 0;
          __Pyx_XDECREF(__pyx_t_32); __pyx_t_32 = 0;
          __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25);
          if ( unlikely(__Pyx_GetException(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22) < 0)) __Pyx_ErrFetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_23);
          __Pyx_XGOTREF(__pyx_t_24);
          __Pyx_XGOTREF(__pyx_t_25);
          __pyx_t_10 = __pyx_lineno; __pyx_t_18 = __pyx_clineno; __pyx_t_35 = __pyx_filename;
          {
            __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_XGIVEREF(__pyx_t_24);
          __Pyx_XGIVEREF(__pyx_t_25);
          __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_24, __pyx_t_25);
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_ErrRestore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
          __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0;
          __pyx_lineno = __pyx_t_10; __pyx_clineno = __pyx_t_18; __pyx_filename = __pyx_t_35;
          goto __pyx_L58_except_error;
        }
        __pyx_L70:;
      }
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L57_exception_handled;
    }
    goto __pyx_L58_except_error;

    /* "ws_package/controllers/activity_controller.py":369
 *         # uses CPU/memory idle heuristics and _check_linux_activity() is a stub (always False),
 *         # so idle desktop time is misreported as sleep and stops pynput listeners.
 *         try:             # <<<<<<<<<<<<<<
 *             wake_detector = get_system_wake_detector()
 *             if wake_detector:
*/
    __pyx_L58_except_error:;
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_6, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L57_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_6, __pyx_t_5);
    __pyx_L61_try_end:;
  }

  /* "ws_package/controllers/activity_controller.py":158
 *     """
 * 
 *     def __init__(self, last_count: int) -> None:             # <<<<<<<<<<<<<<
 *         """
 *         Initialize ActivityController with configuration and managers.
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_27);
  __Pyx_XDECREF(__pyx_t_28);
  __Pyx_XDECREF(__pyx_t_29);
  __Pyx_XDECREF(__pyx_t_30);
  __Pyx_XDECREF(__pyx_t_31);
  __Pyx_XDECREF(__pyx_t_32);
  __Pyx_XDECREF(__pyx_t_33);
  __Pyx_XDECREF(__pyx_t_34);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_session_gap_minutes);
  __Pyx_XDECREF(__pyx_v_tracker_status);
  __Pyx_XDECREF(__pyx_v_resolve_screenshot_directory);
  __Pyx_XDECREF(__pyx_v_screenshot_folder);
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XDECREF(__pyx_v_wake_detector);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":406
 *             logger.warning("Could not register sleep/wake callbacks: %s", e)
 * 
 *     def _handle_wake_session_counter(self) -> None:             # <<<<<<<<<<<<<<
 *         """After system sleep, next timer/monitoring start must use a new counter."""
 *         self._bump_counter_on_next_monitoring_start = True
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_3_handle_wake_session_counter(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_2_handle_wake_session_counter, "After system sleep, next timer/monitoring start must use a new counter.");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_3_handle_wake_session_counter = {"_handle_wake_session_counter", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_3_handle_wake_session_counter, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_2_handle_wake_session_counter};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_3_handle_wake_session_counter(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[1] = {0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_handle_wake_session_counter (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 406, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 406, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_handle_wake_session_counter", 0) < (0)) __PYX_ERR(0, 406, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_handle_wake_session_counter", 1, 1, 1, i); __PYX_ERR(0, 406, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 1)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 406, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_handle_wake_session_counter", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 406, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._handle_wake_session_counter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_2_handle_wake_session_counter(__pyx_self, __pyx_v_self);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_2_handle_wake_session_counter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_handle_wake_session_counter", 0);

  /* "ws_package/controllers/activity_controller.py":408
 *     def _handle_wake_session_counter(self) -> None:
 *         """After system sleep, next timer/monitoring start must use a new counter."""
 *         self._bump_counter_on_next_monitoring_start = True             # <<<<<<<<<<<<<<
 *         logger.info(
 *             "[WAKE] System wake  counter will increment on next monitoring start "
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_bump_counter_on_next_monitoring, Py_True) < (0)) __PYX_ERR(0, 408, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":409
 *         """After system sleep, next timer/monitoring start must use a new counter."""
 *         self._bump_counter_on_next_monitoring_start = True
 *         logger.info(             # <<<<<<<<<<<<<<
 *             "[WAKE] System wake  counter will increment on next monitoring start "
 *             "(stopsleepstart and missed-stop cases)"
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 409, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 409, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_WAKE_System_wake_counter_will_i};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 409, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":406
 *             logger.warning("Could not register sleep/wake callbacks: %s", e)
 * 
 *     def _handle_wake_session_counter(self) -> None:             # <<<<<<<<<<<<<<
 *         """After system sleep, next timer/monitoring start must use a new counter."""
 *         self._bump_counter_on_next_monitoring_start = True
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._handle_wake_session_counter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":414
 *         )
 * 
 *     def _get_electron_comm(self):             # <<<<<<<<<<<<<<
 *         """Return the global Electron communicator instance (lazy-loaded)."""
 *         return _get_electron_comm_lazy()
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_5_get_electron_comm(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_4_get_electron_comm, "Return the global Electron communicator instance (lazy-loaded).");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_5_get_electron_comm = {"_get_electron_comm", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_5_get_electron_comm, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_4_get_electron_comm};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_5_get_electron_comm(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  CYTHON_UNUSED PyObject *__pyx_v_self = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[1] = {0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_electron_comm (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 414, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 414, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_get_electron_comm", 0) < (0)) __PYX_ERR(0, 414, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_get_electron_comm", 1, 1, 1, i); __PYX_ERR(0, 414, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 1)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 414, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_electron_comm", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 414, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._get_electron_comm", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_4_get_electron_comm(__pyx_self, __pyx_v_self);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_4_get_electron_comm(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  size_t __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_get_electron_comm", 0);

  /* "ws_package/controllers/activity_controller.py":416
 *     def _get_electron_comm(self):
 *         """Return the global Electron communicator instance (lazy-loaded)."""
 *         return _get_electron_comm_lazy()             # <<<<<<<<<<<<<<
 * 
 *     def _send_to_electron_if_connected(self, channel: str, data: dict) -> bool:
*/
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_get_electron_comm_lazy); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
    __pyx_t_4 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 416, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "ws_package/controllers/activity_controller.py":414
 *         )
 * 
 *     def _get_electron_comm(self):             # <<<<<<<<<<<<<<
 *         """Return the global Electron communicator instance (lazy-loaded)."""
 *         return _get_electron_comm_lazy()
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._get_electron_comm", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":418
 *         return _get_electron_comm_lazy()
 * 
 *     def _send_to_electron_if_connected(self, channel: str, data: dict) -> bool:             # <<<<<<<<<<<<<<
 *         """Send message to Electron if communicator is available and connected. Returns True if sent."""
 *         electron_comm = self._get_electron_comm()
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_7_send_to_electron_if_connected(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_6_send_to_electron_if_connected, "Send message to Electron if communicator is available and connected. Returns True if sent.");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_7_send_to_electron_if_connected = {"_send_to_electron_if_connected", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_7_send_to_electron_if_connected, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_6_send_to_electron_if_connected};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_7_send_to_electron_if_connected(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_channel = 0;
  PyObject *__pyx_v_data = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_send_to_electron_if_connected (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_channel,&__pyx_mstate_global->__pyx_n_u_data,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 418, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 418, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 418, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 418, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_send_to_electron_if_connected", 0) < (0)) __PYX_ERR(0, 418, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 3; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_send_to_electron_if_connected", 1, 3, 3, i); __PYX_ERR(0, 418, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 3)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 418, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 418, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 418, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_channel = ((PyObject*)values[1]);
    __pyx_v_data = ((PyObject*)values[2]);
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_send_to_electron_if_connected", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 418, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._send_to_electron_if_connected", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_channel), (&PyUnicode_Type), 0, "channel", 2))) __PYX_ERR(0, 418, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_data), (&PyDict_Type), 0, "data", 2))) __PYX_ERR(0, 418, __pyx_L1_error)
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_6_send_to_electron_if_connected(__pyx_self, __pyx_v_self, __pyx_v_channel, __pyx_v_data);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  goto __pyx_L7_cleaned_up;
  __pyx_L0:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __pyx_L7_cleaned_up:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_6_send_to_electron_if_connected(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_channel, PyObject *__pyx_v_data) {
  PyObject *__pyx_v_electron_comm = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  size_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_send_to_electron_if_connected", 0);

  /* "ws_package/controllers/activity_controller.py":420
 *     def _send_to_electron_if_connected(self, channel: str, data: dict) -> bool:
 *         """Send message to Electron if communicator is available and connected. Returns True if sent."""
 *         electron_comm = self._get_electron_comm()             # <<<<<<<<<<<<<<
 *         if not electron_comm or not electron_comm.is_connected():
 *             return False
*/
  __pyx_t_2 = __pyx_v_self;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_3 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_electron_comm_2, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 420, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_v_electron_comm = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":421
 *         """Send message to Electron if communicator is available and connected. Returns True if sent."""
 *         electron_comm = self._get_electron_comm()
 *         if not electron_comm or not electron_comm.is_connected():             # <<<<<<<<<<<<<<
 *             return False
 *         return electron_comm.send_to_electron(channel, data)
*/
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_electron_comm); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 421, __pyx_L1_error)
  __pyx_t_6 = (!__pyx_t_5);
  if (!__pyx_t_6) {
  } else {
    __pyx_t_4 = __pyx_t_6;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = __pyx_v_electron_comm;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_3 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_connected, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 421, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 421, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = (!__pyx_t_6);
  __pyx_t_4 = __pyx_t_5;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_4) {

    /* "ws_package/controllers/activity_controller.py":422
 *         electron_comm = self._get_electron_comm()
 *         if not electron_comm or not electron_comm.is_connected():
 *             return False             # <<<<<<<<<<<<<<
 *         return electron_comm.send_to_electron(channel, data)
 * 
*/
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":421
 *         """Send message to Electron if communicator is available and connected. Returns True if sent."""
 *         electron_comm = self._get_electron_comm()
 *         if not electron_comm or not electron_comm.is_connected():             # <<<<<<<<<<<<<<
 *             return False
 *         return electron_comm.send_to_electron(channel, data)
*/
  }

  /* "ws_package/controllers/activity_controller.py":423
 *         if not electron_comm or not electron_comm.is_connected():
 *             return False
 *         return electron_comm.send_to_electron(channel, data)             # <<<<<<<<<<<<<<
 * 
 *     def _is_system_sleeping(self) -> bool:
*/
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __pyx_v_electron_comm;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_3 = 0;
  {
    PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_v_channel, __pyx_v_data};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_send_to_electron, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 423, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "ws_package/controllers/activity_controller.py":418
 *         return _get_electron_comm_lazy()
 * 
 *     def _send_to_electron_if_connected(self, channel: str, data: dict) -> bool:             # <<<<<<<<<<<<<<
 *         """Send message to Electron if communicator is available and connected. Returns True if sent."""
 *         electron_comm = self._get_electron_comm()
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._send_to_electron_if_connected", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_electron_comm);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":425
 *         return electron_comm.send_to_electron(channel, data)
 * 
 *     def _is_system_sleeping(self) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Check if system is currently sleeping.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_9_is_system_sleeping(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_8_is_system_sleeping, "\n        Check if system is currently sleeping.\n        Returns True if system is sleeping, False otherwise.\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_9_is_system_sleeping = {"_is_system_sleeping", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_9_is_system_sleeping, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_8_is_system_sleeping};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_9_is_system_sleeping(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  CYTHON_UNUSED PyObject *__pyx_v_self = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[1] = {0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_is_system_sleeping (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 425, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 425, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_is_system_sleeping", 0) < (0)) __PYX_ERR(0, 425, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_is_system_sleeping", 1, 1, 1, i); __PYX_ERR(0, 425, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 1)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 425, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_is_system_sleeping", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 425, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._is_system_sleeping", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_8_is_system_sleeping(__pyx_self, __pyx_v_self);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_8_is_system_sleeping(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self) {
  PyObject *__pyx_v_wake_detector = NULL;
  PyObject *__pyx_v_stats = NULL;
  PyObject *__pyx_v_last_sleep_time = NULL;
  PyObject *__pyx_v_last_wake_time = NULL;
  PyObject *__pyx_v_sleep_timestamp = NULL;
  PyObject *__pyx_v_current_timestamp = NULL;
  PyObject *__pyx_v_time_since_sleep = NULL;
  int __pyx_v_system_is_responsive;
  PyObject *__pyx_v_win32gui = NULL;
  PyObject *__pyx_v_hwnd = NULL;
  PyObject *__pyx_v_wake_timestamp = NULL;
  PyObject *__pyx_v_e = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  size_t __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  int __pyx_t_17;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  int __pyx_t_21;
  char const *__pyx_t_22;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_is_system_sleeping", 0);

  /* "ws_package/controllers/activity_controller.py":430
 *         Returns True if system is sleeping, False otherwise.
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             wake_detector = get_system_wake_detector()
 *             if wake_detector:
*/
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":431
 *         """
 *         try:
 *             wake_detector = get_system_wake_detector()             # <<<<<<<<<<<<<<
 *             if wake_detector:
 *                 stats = wake_detector.get_stats()
*/
      __pyx_t_5 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_get_system_wake_detector); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 431, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
        assert(__pyx_t_5);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
        __pyx_t_7 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 431, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_v_wake_detector = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":432
 *         try:
 *             wake_detector = get_system_wake_detector()
 *             if wake_detector:             # <<<<<<<<<<<<<<
 *                 stats = wake_detector.get_stats()
 *                 last_sleep_time = stats.get('last_sleep_time')
*/
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_wake_detector); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 432, __pyx_L3_error)
      if (__pyx_t_8) {

        /* "ws_package/controllers/activity_controller.py":433
 *             wake_detector = get_system_wake_detector()
 *             if wake_detector:
 *                 stats = wake_detector.get_stats()             # <<<<<<<<<<<<<<
 *                 last_sleep_time = stats.get('last_sleep_time')
 *                 last_wake_time = stats.get('last_wake_time')
*/
        __pyx_t_6 = __pyx_v_wake_detector;
        __Pyx_INCREF(__pyx_t_6);
        __pyx_t_7 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
          __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_stats, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 433, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __pyx_v_stats = __pyx_t_4;
        __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":434
 *             if wake_detector:
 *                 stats = wake_detector.get_stats()
 *                 last_sleep_time = stats.get('last_sleep_time')             # <<<<<<<<<<<<<<
 *                 last_wake_time = stats.get('last_wake_time')
 * 
*/
        __pyx_t_6 = __pyx_v_stats;
        __Pyx_INCREF(__pyx_t_6);
        __pyx_t_7 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_n_u_last_sleep_time};
          __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 434, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __pyx_v_last_sleep_time = __pyx_t_4;
        __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":435
 *                 stats = wake_detector.get_stats()
 *                 last_sleep_time = stats.get('last_sleep_time')
 *                 last_wake_time = stats.get('last_wake_time')             # <<<<<<<<<<<<<<
 * 
 *                 # If we have a sleep time and no wake time after it, system is sleeping
*/
        __pyx_t_6 = __pyx_v_stats;
        __Pyx_INCREF(__pyx_t_6);
        __pyx_t_7 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_n_u_last_wake_time};
          __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 435, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __pyx_v_last_wake_time = __pyx_t_4;
        __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":438
 * 
 *                 # If we have a sleep time and no wake time after it, system is sleeping
 *                 if last_sleep_time:             # <<<<<<<<<<<<<<
 *                     # Convert datetime to timestamp if needed
 *                     if isinstance(last_sleep_time, datetime.datetime):
*/
        __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_last_sleep_time); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 438, __pyx_L3_error)
        if (__pyx_t_8) {

          /* "ws_package/controllers/activity_controller.py":440
 *                 if last_sleep_time:
 *                     # Convert datetime to timestamp if needed
 *                     if isinstance(last_sleep_time, datetime.datetime):             # <<<<<<<<<<<<<<
 *                         sleep_timestamp = last_sleep_time.timestamp()
 *                     else:
*/
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 440, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 440, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_8 = PyObject_IsInstance(__pyx_v_last_sleep_time, __pyx_t_6); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 440, __pyx_L3_error)
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (__pyx_t_8) {

            /* "ws_package/controllers/activity_controller.py":441
 *                     # Convert datetime to timestamp if needed
 *                     if isinstance(last_sleep_time, datetime.datetime):
 *                         sleep_timestamp = last_sleep_time.timestamp()             # <<<<<<<<<<<<<<
 *                     else:
 *                         sleep_timestamp = last_sleep_time
*/
            __pyx_t_4 = __pyx_v_last_sleep_time;
            __Pyx_INCREF(__pyx_t_4);
            __pyx_t_7 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
              __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_timestamp, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 441, __pyx_L3_error)
              __Pyx_GOTREF(__pyx_t_6);
            }
            __pyx_v_sleep_timestamp = __pyx_t_6;
            __pyx_t_6 = 0;

            /* "ws_package/controllers/activity_controller.py":440
 *                 if last_sleep_time:
 *                     # Convert datetime to timestamp if needed
 *                     if isinstance(last_sleep_time, datetime.datetime):             # <<<<<<<<<<<<<<
 *                         sleep_timestamp = last_sleep_time.timestamp()
 *                     else:
*/
            goto __pyx_L11;
          }

          /* "ws_package/controllers/activity_controller.py":443
 *                         sleep_timestamp = last_sleep_time.timestamp()
 *                     else:
 *                         sleep_timestamp = last_sleep_time             # <<<<<<<<<<<<<<
 * 
 *                     current_timestamp = time.time()
*/
          /*else*/ {
            __Pyx_INCREF(__pyx_v_last_sleep_time);
            __pyx_v_sleep_timestamp = __pyx_v_last_sleep_time;
          }
          __pyx_L11:;

          /* "ws_package/controllers/activity_controller.py":445
 *                         sleep_timestamp = last_sleep_time
 * 
 *                     current_timestamp = time.time()             # <<<<<<<<<<<<<<
 *                     time_since_sleep = current_timestamp - sleep_timestamp
 * 
*/
          __pyx_t_4 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_time); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 445, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_time); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 445, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_7 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_9))) {
            __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_9);
            assert(__pyx_t_4);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
            __pyx_t_7 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
            __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 445, __pyx_L3_error)
            __Pyx_GOTREF(__pyx_t_6);
          }
          __pyx_v_current_timestamp = __pyx_t_6;
          __pyx_t_6 = 0;

          /* "ws_package/controllers/activity_controller.py":446
 * 
 *                     current_timestamp = time.time()
 *                     time_since_sleep = current_timestamp - sleep_timestamp             # <<<<<<<<<<<<<<
 * 
 *                     # Check if system is actually responsive using non-blocking OS calls.
*/
          __pyx_t_6 = PyNumber_Subtract(__pyx_v_current_timestamp, __pyx_v_sleep_timestamp); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 446, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_v_time_since_sleep = __pyx_t_6;
          __pyx_t_6 = 0;

          /* "ws_package/controllers/activity_controller.py":451
 *                     # The previous macOS path used blocking osascript (up to 1 s) inside
 *                     # an async coroutine, stalling the entire event loop every minute.
 *                     system_is_responsive = False             # <<<<<<<<<<<<<<
 *                     try:
 *                         if platform.system() == "Darwin":
*/
          __pyx_v_system_is_responsive = 0;

          /* "ws_package/controllers/activity_controller.py":452
 *                     # an async coroutine, stalling the entire event loop every minute.
 *                     system_is_responsive = False
 *                     try:             # <<<<<<<<<<<<<<
 *                         if platform.system() == "Darwin":
 *                             # os.getloadavg() is a non-blocking syscall  succeeds only
*/
          {
            __Pyx_PyThreadState_declare
            __Pyx_PyThreadState_assign
            __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
            __Pyx_XGOTREF(__pyx_t_10);
            __Pyx_XGOTREF(__pyx_t_11);
            __Pyx_XGOTREF(__pyx_t_12);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":453
 *                     system_is_responsive = False
 *                     try:
 *                         if platform.system() == "Darwin":             # <<<<<<<<<<<<<<
 *                             # os.getloadavg() is a non-blocking syscall  succeeds only
 *                             # when the kernel is responsive (system is awake).
*/
              __pyx_t_9 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 453, __pyx_L12_error)
              __Pyx_GOTREF(__pyx_t_4);
              __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_system); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 453, __pyx_L12_error)
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_5))) {
                __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_5);
                assert(__pyx_t_9);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                __Pyx_INCREF(__pyx_t_9);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_9, NULL};
                __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 453, __pyx_L12_error)
                __Pyx_GOTREF(__pyx_t_6);
              }
              __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_Darwin, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 453, __pyx_L12_error)
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              if (__pyx_t_8) {

                /* "ws_package/controllers/activity_controller.py":456
 *                             # os.getloadavg() is a non-blocking syscall  succeeds only
 *                             # when the kernel is responsive (system is awake).
 *                             os.getloadavg()             # <<<<<<<<<<<<<<
 *                             system_is_responsive = True
 *                         elif platform.system() == "Windows":
*/
                __pyx_t_5 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_os); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 456, __pyx_L12_error)
                __Pyx_GOTREF(__pyx_t_9);
                __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_getloadavg); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 456, __pyx_L12_error)
                __Pyx_GOTREF(__pyx_t_4);
                __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_4))) {
                  __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
                  assert(__pyx_t_5);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                  __Pyx_INCREF(__pyx_t_5);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                  __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 456, __pyx_L12_error)
                  __Pyx_GOTREF(__pyx_t_6);
                }
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

                /* "ws_package/controllers/activity_controller.py":457
 *                             # when the kernel is responsive (system is awake).
 *                             os.getloadavg()
 *                             system_is_responsive = True             # <<<<<<<<<<<<<<
 *                         elif platform.system() == "Windows":
 *                             # GetForegroundWindow() is non-blocking
*/
                __pyx_v_system_is_responsive = 1;

                /* "ws_package/controllers/activity_controller.py":453
 *                     system_is_responsive = False
 *                     try:
 *                         if platform.system() == "Darwin":             # <<<<<<<<<<<<<<
 *                             # os.getloadavg() is a non-blocking syscall  succeeds only
 *                             # when the kernel is responsive (system is awake).
*/
                goto __pyx_L18;
              }

              /* "ws_package/controllers/activity_controller.py":458
 *                             os.getloadavg()
 *                             system_is_responsive = True
 *                         elif platform.system() == "Windows":             # <<<<<<<<<<<<<<
 *                             # GetForegroundWindow() is non-blocking
 *                             try:
*/
              __pyx_t_4 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 458, __pyx_L12_error)
              __Pyx_GOTREF(__pyx_t_5);
              __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_system); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 458, __pyx_L12_error)
              __Pyx_GOTREF(__pyx_t_9);
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_9))) {
                __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_9);
                assert(__pyx_t_4);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
                __Pyx_INCREF(__pyx_t_4);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
                __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 458, __pyx_L12_error)
                __Pyx_GOTREF(__pyx_t_6);
              }
              __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_Windows, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 458, __pyx_L12_error)
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              if (__pyx_t_8) {

                /* "ws_package/controllers/activity_controller.py":460
 *                         elif platform.system() == "Windows":
 *                             # GetForegroundWindow() is non-blocking
 *                             try:             # <<<<<<<<<<<<<<
 *                                 import win32gui
 *                                 hwnd = win32gui.GetForegroundWindow()
*/
                {
                  __Pyx_PyThreadState_declare
                  __Pyx_PyThreadState_assign
                  __Pyx_ExceptionSave(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
                  __Pyx_XGOTREF(__pyx_t_13);
                  __Pyx_XGOTREF(__pyx_t_14);
                  __Pyx_XGOTREF(__pyx_t_15);
                  /*try:*/ {

                    /* "ws_package/controllers/activity_controller.py":461
 *                             # GetForegroundWindow() is non-blocking
 *                             try:
 *                                 import win32gui             # <<<<<<<<<<<<<<
 *                                 hwnd = win32gui.GetForegroundWindow()
 *                                 if hwnd:
*/
                    __pyx_t_16 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_win32gui, 0, 0, NULL, 0); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 461, __pyx_L19_error)
                    __pyx_t_6 = __pyx_t_16;
                    __Pyx_GOTREF(__pyx_t_6);
                    __pyx_v_win32gui = __pyx_t_6;
                    __pyx_t_6 = 0;

                    /* "ws_package/controllers/activity_controller.py":462
 *                             try:
 *                                 import win32gui
 *                                 hwnd = win32gui.GetForegroundWindow()             # <<<<<<<<<<<<<<
 *                                 if hwnd:
 *                                     system_is_responsive = True
*/
                    __pyx_t_9 = __pyx_v_win32gui;
                    __Pyx_INCREF(__pyx_t_9);
                    __pyx_t_7 = 0;
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_9, NULL};
                      __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_GetForegroundWindow, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 462, __pyx_L19_error)
                      __Pyx_GOTREF(__pyx_t_6);
                    }
                    __pyx_v_hwnd = __pyx_t_6;
                    __pyx_t_6 = 0;

                    /* "ws_package/controllers/activity_controller.py":463
 *                                 import win32gui
 *                                 hwnd = win32gui.GetForegroundWindow()
 *                                 if hwnd:             # <<<<<<<<<<<<<<
 *                                     system_is_responsive = True
 *                             except ImportError:
*/
                    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_hwnd); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 463, __pyx_L19_error)
                    if (__pyx_t_8) {

                      /* "ws_package/controllers/activity_controller.py":464
 *                                 hwnd = win32gui.GetForegroundWindow()
 *                                 if hwnd:
 *                                     system_is_responsive = True             # <<<<<<<<<<<<<<
 *                             except ImportError:
 *                                 pass
*/
                      __pyx_v_system_is_responsive = 1;

                      /* "ws_package/controllers/activity_controller.py":463
 *                                 import win32gui
 *                                 hwnd = win32gui.GetForegroundWindow()
 *                                 if hwnd:             # <<<<<<<<<<<<<<
 *                                     system_is_responsive = True
 *                             except ImportError:
*/
                    }

                    /* "ws_package/controllers/activity_controller.py":460
 *                         elif platform.system() == "Windows":
 *                             # GetForegroundWindow() is non-blocking
 *                             try:             # <<<<<<<<<<<<<<
 *                                 import win32gui
 *                                 hwnd = win32gui.GetForegroundWindow()
*/
                  }
                  __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  goto __pyx_L24_try_end;
                  __pyx_L19_error:;
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

                  /* "ws_package/controllers/activity_controller.py":465
 *                                 if hwnd:
 *                                     system_is_responsive = True
 *                             except ImportError:             # <<<<<<<<<<<<<<
 *                                 pass
 *                         else:
*/
                  __pyx_t_17 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_ImportError))));
                  if (__pyx_t_17) {
                    __Pyx_ErrRestore(0,0,0);
                    goto __pyx_L20_exception_handled;
                  }
                  goto __pyx_L21_except_error;

                  /* "ws_package/controllers/activity_controller.py":460
 *                         elif platform.system() == "Windows":
 *                             # GetForegroundWindow() is non-blocking
 *                             try:             # <<<<<<<<<<<<<<
 *                                 import win32gui
 *                                 hwnd = win32gui.GetForegroundWindow()
*/
                  __pyx_L21_except_error:;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __Pyx_XGIVEREF(__pyx_t_14);
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
                  goto __pyx_L12_error;
                  __pyx_L20_exception_handled:;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __Pyx_XGIVEREF(__pyx_t_14);
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
                  __pyx_L24_try_end:;
                }

                /* "ws_package/controllers/activity_controller.py":458
 *                             os.getloadavg()
 *                             system_is_responsive = True
 *                         elif platform.system() == "Windows":             # <<<<<<<<<<<<<<
 *                             # GetForegroundWindow() is non-blocking
 *                             try:
*/
                goto __pyx_L18;
              }

              /* "ws_package/controllers/activity_controller.py":469
 *                         else:
 *                             # Linux: getloadavg() is always available
 *                             os.getloadavg()             # <<<<<<<<<<<<<<
 *                             system_is_responsive = True
 *                     except Exception:
*/
              /*else*/ {
                __pyx_t_9 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_os); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 469, __pyx_L12_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_getloadavg); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 469, __pyx_L12_error)
                __Pyx_GOTREF(__pyx_t_5);
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_5))) {
                  __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_5);
                  assert(__pyx_t_9);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                  __Pyx_INCREF(__pyx_t_9);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_9, NULL};
                  __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 469, __pyx_L12_error)
                  __Pyx_GOTREF(__pyx_t_6);
                }
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

                /* "ws_package/controllers/activity_controller.py":470
 *                             # Linux: getloadavg() is always available
 *                             os.getloadavg()
 *                             system_is_responsive = True             # <<<<<<<<<<<<<<
 *                     except Exception:
 *                         # If we can't query the system, assume it might be sleeping
*/
                __pyx_v_system_is_responsive = 1;
              }
              __pyx_L18:;

              /* "ws_package/controllers/activity_controller.py":452
 *                     # an async coroutine, stalling the entire event loop every minute.
 *                     system_is_responsive = False
 *                     try:             # <<<<<<<<<<<<<<
 *                         if platform.system() == "Darwin":
 *                             # os.getloadavg() is a non-blocking syscall  succeeds only
*/
            }
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            goto __pyx_L17_try_end;
            __pyx_L12_error:;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

            /* "ws_package/controllers/activity_controller.py":471
 *                             os.getloadavg()
 *                             system_is_responsive = True
 *                     except Exception:             # <<<<<<<<<<<<<<
 *                         # If we can't query the system, assume it might be sleeping
 *                         pass
*/
            __pyx_t_17 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
            if (__pyx_t_17) {
              __Pyx_ErrRestore(0,0,0);
              goto __pyx_L13_exception_handled;
            }
            goto __pyx_L14_except_error;

            /* "ws_package/controllers/activity_controller.py":452
 *                     # an async coroutine, stalling the entire event loop every minute.
 *                     system_is_responsive = False
 *                     try:             # <<<<<<<<<<<<<<
 *                         if platform.system() == "Darwin":
 *                             # os.getloadavg() is a non-blocking syscall  succeeds only
*/
            __pyx_L14_except_error:;
            __Pyx_XGIVEREF(__pyx_t_10);
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
            goto __pyx_L3_error;
            __pyx_L13_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_10);
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
            __pyx_L17_try_end:;
          }

          /* "ws_package/controllers/activity_controller.py":476
 * 
 *                     # If system is responsive, it's definitely awake
 *                     if system_is_responsive:             # <<<<<<<<<<<<<<
 *                         logger.debug("[ACTIVITY] System is responsive (can query frontmost app) - system is awake")
 *                         return False
*/
          if (__pyx_v_system_is_responsive) {

            /* "ws_package/controllers/activity_controller.py":477
 *                     # If system is responsive, it's definitely awake
 *                     if system_is_responsive:
 *                         logger.debug("[ACTIVITY] System is responsive (can query frontmost app) - system is awake")             # <<<<<<<<<<<<<<
 *                         return False
 * 
*/
            __pyx_t_5 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 477, __pyx_L3_error)
            __Pyx_GOTREF(__pyx_t_9);
            __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 477, __pyx_L3_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            __pyx_t_7 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_4))) {
              __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
              assert(__pyx_t_5);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
              __Pyx_INCREF(__pyx_t_5);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
              __pyx_t_7 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_ACTIVITY_System_is_responsive_c};
              __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 477, __pyx_L3_error)
              __Pyx_GOTREF(__pyx_t_6);
            }
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

            /* "ws_package/controllers/activity_controller.py":478
 *                     if system_is_responsive:
 *                         logger.debug("[ACTIVITY] System is responsive (can query frontmost app) - system is awake")
 *                         return False             # <<<<<<<<<<<<<<
 * 
 *                     # FIX: If sleep was detected more than 3 minutes ago and no new sleep,
*/
            __Pyx_XDECREF(__pyx_r);
            __Pyx_INCREF(Py_False);
            __pyx_r = Py_False;
            goto __pyx_L7_try_return;

            /* "ws_package/controllers/activity_controller.py":476
 * 
 *                     # If system is responsive, it's definitely awake
 *                     if system_is_responsive:             # <<<<<<<<<<<<<<
 *                         logger.debug("[ACTIVITY] System is responsive (can query frontmost app) - system is awake")
 *                         return False
*/
          }

          /* "ws_package/controllers/activity_controller.py":483
 *                     # assume system is awake (wake detection may have missed it)
 *                     # Reduced from 10 minutes to 3 minutes for faster recovery
 *                     if time_since_sleep > 180:  # 3 minutes             # <<<<<<<<<<<<<<
 *                         logger.debug("[ACTIVITY] Sleep detected %s minutes ago - assuming awake", time_since_sleep/60)
 *                         return False
*/
          __pyx_t_6 = PyObject_RichCompare(__pyx_v_time_since_sleep, __pyx_mstate_global->__pyx_int_180, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 483, __pyx_L3_error)
          __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 483, __pyx_L3_error)
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (__pyx_t_8) {

            /* "ws_package/controllers/activity_controller.py":484
 *                     # Reduced from 10 minutes to 3 minutes for faster recovery
 *                     if time_since_sleep > 180:  # 3 minutes
 *                         logger.debug("[ACTIVITY] Sleep detected %s minutes ago - assuming awake", time_since_sleep/60)             # <<<<<<<<<<<<<<
 *                         return False
 * 
*/
            __pyx_t_4 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 484, __pyx_L3_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 484, __pyx_L3_error)
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_t_5 = __Pyx_PyLong_TrueDivideObjC(__pyx_v_time_since_sleep, __pyx_mstate_global->__pyx_int_60, 60, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 484, __pyx_L3_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_7 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_9))) {
              __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_9);
              assert(__pyx_t_4);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
              __Pyx_INCREF(__pyx_t_4);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
              __pyx_t_7 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_ACTIVITY_Sleep_detected_s_minut, __pyx_t_5};
              __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
              if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 484, __pyx_L3_error)
              __Pyx_GOTREF(__pyx_t_6);
            }
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

            /* "ws_package/controllers/activity_controller.py":485
 *                     if time_since_sleep > 180:  # 3 minutes
 *                         logger.debug("[ACTIVITY] Sleep detected %s minutes ago - assuming awake", time_since_sleep/60)
 *                         return False             # <<<<<<<<<<<<<<
 * 
 *                     # Otherwise, check if wake time is after sleep time
*/
            __Pyx_XDECREF(__pyx_r);
            __Pyx_INCREF(Py_False);
            __pyx_r = Py_False;
            goto __pyx_L7_try_return;

            /* "ws_package/controllers/activity_controller.py":483
 *                     # assume system is awake (wake detection may have missed it)
 *                     # Reduced from 10 minutes to 3 minutes for faster recovery
 *                     if time_since_sleep > 180:  # 3 minutes             # <<<<<<<<<<<<<<
 *                         logger.debug("[ACTIVITY] Sleep detected %s minutes ago - assuming awake", time_since_sleep/60)
 *                         return False
*/
          }

          /* "ws_package/controllers/activity_controller.py":488
 * 
 *                     # Otherwise, check if wake time is after sleep time
 *                     if last_wake_time is None:             # <<<<<<<<<<<<<<
 *                         return True
 * 
*/
          __pyx_t_8 = (__pyx_v_last_wake_time == Py_None);
          if (__pyx_t_8) {

            /* "ws_package/controllers/activity_controller.py":489
 *                     # Otherwise, check if wake time is after sleep time
 *                     if last_wake_time is None:
 *                         return True             # <<<<<<<<<<<<<<
 * 
 *                     # Convert wake time to timestamp if needed
*/
            __Pyx_XDECREF(__pyx_r);
            __Pyx_INCREF(Py_True);
            __pyx_r = Py_True;
            goto __pyx_L7_try_return;

            /* "ws_package/controllers/activity_controller.py":488
 * 
 *                     # Otherwise, check if wake time is after sleep time
 *                     if last_wake_time is None:             # <<<<<<<<<<<<<<
 *                         return True
 * 
*/
          }

          /* "ws_package/controllers/activity_controller.py":492
 * 
 *                     # Convert wake time to timestamp if needed
 *                     if isinstance(last_wake_time, datetime.datetime):             # <<<<<<<<<<<<<<
 *                         wake_timestamp = last_wake_time.timestamp()
 *                     else:
*/
          __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 492, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 492, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_8 = PyObject_IsInstance(__pyx_v_last_wake_time, __pyx_t_9); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 492, __pyx_L3_error)
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          if (__pyx_t_8) {

            /* "ws_package/controllers/activity_controller.py":493
 *                     # Convert wake time to timestamp if needed
 *                     if isinstance(last_wake_time, datetime.datetime):
 *                         wake_timestamp = last_wake_time.timestamp()             # <<<<<<<<<<<<<<
 *                     else:
 *                         wake_timestamp = last_wake_time
*/
            __pyx_t_6 = __pyx_v_last_wake_time;
            __Pyx_INCREF(__pyx_t_6);
            __pyx_t_7 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
              __pyx_t_9 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_timestamp, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 493, __pyx_L3_error)
              __Pyx_GOTREF(__pyx_t_9);
            }
            __pyx_v_wake_timestamp = __pyx_t_9;
            __pyx_t_9 = 0;

            /* "ws_package/controllers/activity_controller.py":492
 * 
 *                     # Convert wake time to timestamp if needed
 *                     if isinstance(last_wake_time, datetime.datetime):             # <<<<<<<<<<<<<<
 *                         wake_timestamp = last_wake_time.timestamp()
 *                     else:
*/
            goto __pyx_L33;
          }

          /* "ws_package/controllers/activity_controller.py":495
 *                         wake_timestamp = last_wake_time.timestamp()
 *                     else:
 *                         wake_timestamp = last_wake_time             # <<<<<<<<<<<<<<
 * 
 *                     if wake_timestamp < sleep_timestamp:
*/
          /*else*/ {
            __Pyx_INCREF(__pyx_v_last_wake_time);
            __pyx_v_wake_timestamp = __pyx_v_last_wake_time;
          }
          __pyx_L33:;

          /* "ws_package/controllers/activity_controller.py":497
 *                         wake_timestamp = last_wake_time
 * 
 *                     if wake_timestamp < sleep_timestamp:             # <<<<<<<<<<<<<<
 *                         return True
 *             return False
*/
          __pyx_t_9 = PyObject_RichCompare(__pyx_v_wake_timestamp, __pyx_v_sleep_timestamp, Py_LT); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 497, __pyx_L3_error)
          __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 497, __pyx_L3_error)
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          if (__pyx_t_8) {

            /* "ws_package/controllers/activity_controller.py":498
 * 
 *                     if wake_timestamp < sleep_timestamp:
 *                         return True             # <<<<<<<<<<<<<<
 *             return False
 *         except Exception as e:
*/
            __Pyx_XDECREF(__pyx_r);
            __Pyx_INCREF(Py_True);
            __pyx_r = Py_True;
            goto __pyx_L7_try_return;

            /* "ws_package/controllers/activity_controller.py":497
 *                         wake_timestamp = last_wake_time
 * 
 *                     if wake_timestamp < sleep_timestamp:             # <<<<<<<<<<<<<<
 *                         return True
 *             return False
*/
          }

          /* "ws_package/controllers/activity_controller.py":438
 * 
 *                 # If we have a sleep time and no wake time after it, system is sleeping
 *                 if last_sleep_time:             # <<<<<<<<<<<<<<
 *                     # Convert datetime to timestamp if needed
 *                     if isinstance(last_sleep_time, datetime.datetime):
*/
        }

        /* "ws_package/controllers/activity_controller.py":432
 *         try:
 *             wake_detector = get_system_wake_detector()
 *             if wake_detector:             # <<<<<<<<<<<<<<
 *                 stats = wake_detector.get_stats()
 *                 last_sleep_time = stats.get('last_sleep_time')
*/
      }

      /* "ws_package/controllers/activity_controller.py":499
 *                     if wake_timestamp < sleep_timestamp:
 *                         return True
 *             return False             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             logger.debug("Could not check system sleep state: %s", e)
*/
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_False);
      __pyx_r = Py_False;
      goto __pyx_L7_try_return;

      /* "ws_package/controllers/activity_controller.py":430
 *         Returns True if system is sleeping, False otherwise.
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             wake_detector = get_system_wake_detector()
 *             if wake_detector:
*/
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "ws_package/controllers/activity_controller.py":500
 *                         return True
 *             return False
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.debug("Could not check system sleep state: %s", e)
 *             return False
*/
    __pyx_t_17 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_17) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._is_system_sleeping", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_6, &__pyx_t_5) < 0) __PYX_ERR(0, 500, __pyx_L5_except_error)
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __pyx_v_e = __pyx_t_6;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":501
 *             return False
 *         except Exception as e:
 *             logger.debug("Could not check system sleep state: %s", e)             # <<<<<<<<<<<<<<
 *             return False
 * 
*/
        __pyx_t_18 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 501, __pyx_L40_error)
        __Pyx_GOTREF(__pyx_t_19);
        __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 501, __pyx_L40_error)
        __Pyx_GOTREF(__pyx_t_20);
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_20))) {
          __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_20);
          assert(__pyx_t_18);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_20);
          __Pyx_INCREF(__pyx_t_18);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_20, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_18, __pyx_mstate_global->__pyx_kp_u_Could_not_check_system_sleep_sta, __pyx_v_e};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_20, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 501, __pyx_L40_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":502
 *         except Exception as e:
 *             logger.debug("Could not check system sleep state: %s", e)
 *             return False             # <<<<<<<<<<<<<<
 * 
 *     def boundary_time(self, interval):
*/
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_False);
        __pyx_r = Py_False;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L39_return;
      }

      /* "ws_package/controllers/activity_controller.py":500
 *                         return True
 *             return False
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.debug("Could not check system sleep state: %s", e)
 *             return False
*/
      /*finally:*/ {
        __pyx_L40_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
          __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
          __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_14, &__pyx_t_13);
          if ( unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_13);
          __pyx_t_17 = __pyx_lineno; __pyx_t_21 = __pyx_clineno; __pyx_t_22 = __pyx_filename;
          {
            __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_14, __pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_ErrRestore(__pyx_t_12, __pyx_t_11, __pyx_t_10);
          __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_13 = 0;
          __pyx_lineno = __pyx_t_17; __pyx_clineno = __pyx_t_21; __pyx_filename = __pyx_t_22;
          goto __pyx_L5_except_error;
        }
        __pyx_L39_return: {
          __pyx_t_13 = __pyx_r;
          __pyx_r = 0;
          __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
          __pyx_r = __pyx_t_13;
          __pyx_t_13 = 0;
          goto __pyx_L6_except_return;
        }
      }
    }
    goto __pyx_L5_except_error;

    /* "ws_package/controllers/activity_controller.py":430
 *         Returns True if system is sleeping, False otherwise.
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             wake_detector = get_system_wake_detector()
 *             if wake_detector:
*/
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }

  /* "ws_package/controllers/activity_controller.py":425
 *         return electron_comm.send_to_electron(channel, data)
 * 
 *     def _is_system_sleeping(self) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Check if system is currently sleeping.
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._is_system_sleeping", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_wake_detector);
  __Pyx_XDECREF(__pyx_v_stats);
  __Pyx_XDECREF(__pyx_v_last_sleep_time);
  __Pyx_XDECREF(__pyx_v_last_wake_time);
  __Pyx_XDECREF(__pyx_v_sleep_timestamp);
  __Pyx_XDECREF(__pyx_v_current_timestamp);
  __Pyx_XDECREF(__pyx_v_time_since_sleep);
  __Pyx_XDECREF(__pyx_v_win32gui);
  __Pyx_XDECREF(__pyx_v_hwnd);
  __Pyx_XDECREF(__pyx_v_wake_timestamp);
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":504
 *             return False
 * 
 *     def boundary_time(self, interval):             # <<<<<<<<<<<<<<
 *         """
 *         Returns how many seconds are left until the next aligned interval boundary.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_11boundary_time(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_10boundary_time, "\n        Returns how many seconds are left until the next aligned interval boundary.\n        \n        Example:\n        if now = 16:41:33 and interval=300 (5 min),\n        it returns seconds until 16:45:00.\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_11boundary_time = {"boundary_time", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_11boundary_time, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_10boundary_time};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_11boundary_time(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  CYTHON_UNUSED PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_interval = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("boundary_time (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_interval,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 504, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 504, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 504, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "boundary_time", 0) < (0)) __PYX_ERR(0, 504, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("boundary_time", 1, 2, 2, i); __PYX_ERR(0, 504, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 504, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 504, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_interval = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("boundary_time", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 504, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.boundary_time", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_10boundary_time(__pyx_self, __pyx_v_self, __pyx_v_interval);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_10boundary_time(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_interval) {
  PyObject *__pyx_v_now = NULL;
  PyObject *__pyx_v_now_ts = NULL;
  PyObject *__pyx_v_remainder = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("boundary_time", 0);

  /* "ws_package/controllers/activity_controller.py":512
 *         it returns seconds until 16:45:00.
 *         """
 *         now = datetime.datetime.now()             # <<<<<<<<<<<<<<
 *         now_ts = int(now.timestamp())
 *         remainder = now_ts % interval
*/
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 512, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 512, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_2 = __pyx_t_4;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 512, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_v_now = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":513
 *         """
 *         now = datetime.datetime.now()
 *         now_ts = int(now.timestamp())             # <<<<<<<<<<<<<<
 *         remainder = now_ts % interval
 *         return interval - remainder if remainder != 0 else 0
*/
  __pyx_t_4 = __pyx_v_now;
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_timestamp, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 513, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_4 = __Pyx_PyNumber_Int(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 513, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_now_ts = ((PyObject*)__pyx_t_4);
  __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":514
 *         now = datetime.datetime.now()
 *         now_ts = int(now.timestamp())
 *         remainder = now_ts % interval             # <<<<<<<<<<<<<<
 *         return interval - remainder if remainder != 0 else 0
 * 
*/
  __pyx_t_4 = PyNumber_Remainder(__pyx_v_now_ts, __pyx_v_interval); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 514, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_v_remainder = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":515
 *         now_ts = int(now.timestamp())
 *         remainder = now_ts % interval
 *         return interval - remainder if remainder != 0 else 0             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
*/
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_6 = (__Pyx_PyLong_BoolNeObjC(__pyx_v_remainder, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 515, __pyx_L1_error)
  if (__pyx_t_6) {
    __pyx_t_1 = PyNumber_Subtract(__pyx_v_interval, __pyx_v_remainder); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 515, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_4 = __pyx_t_1;
    __pyx_t_1 = 0;
  } else {
    __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
    __pyx_t_4 = __pyx_mstate_global->__pyx_int_0;
  }
  __pyx_r = __pyx_t_4;
  __pyx_t_4 = 0;
  goto __pyx_L0;

  /* "ws_package/controllers/activity_controller.py":504
 *             return False
 * 
 *     def boundary_time(self, interval):             # <<<<<<<<<<<<<<
 *         """
 *         Returns how many seconds are left until the next aligned interval boundary.
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.boundary_time", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_now);
  __Pyx_XDECREF(__pyx_v_now_ts);
  __Pyx_XDECREF(__pyx_v_remainder);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":517
 *         return interval - remainder if remainder != 0 else 0
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def _seconds_until_datetime(target: datetime.datetime) -> float:
 *         """Seconds until ``target``; 0 if target is None or already passed."""
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_13_seconds_until_datetime(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_12_seconds_until_datetime, "Seconds until ``target``; 0 if target is None or already passed.");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_13_seconds_until_datetime = {"_seconds_until_datetime", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_13_seconds_until_datetime, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_12_seconds_until_datetime};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_13_seconds_until_datetime(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_target = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[1] = {0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_seconds_until_datetime (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_target,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 517, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 517, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_seconds_until_datetime", 0) < (0)) __PYX_ERR(0, 517, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_seconds_until_datetime", 1, 1, 1, i); __PYX_ERR(0, 517, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 1)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 517, __pyx_L3_error)
    }
    __pyx_v_target = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_seconds_until_datetime", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 517, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._seconds_until_datetime", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_12_seconds_until_datetime(__pyx_self, __pyx_v_target);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_12_seconds_until_datetime(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_target) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  size_t __pyx_t_8;
  double __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_seconds_until_datetime", 0);

  /* "ws_package/controllers/activity_controller.py":520
 *     def _seconds_until_datetime(target: datetime.datetime) -> float:
 *         """Seconds until ``target``; 0 if target is None or already passed."""
 *         if target is None:             # <<<<<<<<<<<<<<
 *             return 0.0
 *         return max(0.0, (target - datetime.datetime.now()).total_seconds())
*/
  __pyx_t_1 = (__pyx_v_target == Py_None);
  if (__pyx_t_1) {

    /* "ws_package/controllers/activity_controller.py":521
 *         """Seconds until ``target``; 0 if target is None or already passed."""
 *         if target is None:
 *             return 0.0             # <<<<<<<<<<<<<<
 *         return max(0.0, (target - datetime.datetime.now()).total_seconds())
 * 
*/
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_mstate_global->__pyx_float_0_0);
    __pyx_r = __pyx_mstate_global->__pyx_float_0_0;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":520
 *     def _seconds_until_datetime(target: datetime.datetime) -> float:
 *         """Seconds until ``target``; 0 if target is None or already passed."""
 *         if target is None:             # <<<<<<<<<<<<<<
 *             return 0.0
 *         return max(0.0, (target - datetime.datetime.now()).total_seconds())
*/
  }

  /* "ws_package/controllers/activity_controller.py":522
 *         if target is None:
 *             return 0.0
 *         return max(0.0, (target - datetime.datetime.now()).total_seconds())             # <<<<<<<<<<<<<<
 * 
 *     def increment_session_counter(self, reason: str = "new_session") -> int:
*/
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 522, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 522, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_5 = __pyx_t_7;
  __Pyx_INCREF(__pyx_t_5);
  __pyx_t_8 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
    __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 522, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  }
  __pyx_t_7 = PyNumber_Subtract(__pyx_v_target, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 522, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_3 = __pyx_t_7;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_8 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
    __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_total_seconds, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 522, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
  }
  __pyx_t_9 = 0.0;
  __pyx_t_3 = PyFloat_FromDouble(__pyx_t_9); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 522, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 522, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 522, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_1) {
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_7 = __pyx_t_2;
  } else {
    __pyx_t_4 = PyFloat_FromDouble(__pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 522, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __pyx_t_4;
    __pyx_t_4 = 0;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_INCREF(__pyx_t_7);
  __pyx_r = __pyx_t_7;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  goto __pyx_L0;

  /* "ws_package/controllers/activity_controller.py":517
 *         return interval - remainder if remainder != 0 else 0
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def _seconds_until_datetime(target: datetime.datetime) -> float:
 *         """Seconds until ``target``; 0 if target is None or already passed."""
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._seconds_until_datetime", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":524
 *         return max(0.0, (target - datetime.datetime.now()).total_seconds())
 * 
 *     def increment_session_counter(self, reason: str = "new_session") -> int:             # <<<<<<<<<<<<<<
 *         """Bump last_count for a new timer session and sync dependent managers."""
 *         old_counter = self.last_count
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_15increment_session_counter(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_14increment_session_counter, "Bump last_count for a new timer session and sync dependent managers.");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_15increment_session_counter = {"increment_session_counter", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_15increment_session_counter, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_14increment_session_counter};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_15increment_session_counter(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_reason = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("increment_session_counter (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_reason,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 524, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 524, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 524, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "increment_session_counter", 0) < (0)) __PYX_ERR(0, 524, __pyx_L3_error)
      if (!values[1]) values[1] = __Pyx_NewRef(((PyObject*)((PyObject*)__pyx_mstate_global->__pyx_n_u_new_session)));
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("increment_session_counter", 0, 1, 2, i); __PYX_ERR(0, 524, __pyx_L3_error) }
      }
    } else {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 524, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 524, __pyx_L3_error)
        break;
        default: goto __pyx_L5_argtuple_error;
      }
      if (!values[1]) values[1] = __Pyx_NewRef(((PyObject*)((PyObject*)__pyx_mstate_global->__pyx_n_u_new_session)));
    }
    __pyx_v_self = values[0];
    __pyx_v_reason = ((PyObject*)values[1]);
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("increment_session_counter", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 524, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.increment_session_counter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_reason), (&PyUnicode_Type), 0, "reason", 2))) __PYX_ERR(0, 524, __pyx_L1_error)
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_14increment_session_counter(__pyx_self, __pyx_v_self, __pyx_v_reason);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  goto __pyx_L7_cleaned_up;
  __pyx_L0:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __pyx_L7_cleaned_up:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_14increment_session_counter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_reason) {
  PyObject *__pyx_v_old_counter = NULL;
  PyObject *__pyx_v_screenshot_ctrl = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("increment_session_counter", 0);

  /* "ws_package/controllers/activity_controller.py":526
 *     def increment_session_counter(self, reason: str = "new_session") -> int:
 *         """Bump last_count for a new timer session and sync dependent managers."""
 *         old_counter = self.last_count             # <<<<<<<<<<<<<<
 *         self.last_count = old_counter + 1
 *         self._last_counter_bump_at = datetime.datetime.now()
*/
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 526, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_old_counter = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":527
 *         """Bump last_count for a new timer session and sync dependent managers."""
 *         old_counter = self.last_count
 *         self.last_count = old_counter + 1             # <<<<<<<<<<<<<<
 *         self._last_counter_bump_at = datetime.datetime.now()
 *         self._bump_counter_on_next_monitoring_start = False
*/
  __pyx_t_1 = __Pyx_PyLong_AddObjC(__pyx_v_old_counter, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count, __pyx_t_1) < (0)) __PYX_ERR(0, 527, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":528
 *         old_counter = self.last_count
 *         self.last_count = old_counter + 1
 *         self._last_counter_bump_at = datetime.datetime.now()             # <<<<<<<<<<<<<<
 *         self._bump_counter_on_next_monitoring_start = False
 *         self.start_date = datetime.datetime.now().replace(microsecond=0)
*/
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_2 = __pyx_t_4;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 528, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_counter_bump_at, __pyx_t_1) < (0)) __PYX_ERR(0, 528, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":529
 *         self.last_count = old_counter + 1
 *         self._last_counter_bump_at = datetime.datetime.now()
 *         self._bump_counter_on_next_monitoring_start = False             # <<<<<<<<<<<<<<
 *         self.start_date = datetime.datetime.now().replace(microsecond=0)
 *         self.current_session_start_time = None
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_bump_counter_on_next_monitoring, Py_False) < (0)) __PYX_ERR(0, 529, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":530
 *         self._last_counter_bump_at = datetime.datetime.now()
 *         self._bump_counter_on_next_monitoring_start = False
 *         self.start_date = datetime.datetime.now().replace(microsecond=0)             # <<<<<<<<<<<<<<
 *         self.current_session_start_time = None
 *         self._activity_log_payload_start = None
*/
  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 530, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 530, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_3 = __pyx_t_7;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
    __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 530, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
  }
  __pyx_t_4 = __pyx_t_2;
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_4, NULL};
    __pyx_t_7 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 530, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_7, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 530, __pyx_L1_error)
    __pyx_t_1 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_7);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 530, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_start_date, __pyx_t_1) < (0)) __PYX_ERR(0, 530, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":531
 *         self._bump_counter_on_next_monitoring_start = False
 *         self.start_date = datetime.datetime.now().replace(microsecond=0)
 *         self.current_session_start_time = None             # <<<<<<<<<<<<<<
 *         self._activity_log_payload_start = None
 *         screenshot_ctrl = getattr(self, 'screenshot_controller', None)
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_session_start_time, Py_None) < (0)) __PYX_ERR(0, 531, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":532
 *         self.start_date = datetime.datetime.now().replace(microsecond=0)
 *         self.current_session_start_time = None
 *         self._activity_log_payload_start = None             # <<<<<<<<<<<<<<
 *         screenshot_ctrl = getattr(self, 'screenshot_controller', None)
 *         if screenshot_ctrl is not None:
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_log_payload_start, Py_None) < (0)) __PYX_ERR(0, 532, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":533
 *         self.current_session_start_time = None
 *         self._activity_log_payload_start = None
 *         screenshot_ctrl = getattr(self, 'screenshot_controller', None)             # <<<<<<<<<<<<<<
 *         if screenshot_ctrl is not None:
 *             screenshot_ctrl.last_count = self.last_count
*/
  __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 533, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_screenshot_ctrl = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":534
 *         self._activity_log_payload_start = None
 *         screenshot_ctrl = getattr(self, 'screenshot_controller', None)
 *         if screenshot_ctrl is not None:             # <<<<<<<<<<<<<<
 *             screenshot_ctrl.last_count = self.last_count
 *         logger.info(
*/
  __pyx_t_8 = (__pyx_v_screenshot_ctrl != Py_None);
  if (__pyx_t_8) {

    /* "ws_package/controllers/activity_controller.py":535
 *         screenshot_ctrl = getattr(self, 'screenshot_controller', None)
 *         if screenshot_ctrl is not None:
 *             screenshot_ctrl.last_count = self.last_count             # <<<<<<<<<<<<<<
 *         logger.info(
 *             "=== SESSION COUNTER === Incremented %s -> %s (%s); intervals use counter=%s",
*/
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 535, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_screenshot_ctrl, __pyx_mstate_global->__pyx_n_u_last_count, __pyx_t_1) < (0)) __PYX_ERR(0, 535, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "ws_package/controllers/activity_controller.py":534
 *         self._activity_log_payload_start = None
 *         screenshot_ctrl = getattr(self, 'screenshot_controller', None)
 *         if screenshot_ctrl is not None:             # <<<<<<<<<<<<<<
 *             screenshot_ctrl.last_count = self.last_count
 *         logger.info(
*/
  }

  /* "ws_package/controllers/activity_controller.py":536
 *         if screenshot_ctrl is not None:
 *             screenshot_ctrl.last_count = self.last_count
 *         logger.info(             # <<<<<<<<<<<<<<
 *             "=== SESSION COUNTER === Incremented %s -> %s (%s); intervals use counter=%s",
 *             old_counter,
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 536, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 536, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "ws_package/controllers/activity_controller.py":539
 *             "=== SESSION COUNTER === Incremented %s -> %s (%s); intervals use counter=%s",
 *             old_counter,
 *             self.last_count,             # <<<<<<<<<<<<<<
 *             reason,
 *             self.last_count + 1,
*/
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 539, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "ws_package/controllers/activity_controller.py":541
 *             self.last_count,
 *             reason,
 *             self.last_count + 1,             # <<<<<<<<<<<<<<
 *         )
 *         return self.last_count
*/
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 541, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyLong_AddObjC(__pyx_t_3, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 541, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[6] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_SESSION_COUNTER_Incremented_s_s, __pyx_v_old_counter, __pyx_t_7, __pyx_v_reason, __pyx_t_6};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (6-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 536, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":543
 *             self.last_count + 1,
 *         )
 *         return self.last_count             # <<<<<<<<<<<<<<
 * 
 *     def should_skip_counter_bump_dedup(self, within_seconds: int = 12) -> bool:
*/
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 543, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (__Pyx_PyInt_FromNumber(&__pyx_t_1, NULL, 1) < (0)) __PYX_ERR(0, 543, __pyx_L1_error)
  __pyx_r = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "ws_package/controllers/activity_controller.py":524
 *         return max(0.0, (target - datetime.datetime.now()).total_seconds())
 * 
 *     def increment_session_counter(self, reason: str = "new_session") -> int:             # <<<<<<<<<<<<<<
 *         """Bump last_count for a new timer session and sync dependent managers."""
 *         old_counter = self.last_count
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.increment_session_counter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_old_counter);
  __Pyx_XDECREF(__pyx_v_screenshot_ctrl);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":545
 *         return self.last_count
 * 
 *     def should_skip_counter_bump_dedup(self, within_seconds: int = 12) -> bool:             # <<<<<<<<<<<<<<
 *         """Skip duplicate bump when the same start wave retried IPC within a few seconds."""
 *         if getattr(self, '_bump_counter_on_next_monitoring_start', False):
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_17should_skip_counter_bump_dedup(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_16should_skip_counter_bump_dedup, "Skip duplicate bump when the same start wave retried IPC within a few seconds.");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_17should_skip_counter_bump_dedup = {"should_skip_counter_bump_dedup", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_17should_skip_counter_bump_dedup, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_16should_skip_counter_bump_dedup};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_17should_skip_counter_bump_dedup(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_within_seconds = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("should_skip_counter_bump_dedup (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_within_seconds,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 545, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 545, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 545, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "should_skip_counter_bump_dedup", 0) < (0)) __PYX_ERR(0, 545, __pyx_L3_error)
      if (!values[1]) values[1] = __Pyx_NewRef(((PyObject*)((PyObject*)__pyx_mstate_global->__pyx_int_12)));
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("should_skip_counter_bump_dedup", 0, 1, 2, i); __PYX_ERR(0, 545, __pyx_L3_error) }
      }
    } else {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 545, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 545, __pyx_L3_error)
        break;
        default: goto __pyx_L5_argtuple_error;
      }
      if (!values[1]) values[1] = __Pyx_NewRef(((PyObject*)((PyObject*)__pyx_mstate_global->__pyx_int_12)));
    }
    __pyx_v_self = values[0];
    if (__Pyx_PyInt_FromNumber(&values[1], "within_seconds", 0) < (0)) __PYX_ERR(0, 545, __pyx_L3_error)
    __pyx_v_within_seconds = ((PyObject*)values[1]);
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("should_skip_counter_bump_dedup", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 545, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.should_skip_counter_bump_dedup", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_within_seconds), (&PyLong_Type), 0, "within_seconds", 2))) __PYX_ERR(0, 545, __pyx_L1_error)
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_16should_skip_counter_bump_dedup(__pyx_self, __pyx_v_self, __pyx_v_within_seconds);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  goto __pyx_L7_cleaned_up;
  __pyx_L0:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __pyx_L7_cleaned_up:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_16should_skip_counter_bump_dedup(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_within_seconds) {
  PyObject *__pyx_v_last_bump = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  size_t __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("should_skip_counter_bump_dedup", 0);

  /* "ws_package/controllers/activity_controller.py":547
 *     def should_skip_counter_bump_dedup(self, within_seconds: int = 12) -> bool:
 *         """Skip duplicate bump when the same start wave retried IPC within a few seconds."""
 *         if getattr(self, '_bump_counter_on_next_monitoring_start', False):             # <<<<<<<<<<<<<<
 *             return False
 *         last_bump = getattr(self, '_last_counter_bump_at', None)
*/
  __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_bump_counter_on_next_monitoring, Py_False); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 547, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 547, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_2) {

    /* "ws_package/controllers/activity_controller.py":548
 *         """Skip duplicate bump when the same start wave retried IPC within a few seconds."""
 *         if getattr(self, '_bump_counter_on_next_monitoring_start', False):
 *             return False             # <<<<<<<<<<<<<<
 *         last_bump = getattr(self, '_last_counter_bump_at', None)
 *         if last_bump is None:
*/
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":547
 *     def should_skip_counter_bump_dedup(self, within_seconds: int = 12) -> bool:
 *         """Skip duplicate bump when the same start wave retried IPC within a few seconds."""
 *         if getattr(self, '_bump_counter_on_next_monitoring_start', False):             # <<<<<<<<<<<<<<
 *             return False
 *         last_bump = getattr(self, '_last_counter_bump_at', None)
*/
  }

  /* "ws_package/controllers/activity_controller.py":549
 *         if getattr(self, '_bump_counter_on_next_monitoring_start', False):
 *             return False
 *         last_bump = getattr(self, '_last_counter_bump_at', None)             # <<<<<<<<<<<<<<
 *         if last_bump is None:
 *             return False
*/
  __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_counter_bump_at, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 549, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_last_bump = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":550
 *             return False
 *         last_bump = getattr(self, '_last_counter_bump_at', None)
 *         if last_bump is None:             # <<<<<<<<<<<<<<
 *             return False
 *         return (datetime.datetime.now() - last_bump).total_seconds() < within_seconds
*/
  __pyx_t_2 = (__pyx_v_last_bump == Py_None);
  if (__pyx_t_2) {

    /* "ws_package/controllers/activity_controller.py":551
 *         last_bump = getattr(self, '_last_counter_bump_at', None)
 *         if last_bump is None:
 *             return False             # <<<<<<<<<<<<<<
 *         return (datetime.datetime.now() - last_bump).total_seconds() < within_seconds
 * 
*/
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":550
 *             return False
 *         last_bump = getattr(self, '_last_counter_bump_at', None)
 *         if last_bump is None:             # <<<<<<<<<<<<<<
 *             return False
 *         return (datetime.datetime.now() - last_bump).total_seconds() < within_seconds
*/
  }

  /* "ws_package/controllers/activity_controller.py":552
 *         if last_bump is None:
 *             return False
 *         return (datetime.datetime.now() - last_bump).total_seconds() < within_seconds             # <<<<<<<<<<<<<<
 * 
 *     async def has_recent_intervals_on_write_counter(self, within_seconds: int = 45) -> bool:
*/
  __Pyx_XDECREF(__pyx_r);
  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 552, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 552, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_5 = __pyx_t_7;
  __Pyx_INCREF(__pyx_t_5);
  __pyx_t_8 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
    __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 552, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  }
  __pyx_t_7 = PyNumber_Subtract(__pyx_t_4, __pyx_v_last_bump); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 552, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_3 = __pyx_t_7;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_8 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_total_seconds, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 552, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_7 = PyObject_RichCompare(__pyx_t_1, __pyx_v_within_seconds, Py_LT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 552, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_7;
  __pyx_t_7 = 0;
  goto __pyx_L0;

  /* "ws_package/controllers/activity_controller.py":545
 *         return self.last_count
 * 
 *     def should_skip_counter_bump_dedup(self, within_seconds: int = 12) -> bool:             # <<<<<<<<<<<<<<
 *         """Skip duplicate bump when the same start wave retried IPC within a few seconds."""
 *         if getattr(self, '_bump_counter_on_next_monitoring_start', False):
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.should_skip_counter_bump_dedup", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_last_bump);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_20generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":554
 *         return (datetime.datetime.now() - last_bump).total_seconds() < within_seconds
 * 
 *     async def has_recent_intervals_on_write_counter(self, within_seconds: int = 45) -> bool:             # <<<<<<<<<<<<<<
 *         """True if the current write counter already has intervals ended very recently (start retry)."""
 *         DB_OPERATION_TIMEOUT = 5.0
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_19has_recent_intervals_on_write_counter(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_18has_recent_intervals_on_write_counter, "True if the current write counter already has intervals ended very recently (start retry).");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_19has_recent_intervals_on_write_counter = {"has_recent_intervals_on_write_counter", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_19has_recent_intervals_on_write_counter, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_18has_recent_intervals_on_write_counter};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_19has_recent_intervals_on_write_counter(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_within_seconds = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("has_recent_intervals_on_write_counter (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_within_seconds,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 554, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 554, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 554, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "has_recent_intervals_on_write_counter", 0) < (0)) __PYX_ERR(0, 554, __pyx_L3_error)
      if (!values[1]) values[1] = __Pyx_NewRef(((PyObject*)((PyObject*)__pyx_mstate_global->__pyx_int_45)));
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("has_recent_intervals_on_write_counter", 0, 1, 2, i); __PYX_ERR(0, 554, __pyx_L3_error) }
      }
    } else {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 554, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 554, __pyx_L3_error)
        break;
        default: goto __pyx_L5_argtuple_error;
      }
      if (!values[1]) values[1] = __Pyx_NewRef(((PyObject*)((PyObject*)__pyx_mstate_global->__pyx_int_45)));
    }
    __pyx_v_self = values[0];
    if (__Pyx_PyInt_FromNumber(&values[1], "within_seconds", 0) < (0)) __PYX_ERR(0, 554, __pyx_L3_error)
    __pyx_v_within_seconds = ((PyObject*)values[1]);
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("has_recent_intervals_on_write_counter", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 554, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.has_recent_intervals_on_write_counter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_within_seconds), (&PyLong_Type), 0, "within_seconds", 2))) __PYX_ERR(0, 554, __pyx_L1_error)
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_18has_recent_intervals_on_write_counter(__pyx_self, __pyx_v_self, __pyx_v_within_seconds);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  goto __pyx_L7_cleaned_up;
  __pyx_L0:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __pyx_L7_cleaned_up:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_18has_recent_intervals_on_write_counter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_within_seconds) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("has_recent_intervals_on_write_counter", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 554, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_within_seconds = __pyx_v_within_seconds;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_within_seconds);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_within_seconds);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_20generator, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[0]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_has_recent_intervals_on_write_co, __pyx_mstate_global->__pyx_n_u_ActivityController_has_recent_in, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 554, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.has_recent_intervals_on_write_counter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_20generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_PySendResult __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  int __pyx_t_23;
  int __pyx_t_24;
  int __pyx_t_25;
  char const *__pyx_t_26;
  PyObject *__pyx_t_27 = NULL;
  PyObject *__pyx_t_28 = NULL;
  PyObject *__pyx_t_29 = NULL;
  PyObject *__pyx_t_30 = NULL;
  PyObject *__pyx_t_31 = NULL;
  PyObject *__pyx_t_32 = NULL;
  int __pyx_t_33;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("has_recent_intervals_on_write_counter", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L15_resume_from_await;
    case 2: goto __pyx_L31_resume_from_await;
    case 3: goto __pyx_L48_resume_from_await;
    case 4: goto __pyx_L49_resume_from_await;
    case 5: goto __pyx_L50_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 554, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":556
 *     async def has_recent_intervals_on_write_counter(self, within_seconds: int = 45) -> bool:
 *         """True if the current write counter already has intervals ended very recently (start retry)."""
 *         DB_OPERATION_TIMEOUT = 5.0             # <<<<<<<<<<<<<<
 *         write_counter = self.last_count + 1
 *         cutoff = datetime.datetime.now() - datetime.timedelta(seconds=within_seconds)
*/
  __pyx_cur_scope->__pyx_v_DB_OPERATION_TIMEOUT = 5.0;

  /* "ws_package/controllers/activity_controller.py":557
 *         """True if the current write counter already has intervals ended very recently (start retry)."""
 *         DB_OPERATION_TIMEOUT = 5.0
 *         write_counter = self.last_count + 1             # <<<<<<<<<<<<<<
 *         cutoff = datetime.datetime.now() - datetime.timedelta(seconds=within_seconds)
 *         with db_lock_manager.read_lock():
*/
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 557, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyLong_AddObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 557, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_cur_scope->__pyx_v_write_counter = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":558
 *         DB_OPERATION_TIMEOUT = 5.0
 *         write_counter = self.last_count + 1
 *         cutoff = datetime.datetime.now() - datetime.timedelta(seconds=within_seconds)             # <<<<<<<<<<<<<<
 *         with db_lock_manager.read_lock():
 *             async with async_session() as session:
*/
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 558, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 558, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = __pyx_t_4;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
    __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 558, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
  }
  __pyx_t_1 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 558, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_timedelta); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 558, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
    assert(__pyx_t_1);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_1, NULL};
    __pyx_t_3 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 558, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_seconds, __pyx_cur_scope->__pyx_v_within_seconds, __pyx_t_3, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 558, __pyx_L1_error)
    __pyx_t_4 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_3);
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 558, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  }
  __pyx_t_6 = PyNumber_Subtract(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 558, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_cur_scope->__pyx_v_cutoff = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "ws_package/controllers/activity_controller.py":559
 *         write_counter = self.last_count + 1
 *         cutoff = datetime.datetime.now() - datetime.timedelta(seconds=within_seconds)
 *         with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *             async with async_session() as session:
 *                 try:
*/
  /*with:*/ {
    __pyx_t_4 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 559, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 559, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
      assert(__pyx_t_4);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
      __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 559, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    }
    __pyx_t_7 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 559, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_4 = NULL;
    __pyx_t_2 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 559, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (likely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
      assert(__pyx_t_4);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
      __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 559, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    /*try:*/ {
      {
        __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
        __Pyx_XGOTREF(__pyx_t_8);
        __Pyx_XGOTREF(__pyx_t_9);
        __Pyx_XGOTREF(__pyx_t_10);
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":560
 *         cutoff = datetime.datetime.now() - datetime.timedelta(seconds=within_seconds)
 *         with db_lock_manager.read_lock():
 *             async with async_session() as session:             # <<<<<<<<<<<<<<
 *                 try:
 *                     query = (
*/
          /*with:*/ {
            __pyx_t_3 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 560, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_5 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_2))) {
              __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
              assert(__pyx_t_3);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
              __pyx_t_5 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
              __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 560, __pyx_L8_error)
              __Pyx_GOTREF(__pyx_t_6);
            }
            __pyx_t_11 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 560, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_11);
            __pyx_t_3 = NULL;
            __pyx_t_4 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 560, __pyx_L14_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_5 = 1;
            #if CYTHON_UNPACK_METHODS
            if (likely(PyMethod_Check(__pyx_t_4))) {
              __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
              assert(__pyx_t_3);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
              __pyx_t_5 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
              __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 560, __pyx_L14_error)
              __Pyx_GOTREF(__pyx_t_2);
            }
            __pyx_t_12 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_2, &__pyx_r);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (likely(__pyx_t_12 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_6);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
              __Pyx_XGIVEREF(__pyx_t_7);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
              __Pyx_XGIVEREF(__pyx_t_8);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
              __Pyx_XGIVEREF(__pyx_t_9);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
              __Pyx_XGIVEREF(__pyx_t_10);
              __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
              __Pyx_XGIVEREF(__pyx_t_11);
              __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 1;
              return __pyx_r;
              __pyx_L15_resume_from_await:;
              __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_6);
              __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_7);
              __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_8);
              __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_9);
              __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
              __pyx_cur_scope->__pyx_t_4 = 0;
              __Pyx_XGOTREF(__pyx_t_10);
              __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
              __pyx_cur_scope->__pyx_t_5 = 0;
              __Pyx_XGOTREF(__pyx_t_11);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 560, __pyx_L14_error)
              __pyx_t_2 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_2);
            } else if (likely(__pyx_t_12 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __pyx_t_2 = __pyx_r; __pyx_r = NULL;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 560, __pyx_L14_error)
            }
            __pyx_t_4 = __pyx_t_2;
            __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            /*try:*/ {
              {
                __Pyx_ExceptionSave(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
                __Pyx_XGOTREF(__pyx_t_13);
                __Pyx_XGOTREF(__pyx_t_14);
                __Pyx_XGOTREF(__pyx_t_15);
                /*try:*/ {
                  __Pyx_GIVEREF(__pyx_t_4);
                  __pyx_cur_scope->__pyx_v_session = __pyx_t_4;
                  __pyx_t_4 = 0;

                  /* "ws_package/controllers/activity_controller.py":561
 *         with db_lock_manager.read_lock():
 *             async with async_session() as session:
 *                 try:             # <<<<<<<<<<<<<<
 *                     query = (
 *                         select(ActivityInterval.id)
*/
                  {
                    __Pyx_ExceptionSave(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
                    __Pyx_XGOTREF(__pyx_t_16);
                    __Pyx_XGOTREF(__pyx_t_17);
                    __Pyx_XGOTREF(__pyx_t_18);
                    /*try:*/ {

                      /* "ws_package/controllers/activity_controller.py":563
 *                 try:
 *                     query = (
 *                         select(ActivityInterval.id)             # <<<<<<<<<<<<<<
 *                         .where(
 *                             ActivityInterval.counter == write_counter,
*/
                      __pyx_t_19 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 563, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_20);
                      __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 563, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 563, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                      __pyx_t_5 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_20))) {
                        __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_20);
                        assert(__pyx_t_19);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_20);
                        __Pyx_INCREF(__pyx_t_19);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_20, __pyx__function);
                        __pyx_t_5 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_19, __pyx_t_22};
                        __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_20, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 563, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_1);
                      }
                      __pyx_t_3 = __pyx_t_1;
                      __Pyx_INCREF(__pyx_t_3);

                      /* "ws_package/controllers/activity_controller.py":565
 *                         select(ActivityInterval.id)
 *                         .where(
 *                             ActivityInterval.counter == write_counter,             # <<<<<<<<<<<<<<
 *                             ActivityInterval.end_time >= cutoff,
 *                         )
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 565, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_20);
                      __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 565, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                      __pyx_t_20 = PyObject_RichCompare(__pyx_t_22, __pyx_cur_scope->__pyx_v_write_counter, Py_EQ); __Pyx_XGOTREF(__pyx_t_20); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 565, __pyx_L25_error)
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;

                      /* "ws_package/controllers/activity_controller.py":566
 *                         .where(
 *                             ActivityInterval.counter == write_counter,
 *                             ActivityInterval.end_time >= cutoff,             # <<<<<<<<<<<<<<
 *                         )
 *                         .limit(1)
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 566, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 566, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_19);
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                      __pyx_t_22 = PyObject_RichCompare(__pyx_t_19, __pyx_cur_scope->__pyx_v_cutoff, Py_GE); __Pyx_XGOTREF(__pyx_t_22); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 566, __pyx_L25_error)
                      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                      __pyx_t_5 = 0;
                      {
                        PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_t_20, __pyx_t_22};
                        __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 564, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_2);
                      }
                      __pyx_t_6 = __pyx_t_2;
                      __Pyx_INCREF(__pyx_t_6);
                      __pyx_t_5 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_int_1};
                        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_limit, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 568, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_4);
                      }
                      __Pyx_GIVEREF(__pyx_t_4);
                      __pyx_cur_scope->__pyx_v_query = __pyx_t_4;
                      __pyx_t_4 = 0;

                      /* "ws_package/controllers/activity_controller.py":570
 *                         .limit(1)
 *                     )
 *                     result = await asyncio.wait_for(             # <<<<<<<<<<<<<<
 *                         session.execute(query),
 *                         timeout=DB_OPERATION_TIMEOUT,
*/
                      __pyx_t_2 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 570, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_6);
                      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_wait_for); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 570, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_1);
                      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

                      /* "ws_package/controllers/activity_controller.py":571
 *                     )
 *                     result = await asyncio.wait_for(
 *                         session.execute(query),             # <<<<<<<<<<<<<<
 *                         timeout=DB_OPERATION_TIMEOUT,
 *                     )
*/
                      __pyx_t_22 = __pyx_cur_scope->__pyx_v_session;
                      __Pyx_INCREF(__pyx_t_22);
                      __pyx_t_5 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_22, __pyx_cur_scope->__pyx_v_query};
                        __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 571, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_6);
                      }

                      /* "ws_package/controllers/activity_controller.py":572
 *                     result = await asyncio.wait_for(
 *                         session.execute(query),
 *                         timeout=DB_OPERATION_TIMEOUT,             # <<<<<<<<<<<<<<
 *                     )
 *                     return result.first() is not None
*/
                      __pyx_t_22 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_DB_OPERATION_TIMEOUT); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 572, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __pyx_t_5 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_1))) {
                        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
                        assert(__pyx_t_2);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
                        __Pyx_INCREF(__pyx_t_2);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
                        __pyx_t_5 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_2, __pyx_t_6};
                        __pyx_t_20 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 570, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_20);
                        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_timeout, __pyx_t_22, __pyx_t_20, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 570, __pyx_L25_error)
                        __pyx_t_4 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_20);
                        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 570, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_4);
                      }
                      __pyx_t_12 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      if (likely(__pyx_t_12 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_7);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_7;
                        __Pyx_XGIVEREF(__pyx_t_8);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_8;
                        __Pyx_XGIVEREF(__pyx_t_9);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 2;
                        return __pyx_r;
                        __pyx_L31_resume_from_await:;
                        __pyx_t_7 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_7);
                        __pyx_t_8 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_8);
                        __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_9);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 570, __pyx_L25_error)
                        __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                      } else if (likely(__pyx_t_12 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 570, __pyx_L25_error)
                      }
                      __Pyx_GIVEREF(__pyx_t_4);
                      __pyx_cur_scope->__pyx_v_result = __pyx_t_4;
                      __pyx_t_4 = 0;

                      /* "ws_package/controllers/activity_controller.py":574
 *                         timeout=DB_OPERATION_TIMEOUT,
 *                     )
 *                     return result.first() is not None             # <<<<<<<<<<<<<<
 *                 except asyncio.TimeoutError:
 *                     logger.error(
*/
                      __Pyx_XDECREF(__pyx_r);
                      __pyx_t_1 = __pyx_cur_scope->__pyx_v_result;
                      __Pyx_INCREF(__pyx_t_1);
                      __pyx_t_5 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
                        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_first, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 574, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_4);
                      }
                      __pyx_t_23 = (__pyx_t_4 != Py_None);
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __pyx_t_4 = __Pyx_PyBool_FromLong(__pyx_t_23); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 574, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __pyx_r = __pyx_t_4;
                      __pyx_t_4 = 0;
                      goto __pyx_L29_try_return;

                      /* "ws_package/controllers/activity_controller.py":561
 *         with db_lock_manager.read_lock():
 *             async with async_session() as session:
 *                 try:             # <<<<<<<<<<<<<<
 *                     query = (
 *                         select(ActivityInterval.id)
*/
                    }
                    __pyx_L25_error:;
                    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

                    /* "ws_package/controllers/activity_controller.py":575
 *                     )
 *                     return result.first() is not None
 *                 except asyncio.TimeoutError:             # <<<<<<<<<<<<<<
 *                     logger.error(
 *                         "Timeout checking recent intervals for counter=%s",
*/
                    __Pyx_ErrFetch(&__pyx_t_4, &__pyx_t_1, &__pyx_t_20);
                    __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 575, __pyx_L27_except_error)
                    __Pyx_GOTREF(__pyx_t_22);
                    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_TimeoutError); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 575, __pyx_L27_except_error)
                    __Pyx_GOTREF(__pyx_t_6);
                    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                    __pyx_t_24 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_4, __pyx_t_6);
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_ErrRestore(__pyx_t_4, __pyx_t_1, __pyx_t_20);
                    __pyx_t_4 = 0; __pyx_t_1 = 0; __pyx_t_20 = 0;
                    if (__pyx_t_24) {
                      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.has_recent_intervals_on_write_counter", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_20, &__pyx_t_1, &__pyx_t_4) < 0) __PYX_ERR(0, 575, __pyx_L27_except_error)
                      __Pyx_XGOTREF(__pyx_t_20);
                      __Pyx_XGOTREF(__pyx_t_1);
                      __Pyx_XGOTREF(__pyx_t_4);

                      /* "ws_package/controllers/activity_controller.py":576
 *                     return result.first() is not None
 *                 except asyncio.TimeoutError:
 *                     logger.error(             # <<<<<<<<<<<<<<
 *                         "Timeout checking recent intervals for counter=%s",
 *                         write_counter,
*/
                      __pyx_t_22 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 576, __pyx_L27_except_error)
                      __Pyx_GOTREF(__pyx_t_2);
                      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 576, __pyx_L27_except_error)
                      __Pyx_GOTREF(__pyx_t_3);
                      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

                      /* "ws_package/controllers/activity_controller.py":578
 *                     logger.error(
 *                         "Timeout checking recent intervals for counter=%s",
 *                         write_counter,             # <<<<<<<<<<<<<<
 *                     )
 *                     return False
*/
                      __pyx_t_5 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_3))) {
                        __pyx_t_22 = PyMethod_GET_SELF(__pyx_t_3);
                        assert(__pyx_t_22);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
                        __Pyx_INCREF(__pyx_t_22);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
                        __pyx_t_5 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[3] = {__pyx_t_22, __pyx_mstate_global->__pyx_kp_u_Timeout_checking_recent_interval, __pyx_cur_scope->__pyx_v_write_counter};
                        __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 576, __pyx_L27_except_error)
                        __Pyx_GOTREF(__pyx_t_6);
                      }
                      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

                      /* "ws_package/controllers/activity_controller.py":580
 *                         write_counter,
 *                     )
 *                     return False             # <<<<<<<<<<<<<<
 *                 except Exception as e:
 *                     logger.error("Error checking recent intervals: %s", e)
*/
                      __Pyx_XDECREF(__pyx_r);
                      __Pyx_INCREF(Py_False);
                      __pyx_r = Py_False;
                      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                      goto __pyx_L28_except_return;
                    }

                    /* "ws_package/controllers/activity_controller.py":581
 *                     )
 *                     return False
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Error checking recent intervals: %s", e)
 *                     return False
*/
                    __pyx_t_24 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                    if (__pyx_t_24) {
                      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.has_recent_intervals_on_write_counter", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_1, &__pyx_t_20) < 0) __PYX_ERR(0, 581, __pyx_L27_except_error)
                      __Pyx_XGOTREF(__pyx_t_4);
                      __Pyx_XGOTREF(__pyx_t_1);
                      __Pyx_XGOTREF(__pyx_t_20);
                      __Pyx_INCREF(__pyx_t_1);
                      __Pyx_GIVEREF(__pyx_t_1);
                      __pyx_cur_scope->__pyx_v_e = __pyx_t_1;
                      /*try:*/ {

                        /* "ws_package/controllers/activity_controller.py":582
 *                     return False
 *                 except Exception as e:
 *                     logger.error("Error checking recent intervals: %s", e)             # <<<<<<<<<<<<<<
 *                     return False
 * 
*/
                        __pyx_t_3 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 582, __pyx_L39_error)
                        __Pyx_GOTREF(__pyx_t_22);
                        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 582, __pyx_L39_error)
                        __Pyx_GOTREF(__pyx_t_2);
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __pyx_t_5 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_2))) {
                          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
                          assert(__pyx_t_3);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
                          __Pyx_INCREF(__pyx_t_3);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
                          __pyx_t_5 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Error_checking_recent_intervals, __pyx_cur_scope->__pyx_v_e};
                          __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 582, __pyx_L39_error)
                          __Pyx_GOTREF(__pyx_t_6);
                        }
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

                        /* "ws_package/controllers/activity_controller.py":583
 *                 except Exception as e:
 *                     logger.error("Error checking recent intervals: %s", e)
 *                     return False             # <<<<<<<<<<<<<<
 * 
 *     def set_project_task_ids(
*/
                        __Pyx_XDECREF(__pyx_r);
                        __Pyx_INCREF(Py_False);
                        __pyx_r = Py_False;
                        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        goto __pyx_L38_return;
                      }

                      /* "ws_package/controllers/activity_controller.py":581
 *                     )
 *                     return False
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Error checking recent intervals: %s", e)
 *                     return False
*/
                      /*finally:*/ {
                        __pyx_L39_error:;
                        /*exception exit:*/{
                          __Pyx_PyThreadState_assign
                          __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0;
                          __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                          __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                          __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                           __Pyx_ExceptionSwap(&__pyx_t_30, &__pyx_t_31, &__pyx_t_32);
                          if ( unlikely(__Pyx_GetException(&__pyx_t_27, &__pyx_t_28, &__pyx_t_29) < 0)) __Pyx_ErrFetch(&__pyx_t_27, &__pyx_t_28, &__pyx_t_29);
                          __Pyx_XGOTREF(__pyx_t_27);
                          __Pyx_XGOTREF(__pyx_t_28);
                          __Pyx_XGOTREF(__pyx_t_29);
                          __Pyx_XGOTREF(__pyx_t_30);
                          __Pyx_XGOTREF(__pyx_t_31);
                          __Pyx_XGOTREF(__pyx_t_32);
                          __pyx_t_24 = __pyx_lineno; __pyx_t_25 = __pyx_clineno; __pyx_t_26 = __pyx_filename;
                          {
                            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                          }
                          __Pyx_XGIVEREF(__pyx_t_30);
                          __Pyx_XGIVEREF(__pyx_t_31);
                          __Pyx_XGIVEREF(__pyx_t_32);
                          __Pyx_ExceptionReset(__pyx_t_30, __pyx_t_31, __pyx_t_32);
                          __Pyx_XGIVEREF(__pyx_t_27);
                          __Pyx_XGIVEREF(__pyx_t_28);
                          __Pyx_XGIVEREF(__pyx_t_29);
                          __Pyx_ErrRestore(__pyx_t_27, __pyx_t_28, __pyx_t_29);
                          __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0;
                          __pyx_lineno = __pyx_t_24; __pyx_clineno = __pyx_t_25; __pyx_filename = __pyx_t_26;
                          goto __pyx_L27_except_error;
                        }
                        __pyx_L38_return: {
                          __pyx_t_32 = __pyx_r;
                          __pyx_r = 0;
                          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                          __pyx_r = __pyx_t_32;
                          __pyx_t_32 = 0;
                          goto __pyx_L28_except_return;
                        }
                      }
                    }
                    goto __pyx_L27_except_error;

                    /* "ws_package/controllers/activity_controller.py":561
 *         with db_lock_manager.read_lock():
 *             async with async_session() as session:
 *                 try:             # <<<<<<<<<<<<<<
 *                     query = (
 *                         select(ActivityInterval.id)
*/
                    __pyx_L27_except_error:;
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
                    goto __pyx_L19_error;
                    __pyx_L29_try_return:;
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
                    goto __pyx_L23_try_return;
                    __pyx_L28_except_return:;
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
                    goto __pyx_L23_try_return;
                  }

                  /* "ws_package/controllers/activity_controller.py":560
 *         cutoff = datetime.datetime.now() - datetime.timedelta(seconds=within_seconds)
 *         with db_lock_manager.read_lock():
 *             async with async_session() as session:             # <<<<<<<<<<<<<<
 *                 try:
 *                     query = (
*/
                }
                __pyx_L19_error:;
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                /*except:*/ {
                  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.has_recent_intervals_on_write_counter", __pyx_clineno, __pyx_lineno, __pyx_filename);
                  if (__Pyx_GetException(&__pyx_t_20, &__pyx_t_1, &__pyx_t_4) < 0) __PYX_ERR(0, 560, __pyx_L21_except_error)
                  __Pyx_XGOTREF(__pyx_t_20);
                  __Pyx_XGOTREF(__pyx_t_1);
                  __Pyx_XGOTREF(__pyx_t_4);
                  __pyx_t_6 = PyTuple_Pack(3, __pyx_t_20, __pyx_t_1, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 560, __pyx_L21_except_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_6, NULL);
                  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 560, __pyx_L21_except_error)
                  __Pyx_GOTREF(__pyx_t_18);
                  __pyx_t_12 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_18, &__pyx_r);
                  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                  if (likely(__pyx_t_12 == PYGEN_NEXT)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_XGIVEREF(__pyx_t_1);
                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                    __Pyx_XGIVEREF(__pyx_t_4);
                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
                    __Pyx_XGIVEREF(__pyx_t_7);
                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
                    __Pyx_XGIVEREF(__pyx_t_8);
                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_8;
                    __Pyx_XGIVEREF(__pyx_t_9);
                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_9;
                    __Pyx_XGIVEREF(__pyx_t_10);
                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_10;
                    __Pyx_XGIVEREF(__pyx_t_11);
                    __pyx_cur_scope->__pyx_t_6 = __pyx_t_11;
                    __Pyx_XGIVEREF(__pyx_t_13);
                    __pyx_cur_scope->__pyx_t_7 = __pyx_t_13;
                    __Pyx_XGIVEREF(__pyx_t_14);
                    __pyx_cur_scope->__pyx_t_8 = __pyx_t_14;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __pyx_cur_scope->__pyx_t_9 = __pyx_t_15;
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __pyx_cur_scope->__pyx_t_10 = __pyx_t_18;
                    __Pyx_XGIVEREF(__pyx_t_20);
                    __pyx_cur_scope->__pyx_t_11 = __pyx_t_20;
                    __Pyx_XGIVEREF(__pyx_r);
                    __Pyx_RefNannyFinishContext();
                    __Pyx_Coroutine_SwapException(__pyx_generator);
                    /* return from generator, awaiting value */
                    __pyx_generator->resume_label = 3;
                    return __pyx_r;
                    __pyx_L48_resume_from_await:;
                    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                    __pyx_cur_scope->__pyx_t_0 = 0;
                    __Pyx_XGOTREF(__pyx_t_1);
                    __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
                    __pyx_cur_scope->__pyx_t_1 = 0;
                    __Pyx_XGOTREF(__pyx_t_4);
                    __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
                    __pyx_cur_scope->__pyx_t_2 = 0;
                    __Pyx_XGOTREF(__pyx_t_7);
                    __pyx_t_8 = __pyx_cur_scope->__pyx_t_3;
                    __pyx_cur_scope->__pyx_t_3 = 0;
                    __Pyx_XGOTREF(__pyx_t_8);
                    __pyx_t_9 = __pyx_cur_scope->__pyx_t_4;
                    __pyx_cur_scope->__pyx_t_4 = 0;
                    __Pyx_XGOTREF(__pyx_t_9);
                    __pyx_t_10 = __pyx_cur_scope->__pyx_t_5;
                    __pyx_cur_scope->__pyx_t_5 = 0;
                    __Pyx_XGOTREF(__pyx_t_10);
                    __pyx_t_11 = __pyx_cur_scope->__pyx_t_6;
                    __pyx_cur_scope->__pyx_t_6 = 0;
                    __Pyx_XGOTREF(__pyx_t_11);
                    __pyx_t_13 = __pyx_cur_scope->__pyx_t_7;
                    __pyx_cur_scope->__pyx_t_7 = 0;
                    __Pyx_XGOTREF(__pyx_t_13);
                    __pyx_t_14 = __pyx_cur_scope->__pyx_t_8;
                    __pyx_cur_scope->__pyx_t_8 = 0;
                    __Pyx_XGOTREF(__pyx_t_14);
                    __pyx_t_15 = __pyx_cur_scope->__pyx_t_9;
                    __pyx_cur_scope->__pyx_t_9 = 0;
                    __Pyx_XGOTREF(__pyx_t_15);
                    __pyx_t_18 = __pyx_cur_scope->__pyx_t_10;
                    __pyx_cur_scope->__pyx_t_10 = 0;
                    __Pyx_XGOTREF(__pyx_t_18);
                    __pyx_t_20 = __pyx_cur_scope->__pyx_t_11;
                    __pyx_cur_scope->__pyx_t_11 = 0;
                    __Pyx_XGOTREF(__pyx_t_20);
                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 560, __pyx_L21_except_error)
                    __pyx_t_6 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_6);
                  } else if (likely(__pyx_t_12 == PYGEN_RETURN)) {
                    __Pyx_GOTREF(__pyx_r);
                    __pyx_t_6 = __pyx_r; __pyx_r = NULL;
                  } else {
                    __Pyx_XGOTREF(__pyx_r);
                    __PYX_ERR(0, 560, __pyx_L21_except_error)
                  }
                  __pyx_t_18 = __pyx_t_6;
                  __pyx_t_6 = 0;
                  __pyx_t_23 = __Pyx_PyObject_IsTrue(__pyx_t_18);
                  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                  if (__pyx_t_23 < (0)) __PYX_ERR(0, 560, __pyx_L21_except_error)
                  __pyx_t_33 = (!__pyx_t_23);
                  if (unlikely(__pyx_t_33)) {
                    __Pyx_GIVEREF(__pyx_t_20);
                    __Pyx_GIVEREF(__pyx_t_1);
                    __Pyx_XGIVEREF(__pyx_t_4);
                    __Pyx_ErrRestoreWithState(__pyx_t_20, __pyx_t_1, __pyx_t_4);
                    __pyx_t_20 = 0;  __pyx_t_1 = 0;  __pyx_t_4 = 0; 
                    __PYX_ERR(0, 560, __pyx_L21_except_error)
                  }
                  __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  goto __pyx_L20_exception_handled;
                }
                __pyx_L21_except_error:;
                __Pyx_XGIVEREF(__pyx_t_13);
                __Pyx_XGIVEREF(__pyx_t_14);
                __Pyx_XGIVEREF(__pyx_t_15);
                __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
                goto __pyx_L8_error;
                __pyx_L23_try_return:;
                __Pyx_XGIVEREF(__pyx_t_13);
                __Pyx_XGIVEREF(__pyx_t_14);
                __Pyx_XGIVEREF(__pyx_t_15);
                __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
                goto __pyx_L16_return;
                __pyx_L20_exception_handled:;
                __Pyx_XGIVEREF(__pyx_t_13);
                __Pyx_XGIVEREF(__pyx_t_14);
                __Pyx_XGIVEREF(__pyx_t_15);
                __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
              }
            }
            /*finally:*/ {
              /*normal exit:*/{
                if (__pyx_t_11) {
                  __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_mstate_global->__pyx_tuple[7], NULL);
                  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
                  if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 560, __pyx_L8_error)
                  __Pyx_GOTREF(__pyx_t_15);
                  __pyx_t_12 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_15, &__pyx_r);
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  if (likely(__pyx_t_12 == PYGEN_NEXT)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_XGIVEREF(__pyx_t_7);
                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_7;
                    __Pyx_XGIVEREF(__pyx_t_8);
                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_8;
                    __Pyx_XGIVEREF(__pyx_t_9);
                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
                    __Pyx_XGIVEREF(__pyx_t_10);
                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                    __Pyx_XGIVEREF(__pyx_t_11);
                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_15;
                    __Pyx_XGIVEREF(__pyx_r);
                    __Pyx_RefNannyFinishContext();
                    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                    /* return from generator, awaiting value */
                    __pyx_generator->resume_label = 4;
                    return __pyx_r;
                    __pyx_L49_resume_from_await:;
                    __pyx_t_7 = __pyx_cur_scope->__pyx_t_0;
                    __pyx_cur_scope->__pyx_t_0 = 0;
                    __Pyx_XGOTREF(__pyx_t_7);
                    __pyx_t_8 = __pyx_cur_scope->__pyx_t_1;
                    __pyx_cur_scope->__pyx_t_1 = 0;
                    __Pyx_XGOTREF(__pyx_t_8);
                    __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
                    __pyx_cur_scope->__pyx_t_2 = 0;
                    __Pyx_XGOTREF(__pyx_t_9);
                    __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                    __pyx_cur_scope->__pyx_t_3 = 0;
                    __Pyx_XGOTREF(__pyx_t_10);
                    __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
                    __pyx_cur_scope->__pyx_t_4 = 0;
                    __Pyx_XGOTREF(__pyx_t_11);
                    __pyx_t_15 = __pyx_cur_scope->__pyx_t_5;
                    __pyx_cur_scope->__pyx_t_5 = 0;
                    __Pyx_XGOTREF(__pyx_t_15);
                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 560, __pyx_L8_error)
                    __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                  } else if (likely(__pyx_t_12 == PYGEN_RETURN)) {
                    __Pyx_GOTREF(__pyx_r);
                    __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                  } else {
                    __Pyx_XGOTREF(__pyx_r);
                    __PYX_ERR(0, 560, __pyx_L8_error)
                  }
                  __pyx_t_15 = __pyx_t_4;
                  __pyx_t_4 = 0;
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                }
                goto __pyx_L18;
              }
              __pyx_L16_return: {
                __pyx_t_15 = __pyx_r;
                __pyx_r = 0;
                if (__pyx_t_11) {
                  __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_mstate_global->__pyx_tuple[7], NULL);
                  __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
                  if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 560, __pyx_L8_error)
                  __Pyx_GOTREF(__pyx_t_14);
                  __pyx_t_12 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_14, &__pyx_r);
                  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                  if (likely(__pyx_t_12 == PYGEN_NEXT)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_XGIVEREF(__pyx_t_7);
                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_7;
                    __Pyx_XGIVEREF(__pyx_t_8);
                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_8;
                    __Pyx_XGIVEREF(__pyx_t_9);
                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
                    __Pyx_XGIVEREF(__pyx_t_10);
                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                    __Pyx_XGIVEREF(__pyx_t_11);
                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
                    __Pyx_XGIVEREF(__pyx_t_14);
                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __pyx_cur_scope->__pyx_t_6 = __pyx_t_15;
                    __Pyx_XGIVEREF(__pyx_r);
                    __Pyx_RefNannyFinishContext();
                    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                    /* return from generator, awaiting value */
                    __pyx_generator->resume_label = 5;
                    return __pyx_r;
                    __pyx_L50_resume_from_await:;
                    __pyx_t_7 = __pyx_cur_scope->__pyx_t_0;
                    __pyx_cur_scope->__pyx_t_0 = 0;
                    __Pyx_XGOTREF(__pyx_t_7);
                    __pyx_t_8 = __pyx_cur_scope->__pyx_t_1;
                    __pyx_cur_scope->__pyx_t_1 = 0;
                    __Pyx_XGOTREF(__pyx_t_8);
                    __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
                    __pyx_cur_scope->__pyx_t_2 = 0;
                    __Pyx_XGOTREF(__pyx_t_9);
                    __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                    __pyx_cur_scope->__pyx_t_3 = 0;
                    __Pyx_XGOTREF(__pyx_t_10);
                    __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
                    __pyx_cur_scope->__pyx_t_4 = 0;
                    __Pyx_XGOTREF(__pyx_t_11);
                    __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                    __pyx_cur_scope->__pyx_t_5 = 0;
                    __Pyx_XGOTREF(__pyx_t_14);
                    __pyx_t_15 = __pyx_cur_scope->__pyx_t_6;
                    __pyx_cur_scope->__pyx_t_6 = 0;
                    __Pyx_XGOTREF(__pyx_t_15);
                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 560, __pyx_L8_error)
                    __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                  } else if (likely(__pyx_t_12 == PYGEN_RETURN)) {
                    __Pyx_GOTREF(__pyx_r);
                    __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                  } else {
                    __Pyx_XGOTREF(__pyx_r);
                    __PYX_ERR(0, 560, __pyx_L8_error)
                  }
                  __pyx_t_14 = __pyx_t_4;
                  __pyx_t_4 = 0;
                  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                }
                __pyx_r = __pyx_t_15;
                __pyx_t_15 = 0;
                goto __pyx_L12_try_return;
              }
              __pyx_L18:;
            }
            goto __pyx_L51;
            __pyx_L14_error:;
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            goto __pyx_L8_error;
            __pyx_L51:;
          }

          /* "ws_package/controllers/activity_controller.py":559
 *         write_counter = self.last_count + 1
 *         cutoff = datetime.datetime.now() - datetime.timedelta(seconds=within_seconds)
 *         with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *             async with async_session() as session:
 *                 try:
*/
        }
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L13_try_end;
        __pyx_L8_error:;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
        __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
        __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        /*except:*/ {
          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.has_recent_intervals_on_write_counter", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_1, &__pyx_t_20) < 0) __PYX_ERR(0, 559, __pyx_L10_except_error)
          __Pyx_XGOTREF(__pyx_t_4);
          __Pyx_XGOTREF(__pyx_t_1);
          __Pyx_XGOTREF(__pyx_t_20);
          __pyx_t_6 = PyTuple_Pack(3, __pyx_t_4, __pyx_t_1, __pyx_t_20); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 559, __pyx_L10_except_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_6, NULL);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 559, __pyx_L10_except_error)
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_33 = __Pyx_PyObject_IsTrue(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (__pyx_t_33 < (0)) __PYX_ERR(0, 559, __pyx_L10_except_error)
          __pyx_t_23 = (!__pyx_t_33);
          if (unlikely(__pyx_t_23)) {
            __Pyx_GIVEREF(__pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_1);
            __Pyx_XGIVEREF(__pyx_t_20);
            __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_1, __pyx_t_20);
            __pyx_t_4 = 0;  __pyx_t_1 = 0;  __pyx_t_20 = 0; 
            __PYX_ERR(0, 559, __pyx_L10_except_error)
          }
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
          goto __pyx_L9_exception_handled;
        }
        __pyx_L10_except_error:;
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
        goto __pyx_L1_error;
        __pyx_L12_try_return:;
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
        goto __pyx_L5_return;
        __pyx_L9_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
        __pyx_L13_try_end:;
      }
    }
    /*finally:*/ {
      /*normal exit:*/{
        if (__pyx_t_7) {
          __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_mstate_global->__pyx_tuple[7], NULL);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 559, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }
        goto __pyx_L7;
      }
      __pyx_L5_return: {
        __pyx_t_10 = __pyx_r;
        __pyx_r = 0;
        if (__pyx_t_7) {
          __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_mstate_global->__pyx_tuple[7], NULL);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 559, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        }
        __pyx_r = __pyx_t_10;
        __pyx_t_10 = 0;
        goto __pyx_L0;
      }
      __pyx_L7:;
    }
    goto __pyx_L55;
    __pyx_L4_error:;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    goto __pyx_L1_error;
    __pyx_L55:;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":554
 *         return (datetime.datetime.now() - last_bump).total_seconds() < within_seconds
 * 
 *     async def has_recent_intervals_on_write_counter(self, within_seconds: int = 45) -> bool:             # <<<<<<<<<<<<<<
 *         """True if the current write counter already has intervals ended very recently (start retry)."""
 *         DB_OPERATION_TIMEOUT = 5.0
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("has_recent_intervals_on_write_counter", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":585
 *                     return False
 * 
 *     def set_project_task_ids(             # <<<<<<<<<<<<<<
 *         self,
 *         project_id: Optional[str],
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_22set_project_task_ids(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_21set_project_task_ids, "\n        Set the current project ID and task ID received from Electron.\n        When update_segment_start is True (default), sets current_segment_start_time to now\n        for in-flight payload filtering. Project switches use project_switch_event instead.\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_22set_project_task_ids = {"set_project_task_ids", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_22set_project_task_ids, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_21set_project_task_ids};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_22set_project_task_ids(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_project_id = 0;
  PyObject *__pyx_v_task_id = 0;
  int __pyx_v_update_segment_start;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[4] = {0,0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_project_task_ids (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_project_id,&__pyx_mstate_global->__pyx_n_u_task_id,&__pyx_mstate_global->__pyx_n_u_update_segment_start,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 585, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 585, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 585, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 585, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "set_project_task_ids", 0) < (0)) __PYX_ERR(0, 585, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 3; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("set_project_task_ids", 1, 3, 3, i); __PYX_ERR(0, 585, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 3)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 585, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 585, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 585, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_project_id = ((PyObject*)values[1]);
    __pyx_v_task_id = ((PyObject*)values[2]);
    if (values[3]) {
      __pyx_v_update_segment_start = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_update_segment_start == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 590, __pyx_L3_error)
    } else {

      /* "ws_package/controllers/activity_controller.py":590
 *         task_id: Optional[str],
 *         *,
 *         update_segment_start: bool = True,             # <<<<<<<<<<<<<<
 *     ) -> None:
 *         """
*/
      __pyx_v_update_segment_start = ((int)((int)1));
    }
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("set_project_task_ids", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 585, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.set_project_task_ids", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_project_id), (&PyUnicode_Type), 1, "project_id", 2))) __PYX_ERR(0, 587, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_task_id), (&PyUnicode_Type), 1, "task_id", 2))) __PYX_ERR(0, 588, __pyx_L1_error)
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_21set_project_task_ids(__pyx_self, __pyx_v_self, __pyx_v_project_id, __pyx_v_task_id, __pyx_v_update_segment_start);

  /* "ws_package/controllers/activity_controller.py":585
 *                     return False
 * 
 *     def set_project_task_ids(             # <<<<<<<<<<<<<<
 *         self,
 *         project_id: Optional[str],
*/

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  goto __pyx_L7_cleaned_up;
  __pyx_L0:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __pyx_L7_cleaned_up:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_21set_project_task_ids(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_project_id, PyObject *__pyx_v_task_id, int __pyx_v_update_segment_start) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  size_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set_project_task_ids", 0);

  /* "ws_package/controllers/activity_controller.py":597
 *         for in-flight payload filtering. Project switches use project_switch_event instead.
 *         """
 *         self.current_project_id = str(project_id) if project_id is not None else None             # <<<<<<<<<<<<<<
 *         self.current_task_id = str(task_id) if task_id is not None else None
 *         if update_segment_start:
*/
  __pyx_t_2 = (__pyx_v_project_id != ((PyObject*)Py_None));
  if (__pyx_t_2) {
    __pyx_t_3 = __Pyx_PyUnicode_Unicode(__pyx_v_project_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 597, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __pyx_t_3;
    __pyx_t_3 = 0;
  } else {
    __Pyx_INCREF(Py_None);
    __pyx_t_1 = Py_None;
  }
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_project_id, __pyx_t_1) < (0)) __PYX_ERR(0, 597, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":598
 *         """
 *         self.current_project_id = str(project_id) if project_id is not None else None
 *         self.current_task_id = str(task_id) if task_id is not None else None             # <<<<<<<<<<<<<<
 *         if update_segment_start:
 *             self.current_segment_start_time = datetime.datetime.now()
*/
  __pyx_t_2 = (__pyx_v_task_id != ((PyObject*)Py_None));
  if (__pyx_t_2) {
    __pyx_t_3 = __Pyx_PyUnicode_Unicode(__pyx_v_task_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 598, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_1 = __pyx_t_3;
    __pyx_t_3 = 0;
  } else {
    __Pyx_INCREF(Py_None);
    __pyx_t_1 = Py_None;
  }
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_task_id, __pyx_t_1) < (0)) __PYX_ERR(0, 598, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":599
 *         self.current_project_id = str(project_id) if project_id is not None else None
 *         self.current_task_id = str(task_id) if task_id is not None else None
 *         if update_segment_start:             # <<<<<<<<<<<<<<
 *             self.current_segment_start_time = datetime.datetime.now()
 *         logger.info(
*/
  if (__pyx_v_update_segment_start) {

    /* "ws_package/controllers/activity_controller.py":600
 *         self.current_task_id = str(task_id) if task_id is not None else None
 *         if update_segment_start:
 *             self.current_segment_start_time = datetime.datetime.now()             # <<<<<<<<<<<<<<
 *         logger.info(
 *             "ActivityController: Set project_id=%s, task_id=%s, segment_start=%s",
*/
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 600, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 600, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_3 = __pyx_t_5;
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_6 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
      __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 600, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_segment_start_time, __pyx_t_1) < (0)) __PYX_ERR(0, 600, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "ws_package/controllers/activity_controller.py":599
 *         self.current_project_id = str(project_id) if project_id is not None else None
 *         self.current_task_id = str(task_id) if task_id is not None else None
 *         if update_segment_start:             # <<<<<<<<<<<<<<
 *             self.current_segment_start_time = datetime.datetime.now()
 *         logger.info(
*/
  }

  /* "ws_package/controllers/activity_controller.py":601
 *         if update_segment_start:
 *             self.current_segment_start_time = datetime.datetime.now()
 *         logger.info(             # <<<<<<<<<<<<<<
 *             "ActivityController: Set project_id=%s, task_id=%s, segment_start=%s",
 *             self.current_project_id,
*/
  __pyx_t_5 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 601, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 601, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "ws_package/controllers/activity_controller.py":603
 *         logger.info(
 *             "ActivityController: Set project_id=%s, task_id=%s, segment_start=%s",
 *             self.current_project_id,             # <<<<<<<<<<<<<<
 *             self.current_task_id,
 *             self.current_segment_start_time if update_segment_start else "(unchanged)",
*/
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_project_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 603, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "ws_package/controllers/activity_controller.py":604
 *             "ActivityController: Set project_id=%s, task_id=%s, segment_start=%s",
 *             self.current_project_id,
 *             self.current_task_id,             # <<<<<<<<<<<<<<
 *             self.current_segment_start_time if update_segment_start else "(unchanged)",
 *         )
*/
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_task_id); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 604, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "ws_package/controllers/activity_controller.py":605
 *             self.current_project_id,
 *             self.current_task_id,
 *             self.current_segment_start_time if update_segment_start else "(unchanged)",             # <<<<<<<<<<<<<<
 *         )
 * 
*/
  if (__pyx_v_update_segment_start) {
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_segment_start_time); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 605, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_8 = __pyx_t_9;
    __pyx_t_9 = 0;
  } else {
    __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_unchanged);
    __pyx_t_8 = __pyx_mstate_global->__pyx_kp_u_unchanged;
  }
  __pyx_t_6 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_5);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_6 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[5] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_ActivityController_Set_project_i, __pyx_t_3, __pyx_t_7, __pyx_t_8};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_6, (5-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 601, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":585
 *                     return False
 * 
 *     def set_project_task_ids(             # <<<<<<<<<<<<<<
 *         self,
 *         project_id: Optional[str],
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.set_project_task_ids", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_25generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":608
 *         )
 * 
 *     async def _trim_open_partial_at_project_switch(             # <<<<<<<<<<<<<<
 *         self, switch_time: datetime.datetime
 *     ):
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_24_trim_open_partial_at_project_switch(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_23_trim_open_partial_at_project_switch, "\n        When switching again before the slot boundary, trim the open partial interval\n        (e.g. 18:42:14-18:45) so it ends at switch_time instead of using a future end_time\n        as the start of a bogus closing interval.\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_24_trim_open_partial_at_project_switch = {"_trim_open_partial_at_project_switch", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_24_trim_open_partial_at_project_switch, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_23_trim_open_partial_at_project_switch};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_24_trim_open_partial_at_project_switch(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_switch_time = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_trim_open_partial_at_project_switch (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_switch_time,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 608, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 608, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 608, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_trim_open_partial_at_project_switch", 0) < (0)) __PYX_ERR(0, 608, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_trim_open_partial_at_project_switch", 1, 2, 2, i); __PYX_ERR(0, 608, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 608, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 608, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_switch_time = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_trim_open_partial_at_project_switch", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 608, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._trim_open_partial_at_project_switch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23_trim_open_partial_at_project_switch(__pyx_self, __pyx_v_self, __pyx_v_switch_time);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23_trim_open_partial_at_project_switch(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_switch_time) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_trim_open_partial_at_project_switch", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 608, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_switch_time = __pyx_v_switch_time;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_switch_time);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_switch_time);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_25generator1, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[1]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_trim_open_partial_at_project_sw, __pyx_mstate_global->__pyx_n_u_ActivityController__trim_open_pa, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 608, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._trim_open_partial_at_project_switch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_25generator1(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  size_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  __Pyx_PySendResult __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  PyObject *__pyx_t_26 = NULL;
  int __pyx_t_27;
  PyObject *__pyx_t_28 = NULL;
  int __pyx_t_29;
  int __pyx_t_30;
  int __pyx_t_31;
  char const *__pyx_t_32;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_trim_open_partial_at_project_switch", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L21_resume_from_await;
    case 2: goto __pyx_L31_resume_from_await;
    case 3: goto __pyx_L33_resume_from_await;
    case 4: goto __pyx_L37_resume_from_await;
    case 5: goto __pyx_L38_resume_from_await;
    case 6: goto __pyx_L39_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 608, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":616
 *         as the start of a bogus closing interval.
 *         """
 *         switch_time = switch_time.replace(microsecond=0)             # <<<<<<<<<<<<<<
 *         write_counter = self.last_count + 1
 *         try:
*/
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_switch_time;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_3 = 0;
  {
    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_2, NULL};
    __pyx_t_4 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 616, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_4, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 616, __pyx_L1_error)
    __pyx_t_1 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 616, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_switch_time);
  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_switch_time, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":617
 *         """
 *         switch_time = switch_time.replace(microsecond=0)
 *         write_counter = self.last_count + 1             # <<<<<<<<<<<<<<
 *         try:
 *             with db_lock_manager.write_lock():
*/
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 617, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyLong_AddObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 617, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_cur_scope->__pyx_v_write_counter = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":618
 *         switch_time = switch_time.replace(microsecond=0)
 *         write_counter = self.last_count + 1
 *         try:             # <<<<<<<<<<<<<<
 *             with db_lock_manager.write_lock():
 *                 async with async_session() as session:
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_7);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":619
 *         write_counter = self.last_count + 1
 *         try:
 *             with db_lock_manager.write_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     query = (
*/
      /*with:*/ {
        __pyx_t_1 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 619, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_write_lock); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 619, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_3 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_8);
          assert(__pyx_t_1);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
          __pyx_t_3 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 619, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __pyx_t_9 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 619, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_1 = NULL;
        __pyx_t_2 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 619, __pyx_L10_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = 1;
        #if CYTHON_UNPACK_METHODS
        if (likely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
          assert(__pyx_t_1);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
          __pyx_t_3 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
          __pyx_t_8 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 619, __pyx_L10_error)
          __Pyx_GOTREF(__pyx_t_8);
        }
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        /*try:*/ {
          {
            __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
            __Pyx_XGOTREF(__pyx_t_10);
            __Pyx_XGOTREF(__pyx_t_11);
            __Pyx_XGOTREF(__pyx_t_12);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":620
 *         try:
 *             with db_lock_manager.write_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     query = (
 *                         select(ActivityInterval)
*/
              /*with:*/ {
                __pyx_t_8 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 620, __pyx_L14_error)
                __Pyx_GOTREF(__pyx_t_2);
                __pyx_t_3 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_2))) {
                  __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
                  assert(__pyx_t_8);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
                  __Pyx_INCREF(__pyx_t_8);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
                  __pyx_t_3 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
                  __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 620, __pyx_L14_error)
                  __Pyx_GOTREF(__pyx_t_4);
                }
                __pyx_t_13 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 620, __pyx_L14_error)
                __Pyx_GOTREF(__pyx_t_13);
                __pyx_t_8 = NULL;
                __pyx_t_1 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 620, __pyx_L20_error)
                __Pyx_GOTREF(__pyx_t_1);
                __pyx_t_3 = 1;
                #if CYTHON_UNPACK_METHODS
                if (likely(PyMethod_Check(__pyx_t_1))) {
                  __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_1);
                  assert(__pyx_t_8);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
                  __Pyx_INCREF(__pyx_t_8);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
                  __pyx_t_3 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
                  __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 620, __pyx_L20_error)
                  __Pyx_GOTREF(__pyx_t_2);
                }
                __pyx_t_14 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_2, &__pyx_r);
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                if (likely(__pyx_t_14 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_4);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_4;
                  __Pyx_XGIVEREF(__pyx_t_5);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_5;
                  __Pyx_XGIVEREF(__pyx_t_6);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_6;
                  __Pyx_XGIVEREF(__pyx_t_7);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_7;
                  __Pyx_XGIVEREF(__pyx_t_9);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_9;
                  __Pyx_XGIVEREF(__pyx_t_10);
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_10;
                  __Pyx_XGIVEREF(__pyx_t_11);
                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_11;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 1;
                  return __pyx_r;
                  __pyx_L21_resume_from_await:;
                  __pyx_t_4 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_4);
                  __pyx_t_5 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_5);
                  __pyx_t_6 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_6);
                  __pyx_t_7 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_7);
                  __pyx_t_9 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_9);
                  __pyx_t_10 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = 0;
                  __Pyx_XGOTREF(__pyx_t_10);
                  __pyx_t_11 = __pyx_cur_scope->__pyx_t_6;
                  __pyx_cur_scope->__pyx_t_6 = 0;
                  __Pyx_XGOTREF(__pyx_t_11);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_7;
                  __pyx_cur_scope->__pyx_t_7 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_8;
                  __pyx_cur_scope->__pyx_t_8 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 620, __pyx_L20_error)
                  __pyx_t_2 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_2);
                } else if (likely(__pyx_t_14 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __pyx_t_2 = __pyx_r; __pyx_r = NULL;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 620, __pyx_L20_error)
                }
                __pyx_t_1 = __pyx_t_2;
                __pyx_t_2 = 0;
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                /*try:*/ {
                  {
                    __Pyx_ExceptionSave(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
                    __Pyx_XGOTREF(__pyx_t_15);
                    __Pyx_XGOTREF(__pyx_t_16);
                    __Pyx_XGOTREF(__pyx_t_17);
                    /*try:*/ {
                      __Pyx_GIVEREF(__pyx_t_1);
                      __pyx_cur_scope->__pyx_v_session = __pyx_t_1;
                      __pyx_t_1 = 0;

                      /* "ws_package/controllers/activity_controller.py":622
 *                 async with async_session() as session:
 *                     query = (
 *                         select(ActivityInterval)             # <<<<<<<<<<<<<<
 *                         .where(
 *                             ActivityInterval.counter == write_counter,
*/
                      __pyx_t_21 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 622, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 622, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_23);
                      __pyx_t_3 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_22))) {
                        __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_22);
                        assert(__pyx_t_21);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_22);
                        __Pyx_INCREF(__pyx_t_21);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_22, __pyx__function);
                        __pyx_t_3 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_21, __pyx_t_23};
                        __pyx_t_20 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_22, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 622, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_20);
                      }
                      __pyx_t_19 = __pyx_t_20;
                      __Pyx_INCREF(__pyx_t_19);

                      /* "ws_package/controllers/activity_controller.py":624
 *                         select(ActivityInterval)
 *                         .where(
 *                             ActivityInterval.counter == write_counter,             # <<<<<<<<<<<<<<
 *                             ActivityInterval.is_uploaded.is_(False),
 *                             ActivityInterval.is_break == 0,
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 624, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 624, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_23);
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                      __pyx_t_22 = PyObject_RichCompare(__pyx_t_23, __pyx_cur_scope->__pyx_v_write_counter, Py_EQ); __Pyx_XGOTREF(__pyx_t_22); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 624, __pyx_L25_error)
                      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

                      /* "ws_package/controllers/activity_controller.py":625
 *                         .where(
 *                             ActivityInterval.counter == write_counter,
 *                             ActivityInterval.is_uploaded.is_(False),             # <<<<<<<<<<<<<<
 *                             ActivityInterval.is_break == 0,
 *                             ActivityInterval.start_time <= switch_time,
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 625, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_24);
                      __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_is_uploaded); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 625, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_25);
                      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                      __pyx_t_21 = __pyx_t_25;
                      __Pyx_INCREF(__pyx_t_21);
                      __pyx_t_3 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_21, Py_False};
                        __pyx_t_23 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                        if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 625, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_23);
                      }

                      /* "ws_package/controllers/activity_controller.py":626
 *                             ActivityInterval.counter == write_counter,
 *                             ActivityInterval.is_uploaded.is_(False),
 *                             ActivityInterval.is_break == 0,             # <<<<<<<<<<<<<<
 *                             ActivityInterval.start_time <= switch_time,
 *                             ActivityInterval.end_time > switch_time,
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 626, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_25);
                      __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_is_break); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 626, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                      __pyx_t_25 = __Pyx_PyLong_EqObjC(__pyx_t_21, __pyx_mstate_global->__pyx_int_0, 0, 0); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 626, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_25);
                      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;

                      /* "ws_package/controllers/activity_controller.py":627
 *                             ActivityInterval.is_uploaded.is_(False),
 *                             ActivityInterval.is_break == 0,
 *                             ActivityInterval.start_time <= switch_time,             # <<<<<<<<<<<<<<
 *                             ActivityInterval.end_time > switch_time,
 *                         )
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 627, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 627, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_24);
                      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                      __pyx_t_21 = PyObject_RichCompare(__pyx_t_24, __pyx_cur_scope->__pyx_v_switch_time, Py_LE); __Pyx_XGOTREF(__pyx_t_21); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 627, __pyx_L25_error)
                      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;

                      /* "ws_package/controllers/activity_controller.py":628
 *                             ActivityInterval.is_break == 0,
 *                             ActivityInterval.start_time <= switch_time,
 *                             ActivityInterval.end_time > switch_time,             # <<<<<<<<<<<<<<
 *                         )
 *                         .order_by(desc(ActivityInterval.id))
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 628, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_24);
                      __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 628, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_26);
                      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                      __pyx_t_24 = PyObject_RichCompare(__pyx_t_26, __pyx_cur_scope->__pyx_v_switch_time, Py_GT); __Pyx_XGOTREF(__pyx_t_24); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 628, __pyx_L25_error)
                      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                      __pyx_t_3 = 0;
                      {
                        PyObject *__pyx_callargs[6] = {__pyx_t_19, __pyx_t_22, __pyx_t_23, __pyx_t_25, __pyx_t_21, __pyx_t_24};
                        __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_3, (6-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 623, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_18);
                      }
                      __pyx_t_8 = __pyx_t_18;
                      __Pyx_INCREF(__pyx_t_8);

                      /* "ws_package/controllers/activity_controller.py":630
 *                             ActivityInterval.end_time > switch_time,
 *                         )
 *                         .order_by(desc(ActivityInterval.id))             # <<<<<<<<<<<<<<
 *                         .limit(1)
 *                     )
*/
                      __pyx_t_24 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_desc); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 630, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __Pyx_GetModuleGlobalName(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 630, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_25);
                      __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 630, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_23);
                      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                      __pyx_t_3 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_21))) {
                        __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_21);
                        assert(__pyx_t_24);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_21);
                        __Pyx_INCREF(__pyx_t_24);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_21, __pyx__function);
                        __pyx_t_3 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_24, __pyx_t_23};
                        __pyx_t_20 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_21, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 630, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_20);
                      }
                      __pyx_t_3 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_t_20};
                        __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_order_by, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 630, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_2);
                      }
                      __pyx_t_4 = __pyx_t_2;
                      __Pyx_INCREF(__pyx_t_4);
                      __pyx_t_3 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_int_1};
                        __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_limit, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 631, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_1);
                      }
                      __Pyx_GIVEREF(__pyx_t_1);
                      __pyx_cur_scope->__pyx_v_query = __pyx_t_1;
                      __pyx_t_1 = 0;

                      /* "ws_package/controllers/activity_controller.py":633
 *                         .limit(1)
 *                     )
 *                     result = await session.execute(query)             # <<<<<<<<<<<<<<
 *                     interval = result.scalar_one_or_none()
 *                     if interval is None:
*/
                      __pyx_t_2 = __pyx_cur_scope->__pyx_v_session;
                      __Pyx_INCREF(__pyx_t_2);
                      __pyx_t_3 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_query};
                        __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 633, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_1);
                      }
                      __pyx_t_14 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                      if (likely(__pyx_t_14 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_5);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_5;
                        __Pyx_XGIVEREF(__pyx_t_6);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
                        __Pyx_XGIVEREF(__pyx_t_7);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
                        __Pyx_XGIVEREF(__pyx_t_9);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 2;
                        return __pyx_r;
                        __pyx_L31_resume_from_await:;
                        __pyx_t_5 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_5);
                        __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_6);
                        __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_7);
                        __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_9);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 633, __pyx_L25_error)
                        __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
                      } else if (likely(__pyx_t_14 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_1 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 633, __pyx_L25_error)
                      }
                      __Pyx_GIVEREF(__pyx_t_1);
                      __pyx_cur_scope->__pyx_v_result = __pyx_t_1;
                      __pyx_t_1 = 0;

                      /* "ws_package/controllers/activity_controller.py":634
 *                     )
 *                     result = await session.execute(query)
 *                     interval = result.scalar_one_or_none()             # <<<<<<<<<<<<<<
 *                     if interval is None:
 *                         return None
*/
                      __pyx_t_2 = __pyx_cur_scope->__pyx_v_result;
                      __Pyx_INCREF(__pyx_t_2);
                      __pyx_t_3 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
                        __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalar_one_or_none, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 634, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_1);
                      }
                      __Pyx_GIVEREF(__pyx_t_1);
                      __pyx_cur_scope->__pyx_v_interval = __pyx_t_1;
                      __pyx_t_1 = 0;

                      /* "ws_package/controllers/activity_controller.py":635
 *                     result = await session.execute(query)
 *                     interval = result.scalar_one_or_none()
 *                     if interval is None:             # <<<<<<<<<<<<<<
 *                         return None
 *                     old_end = interval.end_time
*/
                      __pyx_t_27 = (__pyx_cur_scope->__pyx_v_interval == Py_None);
                      if (__pyx_t_27) {

                        /* "ws_package/controllers/activity_controller.py":636
 *                     interval = result.scalar_one_or_none()
 *                     if interval is None:
 *                         return None             # <<<<<<<<<<<<<<
 *                     old_end = interval.end_time
 *                     interval.end_time = switch_time
*/
                        __Pyx_XDECREF(__pyx_r);
                        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
                        goto __pyx_L29_try_return;

                        /* "ws_package/controllers/activity_controller.py":635
 *                     result = await session.execute(query)
 *                     interval = result.scalar_one_or_none()
 *                     if interval is None:             # <<<<<<<<<<<<<<
 *                         return None
 *                     old_end = interval.end_time
*/
                      }

                      /* "ws_package/controllers/activity_controller.py":637
 *                     if interval is None:
 *                         return None
 *                     old_end = interval.end_time             # <<<<<<<<<<<<<<
 *                     interval.end_time = switch_time
 *                     await session.commit()
*/
                      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 637, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_1);
                      __Pyx_GIVEREF(__pyx_t_1);
                      __pyx_cur_scope->__pyx_v_old_end = __pyx_t_1;
                      __pyx_t_1 = 0;

                      /* "ws_package/controllers/activity_controller.py":638
 *                         return None
 *                     old_end = interval.end_time
 *                     interval.end_time = switch_time             # <<<<<<<<<<<<<<
 *                     await session.commit()
 *                     logger.info(
*/
                      if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time, __pyx_cur_scope->__pyx_v_switch_time) < (0)) __PYX_ERR(0, 638, __pyx_L25_error)

                      /* "ws_package/controllers/activity_controller.py":639
 *                     old_end = interval.end_time
 *                     interval.end_time = switch_time
 *                     await session.commit()             # <<<<<<<<<<<<<<
 *                     logger.info(
 *                         "Trimmed open partial for project switch (counter=%s): %s to %s (was to %s)",
*/
                      __pyx_t_2 = __pyx_cur_scope->__pyx_v_session;
                      __Pyx_INCREF(__pyx_t_2);
                      __pyx_t_3 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
                        __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_commit, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 639, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_1);
                      }
                      __pyx_t_14 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                      if (likely(__pyx_t_14 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_5);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_5;
                        __Pyx_XGIVEREF(__pyx_t_6);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
                        __Pyx_XGIVEREF(__pyx_t_7);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
                        __Pyx_XGIVEREF(__pyx_t_9);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 3;
                        return __pyx_r;
                        __pyx_L33_resume_from_await:;
                        __pyx_t_5 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_5);
                        __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_6);
                        __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_7);
                        __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_9);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 639, __pyx_L25_error)
                      } else if (likely(__pyx_t_14 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 639, __pyx_L25_error)
                      }

                      /* "ws_package/controllers/activity_controller.py":640
 *                     interval.end_time = switch_time
 *                     await session.commit()
 *                     logger.info(             # <<<<<<<<<<<<<<
 *                         "Trimmed open partial for project switch (counter=%s): %s to %s (was to %s)",
 *                         write_counter,
*/
                      __pyx_t_2 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 640, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 640, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_18);
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                      /* "ws_package/controllers/activity_controller.py":643
 *                         "Trimmed open partial for project switch (counter=%s): %s to %s (was to %s)",
 *                         write_counter,
 *                         interval.start_time,             # <<<<<<<<<<<<<<
 *                         switch_time,
 *                         old_end,
*/
                      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 643, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_4);

                      /* "ws_package/controllers/activity_controller.py":645
 *                         interval.start_time,
 *                         switch_time,
 *                         old_end,             # <<<<<<<<<<<<<<
 *                     )
 *                     return interval
*/
                      __pyx_t_3 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_18))) {
                        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_18);
                        assert(__pyx_t_2);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_18);
                        __Pyx_INCREF(__pyx_t_2);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_18, __pyx__function);
                        __pyx_t_3 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[6] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Trimmed_open_partial_for_project, __pyx_cur_scope->__pyx_v_write_counter, __pyx_t_4, __pyx_cur_scope->__pyx_v_switch_time, __pyx_cur_scope->__pyx_v_old_end};
                        __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_18, __pyx_callargs+__pyx_t_3, (6-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 640, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_1);
                      }
                      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

                      /* "ws_package/controllers/activity_controller.py":647
 *                         old_end,
 *                     )
 *                     return interval             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             logger.error(
*/
                      __Pyx_XDECREF(__pyx_r);
                      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_interval);
                      __pyx_r = __pyx_cur_scope->__pyx_v_interval;
                      goto __pyx_L29_try_return;

                      /* "ws_package/controllers/activity_controller.py":620
 *         try:
 *             with db_lock_manager.write_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     query = (
 *                         select(ActivityInterval)
*/
                    }
                    __pyx_L25_error:;
                    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                    __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                    __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                    /*except:*/ {
                      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._trim_open_partial_at_project_switch", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_18, &__pyx_t_4) < 0) __PYX_ERR(0, 620, __pyx_L27_except_error)
                      __Pyx_XGOTREF(__pyx_t_1);
                      __Pyx_XGOTREF(__pyx_t_18);
                      __Pyx_XGOTREF(__pyx_t_4);
                      __pyx_t_2 = PyTuple_Pack(3, __pyx_t_1, __pyx_t_18, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 620, __pyx_L27_except_error)
                      __Pyx_GOTREF(__pyx_t_2);
                      __pyx_t_28 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_2, NULL);
                      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                      if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 620, __pyx_L27_except_error)
                      __Pyx_GOTREF(__pyx_t_28);
                      __pyx_t_14 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_28, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
                      if (likely(__pyx_t_14 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_4);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
                        __Pyx_XGIVEREF(__pyx_t_5);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_5;
                        __Pyx_XGIVEREF(__pyx_t_6);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_6;
                        __Pyx_XGIVEREF(__pyx_t_7);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_7;
                        __Pyx_XGIVEREF(__pyx_t_9);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_9;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_11 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_12 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_13 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_t_28);
                        __pyx_cur_scope->__pyx_t_14 = __pyx_t_28;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_SwapException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 4;
                        return __pyx_r;
                        __pyx_L37_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_4);
                        __pyx_t_5 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_5);
                        __pyx_t_6 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_6);
                        __pyx_t_7 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_7);
                        __pyx_t_9 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_9);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_11;
                        __pyx_cur_scope->__pyx_t_11 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_12;
                        __pyx_cur_scope->__pyx_t_12 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_13;
                        __pyx_cur_scope->__pyx_t_13 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        __pyx_t_28 = __pyx_cur_scope->__pyx_t_14;
                        __pyx_cur_scope->__pyx_t_14 = 0;
                        __Pyx_XGOTREF(__pyx_t_28);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 620, __pyx_L27_except_error)
                        __pyx_t_2 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_2);
                      } else if (likely(__pyx_t_14 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_2 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 620, __pyx_L27_except_error)
                      }
                      __pyx_t_28 = __pyx_t_2;
                      __pyx_t_2 = 0;
                      __pyx_t_27 = __Pyx_PyObject_IsTrue(__pyx_t_28);
                      __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
                      if (__pyx_t_27 < (0)) __PYX_ERR(0, 620, __pyx_L27_except_error)
                      __pyx_t_29 = (!__pyx_t_27);
                      if (unlikely(__pyx_t_29)) {
                        __Pyx_GIVEREF(__pyx_t_1);
                        __Pyx_GIVEREF(__pyx_t_18);
                        __Pyx_XGIVEREF(__pyx_t_4);
                        __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_18, __pyx_t_4);
                        __pyx_t_1 = 0;  __pyx_t_18 = 0;  __pyx_t_4 = 0; 
                        __PYX_ERR(0, 620, __pyx_L27_except_error)
                      }
                      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                      __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      goto __pyx_L26_exception_handled;
                    }
                    __pyx_L27_except_error:;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
                    goto __pyx_L14_error;
                    __pyx_L29_try_return:;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
                    goto __pyx_L22_return;
                    __pyx_L26_exception_handled:;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
                  }
                }
                /*finally:*/ {
                  /*normal exit:*/{
                    if (__pyx_t_13) {
                      __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_mstate_global->__pyx_tuple[7], NULL);
                      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                      if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 620, __pyx_L14_error)
                      __Pyx_GOTREF(__pyx_t_17);
                      __pyx_t_14 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_17, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                      if (likely(__pyx_t_14 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_5);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_5;
                        __Pyx_XGIVEREF(__pyx_t_6);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
                        __Pyx_XGIVEREF(__pyx_t_7);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
                        __Pyx_XGIVEREF(__pyx_t_9);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 5;
                        return __pyx_r;
                        __pyx_L38_resume_from_await:;
                        __pyx_t_5 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_5);
                        __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_6);
                        __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_7);
                        __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_9);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 620, __pyx_L14_error)
                        __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                      } else if (likely(__pyx_t_14 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 620, __pyx_L14_error)
                      }
                      __pyx_t_17 = __pyx_t_4;
                      __pyx_t_4 = 0;
                      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                    }
                    goto __pyx_L24;
                  }
                  __pyx_L22_return: {
                    __pyx_t_17 = __pyx_r;
                    __pyx_r = 0;
                    if (__pyx_t_13) {
                      __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_mstate_global->__pyx_tuple[7], NULL);
                      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                      if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 620, __pyx_L14_error)
                      __Pyx_GOTREF(__pyx_t_16);
                      __pyx_t_14 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_16, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                      if (likely(__pyx_t_14 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_5);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_5;
                        __Pyx_XGIVEREF(__pyx_t_6);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
                        __Pyx_XGIVEREF(__pyx_t_7);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
                        __Pyx_XGIVEREF(__pyx_t_9);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 6;
                        return __pyx_r;
                        __pyx_L39_resume_from_await:;
                        __pyx_t_5 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_5);
                        __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_6);
                        __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_7);
                        __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_9);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 620, __pyx_L14_error)
                        __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                      } else if (likely(__pyx_t_14 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 620, __pyx_L14_error)
                      }
                      __pyx_t_16 = __pyx_t_4;
                      __pyx_t_4 = 0;
                      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                    }
                    __pyx_r = __pyx_t_17;
                    __pyx_t_17 = 0;
                    goto __pyx_L18_try_return;
                  }
                  __pyx_L24:;
                }
                goto __pyx_L40;
                __pyx_L20_error:;
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                goto __pyx_L14_error;
                __pyx_L40:;
              }

              /* "ws_package/controllers/activity_controller.py":619
 *         write_counter = self.last_count + 1
 *         try:
 *             with db_lock_manager.write_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     query = (
*/
            }
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            goto __pyx_L19_try_end;
            __pyx_L14_error:;
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
            __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
            __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
            __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
            __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
            __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            /*except:*/ {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._trim_open_partial_at_project_switch", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_18, &__pyx_t_1) < 0) __PYX_ERR(0, 619, __pyx_L16_except_error)
              __Pyx_XGOTREF(__pyx_t_4);
              __Pyx_XGOTREF(__pyx_t_18);
              __Pyx_XGOTREF(__pyx_t_1);
              __pyx_t_2 = PyTuple_Pack(3, __pyx_t_4, __pyx_t_18, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 619, __pyx_L16_except_error)
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_2, NULL);
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 619, __pyx_L16_except_error)
              __Pyx_GOTREF(__pyx_t_13);
              __pyx_t_29 = __Pyx_PyObject_IsTrue(__pyx_t_13);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              if (__pyx_t_29 < (0)) __PYX_ERR(0, 619, __pyx_L16_except_error)
              __pyx_t_27 = (!__pyx_t_29);
              if (unlikely(__pyx_t_27)) {
                __Pyx_GIVEREF(__pyx_t_4);
                __Pyx_GIVEREF(__pyx_t_18);
                __Pyx_XGIVEREF(__pyx_t_1);
                __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_18, __pyx_t_1);
                __pyx_t_4 = 0;  __pyx_t_18 = 0;  __pyx_t_1 = 0; 
                __PYX_ERR(0, 619, __pyx_L16_except_error)
              }
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              goto __pyx_L15_exception_handled;
            }
            __pyx_L16_except_error:;
            __Pyx_XGIVEREF(__pyx_t_10);
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
            goto __pyx_L4_error;
            __pyx_L18_try_return:;
            __Pyx_XGIVEREF(__pyx_t_10);
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
            goto __pyx_L11_return;
            __pyx_L15_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_10);
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
            __pyx_L19_try_end:;
          }
        }
        /*finally:*/ {
          /*normal exit:*/{
            if (__pyx_t_9) {
              __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_mstate_global->__pyx_tuple[7], NULL);
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
              if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 619, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            }
            goto __pyx_L13;
          }
          __pyx_L11_return: {
            __pyx_t_12 = __pyx_r;
            __pyx_r = 0;
            if (__pyx_t_9) {
              __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_mstate_global->__pyx_tuple[7], NULL);
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
              if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 619, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_11);
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            }
            __pyx_r = __pyx_t_12;
            __pyx_t_12 = 0;
            goto __pyx_L8_try_return;
          }
          __pyx_L13:;
        }
        goto __pyx_L44;
        __pyx_L10_error:;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L4_error;
        __pyx_L44:;
      }

      /* "ws_package/controllers/activity_controller.py":618
 *         switch_time = switch_time.replace(microsecond=0)
 *         write_counter = self.last_count + 1
 *         try:             # <<<<<<<<<<<<<<
 *             with db_lock_manager.write_lock():
 *                 async with async_session() as session:
*/
    }
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    goto __pyx_L9_try_end;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
    __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
    __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "ws_package/controllers/activity_controller.py":648
 *                     )
 *                     return interval
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error(
 *                 "Failed to trim partial interval at project switch: %s", e, exc_info=True
*/
    __pyx_t_30 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_30) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._trim_open_partial_at_project_switch", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_18, &__pyx_t_4) < 0) __PYX_ERR(0, 648, __pyx_L6_except_error)
      __Pyx_XGOTREF(__pyx_t_1);
      __Pyx_XGOTREF(__pyx_t_18);
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_18);
      __Pyx_GIVEREF(__pyx_t_18);
      __pyx_cur_scope->__pyx_v_e = __pyx_t_18;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":649
 *                     return interval
 *         except Exception as e:
 *             logger.error(             # <<<<<<<<<<<<<<
 *                 "Failed to trim partial interval at project switch: %s", e, exc_info=True
 *             )
*/
        __pyx_t_20 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 649, __pyx_L50_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 649, __pyx_L50_error)
        __Pyx_GOTREF(__pyx_t_21);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

        /* "ws_package/controllers/activity_controller.py":650
 *         except Exception as e:
 *             logger.error(
 *                 "Failed to trim partial interval at project switch: %s", e, exc_info=True             # <<<<<<<<<<<<<<
 *             )
 *             return None
*/
        __pyx_t_3 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_21))) {
          __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_21);
          assert(__pyx_t_20);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_21);
          __Pyx_INCREF(__pyx_t_20);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_21, __pyx__function);
          __pyx_t_3 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_20, __pyx_mstate_global->__pyx_kp_u_Failed_to_trim_partial_interval, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_8 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 649, __pyx_L50_error)
          __Pyx_GOTREF(__pyx_t_8);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_8, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 649, __pyx_L50_error)
          __pyx_t_2 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_21, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_8);
          __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 649, __pyx_L50_error)
          __Pyx_GOTREF(__pyx_t_2);
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "ws_package/controllers/activity_controller.py":652
 *                 "Failed to trim partial interval at project switch: %s", e, exc_info=True
 *             )
 *             return None             # <<<<<<<<<<<<<<
 * 
 *     async def _try_finalize_post_switch_slot_interval(
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        goto __pyx_L49_return;
      }

      /* "ws_package/controllers/activity_controller.py":648
 *                     )
 *                     return interval
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error(
 *                 "Failed to trim partial interval at project switch: %s", e, exc_info=True
*/
      /*finally:*/ {
        __pyx_L50_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_9 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_13 = 0; __pyx_t_17 = 0;
          __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
          __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
          __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
          __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
          __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_13, &__pyx_t_17);
          if ( unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_12, &__pyx_t_11) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_12, &__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_9);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_17);
          __pyx_t_30 = __pyx_lineno; __pyx_t_31 = __pyx_clineno; __pyx_t_32 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_13, __pyx_t_17);
          __Pyx_XGIVEREF(__pyx_t_9);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_ErrRestore(__pyx_t_9, __pyx_t_12, __pyx_t_11);
          __pyx_t_9 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_13 = 0; __pyx_t_17 = 0;
          __pyx_lineno = __pyx_t_30; __pyx_clineno = __pyx_t_31; __pyx_filename = __pyx_t_32;
          goto __pyx_L6_except_error;
        }
        __pyx_L49_return: {
          __pyx_t_17 = __pyx_r;
          __pyx_r = 0;
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          __pyx_r = __pyx_t_17;
          __pyx_t_17 = 0;
          goto __pyx_L7_except_return;
        }
      }
    }
    goto __pyx_L6_except_error;

    /* "ws_package/controllers/activity_controller.py":618
 *         switch_time = switch_time.replace(microsecond=0)
 *         write_counter = self.last_count + 1
 *         try:             # <<<<<<<<<<<<<<
 *             with db_lock_manager.write_lock():
 *                 async with async_session() as session:
*/
    __pyx_L6_except_error:;
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
    goto __pyx_L1_error;
    __pyx_L8_try_return:;
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
    goto __pyx_L0;
    __pyx_L7_except_return:;
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_ExceptionReset(__pyx_t_5, __pyx_t_6, __pyx_t_7);
    goto __pyx_L0;
    __pyx_L9_try_end:;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":608
 *         )
 * 
 *     async def _trim_open_partial_at_project_switch(             # <<<<<<<<<<<<<<
 *         self, switch_time: datetime.datetime
 *     ):
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_XDECREF(__pyx_t_23);
  __Pyx_XDECREF(__pyx_t_24);
  __Pyx_XDECREF(__pyx_t_25);
  __Pyx_XDECREF(__pyx_t_26);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("_trim_open_partial_at_project_switch", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_28generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":654
 *             return None
 * 
 *     async def _try_finalize_post_switch_slot_interval(             # <<<<<<<<<<<<<<
 *         self, user_entity: UserEntity
 *     ) -> bool:
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_27_try_finalize_post_switch_slot_interval(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_26_try_finalize_post_switch_slot_interval, "\n        After project switch, the first interval for the new task (e.g. 10:02\342\200\22310:05) must\n        not be written at switch time \342\200\224 only when the slot boundary is reached (10:05).\n\n        Called from the device loop each iteration; creates the row once ``now >= slot_end``.\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_27_try_finalize_post_switch_slot_interval = {"_try_finalize_post_switch_slot_interval", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_27_try_finalize_post_switch_slot_interval, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_26_try_finalize_post_switch_slot_interval};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_27_try_finalize_post_switch_slot_interval(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  CYTHON_UNUSED PyObject *__pyx_v_user_entity = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_try_finalize_post_switch_slot_interval (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_user_entity,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 654, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 654, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 654, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_try_finalize_post_switch_slot_interval", 0) < (0)) __PYX_ERR(0, 654, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_try_finalize_post_switch_slot_interval", 1, 2, 2, i); __PYX_ERR(0, 654, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 654, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 654, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_user_entity = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_try_finalize_post_switch_slot_interval", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 654, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._try_finalize_post_switch_slot_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_26_try_finalize_post_switch_slot_interval(__pyx_self, __pyx_v_self, __pyx_v_user_entity);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_26_try_finalize_post_switch_slot_interval(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_user_entity) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_try_finalize_post_switch_slot_interval", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 654, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_user_entity = __pyx_v_user_entity;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_user_entity);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_user_entity);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_28generator2, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[2]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_try_finalize_post_switch_slot_i, __pyx_mstate_global->__pyx_n_u_ActivityController__try_finalize, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 654, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._try_finalize_post_switch_slot_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_28generator2(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  int __pyx_t_3;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  size_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_PySendResult __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  int __pyx_t_17;
  char const *__pyx_t_18;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_try_finalize_post_switch_slot_interval", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L8_resume_from_await;
    case 2: goto __pyx_L13_resume_from_await;
    case 3: goto __pyx_L23_resume_from_await;
    case 4: goto __pyx_L35_resume_from_await;
    case 5: goto __pyx_L36_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 654, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":663
 *         Called from the device loop each iteration; creates the row once ``now >= slot_end``.
 *         """
 *         session_start = self.current_session_start_time             # <<<<<<<<<<<<<<
 *         if session_start is None or not self.status:
 *             return False
*/
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_session_start_time); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 663, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_session_start = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":664
 *         """
 *         session_start = self.current_session_start_time
 *         if session_start is None or not self.status:             # <<<<<<<<<<<<<<
 *             return False
 * 
*/
  __pyx_t_3 = (__pyx_cur_scope->__pyx_v_session_start == Py_None);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_2 = __pyx_t_3;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 664, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 664, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = (!__pyx_t_3);
  __pyx_t_2 = __pyx_t_4;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_2) {

    /* "ws_package/controllers/activity_controller.py":665
 *         session_start = self.current_session_start_time
 *         if session_start is None or not self.status:
 *             return False             # <<<<<<<<<<<<<<
 * 
 *         session_start = session_start.replace(microsecond=0)
*/
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":664
 *         """
 *         session_start = self.current_session_start_time
 *         if session_start is None or not self.status:             # <<<<<<<<<<<<<<
 *             return False
 * 
*/
  }

  /* "ws_package/controllers/activity_controller.py":667
 *             return False
 * 
 *         session_start = session_start.replace(microsecond=0)             # <<<<<<<<<<<<<<
 *         now = datetime.datetime.now().replace(microsecond=0)
 *         interval_minutes = int(self.interval / 60)
*/
  __pyx_t_5 = __pyx_cur_scope->__pyx_v_session_start;
  __Pyx_INCREF(__pyx_t_5);
  __pyx_t_6 = 0;
  {
    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_5, NULL};
    __pyx_t_7 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 667, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_7, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 667, __pyx_L1_error)
    __pyx_t_1 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_7);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 667, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_session_start);
  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_session_start, __pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":668
 * 
 *         session_start = session_start.replace(microsecond=0)
 *         now = datetime.datetime.now().replace(microsecond=0)             # <<<<<<<<<<<<<<
 *         interval_minutes = int(self.interval / 60)
 *         slot_start = self._align_to_interval_boundary(session_start)
*/
  __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 668, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 668, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_8 = __pyx_t_10;
  __Pyx_INCREF(__pyx_t_8);
  __pyx_t_6 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
    __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 668, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
  }
  __pyx_t_7 = __pyx_t_5;
  __Pyx_INCREF(__pyx_t_7);
  __pyx_t_6 = 0;
  {
    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_7, NULL};
    __pyx_t_10 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 668, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_10, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 668, __pyx_L1_error)
    __pyx_t_1 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_10);
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 668, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_now = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":669
 *         session_start = session_start.replace(microsecond=0)
 *         now = datetime.datetime.now().replace(microsecond=0)
 *         interval_minutes = int(self.interval / 60)             # <<<<<<<<<<<<<<
 *         slot_start = self._align_to_interval_boundary(session_start)
 *         slot_end = slot_start + datetime.timedelta(minutes=interval_minutes)
*/
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 669, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyLong_TrueDivideObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_60, 60, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 669, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 669, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_interval_minutes = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":670
 *         now = datetime.datetime.now().replace(microsecond=0)
 *         interval_minutes = int(self.interval / 60)
 *         slot_start = self._align_to_interval_boundary(session_start)             # <<<<<<<<<<<<<<
 *         slot_end = slot_start + datetime.timedelta(minutes=interval_minutes)
 * 
*/
  __pyx_t_5 = __pyx_cur_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_5);
  __pyx_t_6 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_session_start};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_align_to_interval_boundary, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 670, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_slot_start = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":671
 *         interval_minutes = int(self.interval / 60)
 *         slot_start = self._align_to_interval_boundary(session_start)
 *         slot_end = slot_start + datetime.timedelta(minutes=interval_minutes)             # <<<<<<<<<<<<<<
 * 
 *         if now < slot_end:
*/
  __pyx_t_5 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 671, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_timedelta); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 671, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __pyx_t_6 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
    assert(__pyx_t_5);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
    __pyx_t_6 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_5, NULL};
    __pyx_t_10 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 671, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_minutes, __pyx_cur_scope->__pyx_v_interval_minutes, __pyx_t_10, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 671, __pyx_L1_error)
    __pyx_t_1 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_10);
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 671, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_7 = PyNumber_Add(__pyx_cur_scope->__pyx_v_slot_start, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 671, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_cur_scope->__pyx_v_slot_end = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "ws_package/controllers/activity_controller.py":673
 *         slot_end = slot_start + datetime.timedelta(minutes=interval_minutes)
 * 
 *         if now < slot_end:             # <<<<<<<<<<<<<<
 *             return False
 * 
*/
  __pyx_t_7 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_now, __pyx_cur_scope->__pyx_v_slot_end, Py_LT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 673, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 673, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__pyx_t_2) {

    /* "ws_package/controllers/activity_controller.py":674
 * 
 *         if now < slot_end:
 *             return False             # <<<<<<<<<<<<<<
 * 
 *         last_end = await self.activity_service.get_last_activity_interval()
*/
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":673
 *         slot_end = slot_start + datetime.timedelta(minutes=interval_minutes)
 * 
 *         if now < slot_end:             # <<<<<<<<<<<<<<
 *             return False
 * 
*/
  }

  /* "ws_package/controllers/activity_controller.py":676
 *             return False
 * 
 *         last_end = await self.activity_service.get_last_activity_interval()             # <<<<<<<<<<<<<<
 *         interval_start = session_start
 *         if last_end is not None and last_end > interval_start:
*/
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 676, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_1 = __pyx_t_10;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_6 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
    __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_last_activity_interval, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 676, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
  }
  __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7, &__pyx_r);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (likely(__pyx_t_11 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L8_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 676, __pyx_L1_error)
    __pyx_t_7 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_7);
  } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __pyx_t_7 = __pyx_r; __pyx_r = NULL;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 676, __pyx_L1_error)
  }
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_cur_scope->__pyx_v_last_end = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "ws_package/controllers/activity_controller.py":677
 * 
 *         last_end = await self.activity_service.get_last_activity_interval()
 *         interval_start = session_start             # <<<<<<<<<<<<<<
 *         if last_end is not None and last_end > interval_start:
 *             interval_start = last_end.replace(microsecond=0)
*/
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_session_start);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_session_start);
  __pyx_cur_scope->__pyx_v_interval_start = __pyx_cur_scope->__pyx_v_session_start;

  /* "ws_package/controllers/activity_controller.py":678
 *         last_end = await self.activity_service.get_last_activity_interval()
 *         interval_start = session_start
 *         if last_end is not None and last_end > interval_start:             # <<<<<<<<<<<<<<
 *             interval_start = last_end.replace(microsecond=0)
 * 
*/
  __pyx_t_4 = (__pyx_cur_scope->__pyx_v_last_end != Py_None);
  if (__pyx_t_4) {
  } else {
    __pyx_t_2 = __pyx_t_4;
    goto __pyx_L10_bool_binop_done;
  }
  __pyx_t_7 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_last_end, __pyx_cur_scope->__pyx_v_interval_start, Py_GT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 678, __pyx_L1_error)
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 678, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_2 = __pyx_t_4;
  __pyx_L10_bool_binop_done:;
  if (__pyx_t_2) {

    /* "ws_package/controllers/activity_controller.py":679
 *         interval_start = session_start
 *         if last_end is not None and last_end > interval_start:
 *             interval_start = last_end.replace(microsecond=0)             # <<<<<<<<<<<<<<
 * 
 *         if interval_start >= slot_end:
*/
    __pyx_t_10 = __pyx_cur_scope->__pyx_v_last_end;
    __Pyx_INCREF(__pyx_t_10);
    __pyx_t_6 = 0;
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_10, NULL};
      __pyx_t_1 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 679, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_1, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 679, __pyx_L1_error)
      __pyx_t_7 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_1);
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 679, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
    }
    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_interval_start);
    __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_interval_start, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_7);
    __pyx_t_7 = 0;

    /* "ws_package/controllers/activity_controller.py":678
 *         last_end = await self.activity_service.get_last_activity_interval()
 *         interval_start = session_start
 *         if last_end is not None and last_end > interval_start:             # <<<<<<<<<<<<<<
 *             interval_start = last_end.replace(microsecond=0)
 * 
*/
  }

  /* "ws_package/controllers/activity_controller.py":681
 *             interval_start = last_end.replace(microsecond=0)
 * 
 *         if interval_start >= slot_end:             # <<<<<<<<<<<<<<
 *             return False
 * 
*/
  __pyx_t_7 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_interval_start, __pyx_cur_scope->__pyx_v_slot_end, Py_GE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 681, __pyx_L1_error)
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 681, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (__pyx_t_2) {

    /* "ws_package/controllers/activity_controller.py":682
 * 
 *         if interval_start >= slot_end:
 *             return False             # <<<<<<<<<<<<<<
 * 
 *         existing = await self.activity_service.check_existing_interval(
*/
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":681
 *             interval_start = last_end.replace(microsecond=0)
 * 
 *         if interval_start >= slot_end:             # <<<<<<<<<<<<<<
 *             return False
 * 
*/
  }

  /* "ws_package/controllers/activity_controller.py":684
 *             return False
 * 
 *         existing = await self.activity_service.check_existing_interval(             # <<<<<<<<<<<<<<
 *             interval_start, slot_end, exact=True
 *         )
*/
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_1 = __pyx_t_10;
  __Pyx_INCREF(__pyx_t_1);

  /* "ws_package/controllers/activity_controller.py":685
 * 
 *         existing = await self.activity_service.check_existing_interval(
 *             interval_start, slot_end, exact=True             # <<<<<<<<<<<<<<
 *         )
 *         if existing:
*/
  __pyx_t_6 = 0;
  {
    PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_1, __pyx_cur_scope->__pyx_v_interval_start, __pyx_cur_scope->__pyx_v_slot_end};
    __pyx_t_5 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 684, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exact, Py_True, __pyx_t_5, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 684, __pyx_L1_error)
    __pyx_t_7 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_check_existing_interval, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_5);
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 684, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
  }
  __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7, &__pyx_r);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  if (likely(__pyx_t_11 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 2;
    return __pyx_r;
    __pyx_L13_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 684, __pyx_L1_error)
    __pyx_t_7 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_7);
  } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __pyx_t_7 = __pyx_r; __pyx_r = NULL;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 684, __pyx_L1_error)
  }
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_cur_scope->__pyx_v_existing = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "ws_package/controllers/activity_controller.py":687
 *             interval_start, slot_end, exact=True
 *         )
 *         if existing:             # <<<<<<<<<<<<<<
 *             return False
 * 
*/
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_existing); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 687, __pyx_L1_error)
  if (__pyx_t_2) {

    /* "ws_package/controllers/activity_controller.py":688
 *         )
 *         if existing:
 *             return False             # <<<<<<<<<<<<<<
 * 
 *         current_break_id = getattr(self, "break_id", 0) or 0
*/
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":687
 *             interval_start, slot_end, exact=True
 *         )
 *         if existing:             # <<<<<<<<<<<<<<
 *             return False
 * 
*/
  }

  /* "ws_package/controllers/activity_controller.py":690
 *             return False
 * 
 *         current_break_id = getattr(self, "break_id", 0) or 0             # <<<<<<<<<<<<<<
 *         try:
 *             activity_level = await self.get_activity_level_from_db(
*/
  __pyx_t_10 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_break_id, __pyx_mstate_global->__pyx_int_0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 690, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 690, __pyx_L1_error)
  if (!__pyx_t_2) {
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  } else {
    __Pyx_INCREF(__pyx_t_10);
    __pyx_t_7 = __pyx_t_10;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    goto __pyx_L15_bool_binop_done;
  }
  __pyx_t_10 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 690, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_7 = __pyx_t_10;
  __pyx_t_10 = 0;
  __pyx_L15_bool_binop_done:;
  __Pyx_GIVEREF(__pyx_t_7);
  __pyx_cur_scope->__pyx_v_current_break_id = __pyx_t_7;
  __pyx_t_7 = 0;

  /* "ws_package/controllers/activity_controller.py":691
 * 
 *         current_break_id = getattr(self, "break_id", 0) or 0
 *         try:             # <<<<<<<<<<<<<<
 *             activity_level = await self.get_activity_level_from_db(
 *                 interval_start, slot_end
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
    __Pyx_XGOTREF(__pyx_t_12);
    __Pyx_XGOTREF(__pyx_t_13);
    __Pyx_XGOTREF(__pyx_t_14);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":692
 *         current_break_id = getattr(self, "break_id", 0) or 0
 *         try:
 *             activity_level = await self.get_activity_level_from_db(             # <<<<<<<<<<<<<<
 *                 interval_start, slot_end
 *             )
*/
      __pyx_t_10 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_10);

      /* "ws_package/controllers/activity_controller.py":693
 *         try:
 *             activity_level = await self.get_activity_level_from_db(
 *                 interval_start, slot_end             # <<<<<<<<<<<<<<
 *             )
 *         except Exception as e:
*/
      __pyx_t_6 = 0;
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_10, __pyx_cur_scope->__pyx_v_interval_start, __pyx_cur_scope->__pyx_v_slot_end};
        __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_activity_level_from_db, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 692, __pyx_L17_error)
        __Pyx_GOTREF(__pyx_t_7);
      }
      __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7, &__pyx_r);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (likely(__pyx_t_11 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_12);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_12;
        __Pyx_XGIVEREF(__pyx_t_13);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_13;
        __Pyx_XGIVEREF(__pyx_t_14);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_14;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 3;
        return __pyx_r;
        __pyx_L23_resume_from_await:;
        __pyx_t_12 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_12);
        __pyx_t_13 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_13);
        __pyx_t_14 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_14);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 692, __pyx_L17_error)
        __pyx_t_7 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_7);
      } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __pyx_t_7 = __pyx_r; __pyx_r = NULL;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 692, __pyx_L17_error)
      }
      __Pyx_GIVEREF(__pyx_t_7);
      __pyx_cur_scope->__pyx_v_activity_level = __pyx_t_7;
      __pyx_t_7 = 0;

      /* "ws_package/controllers/activity_controller.py":691
 * 
 *         current_break_id = getattr(self, "break_id", 0) or 0
 *         try:             # <<<<<<<<<<<<<<
 *             activity_level = await self.get_activity_level_from_db(
 *                 interval_start, slot_end
*/
    }
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    goto __pyx_L22_try_end;
    __pyx_L17_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "ws_package/controllers/activity_controller.py":695
 *                 interval_start, slot_end
 *             )
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.warning(
 *                 "Error getting activity for deferred post-switch interval: %s", e
*/
    __pyx_t_15 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_15) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._try_finalize_post_switch_slot_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_10, &__pyx_t_5) < 0) __PYX_ERR(0, 695, __pyx_L19_except_error)
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_10);
      __pyx_cur_scope->__pyx_v_e = __pyx_t_10;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":696
 *             )
 *         except Exception as e:
 *             logger.warning(             # <<<<<<<<<<<<<<
 *                 "Error getting activity for deferred post-switch interval: %s", e
 *             )
*/
        __pyx_t_8 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 696, __pyx_L29_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 696, __pyx_L29_error)
        __Pyx_GOTREF(__pyx_t_16);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

        /* "ws_package/controllers/activity_controller.py":697
 *         except Exception as e:
 *             logger.warning(
 *                 "Error getting activity for deferred post-switch interval: %s", e             # <<<<<<<<<<<<<<
 *             )
 *             activity_level = {"mouse": "0.0", "average": "0.0", "keyboard": "0.0"}
*/
        __pyx_t_6 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_16))) {
          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_16);
          assert(__pyx_t_8);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_16);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_16, __pyx__function);
          __pyx_t_6 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_8, __pyx_mstate_global->__pyx_kp_u_Error_getting_activity_for_defer, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_16, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 696, __pyx_L29_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":699
 *                 "Error getting activity for deferred post-switch interval: %s", e
 *             )
 *             activity_level = {"mouse": "0.0", "average": "0.0", "keyboard": "0.0"}             # <<<<<<<<<<<<<<
 * 
 *         await self.activity_service.save_activity_log(
*/
        __pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 699, __pyx_L29_error)
        __Pyx_GOTREF(__pyx_t_1);
        if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_mouse, __pyx_mstate_global->__pyx_kp_u_0_0) < (0)) __PYX_ERR(0, 699, __pyx_L29_error)
        if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_average, __pyx_mstate_global->__pyx_kp_u_0_0) < (0)) __PYX_ERR(0, 699, __pyx_L29_error)
        if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_keyboard, __pyx_mstate_global->__pyx_kp_u_0_0) < (0)) __PYX_ERR(0, 699, __pyx_L29_error)
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_activity_level);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_activity_level, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_t_1 = 0;
      }

      /* "ws_package/controllers/activity_controller.py":695
 *                 interval_start, slot_end
 *             )
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.warning(
 *                 "Error getting activity for deferred post-switch interval: %s", e
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          goto __pyx_L30;
        }
        __pyx_L29_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
          if ( unlikely(__Pyx_GetException(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21) < 0)) __Pyx_ErrFetch(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_23);
          __Pyx_XGOTREF(__pyx_t_24);
          __pyx_t_15 = __pyx_lineno; __pyx_t_17 = __pyx_clineno; __pyx_t_18 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_XGIVEREF(__pyx_t_24);
          __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_23, __pyx_t_24);
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_ErrRestore(__pyx_t_19, __pyx_t_20, __pyx_t_21);
          __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0;
          __pyx_lineno = __pyx_t_15; __pyx_clineno = __pyx_t_17; __pyx_filename = __pyx_t_18;
          goto __pyx_L19_except_error;
        }
        __pyx_L30:;
      }
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L18_exception_handled;
    }
    goto __pyx_L19_except_error;

    /* "ws_package/controllers/activity_controller.py":691
 * 
 *         current_break_id = getattr(self, "break_id", 0) or 0
 *         try:             # <<<<<<<<<<<<<<
 *             activity_level = await self.get_activity_level_from_db(
 *                 interval_start, slot_end
*/
    __pyx_L19_except_error:;
    __Pyx_XGIVEREF(__pyx_t_12);
    __Pyx_XGIVEREF(__pyx_t_13);
    __Pyx_XGIVEREF(__pyx_t_14);
    __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
    goto __pyx_L1_error;
    __pyx_L18_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_12);
    __Pyx_XGIVEREF(__pyx_t_13);
    __Pyx_XGIVEREF(__pyx_t_14);
    __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
    __pyx_L22_try_end:;
  }

  /* "ws_package/controllers/activity_controller.py":701
 *             activity_level = {"mouse": "0.0", "average": "0.0", "keyboard": "0.0"}
 * 
 *         await self.activity_service.save_activity_log(             # <<<<<<<<<<<<<<
 *             activity_level,
 *             interval_start,
*/
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 701, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_10 = __pyx_t_7;
  __Pyx_INCREF(__pyx_t_10);

  /* "ws_package/controllers/activity_controller.py":705
 *             interval_start,
 *             slot_end,
 *             self.last_count + 1,             # <<<<<<<<<<<<<<
 *             self.get_today_weekday(),
 *             break_id=current_break_id,
*/
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 705, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_16 = __Pyx_PyLong_AddObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 705, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":706
 *             slot_end,
 *             self.last_count + 1,
 *             self.get_today_weekday(),             # <<<<<<<<<<<<<<
 *             break_id=current_break_id,
 *             is_idle=False,
*/
  __pyx_t_8 = __pyx_cur_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_8);
  __pyx_t_6 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_today_weekday, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 706, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }

  /* "ws_package/controllers/activity_controller.py":708
 *             self.get_today_weekday(),
 *             break_id=current_break_id,
 *             is_idle=False,             # <<<<<<<<<<<<<<
 *         )
 *         await db_writer_service.process_immediately()
*/
  __pyx_t_6 = 0;
  {
    PyObject *__pyx_callargs[6 + ((CYTHON_VECTORCALL) ? 2 : 0)] = {__pyx_t_10, __pyx_cur_scope->__pyx_v_activity_level, __pyx_cur_scope->__pyx_v_interval_start, __pyx_cur_scope->__pyx_v_slot_end, __pyx_t_16, __pyx_t_1};
    __pyx_t_8 = __Pyx_MakeVectorcallBuilderKwds(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 701, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_break_id, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_t_8, __pyx_callargs+6, 0) < (0)) __PYX_ERR(0, 701, __pyx_L1_error)
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_is_idle, Py_False, __pyx_t_8, __pyx_callargs+6, 1) < (0)) __PYX_ERR(0, 701, __pyx_L1_error)
    __pyx_t_5 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_save_activity_log, __pyx_callargs+__pyx_t_6, (6-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_8);
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 701, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
  }
  __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (likely(__pyx_t_11 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 4;
    return __pyx_r;
    __pyx_L35_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 701, __pyx_L1_error)
  } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 701, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":710
 *             is_idle=False,
 *         )
 *         await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 *         logger.info(
 *             "Deferred post-switch interval saved at slot boundary: %s to %s (counter=%s, "
*/
  __pyx_t_7 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 710, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 710, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_6 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
    assert(__pyx_t_7);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_7);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
    __pyx_t_6 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
    __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 710, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
  }
  __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (likely(__pyx_t_11 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 5;
    return __pyx_r;
    __pyx_L36_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 710, __pyx_L1_error)
  } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 710, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":711
 *         )
 *         await db_writer_service.process_immediately()
 *         logger.info(             # <<<<<<<<<<<<<<
 *             "Deferred post-switch interval saved at slot boundary: %s to %s (counter=%s, "
 *             "session_start=%s)",
*/
  __pyx_t_1 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 711, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 711, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "ws_package/controllers/activity_controller.py":716
 *             interval_start,
 *             slot_end,
 *             self.last_count + 1,             # <<<<<<<<<<<<<<
 *             session_start,
 *         )
*/
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 716, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_16 = __Pyx_PyLong_AddObjC(__pyx_t_7, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 716, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

  /* "ws_package/controllers/activity_controller.py":717
 *             slot_end,
 *             self.last_count + 1,
 *             session_start,             # <<<<<<<<<<<<<<
 *         )
 *         return True
*/
  __pyx_t_6 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_8);
    assert(__pyx_t_1);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
    __pyx_t_6 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[6] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Deferred_post_switch_interval_sa, __pyx_cur_scope->__pyx_v_interval_start, __pyx_cur_scope->__pyx_v_slot_end, __pyx_t_16, __pyx_cur_scope->__pyx_v_session_start};
    __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_6, (6-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 711, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "ws_package/controllers/activity_controller.py":719
 *             session_start,
 *         )
 *         return True             # <<<<<<<<<<<<<<
 * 
 *     async def _create_segment_dummy_entry(self, segment_start: datetime.datetime) -> None:
*/
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(Py_True);
  __pyx_r = Py_True;
  goto __pyx_L0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":654
 *             return None
 * 
 *     async def _try_finalize_post_switch_slot_interval(             # <<<<<<<<<<<<<<
 *         self, user_entity: UserEntity
 *     ) -> bool:
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_16);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("_try_finalize_post_switch_slot_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_31generator3(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":721
 *         return True
 * 
 *     async def _create_segment_dummy_entry(self, segment_start: datetime.datetime) -> None:             # <<<<<<<<<<<<<<
 *         """Create is_uploaded=True marker interval at a new session boundary (project switch, etc.)."""
 *         empty_activity_level = {"mouse": "1", "keyboard": "0.0", "average": "0.0"}
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_30_create_segment_dummy_entry(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_29_create_segment_dummy_entry, "Create is_uploaded=True marker interval at a new session boundary (project switch, etc.).");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_30_create_segment_dummy_entry = {"_create_segment_dummy_entry", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_30_create_segment_dummy_entry, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_29_create_segment_dummy_entry};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_30_create_segment_dummy_entry(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_segment_start = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_create_segment_dummy_entry (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_segment_start,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 721, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 721, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 721, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_create_segment_dummy_entry", 0) < (0)) __PYX_ERR(0, 721, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_create_segment_dummy_entry", 1, 2, 2, i); __PYX_ERR(0, 721, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 721, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 721, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_segment_start = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_create_segment_dummy_entry", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 721, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._create_segment_dummy_entry", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_29_create_segment_dummy_entry(__pyx_self, __pyx_v_self, __pyx_v_segment_start);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_29_create_segment_dummy_entry(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_segment_start) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_create_segment_dummy_entry", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 721, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_segment_start = __pyx_v_segment_start;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_segment_start);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_segment_start);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_31generator3, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[3]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_create_segment_dummy_entry, __pyx_mstate_global->__pyx_n_u_ActivityController__create_segme, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 721, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._create_segment_dummy_entry", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_31generator3(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  size_t __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  __Pyx_PySendResult __pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  PyObject *__pyx_t_26 = NULL;
  PyObject *__pyx_t_27 = NULL;
  PyObject *__pyx_t_28 = NULL;
  int __pyx_t_29;
  int __pyx_t_30;
  int __pyx_t_31;
  char const *__pyx_t_32;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_create_segment_dummy_entry", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L23_resume_from_await;
    case 2: goto __pyx_L33_resume_from_await;
    case 3: goto __pyx_L38_resume_from_await;
    case 4: goto __pyx_L39_resume_from_await;
    case 5: goto __pyx_L40_resume_from_await;
    case 6: goto __pyx_L57_resume_from_await;
    case 7: goto __pyx_L58_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 721, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":723
 *     async def _create_segment_dummy_entry(self, segment_start: datetime.datetime) -> None:
 *         """Create is_uploaded=True marker interval at a new session boundary (project switch, etc.)."""
 *         empty_activity_level = {"mouse": "1", "keyboard": "0.0", "average": "0.0"}             # <<<<<<<<<<<<<<
 *         current_break_id = getattr(self, "break_id", 0) or 0
 *         try:
*/
  __pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 723, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_mouse, __pyx_mstate_global->__pyx_kp_u_1) < (0)) __PYX_ERR(0, 723, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_keyboard, __pyx_mstate_global->__pyx_kp_u_0_0) < (0)) __PYX_ERR(0, 723, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_average, __pyx_mstate_global->__pyx_kp_u_0_0) < (0)) __PYX_ERR(0, 723, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_empty_activity_level = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":724
 *         """Create is_uploaded=True marker interval at a new session boundary (project switch, etc.)."""
 *         empty_activity_level = {"mouse": "1", "keyboard": "0.0", "average": "0.0"}
 *         current_break_id = getattr(self, "break_id", 0) or 0             # <<<<<<<<<<<<<<
 *         try:
 *             with db_lock_manager.read_lock():
*/
  __pyx_t_2 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_break_id, __pyx_mstate_global->__pyx_int_0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 724, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 724, __pyx_L1_error)
  if (!__pyx_t_3) {
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_1 = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 724, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __pyx_t_2;
  __pyx_t_2 = 0;
  __pyx_L4_bool_binop_done:;
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_current_break_id = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":725
 *         empty_activity_level = {"mouse": "1", "keyboard": "0.0", "average": "0.0"}
 *         current_break_id = getattr(self, "break_id", 0) or 0
 *         try:             # <<<<<<<<<<<<<<
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":726
 *         current_break_id = getattr(self, "break_id", 0) or 0
 *         try:
 *             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     query = select(ActivityInterval).where(
*/
      /*with:*/ {
        __pyx_t_2 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 726, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 726, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_9 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_8);
          assert(__pyx_t_2);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
          __pyx_t_9 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_9, (1-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 726, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __pyx_t_10 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 726, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_2 = NULL;
        __pyx_t_7 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 726, __pyx_L12_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_9 = 1;
        #if CYTHON_UNPACK_METHODS
        if (likely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7);
          assert(__pyx_t_2);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
          __pyx_t_9 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
          __pyx_t_8 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_9, (1-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 726, __pyx_L12_error)
          __Pyx_GOTREF(__pyx_t_8);
        }
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        /*try:*/ {
          {
            __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
            __Pyx_XGOTREF(__pyx_t_11);
            __Pyx_XGOTREF(__pyx_t_12);
            __Pyx_XGOTREF(__pyx_t_13);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":727
 *         try:
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     query = select(ActivityInterval).where(
 *                         and_(
*/
              /*with:*/ {
                __pyx_t_8 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 727, __pyx_L16_error)
                __Pyx_GOTREF(__pyx_t_7);
                __pyx_t_9 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_7))) {
                  __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
                  assert(__pyx_t_8);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                  __Pyx_INCREF(__pyx_t_8);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                  __pyx_t_9 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
                  __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_9, (1-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 727, __pyx_L16_error)
                  __Pyx_GOTREF(__pyx_t_1);
                }
                __pyx_t_14 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 727, __pyx_L16_error)
                __Pyx_GOTREF(__pyx_t_14);
                __pyx_t_8 = NULL;
                __pyx_t_2 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 727, __pyx_L22_error)
                __Pyx_GOTREF(__pyx_t_2);
                __pyx_t_9 = 1;
                #if CYTHON_UNPACK_METHODS
                if (likely(PyMethod_Check(__pyx_t_2))) {
                  __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
                  assert(__pyx_t_8);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
                  __Pyx_INCREF(__pyx_t_8);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
                  __pyx_t_9 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
                  __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_9, (1-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 727, __pyx_L22_error)
                  __Pyx_GOTREF(__pyx_t_7);
                }
                __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7, &__pyx_r);
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                if (likely(__pyx_t_15 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_1);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                  __Pyx_XGIVEREF(__pyx_t_4);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
                  __Pyx_XGIVEREF(__pyx_t_5);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_5;
                  __Pyx_XGIVEREF(__pyx_t_6);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_6;
                  __Pyx_XGIVEREF(__pyx_t_10);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                  __Pyx_XGIVEREF(__pyx_t_11);
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_t_14);
                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_14;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 1;
                  return __pyx_r;
                  __pyx_L23_resume_from_await:;
                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_1);
                  __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_4);
                  __pyx_t_5 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_5);
                  __pyx_t_6 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_6);
                  __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_10);
                  __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = 0;
                  __Pyx_XGOTREF(__pyx_t_11);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
                  __pyx_cur_scope->__pyx_t_6 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_7;
                  __pyx_cur_scope->__pyx_t_7 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  __pyx_t_14 = __pyx_cur_scope->__pyx_t_8;
                  __pyx_cur_scope->__pyx_t_8 = 0;
                  __Pyx_XGOTREF(__pyx_t_14);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 727, __pyx_L22_error)
                  __pyx_t_7 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_7);
                } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __pyx_t_7 = __pyx_r; __pyx_r = NULL;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 727, __pyx_L22_error)
                }
                __pyx_t_2 = __pyx_t_7;
                __pyx_t_7 = 0;
                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                /*try:*/ {
                  {
                    __Pyx_ExceptionSave(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
                    __Pyx_XGOTREF(__pyx_t_16);
                    __Pyx_XGOTREF(__pyx_t_17);
                    __Pyx_XGOTREF(__pyx_t_18);
                    /*try:*/ {
                      __Pyx_GIVEREF(__pyx_t_2);
                      __pyx_cur_scope->__pyx_v_session = __pyx_t_2;
                      __pyx_t_2 = 0;

                      /* "ws_package/controllers/activity_controller.py":728
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:
 *                     query = select(ActivityInterval).where(             # <<<<<<<<<<<<<<
 *                         and_(
 *                             ActivityInterval.start_time == segment_start,
*/
                      __pyx_t_20 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 728, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 728, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __pyx_t_9 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_21))) {
                        __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_21);
                        assert(__pyx_t_20);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_21);
                        __Pyx_INCREF(__pyx_t_20);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_21, __pyx__function);
                        __pyx_t_9 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_20, __pyx_t_22};
                        __pyx_t_19 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_21, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 728, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_19);
                      }
                      __pyx_t_8 = __pyx_t_19;
                      __Pyx_INCREF(__pyx_t_8);

                      /* "ws_package/controllers/activity_controller.py":729
 *                 async with async_session() as session:
 *                     query = select(ActivityInterval).where(
 *                         and_(             # <<<<<<<<<<<<<<
 *                             ActivityInterval.start_time == segment_start,
 *                             ActivityInterval.end_time == segment_start,
*/
                      __pyx_t_22 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_and); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 729, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_20);

                      /* "ws_package/controllers/activity_controller.py":730
 *                     query = select(ActivityInterval).where(
 *                         and_(
 *                             ActivityInterval.start_time == segment_start,             # <<<<<<<<<<<<<<
 *                             ActivityInterval.end_time == segment_start,
 *                             ActivityInterval.counter == self.last_count + 1,
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 730, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_23);
                      __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 730, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_24);
                      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                      __pyx_t_23 = PyObject_RichCompare(__pyx_t_24, __pyx_cur_scope->__pyx_v_segment_start, Py_EQ); __Pyx_XGOTREF(__pyx_t_23); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 730, __pyx_L27_error)
                      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;

                      /* "ws_package/controllers/activity_controller.py":731
 *                         and_(
 *                             ActivityInterval.start_time == segment_start,
 *                             ActivityInterval.end_time == segment_start,             # <<<<<<<<<<<<<<
 *                             ActivityInterval.counter == self.last_count + 1,
 *                         )
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 731, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_24);
                      __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 731, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_25);
                      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                      __pyx_t_24 = PyObject_RichCompare(__pyx_t_25, __pyx_cur_scope->__pyx_v_segment_start, Py_EQ); __Pyx_XGOTREF(__pyx_t_24); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 731, __pyx_L27_error)
                      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;

                      /* "ws_package/controllers/activity_controller.py":732
 *                             ActivityInterval.start_time == segment_start,
 *                             ActivityInterval.end_time == segment_start,
 *                             ActivityInterval.counter == self.last_count + 1,             # <<<<<<<<<<<<<<
 *                         )
 *                     ).limit(1)
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 732, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_25);
                      __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 732, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_26);
                      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                      __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 732, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_25);
                      __pyx_t_27 = __Pyx_PyLong_AddObjC(__pyx_t_25, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 732, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_27);
                      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                      __pyx_t_25 = PyObject_RichCompare(__pyx_t_26, __pyx_t_27, Py_EQ); __Pyx_XGOTREF(__pyx_t_25); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 732, __pyx_L27_error)
                      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                      __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                      __pyx_t_9 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_20))) {
                        __pyx_t_22 = PyMethod_GET_SELF(__pyx_t_20);
                        assert(__pyx_t_22);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_20);
                        __Pyx_INCREF(__pyx_t_22);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_20, __pyx__function);
                        __pyx_t_9 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[4] = {__pyx_t_22, __pyx_t_23, __pyx_t_24, __pyx_t_25};
                        __pyx_t_21 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_20, __pyx_callargs+__pyx_t_9, (4-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 729, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_21);
                      }
                      __pyx_t_9 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_t_21};
                        __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 728, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_7);
                      }
                      __pyx_t_1 = __pyx_t_7;
                      __Pyx_INCREF(__pyx_t_1);
                      __pyx_t_9 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_int_1};
                        __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_limit, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 734, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_2);
                      }
                      __Pyx_GIVEREF(__pyx_t_2);
                      __pyx_cur_scope->__pyx_v_query = __pyx_t_2;
                      __pyx_t_2 = 0;

                      /* "ws_package/controllers/activity_controller.py":735
 *                         )
 *                     ).limit(1)
 *                     result = await session.execute(query)             # <<<<<<<<<<<<<<
 *                     if result.scalars().first():
 *                         logger.info(
*/
                      __pyx_t_7 = __pyx_cur_scope->__pyx_v_session;
                      __Pyx_INCREF(__pyx_t_7);
                      __pyx_t_9 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_cur_scope->__pyx_v_query};
                        __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 735, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_2);
                      }
                      __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_2, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                      if (likely(__pyx_t_15 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_4);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_4;
                        __Pyx_XGIVEREF(__pyx_t_5);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_5;
                        __Pyx_XGIVEREF(__pyx_t_6);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_6;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 2;
                        return __pyx_r;
                        __pyx_L33_resume_from_await:;
                        __pyx_t_4 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_4);
                        __pyx_t_5 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_5);
                        __pyx_t_6 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_6);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 735, __pyx_L27_error)
                        __pyx_t_2 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_2);
                      } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_2 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 735, __pyx_L27_error)
                      }
                      __Pyx_GIVEREF(__pyx_t_2);
                      __pyx_cur_scope->__pyx_v_result = __pyx_t_2;
                      __pyx_t_2 = 0;

                      /* "ws_package/controllers/activity_controller.py":736
 *                     ).limit(1)
 *                     result = await session.execute(query)
 *                     if result.scalars().first():             # <<<<<<<<<<<<<<
 *                         logger.info(
 *                             "Segment dummy entry already exists for start=%s counter=%s",
*/
                      __pyx_t_19 = __pyx_cur_scope->__pyx_v_result;
                      __Pyx_INCREF(__pyx_t_19);
                      __pyx_t_9 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_19, NULL};
                        __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalars, __pyx_callargs+__pyx_t_9, (1-__pyx_t_9) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 736, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_1);
                      }
                      __pyx_t_7 = __pyx_t_1;
                      __Pyx_INCREF(__pyx_t_7);
                      __pyx_t_9 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
                        __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_first, __pyx_callargs+__pyx_t_9, (1-__pyx_t_9) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 736, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_2);
                      }
                      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 736, __pyx_L27_error)
                      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                      if (__pyx_t_3) {

                        /* "ws_package/controllers/activity_controller.py":737
 *                     result = await session.execute(query)
 *                     if result.scalars().first():
 *                         logger.info(             # <<<<<<<<<<<<<<
 *                             "Segment dummy entry already exists for start=%s counter=%s",
 *                             segment_start,
*/
                        __pyx_t_1 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 737, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_7);
                        __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 737, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_19);
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

                        /* "ws_package/controllers/activity_controller.py":740
 *                             "Segment dummy entry already exists for start=%s counter=%s",
 *                             segment_start,
 *                             self.last_count + 1,             # <<<<<<<<<<<<<<
 *                         )
 *                         return
*/
                        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 740, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_7);
                        __pyx_t_21 = __Pyx_PyLong_AddObjC(__pyx_t_7, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 740, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_21);
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                        __pyx_t_9 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_19))) {
                          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_19);
                          assert(__pyx_t_1);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_19);
                          __Pyx_INCREF(__pyx_t_1);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_19, __pyx__function);
                          __pyx_t_9 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[4] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Segment_dummy_entry_already_exis, __pyx_cur_scope->__pyx_v_segment_start, __pyx_t_21};
                          __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_19, __pyx_callargs+__pyx_t_9, (4-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                          __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 737, __pyx_L27_error)
                          __Pyx_GOTREF(__pyx_t_2);
                        }
                        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

                        /* "ws_package/controllers/activity_controller.py":742
 *                             self.last_count + 1,
 *                         )
 *                         return             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             logger.warning("Error checking segment dummy entry: %s", e)
*/
                        __Pyx_XDECREF(__pyx_r);
                        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
                        goto __pyx_L31_try_return;

                        /* "ws_package/controllers/activity_controller.py":736
 *                     ).limit(1)
 *                     result = await session.execute(query)
 *                     if result.scalars().first():             # <<<<<<<<<<<<<<
 *                         logger.info(
 *                             "Segment dummy entry already exists for start=%s counter=%s",
*/
                      }

                      /* "ws_package/controllers/activity_controller.py":727
 *         try:
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     query = select(ActivityInterval).where(
 *                         and_(
*/
                    }
                    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                    goto __pyx_L32_try_end;
                    __pyx_L27_error:;
                    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                    __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                    __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                    __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                    /*except:*/ {
                      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._create_segment_dummy_entry", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_19, &__pyx_t_21) < 0) __PYX_ERR(0, 727, __pyx_L29_except_error)
                      __Pyx_XGOTREF(__pyx_t_2);
                      __Pyx_XGOTREF(__pyx_t_19);
                      __Pyx_XGOTREF(__pyx_t_21);
                      __pyx_t_1 = PyTuple_Pack(3, __pyx_t_2, __pyx_t_19, __pyx_t_21); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 727, __pyx_L29_except_error)
                      __Pyx_GOTREF(__pyx_t_1);
                      __pyx_t_28 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_1, NULL);
                      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                      if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 727, __pyx_L29_except_error)
                      __Pyx_GOTREF(__pyx_t_28);
                      __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_28, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
                      if (likely(__pyx_t_15 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_4);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
                        __Pyx_XGIVEREF(__pyx_t_5);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_5;
                        __Pyx_XGIVEREF(__pyx_t_6);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_6;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_11 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_t_19);
                        __pyx_cur_scope->__pyx_t_12 = __pyx_t_19;
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __pyx_cur_scope->__pyx_t_13 = __pyx_t_21;
                        __Pyx_XGIVEREF(__pyx_t_28);
                        __pyx_cur_scope->__pyx_t_14 = __pyx_t_28;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_SwapException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 3;
                        return __pyx_r;
                        __pyx_L38_resume_from_await:;
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_4);
                        __pyx_t_5 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_5);
                        __pyx_t_6 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_6);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_11;
                        __pyx_cur_scope->__pyx_t_11 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        __pyx_t_19 = __pyx_cur_scope->__pyx_t_12;
                        __pyx_cur_scope->__pyx_t_12 = 0;
                        __Pyx_XGOTREF(__pyx_t_19);
                        __pyx_t_21 = __pyx_cur_scope->__pyx_t_13;
                        __pyx_cur_scope->__pyx_t_13 = 0;
                        __Pyx_XGOTREF(__pyx_t_21);
                        __pyx_t_28 = __pyx_cur_scope->__pyx_t_14;
                        __pyx_cur_scope->__pyx_t_14 = 0;
                        __Pyx_XGOTREF(__pyx_t_28);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 727, __pyx_L29_except_error)
                        __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
                      } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_1 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 727, __pyx_L29_except_error)
                      }
                      __pyx_t_28 = __pyx_t_1;
                      __pyx_t_1 = 0;
                      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_28);
                      __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
                      if (__pyx_t_3 < (0)) __PYX_ERR(0, 727, __pyx_L29_except_error)
                      __pyx_t_29 = (!__pyx_t_3);
                      if (unlikely(__pyx_t_29)) {
                        __Pyx_GIVEREF(__pyx_t_2);
                        __Pyx_GIVEREF(__pyx_t_19);
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __Pyx_ErrRestoreWithState(__pyx_t_2, __pyx_t_19, __pyx_t_21);
                        __pyx_t_2 = 0;  __pyx_t_19 = 0;  __pyx_t_21 = 0; 
                        __PYX_ERR(0, 727, __pyx_L29_except_error)
                      }
                      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                      __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                      __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                      goto __pyx_L28_exception_handled;
                    }
                    __pyx_L29_except_error:;
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
                    goto __pyx_L16_error;
                    __pyx_L31_try_return:;
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
                    goto __pyx_L24_return;
                    __pyx_L28_exception_handled:;
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
                    __pyx_L32_try_end:;
                  }
                }
                /*finally:*/ {
                  /*normal exit:*/{
                    if (__pyx_t_14) {
                      __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_mstate_global->__pyx_tuple[7], NULL);
                      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                      if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 727, __pyx_L16_error)
                      __Pyx_GOTREF(__pyx_t_18);
                      __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_18, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                      if (likely(__pyx_t_15 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_4);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_4;
                        __Pyx_XGIVEREF(__pyx_t_5);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_5;
                        __Pyx_XGIVEREF(__pyx_t_6);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_6;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 4;
                        return __pyx_r;
                        __pyx_L39_resume_from_await:;
                        __pyx_t_4 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_4);
                        __pyx_t_5 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_5);
                        __pyx_t_6 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_6);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 727, __pyx_L16_error)
                        __pyx_t_21 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_21);
                      } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_21 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 727, __pyx_L16_error)
                      }
                      __pyx_t_18 = __pyx_t_21;
                      __pyx_t_21 = 0;
                      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                    }
                    goto __pyx_L26;
                  }
                  __pyx_L24_return: {
                    __pyx_t_18 = __pyx_r;
                    __pyx_r = 0;
                    if (__pyx_t_14) {
                      __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_mstate_global->__pyx_tuple[7], NULL);
                      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                      if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 727, __pyx_L16_error)
                      __Pyx_GOTREF(__pyx_t_17);
                      __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_17, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                      if (likely(__pyx_t_15 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_4);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_4;
                        __Pyx_XGIVEREF(__pyx_t_5);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_5;
                        __Pyx_XGIVEREF(__pyx_t_6);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_6;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 5;
                        return __pyx_r;
                        __pyx_L40_resume_from_await:;
                        __pyx_t_4 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_4);
                        __pyx_t_5 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_5);
                        __pyx_t_6 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_6);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 727, __pyx_L16_error)
                        __pyx_t_21 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_21);
                      } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_21 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 727, __pyx_L16_error)
                      }
                      __pyx_t_17 = __pyx_t_21;
                      __pyx_t_21 = 0;
                      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                    }
                    __pyx_r = __pyx_t_18;
                    __pyx_t_18 = 0;
                    goto __pyx_L20_try_return;
                  }
                  __pyx_L26:;
                }
                goto __pyx_L41;
                __pyx_L22_error:;
                __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                goto __pyx_L16_error;
                __pyx_L41:;
              }

              /* "ws_package/controllers/activity_controller.py":726
 *         current_break_id = getattr(self, "break_id", 0) or 0
 *         try:
 *             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     query = select(ActivityInterval).where(
*/
            }
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            goto __pyx_L21_try_end;
            __pyx_L16_error:;
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
            __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
            __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
            __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
            __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
            __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
            __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            /*except:*/ {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._create_segment_dummy_entry", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_21, &__pyx_t_19, &__pyx_t_2) < 0) __PYX_ERR(0, 726, __pyx_L18_except_error)
              __Pyx_XGOTREF(__pyx_t_21);
              __Pyx_XGOTREF(__pyx_t_19);
              __Pyx_XGOTREF(__pyx_t_2);
              __pyx_t_1 = PyTuple_Pack(3, __pyx_t_21, __pyx_t_19, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 726, __pyx_L18_except_error)
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_1, NULL);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 726, __pyx_L18_except_error)
              __Pyx_GOTREF(__pyx_t_14);
              __pyx_t_29 = __Pyx_PyObject_IsTrue(__pyx_t_14);
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              if (__pyx_t_29 < (0)) __PYX_ERR(0, 726, __pyx_L18_except_error)
              __pyx_t_3 = (!__pyx_t_29);
              if (unlikely(__pyx_t_3)) {
                __Pyx_GIVEREF(__pyx_t_21);
                __Pyx_GIVEREF(__pyx_t_19);
                __Pyx_XGIVEREF(__pyx_t_2);
                __Pyx_ErrRestoreWithState(__pyx_t_21, __pyx_t_19, __pyx_t_2);
                __pyx_t_21 = 0;  __pyx_t_19 = 0;  __pyx_t_2 = 0; 
                __PYX_ERR(0, 726, __pyx_L18_except_error)
              }
              __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
              __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              goto __pyx_L17_exception_handled;
            }
            __pyx_L18_except_error:;
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
            goto __pyx_L6_error;
            __pyx_L20_try_return:;
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
            goto __pyx_L13_return;
            __pyx_L17_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
            __pyx_L21_try_end:;
          }
        }
        /*finally:*/ {
          /*normal exit:*/{
            if (__pyx_t_10) {
              __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_mstate_global->__pyx_tuple[7], NULL);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 726, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_13);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            }
            goto __pyx_L15;
          }
          __pyx_L13_return: {
            __pyx_t_13 = __pyx_r;
            __pyx_r = 0;
            if (__pyx_t_10) {
              __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_mstate_global->__pyx_tuple[7], NULL);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 726, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            }
            __pyx_r = __pyx_t_13;
            __pyx_t_13 = 0;
            goto __pyx_L10_try_return;
          }
          __pyx_L15:;
        }
        goto __pyx_L45;
        __pyx_L12_error:;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L6_error;
        __pyx_L45:;
      }

      /* "ws_package/controllers/activity_controller.py":725
 *         empty_activity_level = {"mouse": "1", "keyboard": "0.0", "average": "0.0"}
 *         current_break_id = getattr(self, "break_id", 0) or 0
 *         try:             # <<<<<<<<<<<<<<
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:
*/
    }
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L11_try_end;
    __pyx_L6_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
    __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
    __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
    __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "ws_package/controllers/activity_controller.py":743
 *                         )
 *                         return
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.warning("Error checking segment dummy entry: %s", e)
 * 
*/
    __pyx_t_30 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_30) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._create_segment_dummy_entry", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_19, &__pyx_t_21) < 0) __PYX_ERR(0, 743, __pyx_L8_except_error)
      __Pyx_XGOTREF(__pyx_t_2);
      __Pyx_XGOTREF(__pyx_t_19);
      __Pyx_XGOTREF(__pyx_t_21);
      __Pyx_INCREF(__pyx_t_19);
      __Pyx_GIVEREF(__pyx_t_19);
      __pyx_cur_scope->__pyx_v_e = __pyx_t_19;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":744
 *                         return
 *         except Exception as e:
 *             logger.warning("Error checking segment dummy entry: %s", e)             # <<<<<<<<<<<<<<
 * 
 *         await self.activity_service.save_first_activity_log(
*/
        __pyx_t_7 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 744, __pyx_L51_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 744, __pyx_L51_error)
        __Pyx_GOTREF(__pyx_t_20);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_9 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_20))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_20);
          assert(__pyx_t_7);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_20);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_20, __pyx__function);
          __pyx_t_9 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Error_checking_segment_dummy_ent, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_20, __pyx_callargs+__pyx_t_9, (3-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 744, __pyx_L51_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }

      /* "ws_package/controllers/activity_controller.py":743
 *                         )
 *                         return
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.warning("Error checking segment dummy entry: %s", e)
 * 
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          goto __pyx_L52;
        }
        __pyx_L51_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_10 = 0; __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_14 = 0; __pyx_t_18 = 0;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
          __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
          __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
          __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
          __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_11, &__pyx_t_14, &__pyx_t_18);
          if ( unlikely(__Pyx_GetException(&__pyx_t_10, &__pyx_t_13, &__pyx_t_12) < 0)) __Pyx_ErrFetch(&__pyx_t_10, &__pyx_t_13, &__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_18);
          __pyx_t_30 = __pyx_lineno; __pyx_t_31 = __pyx_clineno; __pyx_t_32 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_14, __pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ErrRestore(__pyx_t_10, __pyx_t_13, __pyx_t_12);
          __pyx_t_10 = 0; __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_14 = 0; __pyx_t_18 = 0;
          __pyx_lineno = __pyx_t_30; __pyx_clineno = __pyx_t_31; __pyx_filename = __pyx_t_32;
          goto __pyx_L8_except_error;
        }
        __pyx_L52:;
      }
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
      __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
      goto __pyx_L7_exception_handled;
    }
    goto __pyx_L8_except_error;

    /* "ws_package/controllers/activity_controller.py":725
 *         empty_activity_level = {"mouse": "1", "keyboard": "0.0", "average": "0.0"}
 *         current_break_id = getattr(self, "break_id", 0) or 0
 *         try:             # <<<<<<<<<<<<<<
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:
*/
    __pyx_L8_except_error:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L10_try_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
    __pyx_L7_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    __pyx_L11_try_end:;
  }

  /* "ws_package/controllers/activity_controller.py":746
 *             logger.warning("Error checking segment dummy entry: %s", e)
 * 
 *         await self.activity_service.save_first_activity_log(             # <<<<<<<<<<<<<<
 *             empty_activity_level,
 *             segment_start,
*/
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 746, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_19 = __pyx_t_2;
  __Pyx_INCREF(__pyx_t_19);

  /* "ws_package/controllers/activity_controller.py":750
 *             segment_start,
 *             segment_start,
 *             self.last_count + 1,             # <<<<<<<<<<<<<<
 *             self.get_today_weekday(),
 *             break_id=current_break_id,
*/
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 750, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_20 = __Pyx_PyLong_AddObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 750, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_20);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":751
 *             segment_start,
 *             self.last_count + 1,
 *             self.get_today_weekday(),             # <<<<<<<<<<<<<<
 *             break_id=current_break_id,
 *         )
*/
  __pyx_t_7 = __pyx_cur_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_7);
  __pyx_t_9 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_today_weekday, __pyx_callargs+__pyx_t_9, (1-__pyx_t_9) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 751, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }

  /* "ws_package/controllers/activity_controller.py":752
 *             self.last_count + 1,
 *             self.get_today_weekday(),
 *             break_id=current_break_id,             # <<<<<<<<<<<<<<
 *         )
 *         processed_count = await db_writer_service.process_immediately()
*/
  __pyx_t_9 = 0;
  {
    PyObject *__pyx_callargs[6 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_19, __pyx_cur_scope->__pyx_v_empty_activity_level, __pyx_cur_scope->__pyx_v_segment_start, __pyx_cur_scope->__pyx_v_segment_start, __pyx_t_20, __pyx_t_1};
    __pyx_t_7 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 746, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_break_id, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_t_7, __pyx_callargs+6, 0) < (0)) __PYX_ERR(0, 746, __pyx_L1_error)
    __pyx_t_21 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_save_first_activity_log, __pyx_callargs+__pyx_t_9, (6-__pyx_t_9) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_7);
    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 746, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_21);
  }
  __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_21, &__pyx_r);
  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
  if (likely(__pyx_t_15 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 6;
    return __pyx_r;
    __pyx_L57_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 746, __pyx_L1_error)
  } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 746, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":754
 *             break_id=current_break_id,
 *         )
 *         processed_count = await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 *         logger.info(
 *             "Created segment dummy entry at %s (counter=%s), flushed %s writes",
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 754, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 754, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_t_9 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
    __pyx_t_9 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
    __pyx_t_21 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_9, (1-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 754, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_21);
  }
  __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_21, &__pyx_r);
  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
  if (likely(__pyx_t_15 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 7;
    return __pyx_r;
    __pyx_L58_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 754, __pyx_L1_error)
    __pyx_t_21 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_21);
  } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __pyx_t_21 = __pyx_r; __pyx_r = NULL;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 754, __pyx_L1_error)
  }
  __Pyx_GIVEREF(__pyx_t_21);
  __pyx_cur_scope->__pyx_v_processed_count = __pyx_t_21;
  __pyx_t_21 = 0;

  /* "ws_package/controllers/activity_controller.py":755
 *         )
 *         processed_count = await db_writer_service.process_immediately()
 *         logger.info(             # <<<<<<<<<<<<<<
 *             "Created segment dummy entry at %s (counter=%s), flushed %s writes",
 *             segment_start,
*/
  __pyx_t_1 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 755, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 755, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":758
 *             "Created segment dummy entry at %s (counter=%s), flushed %s writes",
 *             segment_start,
 *             self.last_count + 1,             # <<<<<<<<<<<<<<
 *             processed_count,
 *         )
*/
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 758, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_20 = __Pyx_PyLong_AddObjC(__pyx_t_2, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 758, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_20);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":759
 *             segment_start,
 *             self.last_count + 1,
 *             processed_count,             # <<<<<<<<<<<<<<
 *         )
 * 
*/
  __pyx_t_9 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_7))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_7);
    assert(__pyx_t_1);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
    __pyx_t_9 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[5] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Created_segment_dummy_entry_at_s, __pyx_cur_scope->__pyx_v_segment_start, __pyx_t_20, __pyx_cur_scope->__pyx_v_processed_count};
    __pyx_t_21 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_9, (5-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 755, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_21);
  }
  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":721
 *         return True
 * 
 *     async def _create_segment_dummy_entry(self, segment_start: datetime.datetime) -> None:             # <<<<<<<<<<<<<<
 *         """Create is_uploaded=True marker interval at a new session boundary (project switch, etc.)."""
 *         empty_activity_level = {"mouse": "1", "keyboard": "0.0", "average": "0.0"}
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_XDECREF(__pyx_t_23);
  __Pyx_XDECREF(__pyx_t_24);
  __Pyx_XDECREF(__pyx_t_25);
  __Pyx_XDECREF(__pyx_t_26);
  __Pyx_XDECREF(__pyx_t_27);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("_create_segment_dummy_entry", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":762
 *         )
 * 
 *     def get_os_type_caps(self) -> str:             # <<<<<<<<<<<<<<
 *         platform_name = platform.system()
 *         if platform_name == "Darwin":
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_33get_os_type_caps(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_33get_os_type_caps = {"get_os_type_caps", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_33get_os_type_caps, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_33get_os_type_caps(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  CYTHON_UNUSED PyObject *__pyx_v_self = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[1] = {0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_os_type_caps (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 762, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 762, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "get_os_type_caps", 0) < (0)) __PYX_ERR(0, 762, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("get_os_type_caps", 1, 1, 1, i); __PYX_ERR(0, 762, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 1)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 762, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_os_type_caps", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 762, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.get_os_type_caps", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_32get_os_type_caps(__pyx_self, __pyx_v_self);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_32get_os_type_caps(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self) {
  PyObject *__pyx_v_platform_name = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_os_type_caps", 0);

  /* "ws_package/controllers/activity_controller.py":763
 * 
 *     def get_os_type_caps(self) -> str:
 *         platform_name = platform.system()             # <<<<<<<<<<<<<<
 *         if platform_name == "Darwin":
 *                 return "Mac"
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 763, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_system); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 763, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 763, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_v_platform_name = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":764
 *     def get_os_type_caps(self) -> str:
 *         platform_name = platform.system()
 *         if platform_name == "Darwin":             # <<<<<<<<<<<<<<
 *                 return "Mac"
 *         return platform_name
*/
  __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_platform_name, __pyx_mstate_global->__pyx_n_u_Darwin, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 764, __pyx_L1_error)
  if (__pyx_t_6) {

    /* "ws_package/controllers/activity_controller.py":765
 *         platform_name = platform.system()
 *         if platform_name == "Darwin":
 *                 return "Mac"             # <<<<<<<<<<<<<<
 *         return platform_name
 * 
*/
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_Mac);
    __pyx_r = __pyx_mstate_global->__pyx_n_u_Mac;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":764
 *     def get_os_type_caps(self) -> str:
 *         platform_name = platform.system()
 *         if platform_name == "Darwin":             # <<<<<<<<<<<<<<
 *                 return "Mac"
 *         return platform_name
*/
  }

  /* "ws_package/controllers/activity_controller.py":766
 *         if platform_name == "Darwin":
 *                 return "Mac"
 *         return platform_name             # <<<<<<<<<<<<<<
 * 
 *     def handle_s3_time_error(self, error_message: str):
*/
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_v_platform_name;
  __Pyx_INCREF(__pyx_t_1);
  if (!(likely(PyUnicode_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_t_1))) __PYX_ERR(0, 766, __pyx_L1_error)
  __pyx_r = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "ws_package/controllers/activity_controller.py":762
 *         )
 * 
 *     def get_os_type_caps(self) -> str:             # <<<<<<<<<<<<<<
 *         platform_name = platform.system()
 *         if platform_name == "Darwin":
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.get_os_type_caps", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_platform_name);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":768
 *         return platform_name
 * 
 *     def handle_s3_time_error(self, error_message: str):             # <<<<<<<<<<<<<<
 *         """Handle S3 RequestTimeTooSkewed (clock skew vs AWS). Log only  not a timezone mismatch."""
 *         try:
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_35handle_s3_time_error(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_34handle_s3_time_error, "Handle S3 RequestTimeTooSkewed (clock skew vs AWS). Log only \342\200\224 not a timezone mismatch.");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_35handle_s3_time_error = {"handle_s3_time_error", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_35handle_s3_time_error, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_34handle_s3_time_error};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_35handle_s3_time_error(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  CYTHON_UNUSED PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_error_message = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("handle_s3_time_error (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_error_message,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 768, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 768, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 768, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "handle_s3_time_error", 0) < (0)) __PYX_ERR(0, 768, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("handle_s3_time_error", 1, 2, 2, i); __PYX_ERR(0, 768, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 768, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 768, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_error_message = ((PyObject*)values[1]);
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("handle_s3_time_error", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 768, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.handle_s3_time_error", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_error_message), (&PyUnicode_Type), 0, "error_message", 2))) __PYX_ERR(0, 768, __pyx_L1_error)
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_34handle_s3_time_error(__pyx_self, __pyx_v_self, __pyx_v_error_message);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  goto __pyx_L7_cleaned_up;
  __pyx_L0:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __pyx_L7_cleaned_up:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_34handle_s3_time_error(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_error_message) {
  PyObject *__pyx_v_e = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  size_t __pyx_t_8;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  char const *__pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("handle_s3_time_error", 0);

  /* "ws_package/controllers/activity_controller.py":770
 *     def handle_s3_time_error(self, error_message: str):
 *         """Handle S3 RequestTimeTooSkewed (clock skew vs AWS). Log only  not a timezone mismatch."""
 *         try:             # <<<<<<<<<<<<<<
 *             logger.warning(
 *                 "S3 RequestTimeTooSkewed (system clock skew vs AWS): %s  "
*/
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":771
 *         """Handle S3 RequestTimeTooSkewed (clock skew vs AWS). Log only  not a timezone mismatch."""
 *         try:
 *             logger.warning(             # <<<<<<<<<<<<<<
 *                 "S3 RequestTimeTooSkewed (system clock skew vs AWS): %s  "
 *                 "not showing timezone mismatch; upload will retry after time sync",
*/
      __pyx_t_5 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 771, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 771, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":774
 *                 "S3 RequestTimeTooSkewed (system clock skew vs AWS): %s  "
 *                 "not showing timezone mismatch; upload will retry after time sync",
 *                 error_message,             # <<<<<<<<<<<<<<
 *             )
 *         except Exception as e:
*/
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_5);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_S3_RequestTimeTooSkewed_system_c, __pyx_v_error_message};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 771, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":770
 *     def handle_s3_time_error(self, error_message: str):
 *         """Handle S3 RequestTimeTooSkewed (clock skew vs AWS). Log only  not a timezone mismatch."""
 *         try:             # <<<<<<<<<<<<<<
 *             logger.warning(
 *                 "S3 RequestTimeTooSkewed (system clock skew vs AWS): %s  "
*/
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "ws_package/controllers/activity_controller.py":776
 *                 error_message,
 *             )
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error handling S3 time error: %s", e)
 * 
*/
    __pyx_t_9 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_9) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.handle_s3_time_error", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_7, &__pyx_t_5) < 0) __PYX_ERR(0, 776, __pyx_L5_except_error)
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_7);
      __pyx_v_e = __pyx_t_7;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":777
 *             )
 *         except Exception as e:
 *             logger.error("Error handling S3 time error: %s", e)             # <<<<<<<<<<<<<<
 * 
 *     async def inrange(self, start_date, end_date):
*/
        __pyx_t_10 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 777, __pyx_L14_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 777, __pyx_L14_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_12))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_12);
          assert(__pyx_t_10);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Error_handling_S3_time_error_s, __pyx_v_e};
          __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 777, __pyx_L14_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }

      /* "ws_package/controllers/activity_controller.py":776
 *                 error_message,
 *             )
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error handling S3 time error: %s", e)
 * 
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
          goto __pyx_L15;
        }
        __pyx_L14_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20);
          if ( unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
          __Pyx_XGOTREF(__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_16);
          __Pyx_XGOTREF(__pyx_t_17);
          __Pyx_XGOTREF(__pyx_t_18);
          __Pyx_XGOTREF(__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_20);
          __pyx_t_9 = __pyx_lineno; __pyx_t_13 = __pyx_clineno; __pyx_t_14 = __pyx_filename;
          {
            __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20);
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_XGIVEREF(__pyx_t_16);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_ErrRestore(__pyx_t_15, __pyx_t_16, __pyx_t_17);
          __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
          __pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_13; __pyx_filename = __pyx_t_14;
          goto __pyx_L5_except_error;
        }
        __pyx_L15:;
      }
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L4_exception_handled;
    }
    goto __pyx_L5_except_error;

    /* "ws_package/controllers/activity_controller.py":770
 *     def handle_s3_time_error(self, error_message: str):
 *         """Handle S3 RequestTimeTooSkewed (clock skew vs AWS). Log only  not a timezone mismatch."""
 *         try:             # <<<<<<<<<<<<<<
 *             logger.warning(
 *                 "S3 RequestTimeTooSkewed (system clock skew vs AWS): %s  "
*/
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    __pyx_L8_try_end:;
  }

  /* "ws_package/controllers/activity_controller.py":768
 *         return platform_name
 * 
 *     def handle_s3_time_error(self, error_message: str):             # <<<<<<<<<<<<<<
 *         """Handle S3 RequestTimeTooSkewed (clock skew vs AWS). Log only  not a timezone mismatch."""
 *         try:
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.handle_s3_time_error", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_38generator4(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":779
 *             logger.error("Error handling S3 time error: %s", e)
 * 
 *     async def inrange(self, start_date, end_date):             # <<<<<<<<<<<<<<
 *         if start_date is None or end_date is None:
 *             logger.info("Start date or end date is None")
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_37inrange(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_37inrange = {"inrange", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_37inrange, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_37inrange(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_start_date = 0;
  PyObject *__pyx_v_end_date = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("inrange (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_start_date,&__pyx_mstate_global->__pyx_n_u_end_date,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 779, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 779, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 779, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 779, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "inrange", 0) < (0)) __PYX_ERR(0, 779, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 3; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("inrange", 1, 3, 3, i); __PYX_ERR(0, 779, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 3)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 779, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 779, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 779, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_start_date = values[1];
    __pyx_v_end_date = values[2];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("inrange", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 779, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.inrange", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_36inrange(__pyx_self, __pyx_v_self, __pyx_v_start_date, __pyx_v_end_date);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_36inrange(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_start_date, PyObject *__pyx_v_end_date) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("inrange", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 779, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_start_date = __pyx_v_start_date;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_start_date);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_start_date);
  __pyx_cur_scope->__pyx_v_end_date = __pyx_v_end_date;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_end_date);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_end_date);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_38generator4, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[4]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_inrange, __pyx_mstate_global->__pyx_n_u_ActivityController_inrange, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 779, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.inrange", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_38generator4(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  size_t __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("inrange", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 779, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":780
 * 
 *     async def inrange(self, start_date, end_date):
 *         if start_date is None or end_date is None:             # <<<<<<<<<<<<<<
 *             logger.info("Start date or end date is None")
 *             return
*/
  __pyx_t_2 = (__pyx_cur_scope->__pyx_v_start_date == Py_None);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_2 = (__pyx_cur_scope->__pyx_v_end_date == Py_None);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_1) {

    /* "ws_package/controllers/activity_controller.py":781
 *     async def inrange(self, start_date, end_date):
 *         if start_date is None or end_date is None:
 *             logger.info("Start date or end date is None")             # <<<<<<<<<<<<<<
 *             return
 *         start_date_y = start_date.time()
*/
    __pyx_t_4 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 781, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 781, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
      assert(__pyx_t_4);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Start_date_or_end_date_is_None};
      __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 781, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "ws_package/controllers/activity_controller.py":782
 *         if start_date is None or end_date is None:
 *             logger.info("Start date or end date is None")
 *             return             # <<<<<<<<<<<<<<
 *         start_date_y = start_date.time()
 *         end_date_y = end_date.time()
*/
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":780
 * 
 *     async def inrange(self, start_date, end_date):
 *         if start_date is None or end_date is None:             # <<<<<<<<<<<<<<
 *             logger.info("Start date or end date is None")
 *             return
*/
  }

  /* "ws_package/controllers/activity_controller.py":783
 *             logger.info("Start date or end date is None")
 *             return
 *         start_date_y = start_date.time()             # <<<<<<<<<<<<<<
 *         end_date_y = end_date.time()
 *         if self.limit_start is None or self.limit_end is None or self.no_of_days is None:
*/
  __pyx_t_6 = __pyx_cur_scope->__pyx_v_start_date;
  __Pyx_INCREF(__pyx_t_6);
  __pyx_t_7 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
    __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_time, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 783, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  }
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_start_date_y = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "ws_package/controllers/activity_controller.py":784
 *             return
 *         start_date_y = start_date.time()
 *         end_date_y = end_date.time()             # <<<<<<<<<<<<<<
 *         if self.limit_start is None or self.limit_end is None or self.no_of_days is None:
 *             logger.info("No limit start or end time or no of days")
*/
  __pyx_t_6 = __pyx_cur_scope->__pyx_v_end_date;
  __Pyx_INCREF(__pyx_t_6);
  __pyx_t_7 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
    __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_time, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 784, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  }
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_end_date_y = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "ws_package/controllers/activity_controller.py":785
 *         start_date_y = start_date.time()
 *         end_date_y = end_date.time()
 *         if self.limit_start is None or self.limit_end is None or self.no_of_days is None:             # <<<<<<<<<<<<<<
 *             logger.info("No limit start or end time or no of days")
 *             return True
*/
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_start); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 785, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = (__pyx_t_3 == Py_None);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_end); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 785, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = (__pyx_t_3 == Py_None);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L8_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_no_of_days); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 785, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = (__pyx_t_3 == Py_None);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = __pyx_t_2;
  __pyx_L8_bool_binop_done:;
  if (__pyx_t_1) {

    /* "ws_package/controllers/activity_controller.py":786
 *         end_date_y = end_date.time()
 *         if self.limit_start is None or self.limit_end is None or self.no_of_days is None:
 *             logger.info("No limit start or end time or no of days")             # <<<<<<<<<<<<<<
 *             return True
 *         if self.limit_start <= start_date_y <= self.limit_end and self.limit_start <= end_date_y <= self.limit_end and self.get_weekday(str(start_date)) in self.no_of_days:
*/
    __pyx_t_6 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 786, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 786, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
      assert(__pyx_t_6);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_No_limit_start_or_end_time_or_no};
      __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 786, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "ws_package/controllers/activity_controller.py":787
 *         if self.limit_start is None or self.limit_end is None or self.no_of_days is None:
 *             logger.info("No limit start or end time or no of days")
 *             return True             # <<<<<<<<<<<<<<
 *         if self.limit_start <= start_date_y <= self.limit_end and self.limit_start <= end_date_y <= self.limit_end and self.get_weekday(str(start_date)) in self.no_of_days:
 *             logger.info("In range of tracking senerio")
*/
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_True);
    __pyx_r = Py_True;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":785
 *         start_date_y = start_date.time()
 *         end_date_y = end_date.time()
 *         if self.limit_start is None or self.limit_end is None or self.no_of_days is None:             # <<<<<<<<<<<<<<
 *             logger.info("No limit start or end time or no of days")
 *             return True
*/
  }

  /* "ws_package/controllers/activity_controller.py":788
 *             logger.info("No limit start or end time or no of days")
 *             return True
 *         if self.limit_start <= start_date_y <= self.limit_end and self.limit_start <= end_date_y <= self.limit_end and self.get_weekday(str(start_date)) in self.no_of_days:             # <<<<<<<<<<<<<<
 *             logger.info("In range of tracking senerio")
 *             return True
*/
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_start); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 788, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_cur_scope->__pyx_v_start_date_y, Py_LE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 788, __pyx_L1_error)
  if (__Pyx_PyObject_IsTrue(__pyx_t_5)) {
    __Pyx_DECREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_end); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 788, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_start_date_y, __pyx_t_6, Py_LE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 788, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 788, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L12_bool_binop_done;
  }
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_start); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 788, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_cur_scope->__pyx_v_end_date_y, Py_LE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 788, __pyx_L1_error)
  if (__Pyx_PyObject_IsTrue(__pyx_t_3)) {
    __Pyx_DECREF(__pyx_t_3);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_end); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 788, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_3 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_end_date_y, __pyx_t_6, Py_LE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 788, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 788, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L12_bool_binop_done;
  }
  __pyx_t_5 = __pyx_cur_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_Unicode(__pyx_cur_scope->__pyx_v_start_date); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 788, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_6};
    __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_weekday, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 788, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  }
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_no_of_days); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 788, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_t_3, __pyx_t_6, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 788, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_1 = __pyx_t_2;
  __pyx_L12_bool_binop_done:;
  if (__pyx_t_1) {

    /* "ws_package/controllers/activity_controller.py":789
 *             return True
 *         if self.limit_start <= start_date_y <= self.limit_end and self.limit_start <= end_date_y <= self.limit_end and self.get_weekday(str(start_date)) in self.no_of_days:
 *             logger.info("In range of tracking senerio")             # <<<<<<<<<<<<<<
 *             return True
 *         logger.info("Out of range of tracking senerio")
*/
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 789, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 789, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_In_range_of_tracking_senerio};
      __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 789, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "ws_package/controllers/activity_controller.py":790
 *         if self.limit_start <= start_date_y <= self.limit_end and self.limit_start <= end_date_y <= self.limit_end and self.get_weekday(str(start_date)) in self.no_of_days:
 *             logger.info("In range of tracking senerio")
 *             return True             # <<<<<<<<<<<<<<
 *         logger.info("Out of range of tracking senerio")
 *         return False
*/
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_True);
    __pyx_r = Py_True;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":788
 *             logger.info("No limit start or end time or no of days")
 *             return True
 *         if self.limit_start <= start_date_y <= self.limit_end and self.limit_start <= end_date_y <= self.limit_end and self.get_weekday(str(start_date)) in self.no_of_days:             # <<<<<<<<<<<<<<
 *             logger.info("In range of tracking senerio")
 *             return True
*/
  }

  /* "ws_package/controllers/activity_controller.py":791
 *             logger.info("In range of tracking senerio")
 *             return True
 *         logger.info("Out of range of tracking senerio")             # <<<<<<<<<<<<<<
 *         return False
 * 
*/
  __pyx_t_4 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 791, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 791, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_7 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
    assert(__pyx_t_4);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
    __pyx_t_7 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Out_of_range_of_tracking_senerio};
    __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 791, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "ws_package/controllers/activity_controller.py":792
 *             return True
 *         logger.info("Out of range of tracking senerio")
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     @staticmethod
*/
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(Py_False);
  __pyx_r = Py_False;
  goto __pyx_L0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":779
 *             logger.error("Error handling S3 time error: %s", e)
 * 
 *     async def inrange(self, start_date, end_date):             # <<<<<<<<<<<<<<
 *         if start_date is None or end_date is None:
 *             logger.info("Start date or end date is None")
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("inrange", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":794
 *         return False
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def _normalize_hhmmss(value) -> Optional[str]:
 *         """Normalize API time strings to HH:MM:SS for strptime."""
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_40_normalize_hhmmss(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_39_normalize_hhmmss, "Normalize API time strings to HH:MM:SS for strptime.");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_40_normalize_hhmmss = {"_normalize_hhmmss", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_40_normalize_hhmmss, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_39_normalize_hhmmss};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_40_normalize_hhmmss(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_value = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[1] = {0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_normalize_hhmmss (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_value,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 794, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 794, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_normalize_hhmmss", 0) < (0)) __PYX_ERR(0, 794, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_normalize_hhmmss", 1, 1, 1, i); __PYX_ERR(0, 794, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 1)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 794, __pyx_L3_error)
    }
    __pyx_v_value = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_normalize_hhmmss", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 794, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._normalize_hhmmss", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_39_normalize_hhmmss(__pyx_self, __pyx_v_value);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_39_normalize_hhmmss(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_value) {
  PyObject *__pyx_v_text = NULL;
  PyObject *__pyx_v_fmt = NULL;
  PyObject *__pyx_v_parsed = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  int __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_t_15;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_normalize_hhmmss", 0);

  /* "ws_package/controllers/activity_controller.py":797
 *     def _normalize_hhmmss(value) -> Optional[str]:
 *         """Normalize API time strings to HH:MM:SS for strptime."""
 *         if value is None:             # <<<<<<<<<<<<<<
 *             return None
 *         text = str(value).strip()
*/
  __pyx_t_1 = (__pyx_v_value == Py_None);
  if (__pyx_t_1) {

    /* "ws_package/controllers/activity_controller.py":798
 *         """Normalize API time strings to HH:MM:SS for strptime."""
 *         if value is None:
 *             return None             # <<<<<<<<<<<<<<
 *         text = str(value).strip()
 *         if not text:
*/
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":797
 *     def _normalize_hhmmss(value) -> Optional[str]:
 *         """Normalize API time strings to HH:MM:SS for strptime."""
 *         if value is None:             # <<<<<<<<<<<<<<
 *             return None
 *         text = str(value).strip()
*/
  }

  /* "ws_package/controllers/activity_controller.py":799
 *         if value is None:
 *             return None
 *         text = str(value).strip()             # <<<<<<<<<<<<<<
 *         if not text:
 *             return None
*/
  __pyx_t_4 = __Pyx_PyObject_Unicode(__pyx_v_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 799, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __pyx_t_4;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
    __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strip, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 799, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
  }
  __pyx_v_text = ((PyObject*)__pyx_t_2);
  __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":800
 *             return None
 *         text = str(value).strip()
 *         if not text:             # <<<<<<<<<<<<<<
 *             return None
 *         for fmt in ("%H:%M:%S", "%H:%M"):
*/
  {
    Py_ssize_t __pyx_temp = __Pyx_PyUnicode_IS_TRUE(__pyx_v_text);
    if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 800, __pyx_L1_error)
    __pyx_t_1 = (__pyx_temp != 0);
  }

  __pyx_t_6 = (!__pyx_t_1);
  if (__pyx_t_6) {

    /* "ws_package/controllers/activity_controller.py":801
 *         text = str(value).strip()
 *         if not text:
 *             return None             # <<<<<<<<<<<<<<
 *         for fmt in ("%H:%M:%S", "%H:%M"):
 *             try:
*/
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":800
 *             return None
 *         text = str(value).strip()
 *         if not text:             # <<<<<<<<<<<<<<
 *             return None
 *         for fmt in ("%H:%M:%S", "%H:%M"):
*/
  }

  /* "ws_package/controllers/activity_controller.py":802
 *         if not text:
 *             return None
 *         for fmt in ("%H:%M:%S", "%H:%M"):             # <<<<<<<<<<<<<<
 *             try:
 *                 parsed = datetime.datetime.strptime(text, fmt).time()
*/
  __pyx_t_2 = __pyx_mstate_global->__pyx_tuple[8]; __Pyx_INCREF(__pyx_t_2);
  __pyx_t_7 = 0;
  for (;;) {
    if (__pyx_t_7 >= 2) break;
    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
    __pyx_t_4 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_7));
    #else
    __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_7);
    #endif
    ++__pyx_t_7;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 802, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_XDECREF_SET(__pyx_v_fmt, ((PyObject*)__pyx_t_4));
    __pyx_t_4 = 0;

    /* "ws_package/controllers/activity_controller.py":803
 *             return None
 *         for fmt in ("%H:%M:%S", "%H:%M"):
 *             try:             # <<<<<<<<<<<<<<
 *                 parsed = datetime.datetime.strptime(text, fmt).time()
 *                 return parsed.strftime("%H:%M:%S")
*/
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":804
 *         for fmt in ("%H:%M:%S", "%H:%M"):
 *             try:
 *                 parsed = datetime.datetime.strptime(text, fmt).time()             # <<<<<<<<<<<<<<
 *                 return parsed.strftime("%H:%M:%S")
 *             except ValueError:
*/
        __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 804, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 804, __pyx_L7_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_12 = __pyx_t_14;
        __Pyx_INCREF(__pyx_t_12);
        __pyx_t_5 = 0;
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_12, __pyx_v_text, __pyx_v_fmt};
          __pyx_t_11 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strptime, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 804, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_11);
        }
        __pyx_t_3 = __pyx_t_11;
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_5 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
          __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_time, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 804, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_XDECREF_SET(__pyx_v_parsed, __pyx_t_4);
        __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":805
 *             try:
 *                 parsed = datetime.datetime.strptime(text, fmt).time()
 *                 return parsed.strftime("%H:%M:%S")             # <<<<<<<<<<<<<<
 *             except ValueError:
 *                 continue
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_11 = __pyx_v_parsed;
        __Pyx_INCREF(__pyx_t_11);
        __pyx_t_5 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_11, __pyx_mstate_global->__pyx_kp_u_H_M_S};
          __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strftime, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 805, __pyx_L7_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        if (!(likely(PyUnicode_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_t_4))) __PYX_ERR(0, 805, __pyx_L7_error)
        __pyx_r = ((PyObject*)__pyx_t_4);
        __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        goto __pyx_L11_try_return;

        /* "ws_package/controllers/activity_controller.py":803
 *             return None
 *         for fmt in ("%H:%M:%S", "%H:%M"):
 *             try:             # <<<<<<<<<<<<<<
 *                 parsed = datetime.datetime.strptime(text, fmt).time()
 *                 return parsed.strftime("%H:%M:%S")
*/
      }
      __pyx_L7_error:;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":806
 *                 parsed = datetime.datetime.strptime(text, fmt).time()
 *                 return parsed.strftime("%H:%M:%S")
 *             except ValueError:             # <<<<<<<<<<<<<<
 *                 continue
 *         return None
*/
      __pyx_t_15 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_ValueError))));
      if (__pyx_t_15) {
        __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._normalize_hhmmss", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_11, &__pyx_t_3) < 0) __PYX_ERR(0, 806, __pyx_L9_except_error)
        __Pyx_XGOTREF(__pyx_t_4);
        __Pyx_XGOTREF(__pyx_t_11);
        __Pyx_XGOTREF(__pyx_t_3);

        /* "ws_package/controllers/activity_controller.py":807
 *                 return parsed.strftime("%H:%M:%S")
 *             except ValueError:
 *                 continue             # <<<<<<<<<<<<<<
 *         return None
 * 
*/
        goto __pyx_L15_except_continue;
        __pyx_L15_except_continue:;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        goto __pyx_L13_try_continue;
      }
      goto __pyx_L9_except_error;

      /* "ws_package/controllers/activity_controller.py":803
 *             return None
 *         for fmt in ("%H:%M:%S", "%H:%M"):
 *             try:             # <<<<<<<<<<<<<<
 *                 parsed = datetime.datetime.strptime(text, fmt).time()
 *                 return parsed.strftime("%H:%M:%S")
*/
      __pyx_L9_except_error:;
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      goto __pyx_L1_error;
      __pyx_L13_try_continue:;
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      goto __pyx_L5_continue;
      __pyx_L11_try_return:;
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      goto __pyx_L0;
    }

    /* "ws_package/controllers/activity_controller.py":802
 *         if not text:
 *             return None
 *         for fmt in ("%H:%M:%S", "%H:%M"):             # <<<<<<<<<<<<<<
 *             try:
 *                 parsed = datetime.datetime.strptime(text, fmt).time()
*/
    __pyx_L5_continue:;
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":808
 *             except ValueError:
 *                 continue
 *         return None             # <<<<<<<<<<<<<<
 * 
 *     def _parse_fixed_mode_window(self, response: dict):
*/
  __Pyx_XDECREF(__pyx_r);
  __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
  goto __pyx_L0;

  /* "ws_package/controllers/activity_controller.py":794
 *         return False
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def _normalize_hhmmss(value) -> Optional[str]:
 *         """Normalize API time strings to HH:MM:SS for strptime."""
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._normalize_hhmmss", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_text);
  __Pyx_XDECREF(__pyx_v_fmt);
  __Pyx_XDECREF(__pyx_v_parsed);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":810
 *         return None
 * 
 *     def _parse_fixed_mode_window(self, response: dict):             # <<<<<<<<<<<<<<
 *         """
 *         Read fixed-mode (stealth) start/end from API  same for silent and visible builds.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_42_parse_fixed_mode_window(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_41_parse_fixed_mode_window, "\n        Read fixed-mode (stealth) start/end from API \342\200\224 same for silent and visible builds.\n\n        Prefer start_time/end_time; fall back to limit_start/limit_end; else all-day.\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_42_parse_fixed_mode_window = {"_parse_fixed_mode_window", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_42_parse_fixed_mode_window, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_41_parse_fixed_mode_window};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_42_parse_fixed_mode_window(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_response = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_parse_fixed_mode_window (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_response,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 810, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 810, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 810, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_parse_fixed_mode_window", 0) < (0)) __PYX_ERR(0, 810, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_parse_fixed_mode_window", 1, 2, 2, i); __PYX_ERR(0, 810, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 810, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 810, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_response = ((PyObject*)values[1]);
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_parse_fixed_mode_window", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 810, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._parse_fixed_mode_window", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_response), (&PyDict_Type), 0, "response", 2))) __PYX_ERR(0, 810, __pyx_L1_error)
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_41_parse_fixed_mode_window(__pyx_self, __pyx_v_self, __pyx_v_response);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  goto __pyx_L7_cleaned_up;
  __pyx_L0:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __pyx_L7_cleaned_up:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_41_parse_fixed_mode_window(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_response) {
  PyObject *__pyx_v_raw_start = NULL;
  PyObject *__pyx_v_raw_end = NULL;
  PyObject *__pyx_v_s_limit_start = NULL;
  PyObject *__pyx_v_s_limit_end = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  size_t __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_parse_fixed_mode_window", 0);

  /* "ws_package/controllers/activity_controller.py":816
 *         Prefer start_time/end_time; fall back to limit_start/limit_end; else all-day.
 *         """
 *         raw_start = response.get("start_time")             # <<<<<<<<<<<<<<
 *         if raw_start is None:
 *             raw_start = response.get("limit_start")
*/
  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(__pyx_v_response, __pyx_mstate_global->__pyx_n_u_start_time, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 816, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_raw_start = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":817
 *         """
 *         raw_start = response.get("start_time")
 *         if raw_start is None:             # <<<<<<<<<<<<<<
 *             raw_start = response.get("limit_start")
 *         raw_end = response.get("end_time")
*/
  __pyx_t_2 = (__pyx_v_raw_start == Py_None);
  if (__pyx_t_2) {

    /* "ws_package/controllers/activity_controller.py":818
 *         raw_start = response.get("start_time")
 *         if raw_start is None:
 *             raw_start = response.get("limit_start")             # <<<<<<<<<<<<<<
 *         raw_end = response.get("end_time")
 *         if raw_end is None:
*/
    __pyx_t_1 = __Pyx_PyDict_GetItemDefault(__pyx_v_response, __pyx_mstate_global->__pyx_n_u_limit_start, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 818, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_raw_start, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "ws_package/controllers/activity_controller.py":817
 *         """
 *         raw_start = response.get("start_time")
 *         if raw_start is None:             # <<<<<<<<<<<<<<
 *             raw_start = response.get("limit_start")
 *         raw_end = response.get("end_time")
*/
  }

  /* "ws_package/controllers/activity_controller.py":819
 *         if raw_start is None:
 *             raw_start = response.get("limit_start")
 *         raw_end = response.get("end_time")             # <<<<<<<<<<<<<<
 *         if raw_end is None:
 *             raw_end = response.get("limit_end")
*/
  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(__pyx_v_response, __pyx_mstate_global->__pyx_n_u_end_time, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 819, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_raw_end = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":820
 *             raw_start = response.get("limit_start")
 *         raw_end = response.get("end_time")
 *         if raw_end is None:             # <<<<<<<<<<<<<<
 *             raw_end = response.get("limit_end")
 * 
*/
  __pyx_t_2 = (__pyx_v_raw_end == Py_None);
  if (__pyx_t_2) {

    /* "ws_package/controllers/activity_controller.py":821
 *         raw_end = response.get("end_time")
 *         if raw_end is None:
 *             raw_end = response.get("limit_end")             # <<<<<<<<<<<<<<
 * 
 *         s_limit_start = self._normalize_hhmmss(raw_start)
*/
    __pyx_t_1 = __Pyx_PyDict_GetItemDefault(__pyx_v_response, __pyx_mstate_global->__pyx_n_u_limit_end, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 821, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF_SET(__pyx_v_raw_end, __pyx_t_1);
    __pyx_t_1 = 0;

    /* "ws_package/controllers/activity_controller.py":820
 *             raw_start = response.get("limit_start")
 *         raw_end = response.get("end_time")
 *         if raw_end is None:             # <<<<<<<<<<<<<<
 *             raw_end = response.get("limit_end")
 * 
*/
  }

  /* "ws_package/controllers/activity_controller.py":823
 *             raw_end = response.get("limit_end")
 * 
 *         s_limit_start = self._normalize_hhmmss(raw_start)             # <<<<<<<<<<<<<<
 *         s_limit_end = self._normalize_hhmmss(raw_end)
 * 
*/
  __pyx_t_3 = __pyx_v_self;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_4 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_raw_start};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_normalize_hhmmss, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 823, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_v_s_limit_start = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":824
 * 
 *         s_limit_start = self._normalize_hhmmss(raw_start)
 *         s_limit_end = self._normalize_hhmmss(raw_end)             # <<<<<<<<<<<<<<
 * 
 *         if s_limit_start is None or s_limit_end is None:
*/
  __pyx_t_3 = __pyx_v_self;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_4 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_v_raw_end};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_normalize_hhmmss, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 824, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_v_s_limit_end = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":826
 *         s_limit_end = self._normalize_hhmmss(raw_end)
 * 
 *         if s_limit_start is None or s_limit_end is None:             # <<<<<<<<<<<<<<
 *             logger.warning(
 *                 "[STEALTH] Fixed-mode window missing/invalid (start=%r end=%r)  using all-day fallback",
*/
  __pyx_t_5 = (__pyx_v_s_limit_start == Py_None);
  if (!__pyx_t_5) {
  } else {
    __pyx_t_2 = __pyx_t_5;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_5 = (__pyx_v_s_limit_end == Py_None);
  __pyx_t_2 = __pyx_t_5;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_2) {

    /* "ws_package/controllers/activity_controller.py":827
 * 
 *         if s_limit_start is None or s_limit_end is None:
 *             logger.warning(             # <<<<<<<<<<<<<<
 *                 "[STEALTH] Fixed-mode window missing/invalid (start=%r end=%r)  using all-day fallback",
 *                 raw_start,
*/
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 827, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 827, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "ws_package/controllers/activity_controller.py":830
 *                 "[STEALTH] Fixed-mode window missing/invalid (start=%r end=%r)  using all-day fallback",
 *                 raw_start,
 *                 raw_end,             # <<<<<<<<<<<<<<
 *             )
 *             return "00:00:00", "23:59:59"
*/
    __pyx_t_4 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_7);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
      __pyx_t_4 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[4] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_STEALTH_Fixed_mode_window_missi, __pyx_v_raw_start, __pyx_v_raw_end};
      __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_4, (4-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 827, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "ws_package/controllers/activity_controller.py":832
 *                 raw_end,
 *             )
 *             return "00:00:00", "23:59:59"             # <<<<<<<<<<<<<<
 * 
 *         return s_limit_start, s_limit_end
*/
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_mstate_global->__pyx_tuple[9]);
    __pyx_r = __pyx_mstate_global->__pyx_tuple[9];
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":826
 *         s_limit_end = self._normalize_hhmmss(raw_end)
 * 
 *         if s_limit_start is None or s_limit_end is None:             # <<<<<<<<<<<<<<
 *             logger.warning(
 *                 "[STEALTH] Fixed-mode window missing/invalid (start=%r end=%r)  using all-day fallback",
*/
  }

  /* "ws_package/controllers/activity_controller.py":834
 *             return "00:00:00", "23:59:59"
 * 
 *         return s_limit_start, s_limit_end             # <<<<<<<<<<<<<<
 * 
 *     async def update_tracking_duration(self, user_entity:UserEntity):
*/
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 834, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_v_s_limit_start);
  __Pyx_GIVEREF(__pyx_v_s_limit_start);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_s_limit_start) != (0)) __PYX_ERR(0, 834, __pyx_L1_error);
  __Pyx_INCREF(__pyx_v_s_limit_end);
  __Pyx_GIVEREF(__pyx_v_s_limit_end);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_s_limit_end) != (0)) __PYX_ERR(0, 834, __pyx_L1_error);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "ws_package/controllers/activity_controller.py":810
 *         return None
 * 
 *     def _parse_fixed_mode_window(self, response: dict):             # <<<<<<<<<<<<<<
 *         """
 *         Read fixed-mode (stealth) start/end from API  same for silent and visible builds.
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._parse_fixed_mode_window", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_raw_start);
  __Pyx_XDECREF(__pyx_v_raw_end);
  __Pyx_XDECREF(__pyx_v_s_limit_start);
  __Pyx_XDECREF(__pyx_v_s_limit_end);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_45generator5(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":836
 *         return s_limit_start, s_limit_end
 * 
 *     async def update_tracking_duration(self, user_entity:UserEntity):             # <<<<<<<<<<<<<<
 *         """
 *         Update tracking duration from stealth mode API.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_44update_tracking_duration(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_43update_tracking_duration, "\n        Update tracking duration from stealth mode API.\n        Uses caching to prevent excessive API calls - only refreshes every 5 minutes.\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_44update_tracking_duration = {"update_tracking_duration", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_44update_tracking_duration, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_43update_tracking_duration};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_44update_tracking_duration(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_user_entity = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("update_tracking_duration (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_user_entity,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 836, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 836, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 836, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "update_tracking_duration", 0) < (0)) __PYX_ERR(0, 836, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("update_tracking_duration", 1, 2, 2, i); __PYX_ERR(0, 836, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 836, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 836, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_user_entity = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("update_tracking_duration", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 836, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.update_tracking_duration", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_43update_tracking_duration(__pyx_self, __pyx_v_self, __pyx_v_user_entity);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_43update_tracking_duration(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("update_tracking_duration", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 836, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_user_entity = __pyx_v_user_entity;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_user_entity);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_user_entity);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_45generator5, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[5]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_update_tracking_duration, __pyx_mstate_global->__pyx_n_u_ActivityController_update_tracki, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 836, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.update_tracking_duration", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_45generator5(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  size_t __pyx_t_8;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_PySendResult __pyx_t_11;
  PyObject *(*__pyx_t_12)(PyObject *);
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_t_18;
  int __pyx_t_19;
  char const *__pyx_t_20;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  PyObject *__pyx_t_26 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("update_tracking_duration", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L13_resume_from_await;
    case 2: goto __pyx_L19_resume_from_await;
    case 3: goto __pyx_L20_resume_from_await;
    case 4: goto __pyx_L29_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 836, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":841
 *         Uses caching to prevent excessive API calls - only refreshes every 5 minutes.
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # Check if we should refresh from API (cache expired or first call)
 *             should_refresh = False
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":843
 *         try:
 *             # Check if we should refresh from API (cache expired or first call)
 *             should_refresh = False             # <<<<<<<<<<<<<<
 *             current_time = datetime.datetime.now()
 * 
*/
      __pyx_cur_scope->__pyx_v_should_refresh = 0;

      /* "ws_package/controllers/activity_controller.py":844
 *             # Check if we should refresh from API (cache expired or first call)
 *             should_refresh = False
 *             current_time = datetime.datetime.now()             # <<<<<<<<<<<<<<
 * 
 *             if self._last_stealth_api_call is None:
*/
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 844, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 844, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_5 = __pyx_t_7;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 844, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_cur_scope->__pyx_v_current_time = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":846
 *             current_time = datetime.datetime.now()
 * 
 *             if self._last_stealth_api_call is None:             # <<<<<<<<<<<<<<
 *                 # First call - always refresh
 *                 should_refresh = True
*/
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_stealth_api_call); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 846, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_9 = (__pyx_t_4 == Py_None);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_9) {

        /* "ws_package/controllers/activity_controller.py":848
 *             if self._last_stealth_api_call is None:
 *                 # First call - always refresh
 *                 should_refresh = True             # <<<<<<<<<<<<<<
 *                 logger.debug("[STEALTH] First stealth mode API call - fetching from server")
 *             else:
*/
        __pyx_cur_scope->__pyx_v_should_refresh = 1;

        /* "ws_package/controllers/activity_controller.py":849
 *                 # First call - always refresh
 *                 should_refresh = True
 *                 logger.debug("[STEALTH] First stealth mode API call - fetching from server")             # <<<<<<<<<<<<<<
 *             else:
 *                 # Check if cache has expired
*/
        __pyx_t_7 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 849, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 849, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
          assert(__pyx_t_7);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_STEALTH_First_stealth_mode_API};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 849, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":846
 *             current_time = datetime.datetime.now()
 * 
 *             if self._last_stealth_api_call is None:             # <<<<<<<<<<<<<<
 *                 # First call - always refresh
 *                 should_refresh = True
*/
        goto __pyx_L10;
      }

      /* "ws_package/controllers/activity_controller.py":852
 *             else:
 *                 # Check if cache has expired
 *                 time_since_last_call = (current_time - self._last_stealth_api_call).total_seconds()             # <<<<<<<<<<<<<<
 *                 if time_since_last_call >= self._stealth_api_cache_interval:
 *                     should_refresh = True
*/
      /*else*/ {
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_stealth_api_call); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 852, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_5 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_current_time, __pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 852, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_6 = __pyx_t_5;
        __Pyx_INCREF(__pyx_t_6);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
          __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_total_seconds, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 852, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_GIVEREF(__pyx_t_4);
        __pyx_cur_scope->__pyx_v_time_since_last_call = __pyx_t_4;
        __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":853
 *                 # Check if cache has expired
 *                 time_since_last_call = (current_time - self._last_stealth_api_call).total_seconds()
 *                 if time_since_last_call >= self._stealth_api_cache_interval:             # <<<<<<<<<<<<<<
 *                     should_refresh = True
 *                     logger.debug("[STEALTH] Cache expired (%ss >= %ss) - refreshing from server", int(time_since_last_call), self._stealth_api_cache_interval)
*/
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_stealth_api_cache_interval); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 853, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_time_since_last_call, __pyx_t_4, Py_GE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 853, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 853, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (__pyx_t_9) {

          /* "ws_package/controllers/activity_controller.py":854
 *                 time_since_last_call = (current_time - self._last_stealth_api_call).total_seconds()
 *                 if time_since_last_call >= self._stealth_api_cache_interval:
 *                     should_refresh = True             # <<<<<<<<<<<<<<
 *                     logger.debug("[STEALTH] Cache expired (%ss >= %ss) - refreshing from server", int(time_since_last_call), self._stealth_api_cache_interval)
 *                 else:
*/
          __pyx_cur_scope->__pyx_v_should_refresh = 1;

          /* "ws_package/controllers/activity_controller.py":855
 *                 if time_since_last_call >= self._stealth_api_cache_interval:
 *                     should_refresh = True
 *                     logger.debug("[STEALTH] Cache expired (%ss >= %ss) - refreshing from server", int(time_since_last_call), self._stealth_api_cache_interval)             # <<<<<<<<<<<<<<
 *                 else:
 *                     logger.debug("[STEALTH] Using cached stealth mode data (%ss < %ss)", int(time_since_last_call), self._stealth_api_cache_interval)
*/
          __pyx_t_4 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 855, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 855, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_6 = __Pyx_PyNumber_Int(__pyx_cur_scope->__pyx_v_time_since_last_call); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 855, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_stealth_api_cache_interval); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 855, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_7))) {
            __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7);
            assert(__pyx_t_4);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[4] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_STEALTH_Cache_expired_ss_ss_ref, __pyx_t_6, __pyx_t_10};
            __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 855, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":853
 *                 # Check if cache has expired
 *                 time_since_last_call = (current_time - self._last_stealth_api_call).total_seconds()
 *                 if time_since_last_call >= self._stealth_api_cache_interval:             # <<<<<<<<<<<<<<
 *                     should_refresh = True
 *                     logger.debug("[STEALTH] Cache expired (%ss >= %ss) - refreshing from server", int(time_since_last_call), self._stealth_api_cache_interval)
*/
          goto __pyx_L11;
        }

        /* "ws_package/controllers/activity_controller.py":857
 *                     logger.debug("[STEALTH] Cache expired (%ss >= %ss) - refreshing from server", int(time_since_last_call), self._stealth_api_cache_interval)
 *                 else:
 *                     logger.debug("[STEALTH] Using cached stealth mode data (%ss < %ss)", int(time_since_last_call), self._stealth_api_cache_interval)             # <<<<<<<<<<<<<<
 * 
 *             response = None
*/
        /*else*/ {
          __pyx_t_7 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 857, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 857, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_10 = __Pyx_PyNumber_Int(__pyx_cur_scope->__pyx_v_time_since_last_call); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 857, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_stealth_api_cache_interval); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 857, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_6))) {
            __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
            assert(__pyx_t_7);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_7);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[4] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_STEALTH_Using_cached_stealth_mo, __pyx_t_10, __pyx_t_4};
            __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 857, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        }
        __pyx_L11:;
      }
      __pyx_L10:;

      /* "ws_package/controllers/activity_controller.py":859
 *                     logger.debug("[STEALTH] Using cached stealth mode data (%ss < %ss)", int(time_since_last_call), self._stealth_api_cache_interval)
 * 
 *             response = None             # <<<<<<<<<<<<<<
 *             api_call_made = False
 * 
*/
      __Pyx_INCREF(Py_None);
      __Pyx_GIVEREF(Py_None);
      __pyx_cur_scope->__pyx_v_response = Py_None;

      /* "ws_package/controllers/activity_controller.py":860
 * 
 *             response = None
 *             api_call_made = False             # <<<<<<<<<<<<<<
 * 
 *             if should_refresh:
*/
      __pyx_cur_scope->__pyx_v_api_call_made = 0;

      /* "ws_package/controllers/activity_controller.py":862
 *             api_call_made = False
 * 
 *             if should_refresh:             # <<<<<<<<<<<<<<
 *                 # Make API call
 *                 api_call_made = True
*/
      if (__pyx_cur_scope->__pyx_v_should_refresh) {

        /* "ws_package/controllers/activity_controller.py":864
 *             if should_refresh:
 *                 # Make API call
 *                 api_call_made = True             # <<<<<<<<<<<<<<
 *                 response = await self.fixed_mode.get_fixed_slots(user_entity)
 *                 # Update cache only on successful API call
*/
        __pyx_cur_scope->__pyx_v_api_call_made = 1;

        /* "ws_package/controllers/activity_controller.py":865
 *                 # Make API call
 *                 api_call_made = True
 *                 response = await self.fixed_mode.get_fixed_slots(user_entity)             # <<<<<<<<<<<<<<
 *                 # Update cache only on successful API call
 *                 if response is not None:
*/
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_fixed_mode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 865, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_6 = __pyx_t_4;
        __Pyx_INCREF(__pyx_t_6);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_cur_scope->__pyx_v_user_entity};
          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_fixed_slots, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 865, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (likely(__pyx_t_11 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_1);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
          __Pyx_XGIVEREF(__pyx_t_2);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
          __Pyx_XGIVEREF(__pyx_t_3);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 1;
          return __pyx_r;
          __pyx_L13_resume_from_await:;
          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_1);
          __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_2);
          __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_3);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 865, __pyx_L4_error)
          __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
        } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __pyx_t_5 = __pyx_r; __pyx_r = NULL;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 865, __pyx_L4_error)
        }
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_response);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_response, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":867
 *                 response = await self.fixed_mode.get_fixed_slots(user_entity)
 *                 # Update cache only on successful API call
 *                 if response is not None:             # <<<<<<<<<<<<<<
 *                     self._last_stealth_api_call = current_time
 *                     self._cached_stealth_response = response
*/
        __pyx_t_9 = (__pyx_cur_scope->__pyx_v_response != Py_None);
        if (__pyx_t_9) {

          /* "ws_package/controllers/activity_controller.py":868
 *                 # Update cache only on successful API call
 *                 if response is not None:
 *                     self._last_stealth_api_call = current_time             # <<<<<<<<<<<<<<
 *                     self._cached_stealth_response = response
 *                     logger.debug("[STEALTH] API call successful, cached response")
*/
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_stealth_api_call, __pyx_cur_scope->__pyx_v_current_time) < (0)) __PYX_ERR(0, 868, __pyx_L4_error)

          /* "ws_package/controllers/activity_controller.py":869
 *                 if response is not None:
 *                     self._last_stealth_api_call = current_time
 *                     self._cached_stealth_response = response             # <<<<<<<<<<<<<<
 *                     logger.debug("[STEALTH] API call successful, cached response")
 *                 else:
*/
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_cached_stealth_response, __pyx_cur_scope->__pyx_v_response) < (0)) __PYX_ERR(0, 869, __pyx_L4_error)

          /* "ws_package/controllers/activity_controller.py":870
 *                     self._last_stealth_api_call = current_time
 *                     self._cached_stealth_response = response
 *                     logger.debug("[STEALTH] API call successful, cached response")             # <<<<<<<<<<<<<<
 *                 else:
 *                     # API call failed - fall through to database fallback
*/
          __pyx_t_4 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 870, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 870, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_10))) {
            __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10);
            assert(__pyx_t_4);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_STEALTH_API_call_successful_cac};
            __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 870, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":867
 *                 response = await self.fixed_mode.get_fixed_slots(user_entity)
 *                 # Update cache only on successful API call
 *                 if response is not None:             # <<<<<<<<<<<<<<
 *                     self._last_stealth_api_call = current_time
 *                     self._cached_stealth_response = response
*/
          goto __pyx_L14;
        }

        /* "ws_package/controllers/activity_controller.py":873
 *                 else:
 *                     # API call failed - fall through to database fallback
 *                     logger.warning("[STEALTH] API call failed, will try database fallback")             # <<<<<<<<<<<<<<
 *             else:
 *                 # Use cached response
*/
        /*else*/ {
          __pyx_t_10 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 873, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 873, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_6))) {
            __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6);
            assert(__pyx_t_10);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_STEALTH_API_call_failed_will_tr};
            __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 873, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        }
        __pyx_L14:;

        /* "ws_package/controllers/activity_controller.py":862
 *             api_call_made = False
 * 
 *             if should_refresh:             # <<<<<<<<<<<<<<
 *                 # Make API call
 *                 api_call_made = True
*/
        goto __pyx_L12;
      }

      /* "ws_package/controllers/activity_controller.py":876
 *             else:
 *                 # Use cached response
 *                 response = self._cached_stealth_response             # <<<<<<<<<<<<<<
 *                 if response is not None:
 *                     logger.debug("[STEALTH] Using cached stealth mode response")
*/
      /*else*/ {
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_cached_stealth_response); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 876, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_response);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_response, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":877
 *                 # Use cached response
 *                 response = self._cached_stealth_response
 *                 if response is not None:             # <<<<<<<<<<<<<<
 *                     logger.debug("[STEALTH] Using cached stealth mode response")
 *                 else:
*/
        __pyx_t_9 = (__pyx_cur_scope->__pyx_v_response != Py_None);
        if (__pyx_t_9) {

          /* "ws_package/controllers/activity_controller.py":878
 *                 response = self._cached_stealth_response
 *                 if response is not None:
 *                     logger.debug("[STEALTH] Using cached stealth mode response")             # <<<<<<<<<<<<<<
 *                 else:
 *                     # No cached response available - this shouldn't happen, but try database
*/
          __pyx_t_6 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 878, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 878, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_4))) {
            __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
            assert(__pyx_t_6);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_6);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_STEALTH_Using_cached_stealth_mo_2};
            __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 878, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":877
 *                 # Use cached response
 *                 response = self._cached_stealth_response
 *                 if response is not None:             # <<<<<<<<<<<<<<
 *                     logger.debug("[STEALTH] Using cached stealth mode response")
 *                 else:
*/
          goto __pyx_L15;
        }

        /* "ws_package/controllers/activity_controller.py":881
 *                 else:
 *                     # No cached response available - this shouldn't happen, but try database
 *                     logger.debug("[STEALTH] No cached response available, trying database")             # <<<<<<<<<<<<<<
 *                     api_call_made = True  # Treat as if we tried API and it failed
 * 
*/
        /*else*/ {
          __pyx_t_4 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 881, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 881, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_10))) {
            __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10);
            assert(__pyx_t_4);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_STEALTH_No_cached_response_avai};
            __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 881, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":882
 *                     # No cached response available - this shouldn't happen, but try database
 *                     logger.debug("[STEALTH] No cached response available, trying database")
 *                     api_call_made = True  # Treat as if we tried API and it failed             # <<<<<<<<<<<<<<
 * 
 *             if response:
*/
          __pyx_cur_scope->__pyx_v_api_call_made = 1;
        }
        __pyx_L15:;
      }
      __pyx_L12:;

      /* "ws_package/controllers/activity_controller.py":884
 *                     api_call_made = True  # Treat as if we tried API and it failed
 * 
 *             if response:             # <<<<<<<<<<<<<<
 *                 # Fixed-mode schedule from stealth API  same path for silent and visible builds.
 *                 # Only create/upload intervals inside start_timeend_time on no_of_days.
*/
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_response); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 884, __pyx_L4_error)
      if (__pyx_t_9) {

        /* "ws_package/controllers/activity_controller.py":887
 *                 # Fixed-mode schedule from stealth API  same path for silent and visible builds.
 *                 # Only create/upload intervals inside start_timeend_time on no_of_days.
 *                 s_limit_start, s_limit_end = self._parse_fixed_mode_window(response)             # <<<<<<<<<<<<<<
 * 
 *                 self.limit_start = datetime.datetime.strptime(s_limit_start, "%H:%M:%S").time()
*/
        __pyx_t_10 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_10);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_cur_scope->__pyx_v_response};
          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_parse_fixed_mode_window, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 887, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) {
          PyObject* sequence = __pyx_t_5;
          Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
          if (unlikely(size != 2)) {
            if (size > 2) __Pyx_RaiseTooManyValuesError(2);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            __PYX_ERR(0, 887, __pyx_L4_error)
          }
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_10 = PyTuple_GET_ITEM(sequence, 0);
            __Pyx_INCREF(__pyx_t_10);
            __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1);
            __Pyx_INCREF(__pyx_t_4);
          } else {
            __pyx_t_10 = __Pyx_PyList_GET_ITEM_REF(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
            if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 887, __pyx_L4_error)
            __Pyx_XGOTREF(__pyx_t_10);
            __pyx_t_4 = __Pyx_PyList_GET_ITEM_REF(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
            if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 887, __pyx_L4_error)
            __Pyx_XGOTREF(__pyx_t_4);
          }
          #else
          __pyx_t_10 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 887, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_4 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 887, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        } else {
          Py_ssize_t index = -1;
          __pyx_t_6 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 887, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_12 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_6);
          index = 0; __pyx_t_10 = __pyx_t_12(__pyx_t_6); if (unlikely(!__pyx_t_10)) goto __pyx_L17_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_10);
          index = 1; __pyx_t_4 = __pyx_t_12(__pyx_t_6); if (unlikely(!__pyx_t_4)) goto __pyx_L17_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_4);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_6), 2) < (0)) __PYX_ERR(0, 887, __pyx_L4_error)
          __pyx_t_12 = NULL;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          goto __pyx_L18_unpacking_done;
          __pyx_L17_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_12 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          __PYX_ERR(0, 887, __pyx_L4_error)
          __pyx_L18_unpacking_done:;
        }
        __Pyx_GIVEREF(__pyx_t_10);
        __pyx_cur_scope->__pyx_v_s_limit_start = __pyx_t_10;
        __pyx_t_10 = 0;
        __Pyx_GIVEREF(__pyx_t_4);
        __pyx_cur_scope->__pyx_v_s_limit_end = __pyx_t_4;
        __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":889
 *                 s_limit_start, s_limit_end = self._parse_fixed_mode_window(response)
 * 
 *                 self.limit_start = datetime.datetime.strptime(s_limit_start, "%H:%M:%S").time()             # <<<<<<<<<<<<<<
 *                 self.limit_end = datetime.datetime.strptime(s_limit_end, "%H:%M:%S").time()
 *                 self.no_of_days = response.get('no_of_days')
*/
        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 889, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 889, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_6 = __pyx_t_13;
        __Pyx_INCREF(__pyx_t_6);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_cur_scope->__pyx_v_s_limit_start, __pyx_mstate_global->__pyx_kp_u_H_M_S};
          __pyx_t_10 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strptime, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 889, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_10);
        }
        __pyx_t_4 = __pyx_t_10;
        __Pyx_INCREF(__pyx_t_4);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_time, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 889, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_start, __pyx_t_5) < (0)) __PYX_ERR(0, 889, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":890
 * 
 *                 self.limit_start = datetime.datetime.strptime(s_limit_start, "%H:%M:%S").time()
 *                 self.limit_end = datetime.datetime.strptime(s_limit_end, "%H:%M:%S").time()             # <<<<<<<<<<<<<<
 *                 self.no_of_days = response.get('no_of_days')
 *                 self.mode = response.get('mode')
*/
        __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 890, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 890, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_13 = __pyx_t_7;
        __Pyx_INCREF(__pyx_t_13);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_13, __pyx_cur_scope->__pyx_v_s_limit_end, __pyx_mstate_global->__pyx_kp_u_H_M_S};
          __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strptime, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 890, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __pyx_t_10 = __pyx_t_4;
        __Pyx_INCREF(__pyx_t_10);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_10, NULL};
          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_time, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 890, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_end, __pyx_t_5) < (0)) __PYX_ERR(0, 890, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":891
 *                 self.limit_start = datetime.datetime.strptime(s_limit_start, "%H:%M:%S").time()
 *                 self.limit_end = datetime.datetime.strptime(s_limit_end, "%H:%M:%S").time()
 *                 self.no_of_days = response.get('no_of_days')             # <<<<<<<<<<<<<<
 *                 self.mode = response.get('mode')
 *                 self.tracking_scenario = response.get('tracking_scenario')
*/
        __pyx_t_4 = __pyx_cur_scope->__pyx_v_response;
        __Pyx_INCREF(__pyx_t_4);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_n_u_no_of_days};
          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 891, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_no_of_days, __pyx_t_5) < (0)) __PYX_ERR(0, 891, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":892
 *                 self.limit_end = datetime.datetime.strptime(s_limit_end, "%H:%M:%S").time()
 *                 self.no_of_days = response.get('no_of_days')
 *                 self.mode = response.get('mode')             # <<<<<<<<<<<<<<
 *                 self.tracking_scenario = response.get('tracking_scenario')
 * 
*/
        __pyx_t_4 = __pyx_cur_scope->__pyx_v_response;
        __Pyx_INCREF(__pyx_t_4);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_n_u_mode};
          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 892, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_mode, __pyx_t_5) < (0)) __PYX_ERR(0, 892, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":893
 *                 self.no_of_days = response.get('no_of_days')
 *                 self.mode = response.get('mode')
 *                 self.tracking_scenario = response.get('tracking_scenario')             # <<<<<<<<<<<<<<
 * 
 *                 logger.info(
*/
        __pyx_t_4 = __pyx_cur_scope->__pyx_v_response;
        __Pyx_INCREF(__pyx_t_4);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_n_u_tracking_scenario};
          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 893, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_tracking_scenario, __pyx_t_5) < (0)) __PYX_ERR(0, 893, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":895
 *                 self.tracking_scenario = response.get('tracking_scenario')
 * 
 *                 logger.info(             # <<<<<<<<<<<<<<
 *                     "updated tracking scenerio (fixed mode) %s %s %s mode=%s",
 *                     self.limit_start,
*/
        __pyx_t_4 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 895, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 895, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

        /* "ws_package/controllers/activity_controller.py":897
 *                 logger.info(
 *                     "updated tracking scenerio (fixed mode) %s %s %s mode=%s",
 *                     self.limit_start,             # <<<<<<<<<<<<<<
 *                     self.limit_end,
 *                     self.no_of_days,
*/
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_start); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 897, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);

        /* "ws_package/controllers/activity_controller.py":898
 *                     "updated tracking scenerio (fixed mode) %s %s %s mode=%s",
 *                     self.limit_start,
 *                     self.limit_end,             # <<<<<<<<<<<<<<
 *                     self.no_of_days,
 *                     self.mode,
*/
        __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_end); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 898, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_13);

        /* "ws_package/controllers/activity_controller.py":899
 *                     self.limit_start,
 *                     self.limit_end,
 *                     self.no_of_days,             # <<<<<<<<<<<<<<
 *                     self.mode,
 *                 )
*/
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_no_of_days); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 899, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);

        /* "ws_package/controllers/activity_controller.py":900
 *                     self.limit_end,
 *                     self.no_of_days,
 *                     self.mode,             # <<<<<<<<<<<<<<
 *                 )
 * 
*/
        __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_mode); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 900, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7);
          assert(__pyx_t_4);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[6] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_updated_tracking_scenerio_fixed, __pyx_t_10, __pyx_t_13, __pyx_t_6, __pyx_t_14};
          __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (6-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 895, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":903
 *                 )
 * 
 *                 self.screenshot_controller.limit_start = self.limit_start             # <<<<<<<<<<<<<<
 *                 self.screenshot_controller.limit_end = self.limit_end
 *                 self.screenshot_controller.no_of_days = self.no_of_days
*/
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_start); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 903, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 903, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        if (__Pyx_PyObject_SetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_limit_start, __pyx_t_5) < (0)) __PYX_ERR(0, 903, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "ws_package/controllers/activity_controller.py":904
 * 
 *                 self.screenshot_controller.limit_start = self.limit_start
 *                 self.screenshot_controller.limit_end = self.limit_end             # <<<<<<<<<<<<<<
 *                 self.screenshot_controller.no_of_days = self.no_of_days
 * 
*/
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_end); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 904, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 904, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        if (__Pyx_PyObject_SetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_limit_end, __pyx_t_7) < (0)) __PYX_ERR(0, 904, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":905
 *                 self.screenshot_controller.limit_start = self.limit_start
 *                 self.screenshot_controller.limit_end = self.limit_end
 *                 self.screenshot_controller.no_of_days = self.no_of_days             # <<<<<<<<<<<<<<
 * 
 *                 logger.info("updated Screenshot Controller %s %s %s", self.limit_start, self.limit_end, self.no_of_days)
*/
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_no_of_days); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 905, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 905, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        if (__Pyx_PyObject_SetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_no_of_days, __pyx_t_5) < (0)) __PYX_ERR(0, 905, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "ws_package/controllers/activity_controller.py":907
 *                 self.screenshot_controller.no_of_days = self.no_of_days
 * 
 *                 logger.info("updated Screenshot Controller %s %s %s", self.limit_start, self.limit_end, self.no_of_days)             # <<<<<<<<<<<<<<
 * 
 *                 await self.fixed_mode.save_fixed_mode(ModeEntity(limit_start=s_limit_start, limit_end=s_limit_end, day_list=self.no_of_days, mode=self.mode, tracking=self.tracking_scenario))
*/
        __pyx_t_5 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 907, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 907, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_start); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 907, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_end); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 907, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_no_of_days); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 907, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
          assert(__pyx_t_5);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[5] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_updated_Screenshot_Controller_s, __pyx_t_14, __pyx_t_13, __pyx_t_10};
          __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 907, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "ws_package/controllers/activity_controller.py":909
 *                 logger.info("updated Screenshot Controller %s %s %s", self.limit_start, self.limit_end, self.no_of_days)
 * 
 *                 await self.fixed_mode.save_fixed_mode(ModeEntity(limit_start=s_limit_start, limit_end=s_limit_end, day_list=self.no_of_days, mode=self.mode, tracking=self.tracking_scenario))             # <<<<<<<<<<<<<<
 *             elif api_call_made:
 *                 # Only try database if we actually made an API call and it failed
*/
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_fixed_mode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 909, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_6 = __pyx_t_10;
        __Pyx_INCREF(__pyx_t_6);
        __pyx_t_14 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_ModeEntity); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 909, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_no_of_days); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 909, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_mode); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 909, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_tracking_scenario); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 909, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_16);
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_5);
          assert(__pyx_t_14);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_14);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 5 : 0)] = {__pyx_t_14, NULL};
          __pyx_t_17 = __Pyx_MakeVectorcallBuilderKwds(5); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 909, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_17);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_limit_start, __pyx_cur_scope->__pyx_v_s_limit_start, __pyx_t_17, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 909, __pyx_L4_error)
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_limit_end, __pyx_cur_scope->__pyx_v_s_limit_end, __pyx_t_17, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 909, __pyx_L4_error)
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_day_list, __pyx_t_4, __pyx_t_17, __pyx_callargs+1, 2) < (0)) __PYX_ERR(0, 909, __pyx_L4_error)
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_mode, __pyx_t_15, __pyx_t_17, __pyx_callargs+1, 3) < (0)) __PYX_ERR(0, 909, __pyx_L4_error)
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_tracking, __pyx_t_16, __pyx_t_17, __pyx_callargs+1, 4) < (0)) __PYX_ERR(0, 909, __pyx_L4_error)
          __pyx_t_13 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_17);
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 909, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_13);
        }
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_13};
          __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_save_fixed_mode, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 909, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7, &__pyx_r);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (likely(__pyx_t_11 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_1);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
          __Pyx_XGIVEREF(__pyx_t_2);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
          __Pyx_XGIVEREF(__pyx_t_3);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 2;
          return __pyx_r;
          __pyx_L19_resume_from_await:;
          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_1);
          __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_2);
          __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_3);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 909, __pyx_L4_error)
        } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_DECREF(__pyx_r); __pyx_r = 0;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 909, __pyx_L4_error)
        }

        /* "ws_package/controllers/activity_controller.py":884
 *                     api_call_made = True  # Treat as if we tried API and it failed
 * 
 *             if response:             # <<<<<<<<<<<<<<
 *                 # Fixed-mode schedule from stealth API  same path for silent and visible builds.
 *                 # Only create/upload intervals inside start_timeend_time on no_of_days.
*/
        goto __pyx_L16;
      }

      /* "ws_package/controllers/activity_controller.py":910
 * 
 *                 await self.fixed_mode.save_fixed_mode(ModeEntity(limit_start=s_limit_start, limit_end=s_limit_end, day_list=self.no_of_days, mode=self.mode, tracking=self.tracking_scenario))
 *             elif api_call_made:             # <<<<<<<<<<<<<<
 *                 # Only try database if we actually made an API call and it failed
 *                 # Don't try database if we're just using cached data
*/
      if (__pyx_cur_scope->__pyx_v_api_call_made) {

        /* "ws_package/controllers/activity_controller.py":913
 *                 # Only try database if we actually made an API call and it failed
 *                 # Don't try database if we're just using cached data
 *                 mode_entity = await self.fixed_mode.getting_old_data()             # <<<<<<<<<<<<<<
 *                 logger.warning("Failed to fetch start time from API Response, retrieving from Database")
 *                 if mode_entity:
*/
        __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_fixed_mode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 913, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_10 = __pyx_t_13;
        __Pyx_INCREF(__pyx_t_10);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_10, NULL};
          __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_getting_old_data, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 913, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7, &__pyx_r);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (likely(__pyx_t_11 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_1);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
          __Pyx_XGIVEREF(__pyx_t_2);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
          __Pyx_XGIVEREF(__pyx_t_3);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 3;
          return __pyx_r;
          __pyx_L20_resume_from_await:;
          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_1);
          __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_2);
          __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_3);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 913, __pyx_L4_error)
          __pyx_t_7 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_7);
        } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __pyx_t_7 = __pyx_r; __pyx_r = NULL;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 913, __pyx_L4_error)
        }
        __Pyx_GIVEREF(__pyx_t_7);
        __pyx_cur_scope->__pyx_v_mode_entity = __pyx_t_7;
        __pyx_t_7 = 0;

        /* "ws_package/controllers/activity_controller.py":914
 *                 # Don't try database if we're just using cached data
 *                 mode_entity = await self.fixed_mode.getting_old_data()
 *                 logger.warning("Failed to fetch start time from API Response, retrieving from Database")             # <<<<<<<<<<<<<<
 *                 if mode_entity:
 *                     self.limit_start = datetime.datetime.strptime(mode_entity.limit_start, "%H:%M:%S").time()
*/
        __pyx_t_13 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 914, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 914, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_6);
          assert(__pyx_t_13);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Failed_to_fetch_start_time_from};
          __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 914, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "ws_package/controllers/activity_controller.py":915
 *                 mode_entity = await self.fixed_mode.getting_old_data()
 *                 logger.warning("Failed to fetch start time from API Response, retrieving from Database")
 *                 if mode_entity:             # <<<<<<<<<<<<<<
 *                     self.limit_start = datetime.datetime.strptime(mode_entity.limit_start, "%H:%M:%S").time()
 *                     self.limit_end = datetime.datetime.strptime(mode_entity.limit_end, "%H:%M:%S").time()
*/
        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_mode_entity); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 915, __pyx_L4_error)
        if (__pyx_t_9) {

          /* "ws_package/controllers/activity_controller.py":916
 *                 logger.warning("Failed to fetch start time from API Response, retrieving from Database")
 *                 if mode_entity:
 *                     self.limit_start = datetime.datetime.strptime(mode_entity.limit_start, "%H:%M:%S").time()             # <<<<<<<<<<<<<<
 *                     self.limit_end = datetime.datetime.strptime(mode_entity.limit_end, "%H:%M:%S").time()
 *                     self.no_of_days = mode_entity.day_list
*/
          __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 916, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 916, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_17);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_10 = __pyx_t_17;
          __Pyx_INCREF(__pyx_t_10);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_mode_entity, __pyx_mstate_global->__pyx_n_u_limit_start); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 916, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_8 = 0;
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_10, __pyx_t_5, __pyx_mstate_global->__pyx_kp_u_H_M_S};
            __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strptime, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 916, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_13);
          }
          __pyx_t_6 = __pyx_t_13;
          __Pyx_INCREF(__pyx_t_6);
          __pyx_t_8 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
            __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_time, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 916, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_7);
          }
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_start, __pyx_t_7) < (0)) __PYX_ERR(0, 916, __pyx_L4_error)
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "ws_package/controllers/activity_controller.py":917
 *                 if mode_entity:
 *                     self.limit_start = datetime.datetime.strptime(mode_entity.limit_start, "%H:%M:%S").time()
 *                     self.limit_end = datetime.datetime.strptime(mode_entity.limit_end, "%H:%M:%S").time()             # <<<<<<<<<<<<<<
 *                     self.no_of_days = mode_entity.day_list
 *                     self.mode = mode_entity.mode
*/
          __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 917, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 917, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_17 = __pyx_t_10;
          __Pyx_INCREF(__pyx_t_17);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_mode_entity, __pyx_mstate_global->__pyx_n_u_limit_end); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 917, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_8 = 0;
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_17, __pyx_t_5, __pyx_mstate_global->__pyx_kp_u_H_M_S};
            __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strptime, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 917, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_6);
          }
          __pyx_t_13 = __pyx_t_6;
          __Pyx_INCREF(__pyx_t_13);
          __pyx_t_8 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_13, NULL};
            __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_time, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 917, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_7);
          }
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_end, __pyx_t_7) < (0)) __PYX_ERR(0, 917, __pyx_L4_error)
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "ws_package/controllers/activity_controller.py":918
 *                     self.limit_start = datetime.datetime.strptime(mode_entity.limit_start, "%H:%M:%S").time()
 *                     self.limit_end = datetime.datetime.strptime(mode_entity.limit_end, "%H:%M:%S").time()
 *                     self.no_of_days = mode_entity.day_list             # <<<<<<<<<<<<<<
 *                     self.mode = mode_entity.mode
 *                     self.tracking_scenario = mode_entity.tracking
*/
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_mode_entity, __pyx_mstate_global->__pyx_n_u_day_list); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 918, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_no_of_days, __pyx_t_7) < (0)) __PYX_ERR(0, 918, __pyx_L4_error)
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "ws_package/controllers/activity_controller.py":919
 *                     self.limit_end = datetime.datetime.strptime(mode_entity.limit_end, "%H:%M:%S").time()
 *                     self.no_of_days = mode_entity.day_list
 *                     self.mode = mode_entity.mode             # <<<<<<<<<<<<<<
 *                     self.tracking_scenario = mode_entity.tracking
 *                     logger.info("updated tracking scenerio from database%s %s %s", self.limit_start, self.limit_end, self.no_of_days)
*/
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_mode_entity, __pyx_mstate_global->__pyx_n_u_mode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 919, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_mode, __pyx_t_7) < (0)) __PYX_ERR(0, 919, __pyx_L4_error)
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "ws_package/controllers/activity_controller.py":920
 *                     self.no_of_days = mode_entity.day_list
 *                     self.mode = mode_entity.mode
 *                     self.tracking_scenario = mode_entity.tracking             # <<<<<<<<<<<<<<
 *                     logger.info("updated tracking scenerio from database%s %s %s", self.limit_start, self.limit_end, self.no_of_days)
 *                     self.screenshot_controller.limit_start = self.limit_start
*/
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_mode_entity, __pyx_mstate_global->__pyx_n_u_tracking); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 920, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_tracking_scenario, __pyx_t_7) < (0)) __PYX_ERR(0, 920, __pyx_L4_error)
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "ws_package/controllers/activity_controller.py":921
 *                     self.mode = mode_entity.mode
 *                     self.tracking_scenario = mode_entity.tracking
 *                     logger.info("updated tracking scenerio from database%s %s %s", self.limit_start, self.limit_end, self.no_of_days)             # <<<<<<<<<<<<<<
 *                     self.screenshot_controller.limit_start = self.limit_start
 *                     self.screenshot_controller.limit_end = self.limit_end
*/
          __pyx_t_6 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 921, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 921, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_start); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 921, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_end); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 921, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_no_of_days); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 921, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_10))) {
            __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_10);
            assert(__pyx_t_6);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
            __Pyx_INCREF(__pyx_t_6);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[5] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_updated_tracking_scenerio_from_d, __pyx_t_13, __pyx_t_5, __pyx_t_17};
            __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 921, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_7);
          }
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "ws_package/controllers/activity_controller.py":922
 *                     self.tracking_scenario = mode_entity.tracking
 *                     logger.info("updated tracking scenerio from database%s %s %s", self.limit_start, self.limit_end, self.no_of_days)
 *                     self.screenshot_controller.limit_start = self.limit_start             # <<<<<<<<<<<<<<
 *                     self.screenshot_controller.limit_end = self.limit_end
 *                     self.screenshot_controller.no_of_days = self.no_of_days
*/
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_start); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 922, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 922, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_10);
          if (__Pyx_PyObject_SetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_limit_start, __pyx_t_7) < (0)) __PYX_ERR(0, 922, __pyx_L4_error)
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

          /* "ws_package/controllers/activity_controller.py":923
 *                     logger.info("updated tracking scenerio from database%s %s %s", self.limit_start, self.limit_end, self.no_of_days)
 *                     self.screenshot_controller.limit_start = self.limit_start
 *                     self.screenshot_controller.limit_end = self.limit_end             # <<<<<<<<<<<<<<
 *                     self.screenshot_controller.no_of_days = self.no_of_days
 *                 else:
*/
          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_end); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 923, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 923, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
          if (__Pyx_PyObject_SetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_limit_end, __pyx_t_10) < (0)) __PYX_ERR(0, 923, __pyx_L4_error)
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "ws_package/controllers/activity_controller.py":924
 *                     self.screenshot_controller.limit_start = self.limit_start
 *                     self.screenshot_controller.limit_end = self.limit_end
 *                     self.screenshot_controller.no_of_days = self.no_of_days             # <<<<<<<<<<<<<<
 *                 else:
 *                     logger.info("No tracking scenerio found")
*/
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_no_of_days); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 924, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 924, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_10);
          if (__Pyx_PyObject_SetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_no_of_days, __pyx_t_7) < (0)) __PYX_ERR(0, 924, __pyx_L4_error)
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

          /* "ws_package/controllers/activity_controller.py":915
 *                 mode_entity = await self.fixed_mode.getting_old_data()
 *                 logger.warning("Failed to fetch start time from API Response, retrieving from Database")
 *                 if mode_entity:             # <<<<<<<<<<<<<<
 *                     self.limit_start = datetime.datetime.strptime(mode_entity.limit_start, "%H:%M:%S").time()
 *                     self.limit_end = datetime.datetime.strptime(mode_entity.limit_end, "%H:%M:%S").time()
*/
          goto __pyx_L21;
        }

        /* "ws_package/controllers/activity_controller.py":926
 *                     self.screenshot_controller.no_of_days = self.no_of_days
 *                 else:
 *                     logger.info("No tracking scenerio found")             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             mode_entity = await self.fixed_mode.getting_old_data()
*/
        /*else*/ {
          __pyx_t_7 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 926, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 926, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_5))) {
            __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
            assert(__pyx_t_7);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_7);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_No_tracking_scenerio_found};
            __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 926, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_10);
          }
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }
        __pyx_L21:;

        /* "ws_package/controllers/activity_controller.py":910
 * 
 *                 await self.fixed_mode.save_fixed_mode(ModeEntity(limit_start=s_limit_start, limit_end=s_limit_end, day_list=self.no_of_days, mode=self.mode, tracking=self.tracking_scenario))
 *             elif api_call_made:             # <<<<<<<<<<<<<<
 *                 # Only try database if we actually made an API call and it failed
 *                 # Don't try database if we're just using cached data
*/
      }
      __pyx_L16:;

      /* "ws_package/controllers/activity_controller.py":841
 *         Uses caching to prevent excessive API calls - only refreshes every 5 minutes.
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # Check if we should refresh from API (cache expired or first call)
 *             should_refresh = False
*/
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L9_try_end;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "ws_package/controllers/activity_controller.py":927
 *                 else:
 *                     logger.info("No tracking scenerio found")
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             mode_entity = await self.fixed_mode.getting_old_data()
 *             logger.warning("Failed to fetch start time from API, retrieving from Database")
*/
    __pyx_t_18 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_18) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.update_tracking_duration", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_10, &__pyx_t_5, &__pyx_t_7) < 0) __PYX_ERR(0, 927, __pyx_L6_except_error)
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_cur_scope->__pyx_v_e = __pyx_t_5;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":928
 *                     logger.info("No tracking scenerio found")
 *         except Exception as e:
 *             mode_entity = await self.fixed_mode.getting_old_data()             # <<<<<<<<<<<<<<
 *             logger.warning("Failed to fetch start time from API, retrieving from Database")
 * 
*/
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_fixed_mode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 928, __pyx_L27_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_13 = __pyx_t_6;
        __Pyx_INCREF(__pyx_t_13);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_13, NULL};
          __pyx_t_17 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_getting_old_data, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 928, __pyx_L27_error)
          __Pyx_GOTREF(__pyx_t_17);
        }
        __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_17, &__pyx_r);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        if (likely(__pyx_t_11 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_1);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
          __Pyx_XGIVEREF(__pyx_t_2);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
          __Pyx_XGIVEREF(__pyx_t_3);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
          __Pyx_XGIVEREF(__pyx_t_5);
          __pyx_cur_scope->__pyx_t_3 = __pyx_t_5;
          __Pyx_XGIVEREF(__pyx_t_7);
          __pyx_cur_scope->__pyx_t_4 = __pyx_t_7;
          __Pyx_XGIVEREF(__pyx_t_10);
          __pyx_cur_scope->__pyx_t_5 = __pyx_t_10;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_SwapException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 4;
          return __pyx_r;
          __pyx_L29_resume_from_await:;
          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_1);
          __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_2);
          __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_3);
          __pyx_t_5 = __pyx_cur_scope->__pyx_t_3;
          __pyx_cur_scope->__pyx_t_3 = 0;
          __Pyx_XGOTREF(__pyx_t_5);
          __pyx_t_7 = __pyx_cur_scope->__pyx_t_4;
          __pyx_cur_scope->__pyx_t_4 = 0;
          __Pyx_XGOTREF(__pyx_t_7);
          __pyx_t_10 = __pyx_cur_scope->__pyx_t_5;
          __pyx_cur_scope->__pyx_t_5 = 0;
          __Pyx_XGOTREF(__pyx_t_10);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 928, __pyx_L27_error)
          __pyx_t_17 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_17);
        } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __pyx_t_17 = __pyx_r; __pyx_r = NULL;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 928, __pyx_L27_error)
        }
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_mode_entity);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_mode_entity, __pyx_t_17);
        __Pyx_GIVEREF(__pyx_t_17);
        __pyx_t_17 = 0;

        /* "ws_package/controllers/activity_controller.py":929
 *         except Exception as e:
 *             mode_entity = await self.fixed_mode.getting_old_data()
 *             logger.warning("Failed to fetch start time from API, retrieving from Database")             # <<<<<<<<<<<<<<
 * 
 *             if mode_entity:
*/
        __pyx_t_6 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 929, __pyx_L27_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 929, __pyx_L27_error)
        __Pyx_GOTREF(__pyx_t_16);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_16))) {
          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_16);
          assert(__pyx_t_6);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_16);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_16, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Failed_to_fetch_start_time_from_2};
          __pyx_t_17 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_16, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 929, __pyx_L27_error)
          __Pyx_GOTREF(__pyx_t_17);
        }
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

        /* "ws_package/controllers/activity_controller.py":931
 *             logger.warning("Failed to fetch start time from API, retrieving from Database")
 * 
 *             if mode_entity:             # <<<<<<<<<<<<<<
 *                 self.limit_start = datetime.datetime.strptime(mode_entity.limit_start, "%H:%M:%S").time()
 *                 self.limit_end = datetime.datetime.strptime(mode_entity.limit_end, "%H:%M:%S").time()
*/
        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_mode_entity); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 931, __pyx_L27_error)
        if (__pyx_t_9) {

          /* "ws_package/controllers/activity_controller.py":932
 * 
 *             if mode_entity:
 *                 self.limit_start = datetime.datetime.strptime(mode_entity.limit_start, "%H:%M:%S").time()             # <<<<<<<<<<<<<<
 *                 self.limit_end = datetime.datetime.strptime(mode_entity.limit_end, "%H:%M:%S").time()
 *                 self.no_of_days = mode_entity.day_list
*/
          __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 932, __pyx_L27_error)
          __Pyx_GOTREF(__pyx_t_15);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 932, __pyx_L27_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __pyx_t_13 = __pyx_t_4;
          __Pyx_INCREF(__pyx_t_13);
          __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_mode_entity, __pyx_mstate_global->__pyx_n_u_limit_start); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 932, __pyx_L27_error)
          __Pyx_GOTREF(__pyx_t_15);
          __pyx_t_8 = 0;
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_13, __pyx_t_15, __pyx_mstate_global->__pyx_kp_u_H_M_S};
            __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strptime, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 932, __pyx_L27_error)
            __Pyx_GOTREF(__pyx_t_6);
          }
          __pyx_t_16 = __pyx_t_6;
          __Pyx_INCREF(__pyx_t_16);
          __pyx_t_8 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_16, NULL};
            __pyx_t_17 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_time, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 932, __pyx_L27_error)
            __Pyx_GOTREF(__pyx_t_17);
          }
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_start, __pyx_t_17) < (0)) __PYX_ERR(0, 932, __pyx_L27_error)
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

          /* "ws_package/controllers/activity_controller.py":933
 *             if mode_entity:
 *                 self.limit_start = datetime.datetime.strptime(mode_entity.limit_start, "%H:%M:%S").time()
 *                 self.limit_end = datetime.datetime.strptime(mode_entity.limit_end, "%H:%M:%S").time()             # <<<<<<<<<<<<<<
 *                 self.no_of_days = mode_entity.day_list
 *                 self.mode = mode_entity.mode
*/
          __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 933, __pyx_L27_error)
          __Pyx_GOTREF(__pyx_t_15);
          __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 933, __pyx_L27_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __pyx_t_4 = __pyx_t_13;
          __Pyx_INCREF(__pyx_t_4);
          __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_mode_entity, __pyx_mstate_global->__pyx_n_u_limit_end); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 933, __pyx_L27_error)
          __Pyx_GOTREF(__pyx_t_15);
          __pyx_t_8 = 0;
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_t_15, __pyx_mstate_global->__pyx_kp_u_H_M_S};
            __pyx_t_16 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strptime, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 933, __pyx_L27_error)
            __Pyx_GOTREF(__pyx_t_16);
          }
          __pyx_t_6 = __pyx_t_16;
          __Pyx_INCREF(__pyx_t_6);
          __pyx_t_8 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
            __pyx_t_17 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_time, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
            if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 933, __pyx_L27_error)
            __Pyx_GOTREF(__pyx_t_17);
          }
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_end, __pyx_t_17) < (0)) __PYX_ERR(0, 933, __pyx_L27_error)
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

          /* "ws_package/controllers/activity_controller.py":934
 *                 self.limit_start = datetime.datetime.strptime(mode_entity.limit_start, "%H:%M:%S").time()
 *                 self.limit_end = datetime.datetime.strptime(mode_entity.limit_end, "%H:%M:%S").time()
 *                 self.no_of_days = mode_entity.day_list             # <<<<<<<<<<<<<<
 *                 self.mode = mode_entity.mode
 *                 self.tracking_scenario = mode_entity.tracking
*/
          __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_mode_entity, __pyx_mstate_global->__pyx_n_u_day_list); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 934, __pyx_L27_error)
          __Pyx_GOTREF(__pyx_t_17);
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_no_of_days, __pyx_t_17) < (0)) __PYX_ERR(0, 934, __pyx_L27_error)
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

          /* "ws_package/controllers/activity_controller.py":935
 *                 self.limit_end = datetime.datetime.strptime(mode_entity.limit_end, "%H:%M:%S").time()
 *                 self.no_of_days = mode_entity.day_list
 *                 self.mode = mode_entity.mode             # <<<<<<<<<<<<<<
 *                 self.tracking_scenario = mode_entity.tracking
 *                 logger.info("updated tracking scenerio from database%s %s %s", self.limit_start, self.limit_end, self.no_of_days)
*/
          __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_mode_entity, __pyx_mstate_global->__pyx_n_u_mode); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 935, __pyx_L27_error)
          __Pyx_GOTREF(__pyx_t_17);
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_mode, __pyx_t_17) < (0)) __PYX_ERR(0, 935, __pyx_L27_error)
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

          /* "ws_package/controllers/activity_controller.py":936
 *                 self.no_of_days = mode_entity.day_list
 *                 self.mode = mode_entity.mode
 *                 self.tracking_scenario = mode_entity.tracking             # <<<<<<<<<<<<<<
 *                 logger.info("updated tracking scenerio from database%s %s %s", self.limit_start, self.limit_end, self.no_of_days)
 *             else:
*/
          __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_mode_entity, __pyx_mstate_global->__pyx_n_u_tracking); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 936, __pyx_L27_error)
          __Pyx_GOTREF(__pyx_t_17);
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_tracking_scenario, __pyx_t_17) < (0)) __PYX_ERR(0, 936, __pyx_L27_error)
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

          /* "ws_package/controllers/activity_controller.py":937
 *                 self.mode = mode_entity.mode
 *                 self.tracking_scenario = mode_entity.tracking
 *                 logger.info("updated tracking scenerio from database%s %s %s", self.limit_start, self.limit_end, self.no_of_days)             # <<<<<<<<<<<<<<
 *             else:
 *                 logger.info("No tracking scenerio found")
*/
          __pyx_t_16 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 937, __pyx_L27_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 937, __pyx_L27_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_start); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 937, __pyx_L27_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_end); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 937, __pyx_L27_error)
          __Pyx_GOTREF(__pyx_t_15);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_no_of_days); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 937, __pyx_L27_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_13))) {
            __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_13);
            assert(__pyx_t_16);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
            __Pyx_INCREF(__pyx_t_16);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[5] = {__pyx_t_16, __pyx_mstate_global->__pyx_kp_u_updated_tracking_scenerio_from_d, __pyx_t_6, __pyx_t_15, __pyx_t_4};
            __pyx_t_17 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 937, __pyx_L27_error)
            __Pyx_GOTREF(__pyx_t_17);
          }
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

          /* "ws_package/controllers/activity_controller.py":931
 *             logger.warning("Failed to fetch start time from API, retrieving from Database")
 * 
 *             if mode_entity:             # <<<<<<<<<<<<<<
 *                 self.limit_start = datetime.datetime.strptime(mode_entity.limit_start, "%H:%M:%S").time()
 *                 self.limit_end = datetime.datetime.strptime(mode_entity.limit_end, "%H:%M:%S").time()
*/
          goto __pyx_L30;
        }

        /* "ws_package/controllers/activity_controller.py":939
 *                 logger.info("updated tracking scenerio from database%s %s %s", self.limit_start, self.limit_end, self.no_of_days)
 *             else:
 *                 logger.info("No tracking scenerio found")             # <<<<<<<<<<<<<<
 * 
 *     async def midnight(self, user_entity: UserEntity, last_count):
*/
        /*else*/ {
          __pyx_t_13 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 939, __pyx_L27_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 939, __pyx_L27_error)
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_15))) {
            __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_15);
            assert(__pyx_t_13);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_No_tracking_scenerio_found};
            __pyx_t_17 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 939, __pyx_L27_error)
            __Pyx_GOTREF(__pyx_t_17);
          }
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        }
        __pyx_L30:;
      }

      /* "ws_package/controllers/activity_controller.py":927
 *                 else:
 *                     logger.info("No tracking scenerio found")
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             mode_entity = await self.fixed_mode.getting_old_data()
 *             logger.warning("Failed to fetch start time from API, retrieving from Database")
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          goto __pyx_L28;
        }
        __pyx_L27_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_24, &__pyx_t_25, &__pyx_t_26);
          if ( unlikely(__Pyx_GetException(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23) < 0)) __Pyx_ErrFetch(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_23);
          __Pyx_XGOTREF(__pyx_t_24);
          __Pyx_XGOTREF(__pyx_t_25);
          __Pyx_XGOTREF(__pyx_t_26);
          __pyx_t_18 = __pyx_lineno; __pyx_t_19 = __pyx_clineno; __pyx_t_20 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_24);
          __Pyx_XGIVEREF(__pyx_t_25);
          __Pyx_XGIVEREF(__pyx_t_26);
          __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_25, __pyx_t_26);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_ErrRestore(__pyx_t_21, __pyx_t_22, __pyx_t_23);
          __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0;
          __pyx_lineno = __pyx_t_18; __pyx_clineno = __pyx_t_19; __pyx_filename = __pyx_t_20;
          goto __pyx_L6_except_error;
        }
        __pyx_L28:;
      }
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L5_exception_handled;
    }
    goto __pyx_L6_except_error;

    /* "ws_package/controllers/activity_controller.py":841
 *         Uses caching to prevent excessive API calls - only refreshes every 5 minutes.
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # Check if we should refresh from API (cache expired or first call)
 *             should_refresh = False
*/
    __pyx_L6_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L5_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    __pyx_L9_try_end:;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":836
 *         return s_limit_start, s_limit_end
 * 
 *     async def update_tracking_duration(self, user_entity:UserEntity):             # <<<<<<<<<<<<<<
 *         """
 *         Update tracking duration from stealth mode API.
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("update_tracking_duration", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_48generator6(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":941
 *                 logger.info("No tracking scenerio found")
 * 
 *     async def midnight(self, user_entity: UserEntity, last_count):             # <<<<<<<<<<<<<<
 *         # Use centralized read lock for database read operations
 *         # Database operation timeout constant
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_47midnight(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_47midnight = {"midnight", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_47midnight, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_47midnight(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_user_entity = 0;
  PyObject *__pyx_v_last_count = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("midnight (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_user_entity,&__pyx_mstate_global->__pyx_n_u_last_count,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 941, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 941, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 941, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 941, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "midnight", 0) < (0)) __PYX_ERR(0, 941, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 3; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("midnight", 1, 3, 3, i); __PYX_ERR(0, 941, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 3)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 941, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 941, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 941, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_user_entity = values[1];
    __pyx_v_last_count = values[2];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("midnight", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 941, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.midnight", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_46midnight(__pyx_self, __pyx_v_self, __pyx_v_user_entity, __pyx_v_last_count);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_46midnight(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity, PyObject *__pyx_v_last_count) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("midnight", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 941, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_user_entity = __pyx_v_user_entity;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_user_entity);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_user_entity);
  __pyx_cur_scope->__pyx_v_last_count = __pyx_v_last_count;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_last_count);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_last_count);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_48generator6, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[6]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_midnight, __pyx_mstate_global->__pyx_n_u_ActivityController_midnight, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 941, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.midnight", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_48generator6(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_PySendResult __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  int __pyx_t_24;
  int __pyx_t_25;
  int __pyx_t_26;
  char const *__pyx_t_27;
  PyObject *__pyx_t_28 = NULL;
  PyObject *__pyx_t_29 = NULL;
  PyObject *__pyx_t_30 = NULL;
  PyObject *__pyx_t_31 = NULL;
  PyObject *__pyx_t_32 = NULL;
  PyObject *__pyx_t_33 = NULL;
  int __pyx_t_34;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("midnight", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L15_resume_from_await;
    case 2: goto __pyx_L31_resume_from_await;
    case 3: goto __pyx_L49_resume_from_await;
    case 4: goto __pyx_L50_resume_from_await;
    case 5: goto __pyx_L57_resume_from_await;
    case 6: goto __pyx_L58_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 941, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":944
 *         # Use centralized read lock for database read operations
 *         # Database operation timeout constant
 *         DB_OPERATION_TIMEOUT = 5.0             # <<<<<<<<<<<<<<
 * 
 *         with db_lock_manager.read_lock():
*/
  __pyx_cur_scope->__pyx_v_DB_OPERATION_TIMEOUT = 5.0;

  /* "ws_package/controllers/activity_controller.py":946
 *         DB_OPERATION_TIMEOUT = 5.0
 * 
 *         with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *             async with async_session() as session:
 *                 query = select(ActivityInterval).where(ActivityInterval.counter == last_count+1).order_by(ActivityInterval.start_time.desc()).limit(1)
*/
  /*with:*/ {
    __pyx_t_2 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 946, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 946, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      assert(__pyx_t_2);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
      __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 946, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __pyx_t_6 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 946, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = NULL;
    __pyx_t_3 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 946, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (likely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
      assert(__pyx_t_2);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
      __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 946, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    /*try:*/ {
      {
        __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
        __Pyx_XGOTREF(__pyx_t_7);
        __Pyx_XGOTREF(__pyx_t_8);
        __Pyx_XGOTREF(__pyx_t_9);
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":947
 * 
 *         with db_lock_manager.read_lock():
 *             async with async_session() as session:             # <<<<<<<<<<<<<<
 *                 query = select(ActivityInterval).where(ActivityInterval.counter == last_count+1).order_by(ActivityInterval.start_time.desc()).limit(1)
 *                 try:
*/
          /*with:*/ {
            __pyx_t_4 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 947, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_5 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_3))) {
              __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
              assert(__pyx_t_4);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
              __Pyx_INCREF(__pyx_t_4);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
              __pyx_t_5 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
              __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 947, __pyx_L8_error)
              __Pyx_GOTREF(__pyx_t_1);
            }
            __pyx_t_10 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 947, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_4 = NULL;
            __pyx_t_2 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 947, __pyx_L14_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_5 = 1;
            #if CYTHON_UNPACK_METHODS
            if (likely(PyMethod_Check(__pyx_t_2))) {
              __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
              assert(__pyx_t_4);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_4);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
              __pyx_t_5 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
              __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 947, __pyx_L14_error)
              __Pyx_GOTREF(__pyx_t_3);
            }
            __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_3, &__pyx_r);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            if (likely(__pyx_t_11 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_1);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
              __Pyx_XGIVEREF(__pyx_t_6);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
              __Pyx_XGIVEREF(__pyx_t_7);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
              __Pyx_XGIVEREF(__pyx_t_8);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_8;
              __Pyx_XGIVEREF(__pyx_t_9);
              __pyx_cur_scope->__pyx_t_4 = __pyx_t_9;
              __Pyx_XGIVEREF(__pyx_t_10);
              __pyx_cur_scope->__pyx_t_5 = __pyx_t_10;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 1;
              return __pyx_r;
              __pyx_L15_resume_from_await:;
              __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_1);
              __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_6);
              __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_7);
              __pyx_t_8 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_8);
              __pyx_t_9 = __pyx_cur_scope->__pyx_t_4;
              __pyx_cur_scope->__pyx_t_4 = 0;
              __Pyx_XGOTREF(__pyx_t_9);
              __pyx_t_10 = __pyx_cur_scope->__pyx_t_5;
              __pyx_cur_scope->__pyx_t_5 = 0;
              __Pyx_XGOTREF(__pyx_t_10);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 947, __pyx_L14_error)
              __pyx_t_3 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_3);
            } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __pyx_t_3 = __pyx_r; __pyx_r = NULL;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 947, __pyx_L14_error)
            }
            __pyx_t_2 = __pyx_t_3;
            __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            /*try:*/ {
              {
                __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
                __Pyx_XGOTREF(__pyx_t_12);
                __Pyx_XGOTREF(__pyx_t_13);
                __Pyx_XGOTREF(__pyx_t_14);
                /*try:*/ {
                  __Pyx_GIVEREF(__pyx_t_2);
                  __pyx_cur_scope->__pyx_v_session = __pyx_t_2;
                  __pyx_t_2 = 0;

                  /* "ws_package/controllers/activity_controller.py":948
 *         with db_lock_manager.read_lock():
 *             async with async_session() as session:
 *                 query = select(ActivityInterval).where(ActivityInterval.counter == last_count+1).order_by(ActivityInterval.start_time.desc()).limit(1)             # <<<<<<<<<<<<<<
 *                 try:
 *                     result = await asyncio.wait_for(
*/
                  __pyx_t_18 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 948, __pyx_L19_error)
                  __Pyx_GOTREF(__pyx_t_19);
                  __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 948, __pyx_L19_error)
                  __Pyx_GOTREF(__pyx_t_20);
                  __pyx_t_5 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_19))) {
                    __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_19);
                    assert(__pyx_t_18);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_19);
                    __Pyx_INCREF(__pyx_t_18);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_19, __pyx__function);
                    __pyx_t_5 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_18, __pyx_t_20};
                    __pyx_t_17 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_19, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                    if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 948, __pyx_L19_error)
                    __Pyx_GOTREF(__pyx_t_17);
                  }
                  __pyx_t_16 = __pyx_t_17;
                  __Pyx_INCREF(__pyx_t_16);
                  __Pyx_GetModuleGlobalName(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 948, __pyx_L19_error)
                  __Pyx_GOTREF(__pyx_t_19);
                  __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 948, __pyx_L19_error)
                  __Pyx_GOTREF(__pyx_t_20);
                  __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                  __pyx_t_19 = __Pyx_PyLong_AddObjC(__pyx_cur_scope->__pyx_v_last_count, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 948, __pyx_L19_error)
                  __Pyx_GOTREF(__pyx_t_19);
                  __pyx_t_18 = PyObject_RichCompare(__pyx_t_20, __pyx_t_19, Py_EQ); __Pyx_XGOTREF(__pyx_t_18); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 948, __pyx_L19_error)
                  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                  __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                  __pyx_t_5 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_16, __pyx_t_18};
                    __pyx_t_15 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                    if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 948, __pyx_L19_error)
                    __Pyx_GOTREF(__pyx_t_15);
                  }
                  __pyx_t_4 = __pyx_t_15;
                  __Pyx_INCREF(__pyx_t_4);
                  __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 948, __pyx_L19_error)
                  __Pyx_GOTREF(__pyx_t_16);
                  __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 948, __pyx_L19_error)
                  __Pyx_GOTREF(__pyx_t_19);
                  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                  __pyx_t_18 = __pyx_t_19;
                  __Pyx_INCREF(__pyx_t_18);
                  __pyx_t_5 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_18, NULL};
                    __pyx_t_17 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_desc, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                    if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 948, __pyx_L19_error)
                    __Pyx_GOTREF(__pyx_t_17);
                  }
                  __pyx_t_5 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_17};
                    __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_order_by, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 948, __pyx_L19_error)
                    __Pyx_GOTREF(__pyx_t_3);
                  }
                  __pyx_t_1 = __pyx_t_3;
                  __Pyx_INCREF(__pyx_t_1);
                  __pyx_t_5 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_int_1};
                    __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_limit, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 948, __pyx_L19_error)
                    __Pyx_GOTREF(__pyx_t_2);
                  }
                  __Pyx_GIVEREF(__pyx_t_2);
                  __pyx_cur_scope->__pyx_v_query = __pyx_t_2;
                  __pyx_t_2 = 0;

                  /* "ws_package/controllers/activity_controller.py":949
 *             async with async_session() as session:
 *                 query = select(ActivityInterval).where(ActivityInterval.counter == last_count+1).order_by(ActivityInterval.start_time.desc()).limit(1)
 *                 try:             # <<<<<<<<<<<<<<
 *                     result = await asyncio.wait_for(
 *                         session.scalars(query),
*/
                  {
                    __Pyx_ExceptionSave(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
                    __Pyx_XGOTREF(__pyx_t_21);
                    __Pyx_XGOTREF(__pyx_t_22);
                    __Pyx_XGOTREF(__pyx_t_23);
                    /*try:*/ {

                      /* "ws_package/controllers/activity_controller.py":950
 *                 query = select(ActivityInterval).where(ActivityInterval.counter == last_count+1).order_by(ActivityInterval.start_time.desc()).limit(1)
 *                 try:
 *                     result = await asyncio.wait_for(             # <<<<<<<<<<<<<<
 *                         session.scalars(query),
 *                         timeout=DB_OPERATION_TIMEOUT
*/
                      __pyx_t_3 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 950, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_1);
                      __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_wait_for); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 950, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_15);
                      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

                      /* "ws_package/controllers/activity_controller.py":951
 *                 try:
 *                     result = await asyncio.wait_for(
 *                         session.scalars(query),             # <<<<<<<<<<<<<<
 *                         timeout=DB_OPERATION_TIMEOUT
 *                     )
*/
                      __pyx_t_17 = __pyx_cur_scope->__pyx_v_session;
                      __Pyx_INCREF(__pyx_t_17);
                      __pyx_t_5 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_17, __pyx_cur_scope->__pyx_v_query};
                        __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalars, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 951, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_1);
                      }

                      /* "ws_package/controllers/activity_controller.py":952
 *                     result = await asyncio.wait_for(
 *                         session.scalars(query),
 *                         timeout=DB_OPERATION_TIMEOUT             # <<<<<<<<<<<<<<
 *                     )
 *                     last_entry = result.first()  # Fetch the first (most recent) entry
*/
                      __pyx_t_17 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_DB_OPERATION_TIMEOUT); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 952, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_17);
                      __pyx_t_5 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_15))) {
                        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_15);
                        assert(__pyx_t_3);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                        __Pyx_INCREF(__pyx_t_3);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                        __pyx_t_5 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_3, __pyx_t_1};
                        __pyx_t_4 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 950, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_4);
                        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_timeout, __pyx_t_17, __pyx_t_4, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 950, __pyx_L25_error)
                        __pyx_t_2 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_4);
                        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 950, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_2);
                      }
                      __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_2, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                      if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_6);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
                        __Pyx_XGIVEREF(__pyx_t_7);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
                        __Pyx_XGIVEREF(__pyx_t_8);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
                        __Pyx_XGIVEREF(__pyx_t_9);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_21;
                        __Pyx_XGIVEREF(__pyx_t_22);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_22;
                        __Pyx_XGIVEREF(__pyx_t_23);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_23;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 2;
                        return __pyx_r;
                        __pyx_L31_resume_from_await:;
                        __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_6);
                        __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_7);
                        __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_8);
                        __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_9);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_21 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_21);
                        __pyx_t_22 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_22);
                        __pyx_t_23 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_23);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 950, __pyx_L25_error)
                        __pyx_t_2 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_2);
                      } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_2 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 950, __pyx_L25_error)
                      }
                      __Pyx_GIVEREF(__pyx_t_2);
                      __pyx_cur_scope->__pyx_v_result = __pyx_t_2;
                      __pyx_t_2 = 0;

                      /* "ws_package/controllers/activity_controller.py":954
 *                         timeout=DB_OPERATION_TIMEOUT
 *                     )
 *                     last_entry = result.first()  # Fetch the first (most recent) entry             # <<<<<<<<<<<<<<
 *                     if last_entry:
 *                         last_entry = last_entry.start_time
*/
                      __pyx_t_15 = __pyx_cur_scope->__pyx_v_result;
                      __Pyx_INCREF(__pyx_t_15);
                      __pyx_t_5 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL};
                        __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_first, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 954, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_2);
                      }
                      __Pyx_GIVEREF(__pyx_t_2);
                      __pyx_cur_scope->__pyx_v_last_entry = __pyx_t_2;
                      __pyx_t_2 = 0;

                      /* "ws_package/controllers/activity_controller.py":955
 *                     )
 *                     last_entry = result.first()  # Fetch the first (most recent) entry
 *                     if last_entry:             # <<<<<<<<<<<<<<
 *                         last_entry = last_entry.start_time
 *                     else:
*/
                      __pyx_t_24 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_entry); if (unlikely((__pyx_t_24 < 0))) __PYX_ERR(0, 955, __pyx_L25_error)
                      if (__pyx_t_24) {

                        /* "ws_package/controllers/activity_controller.py":956
 *                     last_entry = result.first()  # Fetch the first (most recent) entry
 *                     if last_entry:
 *                         last_entry = last_entry.start_time             # <<<<<<<<<<<<<<
 *                     else:
 *                         last_entry = None
*/
                        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_entry, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 956, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_2);
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_last_entry);
                        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_last_entry, __pyx_t_2);
                        __Pyx_GIVEREF(__pyx_t_2);
                        __pyx_t_2 = 0;

                        /* "ws_package/controllers/activity_controller.py":955
 *                     )
 *                     last_entry = result.first()  # Fetch the first (most recent) entry
 *                     if last_entry:             # <<<<<<<<<<<<<<
 *                         last_entry = last_entry.start_time
 *                     else:
*/
                        goto __pyx_L32;
                      }

                      /* "ws_package/controllers/activity_controller.py":958
 *                         last_entry = last_entry.start_time
 *                     else:
 *                         last_entry = None             # <<<<<<<<<<<<<<
 *                 except asyncio.TimeoutError:
 *                     logger.error("Database query timed out after %ss in midnight", DB_OPERATION_TIMEOUT)
*/
                      /*else*/ {
                        __Pyx_INCREF(Py_None);
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_last_entry);
                        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_last_entry, Py_None);
                        __Pyx_GIVEREF(Py_None);
                      }
                      __pyx_L32:;

                      /* "ws_package/controllers/activity_controller.py":949
 *             async with async_session() as session:
 *                 query = select(ActivityInterval).where(ActivityInterval.counter == last_count+1).order_by(ActivityInterval.start_time.desc()).limit(1)
 *                 try:             # <<<<<<<<<<<<<<
 *                     result = await asyncio.wait_for(
 *                         session.scalars(query),
*/
                    }
                    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                    goto __pyx_L30_try_end;
                    __pyx_L25_error:;
                    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

                    /* "ws_package/controllers/activity_controller.py":959
 *                     else:
 *                         last_entry = None
 *                 except asyncio.TimeoutError:             # <<<<<<<<<<<<<<
 *                     logger.error("Database query timed out after %ss in midnight", DB_OPERATION_TIMEOUT)
 *                     last_entry = None
*/
                    __Pyx_ErrFetch(&__pyx_t_2, &__pyx_t_15, &__pyx_t_4);
                    __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 959, __pyx_L27_except_error)
                    __Pyx_GOTREF(__pyx_t_17);
                    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_TimeoutError); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 959, __pyx_L27_except_error)
                    __Pyx_GOTREF(__pyx_t_1);
                    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                    __pyx_t_25 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_2, __pyx_t_1);
                    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_ErrRestore(__pyx_t_2, __pyx_t_15, __pyx_t_4);
                    __pyx_t_2 = 0; __pyx_t_15 = 0; __pyx_t_4 = 0;
                    if (__pyx_t_25) {
                      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.midnight", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_15, &__pyx_t_2) < 0) __PYX_ERR(0, 959, __pyx_L27_except_error)
                      __Pyx_XGOTREF(__pyx_t_4);
                      __Pyx_XGOTREF(__pyx_t_15);
                      __Pyx_XGOTREF(__pyx_t_2);

                      /* "ws_package/controllers/activity_controller.py":960
 *                         last_entry = None
 *                 except asyncio.TimeoutError:
 *                     logger.error("Database query timed out after %ss in midnight", DB_OPERATION_TIMEOUT)             # <<<<<<<<<<<<<<
 *                     last_entry = None
 *                 except Exception as e:
*/
                      __pyx_t_17 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 960, __pyx_L27_except_error)
                      __Pyx_GOTREF(__pyx_t_3);
                      __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 960, __pyx_L27_except_error)
                      __Pyx_GOTREF(__pyx_t_19);
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                      __pyx_t_3 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_DB_OPERATION_TIMEOUT); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 960, __pyx_L27_except_error)
                      __Pyx_GOTREF(__pyx_t_3);
                      __pyx_t_5 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_19))) {
                        __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_19);
                        assert(__pyx_t_17);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_19);
                        __Pyx_INCREF(__pyx_t_17);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_19, __pyx__function);
                        __pyx_t_5 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[3] = {__pyx_t_17, __pyx_mstate_global->__pyx_kp_u_Database_query_timed_out_after_s, __pyx_t_3};
                        __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_19, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 960, __pyx_L27_except_error)
                        __Pyx_GOTREF(__pyx_t_1);
                      }
                      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

                      /* "ws_package/controllers/activity_controller.py":961
 *                 except asyncio.TimeoutError:
 *                     logger.error("Database query timed out after %ss in midnight", DB_OPERATION_TIMEOUT)
 *                     last_entry = None             # <<<<<<<<<<<<<<
 *                 except Exception as e:
 *                     logger.exception("Error getting last interval: %s", e)
*/
                      __Pyx_INCREF(Py_None);
                      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_last_entry);
                      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_last_entry, Py_None);
                      __Pyx_GIVEREF(Py_None);
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                      goto __pyx_L26_exception_handled;
                    }

                    /* "ws_package/controllers/activity_controller.py":962
 *                     logger.error("Database query timed out after %ss in midnight", DB_OPERATION_TIMEOUT)
 *                     last_entry = None
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.exception("Error getting last interval: %s", e)
 *                     last_entry = None
*/
                    __pyx_t_25 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                    if (__pyx_t_25) {
                      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.midnight", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_15, &__pyx_t_4) < 0) __PYX_ERR(0, 962, __pyx_L27_except_error)
                      __Pyx_XGOTREF(__pyx_t_2);
                      __Pyx_XGOTREF(__pyx_t_15);
                      __Pyx_XGOTREF(__pyx_t_4);
                      __Pyx_INCREF(__pyx_t_15);
                      __Pyx_GIVEREF(__pyx_t_15);
                      __pyx_cur_scope->__pyx_v_e = __pyx_t_15;
                      /*try:*/ {

                        /* "ws_package/controllers/activity_controller.py":963
 *                     last_entry = None
 *                 except Exception as e:
 *                     logger.exception("Error getting last interval: %s", e)             # <<<<<<<<<<<<<<
 *                     last_entry = None
 * 
*/
                        __pyx_t_19 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 963, __pyx_L40_error)
                        __Pyx_GOTREF(__pyx_t_3);
                        __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_exception); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 963, __pyx_L40_error)
                        __Pyx_GOTREF(__pyx_t_17);
                        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                        __pyx_t_5 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_17))) {
                          __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_17);
                          assert(__pyx_t_19);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
                          __Pyx_INCREF(__pyx_t_19);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
                          __pyx_t_5 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[3] = {__pyx_t_19, __pyx_mstate_global->__pyx_kp_u_Error_getting_last_interval_s, __pyx_cur_scope->__pyx_v_e};
                          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 963, __pyx_L40_error)
                          __Pyx_GOTREF(__pyx_t_1);
                        }
                        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

                        /* "ws_package/controllers/activity_controller.py":964
 *                 except Exception as e:
 *                     logger.exception("Error getting last interval: %s", e)
 *                     last_entry = None             # <<<<<<<<<<<<<<
 * 
 *         # Guard clause: return early if user_entity is None
*/
                        __Pyx_INCREF(Py_None);
                        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_last_entry);
                        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_last_entry, Py_None);
                        __Pyx_GIVEREF(Py_None);
                      }

                      /* "ws_package/controllers/activity_controller.py":962
 *                     logger.error("Database query timed out after %ss in midnight", DB_OPERATION_TIMEOUT)
 *                     last_entry = None
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.exception("Error getting last interval: %s", e)
 *                     last_entry = None
*/
                      /*finally:*/ {
                        /*normal exit:*/{
                          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                          goto __pyx_L41;
                        }
                        __pyx_L40_error:;
                        /*exception exit:*/{
                          __Pyx_PyThreadState_assign
                          __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0; __pyx_t_33 = 0;
                          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                          __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                          __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                           __Pyx_ExceptionSwap(&__pyx_t_31, &__pyx_t_32, &__pyx_t_33);
                          if ( unlikely(__Pyx_GetException(&__pyx_t_28, &__pyx_t_29, &__pyx_t_30) < 0)) __Pyx_ErrFetch(&__pyx_t_28, &__pyx_t_29, &__pyx_t_30);
                          __Pyx_XGOTREF(__pyx_t_28);
                          __Pyx_XGOTREF(__pyx_t_29);
                          __Pyx_XGOTREF(__pyx_t_30);
                          __Pyx_XGOTREF(__pyx_t_31);
                          __Pyx_XGOTREF(__pyx_t_32);
                          __Pyx_XGOTREF(__pyx_t_33);
                          __pyx_t_25 = __pyx_lineno; __pyx_t_26 = __pyx_clineno; __pyx_t_27 = __pyx_filename;
                          {
                            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                          }
                          __Pyx_XGIVEREF(__pyx_t_31);
                          __Pyx_XGIVEREF(__pyx_t_32);
                          __Pyx_XGIVEREF(__pyx_t_33);
                          __Pyx_ExceptionReset(__pyx_t_31, __pyx_t_32, __pyx_t_33);
                          __Pyx_XGIVEREF(__pyx_t_28);
                          __Pyx_XGIVEREF(__pyx_t_29);
                          __Pyx_XGIVEREF(__pyx_t_30);
                          __Pyx_ErrRestore(__pyx_t_28, __pyx_t_29, __pyx_t_30);
                          __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0; __pyx_t_33 = 0;
                          __pyx_lineno = __pyx_t_25; __pyx_clineno = __pyx_t_26; __pyx_filename = __pyx_t_27;
                          goto __pyx_L27_except_error;
                        }
                        __pyx_L41:;
                      }
                      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      goto __pyx_L26_exception_handled;
                    }
                    goto __pyx_L27_except_error;

                    /* "ws_package/controllers/activity_controller.py":949
 *             async with async_session() as session:
 *                 query = select(ActivityInterval).where(ActivityInterval.counter == last_count+1).order_by(ActivityInterval.start_time.desc()).limit(1)
 *                 try:             # <<<<<<<<<<<<<<
 *                     result = await asyncio.wait_for(
 *                         session.scalars(query),
*/
                    __pyx_L27_except_error:;
                    __Pyx_XGIVEREF(__pyx_t_21);
                    __Pyx_XGIVEREF(__pyx_t_22);
                    __Pyx_XGIVEREF(__pyx_t_23);
                    __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_23);
                    goto __pyx_L19_error;
                    __pyx_L26_exception_handled:;
                    __Pyx_XGIVEREF(__pyx_t_21);
                    __Pyx_XGIVEREF(__pyx_t_22);
                    __Pyx_XGIVEREF(__pyx_t_23);
                    __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_23);
                    __pyx_L30_try_end:;
                  }

                  /* "ws_package/controllers/activity_controller.py":947
 * 
 *         with db_lock_manager.read_lock():
 *             async with async_session() as session:             # <<<<<<<<<<<<<<
 *                 query = select(ActivityInterval).where(ActivityInterval.counter == last_count+1).order_by(ActivityInterval.start_time.desc()).limit(1)
 *                 try:
*/
                }
                __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                goto __pyx_L24_try_end;
                __pyx_L19_error:;
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                /*except:*/ {
                  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.midnight", __pyx_clineno, __pyx_lineno, __pyx_filename);
                  if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_15, &__pyx_t_2) < 0) __PYX_ERR(0, 947, __pyx_L21_except_error)
                  __Pyx_XGOTREF(__pyx_t_4);
                  __Pyx_XGOTREF(__pyx_t_15);
                  __Pyx_XGOTREF(__pyx_t_2);
                  __pyx_t_1 = PyTuple_Pack(3, __pyx_t_4, __pyx_t_15, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 947, __pyx_L21_except_error)
                  __Pyx_GOTREF(__pyx_t_1);
                  __pyx_t_23 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_1, NULL);
                  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                  if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 947, __pyx_L21_except_error)
                  __Pyx_GOTREF(__pyx_t_23);
                  __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_23, &__pyx_r);
                  __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                  if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_XGIVEREF(__pyx_t_2);
                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
                    __Pyx_XGIVEREF(__pyx_t_4);
                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
                    __Pyx_XGIVEREF(__pyx_t_6);
                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_6;
                    __Pyx_XGIVEREF(__pyx_t_7);
                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_7;
                    __Pyx_XGIVEREF(__pyx_t_8);
                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_8;
                    __Pyx_XGIVEREF(__pyx_t_9);
                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_9;
                    __Pyx_XGIVEREF(__pyx_t_10);
                    __pyx_cur_scope->__pyx_t_6 = __pyx_t_10;
                    __Pyx_XGIVEREF(__pyx_t_12);
                    __pyx_cur_scope->__pyx_t_7 = __pyx_t_12;
                    __Pyx_XGIVEREF(__pyx_t_13);
                    __pyx_cur_scope->__pyx_t_8 = __pyx_t_13;
                    __Pyx_XGIVEREF(__pyx_t_14);
                    __pyx_cur_scope->__pyx_t_9 = __pyx_t_14;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __pyx_cur_scope->__pyx_t_10 = __pyx_t_15;
                    __Pyx_XGIVEREF(__pyx_t_23);
                    __pyx_cur_scope->__pyx_t_11 = __pyx_t_23;
                    __Pyx_XGIVEREF(__pyx_r);
                    __Pyx_RefNannyFinishContext();
                    __Pyx_Coroutine_SwapException(__pyx_generator);
                    /* return from generator, awaiting value */
                    __pyx_generator->resume_label = 3;
                    return __pyx_r;
                    __pyx_L49_resume_from_await:;
                    __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
                    __pyx_cur_scope->__pyx_t_0 = 0;
                    __Pyx_XGOTREF(__pyx_t_2);
                    __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
                    __pyx_cur_scope->__pyx_t_1 = 0;
                    __Pyx_XGOTREF(__pyx_t_4);
                    __pyx_t_6 = __pyx_cur_scope->__pyx_t_2;
                    __pyx_cur_scope->__pyx_t_2 = 0;
                    __Pyx_XGOTREF(__pyx_t_6);
                    __pyx_t_7 = __pyx_cur_scope->__pyx_t_3;
                    __pyx_cur_scope->__pyx_t_3 = 0;
                    __Pyx_XGOTREF(__pyx_t_7);
                    __pyx_t_8 = __pyx_cur_scope->__pyx_t_4;
                    __pyx_cur_scope->__pyx_t_4 = 0;
                    __Pyx_XGOTREF(__pyx_t_8);
                    __pyx_t_9 = __pyx_cur_scope->__pyx_t_5;
                    __pyx_cur_scope->__pyx_t_5 = 0;
                    __Pyx_XGOTREF(__pyx_t_9);
                    __pyx_t_10 = __pyx_cur_scope->__pyx_t_6;
                    __pyx_cur_scope->__pyx_t_6 = 0;
                    __Pyx_XGOTREF(__pyx_t_10);
                    __pyx_t_12 = __pyx_cur_scope->__pyx_t_7;
                    __pyx_cur_scope->__pyx_t_7 = 0;
                    __Pyx_XGOTREF(__pyx_t_12);
                    __pyx_t_13 = __pyx_cur_scope->__pyx_t_8;
                    __pyx_cur_scope->__pyx_t_8 = 0;
                    __Pyx_XGOTREF(__pyx_t_13);
                    __pyx_t_14 = __pyx_cur_scope->__pyx_t_9;
                    __pyx_cur_scope->__pyx_t_9 = 0;
                    __Pyx_XGOTREF(__pyx_t_14);
                    __pyx_t_15 = __pyx_cur_scope->__pyx_t_10;
                    __pyx_cur_scope->__pyx_t_10 = 0;
                    __Pyx_XGOTREF(__pyx_t_15);
                    __pyx_t_23 = __pyx_cur_scope->__pyx_t_11;
                    __pyx_cur_scope->__pyx_t_11 = 0;
                    __Pyx_XGOTREF(__pyx_t_23);
                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 947, __pyx_L21_except_error)
                    __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
                  } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                    __Pyx_GOTREF(__pyx_r);
                    __pyx_t_1 = __pyx_r; __pyx_r = NULL;
                  } else {
                    __Pyx_XGOTREF(__pyx_r);
                    __PYX_ERR(0, 947, __pyx_L21_except_error)
                  }
                  __pyx_t_23 = __pyx_t_1;
                  __pyx_t_1 = 0;
                  __pyx_t_24 = __Pyx_PyObject_IsTrue(__pyx_t_23);
                  __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                  if (__pyx_t_24 < (0)) __PYX_ERR(0, 947, __pyx_L21_except_error)
                  __pyx_t_34 = (!__pyx_t_24);
                  if (unlikely(__pyx_t_34)) {
                    __Pyx_GIVEREF(__pyx_t_4);
                    __Pyx_GIVEREF(__pyx_t_15);
                    __Pyx_XGIVEREF(__pyx_t_2);
                    __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_15, __pyx_t_2);
                    __pyx_t_4 = 0;  __pyx_t_15 = 0;  __pyx_t_2 = 0; 
                    __PYX_ERR(0, 947, __pyx_L21_except_error)
                  }
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                  goto __pyx_L20_exception_handled;
                }
                __pyx_L21_except_error:;
                __Pyx_XGIVEREF(__pyx_t_12);
                __Pyx_XGIVEREF(__pyx_t_13);
                __Pyx_XGIVEREF(__pyx_t_14);
                __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
                goto __pyx_L8_error;
                __pyx_L20_exception_handled:;
                __Pyx_XGIVEREF(__pyx_t_12);
                __Pyx_XGIVEREF(__pyx_t_13);
                __Pyx_XGIVEREF(__pyx_t_14);
                __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
                __pyx_L24_try_end:;
              }
            }
            /*finally:*/ {
              /*normal exit:*/{
                if (__pyx_t_10) {
                  __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_mstate_global->__pyx_tuple[7], NULL);
                  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                  if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 947, __pyx_L8_error)
                  __Pyx_GOTREF(__pyx_t_14);
                  __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_14, &__pyx_r);
                  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                  if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_XGIVEREF(__pyx_t_6);
                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
                    __Pyx_XGIVEREF(__pyx_t_7);
                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
                    __Pyx_XGIVEREF(__pyx_t_8);
                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
                    __Pyx_XGIVEREF(__pyx_t_9);
                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
                    __Pyx_XGIVEREF(__pyx_t_10);
                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                    __Pyx_XGIVEREF(__pyx_t_14);
                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                    __Pyx_XGIVEREF(__pyx_r);
                    __Pyx_RefNannyFinishContext();
                    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                    /* return from generator, awaiting value */
                    __pyx_generator->resume_label = 4;
                    return __pyx_r;
                    __pyx_L50_resume_from_await:;
                    __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
                    __pyx_cur_scope->__pyx_t_0 = 0;
                    __Pyx_XGOTREF(__pyx_t_6);
                    __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
                    __pyx_cur_scope->__pyx_t_1 = 0;
                    __Pyx_XGOTREF(__pyx_t_7);
                    __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
                    __pyx_cur_scope->__pyx_t_2 = 0;
                    __Pyx_XGOTREF(__pyx_t_8);
                    __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
                    __pyx_cur_scope->__pyx_t_3 = 0;
                    __Pyx_XGOTREF(__pyx_t_9);
                    __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                    __pyx_cur_scope->__pyx_t_4 = 0;
                    __Pyx_XGOTREF(__pyx_t_10);
                    __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                    __pyx_cur_scope->__pyx_t_5 = 0;
                    __Pyx_XGOTREF(__pyx_t_14);
                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 947, __pyx_L8_error)
                    __pyx_t_2 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_2);
                  } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                    __Pyx_GOTREF(__pyx_r);
                    __pyx_t_2 = __pyx_r; __pyx_r = NULL;
                  } else {
                    __Pyx_XGOTREF(__pyx_r);
                    __PYX_ERR(0, 947, __pyx_L8_error)
                  }
                  __pyx_t_14 = __pyx_t_2;
                  __pyx_t_2 = 0;
                  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                }
                goto __pyx_L18;
              }
              __pyx_L18:;
            }
            goto __pyx_L51;
            __pyx_L14_error:;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            goto __pyx_L8_error;
            __pyx_L51:;
          }

          /* "ws_package/controllers/activity_controller.py":946
 *         DB_OPERATION_TIMEOUT = 5.0
 * 
 *         with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *             async with async_session() as session:
 *                 query = select(ActivityInterval).where(ActivityInterval.counter == last_count+1).order_by(ActivityInterval.start_time.desc()).limit(1)
*/
        }
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L13_try_end;
        __pyx_L8_error:;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
        __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        /*except:*/ {
          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.midnight", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_15, &__pyx_t_4) < 0) __PYX_ERR(0, 946, __pyx_L10_except_error)
          __Pyx_XGOTREF(__pyx_t_2);
          __Pyx_XGOTREF(__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_4);
          __pyx_t_1 = PyTuple_Pack(3, __pyx_t_2, __pyx_t_15, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 946, __pyx_L10_except_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_1, NULL);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 946, __pyx_L10_except_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_34 = __Pyx_PyObject_IsTrue(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (__pyx_t_34 < (0)) __PYX_ERR(0, 946, __pyx_L10_except_error)
          __pyx_t_24 = (!__pyx_t_34);
          if (unlikely(__pyx_t_24)) {
            __Pyx_GIVEREF(__pyx_t_2);
            __Pyx_GIVEREF(__pyx_t_15);
            __Pyx_XGIVEREF(__pyx_t_4);
            __Pyx_ErrRestoreWithState(__pyx_t_2, __pyx_t_15, __pyx_t_4);
            __pyx_t_2 = 0;  __pyx_t_15 = 0;  __pyx_t_4 = 0; 
            __PYX_ERR(0, 946, __pyx_L10_except_error)
          }
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          goto __pyx_L9_exception_handled;
        }
        __pyx_L10_except_error:;
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
        goto __pyx_L1_error;
        __pyx_L9_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
        __pyx_L13_try_end:;
      }
    }
    /*finally:*/ {
      /*normal exit:*/{
        if (__pyx_t_6) {
          __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_mstate_global->__pyx_tuple[7], NULL);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 946, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        }
        goto __pyx_L7;
      }
      __pyx_L7:;
    }
    goto __pyx_L55;
    __pyx_L4_error:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L1_error;
    __pyx_L55:;
  }

  /* "ws_package/controllers/activity_controller.py":967
 * 
 *         # Guard clause: return early if user_entity is None
 *         if user_entity is None:             # <<<<<<<<<<<<<<
 *             logger.warning("Cannot execute midnight operations: user_entity is None")
 *             return
*/
  __pyx_t_24 = (__pyx_cur_scope->__pyx_v_user_entity == Py_None);
  if (__pyx_t_24) {

    /* "ws_package/controllers/activity_controller.py":968
 *         # Guard clause: return early if user_entity is None
 *         if user_entity is None:
 *             logger.warning("Cannot execute midnight operations: user_entity is None")             # <<<<<<<<<<<<<<
 *             return
 * 
*/
    __pyx_t_15 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 968, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 968, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_1);
      assert(__pyx_t_15);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Cannot_execute_midnight_operatio};
      __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 968, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "ws_package/controllers/activity_controller.py":969
 *         if user_entity is None:
 *             logger.warning("Cannot execute midnight operations: user_entity is None")
 *             return             # <<<<<<<<<<<<<<
 * 
 *         # S3 bucket update removed from midnight - now handled on app startup and wake
*/
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":967
 * 
 *         # Guard clause: return early if user_entity is None
 *         if user_entity is None:             # <<<<<<<<<<<<<<
 *             logger.warning("Cannot execute midnight operations: user_entity is None")
 *             return
*/
  }

  /* "ws_package/controllers/activity_controller.py":973
 *         # S3 bucket update removed from midnight - now handled on app startup and wake
 *         # After releasing the lock, do the rest
 *         await self.update_interval(user_entity) # update Org settings in every interval             # <<<<<<<<<<<<<<
 *         await self.ensure_s3_credentials_fresh(user_entity)
 *         logger.debug("ORG check at every interval")
*/
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_cur_scope->__pyx_v_user_entity};
    __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_update_interval, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 973, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  }
  __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (likely(__pyx_t_11 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 5;
    return __pyx_r;
    __pyx_L57_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 973, __pyx_L1_error)
  } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 973, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":974
 *         # After releasing the lock, do the rest
 *         await self.update_interval(user_entity) # update Org settings in every interval
 *         await self.ensure_s3_credentials_fresh(user_entity)             # <<<<<<<<<<<<<<
 *         logger.debug("ORG check at every interval")
 * 
*/
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_cur_scope->__pyx_v_user_entity};
    __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_ensure_s3_credentials_fresh, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 974, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  }
  __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (likely(__pyx_t_11 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 6;
    return __pyx_r;
    __pyx_L58_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 974, __pyx_L1_error)
  } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 974, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":975
 *         await self.update_interval(user_entity) # update Org settings in every interval
 *         await self.ensure_s3_credentials_fresh(user_entity)
 *         logger.debug("ORG check at every interval")             # <<<<<<<<<<<<<<
 * 
 *     def decrypt(self, encrypted_key) -> str:
*/
  __pyx_t_1 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 975, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 975, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
    assert(__pyx_t_1);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_ORG_check_at_every_interval};
    __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 975, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":941
 *                 logger.info("No tracking scenerio found")
 * 
 *     async def midnight(self, user_entity: UserEntity, last_count):             # <<<<<<<<<<<<<<
 *         # Use centralized read lock for database read operations
 *         # Database operation timeout constant
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("midnight", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":977
 *         logger.debug("ORG check at every interval")
 * 
 *     def decrypt(self, encrypted_key) -> str:             # <<<<<<<<<<<<<<
 *         """Decrypt encrypted key with improved error handling."""
 *         if not encrypted_key or not isinstance(encrypted_key, str):
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_50decrypt(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_49decrypt, "Decrypt encrypted key with improved error handling.");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_50decrypt = {"decrypt", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_50decrypt, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_49decrypt};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_50decrypt(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  CYTHON_UNUSED PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_encrypted_key = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("decrypt (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_encrypted_key,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 977, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 977, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 977, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "decrypt", 0) < (0)) __PYX_ERR(0, 977, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("decrypt", 1, 2, 2, i); __PYX_ERR(0, 977, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 977, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 977, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_encrypted_key = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("decrypt", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 977, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.decrypt", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_49decrypt(__pyx_self, __pyx_v_self, __pyx_v_encrypted_key);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_49decrypt(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_encrypted_key) {
  PyObject *__pyx_v_position_of_dollar = NULL;
  PyObject *__pyx_v_new_string = NULL;
  PyObject *__pyx_v_decrypted_data = NULL;
  PyObject *__pyx_v_e = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  size_t __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_t_18;
  char const *__pyx_t_19;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  char const *__pyx_t_26;
  char const *__pyx_t_27;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("decrypt", 0);

  /* "ws_package/controllers/activity_controller.py":979
 *     def decrypt(self, encrypted_key) -> str:
 *         """Decrypt encrypted key with improved error handling."""
 *         if not encrypted_key or not isinstance(encrypted_key, str):             # <<<<<<<<<<<<<<
 *             raise ValidationError("Encrypted key must be a non-empty string", context={"encrypted_key": str(encrypted_key)[:50]})
 * 
*/
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_encrypted_key); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 979, __pyx_L1_error)
  __pyx_t_3 = (!__pyx_t_2);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = PyUnicode_Check(__pyx_v_encrypted_key); 
  __pyx_t_2 = (!__pyx_t_3);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (unlikely(__pyx_t_1)) {

    /* "ws_package/controllers/activity_controller.py":980
 *         """Decrypt encrypted key with improved error handling."""
 *         if not encrypted_key or not isinstance(encrypted_key, str):
 *             raise ValidationError("Encrypted key must be a non-empty string", context={"encrypted_key": str(encrypted_key)[:50]})             # <<<<<<<<<<<<<<
 * 
 *         try:
*/
    __pyx_t_5 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_ValidationError); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 980, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 980, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_Unicode(__pyx_v_encrypted_key); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 980, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_9 = __Pyx_PyUnicode_Substring(__pyx_t_8, 0, 50); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 980, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (PyDict_SetItem(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_encrypted_key, __pyx_t_9) < (0)) __PYX_ERR(0, 980, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_10 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
      assert(__pyx_t_5);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
      __pyx_t_10 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Encrypted_key_must_be_a_non_empt};
      __pyx_t_9 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 980, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_context, __pyx_t_7, __pyx_t_9, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 980, __pyx_L1_error)
      __pyx_t_4 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_9);
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 980, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_Raise(__pyx_t_4, 0, 0, 0);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __PYX_ERR(0, 980, __pyx_L1_error)

    /* "ws_package/controllers/activity_controller.py":979
 *     def decrypt(self, encrypted_key) -> str:
 *         """Decrypt encrypted key with improved error handling."""
 *         if not encrypted_key or not isinstance(encrypted_key, str):             # <<<<<<<<<<<<<<
 *             raise ValidationError("Encrypted key must be a non-empty string", context={"encrypted_key": str(encrypted_key)[:50]})
 * 
*/
  }

  /* "ws_package/controllers/activity_controller.py":982
 *             raise ValidationError("Encrypted key must be a non-empty string", context={"encrypted_key": str(encrypted_key)[:50]})
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             position_of_dollar = encrypted_key.find('$')
 *             if position_of_dollar == -1:
*/
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
    __Pyx_XGOTREF(__pyx_t_11);
    __Pyx_XGOTREF(__pyx_t_12);
    __Pyx_XGOTREF(__pyx_t_13);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":983
 * 
 *         try:
 *             position_of_dollar = encrypted_key.find('$')             # <<<<<<<<<<<<<<
 *             if position_of_dollar == -1:
 *                 raise ValidationError("Invalid encrypted key format: missing '$' delimiter", context={"encrypted_key": encrypted_key[:50]})
*/
      __pyx_t_6 = __pyx_v_encrypted_key;
      __Pyx_INCREF(__pyx_t_6);
      __pyx_t_10 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u__3};
        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_find, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 983, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_v_position_of_dollar = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":984
 *         try:
 *             position_of_dollar = encrypted_key.find('$')
 *             if position_of_dollar == -1:             # <<<<<<<<<<<<<<
 *                 raise ValidationError("Invalid encrypted key format: missing '$' delimiter", context={"encrypted_key": encrypted_key[:50]})
 * 
*/
      __pyx_t_1 = (__Pyx_PyLong_BoolEqObjC(__pyx_v_position_of_dollar, __pyx_mstate_global->__pyx_int_neg_1, -1L, 0)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 984, __pyx_L6_error)
      if (unlikely(__pyx_t_1)) {

        /* "ws_package/controllers/activity_controller.py":985
 *             position_of_dollar = encrypted_key.find('$')
 *             if position_of_dollar == -1:
 *                 raise ValidationError("Invalid encrypted key format: missing '$' delimiter", context={"encrypted_key": encrypted_key[:50]})             # <<<<<<<<<<<<<<
 * 
 *             new_string = encrypted_key[position_of_dollar + 1:]
*/
        __pyx_t_6 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_ValidationError); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 985, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 985, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_5 = __Pyx_PyObject_GetSlice(__pyx_v_encrypted_key, 0, 50, NULL, NULL, &__pyx_mstate_global->__pyx_slice[0], 0, 1, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 985, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_5);
        if (PyDict_SetItem(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_encrypted_key, __pyx_t_5) < (0)) __PYX_ERR(0, 985, __pyx_L6_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_9);
          assert(__pyx_t_6);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Invalid_encrypted_key_format_mis};
          __pyx_t_5 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 985, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_5);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_context, __pyx_t_7, __pyx_t_5, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 985, __pyx_L6_error)
          __pyx_t_4 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_5);
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 985, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_Raise(__pyx_t_4, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __PYX_ERR(0, 985, __pyx_L6_error)

        /* "ws_package/controllers/activity_controller.py":984
 *         try:
 *             position_of_dollar = encrypted_key.find('$')
 *             if position_of_dollar == -1:             # <<<<<<<<<<<<<<
 *                 raise ValidationError("Invalid encrypted key format: missing '$' delimiter", context={"encrypted_key": encrypted_key[:50]})
 * 
*/
      }

      /* "ws_package/controllers/activity_controller.py":987
 *                 raise ValidationError("Invalid encrypted key format: missing '$' delimiter", context={"encrypted_key": encrypted_key[:50]})
 * 
 *             new_string = encrypted_key[position_of_dollar + 1:]             # <<<<<<<<<<<<<<
 *             if not new_string:
 *                 raise ValidationError("Invalid encrypted key format: empty data after '$'", context={"encrypted_key": encrypted_key[:50]})
*/
      __pyx_t_4 = __Pyx_PyLong_AddObjC(__pyx_v_position_of_dollar, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 987, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_9 = __Pyx_PyObject_GetSlice(__pyx_v_encrypted_key, 0, 0, &__pyx_t_4, NULL, NULL, 0, 0, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 987, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_v_new_string = __pyx_t_9;
      __pyx_t_9 = 0;

      /* "ws_package/controllers/activity_controller.py":988
 * 
 *             new_string = encrypted_key[position_of_dollar + 1:]
 *             if not new_string:             # <<<<<<<<<<<<<<
 *                 raise ValidationError("Invalid encrypted key format: empty data after '$'", context={"encrypted_key": encrypted_key[:50]})
 * 
*/
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_new_string); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 988, __pyx_L6_error)
      __pyx_t_2 = (!__pyx_t_1);
      if (unlikely(__pyx_t_2)) {

        /* "ws_package/controllers/activity_controller.py":989
 *             new_string = encrypted_key[position_of_dollar + 1:]
 *             if not new_string:
 *                 raise ValidationError("Invalid encrypted key format: empty data after '$'", context={"encrypted_key": encrypted_key[:50]})             # <<<<<<<<<<<<<<
 * 
 *             new_string = new_string[::-1]
*/
        __pyx_t_4 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_ValidationError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 989, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 989, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_6 = __Pyx_PyObject_GetSlice(__pyx_v_encrypted_key, 0, 50, NULL, NULL, &__pyx_mstate_global->__pyx_slice[0], 0, 1, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 989, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (PyDict_SetItem(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_encrypted_key, __pyx_t_6) < (0)) __PYX_ERR(0, 989, __pyx_L6_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
          assert(__pyx_t_4);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Invalid_encrypted_key_format_emp};
          __pyx_t_6 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 989, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_6);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_context, __pyx_t_7, __pyx_t_6, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 989, __pyx_L6_error)
          __pyx_t_9 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_6);
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 989, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_9);
        }
        __Pyx_Raise(__pyx_t_9, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __PYX_ERR(0, 989, __pyx_L6_error)

        /* "ws_package/controllers/activity_controller.py":988
 * 
 *             new_string = encrypted_key[position_of_dollar + 1:]
 *             if not new_string:             # <<<<<<<<<<<<<<
 *                 raise ValidationError("Invalid encrypted key format: empty data after '$'", context={"encrypted_key": encrypted_key[:50]})
 * 
*/
      }

      /* "ws_package/controllers/activity_controller.py":991
 *                 raise ValidationError("Invalid encrypted key format: empty data after '$'", context={"encrypted_key": encrypted_key[:50]})
 * 
 *             new_string = new_string[::-1]             # <<<<<<<<<<<<<<
 *             decrypted_data = base64.b64decode(new_string).decode()
 *             return decrypted_data
*/
      __pyx_t_9 = __Pyx_PyObject_GetItem(__pyx_v_new_string, __pyx_mstate_global->__pyx_slice[1]); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 991, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF_SET(__pyx_v_new_string, __pyx_t_9);
      __pyx_t_9 = 0;

      /* "ws_package/controllers/activity_controller.py":992
 * 
 *             new_string = new_string[::-1]
 *             decrypted_data = base64.b64decode(new_string).decode()             # <<<<<<<<<<<<<<
 *             return decrypted_data
 * 
*/
      __pyx_t_7 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_base64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 992, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_b64decode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 992, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_10 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
        assert(__pyx_t_7);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
        __pyx_t_10 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_new_string};
        __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 992, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_6);
      }
      __pyx_t_5 = __pyx_t_6;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_10 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
        __pyx_t_9 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_decode, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 992, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_9);
      }
      __pyx_v_decrypted_data = __pyx_t_9;
      __pyx_t_9 = 0;

      /* "ws_package/controllers/activity_controller.py":993
 *             new_string = new_string[::-1]
 *             decrypted_data = base64.b64decode(new_string).decode()
 *             return decrypted_data             # <<<<<<<<<<<<<<
 * 
 *         except ValueError as e:
*/
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_9 = __pyx_v_decrypted_data;
      __Pyx_INCREF(__pyx_t_9);
      if (!(likely(PyUnicode_CheckExact(__pyx_t_9))||((__pyx_t_9) == Py_None) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_t_9))) __PYX_ERR(0, 993, __pyx_L6_error)
      __pyx_r = ((PyObject*)__pyx_t_9);
      __pyx_t_9 = 0;
      goto __pyx_L10_try_return;

      /* "ws_package/controllers/activity_controller.py":982
 *             raise ValidationError("Encrypted key must be a non-empty string", context={"encrypted_key": str(encrypted_key)[:50]})
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             position_of_dollar = encrypted_key.find('$')
 *             if position_of_dollar == -1:
*/
    }
    __pyx_L6_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "ws_package/controllers/activity_controller.py":995
 *             return decrypted_data
 * 
 *         except ValueError as e:             # <<<<<<<<<<<<<<
 *             logger.error("Value error in decryption: %s", e)
 *             raise ValidationError(f"Invalid base64 data in encrypted key: {e}", context={"encrypted_key": encrypted_key[:50]})
*/
    __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_ValueError))));
    if (__pyx_t_14) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.decrypt", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_6, &__pyx_t_5) < 0) __PYX_ERR(0, 995, __pyx_L8_except_error)
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __pyx_v_e = __pyx_t_6;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":996
 * 
 *         except ValueError as e:
 *             logger.error("Value error in decryption: %s", e)             # <<<<<<<<<<<<<<
 *             raise ValidationError(f"Invalid base64 data in encrypted key: {e}", context={"encrypted_key": encrypted_key[:50]})
 *         except UnicodeDecodeError as e:
*/
        __pyx_t_7 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 996, __pyx_L19_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 996, __pyx_L19_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_15))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_15);
          assert(__pyx_t_7);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Value_error_in_decryption_s, __pyx_v_e};
          __pyx_t_8 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_10, (3-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 996, __pyx_L19_error)
          __Pyx_GOTREF(__pyx_t_8);
        }
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

        /* "ws_package/controllers/activity_controller.py":997
 *         except ValueError as e:
 *             logger.error("Value error in decryption: %s", e)
 *             raise ValidationError(f"Invalid base64 data in encrypted key: {e}", context={"encrypted_key": encrypted_key[:50]})             # <<<<<<<<<<<<<<
 *         except UnicodeDecodeError as e:
 *             logger.error("Unicode decode error in decryption: %s", e)
*/
        __pyx_t_15 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_ValidationError); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 997, __pyx_L19_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_4 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 997, __pyx_L19_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_16 = __Pyx_PyUnicode_Concat(__pyx_mstate_global->__pyx_kp_u_Invalid_base64_data_in_encrypted, __pyx_t_4); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 997, __pyx_L19_error)
        __Pyx_GOTREF(__pyx_t_16);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 997, __pyx_L19_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_17 = __Pyx_PyObject_GetSlice(__pyx_v_encrypted_key, 0, 50, NULL, NULL, &__pyx_mstate_global->__pyx_slice[0], 0, 1, 0); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 997, __pyx_L19_error)
        __Pyx_GOTREF(__pyx_t_17);
        if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_encrypted_key, __pyx_t_17) < (0)) __PYX_ERR(0, 997, __pyx_L19_error)
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_7);
          assert(__pyx_t_15);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_15);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_15, __pyx_t_16};
          __pyx_t_17 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 997, __pyx_L19_error)
          __Pyx_GOTREF(__pyx_t_17);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_context, __pyx_t_4, __pyx_t_17, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 997, __pyx_L19_error)
          __pyx_t_8 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_17);
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 997, __pyx_L19_error)
          __Pyx_GOTREF(__pyx_t_8);
        }
        __Pyx_Raise(__pyx_t_8, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __PYX_ERR(0, 997, __pyx_L19_error)
      }

      /* "ws_package/controllers/activity_controller.py":995
 *             return decrypted_data
 * 
 *         except ValueError as e:             # <<<<<<<<<<<<<<
 *             logger.error("Value error in decryption: %s", e)
 *             raise ValidationError(f"Invalid base64 data in encrypted key: {e}", context={"encrypted_key": encrypted_key[:50]})
*/
      /*finally:*/ {
        __pyx_L19_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25);
          if ( unlikely(__Pyx_GetException(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22) < 0)) __Pyx_ErrFetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_23);
          __Pyx_XGOTREF(__pyx_t_24);
          __Pyx_XGOTREF(__pyx_t_25);
          __pyx_t_14 = __pyx_lineno; __pyx_t_18 = __pyx_clineno; __pyx_t_19 = __pyx_filename;
          {
            __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_XGIVEREF(__pyx_t_24);
          __Pyx_XGIVEREF(__pyx_t_25);
          __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_24, __pyx_t_25);
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_ErrRestore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
          __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0;
          __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_18; __pyx_filename = __pyx_t_19;
          goto __pyx_L8_except_error;
        }
      }
    }

    /* "ws_package/controllers/activity_controller.py":998
 *             logger.error("Value error in decryption: %s", e)
 *             raise ValidationError(f"Invalid base64 data in encrypted key: {e}", context={"encrypted_key": encrypted_key[:50]})
 *         except UnicodeDecodeError as e:             # <<<<<<<<<<<<<<
 *             logger.error("Unicode decode error in decryption: %s", e)
 *             raise ValidationError(f"Invalid UTF-8 data in encrypted key: {e}", context={"encrypted_key": encrypted_key[:50]})
*/
    __pyx_t_18 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_UnicodeDecodeError))));
    if (__pyx_t_18) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.decrypt", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_9) < 0) __PYX_ERR(0, 998, __pyx_L8_except_error)
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_6);
      __pyx_v_e = __pyx_t_6;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":999
 *             raise ValidationError(f"Invalid base64 data in encrypted key: {e}", context={"encrypted_key": encrypted_key[:50]})
 *         except UnicodeDecodeError as e:
 *             logger.error("Unicode decode error in decryption: %s", e)             # <<<<<<<<<<<<<<
 *             raise ValidationError(f"Invalid UTF-8 data in encrypted key: {e}", context={"encrypted_key": encrypted_key[:50]})
 *         except Exception as e:
*/
        __pyx_t_7 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 999, __pyx_L30_error)
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 999, __pyx_L30_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
          assert(__pyx_t_7);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Unicode_decode_error_in_decrypti, __pyx_v_e};
          __pyx_t_8 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_10, (3-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 999, __pyx_L30_error)
          __Pyx_GOTREF(__pyx_t_8);
        }
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

        /* "ws_package/controllers/activity_controller.py":1000
 *         except UnicodeDecodeError as e:
 *             logger.error("Unicode decode error in decryption: %s", e)
 *             raise ValidationError(f"Invalid UTF-8 data in encrypted key: {e}", context={"encrypted_key": encrypted_key[:50]})             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             logger.error("Unexpected error in decryption: %s", e)
*/
        __pyx_t_4 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_ValidationError); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1000, __pyx_L30_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_17 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1000, __pyx_L30_error)
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_16 = __Pyx_PyUnicode_Concat(__pyx_mstate_global->__pyx_kp_u_Invalid_UTF_8_data_in_encrypted, __pyx_t_17); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1000, __pyx_L30_error)
        __Pyx_GOTREF(__pyx_t_16);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __pyx_t_17 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1000, __pyx_L30_error)
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_15 = __Pyx_PyObject_GetSlice(__pyx_v_encrypted_key, 0, 50, NULL, NULL, &__pyx_mstate_global->__pyx_slice[0], 0, 1, 0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1000, __pyx_L30_error)
        __Pyx_GOTREF(__pyx_t_15);
        if (PyDict_SetItem(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_encrypted_key, __pyx_t_15) < (0)) __PYX_ERR(0, 1000, __pyx_L30_error)
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7);
          assert(__pyx_t_4);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_4, __pyx_t_16};
          __pyx_t_15 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1000, __pyx_L30_error)
          __Pyx_GOTREF(__pyx_t_15);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_context, __pyx_t_17, __pyx_t_15, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 1000, __pyx_L30_error)
          __pyx_t_8 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_15);
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1000, __pyx_L30_error)
          __Pyx_GOTREF(__pyx_t_8);
        }
        __Pyx_Raise(__pyx_t_8, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __PYX_ERR(0, 1000, __pyx_L30_error)
      }

      /* "ws_package/controllers/activity_controller.py":998
 *             logger.error("Value error in decryption: %s", e)
 *             raise ValidationError(f"Invalid base64 data in encrypted key: {e}", context={"encrypted_key": encrypted_key[:50]})
 *         except UnicodeDecodeError as e:             # <<<<<<<<<<<<<<
 *             logger.error("Unicode decode error in decryption: %s", e)
 *             raise ValidationError(f"Invalid UTF-8 data in encrypted key: {e}", context={"encrypted_key": encrypted_key[:50]})
*/
      /*finally:*/ {
        __pyx_L30_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
          if ( unlikely(__Pyx_GetException(&__pyx_t_25, &__pyx_t_24, &__pyx_t_23) < 0)) __Pyx_ErrFetch(&__pyx_t_25, &__pyx_t_24, &__pyx_t_23);
          __Pyx_XGOTREF(__pyx_t_25);
          __Pyx_XGOTREF(__pyx_t_24);
          __Pyx_XGOTREF(__pyx_t_23);
          __Pyx_XGOTREF(__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_20);
          __pyx_t_18 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_26 = __pyx_filename;
          {
            __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_21, __pyx_t_20);
          __Pyx_XGIVEREF(__pyx_t_25);
          __Pyx_XGIVEREF(__pyx_t_24);
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_ErrRestore(__pyx_t_25, __pyx_t_24, __pyx_t_23);
          __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0;
          __pyx_lineno = __pyx_t_18; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_26;
          goto __pyx_L8_except_error;
        }
      }
    }

    /* "ws_package/controllers/activity_controller.py":1001
 *             logger.error("Unicode decode error in decryption: %s", e)
 *             raise ValidationError(f"Invalid UTF-8 data in encrypted key: {e}", context={"encrypted_key": encrypted_key[:50]})
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Unexpected error in decryption: %s", e)
 *             raise ValidationError(f"Unexpected error decrypting key: {e}", context={"encrypted_key": encrypted_key[:50]})
*/
    __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_14) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.decrypt", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_6, &__pyx_t_5) < 0) __PYX_ERR(0, 1001, __pyx_L8_except_error)
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_6);
      __pyx_v_e = __pyx_t_6;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":1002
 *             raise ValidationError(f"Invalid UTF-8 data in encrypted key: {e}", context={"encrypted_key": encrypted_key[:50]})
 *         except Exception as e:
 *             logger.error("Unexpected error in decryption: %s", e)             # <<<<<<<<<<<<<<
 *             raise ValidationError(f"Unexpected error decrypting key: {e}", context={"encrypted_key": encrypted_key[:50]})
 * 
*/
        __pyx_t_7 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1002, __pyx_L41_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1002, __pyx_L41_error)
        __Pyx_GOTREF(__pyx_t_17);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_17))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_17);
          assert(__pyx_t_7);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Unexpected_error_in_decryption_s, __pyx_v_e};
          __pyx_t_8 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_10, (3-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1002, __pyx_L41_error)
          __Pyx_GOTREF(__pyx_t_8);
        }
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

        /* "ws_package/controllers/activity_controller.py":1003
 *         except Exception as e:
 *             logger.error("Unexpected error in decryption: %s", e)
 *             raise ValidationError(f"Unexpected error decrypting key: {e}", context={"encrypted_key": encrypted_key[:50]})             # <<<<<<<<<<<<<<
 * 
 *     def _handle_wake_s3_update(self):
*/
        __pyx_t_17 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_ValidationError); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1003, __pyx_L41_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_15 = __Pyx_PyObject_FormatSimple(__pyx_v_e, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1003, __pyx_L41_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_16 = __Pyx_PyUnicode_Concat(__pyx_mstate_global->__pyx_kp_u_Unexpected_error_decrypting_key, __pyx_t_15); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1003, __pyx_L41_error)
        __Pyx_GOTREF(__pyx_t_16);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __pyx_t_15 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1003, __pyx_L41_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_v_encrypted_key, 0, 50, NULL, NULL, &__pyx_mstate_global->__pyx_slice[0], 0, 1, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1003, __pyx_L41_error)
        __Pyx_GOTREF(__pyx_t_4);
        if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_encrypted_key, __pyx_t_4) < (0)) __PYX_ERR(0, 1003, __pyx_L41_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_7);
          assert(__pyx_t_17);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_17);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_17, __pyx_t_16};
          __pyx_t_4 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1003, __pyx_L41_error)
          __Pyx_GOTREF(__pyx_t_4);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_context, __pyx_t_15, __pyx_t_4, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 1003, __pyx_L41_error)
          __pyx_t_8 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_4);
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1003, __pyx_L41_error)
          __Pyx_GOTREF(__pyx_t_8);
        }
        __Pyx_Raise(__pyx_t_8, 0, 0, 0);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __PYX_ERR(0, 1003, __pyx_L41_error)
      }

      /* "ws_package/controllers/activity_controller.py":1001
 *             logger.error("Unicode decode error in decryption: %s", e)
 *             raise ValidationError(f"Invalid UTF-8 data in encrypted key: {e}", context={"encrypted_key": encrypted_key[:50]})
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Unexpected error in decryption: %s", e)
 *             raise ValidationError(f"Unexpected error decrypting key: {e}", context={"encrypted_key": encrypted_key[:50]})
*/
      /*finally:*/ {
        __pyx_L41_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25);
          if ( unlikely(__Pyx_GetException(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22) < 0)) __Pyx_ErrFetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_23);
          __Pyx_XGOTREF(__pyx_t_24);
          __Pyx_XGOTREF(__pyx_t_25);
          __pyx_t_14 = __pyx_lineno; __pyx_t_18 = __pyx_clineno; __pyx_t_27 = __pyx_filename;
          {
            __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_XGIVEREF(__pyx_t_24);
          __Pyx_XGIVEREF(__pyx_t_25);
          __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_24, __pyx_t_25);
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_ErrRestore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
          __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0;
          __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_18; __pyx_filename = __pyx_t_27;
          goto __pyx_L8_except_error;
        }
      }
    }
    goto __pyx_L8_except_error;

    /* "ws_package/controllers/activity_controller.py":982
 *             raise ValidationError("Encrypted key must be a non-empty string", context={"encrypted_key": str(encrypted_key)[:50]})
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             position_of_dollar = encrypted_key.find('$')
 *             if position_of_dollar == -1:
*/
    __pyx_L8_except_error:;
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_XGIVEREF(__pyx_t_12);
    __Pyx_XGIVEREF(__pyx_t_13);
    __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
    goto __pyx_L1_error;
    __pyx_L10_try_return:;
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_XGIVEREF(__pyx_t_12);
    __Pyx_XGIVEREF(__pyx_t_13);
    __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
    goto __pyx_L0;
  }

  /* "ws_package/controllers/activity_controller.py":977
 *         logger.debug("ORG check at every interval")
 * 
 *     def decrypt(self, encrypted_key) -> str:             # <<<<<<<<<<<<<<
 *         """Decrypt encrypted key with improved error handling."""
 *         if not encrypted_key or not isinstance(encrypted_key, str):
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.decrypt", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_position_of_dollar);
  __Pyx_XDECREF(__pyx_v_new_string);
  __Pyx_XDECREF(__pyx_v_decrypted_data);
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":1005
 *             raise ValidationError(f"Unexpected error decrypting key: {e}", context={"encrypted_key": encrypted_key[:50]})
 * 
 *     def _handle_wake_s3_update(self):             # <<<<<<<<<<<<<<
 *         """
 *         Handle system wake event - check if new day and update S3 bucket config.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_52_handle_wake_s3_update(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_51_handle_wake_s3_update, "\n        Handle system wake event - check if new day and update S3 bucket config.\n        This is called when system wakes from sleep, not at midnight.\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_52_handle_wake_s3_update = {"_handle_wake_s3_update", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_52_handle_wake_s3_update, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_51_handle_wake_s3_update};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_52_handle_wake_s3_update(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[1] = {0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_handle_wake_s3_update (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 1005, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1005, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_handle_wake_s3_update", 0) < (0)) __PYX_ERR(0, 1005, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_handle_wake_s3_update", 1, 1, 1, i); __PYX_ERR(0, 1005, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 1)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1005, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_handle_wake_s3_update", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 1005, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._handle_wake_s3_update", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_51_handle_wake_s3_update(__pyx_self, __pyx_v_self);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_51_handle_wake_s3_update(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_v_user_entity = NULL;
  PyObject *__pyx_v_loop = NULL;
  PyObject *__pyx_v_e = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  size_t __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  int __pyx_t_20;
  char const *__pyx_t_21;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_handle_wake_s3_update", 0);

  /* "ws_package/controllers/activity_controller.py":1010
 *         This is called when system wakes from sleep, not at midnight.
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # This is a synchronous callback, so we need to check if user_entity is available
 *             # and schedule async operation if needed
*/
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":1013
 *             # This is a synchronous callback, so we need to check if user_entity is available
 *             # and schedule async operation if needed
 *             if not hasattr(self, '_user_entity_for_wake') or self._user_entity_for_wake is None:             # <<<<<<<<<<<<<<
 *                 logger.debug("[WAKE] No user_entity available for S3 bucket update on wake")
 *                 return
*/
      __pyx_t_5 = __Pyx_HasAttr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_user_entity_for_wake); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 1013, __pyx_L3_error)
      __pyx_t_6 = (!__pyx_t_5);
      if (!__pyx_t_6) {
      } else {
        __pyx_t_4 = __pyx_t_6;
        goto __pyx_L10_bool_binop_done;
      }
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_user_entity_for_wake); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1013, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = (__pyx_t_7 == Py_None);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_4 = __pyx_t_6;
      __pyx_L10_bool_binop_done:;
      if (__pyx_t_4) {

        /* "ws_package/controllers/activity_controller.py":1014
 *             # and schedule async operation if needed
 *             if not hasattr(self, '_user_entity_for_wake') or self._user_entity_for_wake is None:
 *                 logger.debug("[WAKE] No user_entity available for S3 bucket update on wake")             # <<<<<<<<<<<<<<
 *                 return
 * 
*/
        __pyx_t_8 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1014, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1014, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_11 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_10);
          assert(__pyx_t_8);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
          __pyx_t_11 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_mstate_global->__pyx_kp_u_WAKE_No_user_entity_available_f};
          __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_11, (2-__pyx_t_11) | (__pyx_t_11*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1014, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "ws_package/controllers/activity_controller.py":1015
 *             if not hasattr(self, '_user_entity_for_wake') or self._user_entity_for_wake is None:
 *                 logger.debug("[WAKE] No user_entity available for S3 bucket update on wake")
 *                 return             # <<<<<<<<<<<<<<
 * 
 *             user_entity = self._user_entity_for_wake
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
        goto __pyx_L7_try_return;

        /* "ws_package/controllers/activity_controller.py":1013
 *             # This is a synchronous callback, so we need to check if user_entity is available
 *             # and schedule async operation if needed
 *             if not hasattr(self, '_user_entity_for_wake') or self._user_entity_for_wake is None:             # <<<<<<<<<<<<<<
 *                 logger.debug("[WAKE] No user_entity available for S3 bucket update on wake")
 *                 return
*/
      }

      /* "ws_package/controllers/activity_controller.py":1017
 *                 return
 * 
 *             user_entity = self._user_entity_for_wake             # <<<<<<<<<<<<<<
 * 
 *             # Check if it's a new day by comparing with last activity interval date
*/
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_user_entity_for_wake); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1017, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_v_user_entity = __pyx_t_7;
      __pyx_t_7 = 0;

      /* "ws_package/controllers/activity_controller.py":1020
 * 
 *             # Check if it's a new day by comparing with last activity interval date
 *             try:             # <<<<<<<<<<<<<<
 *                 # Try to get event loop
 *                 loop = asyncio.get_event_loop()
*/
      {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
        __Pyx_XGOTREF(__pyx_t_12);
        __Pyx_XGOTREF(__pyx_t_13);
        __Pyx_XGOTREF(__pyx_t_14);
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":1022
 *             try:
 *                 # Try to get event loop
 *                 loop = asyncio.get_event_loop()             # <<<<<<<<<<<<<<
 *                 if loop.is_running():
 *                     # Schedule async operation
*/
          __pyx_t_10 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1022, __pyx_L12_error)
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_get_event_loop); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1022, __pyx_L12_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __pyx_t_11 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_9))) {
            __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9);
            assert(__pyx_t_10);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
            __pyx_t_11 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_10, NULL};
            __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_11, (1-__pyx_t_11) | (__pyx_t_11*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1022, __pyx_L12_error)
            __Pyx_GOTREF(__pyx_t_7);
          }
          __pyx_v_loop = __pyx_t_7;
          __pyx_t_7 = 0;

          /* "ws_package/controllers/activity_controller.py":1023
 *                 # Try to get event loop
 *                 loop = asyncio.get_event_loop()
 *                 if loop.is_running():             # <<<<<<<<<<<<<<
 *                     # Schedule async operation
 *                     asyncio.create_task(self._check_and_update_s3_on_wake(user_entity))
*/
          __pyx_t_9 = __pyx_v_loop;
          __Pyx_INCREF(__pyx_t_9);
          __pyx_t_11 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_9, NULL};
            __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_running, __pyx_callargs+__pyx_t_11, (1-__pyx_t_11) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
            if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1023, __pyx_L12_error)
            __Pyx_GOTREF(__pyx_t_7);
          }
          __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1023, __pyx_L12_error)
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (__pyx_t_4) {

            /* "ws_package/controllers/activity_controller.py":1025
 *                 if loop.is_running():
 *                     # Schedule async operation
 *                     asyncio.create_task(self._check_and_update_s3_on_wake(user_entity))             # <<<<<<<<<<<<<<
 *                 else:
 *                     # Run async operation
*/
            __pyx_t_9 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1025, __pyx_L12_error)
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_create_task); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1025, __pyx_L12_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __pyx_t_15 = __pyx_v_self;
            __Pyx_INCREF(__pyx_t_15);
            __pyx_t_11 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_v_user_entity};
              __pyx_t_10 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_check_and_update_s3_on_wake, __pyx_callargs+__pyx_t_11, (2-__pyx_t_11) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1025, __pyx_L12_error)
              __Pyx_GOTREF(__pyx_t_10);
            }
            __pyx_t_11 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_8))) {
              __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
              assert(__pyx_t_9);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
              __Pyx_INCREF(__pyx_t_9);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
              __pyx_t_11 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_t_10};
              __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_11, (2-__pyx_t_11) | (__pyx_t_11*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
              if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1025, __pyx_L12_error)
              __Pyx_GOTREF(__pyx_t_7);
            }
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

            /* "ws_package/controllers/activity_controller.py":1023
 *                 # Try to get event loop
 *                 loop = asyncio.get_event_loop()
 *                 if loop.is_running():             # <<<<<<<<<<<<<<
 *                     # Schedule async operation
 *                     asyncio.create_task(self._check_and_update_s3_on_wake(user_entity))
*/
            goto __pyx_L18;
          }

          /* "ws_package/controllers/activity_controller.py":1028
 *                 else:
 *                     # Run async operation
 *                     asyncio.run(self._check_and_update_s3_on_wake(user_entity))             # <<<<<<<<<<<<<<
 *             except RuntimeError:
 *                 # No event loop, create one
*/
          /*else*/ {
            __pyx_t_8 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1028, __pyx_L12_error)
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_run); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1028, __pyx_L12_error)
            __Pyx_GOTREF(__pyx_t_9);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __pyx_t_15 = __pyx_v_self;
            __Pyx_INCREF(__pyx_t_15);
            __pyx_t_11 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_v_user_entity};
              __pyx_t_10 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_check_and_update_s3_on_wake, __pyx_callargs+__pyx_t_11, (2-__pyx_t_11) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1028, __pyx_L12_error)
              __Pyx_GOTREF(__pyx_t_10);
            }
            __pyx_t_11 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_9))) {
              __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9);
              assert(__pyx_t_8);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
              __Pyx_INCREF(__pyx_t_8);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
              __pyx_t_11 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_t_10};
              __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_11, (2-__pyx_t_11) | (__pyx_t_11*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
              if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1028, __pyx_L12_error)
              __Pyx_GOTREF(__pyx_t_7);
            }
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          }
          __pyx_L18:;

          /* "ws_package/controllers/activity_controller.py":1020
 * 
 *             # Check if it's a new day by comparing with last activity interval date
 *             try:             # <<<<<<<<<<<<<<
 *                 # Try to get event loop
 *                 loop = asyncio.get_event_loop()
*/
        }
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        goto __pyx_L17_try_end;
        __pyx_L12_error:;
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

        /* "ws_package/controllers/activity_controller.py":1029
 *                     # Run async operation
 *                     asyncio.run(self._check_and_update_s3_on_wake(user_entity))
 *             except RuntimeError:             # <<<<<<<<<<<<<<
 *                 # No event loop, create one
 *                 asyncio.run(self._check_and_update_s3_on_wake(user_entity))
*/
        __pyx_t_16 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_RuntimeError))));
        if (__pyx_t_16) {
          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._handle_wake_s3_update", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_9, &__pyx_t_10) < 0) __PYX_ERR(0, 1029, __pyx_L14_except_error)
          __Pyx_XGOTREF(__pyx_t_7);
          __Pyx_XGOTREF(__pyx_t_9);
          __Pyx_XGOTREF(__pyx_t_10);

          /* "ws_package/controllers/activity_controller.py":1031
 *             except RuntimeError:
 *                 # No event loop, create one
 *                 asyncio.run(self._check_and_update_s3_on_wake(user_entity))             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             logger.error("[WAKE] Error handling S3 bucket update on wake: %s", e, exc_info=True)
*/
          __pyx_t_15 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1031, __pyx_L14_except_error)
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_run); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1031, __pyx_L14_except_error)
          __Pyx_GOTREF(__pyx_t_18);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __pyx_t_19 = __pyx_v_self;
          __Pyx_INCREF(__pyx_t_19);
          __pyx_t_11 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_19, __pyx_v_user_entity};
            __pyx_t_17 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_check_and_update_s3_on_wake, __pyx_callargs+__pyx_t_11, (2-__pyx_t_11) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
            if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1031, __pyx_L14_except_error)
            __Pyx_GOTREF(__pyx_t_17);
          }
          __pyx_t_11 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_18))) {
            __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_18);
            assert(__pyx_t_15);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_18);
            __Pyx_INCREF(__pyx_t_15);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_18, __pyx__function);
            __pyx_t_11 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_t_17};
            __pyx_t_8 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_18, __pyx_callargs+__pyx_t_11, (2-__pyx_t_11) | (__pyx_t_11*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
            if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1031, __pyx_L14_except_error)
            __Pyx_GOTREF(__pyx_t_8);
          }
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          goto __pyx_L13_exception_handled;
        }
        goto __pyx_L14_except_error;

        /* "ws_package/controllers/activity_controller.py":1020
 * 
 *             # Check if it's a new day by comparing with last activity interval date
 *             try:             # <<<<<<<<<<<<<<
 *                 # Try to get event loop
 *                 loop = asyncio.get_event_loop()
*/
        __pyx_L14_except_error:;
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
        goto __pyx_L3_error;
        __pyx_L13_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
        __pyx_L17_try_end:;
      }

      /* "ws_package/controllers/activity_controller.py":1010
 *         This is called when system wakes from sleep, not at midnight.
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # This is a synchronous callback, so we need to check if user_entity is available
 *             # and schedule async operation if needed
*/
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "ws_package/controllers/activity_controller.py":1032
 *                 # No event loop, create one
 *                 asyncio.run(self._check_and_update_s3_on_wake(user_entity))
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("[WAKE] Error handling S3 bucket update on wake: %s", e, exc_info=True)
 * 
*/
    __pyx_t_16 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_16) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._handle_wake_s3_update", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_10, &__pyx_t_9, &__pyx_t_7) < 0) __PYX_ERR(0, 1032, __pyx_L5_except_error)
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_9);
      __pyx_v_e = __pyx_t_9;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":1033
 *                 asyncio.run(self._check_and_update_s3_on_wake(user_entity))
 *         except Exception as e:
 *             logger.error("[WAKE] Error handling S3 bucket update on wake: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *     async def _check_and_update_s3_on_startup(self, user_entity):
*/
        __pyx_t_18 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1033, __pyx_L26_error)
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1033, __pyx_L26_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __pyx_t_11 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_15))) {
          __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_15);
          assert(__pyx_t_18);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
          __Pyx_INCREF(__pyx_t_18);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
          __pyx_t_11 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_18, __pyx_mstate_global->__pyx_kp_u_WAKE_Error_handling_S3_bucket_u, __pyx_v_e};
          __pyx_t_17 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1033, __pyx_L26_error)
          __Pyx_GOTREF(__pyx_t_17);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_17, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 1033, __pyx_L26_error)
          __pyx_t_8 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_11, (3-__pyx_t_11) | (__pyx_t_11*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_17);
          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1033, __pyx_L26_error)
          __Pyx_GOTREF(__pyx_t_8);
        }
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      }

      /* "ws_package/controllers/activity_controller.py":1032
 *                 # No event loop, create one
 *                 asyncio.run(self._check_and_update_s3_on_wake(user_entity))
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("[WAKE] Error handling S3 bucket update on wake: %s", e, exc_info=True)
 * 
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
          goto __pyx_L27;
        }
        __pyx_L26_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
          __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
          if ( unlikely(__Pyx_GetException(&__pyx_t_14, &__pyx_t_13, &__pyx_t_12) < 0)) __Pyx_ErrFetch(&__pyx_t_14, &__pyx_t_13, &__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_23);
          __Pyx_XGOTREF(__pyx_t_24);
          __pyx_t_16 = __pyx_lineno; __pyx_t_20 = __pyx_clineno; __pyx_t_21 = __pyx_filename;
          {
            __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_XGIVEREF(__pyx_t_24);
          __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_23, __pyx_t_24);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ErrRestore(__pyx_t_14, __pyx_t_13, __pyx_t_12);
          __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0;
          __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_20; __pyx_filename = __pyx_t_21;
          goto __pyx_L5_except_error;
        }
        __pyx_L27:;
      }
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L4_exception_handled;
    }
    goto __pyx_L5_except_error;

    /* "ws_package/controllers/activity_controller.py":1010
 *         This is called when system wakes from sleep, not at midnight.
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # This is a synchronous callback, so we need to check if user_entity is available
 *             # and schedule async operation if needed
*/
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    __pyx_L8_try_end:;
  }

  /* "ws_package/controllers/activity_controller.py":1005
 *             raise ValidationError(f"Unexpected error decrypting key: {e}", context={"encrypted_key": encrypted_key[:50]})
 * 
 *     def _handle_wake_s3_update(self):             # <<<<<<<<<<<<<<
 *         """
 *         Handle system wake event - check if new day and update S3 bucket config.
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._handle_wake_s3_update", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_user_entity);
  __Pyx_XDECREF(__pyx_v_loop);
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_55generator7(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":1035
 *             logger.error("[WAKE] Error handling S3 bucket update on wake: %s", e, exc_info=True)
 * 
 *     async def _check_and_update_s3_on_startup(self, user_entity):             # <<<<<<<<<<<<<<
 *         """
 *         Check if it's a new day on app startup and update S3 bucket config if needed.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_54_check_and_update_s3_on_startup(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_53_check_and_update_s3_on_startup, "\n        Check if it's a new day on app startup and update S3 bucket config if needed.\n        Called when app starts.\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_54_check_and_update_s3_on_startup = {"_check_and_update_s3_on_startup", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_54_check_and_update_s3_on_startup, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_53_check_and_update_s3_on_startup};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_54_check_and_update_s3_on_startup(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_user_entity = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_check_and_update_s3_on_startup (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_user_entity,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 1035, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1035, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1035, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_check_and_update_s3_on_startup", 0) < (0)) __PYX_ERR(0, 1035, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_check_and_update_s3_on_startup", 1, 2, 2, i); __PYX_ERR(0, 1035, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1035, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1035, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_user_entity = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_check_and_update_s3_on_startup", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 1035, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._check_and_update_s3_on_startup", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_53_check_and_update_s3_on_startup(__pyx_self, __pyx_v_self, __pyx_v_user_entity);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_53_check_and_update_s3_on_startup(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_check_and_update_s3_on_startup", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1035, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_user_entity = __pyx_v_user_entity;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_user_entity);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_user_entity);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_55generator7, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[7]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_check_and_update_s3_on_startup, __pyx_mstate_global->__pyx_n_u_ActivityController__check_and_up, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 1035, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._check_and_update_s3_on_startup", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_55generator7(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  size_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  __Pyx_PySendResult __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  PyObject *__pyx_t_26 = NULL;
  int __pyx_t_27;
  int __pyx_t_28;
  int __pyx_t_29;
  char const *__pyx_t_30;
  PyObject *__pyx_t_31 = NULL;
  PyObject *__pyx_t_32 = NULL;
  PyObject *__pyx_t_33 = NULL;
  PyObject *__pyx_t_34 = NULL;
  PyObject *__pyx_t_35 = NULL;
  PyObject *__pyx_t_36 = NULL;
  int __pyx_t_37;
  char const *__pyx_t_38;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_check_and_update_s3_on_startup", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L21_resume_from_await;
    case 2: goto __pyx_L37_resume_from_await;
    case 3: goto __pyx_L55_resume_from_await;
    case 4: goto __pyx_L56_resume_from_await;
    case 5: goto __pyx_L62_resume_from_await;
    case 6: goto __pyx_L70_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 1035, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":1040
 *         Called when app starts.
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # Use centralized read lock for database read operations
 *             DB_OPERATION_TIMEOUT = 5.0
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":1042
 *         try:
 *             # Use centralized read lock for database read operations
 *             DB_OPERATION_TIMEOUT = 5.0             # <<<<<<<<<<<<<<
 * 
 *             with db_lock_manager.read_lock():
*/
      __pyx_cur_scope->__pyx_v_DB_OPERATION_TIMEOUT = 5.0;

      /* "ws_package/controllers/activity_controller.py":1044
 *             DB_OPERATION_TIMEOUT = 5.0
 * 
 *             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     query = select(ActivityInterval).where(
*/
      /*with:*/ {
        __pyx_t_5 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1044, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1044, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
          assert(__pyx_t_5);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1044, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __pyx_t_9 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1044, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_5 = NULL;
        __pyx_t_6 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1044, __pyx_L10_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (likely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
          assert(__pyx_t_5);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
          __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1044, __pyx_L10_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        /*try:*/ {
          {
            __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
            __Pyx_XGOTREF(__pyx_t_10);
            __Pyx_XGOTREF(__pyx_t_11);
            __Pyx_XGOTREF(__pyx_t_12);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":1045
 * 
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     query = select(ActivityInterval).where(
 *                         ActivityInterval.counter == self.last_count + 1
*/
              /*with:*/ {
                __pyx_t_7 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1045, __pyx_L14_error)
                __Pyx_GOTREF(__pyx_t_6);
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_6))) {
                  __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
                  assert(__pyx_t_7);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                  __Pyx_INCREF(__pyx_t_7);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
                  __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1045, __pyx_L14_error)
                  __Pyx_GOTREF(__pyx_t_4);
                }
                __pyx_t_13 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1045, __pyx_L14_error)
                __Pyx_GOTREF(__pyx_t_13);
                __pyx_t_7 = NULL;
                __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1045, __pyx_L20_error)
                __Pyx_GOTREF(__pyx_t_5);
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (likely(PyMethod_Check(__pyx_t_5))) {
                  __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
                  assert(__pyx_t_7);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                  __Pyx_INCREF(__pyx_t_7);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
                  __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1045, __pyx_L20_error)
                  __Pyx_GOTREF(__pyx_t_6);
                }
                __pyx_t_14 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_6, &__pyx_r);
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                if (likely(__pyx_t_14 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_1);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                  __Pyx_XGIVEREF(__pyx_t_2);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                  __Pyx_XGIVEREF(__pyx_t_3);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                  __Pyx_XGIVEREF(__pyx_t_4);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
                  __Pyx_XGIVEREF(__pyx_t_9);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_9;
                  __Pyx_XGIVEREF(__pyx_t_10);
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_10;
                  __Pyx_XGIVEREF(__pyx_t_11);
                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_11;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 1;
                  return __pyx_r;
                  __pyx_L21_resume_from_await:;
                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_1);
                  __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_2);
                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_3);
                  __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_4);
                  __pyx_t_9 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_9);
                  __pyx_t_10 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = 0;
                  __Pyx_XGOTREF(__pyx_t_10);
                  __pyx_t_11 = __pyx_cur_scope->__pyx_t_6;
                  __pyx_cur_scope->__pyx_t_6 = 0;
                  __Pyx_XGOTREF(__pyx_t_11);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_7;
                  __pyx_cur_scope->__pyx_t_7 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_8;
                  __pyx_cur_scope->__pyx_t_8 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1045, __pyx_L20_error)
                  __pyx_t_6 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_6);
                } else if (likely(__pyx_t_14 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __pyx_t_6 = __pyx_r; __pyx_r = NULL;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 1045, __pyx_L20_error)
                }
                __pyx_t_5 = __pyx_t_6;
                __pyx_t_6 = 0;
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                /*try:*/ {
                  {
                    __Pyx_ExceptionSave(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
                    __Pyx_XGOTREF(__pyx_t_15);
                    __Pyx_XGOTREF(__pyx_t_16);
                    __Pyx_XGOTREF(__pyx_t_17);
                    /*try:*/ {
                      __Pyx_GIVEREF(__pyx_t_5);
                      __pyx_cur_scope->__pyx_v_session = __pyx_t_5;
                      __pyx_t_5 = 0;

                      /* "ws_package/controllers/activity_controller.py":1046
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:
 *                     query = select(ActivityInterval).where(             # <<<<<<<<<<<<<<
 *                         ActivityInterval.counter == self.last_count + 1
 *                     ).order_by(ActivityInterval.start_time.desc()).limit(1)
*/
                      __pyx_t_21 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 1046, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 1046, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_23);
                      __pyx_t_8 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_22))) {
                        __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_22);
                        assert(__pyx_t_21);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_22);
                        __Pyx_INCREF(__pyx_t_21);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_22, __pyx__function);
                        __pyx_t_8 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_21, __pyx_t_23};
                        __pyx_t_20 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_22, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1046, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_20);
                      }
                      __pyx_t_19 = __pyx_t_20;
                      __Pyx_INCREF(__pyx_t_19);

                      /* "ws_package/controllers/activity_controller.py":1047
 *                 async with async_session() as session:
 *                     query = select(ActivityInterval).where(
 *                         ActivityInterval.counter == self.last_count + 1             # <<<<<<<<<<<<<<
 *                     ).order_by(ActivityInterval.start_time.desc()).limit(1)
 *                     try:
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 1047, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 1047, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_23);
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                      __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 1047, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __pyx_t_21 = __Pyx_PyLong_AddObjC(__pyx_t_22, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1047, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                      __pyx_t_22 = PyObject_RichCompare(__pyx_t_23, __pyx_t_21, Py_EQ); __Pyx_XGOTREF(__pyx_t_22); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 1047, __pyx_L25_error)
                      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_19, __pyx_t_22};
                        __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1046, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_18);
                      }
                      __pyx_t_7 = __pyx_t_18;
                      __Pyx_INCREF(__pyx_t_7);

                      /* "ws_package/controllers/activity_controller.py":1048
 *                     query = select(ActivityInterval).where(
 *                         ActivityInterval.counter == self.last_count + 1
 *                     ).order_by(ActivityInterval.start_time.desc()).limit(1)             # <<<<<<<<<<<<<<
 *                     try:
 *                         result = await asyncio.wait_for(
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1048, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_19);
                      __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1048, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                      __pyx_t_22 = __pyx_t_21;
                      __Pyx_INCREF(__pyx_t_22);
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_22, NULL};
                        __pyx_t_20 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_desc, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1048, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_20);
                      }
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_t_20};
                        __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_order_by, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1048, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_6);
                      }
                      __pyx_t_4 = __pyx_t_6;
                      __Pyx_INCREF(__pyx_t_4);
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_int_1};
                        __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_limit, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1048, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_5);
                      }
                      __Pyx_GIVEREF(__pyx_t_5);
                      __pyx_cur_scope->__pyx_v_query = __pyx_t_5;
                      __pyx_t_5 = 0;

                      /* "ws_package/controllers/activity_controller.py":1049
 *                         ActivityInterval.counter == self.last_count + 1
 *                     ).order_by(ActivityInterval.start_time.desc()).limit(1)
 *                     try:             # <<<<<<<<<<<<<<
 *                         result = await asyncio.wait_for(
 *                             session.scalars(query),
*/
                      {
                        __Pyx_ExceptionSave(&__pyx_t_24, &__pyx_t_25, &__pyx_t_26);
                        __Pyx_XGOTREF(__pyx_t_24);
                        __Pyx_XGOTREF(__pyx_t_25);
                        __Pyx_XGOTREF(__pyx_t_26);
                        /*try:*/ {

                          /* "ws_package/controllers/activity_controller.py":1050
 *                     ).order_by(ActivityInterval.start_time.desc()).limit(1)
 *                     try:
 *                         result = await asyncio.wait_for(             # <<<<<<<<<<<<<<
 *                             session.scalars(query),
 *                             timeout=DB_OPERATION_TIMEOUT
*/
                          __pyx_t_6 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1050, __pyx_L31_error)
                          __Pyx_GOTREF(__pyx_t_4);
                          __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_wait_for); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1050, __pyx_L31_error)
                          __Pyx_GOTREF(__pyx_t_18);
                          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                          /* "ws_package/controllers/activity_controller.py":1051
 *                     try:
 *                         result = await asyncio.wait_for(
 *                             session.scalars(query),             # <<<<<<<<<<<<<<
 *                             timeout=DB_OPERATION_TIMEOUT
 *                         )
*/
                          __pyx_t_20 = __pyx_cur_scope->__pyx_v_session;
                          __Pyx_INCREF(__pyx_t_20);
                          __pyx_t_8 = 0;
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_20, __pyx_cur_scope->__pyx_v_query};
                            __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalars, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                            if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1051, __pyx_L31_error)
                            __Pyx_GOTREF(__pyx_t_4);
                          }

                          /* "ws_package/controllers/activity_controller.py":1052
 *                         result = await asyncio.wait_for(
 *                             session.scalars(query),
 *                             timeout=DB_OPERATION_TIMEOUT             # <<<<<<<<<<<<<<
 *                         )
 *                         last_entry = result.first()
*/
                          __pyx_t_20 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_DB_OPERATION_TIMEOUT); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1052, __pyx_L31_error)
                          __Pyx_GOTREF(__pyx_t_20);
                          __pyx_t_8 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_18))) {
                            __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_18);
                            assert(__pyx_t_6);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_18);
                            __Pyx_INCREF(__pyx_t_6);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_18, __pyx__function);
                            __pyx_t_8 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_6, __pyx_t_4};
                            __pyx_t_7 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1050, __pyx_L31_error)
                            __Pyx_GOTREF(__pyx_t_7);
                            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_timeout, __pyx_t_20, __pyx_t_7, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 1050, __pyx_L31_error)
                            __pyx_t_5 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_18, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_7);
                            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                            __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1050, __pyx_L31_error)
                            __Pyx_GOTREF(__pyx_t_5);
                          }
                          __pyx_t_14 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
                          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                          if (likely(__pyx_t_14 == PYGEN_NEXT)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_XGIVEREF(__pyx_t_1);
                            __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                            __Pyx_XGIVEREF(__pyx_t_2);
                            __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                            __Pyx_XGIVEREF(__pyx_t_3);
                            __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                            __Pyx_XGIVEREF(__pyx_t_9);
                            __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
                            __Pyx_XGIVEREF(__pyx_t_10);
                            __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                            __Pyx_XGIVEREF(__pyx_t_11);
                            __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
                            __Pyx_XGIVEREF(__pyx_t_12);
                            __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
                            __Pyx_XGIVEREF(__pyx_t_13);
                            __pyx_cur_scope->__pyx_t_7 = __pyx_t_13;
                            __Pyx_XGIVEREF(__pyx_t_15);
                            __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                            __Pyx_XGIVEREF(__pyx_t_16);
                            __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                            __Pyx_XGIVEREF(__pyx_t_17);
                            __pyx_cur_scope->__pyx_t_10 = __pyx_t_17;
                            __Pyx_XGIVEREF(__pyx_t_24);
                            __pyx_cur_scope->__pyx_t_11 = __pyx_t_24;
                            __Pyx_XGIVEREF(__pyx_t_25);
                            __pyx_cur_scope->__pyx_t_12 = __pyx_t_25;
                            __Pyx_XGIVEREF(__pyx_t_26);
                            __pyx_cur_scope->__pyx_t_13 = __pyx_t_26;
                            __Pyx_XGIVEREF(__pyx_r);
                            __Pyx_RefNannyFinishContext();
                            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                            /* return from generator, awaiting value */
                            __pyx_generator->resume_label = 2;
                            return __pyx_r;
                            __pyx_L37_resume_from_await:;
                            __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                            __pyx_cur_scope->__pyx_t_0 = 0;
                            __Pyx_XGOTREF(__pyx_t_1);
                            __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                            __pyx_cur_scope->__pyx_t_1 = 0;
                            __Pyx_XGOTREF(__pyx_t_2);
                            __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                            __pyx_cur_scope->__pyx_t_2 = 0;
                            __Pyx_XGOTREF(__pyx_t_3);
                            __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
                            __pyx_cur_scope->__pyx_t_3 = 0;
                            __Pyx_XGOTREF(__pyx_t_9);
                            __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                            __pyx_cur_scope->__pyx_t_4 = 0;
                            __Pyx_XGOTREF(__pyx_t_10);
                            __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
                            __pyx_cur_scope->__pyx_t_5 = 0;
                            __Pyx_XGOTREF(__pyx_t_11);
                            __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
                            __pyx_cur_scope->__pyx_t_6 = 0;
                            __Pyx_XGOTREF(__pyx_t_12);
                            __pyx_t_13 = __pyx_cur_scope->__pyx_t_7;
                            __pyx_cur_scope->__pyx_t_7 = 0;
                            __Pyx_XGOTREF(__pyx_t_13);
                            __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                            __pyx_cur_scope->__pyx_t_8 = 0;
                            __Pyx_XGOTREF(__pyx_t_15);
                            __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                            __pyx_cur_scope->__pyx_t_9 = 0;
                            __Pyx_XGOTREF(__pyx_t_16);
                            __pyx_t_17 = __pyx_cur_scope->__pyx_t_10;
                            __pyx_cur_scope->__pyx_t_10 = 0;
                            __Pyx_XGOTREF(__pyx_t_17);
                            __pyx_t_24 = __pyx_cur_scope->__pyx_t_11;
                            __pyx_cur_scope->__pyx_t_11 = 0;
                            __Pyx_XGOTREF(__pyx_t_24);
                            __pyx_t_25 = __pyx_cur_scope->__pyx_t_12;
                            __pyx_cur_scope->__pyx_t_12 = 0;
                            __Pyx_XGOTREF(__pyx_t_25);
                            __pyx_t_26 = __pyx_cur_scope->__pyx_t_13;
                            __pyx_cur_scope->__pyx_t_13 = 0;
                            __Pyx_XGOTREF(__pyx_t_26);
                            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1050, __pyx_L31_error)
                            __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
                          } else if (likely(__pyx_t_14 == PYGEN_RETURN)) {
                            __Pyx_GOTREF(__pyx_r);
                            __pyx_t_5 = __pyx_r; __pyx_r = NULL;
                          } else {
                            __Pyx_XGOTREF(__pyx_r);
                            __PYX_ERR(0, 1050, __pyx_L31_error)
                          }
                          __Pyx_GIVEREF(__pyx_t_5);
                          __pyx_cur_scope->__pyx_v_result = __pyx_t_5;
                          __pyx_t_5 = 0;

                          /* "ws_package/controllers/activity_controller.py":1054
 *                             timeout=DB_OPERATION_TIMEOUT
 *                         )
 *                         last_entry = result.first()             # <<<<<<<<<<<<<<
 *                         if last_entry:
 *                             last_entry_date = last_entry.start_time.date()
*/
                          __pyx_t_18 = __pyx_cur_scope->__pyx_v_result;
                          __Pyx_INCREF(__pyx_t_18);
                          __pyx_t_8 = 0;
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_18, NULL};
                            __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_first, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1054, __pyx_L31_error)
                            __Pyx_GOTREF(__pyx_t_5);
                          }
                          __Pyx_GIVEREF(__pyx_t_5);
                          __pyx_cur_scope->__pyx_v_last_entry = __pyx_t_5;
                          __pyx_t_5 = 0;

                          /* "ws_package/controllers/activity_controller.py":1055
 *                         )
 *                         last_entry = result.first()
 *                         if last_entry:             # <<<<<<<<<<<<<<
 *                             last_entry_date = last_entry.start_time.date()
 *                         else:
*/
                          __pyx_t_27 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_entry); if (unlikely((__pyx_t_27 < 0))) __PYX_ERR(0, 1055, __pyx_L31_error)
                          if (__pyx_t_27) {

                            /* "ws_package/controllers/activity_controller.py":1056
 *                         last_entry = result.first()
 *                         if last_entry:
 *                             last_entry_date = last_entry.start_time.date()             # <<<<<<<<<<<<<<
 *                         else:
 *                             last_entry_date = None
*/
                            __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_entry, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1056, __pyx_L31_error)
                            __Pyx_GOTREF(__pyx_t_7);
                            __pyx_t_18 = __pyx_t_7;
                            __Pyx_INCREF(__pyx_t_18);
                            __pyx_t_8 = 0;
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_18, NULL};
                              __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_date, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                              if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1056, __pyx_L31_error)
                              __Pyx_GOTREF(__pyx_t_5);
                            }
                            __Pyx_GIVEREF(__pyx_t_5);
                            __pyx_cur_scope->__pyx_v_last_entry_date = __pyx_t_5;
                            __pyx_t_5 = 0;

                            /* "ws_package/controllers/activity_controller.py":1055
 *                         )
 *                         last_entry = result.first()
 *                         if last_entry:             # <<<<<<<<<<<<<<
 *                             last_entry_date = last_entry.start_time.date()
 *                         else:
*/
                            goto __pyx_L38;
                          }

                          /* "ws_package/controllers/activity_controller.py":1058
 *                             last_entry_date = last_entry.start_time.date()
 *                         else:
 *                             last_entry_date = None             # <<<<<<<<<<<<<<
 *                     except asyncio.TimeoutError:
 *                         logger.error("Database query timed out after %ss in startup S3 check", DB_OPERATION_TIMEOUT)
*/
                          /*else*/ {
                            __Pyx_INCREF(Py_None);
                            __Pyx_GIVEREF(Py_None);
                            __pyx_cur_scope->__pyx_v_last_entry_date = Py_None;
                          }
                          __pyx_L38:;

                          /* "ws_package/controllers/activity_controller.py":1049
 *                         ActivityInterval.counter == self.last_count + 1
 *                     ).order_by(ActivityInterval.start_time.desc()).limit(1)
 *                     try:             # <<<<<<<<<<<<<<
 *                         result = await asyncio.wait_for(
 *                             session.scalars(query),
*/
                        }
                        __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                        __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                        goto __pyx_L36_try_end;
                        __pyx_L31_error:;
                        __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                        __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                        __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                        __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

                        /* "ws_package/controllers/activity_controller.py":1059
 *                         else:
 *                             last_entry_date = None
 *                     except asyncio.TimeoutError:             # <<<<<<<<<<<<<<
 *                         logger.error("Database query timed out after %ss in startup S3 check", DB_OPERATION_TIMEOUT)
 *                         last_entry_date = None
*/
                        __Pyx_ErrFetch(&__pyx_t_5, &__pyx_t_7, &__pyx_t_18);
                        __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1059, __pyx_L33_except_error)
                        __Pyx_GOTREF(__pyx_t_20);
                        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_TimeoutError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1059, __pyx_L33_except_error)
                        __Pyx_GOTREF(__pyx_t_4);
                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        __pyx_t_28 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_5, __pyx_t_4);
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_ErrRestore(__pyx_t_5, __pyx_t_7, __pyx_t_18);
                        __pyx_t_5 = 0; __pyx_t_7 = 0; __pyx_t_18 = 0;
                        if (__pyx_t_28) {
                          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._check_and_update_s3_on_startup", __pyx_clineno, __pyx_lineno, __pyx_filename);
                          if (__Pyx_GetException(&__pyx_t_18, &__pyx_t_7, &__pyx_t_5) < 0) __PYX_ERR(0, 1059, __pyx_L33_except_error)
                          __Pyx_XGOTREF(__pyx_t_18);
                          __Pyx_XGOTREF(__pyx_t_7);
                          __Pyx_XGOTREF(__pyx_t_5);

                          /* "ws_package/controllers/activity_controller.py":1060
 *                             last_entry_date = None
 *                     except asyncio.TimeoutError:
 *                         logger.error("Database query timed out after %ss in startup S3 check", DB_OPERATION_TIMEOUT)             # <<<<<<<<<<<<<<
 *                         last_entry_date = None
 *                     except Exception as e:
*/
                          __pyx_t_20 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1060, __pyx_L33_except_error)
                          __Pyx_GOTREF(__pyx_t_6);
                          __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1060, __pyx_L33_except_error)
                          __Pyx_GOTREF(__pyx_t_21);
                          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                          __pyx_t_6 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_DB_OPERATION_TIMEOUT); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1060, __pyx_L33_except_error)
                          __Pyx_GOTREF(__pyx_t_6);
                          __pyx_t_8 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_21))) {
                            __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_21);
                            assert(__pyx_t_20);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_21);
                            __Pyx_INCREF(__pyx_t_20);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_21, __pyx__function);
                            __pyx_t_8 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[3] = {__pyx_t_20, __pyx_mstate_global->__pyx_kp_u_Database_query_timed_out_after_s_2, __pyx_t_6};
                            __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_21, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                            __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                            if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1060, __pyx_L33_except_error)
                            __Pyx_GOTREF(__pyx_t_4);
                          }
                          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                          /* "ws_package/controllers/activity_controller.py":1061
 *                     except asyncio.TimeoutError:
 *                         logger.error("Database query timed out after %ss in startup S3 check", DB_OPERATION_TIMEOUT)
 *                         last_entry_date = None             # <<<<<<<<<<<<<<
 *                     except Exception as e:
 *                         logger.exception("Error getting last interval on startup: %s", e)
*/
                          __Pyx_INCREF(Py_None);
                          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_last_entry_date);
                          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_last_entry_date, Py_None);
                          __Pyx_GIVEREF(Py_None);
                          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                          goto __pyx_L32_exception_handled;
                        }

                        /* "ws_package/controllers/activity_controller.py":1062
 *                         logger.error("Database query timed out after %ss in startup S3 check", DB_OPERATION_TIMEOUT)
 *                         last_entry_date = None
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.exception("Error getting last interval on startup: %s", e)
 *                         last_entry_date = None
*/
                        __pyx_t_28 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                        if (__pyx_t_28) {
                          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._check_and_update_s3_on_startup", __pyx_clineno, __pyx_lineno, __pyx_filename);
                          if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_7, &__pyx_t_18) < 0) __PYX_ERR(0, 1062, __pyx_L33_except_error)
                          __Pyx_XGOTREF(__pyx_t_5);
                          __Pyx_XGOTREF(__pyx_t_7);
                          __Pyx_XGOTREF(__pyx_t_18);
                          __Pyx_INCREF(__pyx_t_7);
                          __Pyx_GIVEREF(__pyx_t_7);
                          __pyx_cur_scope->__pyx_v_e = __pyx_t_7;
                          /*try:*/ {

                            /* "ws_package/controllers/activity_controller.py":1063
 *                         last_entry_date = None
 *                     except Exception as e:
 *                         logger.exception("Error getting last interval on startup: %s", e)             # <<<<<<<<<<<<<<
 *                         last_entry_date = None
 * 
*/
                            __pyx_t_21 = NULL;
                            __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1063, __pyx_L46_error)
                            __Pyx_GOTREF(__pyx_t_6);
                            __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_exception); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1063, __pyx_L46_error)
                            __Pyx_GOTREF(__pyx_t_20);
                            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                            __pyx_t_8 = 1;
                            #if CYTHON_UNPACK_METHODS
                            if (unlikely(PyMethod_Check(__pyx_t_20))) {
                              __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_20);
                              assert(__pyx_t_21);
                              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_20);
                              __Pyx_INCREF(__pyx_t_21);
                              __Pyx_INCREF(__pyx__function);
                              __Pyx_DECREF_SET(__pyx_t_20, __pyx__function);
                              __pyx_t_8 = 0;
                            }
                            #endif
                            {
                              PyObject *__pyx_callargs[3] = {__pyx_t_21, __pyx_mstate_global->__pyx_kp_u_Error_getting_last_interval_on_s, __pyx_cur_scope->__pyx_v_e};
                              __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_20, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                              __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1063, __pyx_L46_error)
                              __Pyx_GOTREF(__pyx_t_4);
                            }
                            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                            /* "ws_package/controllers/activity_controller.py":1064
 *                     except Exception as e:
 *                         logger.exception("Error getting last interval on startup: %s", e)
 *                         last_entry_date = None             # <<<<<<<<<<<<<<
 * 
 *             # Check if it's a new day or STS credentials expired
*/
                            __Pyx_INCREF(Py_None);
                            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_last_entry_date);
                            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_last_entry_date, Py_None);
                            __Pyx_GIVEREF(Py_None);
                          }

                          /* "ws_package/controllers/activity_controller.py":1062
 *                         logger.error("Database query timed out after %ss in startup S3 check", DB_OPERATION_TIMEOUT)
 *                         last_entry_date = None
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.exception("Error getting last interval on startup: %s", e)
 *                         last_entry_date = None
*/
                          /*finally:*/ {
                            /*normal exit:*/{
                              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                              goto __pyx_L47;
                            }
                            __pyx_L46_error:;
                            /*exception exit:*/{
                              __Pyx_PyThreadState_assign
                              __pyx_t_31 = 0; __pyx_t_32 = 0; __pyx_t_33 = 0; __pyx_t_34 = 0; __pyx_t_35 = 0; __pyx_t_36 = 0;
                              __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                              __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                              __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                              __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                               __Pyx_ExceptionSwap(&__pyx_t_34, &__pyx_t_35, &__pyx_t_36);
                              if ( unlikely(__Pyx_GetException(&__pyx_t_31, &__pyx_t_32, &__pyx_t_33) < 0)) __Pyx_ErrFetch(&__pyx_t_31, &__pyx_t_32, &__pyx_t_33);
                              __Pyx_XGOTREF(__pyx_t_31);
                              __Pyx_XGOTREF(__pyx_t_32);
                              __Pyx_XGOTREF(__pyx_t_33);
                              __Pyx_XGOTREF(__pyx_t_34);
                              __Pyx_XGOTREF(__pyx_t_35);
                              __Pyx_XGOTREF(__pyx_t_36);
                              __pyx_t_28 = __pyx_lineno; __pyx_t_29 = __pyx_clineno; __pyx_t_30 = __pyx_filename;
                              {
                                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                              }
                              __Pyx_XGIVEREF(__pyx_t_34);
                              __Pyx_XGIVEREF(__pyx_t_35);
                              __Pyx_XGIVEREF(__pyx_t_36);
                              __Pyx_ExceptionReset(__pyx_t_34, __pyx_t_35, __pyx_t_36);
                              __Pyx_XGIVEREF(__pyx_t_31);
                              __Pyx_XGIVEREF(__pyx_t_32);
                              __Pyx_XGIVEREF(__pyx_t_33);
                              __Pyx_ErrRestore(__pyx_t_31, __pyx_t_32, __pyx_t_33);
                              __pyx_t_31 = 0; __pyx_t_32 = 0; __pyx_t_33 = 0; __pyx_t_34 = 0; __pyx_t_35 = 0; __pyx_t_36 = 0;
                              __pyx_lineno = __pyx_t_28; __pyx_clineno = __pyx_t_29; __pyx_filename = __pyx_t_30;
                              goto __pyx_L33_except_error;
                            }
                            __pyx_L47:;
                          }
                          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                          goto __pyx_L32_exception_handled;
                        }
                        goto __pyx_L33_except_error;

                        /* "ws_package/controllers/activity_controller.py":1049
 *                         ActivityInterval.counter == self.last_count + 1
 *                     ).order_by(ActivityInterval.start_time.desc()).limit(1)
 *                     try:             # <<<<<<<<<<<<<<
 *                         result = await asyncio.wait_for(
 *                             session.scalars(query),
*/
                        __pyx_L33_except_error:;
                        __Pyx_XGIVEREF(__pyx_t_24);
                        __Pyx_XGIVEREF(__pyx_t_25);
                        __Pyx_XGIVEREF(__pyx_t_26);
                        __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_25, __pyx_t_26);
                        goto __pyx_L25_error;
                        __pyx_L32_exception_handled:;
                        __Pyx_XGIVEREF(__pyx_t_24);
                        __Pyx_XGIVEREF(__pyx_t_25);
                        __Pyx_XGIVEREF(__pyx_t_26);
                        __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_25, __pyx_t_26);
                        __pyx_L36_try_end:;
                      }

                      /* "ws_package/controllers/activity_controller.py":1045
 * 
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     query = select(ActivityInterval).where(
 *                         ActivityInterval.counter == self.last_count + 1
*/
                    }
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                    goto __pyx_L30_try_end;
                    __pyx_L25_error:;
                    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                    /*except:*/ {
                      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._check_and_update_s3_on_startup", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_18, &__pyx_t_7, &__pyx_t_5) < 0) __PYX_ERR(0, 1045, __pyx_L27_except_error)
                      __Pyx_XGOTREF(__pyx_t_18);
                      __Pyx_XGOTREF(__pyx_t_7);
                      __Pyx_XGOTREF(__pyx_t_5);
                      __pyx_t_4 = PyTuple_Pack(3, __pyx_t_18, __pyx_t_7, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1045, __pyx_L27_except_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __pyx_t_26 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_4, NULL);
                      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 1045, __pyx_L27_except_error)
                      __Pyx_GOTREF(__pyx_t_26);
                      __pyx_t_14 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_26, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                      if (likely(__pyx_t_14 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_5);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_5;
                        __Pyx_XGIVEREF(__pyx_t_7);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_7;
                        __Pyx_XGIVEREF(__pyx_t_9);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_9;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_11 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_12 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_13 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_t_26);
                        __pyx_cur_scope->__pyx_t_14 = __pyx_t_26;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_SwapException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 3;
                        return __pyx_r;
                        __pyx_L55_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_5 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_5);
                        __pyx_t_7 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_7);
                        __pyx_t_9 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_9);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_11;
                        __pyx_cur_scope->__pyx_t_11 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_12;
                        __pyx_cur_scope->__pyx_t_12 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_13;
                        __pyx_cur_scope->__pyx_t_13 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        __pyx_t_26 = __pyx_cur_scope->__pyx_t_14;
                        __pyx_cur_scope->__pyx_t_14 = 0;
                        __Pyx_XGOTREF(__pyx_t_26);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1045, __pyx_L27_except_error)
                        __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                      } else if (likely(__pyx_t_14 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 1045, __pyx_L27_except_error)
                      }
                      __pyx_t_26 = __pyx_t_4;
                      __pyx_t_4 = 0;
                      __pyx_t_27 = __Pyx_PyObject_IsTrue(__pyx_t_26);
                      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                      if (__pyx_t_27 < (0)) __PYX_ERR(0, 1045, __pyx_L27_except_error)
                      __pyx_t_37 = (!__pyx_t_27);
                      if (unlikely(__pyx_t_37)) {
                        __Pyx_GIVEREF(__pyx_t_18);
                        __Pyx_GIVEREF(__pyx_t_7);
                        __Pyx_XGIVEREF(__pyx_t_5);
                        __Pyx_ErrRestoreWithState(__pyx_t_18, __pyx_t_7, __pyx_t_5);
                        __pyx_t_18 = 0;  __pyx_t_7 = 0;  __pyx_t_5 = 0; 
                        __PYX_ERR(0, 1045, __pyx_L27_except_error)
                      }
                      __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                      goto __pyx_L26_exception_handled;
                    }
                    __pyx_L27_except_error:;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
                    goto __pyx_L14_error;
                    __pyx_L26_exception_handled:;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
                    __pyx_L30_try_end:;
                  }
                }
                /*finally:*/ {
                  /*normal exit:*/{
                    if (__pyx_t_13) {
                      __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_mstate_global->__pyx_tuple[7], NULL);
                      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                      if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1045, __pyx_L14_error)
                      __Pyx_GOTREF(__pyx_t_17);
                      __pyx_t_14 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_17, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                      if (likely(__pyx_t_14 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_9);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 4;
                        return __pyx_r;
                        __pyx_L56_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_9);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1045, __pyx_L14_error)
                        __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
                      } else if (likely(__pyx_t_14 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_5 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 1045, __pyx_L14_error)
                      }
                      __pyx_t_17 = __pyx_t_5;
                      __pyx_t_5 = 0;
                      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                    }
                    goto __pyx_L24;
                  }
                  __pyx_L24:;
                }
                goto __pyx_L57;
                __pyx_L20_error:;
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                goto __pyx_L14_error;
                __pyx_L57:;
              }

              /* "ws_package/controllers/activity_controller.py":1044
 *             DB_OPERATION_TIMEOUT = 5.0
 * 
 *             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     query = select(ActivityInterval).where(
*/
            }
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            goto __pyx_L19_try_end;
            __pyx_L14_error:;
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
            __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
            __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
            __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            /*except:*/ {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._check_and_update_s3_on_startup", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_7, &__pyx_t_18) < 0) __PYX_ERR(0, 1044, __pyx_L16_except_error)
              __Pyx_XGOTREF(__pyx_t_5);
              __Pyx_XGOTREF(__pyx_t_7);
              __Pyx_XGOTREF(__pyx_t_18);
              __pyx_t_4 = PyTuple_Pack(3, __pyx_t_5, __pyx_t_7, __pyx_t_18); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1044, __pyx_L16_except_error)
              __Pyx_GOTREF(__pyx_t_4);
              __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_4, NULL);
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1044, __pyx_L16_except_error)
              __Pyx_GOTREF(__pyx_t_13);
              __pyx_t_37 = __Pyx_PyObject_IsTrue(__pyx_t_13);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              if (__pyx_t_37 < (0)) __PYX_ERR(0, 1044, __pyx_L16_except_error)
              __pyx_t_27 = (!__pyx_t_37);
              if (unlikely(__pyx_t_27)) {
                __Pyx_GIVEREF(__pyx_t_5);
                __Pyx_GIVEREF(__pyx_t_7);
                __Pyx_XGIVEREF(__pyx_t_18);
                __Pyx_ErrRestoreWithState(__pyx_t_5, __pyx_t_7, __pyx_t_18);
                __pyx_t_5 = 0;  __pyx_t_7 = 0;  __pyx_t_18 = 0; 
                __PYX_ERR(0, 1044, __pyx_L16_except_error)
              }
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
              __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
              goto __pyx_L15_exception_handled;
            }
            __pyx_L16_except_error:;
            __Pyx_XGIVEREF(__pyx_t_10);
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
            goto __pyx_L4_error;
            __pyx_L15_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_10);
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
            __pyx_L19_try_end:;
          }
        }
        /*finally:*/ {
          /*normal exit:*/{
            if (__pyx_t_9) {
              __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_mstate_global->__pyx_tuple[7], NULL);
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
              if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1044, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            }
            goto __pyx_L13;
          }
          __pyx_L13:;
        }
        goto __pyx_L61;
        __pyx_L10_error:;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L4_error;
        __pyx_L61:;
      }

      /* "ws_package/controllers/activity_controller.py":1067
 * 
 *             # Check if it's a new day or STS credentials expired
 *             current_date = datetime.datetime.now().date()             # <<<<<<<<<<<<<<
 *             credentials_stale = await self._s3_credentials_need_refresh(user_entity)
 *             if last_entry_date is None or last_entry_date != current_date or credentials_stale:
*/
      __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1067, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_20);
      __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1067, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_21);
      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
      __pyx_t_4 = __pyx_t_21;
      __Pyx_INCREF(__pyx_t_4);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
        __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1067, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
      }
      __pyx_t_7 = __pyx_t_5;
      __Pyx_INCREF(__pyx_t_7);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
        __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_date, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1067, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_18);
      }
      __Pyx_GIVEREF(__pyx_t_18);
      __pyx_cur_scope->__pyx_v_current_date = __pyx_t_18;
      __pyx_t_18 = 0;

      /* "ws_package/controllers/activity_controller.py":1068
 *             # Check if it's a new day or STS credentials expired
 *             current_date = datetime.datetime.now().date()
 *             credentials_stale = await self._s3_credentials_need_refresh(user_entity)             # <<<<<<<<<<<<<<
 *             if last_entry_date is None or last_entry_date != current_date or credentials_stale:
 *                 if credentials_stale:
*/
      __pyx_t_5 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_user_entity};
        __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_s3_credentials_need_refresh, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1068, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_18);
      }
      __pyx_t_14 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_18, &__pyx_r);
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      if (likely(__pyx_t_14 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
        __Pyx_XGIVEREF(__pyx_t_2);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
        __Pyx_XGIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 5;
        return __pyx_r;
        __pyx_L62_resume_from_await:;
        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_1);
        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_2);
        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_3);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1068, __pyx_L4_error)
        __pyx_t_18 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_18);
      } else if (likely(__pyx_t_14 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __pyx_t_18 = __pyx_r; __pyx_r = NULL;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 1068, __pyx_L4_error)
      }
      __Pyx_GIVEREF(__pyx_t_18);
      __pyx_cur_scope->__pyx_v_credentials_stale = __pyx_t_18;
      __pyx_t_18 = 0;

      /* "ws_package/controllers/activity_controller.py":1069
 *             current_date = datetime.datetime.now().date()
 *             credentials_stale = await self._s3_credentials_need_refresh(user_entity)
 *             if last_entry_date is None or last_entry_date != current_date or credentials_stale:             # <<<<<<<<<<<<<<
 *                 if credentials_stale:
 *                     logger.info("[STARTUP] STS credentials expired  refreshing S3 bucket config")
*/
      if (unlikely(!__pyx_cur_scope->__pyx_v_last_entry_date)) { __Pyx_RaiseUnboundLocalError("last_entry_date"); __PYX_ERR(0, 1069, __pyx_L4_error) }
      __pyx_t_37 = (__pyx_cur_scope->__pyx_v_last_entry_date == Py_None);
      if (!__pyx_t_37) {
      } else {
        __pyx_t_27 = __pyx_t_37;
        goto __pyx_L64_bool_binop_done;
      }
      if (unlikely(!__pyx_cur_scope->__pyx_v_last_entry_date)) { __Pyx_RaiseUnboundLocalError("last_entry_date"); __PYX_ERR(0, 1069, __pyx_L4_error) }
      __pyx_t_18 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_last_entry_date, __pyx_cur_scope->__pyx_v_current_date, Py_NE); __Pyx_XGOTREF(__pyx_t_18); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1069, __pyx_L4_error)
      __pyx_t_37 = __Pyx_PyObject_IsTrue(__pyx_t_18); if (unlikely((__pyx_t_37 < 0))) __PYX_ERR(0, 1069, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      if (!__pyx_t_37) {
      } else {
        __pyx_t_27 = __pyx_t_37;
        goto __pyx_L64_bool_binop_done;
      }
      __pyx_t_37 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_credentials_stale); if (unlikely((__pyx_t_37 < 0))) __PYX_ERR(0, 1069, __pyx_L4_error)
      __pyx_t_27 = __pyx_t_37;
      __pyx_L64_bool_binop_done:;
      if (__pyx_t_27) {

        /* "ws_package/controllers/activity_controller.py":1070
 *             credentials_stale = await self._s3_credentials_need_refresh(user_entity)
 *             if last_entry_date is None or last_entry_date != current_date or credentials_stale:
 *                 if credentials_stale:             # <<<<<<<<<<<<<<
 *                     logger.info("[STARTUP] STS credentials expired  refreshing S3 bucket config")
 *                 elif last_entry_date is None or last_entry_date != current_date:
*/
        __pyx_t_27 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_credentials_stale); if (unlikely((__pyx_t_27 < 0))) __PYX_ERR(0, 1070, __pyx_L4_error)
        if (__pyx_t_27) {

          /* "ws_package/controllers/activity_controller.py":1071
 *             if last_entry_date is None or last_entry_date != current_date or credentials_stale:
 *                 if credentials_stale:
 *                     logger.info("[STARTUP] STS credentials expired  refreshing S3 bucket config")             # <<<<<<<<<<<<<<
 *                 elif last_entry_date is None or last_entry_date != current_date:
 *                     logger.info("[STARTUP] New day detected (last: %s, current: %s) - updating S3 bucket config", last_entry_date, current_date)
*/
          __pyx_t_5 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1071, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1071, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_21);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_21))) {
            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_21);
            assert(__pyx_t_5);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_21);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_21, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_STARTUP_STS_credentials_expired};
            __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_21, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
            if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1071, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_18);
          }
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

          /* "ws_package/controllers/activity_controller.py":1070
 *             credentials_stale = await self._s3_credentials_need_refresh(user_entity)
 *             if last_entry_date is None or last_entry_date != current_date or credentials_stale:
 *                 if credentials_stale:             # <<<<<<<<<<<<<<
 *                     logger.info("[STARTUP] STS credentials expired  refreshing S3 bucket config")
 *                 elif last_entry_date is None or last_entry_date != current_date:
*/
          goto __pyx_L67;
        }

        /* "ws_package/controllers/activity_controller.py":1072
 *                 if credentials_stale:
 *                     logger.info("[STARTUP] STS credentials expired  refreshing S3 bucket config")
 *                 elif last_entry_date is None or last_entry_date != current_date:             # <<<<<<<<<<<<<<
 *                     logger.info("[STARTUP] New day detected (last: %s, current: %s) - updating S3 bucket config", last_entry_date, current_date)
 *                 await self.ensure_s3_credentials_fresh(user_entity)
*/
        if (unlikely(!__pyx_cur_scope->__pyx_v_last_entry_date)) { __Pyx_RaiseUnboundLocalError("last_entry_date"); __PYX_ERR(0, 1072, __pyx_L4_error) }
        __pyx_t_37 = (__pyx_cur_scope->__pyx_v_last_entry_date == Py_None);
        if (!__pyx_t_37) {
        } else {
          __pyx_t_27 = __pyx_t_37;
          goto __pyx_L68_bool_binop_done;
        }
        if (unlikely(!__pyx_cur_scope->__pyx_v_last_entry_date)) { __Pyx_RaiseUnboundLocalError("last_entry_date"); __PYX_ERR(0, 1072, __pyx_L4_error) }
        __pyx_t_18 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_last_entry_date, __pyx_cur_scope->__pyx_v_current_date, Py_NE); __Pyx_XGOTREF(__pyx_t_18); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1072, __pyx_L4_error)
        __pyx_t_37 = __Pyx_PyObject_IsTrue(__pyx_t_18); if (unlikely((__pyx_t_37 < 0))) __PYX_ERR(0, 1072, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        __pyx_t_27 = __pyx_t_37;
        __pyx_L68_bool_binop_done:;
        if (__pyx_t_27) {

          /* "ws_package/controllers/activity_controller.py":1073
 *                     logger.info("[STARTUP] STS credentials expired  refreshing S3 bucket config")
 *                 elif last_entry_date is None or last_entry_date != current_date:
 *                     logger.info("[STARTUP] New day detected (last: %s, current: %s) - updating S3 bucket config", last_entry_date, current_date)             # <<<<<<<<<<<<<<
 *                 await self.ensure_s3_credentials_fresh(user_entity)
 *             else:
*/
          __pyx_t_21 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1073, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1073, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_cur_scope->__pyx_v_last_entry_date)) { __Pyx_RaiseUnboundLocalError("last_entry_date"); __PYX_ERR(0, 1073, __pyx_L4_error) }
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_7))) {
            __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_7);
            assert(__pyx_t_21);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
            __Pyx_INCREF(__pyx_t_21);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[4] = {__pyx_t_21, __pyx_mstate_global->__pyx_kp_u_STARTUP_New_day_detected_last_s, __pyx_cur_scope->__pyx_v_last_entry_date, __pyx_cur_scope->__pyx_v_current_date};
            __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1073, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_18);
          }
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

          /* "ws_package/controllers/activity_controller.py":1072
 *                 if credentials_stale:
 *                     logger.info("[STARTUP] STS credentials expired  refreshing S3 bucket config")
 *                 elif last_entry_date is None or last_entry_date != current_date:             # <<<<<<<<<<<<<<
 *                     logger.info("[STARTUP] New day detected (last: %s, current: %s) - updating S3 bucket config", last_entry_date, current_date)
 *                 await self.ensure_s3_credentials_fresh(user_entity)
*/
        }
        __pyx_L67:;

        /* "ws_package/controllers/activity_controller.py":1074
 *                 elif last_entry_date is None or last_entry_date != current_date:
 *                     logger.info("[STARTUP] New day detected (last: %s, current: %s) - updating S3 bucket config", last_entry_date, current_date)
 *                 await self.ensure_s3_credentials_fresh(user_entity)             # <<<<<<<<<<<<<<
 *             else:
 *                 logger.debug("[STARTUP] Same day (last: %s, current: %s) - no S3 bucket update needed", last_entry_date, current_date)
*/
        __pyx_t_7 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_7);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_cur_scope->__pyx_v_user_entity};
          __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_ensure_s3_credentials_fresh, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1074, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_18);
        }
        __pyx_t_14 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_18, &__pyx_r);
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        if (likely(__pyx_t_14 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_1);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
          __Pyx_XGIVEREF(__pyx_t_2);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
          __Pyx_XGIVEREF(__pyx_t_3);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 6;
          return __pyx_r;
          __pyx_L70_resume_from_await:;
          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_1);
          __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_2);
          __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_3);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1074, __pyx_L4_error)
        } else if (likely(__pyx_t_14 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_DECREF(__pyx_r); __pyx_r = 0;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 1074, __pyx_L4_error)
        }

        /* "ws_package/controllers/activity_controller.py":1069
 *             current_date = datetime.datetime.now().date()
 *             credentials_stale = await self._s3_credentials_need_refresh(user_entity)
 *             if last_entry_date is None or last_entry_date != current_date or credentials_stale:             # <<<<<<<<<<<<<<
 *                 if credentials_stale:
 *                     logger.info("[STARTUP] STS credentials expired  refreshing S3 bucket config")
*/
        goto __pyx_L63;
      }

      /* "ws_package/controllers/activity_controller.py":1076
 *                 await self.ensure_s3_credentials_fresh(user_entity)
 *             else:
 *                 logger.debug("[STARTUP] Same day (last: %s, current: %s) - no S3 bucket update needed", last_entry_date, current_date)             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             logger.error("[STARTUP] Error checking/updating S3 bucket on startup: %s", e, exc_info=True)
*/
      /*else*/ {
        __pyx_t_7 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1076, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_21);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1076, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
        if (unlikely(!__pyx_cur_scope->__pyx_v_last_entry_date)) { __Pyx_RaiseUnboundLocalError("last_entry_date"); __PYX_ERR(0, 1076, __pyx_L4_error) }
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
          assert(__pyx_t_7);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[4] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_STARTUP_Same_day_last_s_current, __pyx_cur_scope->__pyx_v_last_entry_date, __pyx_cur_scope->__pyx_v_current_date};
          __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1076, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_18);
        }
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      }
      __pyx_L63:;

      /* "ws_package/controllers/activity_controller.py":1040
 *         Called when app starts.
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # Use centralized read lock for database read operations
 *             DB_OPERATION_TIMEOUT = 5.0
*/
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L9_try_end;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "ws_package/controllers/activity_controller.py":1077
 *             else:
 *                 logger.debug("[STARTUP] Same day (last: %s, current: %s) - no S3 bucket update needed", last_entry_date, current_date)
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("[STARTUP] Error checking/updating S3 bucket on startup: %s", e, exc_info=True)
 * 
*/
    __pyx_t_29 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_29) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._check_and_update_s3_on_startup", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_18, &__pyx_t_5, &__pyx_t_7) < 0) __PYX_ERR(0, 1077, __pyx_L6_except_error)
      __Pyx_XGOTREF(__pyx_t_18);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":1078
 *                 logger.debug("[STARTUP] Same day (last: %s, current: %s) - no S3 bucket update needed", last_entry_date, current_date)
 *         except Exception as e:
 *             logger.error("[STARTUP] Error checking/updating S3 bucket on startup: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *     async def _check_and_update_s3_on_wake(self, user_entity):
*/
        __pyx_t_4 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1078, __pyx_L76_error)
        __Pyx_GOTREF(__pyx_t_20);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1078, __pyx_L76_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
          assert(__pyx_t_4);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_STARTUP_Error_checking_updating, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_20 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1078, __pyx_L76_error)
          __Pyx_GOTREF(__pyx_t_20);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_20, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 1078, __pyx_L76_error)
          __pyx_t_21 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_20);
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1078, __pyx_L76_error)
          __Pyx_GOTREF(__pyx_t_21);
        }
        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
      }

      /* "ws_package/controllers/activity_controller.py":1077
 *             else:
 *                 logger.debug("[STARTUP] Same day (last: %s, current: %s) - no S3 bucket update needed", last_entry_date, current_date)
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("[STARTUP] Error checking/updating S3 bucket on startup: %s", e, exc_info=True)
 * 
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          goto __pyx_L77;
        }
        __pyx_L76_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_9 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_13 = 0; __pyx_t_17 = 0;
          __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
          __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
          __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
          __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_13, &__pyx_t_17);
          if ( unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_12, &__pyx_t_11) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_12, &__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_9);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_17);
          __pyx_t_29 = __pyx_lineno; __pyx_t_28 = __pyx_clineno; __pyx_t_38 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_13, __pyx_t_17);
          __Pyx_XGIVEREF(__pyx_t_9);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_ErrRestore(__pyx_t_9, __pyx_t_12, __pyx_t_11);
          __pyx_t_9 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_13 = 0; __pyx_t_17 = 0;
          __pyx_lineno = __pyx_t_29; __pyx_clineno = __pyx_t_28; __pyx_filename = __pyx_t_38;
          goto __pyx_L6_except_error;
        }
        __pyx_L77:;
      }
      __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L5_exception_handled;
    }
    goto __pyx_L6_except_error;

    /* "ws_package/controllers/activity_controller.py":1040
 *         Called when app starts.
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # Use centralized read lock for database read operations
 *             DB_OPERATION_TIMEOUT = 5.0
*/
    __pyx_L6_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L5_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    __pyx_L9_try_end:;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":1035
 *             logger.error("[WAKE] Error handling S3 bucket update on wake: %s", e, exc_info=True)
 * 
 *     async def _check_and_update_s3_on_startup(self, user_entity):             # <<<<<<<<<<<<<<
 *         """
 *         Check if it's a new day on app startup and update S3 bucket config if needed.
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_XDECREF(__pyx_t_23);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("_check_and_update_s3_on_startup", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_58generator8(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":1080
 *             logger.error("[STARTUP] Error checking/updating S3 bucket on startup: %s", e, exc_info=True)
 * 
 *     async def _check_and_update_s3_on_wake(self, user_entity):             # <<<<<<<<<<<<<<
 *         """
 *         Check if it's a new day and update S3 bucket config if needed.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_57_check_and_update_s3_on_wake(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_56_check_and_update_s3_on_wake, "\n        Check if it's a new day and update S3 bucket config if needed.\n        Called on app wake from sleep.\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_57_check_and_update_s3_on_wake = {"_check_and_update_s3_on_wake", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_57_check_and_update_s3_on_wake, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_56_check_and_update_s3_on_wake};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_57_check_and_update_s3_on_wake(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_user_entity = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_check_and_update_s3_on_wake (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_user_entity,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 1080, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1080, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1080, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_check_and_update_s3_on_wake", 0) < (0)) __PYX_ERR(0, 1080, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_check_and_update_s3_on_wake", 1, 2, 2, i); __PYX_ERR(0, 1080, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1080, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1080, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_user_entity = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_check_and_update_s3_on_wake", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 1080, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._check_and_update_s3_on_wake", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_56_check_and_update_s3_on_wake(__pyx_self, __pyx_v_self, __pyx_v_user_entity);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_56_check_and_update_s3_on_wake(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_check_and_update_s3_on_wake", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1080, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_user_entity = __pyx_v_user_entity;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_user_entity);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_user_entity);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_58generator8, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[8]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_check_and_update_s3_on_wake, __pyx_mstate_global->__pyx_n_u_ActivityController__check_and_up_2, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 1080, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._check_and_update_s3_on_wake", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_58generator8(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  size_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  __Pyx_PySendResult __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  PyObject *__pyx_t_26 = NULL;
  int __pyx_t_27;
  int __pyx_t_28;
  int __pyx_t_29;
  char const *__pyx_t_30;
  PyObject *__pyx_t_31 = NULL;
  PyObject *__pyx_t_32 = NULL;
  PyObject *__pyx_t_33 = NULL;
  PyObject *__pyx_t_34 = NULL;
  PyObject *__pyx_t_35 = NULL;
  PyObject *__pyx_t_36 = NULL;
  int __pyx_t_37;
  char const *__pyx_t_38;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_check_and_update_s3_on_wake", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L21_resume_from_await;
    case 2: goto __pyx_L37_resume_from_await;
    case 3: goto __pyx_L55_resume_from_await;
    case 4: goto __pyx_L56_resume_from_await;
    case 5: goto __pyx_L62_resume_from_await;
    case 6: goto __pyx_L70_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 1080, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":1085
 *         Called on app wake from sleep.
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # Use centralized read lock for database read operations
 *             DB_OPERATION_TIMEOUT = 5.0
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":1087
 *         try:
 *             # Use centralized read lock for database read operations
 *             DB_OPERATION_TIMEOUT = 5.0             # <<<<<<<<<<<<<<
 * 
 *             with db_lock_manager.read_lock():
*/
      __pyx_cur_scope->__pyx_v_DB_OPERATION_TIMEOUT = 5.0;

      /* "ws_package/controllers/activity_controller.py":1089
 *             DB_OPERATION_TIMEOUT = 5.0
 * 
 *             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     query = select(ActivityInterval).where(
*/
      /*with:*/ {
        __pyx_t_5 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1089, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1089, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
          assert(__pyx_t_5);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1089, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __pyx_t_9 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1089, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_5 = NULL;
        __pyx_t_6 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1089, __pyx_L10_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (likely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
          assert(__pyx_t_5);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
          __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1089, __pyx_L10_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        /*try:*/ {
          {
            __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
            __Pyx_XGOTREF(__pyx_t_10);
            __Pyx_XGOTREF(__pyx_t_11);
            __Pyx_XGOTREF(__pyx_t_12);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":1090
 * 
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     query = select(ActivityInterval).where(
 *                         ActivityInterval.counter == self.last_count + 1
*/
              /*with:*/ {
                __pyx_t_7 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1090, __pyx_L14_error)
                __Pyx_GOTREF(__pyx_t_6);
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_6))) {
                  __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
                  assert(__pyx_t_7);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                  __Pyx_INCREF(__pyx_t_7);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
                  __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1090, __pyx_L14_error)
                  __Pyx_GOTREF(__pyx_t_4);
                }
                __pyx_t_13 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1090, __pyx_L14_error)
                __Pyx_GOTREF(__pyx_t_13);
                __pyx_t_7 = NULL;
                __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1090, __pyx_L20_error)
                __Pyx_GOTREF(__pyx_t_5);
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (likely(PyMethod_Check(__pyx_t_5))) {
                  __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
                  assert(__pyx_t_7);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                  __Pyx_INCREF(__pyx_t_7);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
                  __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1090, __pyx_L20_error)
                  __Pyx_GOTREF(__pyx_t_6);
                }
                __pyx_t_14 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_6, &__pyx_r);
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                if (likely(__pyx_t_14 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_1);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                  __Pyx_XGIVEREF(__pyx_t_2);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                  __Pyx_XGIVEREF(__pyx_t_3);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                  __Pyx_XGIVEREF(__pyx_t_4);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
                  __Pyx_XGIVEREF(__pyx_t_9);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_9;
                  __Pyx_XGIVEREF(__pyx_t_10);
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_10;
                  __Pyx_XGIVEREF(__pyx_t_11);
                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_11;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 1;
                  return __pyx_r;
                  __pyx_L21_resume_from_await:;
                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_1);
                  __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_2);
                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_3);
                  __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_4);
                  __pyx_t_9 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_9);
                  __pyx_t_10 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = 0;
                  __Pyx_XGOTREF(__pyx_t_10);
                  __pyx_t_11 = __pyx_cur_scope->__pyx_t_6;
                  __pyx_cur_scope->__pyx_t_6 = 0;
                  __Pyx_XGOTREF(__pyx_t_11);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_7;
                  __pyx_cur_scope->__pyx_t_7 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_8;
                  __pyx_cur_scope->__pyx_t_8 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1090, __pyx_L20_error)
                  __pyx_t_6 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_6);
                } else if (likely(__pyx_t_14 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __pyx_t_6 = __pyx_r; __pyx_r = NULL;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 1090, __pyx_L20_error)
                }
                __pyx_t_5 = __pyx_t_6;
                __pyx_t_6 = 0;
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                /*try:*/ {
                  {
                    __Pyx_ExceptionSave(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
                    __Pyx_XGOTREF(__pyx_t_15);
                    __Pyx_XGOTREF(__pyx_t_16);
                    __Pyx_XGOTREF(__pyx_t_17);
                    /*try:*/ {
                      __Pyx_GIVEREF(__pyx_t_5);
                      __pyx_cur_scope->__pyx_v_session = __pyx_t_5;
                      __pyx_t_5 = 0;

                      /* "ws_package/controllers/activity_controller.py":1091
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:
 *                     query = select(ActivityInterval).where(             # <<<<<<<<<<<<<<
 *                         ActivityInterval.counter == self.last_count + 1
 *                     ).order_by(ActivityInterval.start_time.desc()).limit(1)
*/
                      __pyx_t_21 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 1091, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 1091, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_23);
                      __pyx_t_8 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_22))) {
                        __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_22);
                        assert(__pyx_t_21);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_22);
                        __Pyx_INCREF(__pyx_t_21);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_22, __pyx__function);
                        __pyx_t_8 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_21, __pyx_t_23};
                        __pyx_t_20 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_22, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1091, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_20);
                      }
                      __pyx_t_19 = __pyx_t_20;
                      __Pyx_INCREF(__pyx_t_19);

                      /* "ws_package/controllers/activity_controller.py":1092
 *                 async with async_session() as session:
 *                     query = select(ActivityInterval).where(
 *                         ActivityInterval.counter == self.last_count + 1             # <<<<<<<<<<<<<<
 *                     ).order_by(ActivityInterval.start_time.desc()).limit(1)
 *                     try:
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 1092, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 1092, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_23);
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                      __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 1092, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __pyx_t_21 = __Pyx_PyLong_AddObjC(__pyx_t_22, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1092, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                      __pyx_t_22 = PyObject_RichCompare(__pyx_t_23, __pyx_t_21, Py_EQ); __Pyx_XGOTREF(__pyx_t_22); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 1092, __pyx_L25_error)
                      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_19, __pyx_t_22};
                        __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1091, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_18);
                      }
                      __pyx_t_7 = __pyx_t_18;
                      __Pyx_INCREF(__pyx_t_7);

                      /* "ws_package/controllers/activity_controller.py":1093
 *                     query = select(ActivityInterval).where(
 *                         ActivityInterval.counter == self.last_count + 1
 *                     ).order_by(ActivityInterval.start_time.desc()).limit(1)             # <<<<<<<<<<<<<<
 *                     try:
 *                         result = await asyncio.wait_for(
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1093, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_19);
                      __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1093, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                      __pyx_t_22 = __pyx_t_21;
                      __Pyx_INCREF(__pyx_t_22);
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_22, NULL};
                        __pyx_t_20 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_desc, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1093, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_20);
                      }
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_t_20};
                        __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_order_by, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1093, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_6);
                      }
                      __pyx_t_4 = __pyx_t_6;
                      __Pyx_INCREF(__pyx_t_4);
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_int_1};
                        __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_limit, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1093, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_5);
                      }
                      __Pyx_GIVEREF(__pyx_t_5);
                      __pyx_cur_scope->__pyx_v_query = __pyx_t_5;
                      __pyx_t_5 = 0;

                      /* "ws_package/controllers/activity_controller.py":1094
 *                         ActivityInterval.counter == self.last_count + 1
 *                     ).order_by(ActivityInterval.start_time.desc()).limit(1)
 *                     try:             # <<<<<<<<<<<<<<
 *                         result = await asyncio.wait_for(
 *                             session.scalars(query),
*/
                      {
                        __Pyx_ExceptionSave(&__pyx_t_24, &__pyx_t_25, &__pyx_t_26);
                        __Pyx_XGOTREF(__pyx_t_24);
                        __Pyx_XGOTREF(__pyx_t_25);
                        __Pyx_XGOTREF(__pyx_t_26);
                        /*try:*/ {

                          /* "ws_package/controllers/activity_controller.py":1095
 *                     ).order_by(ActivityInterval.start_time.desc()).limit(1)
 *                     try:
 *                         result = await asyncio.wait_for(             # <<<<<<<<<<<<<<
 *                             session.scalars(query),
 *                             timeout=DB_OPERATION_TIMEOUT
*/
                          __pyx_t_6 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1095, __pyx_L31_error)
                          __Pyx_GOTREF(__pyx_t_4);
                          __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_wait_for); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1095, __pyx_L31_error)
                          __Pyx_GOTREF(__pyx_t_18);
                          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                          /* "ws_package/controllers/activity_controller.py":1096
 *                     try:
 *                         result = await asyncio.wait_for(
 *                             session.scalars(query),             # <<<<<<<<<<<<<<
 *                             timeout=DB_OPERATION_TIMEOUT
 *                         )
*/
                          __pyx_t_20 = __pyx_cur_scope->__pyx_v_session;
                          __Pyx_INCREF(__pyx_t_20);
                          __pyx_t_8 = 0;
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_20, __pyx_cur_scope->__pyx_v_query};
                            __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalars, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                            if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1096, __pyx_L31_error)
                            __Pyx_GOTREF(__pyx_t_4);
                          }

                          /* "ws_package/controllers/activity_controller.py":1097
 *                         result = await asyncio.wait_for(
 *                             session.scalars(query),
 *                             timeout=DB_OPERATION_TIMEOUT             # <<<<<<<<<<<<<<
 *                         )
 *                         last_entry = result.first()
*/
                          __pyx_t_20 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_DB_OPERATION_TIMEOUT); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1097, __pyx_L31_error)
                          __Pyx_GOTREF(__pyx_t_20);
                          __pyx_t_8 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_18))) {
                            __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_18);
                            assert(__pyx_t_6);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_18);
                            __Pyx_INCREF(__pyx_t_6);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_18, __pyx__function);
                            __pyx_t_8 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_6, __pyx_t_4};
                            __pyx_t_7 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1095, __pyx_L31_error)
                            __Pyx_GOTREF(__pyx_t_7);
                            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_timeout, __pyx_t_20, __pyx_t_7, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 1095, __pyx_L31_error)
                            __pyx_t_5 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_18, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_7);
                            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                            __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1095, __pyx_L31_error)
                            __Pyx_GOTREF(__pyx_t_5);
                          }
                          __pyx_t_14 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
                          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                          if (likely(__pyx_t_14 == PYGEN_NEXT)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_XGIVEREF(__pyx_t_1);
                            __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                            __Pyx_XGIVEREF(__pyx_t_2);
                            __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                            __Pyx_XGIVEREF(__pyx_t_3);
                            __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                            __Pyx_XGIVEREF(__pyx_t_9);
                            __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
                            __Pyx_XGIVEREF(__pyx_t_10);
                            __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                            __Pyx_XGIVEREF(__pyx_t_11);
                            __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
                            __Pyx_XGIVEREF(__pyx_t_12);
                            __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
                            __Pyx_XGIVEREF(__pyx_t_13);
                            __pyx_cur_scope->__pyx_t_7 = __pyx_t_13;
                            __Pyx_XGIVEREF(__pyx_t_15);
                            __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                            __Pyx_XGIVEREF(__pyx_t_16);
                            __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                            __Pyx_XGIVEREF(__pyx_t_17);
                            __pyx_cur_scope->__pyx_t_10 = __pyx_t_17;
                            __Pyx_XGIVEREF(__pyx_t_24);
                            __pyx_cur_scope->__pyx_t_11 = __pyx_t_24;
                            __Pyx_XGIVEREF(__pyx_t_25);
                            __pyx_cur_scope->__pyx_t_12 = __pyx_t_25;
                            __Pyx_XGIVEREF(__pyx_t_26);
                            __pyx_cur_scope->__pyx_t_13 = __pyx_t_26;
                            __Pyx_XGIVEREF(__pyx_r);
                            __Pyx_RefNannyFinishContext();
                            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                            /* return from generator, awaiting value */
                            __pyx_generator->resume_label = 2;
                            return __pyx_r;
                            __pyx_L37_resume_from_await:;
                            __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                            __pyx_cur_scope->__pyx_t_0 = 0;
                            __Pyx_XGOTREF(__pyx_t_1);
                            __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                            __pyx_cur_scope->__pyx_t_1 = 0;
                            __Pyx_XGOTREF(__pyx_t_2);
                            __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                            __pyx_cur_scope->__pyx_t_2 = 0;
                            __Pyx_XGOTREF(__pyx_t_3);
                            __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
                            __pyx_cur_scope->__pyx_t_3 = 0;
                            __Pyx_XGOTREF(__pyx_t_9);
                            __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                            __pyx_cur_scope->__pyx_t_4 = 0;
                            __Pyx_XGOTREF(__pyx_t_10);
                            __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
                            __pyx_cur_scope->__pyx_t_5 = 0;
                            __Pyx_XGOTREF(__pyx_t_11);
                            __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
                            __pyx_cur_scope->__pyx_t_6 = 0;
                            __Pyx_XGOTREF(__pyx_t_12);
                            __pyx_t_13 = __pyx_cur_scope->__pyx_t_7;
                            __pyx_cur_scope->__pyx_t_7 = 0;
                            __Pyx_XGOTREF(__pyx_t_13);
                            __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                            __pyx_cur_scope->__pyx_t_8 = 0;
                            __Pyx_XGOTREF(__pyx_t_15);
                            __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                            __pyx_cur_scope->__pyx_t_9 = 0;
                            __Pyx_XGOTREF(__pyx_t_16);
                            __pyx_t_17 = __pyx_cur_scope->__pyx_t_10;
                            __pyx_cur_scope->__pyx_t_10 = 0;
                            __Pyx_XGOTREF(__pyx_t_17);
                            __pyx_t_24 = __pyx_cur_scope->__pyx_t_11;
                            __pyx_cur_scope->__pyx_t_11 = 0;
                            __Pyx_XGOTREF(__pyx_t_24);
                            __pyx_t_25 = __pyx_cur_scope->__pyx_t_12;
                            __pyx_cur_scope->__pyx_t_12 = 0;
                            __Pyx_XGOTREF(__pyx_t_25);
                            __pyx_t_26 = __pyx_cur_scope->__pyx_t_13;
                            __pyx_cur_scope->__pyx_t_13 = 0;
                            __Pyx_XGOTREF(__pyx_t_26);
                            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1095, __pyx_L31_error)
                            __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
                          } else if (likely(__pyx_t_14 == PYGEN_RETURN)) {
                            __Pyx_GOTREF(__pyx_r);
                            __pyx_t_5 = __pyx_r; __pyx_r = NULL;
                          } else {
                            __Pyx_XGOTREF(__pyx_r);
                            __PYX_ERR(0, 1095, __pyx_L31_error)
                          }
                          __Pyx_GIVEREF(__pyx_t_5);
                          __pyx_cur_scope->__pyx_v_result = __pyx_t_5;
                          __pyx_t_5 = 0;

                          /* "ws_package/controllers/activity_controller.py":1099
 *                             timeout=DB_OPERATION_TIMEOUT
 *                         )
 *                         last_entry = result.first()             # <<<<<<<<<<<<<<
 *                         if last_entry:
 *                             last_entry_date = last_entry.start_time.date()
*/
                          __pyx_t_18 = __pyx_cur_scope->__pyx_v_result;
                          __Pyx_INCREF(__pyx_t_18);
                          __pyx_t_8 = 0;
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_18, NULL};
                            __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_first, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1099, __pyx_L31_error)
                            __Pyx_GOTREF(__pyx_t_5);
                          }
                          __Pyx_GIVEREF(__pyx_t_5);
                          __pyx_cur_scope->__pyx_v_last_entry = __pyx_t_5;
                          __pyx_t_5 = 0;

                          /* "ws_package/controllers/activity_controller.py":1100
 *                         )
 *                         last_entry = result.first()
 *                         if last_entry:             # <<<<<<<<<<<<<<
 *                             last_entry_date = last_entry.start_time.date()
 *                         else:
*/
                          __pyx_t_27 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_entry); if (unlikely((__pyx_t_27 < 0))) __PYX_ERR(0, 1100, __pyx_L31_error)
                          if (__pyx_t_27) {

                            /* "ws_package/controllers/activity_controller.py":1101
 *                         last_entry = result.first()
 *                         if last_entry:
 *                             last_entry_date = last_entry.start_time.date()             # <<<<<<<<<<<<<<
 *                         else:
 *                             last_entry_date = None
*/
                            __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_entry, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1101, __pyx_L31_error)
                            __Pyx_GOTREF(__pyx_t_7);
                            __pyx_t_18 = __pyx_t_7;
                            __Pyx_INCREF(__pyx_t_18);
                            __pyx_t_8 = 0;
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_18, NULL};
                              __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_date, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                              if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1101, __pyx_L31_error)
                              __Pyx_GOTREF(__pyx_t_5);
                            }
                            __Pyx_GIVEREF(__pyx_t_5);
                            __pyx_cur_scope->__pyx_v_last_entry_date = __pyx_t_5;
                            __pyx_t_5 = 0;

                            /* "ws_package/controllers/activity_controller.py":1100
 *                         )
 *                         last_entry = result.first()
 *                         if last_entry:             # <<<<<<<<<<<<<<
 *                             last_entry_date = last_entry.start_time.date()
 *                         else:
*/
                            goto __pyx_L38;
                          }

                          /* "ws_package/controllers/activity_controller.py":1103
 *                             last_entry_date = last_entry.start_time.date()
 *                         else:
 *                             last_entry_date = None             # <<<<<<<<<<<<<<
 *                     except asyncio.TimeoutError:
 *                         logger.error("Database query timed out after %ss in wake S3 check", DB_OPERATION_TIMEOUT)
*/
                          /*else*/ {
                            __Pyx_INCREF(Py_None);
                            __Pyx_GIVEREF(Py_None);
                            __pyx_cur_scope->__pyx_v_last_entry_date = Py_None;
                          }
                          __pyx_L38:;

                          /* "ws_package/controllers/activity_controller.py":1094
 *                         ActivityInterval.counter == self.last_count + 1
 *                     ).order_by(ActivityInterval.start_time.desc()).limit(1)
 *                     try:             # <<<<<<<<<<<<<<
 *                         result = await asyncio.wait_for(
 *                             session.scalars(query),
*/
                        }
                        __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                        __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                        goto __pyx_L36_try_end;
                        __pyx_L31_error:;
                        __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                        __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                        __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                        __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

                        /* "ws_package/controllers/activity_controller.py":1104
 *                         else:
 *                             last_entry_date = None
 *                     except asyncio.TimeoutError:             # <<<<<<<<<<<<<<
 *                         logger.error("Database query timed out after %ss in wake S3 check", DB_OPERATION_TIMEOUT)
 *                         last_entry_date = None
*/
                        __Pyx_ErrFetch(&__pyx_t_5, &__pyx_t_7, &__pyx_t_18);
                        __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1104, __pyx_L33_except_error)
                        __Pyx_GOTREF(__pyx_t_20);
                        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_TimeoutError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1104, __pyx_L33_except_error)
                        __Pyx_GOTREF(__pyx_t_4);
                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        __pyx_t_28 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_5, __pyx_t_4);
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_ErrRestore(__pyx_t_5, __pyx_t_7, __pyx_t_18);
                        __pyx_t_5 = 0; __pyx_t_7 = 0; __pyx_t_18 = 0;
                        if (__pyx_t_28) {
                          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._check_and_update_s3_on_wake", __pyx_clineno, __pyx_lineno, __pyx_filename);
                          if (__Pyx_GetException(&__pyx_t_18, &__pyx_t_7, &__pyx_t_5) < 0) __PYX_ERR(0, 1104, __pyx_L33_except_error)
                          __Pyx_XGOTREF(__pyx_t_18);
                          __Pyx_XGOTREF(__pyx_t_7);
                          __Pyx_XGOTREF(__pyx_t_5);

                          /* "ws_package/controllers/activity_controller.py":1105
 *                             last_entry_date = None
 *                     except asyncio.TimeoutError:
 *                         logger.error("Database query timed out after %ss in wake S3 check", DB_OPERATION_TIMEOUT)             # <<<<<<<<<<<<<<
 *                         last_entry_date = None
 *                     except Exception as e:
*/
                          __pyx_t_20 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1105, __pyx_L33_except_error)
                          __Pyx_GOTREF(__pyx_t_6);
                          __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1105, __pyx_L33_except_error)
                          __Pyx_GOTREF(__pyx_t_21);
                          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                          __pyx_t_6 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_DB_OPERATION_TIMEOUT); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1105, __pyx_L33_except_error)
                          __Pyx_GOTREF(__pyx_t_6);
                          __pyx_t_8 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_21))) {
                            __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_21);
                            assert(__pyx_t_20);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_21);
                            __Pyx_INCREF(__pyx_t_20);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_21, __pyx__function);
                            __pyx_t_8 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[3] = {__pyx_t_20, __pyx_mstate_global->__pyx_kp_u_Database_query_timed_out_after_s_3, __pyx_t_6};
                            __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_21, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                            __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                            if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1105, __pyx_L33_except_error)
                            __Pyx_GOTREF(__pyx_t_4);
                          }
                          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                          /* "ws_package/controllers/activity_controller.py":1106
 *                     except asyncio.TimeoutError:
 *                         logger.error("Database query timed out after %ss in wake S3 check", DB_OPERATION_TIMEOUT)
 *                         last_entry_date = None             # <<<<<<<<<<<<<<
 *                     except Exception as e:
 *                         logger.exception("Error getting last interval on wake: %s", e)
*/
                          __Pyx_INCREF(Py_None);
                          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_last_entry_date);
                          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_last_entry_date, Py_None);
                          __Pyx_GIVEREF(Py_None);
                          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                          goto __pyx_L32_exception_handled;
                        }

                        /* "ws_package/controllers/activity_controller.py":1107
 *                         logger.error("Database query timed out after %ss in wake S3 check", DB_OPERATION_TIMEOUT)
 *                         last_entry_date = None
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.exception("Error getting last interval on wake: %s", e)
 *                         last_entry_date = None
*/
                        __pyx_t_28 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                        if (__pyx_t_28) {
                          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._check_and_update_s3_on_wake", __pyx_clineno, __pyx_lineno, __pyx_filename);
                          if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_7, &__pyx_t_18) < 0) __PYX_ERR(0, 1107, __pyx_L33_except_error)
                          __Pyx_XGOTREF(__pyx_t_5);
                          __Pyx_XGOTREF(__pyx_t_7);
                          __Pyx_XGOTREF(__pyx_t_18);
                          __Pyx_INCREF(__pyx_t_7);
                          __Pyx_GIVEREF(__pyx_t_7);
                          __pyx_cur_scope->__pyx_v_e = __pyx_t_7;
                          /*try:*/ {

                            /* "ws_package/controllers/activity_controller.py":1108
 *                         last_entry_date = None
 *                     except Exception as e:
 *                         logger.exception("Error getting last interval on wake: %s", e)             # <<<<<<<<<<<<<<
 *                         last_entry_date = None
 * 
*/
                            __pyx_t_21 = NULL;
                            __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1108, __pyx_L46_error)
                            __Pyx_GOTREF(__pyx_t_6);
                            __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_exception); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1108, __pyx_L46_error)
                            __Pyx_GOTREF(__pyx_t_20);
                            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                            __pyx_t_8 = 1;
                            #if CYTHON_UNPACK_METHODS
                            if (unlikely(PyMethod_Check(__pyx_t_20))) {
                              __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_20);
                              assert(__pyx_t_21);
                              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_20);
                              __Pyx_INCREF(__pyx_t_21);
                              __Pyx_INCREF(__pyx__function);
                              __Pyx_DECREF_SET(__pyx_t_20, __pyx__function);
                              __pyx_t_8 = 0;
                            }
                            #endif
                            {
                              PyObject *__pyx_callargs[3] = {__pyx_t_21, __pyx_mstate_global->__pyx_kp_u_Error_getting_last_interval_on_w, __pyx_cur_scope->__pyx_v_e};
                              __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_20, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                              __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1108, __pyx_L46_error)
                              __Pyx_GOTREF(__pyx_t_4);
                            }
                            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                            /* "ws_package/controllers/activity_controller.py":1109
 *                     except Exception as e:
 *                         logger.exception("Error getting last interval on wake: %s", e)
 *                         last_entry_date = None             # <<<<<<<<<<<<<<
 * 
 *             # Check if it's a new day or STS credentials expired
*/
                            __Pyx_INCREF(Py_None);
                            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_last_entry_date);
                            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_last_entry_date, Py_None);
                            __Pyx_GIVEREF(Py_None);
                          }

                          /* "ws_package/controllers/activity_controller.py":1107
 *                         logger.error("Database query timed out after %ss in wake S3 check", DB_OPERATION_TIMEOUT)
 *                         last_entry_date = None
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.exception("Error getting last interval on wake: %s", e)
 *                         last_entry_date = None
*/
                          /*finally:*/ {
                            /*normal exit:*/{
                              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                              goto __pyx_L47;
                            }
                            __pyx_L46_error:;
                            /*exception exit:*/{
                              __Pyx_PyThreadState_assign
                              __pyx_t_31 = 0; __pyx_t_32 = 0; __pyx_t_33 = 0; __pyx_t_34 = 0; __pyx_t_35 = 0; __pyx_t_36 = 0;
                              __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                              __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                              __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                              __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                               __Pyx_ExceptionSwap(&__pyx_t_34, &__pyx_t_35, &__pyx_t_36);
                              if ( unlikely(__Pyx_GetException(&__pyx_t_31, &__pyx_t_32, &__pyx_t_33) < 0)) __Pyx_ErrFetch(&__pyx_t_31, &__pyx_t_32, &__pyx_t_33);
                              __Pyx_XGOTREF(__pyx_t_31);
                              __Pyx_XGOTREF(__pyx_t_32);
                              __Pyx_XGOTREF(__pyx_t_33);
                              __Pyx_XGOTREF(__pyx_t_34);
                              __Pyx_XGOTREF(__pyx_t_35);
                              __Pyx_XGOTREF(__pyx_t_36);
                              __pyx_t_28 = __pyx_lineno; __pyx_t_29 = __pyx_clineno; __pyx_t_30 = __pyx_filename;
                              {
                                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                              }
                              __Pyx_XGIVEREF(__pyx_t_34);
                              __Pyx_XGIVEREF(__pyx_t_35);
                              __Pyx_XGIVEREF(__pyx_t_36);
                              __Pyx_ExceptionReset(__pyx_t_34, __pyx_t_35, __pyx_t_36);
                              __Pyx_XGIVEREF(__pyx_t_31);
                              __Pyx_XGIVEREF(__pyx_t_32);
                              __Pyx_XGIVEREF(__pyx_t_33);
                              __Pyx_ErrRestore(__pyx_t_31, __pyx_t_32, __pyx_t_33);
                              __pyx_t_31 = 0; __pyx_t_32 = 0; __pyx_t_33 = 0; __pyx_t_34 = 0; __pyx_t_35 = 0; __pyx_t_36 = 0;
                              __pyx_lineno = __pyx_t_28; __pyx_clineno = __pyx_t_29; __pyx_filename = __pyx_t_30;
                              goto __pyx_L33_except_error;
                            }
                            __pyx_L47:;
                          }
                          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                          goto __pyx_L32_exception_handled;
                        }
                        goto __pyx_L33_except_error;

                        /* "ws_package/controllers/activity_controller.py":1094
 *                         ActivityInterval.counter == self.last_count + 1
 *                     ).order_by(ActivityInterval.start_time.desc()).limit(1)
 *                     try:             # <<<<<<<<<<<<<<
 *                         result = await asyncio.wait_for(
 *                             session.scalars(query),
*/
                        __pyx_L33_except_error:;
                        __Pyx_XGIVEREF(__pyx_t_24);
                        __Pyx_XGIVEREF(__pyx_t_25);
                        __Pyx_XGIVEREF(__pyx_t_26);
                        __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_25, __pyx_t_26);
                        goto __pyx_L25_error;
                        __pyx_L32_exception_handled:;
                        __Pyx_XGIVEREF(__pyx_t_24);
                        __Pyx_XGIVEREF(__pyx_t_25);
                        __Pyx_XGIVEREF(__pyx_t_26);
                        __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_25, __pyx_t_26);
                        __pyx_L36_try_end:;
                      }

                      /* "ws_package/controllers/activity_controller.py":1090
 * 
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     query = select(ActivityInterval).where(
 *                         ActivityInterval.counter == self.last_count + 1
*/
                    }
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                    goto __pyx_L30_try_end;
                    __pyx_L25_error:;
                    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                    /*except:*/ {
                      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._check_and_update_s3_on_wake", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_18, &__pyx_t_7, &__pyx_t_5) < 0) __PYX_ERR(0, 1090, __pyx_L27_except_error)
                      __Pyx_XGOTREF(__pyx_t_18);
                      __Pyx_XGOTREF(__pyx_t_7);
                      __Pyx_XGOTREF(__pyx_t_5);
                      __pyx_t_4 = PyTuple_Pack(3, __pyx_t_18, __pyx_t_7, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1090, __pyx_L27_except_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __pyx_t_26 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_4, NULL);
                      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 1090, __pyx_L27_except_error)
                      __Pyx_GOTREF(__pyx_t_26);
                      __pyx_t_14 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_26, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                      if (likely(__pyx_t_14 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_5);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_5;
                        __Pyx_XGIVEREF(__pyx_t_7);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_7;
                        __Pyx_XGIVEREF(__pyx_t_9);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_9;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_11 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_12 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_13 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_t_26);
                        __pyx_cur_scope->__pyx_t_14 = __pyx_t_26;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_SwapException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 3;
                        return __pyx_r;
                        __pyx_L55_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_5 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_5);
                        __pyx_t_7 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_7);
                        __pyx_t_9 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_9);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_11;
                        __pyx_cur_scope->__pyx_t_11 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_12;
                        __pyx_cur_scope->__pyx_t_12 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_13;
                        __pyx_cur_scope->__pyx_t_13 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        __pyx_t_26 = __pyx_cur_scope->__pyx_t_14;
                        __pyx_cur_scope->__pyx_t_14 = 0;
                        __Pyx_XGOTREF(__pyx_t_26);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1090, __pyx_L27_except_error)
                        __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                      } else if (likely(__pyx_t_14 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 1090, __pyx_L27_except_error)
                      }
                      __pyx_t_26 = __pyx_t_4;
                      __pyx_t_4 = 0;
                      __pyx_t_27 = __Pyx_PyObject_IsTrue(__pyx_t_26);
                      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                      if (__pyx_t_27 < (0)) __PYX_ERR(0, 1090, __pyx_L27_except_error)
                      __pyx_t_37 = (!__pyx_t_27);
                      if (unlikely(__pyx_t_37)) {
                        __Pyx_GIVEREF(__pyx_t_18);
                        __Pyx_GIVEREF(__pyx_t_7);
                        __Pyx_XGIVEREF(__pyx_t_5);
                        __Pyx_ErrRestoreWithState(__pyx_t_18, __pyx_t_7, __pyx_t_5);
                        __pyx_t_18 = 0;  __pyx_t_7 = 0;  __pyx_t_5 = 0; 
                        __PYX_ERR(0, 1090, __pyx_L27_except_error)
                      }
                      __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                      goto __pyx_L26_exception_handled;
                    }
                    __pyx_L27_except_error:;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
                    goto __pyx_L14_error;
                    __pyx_L26_exception_handled:;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
                    __pyx_L30_try_end:;
                  }
                }
                /*finally:*/ {
                  /*normal exit:*/{
                    if (__pyx_t_13) {
                      __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_mstate_global->__pyx_tuple[7], NULL);
                      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                      if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1090, __pyx_L14_error)
                      __Pyx_GOTREF(__pyx_t_17);
                      __pyx_t_14 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_17, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                      if (likely(__pyx_t_14 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_9);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 4;
                        return __pyx_r;
                        __pyx_L56_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_9);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1090, __pyx_L14_error)
                        __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
                      } else if (likely(__pyx_t_14 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_5 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 1090, __pyx_L14_error)
                      }
                      __pyx_t_17 = __pyx_t_5;
                      __pyx_t_5 = 0;
                      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                    }
                    goto __pyx_L24;
                  }
                  __pyx_L24:;
                }
                goto __pyx_L57;
                __pyx_L20_error:;
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                goto __pyx_L14_error;
                __pyx_L57:;
              }

              /* "ws_package/controllers/activity_controller.py":1089
 *             DB_OPERATION_TIMEOUT = 5.0
 * 
 *             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     query = select(ActivityInterval).where(
*/
            }
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            goto __pyx_L19_try_end;
            __pyx_L14_error:;
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
            __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
            __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
            __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            /*except:*/ {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._check_and_update_s3_on_wake", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_7, &__pyx_t_18) < 0) __PYX_ERR(0, 1089, __pyx_L16_except_error)
              __Pyx_XGOTREF(__pyx_t_5);
              __Pyx_XGOTREF(__pyx_t_7);
              __Pyx_XGOTREF(__pyx_t_18);
              __pyx_t_4 = PyTuple_Pack(3, __pyx_t_5, __pyx_t_7, __pyx_t_18); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1089, __pyx_L16_except_error)
              __Pyx_GOTREF(__pyx_t_4);
              __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_4, NULL);
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1089, __pyx_L16_except_error)
              __Pyx_GOTREF(__pyx_t_13);
              __pyx_t_37 = __Pyx_PyObject_IsTrue(__pyx_t_13);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              if (__pyx_t_37 < (0)) __PYX_ERR(0, 1089, __pyx_L16_except_error)
              __pyx_t_27 = (!__pyx_t_37);
              if (unlikely(__pyx_t_27)) {
                __Pyx_GIVEREF(__pyx_t_5);
                __Pyx_GIVEREF(__pyx_t_7);
                __Pyx_XGIVEREF(__pyx_t_18);
                __Pyx_ErrRestoreWithState(__pyx_t_5, __pyx_t_7, __pyx_t_18);
                __pyx_t_5 = 0;  __pyx_t_7 = 0;  __pyx_t_18 = 0; 
                __PYX_ERR(0, 1089, __pyx_L16_except_error)
              }
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
              __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
              goto __pyx_L15_exception_handled;
            }
            __pyx_L16_except_error:;
            __Pyx_XGIVEREF(__pyx_t_10);
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
            goto __pyx_L4_error;
            __pyx_L15_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_10);
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
            __pyx_L19_try_end:;
          }
        }
        /*finally:*/ {
          /*normal exit:*/{
            if (__pyx_t_9) {
              __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_mstate_global->__pyx_tuple[7], NULL);
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
              if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1089, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            }
            goto __pyx_L13;
          }
          __pyx_L13:;
        }
        goto __pyx_L61;
        __pyx_L10_error:;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L4_error;
        __pyx_L61:;
      }

      /* "ws_package/controllers/activity_controller.py":1112
 * 
 *             # Check if it's a new day or STS credentials expired
 *             current_date = datetime.datetime.now().date()             # <<<<<<<<<<<<<<
 *             credentials_stale = await self._s3_credentials_need_refresh(user_entity)
 *             if last_entry_date is None or last_entry_date != current_date or credentials_stale:
*/
      __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1112, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_20);
      __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1112, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_21);
      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
      __pyx_t_4 = __pyx_t_21;
      __Pyx_INCREF(__pyx_t_4);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
        __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1112, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
      }
      __pyx_t_7 = __pyx_t_5;
      __Pyx_INCREF(__pyx_t_7);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
        __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_date, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1112, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_18);
      }
      __Pyx_GIVEREF(__pyx_t_18);
      __pyx_cur_scope->__pyx_v_current_date = __pyx_t_18;
      __pyx_t_18 = 0;

      /* "ws_package/controllers/activity_controller.py":1113
 *             # Check if it's a new day or STS credentials expired
 *             current_date = datetime.datetime.now().date()
 *             credentials_stale = await self._s3_credentials_need_refresh(user_entity)             # <<<<<<<<<<<<<<
 *             if last_entry_date is None or last_entry_date != current_date or credentials_stale:
 *                 if credentials_stale:
*/
      __pyx_t_5 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_user_entity};
        __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_s3_credentials_need_refresh, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1113, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_18);
      }
      __pyx_t_14 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_18, &__pyx_r);
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      if (likely(__pyx_t_14 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
        __Pyx_XGIVEREF(__pyx_t_2);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
        __Pyx_XGIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 5;
        return __pyx_r;
        __pyx_L62_resume_from_await:;
        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_1);
        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_2);
        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_3);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1113, __pyx_L4_error)
        __pyx_t_18 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_18);
      } else if (likely(__pyx_t_14 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __pyx_t_18 = __pyx_r; __pyx_r = NULL;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 1113, __pyx_L4_error)
      }
      __Pyx_GIVEREF(__pyx_t_18);
      __pyx_cur_scope->__pyx_v_credentials_stale = __pyx_t_18;
      __pyx_t_18 = 0;

      /* "ws_package/controllers/activity_controller.py":1114
 *             current_date = datetime.datetime.now().date()
 *             credentials_stale = await self._s3_credentials_need_refresh(user_entity)
 *             if last_entry_date is None or last_entry_date != current_date or credentials_stale:             # <<<<<<<<<<<<<<
 *                 if credentials_stale:
 *                     logger.info("[WAKE] STS credentials expired  refreshing S3 bucket config")
*/
      if (unlikely(!__pyx_cur_scope->__pyx_v_last_entry_date)) { __Pyx_RaiseUnboundLocalError("last_entry_date"); __PYX_ERR(0, 1114, __pyx_L4_error) }
      __pyx_t_37 = (__pyx_cur_scope->__pyx_v_last_entry_date == Py_None);
      if (!__pyx_t_37) {
      } else {
        __pyx_t_27 = __pyx_t_37;
        goto __pyx_L64_bool_binop_done;
      }
      if (unlikely(!__pyx_cur_scope->__pyx_v_last_entry_date)) { __Pyx_RaiseUnboundLocalError("last_entry_date"); __PYX_ERR(0, 1114, __pyx_L4_error) }
      __pyx_t_18 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_last_entry_date, __pyx_cur_scope->__pyx_v_current_date, Py_NE); __Pyx_XGOTREF(__pyx_t_18); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1114, __pyx_L4_error)
      __pyx_t_37 = __Pyx_PyObject_IsTrue(__pyx_t_18); if (unlikely((__pyx_t_37 < 0))) __PYX_ERR(0, 1114, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      if (!__pyx_t_37) {
      } else {
        __pyx_t_27 = __pyx_t_37;
        goto __pyx_L64_bool_binop_done;
      }
      __pyx_t_37 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_credentials_stale); if (unlikely((__pyx_t_37 < 0))) __PYX_ERR(0, 1114, __pyx_L4_error)
      __pyx_t_27 = __pyx_t_37;
      __pyx_L64_bool_binop_done:;
      if (__pyx_t_27) {

        /* "ws_package/controllers/activity_controller.py":1115
 *             credentials_stale = await self._s3_credentials_need_refresh(user_entity)
 *             if last_entry_date is None or last_entry_date != current_date or credentials_stale:
 *                 if credentials_stale:             # <<<<<<<<<<<<<<
 *                     logger.info("[WAKE] STS credentials expired  refreshing S3 bucket config")
 *                 elif last_entry_date is None or last_entry_date != current_date:
*/
        __pyx_t_27 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_credentials_stale); if (unlikely((__pyx_t_27 < 0))) __PYX_ERR(0, 1115, __pyx_L4_error)
        if (__pyx_t_27) {

          /* "ws_package/controllers/activity_controller.py":1116
 *             if last_entry_date is None or last_entry_date != current_date or credentials_stale:
 *                 if credentials_stale:
 *                     logger.info("[WAKE] STS credentials expired  refreshing S3 bucket config")             # <<<<<<<<<<<<<<
 *                 elif last_entry_date is None or last_entry_date != current_date:
 *                     logger.info("[WAKE] New day detected (last: %s, current: %s) - updating S3 bucket config", last_entry_date, current_date)
*/
          __pyx_t_5 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1116, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1116, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_21);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_21))) {
            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_21);
            assert(__pyx_t_5);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_21);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_21, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_WAKE_STS_credentials_expired_re};
            __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_21, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
            if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1116, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_18);
          }
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

          /* "ws_package/controllers/activity_controller.py":1115
 *             credentials_stale = await self._s3_credentials_need_refresh(user_entity)
 *             if last_entry_date is None or last_entry_date != current_date or credentials_stale:
 *                 if credentials_stale:             # <<<<<<<<<<<<<<
 *                     logger.info("[WAKE] STS credentials expired  refreshing S3 bucket config")
 *                 elif last_entry_date is None or last_entry_date != current_date:
*/
          goto __pyx_L67;
        }

        /* "ws_package/controllers/activity_controller.py":1117
 *                 if credentials_stale:
 *                     logger.info("[WAKE] STS credentials expired  refreshing S3 bucket config")
 *                 elif last_entry_date is None or last_entry_date != current_date:             # <<<<<<<<<<<<<<
 *                     logger.info("[WAKE] New day detected (last: %s, current: %s) - updating S3 bucket config", last_entry_date, current_date)
 *                 await self.ensure_s3_credentials_fresh(user_entity)
*/
        if (unlikely(!__pyx_cur_scope->__pyx_v_last_entry_date)) { __Pyx_RaiseUnboundLocalError("last_entry_date"); __PYX_ERR(0, 1117, __pyx_L4_error) }
        __pyx_t_37 = (__pyx_cur_scope->__pyx_v_last_entry_date == Py_None);
        if (!__pyx_t_37) {
        } else {
          __pyx_t_27 = __pyx_t_37;
          goto __pyx_L68_bool_binop_done;
        }
        if (unlikely(!__pyx_cur_scope->__pyx_v_last_entry_date)) { __Pyx_RaiseUnboundLocalError("last_entry_date"); __PYX_ERR(0, 1117, __pyx_L4_error) }
        __pyx_t_18 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_last_entry_date, __pyx_cur_scope->__pyx_v_current_date, Py_NE); __Pyx_XGOTREF(__pyx_t_18); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1117, __pyx_L4_error)
        __pyx_t_37 = __Pyx_PyObject_IsTrue(__pyx_t_18); if (unlikely((__pyx_t_37 < 0))) __PYX_ERR(0, 1117, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        __pyx_t_27 = __pyx_t_37;
        __pyx_L68_bool_binop_done:;
        if (__pyx_t_27) {

          /* "ws_package/controllers/activity_controller.py":1118
 *                     logger.info("[WAKE] STS credentials expired  refreshing S3 bucket config")
 *                 elif last_entry_date is None or last_entry_date != current_date:
 *                     logger.info("[WAKE] New day detected (last: %s, current: %s) - updating S3 bucket config", last_entry_date, current_date)             # <<<<<<<<<<<<<<
 *                 await self.ensure_s3_credentials_fresh(user_entity)
 *             else:
*/
          __pyx_t_21 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1118, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1118, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_cur_scope->__pyx_v_last_entry_date)) { __Pyx_RaiseUnboundLocalError("last_entry_date"); __PYX_ERR(0, 1118, __pyx_L4_error) }
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_7))) {
            __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_7);
            assert(__pyx_t_21);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
            __Pyx_INCREF(__pyx_t_21);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[4] = {__pyx_t_21, __pyx_mstate_global->__pyx_kp_u_WAKE_New_day_detected_last_s_cu, __pyx_cur_scope->__pyx_v_last_entry_date, __pyx_cur_scope->__pyx_v_current_date};
            __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1118, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_18);
          }
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

          /* "ws_package/controllers/activity_controller.py":1117
 *                 if credentials_stale:
 *                     logger.info("[WAKE] STS credentials expired  refreshing S3 bucket config")
 *                 elif last_entry_date is None or last_entry_date != current_date:             # <<<<<<<<<<<<<<
 *                     logger.info("[WAKE] New day detected (last: %s, current: %s) - updating S3 bucket config", last_entry_date, current_date)
 *                 await self.ensure_s3_credentials_fresh(user_entity)
*/
        }
        __pyx_L67:;

        /* "ws_package/controllers/activity_controller.py":1119
 *                 elif last_entry_date is None or last_entry_date != current_date:
 *                     logger.info("[WAKE] New day detected (last: %s, current: %s) - updating S3 bucket config", last_entry_date, current_date)
 *                 await self.ensure_s3_credentials_fresh(user_entity)             # <<<<<<<<<<<<<<
 *             else:
 *                 logger.debug("[WAKE] Same day (last: %s, current: %s) - no S3 bucket update needed", last_entry_date, current_date)
*/
        __pyx_t_7 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_7);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_cur_scope->__pyx_v_user_entity};
          __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_ensure_s3_credentials_fresh, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1119, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_18);
        }
        __pyx_t_14 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_18, &__pyx_r);
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        if (likely(__pyx_t_14 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_1);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
          __Pyx_XGIVEREF(__pyx_t_2);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
          __Pyx_XGIVEREF(__pyx_t_3);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 6;
          return __pyx_r;
          __pyx_L70_resume_from_await:;
          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_1);
          __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_2);
          __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_3);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1119, __pyx_L4_error)
        } else if (likely(__pyx_t_14 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_DECREF(__pyx_r); __pyx_r = 0;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 1119, __pyx_L4_error)
        }

        /* "ws_package/controllers/activity_controller.py":1114
 *             current_date = datetime.datetime.now().date()
 *             credentials_stale = await self._s3_credentials_need_refresh(user_entity)
 *             if last_entry_date is None or last_entry_date != current_date or credentials_stale:             # <<<<<<<<<<<<<<
 *                 if credentials_stale:
 *                     logger.info("[WAKE] STS credentials expired  refreshing S3 bucket config")
*/
        goto __pyx_L63;
      }

      /* "ws_package/controllers/activity_controller.py":1121
 *                 await self.ensure_s3_credentials_fresh(user_entity)
 *             else:
 *                 logger.debug("[WAKE] Same day (last: %s, current: %s) - no S3 bucket update needed", last_entry_date, current_date)             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             logger.error("[WAKE] Error checking/updating S3 bucket on wake: %s", e, exc_info=True)
*/
      /*else*/ {
        __pyx_t_7 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1121, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_21);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1121, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
        if (unlikely(!__pyx_cur_scope->__pyx_v_last_entry_date)) { __Pyx_RaiseUnboundLocalError("last_entry_date"); __PYX_ERR(0, 1121, __pyx_L4_error) }
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
          assert(__pyx_t_7);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[4] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_WAKE_Same_day_last_s_current_s, __pyx_cur_scope->__pyx_v_last_entry_date, __pyx_cur_scope->__pyx_v_current_date};
          __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1121, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_18);
        }
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
      }
      __pyx_L63:;

      /* "ws_package/controllers/activity_controller.py":1085
 *         Called on app wake from sleep.
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # Use centralized read lock for database read operations
 *             DB_OPERATION_TIMEOUT = 5.0
*/
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L9_try_end;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "ws_package/controllers/activity_controller.py":1122
 *             else:
 *                 logger.debug("[WAKE] Same day (last: %s, current: %s) - no S3 bucket update needed", last_entry_date, current_date)
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("[WAKE] Error checking/updating S3 bucket on wake: %s", e, exc_info=True)
 * 
*/
    __pyx_t_29 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_29) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._check_and_update_s3_on_wake", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_18, &__pyx_t_5, &__pyx_t_7) < 0) __PYX_ERR(0, 1122, __pyx_L6_except_error)
      __Pyx_XGOTREF(__pyx_t_18);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":1123
 *                 logger.debug("[WAKE] Same day (last: %s, current: %s) - no S3 bucket update needed", last_entry_date, current_date)
 *         except Exception as e:
 *             logger.error("[WAKE] Error checking/updating S3 bucket on wake: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *     async def _s3_credentials_need_refresh(self, user_entity: UserEntity) -> bool:
*/
        __pyx_t_4 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1123, __pyx_L76_error)
        __Pyx_GOTREF(__pyx_t_20);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1123, __pyx_L76_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
          assert(__pyx_t_4);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_WAKE_Error_checking_updating_S3, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_20 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1123, __pyx_L76_error)
          __Pyx_GOTREF(__pyx_t_20);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_20, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 1123, __pyx_L76_error)
          __pyx_t_21 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_20);
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1123, __pyx_L76_error)
          __Pyx_GOTREF(__pyx_t_21);
        }
        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
      }

      /* "ws_package/controllers/activity_controller.py":1122
 *             else:
 *                 logger.debug("[WAKE] Same day (last: %s, current: %s) - no S3 bucket update needed", last_entry_date, current_date)
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("[WAKE] Error checking/updating S3 bucket on wake: %s", e, exc_info=True)
 * 
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          goto __pyx_L77;
        }
        __pyx_L76_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_9 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_13 = 0; __pyx_t_17 = 0;
          __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
          __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
          __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
          __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_13, &__pyx_t_17);
          if ( unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_12, &__pyx_t_11) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_12, &__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_9);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_17);
          __pyx_t_29 = __pyx_lineno; __pyx_t_28 = __pyx_clineno; __pyx_t_38 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_13, __pyx_t_17);
          __Pyx_XGIVEREF(__pyx_t_9);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_ErrRestore(__pyx_t_9, __pyx_t_12, __pyx_t_11);
          __pyx_t_9 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_13 = 0; __pyx_t_17 = 0;
          __pyx_lineno = __pyx_t_29; __pyx_clineno = __pyx_t_28; __pyx_filename = __pyx_t_38;
          goto __pyx_L6_except_error;
        }
        __pyx_L77:;
      }
      __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L5_exception_handled;
    }
    goto __pyx_L6_except_error;

    /* "ws_package/controllers/activity_controller.py":1085
 *         Called on app wake from sleep.
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # Use centralized read lock for database read operations
 *             DB_OPERATION_TIMEOUT = 5.0
*/
    __pyx_L6_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L5_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    __pyx_L9_try_end:;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":1080
 *             logger.error("[STARTUP] Error checking/updating S3 bucket on startup: %s", e, exc_info=True)
 * 
 *     async def _check_and_update_s3_on_wake(self, user_entity):             # <<<<<<<<<<<<<<
 *         """
 *         Check if it's a new day and update S3 bucket config if needed.
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_XDECREF(__pyx_t_23);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("_check_and_update_s3_on_wake", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_61generator9(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":1125
 *             logger.error("[WAKE] Error checking/updating S3 bucket on wake: %s", e, exc_info=True)
 * 
 *     async def _s3_credentials_need_refresh(self, user_entity: UserEntity) -> bool:             # <<<<<<<<<<<<<<
 *         """True when stored STS credentials are missing or past expire_time."""
 *         if user_entity is None:
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_60_s3_credentials_need_refresh(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_59_s3_credentials_need_refresh, "True when stored STS credentials are missing or past expire_time.");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_60_s3_credentials_need_refresh = {"_s3_credentials_need_refresh", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_60_s3_credentials_need_refresh, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_59_s3_credentials_need_refresh};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_60_s3_credentials_need_refresh(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_user_entity = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_s3_credentials_need_refresh (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_user_entity,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 1125, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1125, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1125, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_s3_credentials_need_refresh", 0) < (0)) __PYX_ERR(0, 1125, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_s3_credentials_need_refresh", 1, 2, 2, i); __PYX_ERR(0, 1125, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1125, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1125, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_user_entity = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_s3_credentials_need_refresh", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 1125, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._s3_credentials_need_refresh", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_59_s3_credentials_need_refresh(__pyx_self, __pyx_v_self, __pyx_v_user_entity);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_59_s3_credentials_need_refresh(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_s3_credentials_need_refresh", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1125, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_user_entity = __pyx_v_user_entity;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_user_entity);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_user_entity);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_61generator9, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[9]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_s3_credentials_need_refresh, __pyx_mstate_global->__pyx_n_u_ActivityController__s3_credentia, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 1125, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._s3_credentials_need_refresh", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_61generator9(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  size_t __pyx_t_8;
  __Pyx_PySendResult __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_s3_credentials_need_refresh", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L5_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 1125, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":1127
 *     async def _s3_credentials_need_refresh(self, user_entity: UserEntity) -> bool:
 *         """True when stored STS credentials are missing or past expire_time."""
 *         if user_entity is None:             # <<<<<<<<<<<<<<
 *             return True
 *         from ws_package.utils.s3 import s3_credentials_expired
*/
  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_user_entity == Py_None);
  if (__pyx_t_1) {

    /* "ws_package/controllers/activity_controller.py":1128
 *         """True when stored STS credentials are missing or past expire_time."""
 *         if user_entity is None:
 *             return True             # <<<<<<<<<<<<<<
 *         from ws_package.utils.s3 import s3_credentials_expired
 * 
*/
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_True);
    __pyx_r = Py_True;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":1127
 *     async def _s3_credentials_need_refresh(self, user_entity: UserEntity) -> bool:
 *         """True when stored STS credentials are missing or past expire_time."""
 *         if user_entity is None:             # <<<<<<<<<<<<<<
 *             return True
 *         from ws_package.utils.s3 import s3_credentials_expired
*/
  }

  /* "ws_package/controllers/activity_controller.py":1129
 *         if user_entity is None:
 *             return True
 *         from ws_package.utils.s3 import s3_credentials_expired             # <<<<<<<<<<<<<<
 * 
 *         existing = await self.server_controller.server_service.get_s3bucket(user_entity.org_id)
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_s3_credentials_expired};
    __pyx_t_3 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_utils_s3, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1129, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_3;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_s3_credentials_expired};
    __pyx_t_4 = 0; {
      __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_4]); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1129, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      switch (__pyx_t_4) {
        case 0:
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        __pyx_cur_scope->__pyx_v_s3_credentials_expired = __pyx_t_5;
        break;
        default:;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":1131
 *         from ws_package.utils.s3 import s3_credentials_expired
 * 
 *         existing = await self.server_controller.server_service.get_s3bucket(user_entity.org_id)             # <<<<<<<<<<<<<<
 *         return existing is None or s3_credentials_expired(existing)
 * 
*/
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_server_controller); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1131, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_server_service); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1131, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_5 = __pyx_t_7;
  __Pyx_INCREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_org_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1131, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_6};
    __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_s3bucket, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1131, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
  }
  __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_2, &__pyx_r);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(__pyx_t_9 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L5_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1131, __pyx_L1_error)
    __pyx_t_2 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_2);
  } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __pyx_t_2 = __pyx_r; __pyx_r = NULL;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 1131, __pyx_L1_error)
  }
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_cur_scope->__pyx_v_existing = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":1132
 * 
 *         existing = await self.server_controller.server_service.get_s3bucket(user_entity.org_id)
 *         return existing is None or s3_credentials_expired(existing)             # <<<<<<<<<<<<<<
 * 
 *     async def ensure_s3_credentials_fresh(self, user_entity: UserEntity) -> S3BucketEntity | None:
*/
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_existing == Py_None);
  if (!__pyx_t_1) {
  } else {
    __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1132, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_2 = __pyx_t_7;
    __pyx_t_7 = 0;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_6 = NULL;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_s3_credentials_expired);
  __pyx_t_5 = __pyx_cur_scope->__pyx_v_s3_credentials_expired; 
  __pyx_t_8 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
    assert(__pyx_t_6);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
    __pyx_t_8 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_cur_scope->__pyx_v_existing};
    __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1132, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
  }
  __Pyx_INCREF(__pyx_t_7);
  __pyx_t_2 = __pyx_t_7;
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  __pyx_L6_bool_binop_done:;
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":1125
 *             logger.error("[WAKE] Error checking/updating S3 bucket on wake: %s", e, exc_info=True)
 * 
 *     async def _s3_credentials_need_refresh(self, user_entity: UserEntity) -> bool:             # <<<<<<<<<<<<<<
 *         """True when stored STS credentials are missing or past expire_time."""
 *         if user_entity is None:
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("_s3_credentials_need_refresh", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_64generator10(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":1134
 *         return existing is None or s3_credentials_expired(existing)
 * 
 *     async def ensure_s3_credentials_fresh(self, user_entity: UserEntity) -> S3BucketEntity | None:             # <<<<<<<<<<<<<<
 *         """Refresh S3 credentials from sts/keys when expire_time has passed."""
 *         return await self.server_controller.ensure_fresh_s3_bucket(user_entity)
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_63ensure_s3_credentials_fresh(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_62ensure_s3_credentials_fresh, "Refresh S3 credentials from sts/keys when expire_time has passed.");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_63ensure_s3_credentials_fresh = {"ensure_s3_credentials_fresh", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_63ensure_s3_credentials_fresh, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_62ensure_s3_credentials_fresh};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_63ensure_s3_credentials_fresh(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_user_entity = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ensure_s3_credentials_fresh (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_user_entity,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 1134, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1134, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1134, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "ensure_s3_credentials_fresh", 0) < (0)) __PYX_ERR(0, 1134, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("ensure_s3_credentials_fresh", 1, 2, 2, i); __PYX_ERR(0, 1134, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1134, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1134, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_user_entity = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("ensure_s3_credentials_fresh", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 1134, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.ensure_s3_credentials_fresh", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_62ensure_s3_credentials_fresh(__pyx_self, __pyx_v_self, __pyx_v_user_entity);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_62ensure_s3_credentials_fresh(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("ensure_s3_credentials_fresh", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1134, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_user_entity = __pyx_v_user_entity;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_user_entity);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_user_entity);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_64generator10, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[10]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_ensure_s3_credentials_fresh, __pyx_mstate_global->__pyx_n_u_ActivityController_ensure_s3_cre, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 1134, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.ensure_s3_credentials_fresh", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_64generator10(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  size_t __pyx_t_4;
  __Pyx_PySendResult __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ensure_s3_credentials_fresh", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L4_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 1134, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":1136
 *     async def ensure_s3_credentials_fresh(self, user_entity: UserEntity) -> S3BucketEntity | None:
 *         """Refresh S3 credentials from sts/keys when expire_time has passed."""
 *         return await self.server_controller.ensure_fresh_s3_bucket(user_entity)             # <<<<<<<<<<<<<<
 * 
 *     async def get_bucket_in_every_interval(self, user_entity: UserEntity) -> S3BucketEntity | None:
*/
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_server_controller); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1136, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __pyx_t_3;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_4 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_user_entity};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_ensure_fresh_s3_bucket, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1136, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_5 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_5 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L4_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1136, __pyx_L1_error)
    __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
  } else if (likely(__pyx_t_5 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __pyx_t_1 = __pyx_r; __pyx_r = NULL;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 1136, __pyx_L1_error)
  }
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":1134
 *         return existing is None or s3_credentials_expired(existing)
 * 
 *     async def ensure_s3_credentials_fresh(self, user_entity: UserEntity) -> S3BucketEntity | None:             # <<<<<<<<<<<<<<
 *         """Refresh S3 credentials from sts/keys when expire_time has passed."""
 *         return await self.server_controller.ensure_fresh_s3_bucket(user_entity)
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("ensure_s3_credentials_fresh", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_67generator11(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":1138
 *         return await self.server_controller.ensure_fresh_s3_bucket(user_entity)
 * 
 *     async def get_bucket_in_every_interval(self, user_entity: UserEntity) -> S3BucketEntity | None:             # <<<<<<<<<<<<<<
 *         """Refresh S3 bucket credentials from the remote API when needed.
 * 
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_66get_bucket_in_every_interval(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_65get_bucket_in_every_interval, "Refresh S3 bucket credentials from the remote API when needed.\n\n        Calls sts/keys only when credentials are missing or ``expire_time`` has passed.\n        The underlying HTTP call is synchronous (``requests``).  It is offloaded\n        to the thread-pool executor so the event loop is never blocked by network\n        latency or retry back-off, regardless of how long the server takes to\n        respond.\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_66get_bucket_in_every_interval = {"get_bucket_in_every_interval", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_66get_bucket_in_every_interval, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_65get_bucket_in_every_interval};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_66get_bucket_in_every_interval(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_user_entity = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_bucket_in_every_interval (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_user_entity,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 1138, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1138, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1138, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "get_bucket_in_every_interval", 0) < (0)) __PYX_ERR(0, 1138, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("get_bucket_in_every_interval", 1, 2, 2, i); __PYX_ERR(0, 1138, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1138, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1138, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_user_entity = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_bucket_in_every_interval", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 1138, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.get_bucket_in_every_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_65get_bucket_in_every_interval(__pyx_self, __pyx_v_self, __pyx_v_user_entity);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_65get_bucket_in_every_interval(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_bucket_in_every_interval", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1138, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_user_entity = __pyx_v_user_entity;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_user_entity);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_user_entity);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_67generator11, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[11]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_get_bucket_in_every_interval, __pyx_mstate_global->__pyx_n_u_ActivityController_get_bucket_in, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 1138, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.get_bucket_in_every_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_67generator11(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  size_t __pyx_t_3;
  __Pyx_PySendResult __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_bucket_in_every_interval", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L4_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 1138, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":1147
 *         respond.
 *         """
 *         return await self.ensure_s3_credentials_fresh(user_entity)             # <<<<<<<<<<<<<<
 * 
 *     async def update_interval(self, user_entity: UserEntity):
*/
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_3 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_user_entity};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_ensure_s3_credentials_fresh, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1147, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_4 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_4 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L4_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1147, __pyx_L1_error)
    __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
  } else if (likely(__pyx_t_4 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __pyx_t_1 = __pyx_r; __pyx_r = NULL;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 1147, __pyx_L1_error)
  }
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":1138
 *         return await self.server_controller.ensure_fresh_s3_bucket(user_entity)
 * 
 *     async def get_bucket_in_every_interval(self, user_entity: UserEntity) -> S3BucketEntity | None:             # <<<<<<<<<<<<<<
 *         """Refresh S3 bucket credentials from the remote API when needed.
 * 
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("get_bucket_in_every_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_70generator12(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":1149
 *         return await self.ensure_s3_credentials_fresh(user_entity)
 * 
 *     async def update_interval(self, user_entity: UserEntity):             # <<<<<<<<<<<<<<
 *         """Refresh org settings (interval, screenshot frequency, limits) from the remote API.
 * 
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_69update_interval(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_68update_interval, "Refresh org settings (interval, screenshot frequency, limits) from the remote API.\n\n        Called at every interval boundary.  The underlying HTTP call is\n        synchronous (``requests``); it is offloaded to the thread-pool executor\n        so the event loop is never blocked during network I/O or retry sleeps.\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_69update_interval = {"update_interval", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_69update_interval, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_68update_interval};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_69update_interval(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_user_entity = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("update_interval (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_user_entity,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 1149, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1149, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1149, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "update_interval", 0) < (0)) __PYX_ERR(0, 1149, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("update_interval", 1, 2, 2, i); __PYX_ERR(0, 1149, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1149, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1149, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_user_entity = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("update_interval", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 1149, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.update_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_68update_interval(__pyx_self, __pyx_v_self, __pyx_v_user_entity);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_68update_interval(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("update_interval", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1149, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_user_entity = __pyx_v_user_entity;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_user_entity);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_user_entity);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_70generator12, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[12]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_update_interval, __pyx_mstate_global->__pyx_n_u_ActivityController_update_interv, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 1149, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.update_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_70generator12(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  size_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_PySendResult __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  Py_ssize_t __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  int __pyx_t_17;
  char const *__pyx_t_18;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("update_interval", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L11_resume_from_await;
    case 2: goto __pyx_L13_resume_from_await;
    case 3: goto __pyx_L28_resume_from_await;
    case 4: goto __pyx_L32_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 1149, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":1156
 *         so the event loop is never blocked during network I/O or retry sleeps.
 *         """
 *         if user_entity is None:             # <<<<<<<<<<<<<<
 *             logger.warning("Cannot update interval: user_entity is None")
 *             return
*/
  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_user_entity == Py_None);
  if (__pyx_t_1) {

    /* "ws_package/controllers/activity_controller.py":1157
 *         """
 *         if user_entity is None:
 *             logger.warning("Cannot update interval: user_entity is None")             # <<<<<<<<<<<<<<
 *             return
 * 
*/
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1157, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1157, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
      __pyx_t_6 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Cannot_update_interval_user_enti};
      __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1157, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "ws_package/controllers/activity_controller.py":1158
 *         if user_entity is None:
 *             logger.warning("Cannot update interval: user_entity is None")
 *             return             # <<<<<<<<<<<<<<
 * 
 *         self.user_service.application_org_config_url = config('application_org_config_url')
*/
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":1156
 *         so the event loop is never blocked during network I/O or retry sleeps.
 *         """
 *         if user_entity is None:             # <<<<<<<<<<<<<<
 *             logger.warning("Cannot update interval: user_entity is None")
 *             return
*/
  }

  /* "ws_package/controllers/activity_controller.py":1160
 *             return
 * 
 *         self.user_service.application_org_config_url = config('application_org_config_url')             # <<<<<<<<<<<<<<
 *         sd_token = user_entity.sd_token
 *         org_id = user_entity.org_id
*/
  __pyx_t_5 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_config); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
    assert(__pyx_t_5);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
    __pyx_t_6 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_n_u_application_org_config_url};
    __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1160, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
  }
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_user_service); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1160, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (__Pyx_PyObject_SetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_application_org_config_url, __pyx_t_2) < (0)) __PYX_ERR(0, 1160, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "ws_package/controllers/activity_controller.py":1161
 * 
 *         self.user_service.application_org_config_url = config('application_org_config_url')
 *         sd_token = user_entity.sd_token             # <<<<<<<<<<<<<<
 *         org_id = user_entity.org_id
 *         user_id = user_entity.user_id
*/
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_sd_token); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1161, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_sd_token = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "ws_package/controllers/activity_controller.py":1162
 *         self.user_service.application_org_config_url = config('application_org_config_url')
 *         sd_token = user_entity.sd_token
 *         org_id = user_entity.org_id             # <<<<<<<<<<<<<<
 *         user_id = user_entity.user_id
 *         self.user_service.headers = {
*/
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_org_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1162, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_org_id = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "ws_package/controllers/activity_controller.py":1163
 *         sd_token = user_entity.sd_token
 *         org_id = user_entity.org_id
 *         user_id = user_entity.user_id             # <<<<<<<<<<<<<<
 *         self.user_service.headers = {
 *             'SDToken': str(sd_token),
*/
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_user_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1163, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_user_id = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "ws_package/controllers/activity_controller.py":1165
 *         user_id = user_entity.user_id
 *         self.user_service.headers = {
 *             'SDToken': str(sd_token),             # <<<<<<<<<<<<<<
 *             'OrgID': str(org_id),
 *             'Authorization': f'Bearer {sd_token}',
*/
  __pyx_t_3 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_Unicode(__pyx_cur_scope->__pyx_v_sd_token); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1165, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_SDToken, __pyx_t_2) < (0)) __PYX_ERR(0, 1165, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":1166
 *         self.user_service.headers = {
 *             'SDToken': str(sd_token),
 *             'OrgID': str(org_id),             # <<<<<<<<<<<<<<
 *             'Authorization': f'Bearer {sd_token}',
 *         }
*/
  __pyx_t_2 = __Pyx_PyObject_Unicode(__pyx_cur_scope->__pyx_v_org_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1166, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_OrgID, __pyx_t_2) < (0)) __PYX_ERR(0, 1165, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":1167
 *             'SDToken': str(sd_token),
 *             'OrgID': str(org_id),
 *             'Authorization': f'Bearer {sd_token}',             # <<<<<<<<<<<<<<
 *         }
 *         payload = {"user_id": user_id, "org_id": org_id}
*/
  __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_sd_token, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyUnicode_Concat(__pyx_mstate_global->__pyx_kp_u_Bearer, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1167, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (PyDict_SetItem(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_Authorization, __pyx_t_5) < (0)) __PYX_ERR(0, 1165, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "ws_package/controllers/activity_controller.py":1164
 *         org_id = user_entity.org_id
 *         user_id = user_entity.user_id
 *         self.user_service.headers = {             # <<<<<<<<<<<<<<
 *             'SDToken': str(sd_token),
 *             'OrgID': str(org_id),
*/
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_user_service); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1164, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (__Pyx_PyObject_SetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_headers, __pyx_t_3) < (0)) __PYX_ERR(0, 1164, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "ws_package/controllers/activity_controller.py":1169
 *             'Authorization': f'Bearer {sd_token}',
 *         }
 *         payload = {"user_id": user_id, "org_id": org_id}             # <<<<<<<<<<<<<<
 * 
 *         try:
*/
  __pyx_t_5 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1169, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (PyDict_SetItem(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_user_id, __pyx_cur_scope->__pyx_v_user_id) < (0)) __PYX_ERR(0, 1169, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_org_id, __pyx_cur_scope->__pyx_v_org_id) < (0)) __PYX_ERR(0, 1169, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_5);
  __pyx_cur_scope->__pyx_v_payload = ((PyObject*)__pyx_t_5);
  __pyx_t_5 = 0;

  /* "ws_package/controllers/activity_controller.py":1171
 *         payload = {"user_id": user_id, "org_id": org_id}
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             # Offload the blocking HTTP call to a thread-pool executor.
 *             loop = asyncio.get_event_loop()
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
    __Pyx_XGOTREF(__pyx_t_7);
    __Pyx_XGOTREF(__pyx_t_8);
    __Pyx_XGOTREF(__pyx_t_9);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":1173
 *         try:
 *             # Offload the blocking HTTP call to a thread-pool executor.
 *             loop = asyncio.get_event_loop()             # <<<<<<<<<<<<<<
 *             response_data = await loop.run_in_executor(
 *                 None,
*/
      __pyx_t_3 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1173, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_get_event_loop); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1173, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_6 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
        assert(__pyx_t_3);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
        __pyx_t_6 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
        __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1173, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_5);
      }
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_cur_scope->__pyx_v_loop = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "ws_package/controllers/activity_controller.py":1174
 *             # Offload the blocking HTTP call to a thread-pool executor.
 *             loop = asyncio.get_event_loop()
 *             response_data = await loop.run_in_executor(             # <<<<<<<<<<<<<<
 *                 None,
 *                 self.user_service.fetch_user_org,
*/
      __pyx_t_4 = __pyx_cur_scope->__pyx_v_loop;
      __Pyx_INCREF(__pyx_t_4);

      /* "ws_package/controllers/activity_controller.py":1176
 *             response_data = await loop.run_in_executor(
 *                 None,
 *                 self.user_service.fetch_user_org,             # <<<<<<<<<<<<<<
 *                 payload,
 *             )
*/
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_user_service); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1176, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_fetch_user_org); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1176, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "ws_package/controllers/activity_controller.py":1177
 *                 None,
 *                 self.user_service.fetch_user_org,
 *                 payload,             # <<<<<<<<<<<<<<
 *             )
 * 
*/
      __pyx_t_6 = 0;
      {
        PyObject *__pyx_callargs[4] = {__pyx_t_4, Py_None, __pyx_t_2, __pyx_cur_scope->__pyx_v_payload};
        __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_run_in_executor, __pyx_callargs+__pyx_t_6, (4-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1174, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_5);
      }
      __pyx_t_10 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (likely(__pyx_t_10 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_7);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_7;
        __Pyx_XGIVEREF(__pyx_t_8);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_8;
        __Pyx_XGIVEREF(__pyx_t_9);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 1;
        return __pyx_r;
        __pyx_L11_resume_from_await:;
        __pyx_t_7 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_7);
        __pyx_t_8 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_8);
        __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_9);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1174, __pyx_L5_error)
        __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
      } else if (likely(__pyx_t_10 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __pyx_t_5 = __pyx_r; __pyx_r = NULL;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 1174, __pyx_L5_error)
      }
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_cur_scope->__pyx_v_response_data = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "ws_package/controllers/activity_controller.py":1180
 *             )
 * 
 *             if response_data is None:             # <<<<<<<<<<<<<<
 *                 logger.warning(
 *                     "No org settings from API (rate limit or error)  skipping update_interval apply"
*/
      __pyx_t_1 = (__pyx_cur_scope->__pyx_v_response_data == Py_None);
      if (__pyx_t_1) {

        /* "ws_package/controllers/activity_controller.py":1181
 * 
 *             if response_data is None:
 *                 logger.warning(             # <<<<<<<<<<<<<<
 *                     "No org settings from API (rate limit or error)  skipping update_interval apply"
 *                 )
*/
        __pyx_t_2 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1181, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1181, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_6 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
          assert(__pyx_t_2);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
          __pyx_t_6 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_No_org_settings_from_API_rate_li};
          __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1181, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":1184
 *                     "No org settings from API (rate limit or error)  skipping update_interval apply"
 *                 )
 *                 await self._load_org_settings_from_db()             # <<<<<<<<<<<<<<
 *                 return
 * 
*/
        __pyx_t_3 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_6 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_load_org_settings_from_db, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1184, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __pyx_t_10 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (likely(__pyx_t_10 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_7);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_7;
          __Pyx_XGIVEREF(__pyx_t_8);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_8;
          __Pyx_XGIVEREF(__pyx_t_9);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 2;
          return __pyx_r;
          __pyx_L13_resume_from_await:;
          __pyx_t_7 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_7);
          __pyx_t_8 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_8);
          __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_9);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1184, __pyx_L5_error)
        } else if (likely(__pyx_t_10 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_DECREF(__pyx_r); __pyx_r = 0;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 1184, __pyx_L5_error)
        }

        /* "ws_package/controllers/activity_controller.py":1185
 *                 )
 *                 await self._load_org_settings_from_db()
 *                 return             # <<<<<<<<<<<<<<
 * 
 *             # Extract weekly_limit data if present
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
        goto __pyx_L9_try_return;

        /* "ws_package/controllers/activity_controller.py":1180
 *             )
 * 
 *             if response_data is None:             # <<<<<<<<<<<<<<
 *                 logger.warning(
 *                     "No org settings from API (rate limit or error)  skipping update_interval apply"
*/
      }

      /* "ws_package/controllers/activity_controller.py":1188
 * 
 *             # Extract weekly_limit data if present
 *             weekly_limit_data = response_data.get("weekly_limit")             # <<<<<<<<<<<<<<
 *             if weekly_limit_data:
 *                 # Add weekly_limit fields to response_data for OrgEntity
*/
      __pyx_t_3 = __pyx_cur_scope->__pyx_v_response_data;
      __Pyx_INCREF(__pyx_t_3);
      __pyx_t_6 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_n_u_weekly_limit};
        __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1188, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_5);
      }
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_cur_scope->__pyx_v_weekly_limit_data = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "ws_package/controllers/activity_controller.py":1189
 *             # Extract weekly_limit data if present
 *             weekly_limit_data = response_data.get("weekly_limit")
 *             if weekly_limit_data:             # <<<<<<<<<<<<<<
 *                 # Add weekly_limit fields to response_data for OrgEntity
 *                 response_data["weekly_limit"] = weekly_limit_data
*/
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_weekly_limit_data); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 1189, __pyx_L5_error)
      if (__pyx_t_1) {

        /* "ws_package/controllers/activity_controller.py":1191
 *             if weekly_limit_data:
 *                 # Add weekly_limit fields to response_data for OrgEntity
 *                 response_data["weekly_limit"] = weekly_limit_data             # <<<<<<<<<<<<<<
 *                 response_data["org_week_start_day"] = weekly_limit_data.get("org_week_start_day")
 *                 response_data["worked_total_hours_week"] = weekly_limit_data.get("worked_total_hours_week")
*/
        if (unlikely((PyObject_SetItem(__pyx_cur_scope->__pyx_v_response_data, __pyx_mstate_global->__pyx_n_u_weekly_limit, __pyx_cur_scope->__pyx_v_weekly_limit_data) < 0))) __PYX_ERR(0, 1191, __pyx_L5_error)

        /* "ws_package/controllers/activity_controller.py":1192
 *                 # Add weekly_limit fields to response_data for OrgEntity
 *                 response_data["weekly_limit"] = weekly_limit_data
 *                 response_data["org_week_start_day"] = weekly_limit_data.get("org_week_start_day")             # <<<<<<<<<<<<<<
 *                 response_data["worked_total_hours_week"] = weekly_limit_data.get("worked_total_hours_week")
 *                 response_data["worked_total_hours_week_leaving_today"] = weekly_limit_data.get("worked_total_hours_week_leaving_today")
*/
        __pyx_t_3 = __pyx_cur_scope->__pyx_v_weekly_limit_data;
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_6 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_n_u_org_week_start_day};
          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1192, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        if (unlikely((PyObject_SetItem(__pyx_cur_scope->__pyx_v_response_data, __pyx_mstate_global->__pyx_n_u_org_week_start_day, __pyx_t_5) < 0))) __PYX_ERR(0, 1192, __pyx_L5_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":1193
 *                 response_data["weekly_limit"] = weekly_limit_data
 *                 response_data["org_week_start_day"] = weekly_limit_data.get("org_week_start_day")
 *                 response_data["worked_total_hours_week"] = weekly_limit_data.get("worked_total_hours_week")             # <<<<<<<<<<<<<<
 *                 response_data["worked_total_hours_week_leaving_today"] = weekly_limit_data.get("worked_total_hours_week_leaving_today")
 *                 response_data["daily_limit"] = weekly_limit_data.get("daily_limit")
*/
        __pyx_t_3 = __pyx_cur_scope->__pyx_v_weekly_limit_data;
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_6 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_n_u_worked_total_hours_week};
          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1193, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        if (unlikely((PyObject_SetItem(__pyx_cur_scope->__pyx_v_response_data, __pyx_mstate_global->__pyx_n_u_worked_total_hours_week, __pyx_t_5) < 0))) __PYX_ERR(0, 1193, __pyx_L5_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":1194
 *                 response_data["org_week_start_day"] = weekly_limit_data.get("org_week_start_day")
 *                 response_data["worked_total_hours_week"] = weekly_limit_data.get("worked_total_hours_week")
 *                 response_data["worked_total_hours_week_leaving_today"] = weekly_limit_data.get("worked_total_hours_week_leaving_today")             # <<<<<<<<<<<<<<
 *                 response_data["daily_limit"] = weekly_limit_data.get("daily_limit")
 *                 response_data["weekly_limit_hours"] = weekly_limit_data.get("weekly_limit")
*/
        __pyx_t_3 = __pyx_cur_scope->__pyx_v_weekly_limit_data;
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_6 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_n_u_worked_total_hours_week_leaving};
          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1194, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        if (unlikely((PyObject_SetItem(__pyx_cur_scope->__pyx_v_response_data, __pyx_mstate_global->__pyx_n_u_worked_total_hours_week_leaving, __pyx_t_5) < 0))) __PYX_ERR(0, 1194, __pyx_L5_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":1195
 *                 response_data["worked_total_hours_week"] = weekly_limit_data.get("worked_total_hours_week")
 *                 response_data["worked_total_hours_week_leaving_today"] = weekly_limit_data.get("worked_total_hours_week_leaving_today")
 *                 response_data["daily_limit"] = weekly_limit_data.get("daily_limit")             # <<<<<<<<<<<<<<
 *                 response_data["weekly_limit_hours"] = weekly_limit_data.get("weekly_limit")
 *                 response_data["worked_total_hours_today"] = weekly_limit_data.get("worked_total_hours_today")
*/
        __pyx_t_3 = __pyx_cur_scope->__pyx_v_weekly_limit_data;
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_6 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_n_u_daily_limit};
          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1195, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        if (unlikely((PyObject_SetItem(__pyx_cur_scope->__pyx_v_response_data, __pyx_mstate_global->__pyx_n_u_daily_limit, __pyx_t_5) < 0))) __PYX_ERR(0, 1195, __pyx_L5_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":1196
 *                 response_data["worked_total_hours_week_leaving_today"] = weekly_limit_data.get("worked_total_hours_week_leaving_today")
 *                 response_data["daily_limit"] = weekly_limit_data.get("daily_limit")
 *                 response_data["weekly_limit_hours"] = weekly_limit_data.get("weekly_limit")             # <<<<<<<<<<<<<<
 *                 response_data["worked_total_hours_today"] = weekly_limit_data.get("worked_total_hours_today")
 *                 # limit_action lives inside weekly_limit  must be extracted here, not outside
*/
        __pyx_t_3 = __pyx_cur_scope->__pyx_v_weekly_limit_data;
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_6 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_n_u_weekly_limit};
          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1196, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        if (unlikely((PyObject_SetItem(__pyx_cur_scope->__pyx_v_response_data, __pyx_mstate_global->__pyx_n_u_weekly_limit_hours, __pyx_t_5) < 0))) __PYX_ERR(0, 1196, __pyx_L5_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":1197
 *                 response_data["daily_limit"] = weekly_limit_data.get("daily_limit")
 *                 response_data["weekly_limit_hours"] = weekly_limit_data.get("weekly_limit")
 *                 response_data["worked_total_hours_today"] = weekly_limit_data.get("worked_total_hours_today")             # <<<<<<<<<<<<<<
 *                 # limit_action lives inside weekly_limit  must be extracted here, not outside
 *                 response_data["limit_action"] = weekly_limit_data.get("limit_action")
*/
        __pyx_t_3 = __pyx_cur_scope->__pyx_v_weekly_limit_data;
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_6 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_n_u_worked_total_hours_today};
          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1197, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        if (unlikely((PyObject_SetItem(__pyx_cur_scope->__pyx_v_response_data, __pyx_mstate_global->__pyx_n_u_worked_total_hours_today, __pyx_t_5) < 0))) __PYX_ERR(0, 1197, __pyx_L5_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":1199
 *                 response_data["worked_total_hours_today"] = weekly_limit_data.get("worked_total_hours_today")
 *                 # limit_action lives inside weekly_limit  must be extracted here, not outside
 *                 response_data["limit_action"] = weekly_limit_data.get("limit_action")             # <<<<<<<<<<<<<<
 *             else:
 *                 # API did not return weekly_limit; leave limit_action unset so OrgEntity uses its default
*/
        __pyx_t_3 = __pyx_cur_scope->__pyx_v_weekly_limit_data;
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_6 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_n_u_limit_action};
          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1199, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        if (unlikely((PyObject_SetItem(__pyx_cur_scope->__pyx_v_response_data, __pyx_mstate_global->__pyx_n_u_limit_action, __pyx_t_5) < 0))) __PYX_ERR(0, 1199, __pyx_L5_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":1189
 *             # Extract weekly_limit data if present
 *             weekly_limit_data = response_data.get("weekly_limit")
 *             if weekly_limit_data:             # <<<<<<<<<<<<<<
 *                 # Add weekly_limit fields to response_data for OrgEntity
 *                 response_data["weekly_limit"] = weekly_limit_data
*/
        goto __pyx_L14;
      }

      /* "ws_package/controllers/activity_controller.py":1202
 *             else:
 *                 # API did not return weekly_limit; leave limit_action unset so OrgEntity uses its default
 *                 response_data.setdefault("limit_action", None)             # <<<<<<<<<<<<<<
 * 
 *             # Extract idle_time_limit_in_seconds from API response
*/
      /*else*/ {
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_response_data, __pyx_mstate_global->__pyx_n_u_setdefault); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1202, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_mstate_global->__pyx_tuple[10], NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1202, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __pyx_L14:;

      /* "ws_package/controllers/activity_controller.py":1205
 * 
 *             # Extract idle_time_limit_in_seconds from API response
 *             if "idle_time_limit_in_seconds" in response_data:             # <<<<<<<<<<<<<<
 *                 response_data["idle_time_limit_in_seconds"] = response_data.get("idle_time_limit_in_seconds", 3600)
 *             else:
*/
      __pyx_t_1 = (__Pyx_PySequence_ContainsTF(__pyx_mstate_global->__pyx_n_u_idle_time_limit_in_seconds, __pyx_cur_scope->__pyx_v_response_data, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 1205, __pyx_L5_error)
      if (__pyx_t_1) {

        /* "ws_package/controllers/activity_controller.py":1206
 *             # Extract idle_time_limit_in_seconds from API response
 *             if "idle_time_limit_in_seconds" in response_data:
 *                 response_data["idle_time_limit_in_seconds"] = response_data.get("idle_time_limit_in_seconds", 3600)             # <<<<<<<<<<<<<<
 *             else:
 *                 response_data["idle_time_limit_in_seconds"] = 3600  # Default fallback
*/
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_response_data, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1206, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_mstate_global->__pyx_tuple[11], NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1206, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely((PyObject_SetItem(__pyx_cur_scope->__pyx_v_response_data, __pyx_mstate_global->__pyx_n_u_idle_time_limit_in_seconds, __pyx_t_5) < 0))) __PYX_ERR(0, 1206, __pyx_L5_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":1205
 * 
 *             # Extract idle_time_limit_in_seconds from API response
 *             if "idle_time_limit_in_seconds" in response_data:             # <<<<<<<<<<<<<<
 *                 response_data["idle_time_limit_in_seconds"] = response_data.get("idle_time_limit_in_seconds", 3600)
 *             else:
*/
        goto __pyx_L15;
      }

      /* "ws_package/controllers/activity_controller.py":1208
 *                 response_data["idle_time_limit_in_seconds"] = response_data.get("idle_time_limit_in_seconds", 3600)
 *             else:
 *                 response_data["idle_time_limit_in_seconds"] = 3600  # Default fallback             # <<<<<<<<<<<<<<
 * 
 *             from ws_package.entities.org_entity import normalize_timezone_preference
*/
      /*else*/ {
        if (unlikely((PyObject_SetItem(__pyx_cur_scope->__pyx_v_response_data, __pyx_mstate_global->__pyx_n_u_idle_time_limit_in_seconds, __pyx_mstate_global->__pyx_int_3600) < 0))) __PYX_ERR(0, 1208, __pyx_L5_error)
      }
      __pyx_L15:;

      /* "ws_package/controllers/activity_controller.py":1210
 *                 response_data["idle_time_limit_in_seconds"] = 3600  # Default fallback
 * 
 *             from ws_package.entities.org_entity import normalize_timezone_preference             # <<<<<<<<<<<<<<
 * 
 *             response_data["timezone_preference"] = normalize_timezone_preference(
*/
      {
        PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_normalize_timezone_preference};
        __pyx_t_11 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_entities_org_entity, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1210, __pyx_L5_error)
      }
      __pyx_t_5 = __pyx_t_11;
      __Pyx_GOTREF(__pyx_t_5);
      {
        PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_normalize_timezone_preference};
        __pyx_t_12 = 0; {
          __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_5, __pyx_imported_names[__pyx_t_12]); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1210, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_3);
          switch (__pyx_t_12) {
            case 0:
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_GIVEREF(__pyx_t_3);
            __pyx_cur_scope->__pyx_v_normalize_timezone_preference = __pyx_t_3;
            break;
            default:;
          }
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "ws_package/controllers/activity_controller.py":1212
 *             from ws_package.entities.org_entity import normalize_timezone_preference
 * 
 *             response_data["timezone_preference"] = normalize_timezone_preference(             # <<<<<<<<<<<<<<
 *                 response_data.get("timezone_preference", 1)
 *             )
*/
      __pyx_t_3 = NULL;
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_normalize_timezone_preference);
      __pyx_t_2 = __pyx_cur_scope->__pyx_v_normalize_timezone_preference; 

      /* "ws_package/controllers/activity_controller.py":1213
 * 
 *             response_data["timezone_preference"] = normalize_timezone_preference(
 *                 response_data.get("timezone_preference", 1)             # <<<<<<<<<<<<<<
 *             )
 * 
*/
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_response_data, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1213, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_mstate_global->__pyx_tuple[12], NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1213, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_6 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        assert(__pyx_t_3);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
        __pyx_t_6 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_13};
        __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1212, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_5);
      }

      /* "ws_package/controllers/activity_controller.py":1212
 *             from ws_package.entities.org_entity import normalize_timezone_preference
 * 
 *             response_data["timezone_preference"] = normalize_timezone_preference(             # <<<<<<<<<<<<<<
 *                 response_data.get("timezone_preference", 1)
 *             )
*/
      if (unlikely((PyObject_SetItem(__pyx_cur_scope->__pyx_v_response_data, __pyx_mstate_global->__pyx_n_u_timezone_preference, __pyx_t_5) < 0))) __PYX_ERR(0, 1212, __pyx_L5_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "ws_package/controllers/activity_controller.py":1216
 *             )
 * 
 *             org_entity = OrgEntity(**response_data)             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             logger.exception("Error fetching user org: %s", e)
*/
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_OrgEntity); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1216, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_5);
      if (unlikely(__pyx_cur_scope->__pyx_v_response_data == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType");
        __PYX_ERR(0, 1216, __pyx_L5_error)
      }
      if (likely(PyDict_CheckExact(__pyx_cur_scope->__pyx_v_response_data))) {
        __pyx_t_2 = PyDict_Copy(__pyx_cur_scope->__pyx_v_response_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1216, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_2);
      } else {
        __pyx_t_2 = __Pyx_PyObject_CallOneArg((PyObject*)&PyDict_Type, __pyx_cur_scope->__pyx_v_response_data); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1216, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_2);
      }
      __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_mstate_global->__pyx_empty_tuple, __pyx_t_2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1216, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GIVEREF(__pyx_t_13);
      __pyx_cur_scope->__pyx_v_org_entity = __pyx_t_13;
      __pyx_t_13 = 0;

      /* "ws_package/controllers/activity_controller.py":1171
 *         payload = {"user_id": user_id, "org_id": org_id}
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             # Offload the blocking HTTP call to a thread-pool executor.
 *             loop = asyncio.get_event_loop()
*/
    }
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    goto __pyx_L10_try_end;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "ws_package/controllers/activity_controller.py":1217
 * 
 *             org_entity = OrgEntity(**response_data)
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.exception("Error fetching user org: %s", e)
 *             response_data = None
*/
    __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_14) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.update_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_13, &__pyx_t_2, &__pyx_t_5) < 0) __PYX_ERR(0, 1217, __pyx_L7_except_error)
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_2);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_cur_scope->__pyx_v_e = __pyx_t_2;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":1218
 *             org_entity = OrgEntity(**response_data)
 *         except Exception as e:
 *             logger.exception("Error fetching user org: %s", e)             # <<<<<<<<<<<<<<
 *             response_data = None
 * 
*/
        __pyx_t_4 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1218, __pyx_L21_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_exception); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1218, __pyx_L21_error)
        __Pyx_GOTREF(__pyx_t_16);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __pyx_t_6 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_16))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_16);
          assert(__pyx_t_4);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_16);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_16, __pyx__function);
          __pyx_t_6 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Error_fetching_user_org_s, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_16, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1218, __pyx_L21_error)
          __Pyx_GOTREF(__pyx_t_3);
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "ws_package/controllers/activity_controller.py":1219
 *         except Exception as e:
 *             logger.exception("Error fetching user org: %s", e)
 *             response_data = None             # <<<<<<<<<<<<<<
 * 
 *         if response_data is not None:
*/
        __Pyx_INCREF(Py_None);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_response_data);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_response_data, Py_None);
        __Pyx_GIVEREF(Py_None);
      }

      /* "ws_package/controllers/activity_controller.py":1217
 * 
 *             org_entity = OrgEntity(**response_data)
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.exception("Error fetching user org: %s", e)
 *             response_data = None
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          goto __pyx_L22;
        }
        __pyx_L21_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_11 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
          if ( unlikely(__Pyx_GetException(&__pyx_t_11, &__pyx_t_19, &__pyx_t_20) < 0)) __Pyx_ErrFetch(&__pyx_t_11, &__pyx_t_19, &__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_23);
          __pyx_t_14 = __pyx_lineno; __pyx_t_17 = __pyx_clineno; __pyx_t_18 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_23);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_ErrRestore(__pyx_t_11, __pyx_t_19, __pyx_t_20);
          __pyx_t_11 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
          __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_17; __pyx_filename = __pyx_t_18;
          goto __pyx_L7_except_error;
        }
        __pyx_L22:;
      }
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L6_exception_handled;
    }
    goto __pyx_L7_except_error;

    /* "ws_package/controllers/activity_controller.py":1171
 *         payload = {"user_id": user_id, "org_id": org_id}
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             # Offload the blocking HTTP call to a thread-pool executor.
 *             loop = asyncio.get_event_loop()
*/
    __pyx_L7_except_error:;
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
    goto __pyx_L1_error;
    __pyx_L9_try_return:;
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
    goto __pyx_L0;
    __pyx_L6_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_XGIVEREF(__pyx_t_9);
    __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
    __pyx_L10_try_end:;
  }

  /* "ws_package/controllers/activity_controller.py":1221
 *             response_data = None
 * 
 *         if response_data is not None:             # <<<<<<<<<<<<<<
 * 
 *             # saving into local DB again for the new values
*/
  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_response_data != Py_None);
  if (__pyx_t_1) {

    /* "ws_package/controllers/activity_controller.py":1224
 * 
 *             # saving into local DB again for the new values
 *             await self.user_service.save_user_org(org_entity)             # <<<<<<<<<<<<<<
 * 
 *             if response_data.get("timeInterval") == "5 Min.":
*/
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_user_service); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1224, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_2 = __pyx_t_13;
    __Pyx_INCREF(__pyx_t_2);
    if (unlikely(!__pyx_cur_scope->__pyx_v_org_entity)) { __Pyx_RaiseUnboundLocalError("org_entity"); __PYX_ERR(0, 1224, __pyx_L1_error) }
    __pyx_t_6 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_org_entity};
      __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_save_user_org, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1224, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    __pyx_t_10 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (likely(__pyx_t_10 == PYGEN_NEXT)) {
      __Pyx_GOTREF(__pyx_r);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 3;
      return __pyx_r;
      __pyx_L28_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1224, __pyx_L1_error)
    } else if (likely(__pyx_t_10 == PYGEN_RETURN)) {
      __Pyx_GOTREF(__pyx_r);
      __Pyx_DECREF(__pyx_r); __pyx_r = 0;
    } else {
      __Pyx_XGOTREF(__pyx_r);
      __PYX_ERR(0, 1224, __pyx_L1_error)
    }

    /* "ws_package/controllers/activity_controller.py":1226
 *             await self.user_service.save_user_org(org_entity)
 * 
 *             if response_data.get("timeInterval") == "5 Min.":             # <<<<<<<<<<<<<<
 *                 self.interval = 300
 *             elif response_data.get("timeInterval") == "15 Min.":
*/
    __pyx_t_13 = __pyx_cur_scope->__pyx_v_response_data;
    __Pyx_INCREF(__pyx_t_13);
    __pyx_t_6 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_mstate_global->__pyx_n_u_timeInterval};
      __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1226, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_5_Min, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 1226, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_1) {

      /* "ws_package/controllers/activity_controller.py":1227
 * 
 *             if response_data.get("timeInterval") == "5 Min.":
 *                 self.interval = 300             # <<<<<<<<<<<<<<
 *             elif response_data.get("timeInterval") == "15 Min.":
 *                 self.interval = 900
*/
      if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval, __pyx_mstate_global->__pyx_int_300) < (0)) __PYX_ERR(0, 1227, __pyx_L1_error)

      /* "ws_package/controllers/activity_controller.py":1226
 *             await self.user_service.save_user_org(org_entity)
 * 
 *             if response_data.get("timeInterval") == "5 Min.":             # <<<<<<<<<<<<<<
 *                 self.interval = 300
 *             elif response_data.get("timeInterval") == "15 Min.":
*/
      goto __pyx_L29;
    }

    /* "ws_package/controllers/activity_controller.py":1228
 *             if response_data.get("timeInterval") == "5 Min.":
 *                 self.interval = 300
 *             elif response_data.get("timeInterval") == "15 Min.":             # <<<<<<<<<<<<<<
 *                 self.interval = 900
 *             else:
*/
    __pyx_t_13 = __pyx_cur_scope->__pyx_v_response_data;
    __Pyx_INCREF(__pyx_t_13);
    __pyx_t_6 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_mstate_global->__pyx_n_u_timeInterval};
      __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1228, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_15_Min, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 1228, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_1) {

      /* "ws_package/controllers/activity_controller.py":1229
 *                 self.interval = 300
 *             elif response_data.get("timeInterval") == "15 Min.":
 *                 self.interval = 900             # <<<<<<<<<<<<<<
 *             else:
 *                 self.interval = 600
*/
      if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval, __pyx_mstate_global->__pyx_int_900) < (0)) __PYX_ERR(0, 1229, __pyx_L1_error)

      /* "ws_package/controllers/activity_controller.py":1228
 *             if response_data.get("timeInterval") == "5 Min.":
 *                 self.interval = 300
 *             elif response_data.get("timeInterval") == "15 Min.":             # <<<<<<<<<<<<<<
 *                 self.interval = 900
 *             else:
*/
      goto __pyx_L29;
    }

    /* "ws_package/controllers/activity_controller.py":1231
 *                 self.interval = 900
 *             else:
 *                 self.interval = 600             # <<<<<<<<<<<<<<
 * 
 *             # Cast to int  module-level _to_int() handles None / string values safely.
*/
    /*else*/ {
      if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval, __pyx_mstate_global->__pyx_int_600) < (0)) __PYX_ERR(0, 1231, __pyx_L1_error)
    }
    __pyx_L29:;

    /* "ws_package/controllers/activity_controller.py":1234
 * 
 *             # Cast to int  module-level _to_int() handles None / string values safely.
 *             self.screenshot_interval = _to_int(response_data.get("ssfrequencystatus"), default=0)             # <<<<<<<<<<<<<<
 *             self.appandurlstatus = _to_int(response_data.get("appandurlstatus"), default=0)
 *             self.blur_intensity = _to_int(response_data.get("screenshotblurstatus"), default=0)
*/
    __pyx_t_13 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_to_int); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1234, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_16 = __pyx_cur_scope->__pyx_v_response_data;
    __Pyx_INCREF(__pyx_t_16);
    __pyx_t_6 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_16, __pyx_mstate_global->__pyx_n_u_ssfrequencystatus};
      __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1234, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __pyx_t_6 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_2);
      assert(__pyx_t_13);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
      __pyx_t_6 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_13, __pyx_t_3};
      __pyx_t_16 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1234, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_16);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_default, __pyx_mstate_global->__pyx_int_0, __pyx_t_16, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 1234, __pyx_L1_error)
      __pyx_t_5 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_16);
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1234, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_interval, __pyx_t_5) < (0)) __PYX_ERR(0, 1234, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "ws_package/controllers/activity_controller.py":1235
 *             # Cast to int  module-level _to_int() handles None / string values safely.
 *             self.screenshot_interval = _to_int(response_data.get("ssfrequencystatus"), default=0)
 *             self.appandurlstatus = _to_int(response_data.get("appandurlstatus"), default=0)             # <<<<<<<<<<<<<<
 *             self.blur_intensity = _to_int(response_data.get("screenshotblurstatus"), default=0)
 *             self.notification_status = 0
*/
    __pyx_t_2 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_to_int); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1235, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);
    __pyx_t_13 = __pyx_cur_scope->__pyx_v_response_data;
    __Pyx_INCREF(__pyx_t_13);
    __pyx_t_6 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_mstate_global->__pyx_n_u_appandurlstatus};
      __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1235, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __pyx_t_6 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_16))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_16);
      assert(__pyx_t_2);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_16);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_16, __pyx__function);
      __pyx_t_6 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_2, __pyx_t_3};
      __pyx_t_13 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1235, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_default, __pyx_mstate_global->__pyx_int_0, __pyx_t_13, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 1235, __pyx_L1_error)
      __pyx_t_5 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_16, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_13);
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1235, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus, __pyx_t_5) < (0)) __PYX_ERR(0, 1235, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "ws_package/controllers/activity_controller.py":1236
 *             self.screenshot_interval = _to_int(response_data.get("ssfrequencystatus"), default=0)
 *             self.appandurlstatus = _to_int(response_data.get("appandurlstatus"), default=0)
 *             self.blur_intensity = _to_int(response_data.get("screenshotblurstatus"), default=0)             # <<<<<<<<<<<<<<
 *             self.notification_status = 0
 *             self.org_api_timezone = response_data.get("user_timezone")
*/
    __pyx_t_16 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_to_int); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1236, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_2 = __pyx_cur_scope->__pyx_v_response_data;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_6 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_n_u_screenshotblurstatus};
      __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1236, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __pyx_t_6 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_13))) {
      __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_13);
      assert(__pyx_t_16);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
      __Pyx_INCREF(__pyx_t_16);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
      __pyx_t_6 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_16, __pyx_t_3};
      __pyx_t_2 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1236, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_default, __pyx_mstate_global->__pyx_int_0, __pyx_t_2, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 1236, __pyx_L1_error)
      __pyx_t_5 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_2);
      __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1236, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_blur_intensity, __pyx_t_5) < (0)) __PYX_ERR(0, 1236, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "ws_package/controllers/activity_controller.py":1237
 *             self.appandurlstatus = _to_int(response_data.get("appandurlstatus"), default=0)
 *             self.blur_intensity = _to_int(response_data.get("screenshotblurstatus"), default=0)
 *             self.notification_status = 0             # <<<<<<<<<<<<<<
 *             self.org_api_timezone = response_data.get("user_timezone")
 *             self.limit_action = response_data.get("limit_action")
*/
    if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_notification_status, __pyx_mstate_global->__pyx_int_0) < (0)) __PYX_ERR(0, 1237, __pyx_L1_error)

    /* "ws_package/controllers/activity_controller.py":1238
 *             self.blur_intensity = _to_int(response_data.get("screenshotblurstatus"), default=0)
 *             self.notification_status = 0
 *             self.org_api_timezone = response_data.get("user_timezone")             # <<<<<<<<<<<<<<
 *             self.limit_action = response_data.get("limit_action")
 *             self._apply_org_timezone_preference(
*/
    __pyx_t_13 = __pyx_cur_scope->__pyx_v_response_data;
    __Pyx_INCREF(__pyx_t_13);
    __pyx_t_6 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_mstate_global->__pyx_n_u_user_timezone};
      __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1238, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_org_api_timezone, __pyx_t_5) < (0)) __PYX_ERR(0, 1238, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "ws_package/controllers/activity_controller.py":1239
 *             self.notification_status = 0
 *             self.org_api_timezone = response_data.get("user_timezone")
 *             self.limit_action = response_data.get("limit_action")             # <<<<<<<<<<<<<<
 *             self._apply_org_timezone_preference(
 *                 response_data.get("timezone_preference", 1),
*/
    __pyx_t_13 = __pyx_cur_scope->__pyx_v_response_data;
    __Pyx_INCREF(__pyx_t_13);
    __pyx_t_6 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_mstate_global->__pyx_n_u_limit_action};
      __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1239, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_action, __pyx_t_5) < (0)) __PYX_ERR(0, 1239, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "ws_package/controllers/activity_controller.py":1240
 *             self.org_api_timezone = response_data.get("user_timezone")
 *             self.limit_action = response_data.get("limit_action")
 *             self._apply_org_timezone_preference(             # <<<<<<<<<<<<<<
 *                 response_data.get("timezone_preference", 1),
 *                 user_entity,
*/
    __pyx_t_13 = __pyx_cur_scope->__pyx_v_self;
    __Pyx_INCREF(__pyx_t_13);

    /* "ws_package/controllers/activity_controller.py":1241
 *             self.limit_action = response_data.get("limit_action")
 *             self._apply_org_timezone_preference(
 *                 response_data.get("timezone_preference", 1),             # <<<<<<<<<<<<<<
 *                 user_entity,
 *             )
*/
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_response_data, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1241, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_mstate_global->__pyx_tuple[12], NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1241, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "ws_package/controllers/activity_controller.py":1242
 *             self._apply_org_timezone_preference(
 *                 response_data.get("timezone_preference", 1),
 *                 user_entity,             # <<<<<<<<<<<<<<
 *             )
 * 
*/
    __pyx_t_6 = 0;
    {
      PyObject *__pyx_callargs[3] = {__pyx_t_13, __pyx_t_3, __pyx_cur_scope->__pyx_v_user_entity};
      __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_apply_org_timezone_preference, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1240, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "ws_package/controllers/activity_controller.py":1248
 *             # whether screenshots and app/URL tracking are enabled at the org level.
 *             # ssfrequencystatus=0  screenshots OFF; appandurlstatus=0  tracking OFF.
 *             logger.info(             # <<<<<<<<<<<<<<
 *                 "[update_interval] org settings  ssfrequencystatus=%s, appandurlstatus=%s, "
 *                 "screenshotblurstatus=%s, timeInterval=%s, timezone_preference=%s",
*/
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1248, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1248, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

    /* "ws_package/controllers/activity_controller.py":1251
 *                 "[update_interval] org settings  ssfrequencystatus=%s, appandurlstatus=%s, "
 *                 "screenshotblurstatus=%s, timeInterval=%s, timezone_preference=%s",
 *                 self.screenshot_interval, self.appandurlstatus,             # <<<<<<<<<<<<<<
 *                 self.blur_intensity, response_data.get("timeInterval"),
 *                 self.timezone_preference,
*/
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_interval); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1251, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1251, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_16);

    /* "ws_package/controllers/activity_controller.py":1252
 *                 "screenshotblurstatus=%s, timeInterval=%s, timezone_preference=%s",
 *                 self.screenshot_interval, self.appandurlstatus,
 *                 self.blur_intensity, response_data.get("timeInterval"),             # <<<<<<<<<<<<<<
 *                 self.timezone_preference,
 *             )
*/
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_blur_intensity); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1252, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_24 = __pyx_cur_scope->__pyx_v_response_data;
    __Pyx_INCREF(__pyx_t_24);
    __pyx_t_6 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_24, __pyx_mstate_global->__pyx_n_u_timeInterval};
      __pyx_t_15 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
      if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1252, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
    }

    /* "ws_package/controllers/activity_controller.py":1253
 *                 self.screenshot_interval, self.appandurlstatus,
 *                 self.blur_intensity, response_data.get("timeInterval"),
 *                 self.timezone_preference,             # <<<<<<<<<<<<<<
 *             )
 * 
*/
    __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_timezone_preference); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 1253, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_24);
    __pyx_t_6 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
      __pyx_t_6 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[7] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_update_interval_org_settings_ss, __pyx_t_13, __pyx_t_16, __pyx_t_4, __pyx_t_15, __pyx_t_24};
      __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_6, (7-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1248, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "ws_package/controllers/activity_controller.py":1256
 *             )
 * 
 *             self.screenshot_controller.screenshot_interval = self.screenshot_interval             # <<<<<<<<<<<<<<
 * 
 *             # Store idle_time_limit_in_seconds from API
*/
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_interval); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1256, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1256, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_PyObject_SetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_screenshot_interval, __pyx_t_5) < (0)) __PYX_ERR(0, 1256, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "ws_package/controllers/activity_controller.py":1259
 * 
 *             # Store idle_time_limit_in_seconds from API
 *             self.idle_time_limit_in_seconds = org_entity.idle_time_limit_in_seconds or 3600             # <<<<<<<<<<<<<<
 *             logger.info("Updated idle_time_limit_in_seconds from API: %s seconds", self.idle_time_limit_in_seconds)
 *             self.screenshot_controller.blur_intensity = self.blur_intensity
*/
    if (unlikely(!__pyx_cur_scope->__pyx_v_org_entity)) { __Pyx_RaiseUnboundLocalError("org_entity"); __PYX_ERR(0, 1259, __pyx_L1_error) }
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_org_entity, __pyx_mstate_global->__pyx_n_u_idle_time_limit_in_seconds); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1259, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 1259, __pyx_L1_error)
    if (!__pyx_t_1) {
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    } else {
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_2 = __pyx_t_5;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      goto __pyx_L30_bool_binop_done;
    }
    __pyx_t_5 = __Pyx_PyLong_From_long(0xE10); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1259, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = __pyx_t_5;
    __pyx_t_5 = 0;
    __pyx_L30_bool_binop_done:;
    if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_time_limit_in_seconds, __pyx_t_2) < (0)) __PYX_ERR(0, 1259, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "ws_package/controllers/activity_controller.py":1260
 *             # Store idle_time_limit_in_seconds from API
 *             self.idle_time_limit_in_seconds = org_entity.idle_time_limit_in_seconds or 3600
 *             logger.info("Updated idle_time_limit_in_seconds from API: %s seconds", self.idle_time_limit_in_seconds)             # <<<<<<<<<<<<<<
 *             self.screenshot_controller.blur_intensity = self.blur_intensity
 *             self.screenshot_controller.interval = self.interval
*/
    __pyx_t_5 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 1260, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_24);
    __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1260, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
    __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_time_limit_in_seconds); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 1260, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_24);
    __pyx_t_6 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_15))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_15);
      assert(__pyx_t_5);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
      __pyx_t_6 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Updated_idle_time_limit_in_secon, __pyx_t_24};
      __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1260, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "ws_package/controllers/activity_controller.py":1261
 *             self.idle_time_limit_in_seconds = org_entity.idle_time_limit_in_seconds or 3600
 *             logger.info("Updated idle_time_limit_in_seconds from API: %s seconds", self.idle_time_limit_in_seconds)
 *             self.screenshot_controller.blur_intensity = self.blur_intensity             # <<<<<<<<<<<<<<
 *             self.screenshot_controller.interval = self.interval
 *             self.screenshot_controller.status = self.status
*/
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_blur_intensity); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1261, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1261, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    if (__Pyx_PyObject_SetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_blur_intensity, __pyx_t_2) < (0)) __PYX_ERR(0, 1261, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

    /* "ws_package/controllers/activity_controller.py":1262
 *             logger.info("Updated idle_time_limit_in_seconds from API: %s seconds", self.idle_time_limit_in_seconds)
 *             self.screenshot_controller.blur_intensity = self.blur_intensity
 *             self.screenshot_controller.interval = self.interval             # <<<<<<<<<<<<<<
 *             self.screenshot_controller.status = self.status
 * 
*/
    __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1262, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1262, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    if (__Pyx_PyObject_SetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_interval, __pyx_t_15) < (0)) __PYX_ERR(0, 1262, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "ws_package/controllers/activity_controller.py":1263
 *             self.screenshot_controller.blur_intensity = self.blur_intensity
 *             self.screenshot_controller.interval = self.interval
 *             self.screenshot_controller.status = self.status             # <<<<<<<<<<<<<<
 * 
 *             # Check limits and handle notifications/timer stopping
*/
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1263, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1263, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    if (__Pyx_PyObject_SetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_status, __pyx_t_2) < (0)) __PYX_ERR(0, 1263, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

    /* "ws_package/controllers/activity_controller.py":1266
 * 
 *             # Check limits and handle notifications/timer stopping
 *             await self._check_and_handle_limits(user_entity, org_entity)             # <<<<<<<<<<<<<<
 * 
 *     def _apply_org_timezone_preference(self, preference, user_entity: UserEntity = None) -> None:
*/
    __pyx_t_2 = __pyx_cur_scope->__pyx_v_self;
    __Pyx_INCREF(__pyx_t_2);
    if (unlikely(!__pyx_cur_scope->__pyx_v_org_entity)) { __Pyx_RaiseUnboundLocalError("org_entity"); __PYX_ERR(0, 1266, __pyx_L1_error) }
    __pyx_t_6 = 0;
    {
      PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_user_entity, __pyx_cur_scope->__pyx_v_org_entity};
      __pyx_t_15 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_check_and_handle_limits, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1266, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
    }
    __pyx_t_10 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_15, &__pyx_r);
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    if (likely(__pyx_t_10 == PYGEN_NEXT)) {
      __Pyx_GOTREF(__pyx_r);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 4;
      return __pyx_r;
      __pyx_L32_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1266, __pyx_L1_error)
    } else if (likely(__pyx_t_10 == PYGEN_RETURN)) {
      __Pyx_GOTREF(__pyx_r);
      __Pyx_DECREF(__pyx_r); __pyx_r = 0;
    } else {
      __Pyx_XGOTREF(__pyx_r);
      __PYX_ERR(0, 1266, __pyx_L1_error)
    }

    /* "ws_package/controllers/activity_controller.py":1221
 *             response_data = None
 * 
 *         if response_data is not None:             # <<<<<<<<<<<<<<
 * 
 *             # saving into local DB again for the new values
*/
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":1149
 *         return await self.ensure_s3_credentials_fresh(user_entity)
 * 
 *     async def update_interval(self, user_entity: UserEntity):             # <<<<<<<<<<<<<<
 *         """Refresh org settings (interval, screenshot frequency, limits) from the remote API.
 * 
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_24);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("update_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":1268
 *             await self._check_and_handle_limits(user_entity, org_entity)
 * 
 *     def _apply_org_timezone_preference(self, preference, user_entity: UserEntity = None) -> None:             # <<<<<<<<<<<<<<
 *         """Apply timezone_preference from org settings and toggle time monitor if it flips."""
 *         from ws_package.entities.org_entity import normalize_timezone_preference
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_72_apply_org_timezone_preference(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_71_apply_org_timezone_preference, "Apply timezone_preference from org settings and toggle time monitor if it flips.");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_72_apply_org_timezone_preference = {"_apply_org_timezone_preference", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_72_apply_org_timezone_preference, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_71_apply_org_timezone_preference};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_72_apply_org_timezone_preference(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_preference = 0;
  PyObject *__pyx_v_user_entity = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_apply_org_timezone_preference (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_preference,&__pyx_mstate_global->__pyx_n_u_user_entity,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 1268, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 1268, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1268, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1268, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_apply_org_timezone_preference", 0) < (0)) __PYX_ERR(0, 1268, __pyx_L3_error)
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject *)Py_None));
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_apply_org_timezone_preference", 0, 2, 3, i); __PYX_ERR(0, 1268, __pyx_L3_error) }
      }
    } else {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 1268, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1268, __pyx_L3_error)
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1268, __pyx_L3_error)
        break;
        default: goto __pyx_L5_argtuple_error;
      }
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject *)Py_None));
    }
    __pyx_v_self = values[0];
    __pyx_v_preference = values[1];
    __pyx_v_user_entity = values[2];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_apply_org_timezone_preference", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 1268, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._apply_org_timezone_preference", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_71_apply_org_timezone_preference(__pyx_self, __pyx_v_self, __pyx_v_preference, __pyx_v_user_entity);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_71_apply_org_timezone_preference(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_preference, PyObject *__pyx_v_user_entity) {
  PyObject *__pyx_v_normalize_timezone_preference = NULL;
  PyObject *__pyx_v_previous = NULL;
  PyObject *__pyx_v_normalized = NULL;
  PyObject *__pyx_v_time_monitor = NULL;
  PyObject *__pyx_v_e = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  size_t __pyx_t_6;
  int __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  char const *__pyx_t_17;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_apply_org_timezone_preference", 0);

  /* "ws_package/controllers/activity_controller.py":1270
 *     def _apply_org_timezone_preference(self, preference, user_entity: UserEntity = None) -> None:
 *         """Apply timezone_preference from org settings and toggle time monitor if it flips."""
 *         from ws_package.entities.org_entity import normalize_timezone_preference             # <<<<<<<<<<<<<<
 * 
 *         previous = getattr(self, "timezone_preference", None)
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_normalize_timezone_preference};
    __pyx_t_2 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_entities_org_entity, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1270, __pyx_L1_error)
  }
  __pyx_t_1 = __pyx_t_2;
  __Pyx_GOTREF(__pyx_t_1);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_normalize_timezone_preference};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_1, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1270, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      switch (__pyx_t_3) {
        case 0:
        __Pyx_INCREF(__pyx_t_4);
        __pyx_v_normalize_timezone_preference = __pyx_t_4;
        break;
        default:;
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":1272
 *         from ws_package.entities.org_entity import normalize_timezone_preference
 * 
 *         previous = getattr(self, "timezone_preference", None)             # <<<<<<<<<<<<<<
 *         normalized = normalize_timezone_preference(preference)
 *         self.timezone_preference = normalized
*/
  __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_timezone_preference, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1272, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_previous = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":1273
 * 
 *         previous = getattr(self, "timezone_preference", None)
 *         normalized = normalize_timezone_preference(preference)             # <<<<<<<<<<<<<<
 *         self.timezone_preference = normalized
 *         if user_entity is not None:
*/
  __pyx_t_4 = NULL;
  __Pyx_INCREF(__pyx_v_normalize_timezone_preference);
  __pyx_t_5 = __pyx_v_normalize_timezone_preference; 
  __pyx_t_6 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
    assert(__pyx_t_4);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
    __pyx_t_6 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_v_preference};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1273, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_v_normalized = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":1274
 *         previous = getattr(self, "timezone_preference", None)
 *         normalized = normalize_timezone_preference(preference)
 *         self.timezone_preference = normalized             # <<<<<<<<<<<<<<
 *         if user_entity is not None:
 *             user_entity.timezone_preference = normalized
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_timezone_preference, __pyx_v_normalized) < (0)) __PYX_ERR(0, 1274, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":1275
 *         normalized = normalize_timezone_preference(preference)
 *         self.timezone_preference = normalized
 *         if user_entity is not None:             # <<<<<<<<<<<<<<
 *             user_entity.timezone_preference = normalized
 *         if getattr(self, "user_entity", None) is not None:
*/
  __pyx_t_7 = (__pyx_v_user_entity != Py_None);
  if (__pyx_t_7) {

    /* "ws_package/controllers/activity_controller.py":1276
 *         self.timezone_preference = normalized
 *         if user_entity is not None:
 *             user_entity.timezone_preference = normalized             # <<<<<<<<<<<<<<
 *         if getattr(self, "user_entity", None) is not None:
 *             self.user_entity.timezone_preference = normalized
*/
    if (__Pyx_PyObject_SetAttrStr(__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_timezone_preference, __pyx_v_normalized) < (0)) __PYX_ERR(0, 1276, __pyx_L1_error)

    /* "ws_package/controllers/activity_controller.py":1275
 *         normalized = normalize_timezone_preference(preference)
 *         self.timezone_preference = normalized
 *         if user_entity is not None:             # <<<<<<<<<<<<<<
 *             user_entity.timezone_preference = normalized
 *         if getattr(self, "user_entity", None) is not None:
*/
  }

  /* "ws_package/controllers/activity_controller.py":1277
 *         if user_entity is not None:
 *             user_entity.timezone_preference = normalized
 *         if getattr(self, "user_entity", None) is not None:             # <<<<<<<<<<<<<<
 *             self.user_entity.timezone_preference = normalized
 * 
*/
  __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_user_entity, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1277, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_7 = (__pyx_t_1 != Py_None);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_7) {

    /* "ws_package/controllers/activity_controller.py":1278
 *             user_entity.timezone_preference = normalized
 *         if getattr(self, "user_entity", None) is not None:
 *             self.user_entity.timezone_preference = normalized             # <<<<<<<<<<<<<<
 * 
 *         if previous is None or int(previous) == int(normalized):
*/
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_user_entity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1278, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    if (__Pyx_PyObject_SetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_timezone_preference, __pyx_v_normalized) < (0)) __PYX_ERR(0, 1278, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "ws_package/controllers/activity_controller.py":1277
 *         if user_entity is not None:
 *             user_entity.timezone_preference = normalized
 *         if getattr(self, "user_entity", None) is not None:             # <<<<<<<<<<<<<<
 *             self.user_entity.timezone_preference = normalized
 * 
*/
  }

  /* "ws_package/controllers/activity_controller.py":1280
 *             self.user_entity.timezone_preference = normalized
 * 
 *         if previous is None or int(previous) == int(normalized):             # <<<<<<<<<<<<<<
 *             return
 * 
*/
  __pyx_t_8 = (__pyx_v_previous == Py_None);
  if (!__pyx_t_8) {
  } else {
    __pyx_t_7 = __pyx_t_8;
    goto __pyx_L6_bool_binop_done;
  }
  __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_v_previous); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1280, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = __Pyx_PyNumber_Int(__pyx_v_normalized); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1280, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1280, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 1280, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = __pyx_t_8;
  __pyx_L6_bool_binop_done:;
  if (__pyx_t_7) {

    /* "ws_package/controllers/activity_controller.py":1281
 * 
 *         if previous is None or int(previous) == int(normalized):
 *             return             # <<<<<<<<<<<<<<
 * 
 *         logger.info(
*/
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":1280
 *             self.user_entity.timezone_preference = normalized
 * 
 *         if previous is None or int(previous) == int(normalized):             # <<<<<<<<<<<<<<
 *             return
 * 
*/
  }

  /* "ws_package/controllers/activity_controller.py":1283
 *             return
 * 
 *         logger.info(             # <<<<<<<<<<<<<<
 *             "[TimezonePref] org timezone_preference changed %s  %s",
 *             previous,
*/
  __pyx_t_5 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1283, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":1286
 *             "[TimezonePref] org timezone_preference changed %s  %s",
 *             previous,
 *             normalized,             # <<<<<<<<<<<<<<
 *         )
 *         time_monitor = getattr(getattr(self, "activity_manager", None), "time_monitor", None)
*/
  __pyx_t_6 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_9);
    assert(__pyx_t_5);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
    __pyx_t_6 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[4] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_TimezonePref_org_timezone_prefe, __pyx_v_previous, __pyx_v_normalized};
    __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_6, (4-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1283, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":1288
 *             normalized,
 *         )
 *         time_monitor = getattr(getattr(self, "activity_manager", None), "time_monitor", None)             # <<<<<<<<<<<<<<
 *         if not time_monitor:
 *             return
*/
  __pyx_t_4 = __Pyx_GetAttr3(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_manager, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1288, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_9 = __Pyx_GetAttr3(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_time_monitor, Py_None); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1288, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_time_monitor = __pyx_t_9;
  __pyx_t_9 = 0;

  /* "ws_package/controllers/activity_controller.py":1289
 *         )
 *         time_monitor = getattr(getattr(self, "activity_manager", None), "time_monitor", None)
 *         if not time_monitor:             # <<<<<<<<<<<<<<
 *             return
 *         try:
*/
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_time_monitor); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1289, __pyx_L1_error)
  __pyx_t_8 = (!__pyx_t_7);
  if (__pyx_t_8) {

    /* "ws_package/controllers/activity_controller.py":1290
 *         time_monitor = getattr(getattr(self, "activity_manager", None), "time_monitor", None)
 *         if not time_monitor:
 *             return             # <<<<<<<<<<<<<<
 *         try:
 *             if normalized == 0:
*/
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":1289
 *         )
 *         time_monitor = getattr(getattr(self, "activity_manager", None), "time_monitor", None)
 *         if not time_monitor:             # <<<<<<<<<<<<<<
 *             return
 *         try:
*/
  }

  /* "ws_package/controllers/activity_controller.py":1291
 *         if not time_monitor:
 *             return
 *         try:             # <<<<<<<<<<<<<<
 *             if normalized == 0:
 *                 time_monitor.start_monitoring()
*/
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_2, &__pyx_t_10, &__pyx_t_11);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_10);
    __Pyx_XGOTREF(__pyx_t_11);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":1292
 *             return
 *         try:
 *             if normalized == 0:             # <<<<<<<<<<<<<<
 *                 time_monitor.start_monitoring()
 *                 logger.info("[TimezonePref] Time monitor started after org preference enabled checks")
*/
      __pyx_t_8 = (__Pyx_PyLong_BoolEqObjC(__pyx_v_normalized, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 1292, __pyx_L9_error)
      if (__pyx_t_8) {

        /* "ws_package/controllers/activity_controller.py":1293
 *         try:
 *             if normalized == 0:
 *                 time_monitor.start_monitoring()             # <<<<<<<<<<<<<<
 *                 logger.info("[TimezonePref] Time monitor started after org preference enabled checks")
 *             else:
*/
        __pyx_t_4 = __pyx_v_time_monitor;
        __Pyx_INCREF(__pyx_t_4);
        __pyx_t_6 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
          __pyx_t_9 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_start_monitoring, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1293, __pyx_L9_error)
          __Pyx_GOTREF(__pyx_t_9);
        }
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

        /* "ws_package/controllers/activity_controller.py":1294
 *             if normalized == 0:
 *                 time_monitor.start_monitoring()
 *                 logger.info("[TimezonePref] Time monitor started after org preference enabled checks")             # <<<<<<<<<<<<<<
 *             else:
 *                 time_monitor.stop_monitoring()
*/
        __pyx_t_4 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1294, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1294, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_6 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
          assert(__pyx_t_4);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
          __pyx_t_6 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_TimezonePref_Time_monitor_start};
          __pyx_t_9 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1294, __pyx_L9_error)
          __Pyx_GOTREF(__pyx_t_9);
        }
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

        /* "ws_package/controllers/activity_controller.py":1292
 *             return
 *         try:
 *             if normalized == 0:             # <<<<<<<<<<<<<<
 *                 time_monitor.start_monitoring()
 *                 logger.info("[TimezonePref] Time monitor started after org preference enabled checks")
*/
        goto __pyx_L15;
      }

      /* "ws_package/controllers/activity_controller.py":1296
 *                 logger.info("[TimezonePref] Time monitor started after org preference enabled checks")
 *             else:
 *                 time_monitor.stop_monitoring()             # <<<<<<<<<<<<<<
 *                 logger.info("[TimezonePref] Time monitor stopped after org preference disabled checks")
 *         except Exception as e:
*/
      /*else*/ {
        __pyx_t_1 = __pyx_v_time_monitor;
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_6 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
          __pyx_t_9 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_stop_monitoring, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1296, __pyx_L9_error)
          __Pyx_GOTREF(__pyx_t_9);
        }
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

        /* "ws_package/controllers/activity_controller.py":1297
 *             else:
 *                 time_monitor.stop_monitoring()
 *                 logger.info("[TimezonePref] Time monitor stopped after org preference disabled checks")             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             logger.warning("[TimezonePref] Failed to toggle time monitor: %s", e)
*/
        __pyx_t_1 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1297, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1297, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_6 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
          assert(__pyx_t_1);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
          __pyx_t_6 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_TimezonePref_Time_monitor_stopp};
          __pyx_t_9 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1297, __pyx_L9_error)
          __Pyx_GOTREF(__pyx_t_9);
        }
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      }
      __pyx_L15:;

      /* "ws_package/controllers/activity_controller.py":1291
 *         if not time_monitor:
 *             return
 *         try:             # <<<<<<<<<<<<<<
 *             if normalized == 0:
 *                 time_monitor.start_monitoring()
*/
    }
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    goto __pyx_L14_try_end;
    __pyx_L9_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "ws_package/controllers/activity_controller.py":1298
 *                 time_monitor.stop_monitoring()
 *                 logger.info("[TimezonePref] Time monitor stopped after org preference disabled checks")
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.warning("[TimezonePref] Failed to toggle time monitor: %s", e)
 * 
*/
    __pyx_t_12 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_12) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._apply_org_timezone_preference", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_5, &__pyx_t_1) < 0) __PYX_ERR(0, 1298, __pyx_L11_except_error)
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_5);
      __pyx_v_e = __pyx_t_5;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":1299
 *                 logger.info("[TimezonePref] Time monitor stopped after org preference disabled checks")
 *         except Exception as e:
 *             logger.warning("[TimezonePref] Failed to toggle time monitor: %s", e)             # <<<<<<<<<<<<<<
 * 
 *     async def _load_org_settings_from_db(self):
*/
        __pyx_t_13 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1299, __pyx_L21_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1299, __pyx_L21_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_6 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_15))) {
          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_15);
          assert(__pyx_t_13);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
          __pyx_t_6 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_TimezonePref_Failed_to_toggle_t, __pyx_v_e};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1299, __pyx_L21_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }

      /* "ws_package/controllers/activity_controller.py":1298
 *                 time_monitor.stop_monitoring()
 *                 logger.info("[TimezonePref] Time monitor stopped after org preference disabled checks")
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.warning("[TimezonePref] Failed to toggle time monitor: %s", e)
 * 
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
          goto __pyx_L22;
        }
        __pyx_L21_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
          if ( unlikely(__Pyx_GetException(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20) < 0)) __Pyx_ErrFetch(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_18);
          __Pyx_XGOTREF(__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_23);
          __pyx_t_12 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_17 = __pyx_filename;
          {
            __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_23);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_ErrRestore(__pyx_t_18, __pyx_t_19, __pyx_t_20);
          __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
          __pyx_lineno = __pyx_t_12; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_17;
          goto __pyx_L11_except_error;
        }
        __pyx_L22:;
      }
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L10_exception_handled;
    }
    goto __pyx_L11_except_error;

    /* "ws_package/controllers/activity_controller.py":1291
 *         if not time_monitor:
 *             return
 *         try:             # <<<<<<<<<<<<<<
 *             if normalized == 0:
 *                 time_monitor.start_monitoring()
*/
    __pyx_L11_except_error:;
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_10);
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_10, __pyx_t_11);
    goto __pyx_L1_error;
    __pyx_L10_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_10);
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_ExceptionReset(__pyx_t_2, __pyx_t_10, __pyx_t_11);
    __pyx_L14_try_end:;
  }

  /* "ws_package/controllers/activity_controller.py":1268
 *             await self._check_and_handle_limits(user_entity, org_entity)
 * 
 *     def _apply_org_timezone_preference(self, preference, user_entity: UserEntity = None) -> None:             # <<<<<<<<<<<<<<
 *         """Apply timezone_preference from org settings and toggle time monitor if it flips."""
 *         from ws_package.entities.org_entity import normalize_timezone_preference
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._apply_org_timezone_preference", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_normalize_timezone_preference);
  __Pyx_XDECREF(__pyx_v_previous);
  __Pyx_XDECREF(__pyx_v_normalized);
  __Pyx_XDECREF(__pyx_v_time_monitor);
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_75generator13(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":1301
 *             logger.warning("[TimezonePref] Failed to toggle time monitor: %s", e)
 * 
 *     async def _load_org_settings_from_db(self):             # <<<<<<<<<<<<<<
 *         """Load organization settings from local database as fallback."""
 *         try:
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_74_load_org_settings_from_db(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_73_load_org_settings_from_db, "Load organization settings from local database as fallback.");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_74_load_org_settings_from_db = {"_load_org_settings_from_db", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_74_load_org_settings_from_db, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_73_load_org_settings_from_db};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_74_load_org_settings_from_db(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[1] = {0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_load_org_settings_from_db (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 1301, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1301, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_load_org_settings_from_db", 0) < (0)) __PYX_ERR(0, 1301, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_load_org_settings_from_db", 1, 1, 1, i); __PYX_ERR(0, 1301, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 1)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1301, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_load_org_settings_from_db", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 1301, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._load_org_settings_from_db", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_73_load_org_settings_from_db(__pyx_self, __pyx_v_self);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_73_load_org_settings_from_db(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_load_org_settings_from_db", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1301, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_75generator13, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[13]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_load_org_settings_from_db, __pyx_mstate_global->__pyx_n_u_ActivityController__load_org_set, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 1301, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._load_org_settings_from_db", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_75generator13(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  size_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  __Pyx_PySendResult __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  int __pyx_t_23;
  PyObject *__pyx_t_24 = NULL;
  int __pyx_t_25;
  int __pyx_t_26;
  int __pyx_t_27;
  char const *__pyx_t_28;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_load_org_settings_from_db", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L21_resume_from_await;
    case 2: goto __pyx_L31_resume_from_await;
    case 3: goto __pyx_L37_resume_from_await;
    case 4: goto __pyx_L38_resume_from_await;
    case 5: goto __pyx_L39_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 1301, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":1303
 *     async def _load_org_settings_from_db(self):
 *         """Load organization settings from local database as fallback."""
 *         try:             # <<<<<<<<<<<<<<
 *             # Use centralized read lock
 *             with db_lock_manager.read_lock():
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":1305
 *         try:
 *             # Use centralized read lock
 *             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     query = select(OrgConfigurations).order_by(OrgConfigurations.id.desc()).limit(1)
*/
      /*with:*/ {
        __pyx_t_5 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1305, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1305, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
          assert(__pyx_t_5);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1305, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __pyx_t_9 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1305, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_5 = NULL;
        __pyx_t_6 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1305, __pyx_L10_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (likely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
          assert(__pyx_t_5);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
          __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1305, __pyx_L10_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        /*try:*/ {
          {
            __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
            __Pyx_XGOTREF(__pyx_t_10);
            __Pyx_XGOTREF(__pyx_t_11);
            __Pyx_XGOTREF(__pyx_t_12);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":1306
 *             # Use centralized read lock
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     query = select(OrgConfigurations).order_by(OrgConfigurations.id.desc()).limit(1)
 *                     result = await session.scalars(query)
*/
              /*with:*/ {
                __pyx_t_7 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1306, __pyx_L14_error)
                __Pyx_GOTREF(__pyx_t_6);
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_6))) {
                  __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
                  assert(__pyx_t_7);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                  __Pyx_INCREF(__pyx_t_7);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
                  __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1306, __pyx_L14_error)
                  __Pyx_GOTREF(__pyx_t_4);
                }
                __pyx_t_13 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1306, __pyx_L14_error)
                __Pyx_GOTREF(__pyx_t_13);
                __pyx_t_7 = NULL;
                __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1306, __pyx_L20_error)
                __Pyx_GOTREF(__pyx_t_5);
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (likely(PyMethod_Check(__pyx_t_5))) {
                  __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
                  assert(__pyx_t_7);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                  __Pyx_INCREF(__pyx_t_7);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
                  __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1306, __pyx_L20_error)
                  __Pyx_GOTREF(__pyx_t_6);
                }
                __pyx_t_14 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_6, &__pyx_r);
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                if (likely(__pyx_t_14 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_1);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                  __Pyx_XGIVEREF(__pyx_t_2);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                  __Pyx_XGIVEREF(__pyx_t_3);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                  __Pyx_XGIVEREF(__pyx_t_4);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
                  __Pyx_XGIVEREF(__pyx_t_9);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_9;
                  __Pyx_XGIVEREF(__pyx_t_10);
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_10;
                  __Pyx_XGIVEREF(__pyx_t_11);
                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_11;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 1;
                  return __pyx_r;
                  __pyx_L21_resume_from_await:;
                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_1);
                  __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_2);
                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_3);
                  __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_4);
                  __pyx_t_9 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_9);
                  __pyx_t_10 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = 0;
                  __Pyx_XGOTREF(__pyx_t_10);
                  __pyx_t_11 = __pyx_cur_scope->__pyx_t_6;
                  __pyx_cur_scope->__pyx_t_6 = 0;
                  __Pyx_XGOTREF(__pyx_t_11);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_7;
                  __pyx_cur_scope->__pyx_t_7 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_8;
                  __pyx_cur_scope->__pyx_t_8 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1306, __pyx_L20_error)
                  __pyx_t_6 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_6);
                } else if (likely(__pyx_t_14 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __pyx_t_6 = __pyx_r; __pyx_r = NULL;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 1306, __pyx_L20_error)
                }
                __pyx_t_5 = __pyx_t_6;
                __pyx_t_6 = 0;
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                /*try:*/ {
                  {
                    __Pyx_ExceptionSave(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
                    __Pyx_XGOTREF(__pyx_t_15);
                    __Pyx_XGOTREF(__pyx_t_16);
                    __Pyx_XGOTREF(__pyx_t_17);
                    /*try:*/ {
                      __Pyx_GIVEREF(__pyx_t_5);
                      __pyx_cur_scope->__pyx_v_session = __pyx_t_5;
                      __pyx_t_5 = 0;

                      /* "ws_package/controllers/activity_controller.py":1307
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:
 *                     query = select(OrgConfigurations).order_by(OrgConfigurations.id.desc()).limit(1)             # <<<<<<<<<<<<<<
 *                     result = await session.scalars(query)
 *                     record = result.first()
*/
                      __pyx_t_19 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1307, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_20);
                      __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_OrgConfigurations); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 1307, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __pyx_t_8 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_20))) {
                        __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_20);
                        assert(__pyx_t_19);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_20);
                        __Pyx_INCREF(__pyx_t_19);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_20, __pyx__function);
                        __pyx_t_8 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_19, __pyx_t_21};
                        __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_20, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1307, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_18);
                      }
                      __pyx_t_7 = __pyx_t_18;
                      __Pyx_INCREF(__pyx_t_7);
                      __Pyx_GetModuleGlobalName(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_OrgConfigurations); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 1307, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_19);
                      __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 1307, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                      __pyx_t_21 = __pyx_t_22;
                      __Pyx_INCREF(__pyx_t_21);
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_21, NULL};
                        __pyx_t_20 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_desc, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 1307, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_20);
                      }
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_t_20};
                        __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_order_by, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1307, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_6);
                      }
                      __pyx_t_4 = __pyx_t_6;
                      __Pyx_INCREF(__pyx_t_4);
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_int_1};
                        __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_limit, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1307, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_5);
                      }
                      __Pyx_GIVEREF(__pyx_t_5);
                      __pyx_cur_scope->__pyx_v_query = __pyx_t_5;
                      __pyx_t_5 = 0;

                      /* "ws_package/controllers/activity_controller.py":1308
 *                 async with async_session() as session:
 *                     query = select(OrgConfigurations).order_by(OrgConfigurations.id.desc()).limit(1)
 *                     result = await session.scalars(query)             # <<<<<<<<<<<<<<
 *                     record = result.first()
 * 
*/
                      __pyx_t_6 = __pyx_cur_scope->__pyx_v_session;
                      __Pyx_INCREF(__pyx_t_6);
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_cur_scope->__pyx_v_query};
                        __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalars, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1308, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_5);
                      }
                      __pyx_t_14 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      if (likely(__pyx_t_14 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_9);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 2;
                        return __pyx_r;
                        __pyx_L31_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_9);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1308, __pyx_L25_error)
                        __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
                      } else if (likely(__pyx_t_14 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_5 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 1308, __pyx_L25_error)
                      }
                      __Pyx_GIVEREF(__pyx_t_5);
                      __pyx_cur_scope->__pyx_v_result = __pyx_t_5;
                      __pyx_t_5 = 0;

                      /* "ws_package/controllers/activity_controller.py":1309
 *                     query = select(OrgConfigurations).order_by(OrgConfigurations.id.desc()).limit(1)
 *                     result = await session.scalars(query)
 *                     record = result.first()             # <<<<<<<<<<<<<<
 * 
 *                     if record:
*/
                      __pyx_t_6 = __pyx_cur_scope->__pyx_v_result;
                      __Pyx_INCREF(__pyx_t_6);
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
                        __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_first, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1309, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_5);
                      }
                      __Pyx_GIVEREF(__pyx_t_5);
                      __pyx_cur_scope->__pyx_v_record = __pyx_t_5;
                      __pyx_t_5 = 0;

                      /* "ws_package/controllers/activity_controller.py":1311
 *                     record = result.first()
 * 
 *                     if record:             # <<<<<<<<<<<<<<
 *                         logger.info("Loaded org settings from DB: timezone=%s", record.user_timezone)
 *                         self.org_api_timezone = record.user_timezone
*/
                      __pyx_t_23 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_record); if (unlikely((__pyx_t_23 < 0))) __PYX_ERR(0, 1311, __pyx_L25_error)
                      if (__pyx_t_23) {

                        /* "ws_package/controllers/activity_controller.py":1312
 * 
 *                     if record:
 *                         logger.info("Loaded org settings from DB: timezone=%s", record.user_timezone)             # <<<<<<<<<<<<<<
 *                         self.org_api_timezone = record.user_timezone
 *                         # Also restore other critical settings if needed
*/
                        __pyx_t_6 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1312, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_4);
                        __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1312, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_18);
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_record, __pyx_mstate_global->__pyx_n_u_user_timezone); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1312, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_4);
                        __pyx_t_8 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_18))) {
                          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_18);
                          assert(__pyx_t_6);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_18);
                          __Pyx_INCREF(__pyx_t_6);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_18, __pyx__function);
                          __pyx_t_8 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Loaded_org_settings_from_DB_time, __pyx_t_4};
                          __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_18, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1312, __pyx_L25_error)
                          __Pyx_GOTREF(__pyx_t_5);
                        }
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                        /* "ws_package/controllers/activity_controller.py":1313
 *                     if record:
 *                         logger.info("Loaded org settings from DB: timezone=%s", record.user_timezone)
 *                         self.org_api_timezone = record.user_timezone             # <<<<<<<<<<<<<<
 *                         # Also restore other critical settings if needed
 *                         if record.timeInterval == "5 Min.":
*/
                        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_record, __pyx_mstate_global->__pyx_n_u_user_timezone); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1313, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_5);
                        if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_org_api_timezone, __pyx_t_5) < (0)) __PYX_ERR(0, 1313, __pyx_L25_error)
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                        /* "ws_package/controllers/activity_controller.py":1315
 *                         self.org_api_timezone = record.user_timezone
 *                         # Also restore other critical settings if needed
 *                         if record.timeInterval == "5 Min.":             # <<<<<<<<<<<<<<
 *                             self.interval = 300
 *                         elif record.timeInterval == "15 Min.":
*/
                        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_record, __pyx_mstate_global->__pyx_n_u_timeInterval); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1315, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_5);
                        __pyx_t_23 = (__Pyx_PyUnicode_Equals(__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_5_Min, Py_EQ)); if (unlikely((__pyx_t_23 < 0))) __PYX_ERR(0, 1315, __pyx_L25_error)
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                        if (__pyx_t_23) {

                          /* "ws_package/controllers/activity_controller.py":1316
 *                         # Also restore other critical settings if needed
 *                         if record.timeInterval == "5 Min.":
 *                             self.interval = 300             # <<<<<<<<<<<<<<
 *                         elif record.timeInterval == "15 Min.":
 *                             self.interval = 900
*/
                          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval, __pyx_mstate_global->__pyx_int_300) < (0)) __PYX_ERR(0, 1316, __pyx_L25_error)

                          /* "ws_package/controllers/activity_controller.py":1315
 *                         self.org_api_timezone = record.user_timezone
 *                         # Also restore other critical settings if needed
 *                         if record.timeInterval == "5 Min.":             # <<<<<<<<<<<<<<
 *                             self.interval = 300
 *                         elif record.timeInterval == "15 Min.":
*/
                          goto __pyx_L33;
                        }

                        /* "ws_package/controllers/activity_controller.py":1317
 *                         if record.timeInterval == "5 Min.":
 *                             self.interval = 300
 *                         elif record.timeInterval == "15 Min.":             # <<<<<<<<<<<<<<
 *                             self.interval = 900
 *                         else:
*/
                        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_record, __pyx_mstate_global->__pyx_n_u_timeInterval); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1317, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_5);
                        __pyx_t_23 = (__Pyx_PyUnicode_Equals(__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_15_Min, Py_EQ)); if (unlikely((__pyx_t_23 < 0))) __PYX_ERR(0, 1317, __pyx_L25_error)
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                        if (__pyx_t_23) {

                          /* "ws_package/controllers/activity_controller.py":1318
 *                             self.interval = 300
 *                         elif record.timeInterval == "15 Min.":
 *                             self.interval = 900             # <<<<<<<<<<<<<<
 *                         else:
 *                             self.interval = 600
*/
                          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval, __pyx_mstate_global->__pyx_int_900) < (0)) __PYX_ERR(0, 1318, __pyx_L25_error)

                          /* "ws_package/controllers/activity_controller.py":1317
 *                         if record.timeInterval == "5 Min.":
 *                             self.interval = 300
 *                         elif record.timeInterval == "15 Min.":             # <<<<<<<<<<<<<<
 *                             self.interval = 900
 *                         else:
*/
                          goto __pyx_L33;
                        }

                        /* "ws_package/controllers/activity_controller.py":1320
 *                             self.interval = 900
 *                         else:
 *                             self.interval = 600             # <<<<<<<<<<<<<<
 * 
 *                         # Cast to int  module-level _to_int() handles None / string values safely.
*/
                        /*else*/ {
                          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval, __pyx_mstate_global->__pyx_int_600) < (0)) __PYX_ERR(0, 1320, __pyx_L25_error)
                        }
                        __pyx_L33:;

                        /* "ws_package/controllers/activity_controller.py":1323
 * 
 *                         # Cast to int  module-level _to_int() handles None / string values safely.
 *                         self.screenshot_interval = _to_int(record.ssfrequencystatus)             # <<<<<<<<<<<<<<
 *                         self.appandurlstatus = _to_int(record.appandurlstatus)
 *                         self.blur_intensity = _to_int(record.screenshotblurstatus)
*/
                        __pyx_t_18 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_to_int); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1323, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_4);
                        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_record, __pyx_mstate_global->__pyx_n_u_ssfrequencystatus); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1323, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_6);
                        __pyx_t_8 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_4))) {
                          __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_4);
                          assert(__pyx_t_18);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                          __Pyx_INCREF(__pyx_t_18);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                          __pyx_t_8 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_18, __pyx_t_6};
                          __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1323, __pyx_L25_error)
                          __Pyx_GOTREF(__pyx_t_5);
                        }
                        if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_interval, __pyx_t_5) < (0)) __PYX_ERR(0, 1323, __pyx_L25_error)
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                        /* "ws_package/controllers/activity_controller.py":1324
 *                         # Cast to int  module-level _to_int() handles None / string values safely.
 *                         self.screenshot_interval = _to_int(record.ssfrequencystatus)
 *                         self.appandurlstatus = _to_int(record.appandurlstatus)             # <<<<<<<<<<<<<<
 *                         self.blur_intensity = _to_int(record.screenshotblurstatus)
 *                         self._apply_org_timezone_preference(
*/
                        __pyx_t_4 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_to_int); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1324, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_6);
                        __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_record, __pyx_mstate_global->__pyx_n_u_appandurlstatus); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1324, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_18);
                        __pyx_t_8 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_6))) {
                          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
                          assert(__pyx_t_4);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                          __Pyx_INCREF(__pyx_t_4);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                          __pyx_t_8 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_18};
                          __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1324, __pyx_L25_error)
                          __Pyx_GOTREF(__pyx_t_5);
                        }
                        if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus, __pyx_t_5) < (0)) __PYX_ERR(0, 1324, __pyx_L25_error)
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                        /* "ws_package/controllers/activity_controller.py":1325
 *                         self.screenshot_interval = _to_int(record.ssfrequencystatus)
 *                         self.appandurlstatus = _to_int(record.appandurlstatus)
 *                         self.blur_intensity = _to_int(record.screenshotblurstatus)             # <<<<<<<<<<<<<<
 *                         self._apply_org_timezone_preference(
 *                             getattr(record, "timezone_preference", 1),
*/
                        __pyx_t_6 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_to_int); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1325, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_18);
                        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_record, __pyx_mstate_global->__pyx_n_u_screenshotblurstatus); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1325, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_4);
                        __pyx_t_8 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_18))) {
                          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_18);
                          assert(__pyx_t_6);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_18);
                          __Pyx_INCREF(__pyx_t_6);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_18, __pyx__function);
                          __pyx_t_8 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_4};
                          __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_18, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1325, __pyx_L25_error)
                          __Pyx_GOTREF(__pyx_t_5);
                        }
                        if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_blur_intensity, __pyx_t_5) < (0)) __PYX_ERR(0, 1325, __pyx_L25_error)
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                        /* "ws_package/controllers/activity_controller.py":1326
 *                         self.appandurlstatus = _to_int(record.appandurlstatus)
 *                         self.blur_intensity = _to_int(record.screenshotblurstatus)
 *                         self._apply_org_timezone_preference(             # <<<<<<<<<<<<<<
 *                             getattr(record, "timezone_preference", 1),
 *                             getattr(self, "user_entity", None),
*/
                        __pyx_t_18 = __pyx_cur_scope->__pyx_v_self;
                        __Pyx_INCREF(__pyx_t_18);

                        /* "ws_package/controllers/activity_controller.py":1327
 *                         self.blur_intensity = _to_int(record.screenshotblurstatus)
 *                         self._apply_org_timezone_preference(
 *                             getattr(record, "timezone_preference", 1),             # <<<<<<<<<<<<<<
 *                             getattr(self, "user_entity", None),
 *                         )
*/
                        __pyx_t_4 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_record, __pyx_mstate_global->__pyx_n_u_timezone_preference, __pyx_mstate_global->__pyx_int_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1327, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_4);

                        /* "ws_package/controllers/activity_controller.py":1328
 *                         self._apply_org_timezone_preference(
 *                             getattr(record, "timezone_preference", 1),
 *                             getattr(self, "user_entity", None),             # <<<<<<<<<<<<<<
 *                         )
 * 
*/
                        __pyx_t_6 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_user_entity, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1328, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_6);
                        __pyx_t_8 = 0;
                        {
                          PyObject *__pyx_callargs[3] = {__pyx_t_18, __pyx_t_4, __pyx_t_6};
                          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_apply_org_timezone_preference, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1326, __pyx_L25_error)
                          __Pyx_GOTREF(__pyx_t_5);
                        }
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                        /* "ws_package/controllers/activity_controller.py":1332
 * 
 *                         # Update screenshot controller
 *                         self.screenshot_controller.screenshot_interval = self.screenshot_interval             # <<<<<<<<<<<<<<
 *                         self.screenshot_controller.blur_intensity = self.blur_intensity
 *                         self.screenshot_controller.interval = self.interval
*/
                        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_interval); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1332, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_5);
                        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1332, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_6);
                        if (__Pyx_PyObject_SetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_screenshot_interval, __pyx_t_5) < (0)) __PYX_ERR(0, 1332, __pyx_L25_error)
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

                        /* "ws_package/controllers/activity_controller.py":1333
 *                         # Update screenshot controller
 *                         self.screenshot_controller.screenshot_interval = self.screenshot_interval
 *                         self.screenshot_controller.blur_intensity = self.blur_intensity             # <<<<<<<<<<<<<<
 *                         self.screenshot_controller.interval = self.interval
 * 
*/
                        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_blur_intensity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1333, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_6);
                        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1333, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_5);
                        if (__Pyx_PyObject_SetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_blur_intensity, __pyx_t_6) < (0)) __PYX_ERR(0, 1333, __pyx_L25_error)
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                        /* "ws_package/controllers/activity_controller.py":1334
 *                         self.screenshot_controller.screenshot_interval = self.screenshot_interval
 *                         self.screenshot_controller.blur_intensity = self.blur_intensity
 *                         self.screenshot_controller.interval = self.interval             # <<<<<<<<<<<<<<
 * 
 *                         return True
*/
                        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1334, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_5);
                        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1334, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_6);
                        if (__Pyx_PyObject_SetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_interval, __pyx_t_5) < (0)) __PYX_ERR(0, 1334, __pyx_L25_error)
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

                        /* "ws_package/controllers/activity_controller.py":1336
 *                         self.screenshot_controller.interval = self.interval
 * 
 *                         return True             # <<<<<<<<<<<<<<
 *             return False
 *         except Exception as e:
*/
                        __Pyx_XDECREF(__pyx_r);
                        __Pyx_INCREF(Py_True);
                        __pyx_r = Py_True;
                        goto __pyx_L29_try_return;

                        /* "ws_package/controllers/activity_controller.py":1311
 *                     record = result.first()
 * 
 *                     if record:             # <<<<<<<<<<<<<<
 *                         logger.info("Loaded org settings from DB: timezone=%s", record.user_timezone)
 *                         self.org_api_timezone = record.user_timezone
*/
                      }

                      /* "ws_package/controllers/activity_controller.py":1306
 *             # Use centralized read lock
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     query = select(OrgConfigurations).order_by(OrgConfigurations.id.desc()).limit(1)
 *                     result = await session.scalars(query)
*/
                    }
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                    goto __pyx_L30_try_end;
                    __pyx_L25_error:;
                    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                    /*except:*/ {
                      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._load_org_settings_from_db", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4) < 0) __PYX_ERR(0, 1306, __pyx_L27_except_error)
                      __Pyx_XGOTREF(__pyx_t_6);
                      __Pyx_XGOTREF(__pyx_t_5);
                      __Pyx_XGOTREF(__pyx_t_4);
                      __pyx_t_18 = PyTuple_Pack(3, __pyx_t_6, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1306, __pyx_L27_except_error)
                      __Pyx_GOTREF(__pyx_t_18);
                      __pyx_t_24 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_18, NULL);
                      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                      if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 1306, __pyx_L27_except_error)
                      __Pyx_GOTREF(__pyx_t_24);
                      __pyx_t_14 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_24, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                      if (likely(__pyx_t_14 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_4);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
                        __Pyx_XGIVEREF(__pyx_t_5);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_5;
                        __Pyx_XGIVEREF(__pyx_t_6);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_6;
                        __Pyx_XGIVEREF(__pyx_t_9);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_9;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_11 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_12 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_13 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_24);
                        __pyx_cur_scope->__pyx_t_14 = __pyx_t_24;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_SwapException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 3;
                        return __pyx_r;
                        __pyx_L37_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_4);
                        __pyx_t_5 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_5);
                        __pyx_t_6 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_6);
                        __pyx_t_9 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_9);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_11;
                        __pyx_cur_scope->__pyx_t_11 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_12;
                        __pyx_cur_scope->__pyx_t_12 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_13;
                        __pyx_cur_scope->__pyx_t_13 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_24 = __pyx_cur_scope->__pyx_t_14;
                        __pyx_cur_scope->__pyx_t_14 = 0;
                        __Pyx_XGOTREF(__pyx_t_24);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1306, __pyx_L27_except_error)
                        __pyx_t_18 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_18);
                      } else if (likely(__pyx_t_14 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_18 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 1306, __pyx_L27_except_error)
                      }
                      __pyx_t_24 = __pyx_t_18;
                      __pyx_t_18 = 0;
                      __pyx_t_23 = __Pyx_PyObject_IsTrue(__pyx_t_24);
                      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                      if (__pyx_t_23 < (0)) __PYX_ERR(0, 1306, __pyx_L27_except_error)
                      __pyx_t_25 = (!__pyx_t_23);
                      if (unlikely(__pyx_t_25)) {
                        __Pyx_GIVEREF(__pyx_t_6);
                        __Pyx_GIVEREF(__pyx_t_5);
                        __Pyx_XGIVEREF(__pyx_t_4);
                        __Pyx_ErrRestoreWithState(__pyx_t_6, __pyx_t_5, __pyx_t_4);
                        __pyx_t_6 = 0;  __pyx_t_5 = 0;  __pyx_t_4 = 0; 
                        __PYX_ERR(0, 1306, __pyx_L27_except_error)
                      }
                      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      goto __pyx_L26_exception_handled;
                    }
                    __pyx_L27_except_error:;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
                    goto __pyx_L14_error;
                    __pyx_L29_try_return:;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
                    goto __pyx_L22_return;
                    __pyx_L26_exception_handled:;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
                    __pyx_L30_try_end:;
                  }
                }
                /*finally:*/ {
                  /*normal exit:*/{
                    if (__pyx_t_13) {
                      __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_mstate_global->__pyx_tuple[7], NULL);
                      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                      if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1306, __pyx_L14_error)
                      __Pyx_GOTREF(__pyx_t_17);
                      __pyx_t_14 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_17, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                      if (likely(__pyx_t_14 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_9);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 4;
                        return __pyx_r;
                        __pyx_L38_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_9);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1306, __pyx_L14_error)
                        __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                      } else if (likely(__pyx_t_14 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 1306, __pyx_L14_error)
                      }
                      __pyx_t_17 = __pyx_t_4;
                      __pyx_t_4 = 0;
                      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                    }
                    goto __pyx_L24;
                  }
                  __pyx_L22_return: {
                    __pyx_t_17 = __pyx_r;
                    __pyx_r = 0;
                    if (__pyx_t_13) {
                      __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_mstate_global->__pyx_tuple[7], NULL);
                      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                      if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1306, __pyx_L14_error)
                      __Pyx_GOTREF(__pyx_t_16);
                      __pyx_t_14 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_16, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                      if (likely(__pyx_t_14 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_9);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 5;
                        return __pyx_r;
                        __pyx_L39_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_9);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1306, __pyx_L14_error)
                        __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                      } else if (likely(__pyx_t_14 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 1306, __pyx_L14_error)
                      }
                      __pyx_t_16 = __pyx_t_4;
                      __pyx_t_4 = 0;
                      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                    }
                    __pyx_r = __pyx_t_17;
                    __pyx_t_17 = 0;
                    goto __pyx_L18_try_return;
                  }
                  __pyx_L24:;
                }
                goto __pyx_L40;
                __pyx_L20_error:;
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                goto __pyx_L14_error;
                __pyx_L40:;
              }

              /* "ws_package/controllers/activity_controller.py":1305
 *         try:
 *             # Use centralized read lock
 *             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     query = select(OrgConfigurations).order_by(OrgConfigurations.id.desc()).limit(1)
*/
            }
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            goto __pyx_L19_try_end;
            __pyx_L14_error:;
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
            __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
            __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            /*except:*/ {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._load_org_settings_from_db", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0) __PYX_ERR(0, 1305, __pyx_L16_except_error)
              __Pyx_XGOTREF(__pyx_t_4);
              __Pyx_XGOTREF(__pyx_t_5);
              __Pyx_XGOTREF(__pyx_t_6);
              __pyx_t_18 = PyTuple_Pack(3, __pyx_t_4, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1305, __pyx_L16_except_error)
              __Pyx_GOTREF(__pyx_t_18);
              __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_18, NULL);
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
              if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1305, __pyx_L16_except_error)
              __Pyx_GOTREF(__pyx_t_13);
              __pyx_t_25 = __Pyx_PyObject_IsTrue(__pyx_t_13);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              if (__pyx_t_25 < (0)) __PYX_ERR(0, 1305, __pyx_L16_except_error)
              __pyx_t_23 = (!__pyx_t_25);
              if (unlikely(__pyx_t_23)) {
                __Pyx_GIVEREF(__pyx_t_4);
                __Pyx_GIVEREF(__pyx_t_5);
                __Pyx_XGIVEREF(__pyx_t_6);
                __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_5, __pyx_t_6);
                __pyx_t_4 = 0;  __pyx_t_5 = 0;  __pyx_t_6 = 0; 
                __PYX_ERR(0, 1305, __pyx_L16_except_error)
              }
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              goto __pyx_L15_exception_handled;
            }
            __pyx_L16_except_error:;
            __Pyx_XGIVEREF(__pyx_t_10);
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
            goto __pyx_L4_error;
            __pyx_L18_try_return:;
            __Pyx_XGIVEREF(__pyx_t_10);
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
            goto __pyx_L11_return;
            __pyx_L15_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_10);
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
            __pyx_L19_try_end:;
          }
        }
        /*finally:*/ {
          /*normal exit:*/{
            if (__pyx_t_9) {
              __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_mstate_global->__pyx_tuple[7], NULL);
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
              if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1305, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            }
            goto __pyx_L13;
          }
          __pyx_L11_return: {
            __pyx_t_12 = __pyx_r;
            __pyx_r = 0;
            if (__pyx_t_9) {
              __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_mstate_global->__pyx_tuple[7], NULL);
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
              if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1305, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_11);
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            }
            __pyx_r = __pyx_t_12;
            __pyx_t_12 = 0;
            goto __pyx_L8_try_return;
          }
          __pyx_L13:;
        }
        goto __pyx_L44;
        __pyx_L10_error:;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L4_error;
        __pyx_L44:;
      }

      /* "ws_package/controllers/activity_controller.py":1337
 * 
 *                         return True
 *             return False             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             logger.error("Error loading org settings from DB: %s", e)
*/
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_False);
      __pyx_r = Py_False;
      goto __pyx_L8_try_return;

      /* "ws_package/controllers/activity_controller.py":1303
 *     async def _load_org_settings_from_db(self):
 *         """Load organization settings from local database as fallback."""
 *         try:             # <<<<<<<<<<<<<<
 *             # Use centralized read lock
 *             with db_lock_manager.read_lock():
*/
    }
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "ws_package/controllers/activity_controller.py":1338
 *                         return True
 *             return False
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error loading org settings from DB: %s", e)
 *             return False
*/
    __pyx_t_26 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_26) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._load_org_settings_from_db", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4) < 0) __PYX_ERR(0, 1338, __pyx_L6_except_error)
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_cur_scope->__pyx_v_e = __pyx_t_5;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":1339
 *             return False
 *         except Exception as e:
 *             logger.error("Error loading org settings from DB: %s", e)             # <<<<<<<<<<<<<<
 *             return False
 * 
*/
        __pyx_t_20 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1339, __pyx_L50_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 1339, __pyx_L50_error)
        __Pyx_GOTREF(__pyx_t_22);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_22))) {
          __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_22);
          assert(__pyx_t_20);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_22);
          __Pyx_INCREF(__pyx_t_20);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_22, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_20, __pyx_mstate_global->__pyx_kp_u_Error_loading_org_settings_from, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_22, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
          __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
          if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 1339, __pyx_L50_error)
          __Pyx_GOTREF(__pyx_t_18);
        }
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

        /* "ws_package/controllers/activity_controller.py":1340
 *         except Exception as e:
 *             logger.error("Error loading org settings from DB: %s", e)
 *             return False             # <<<<<<<<<<<<<<
 * 
 *     async def _check_and_handle_limits(self, user_entity: UserEntity, org_entity: OrgEntity):
*/
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_False);
        __pyx_r = Py_False;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        goto __pyx_L49_return;
      }

      /* "ws_package/controllers/activity_controller.py":1338
 *                         return True
 *             return False
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error loading org settings from DB: %s", e)
 *             return False
*/
      /*finally:*/ {
        __pyx_L50_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_9 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_13 = 0; __pyx_t_17 = 0;
          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
          __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
          __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
          __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
          __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_10, &__pyx_t_13, &__pyx_t_17);
          if ( unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_12, &__pyx_t_11) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_12, &__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_9);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_17);
          __pyx_t_26 = __pyx_lineno; __pyx_t_27 = __pyx_clineno; __pyx_t_28 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_13, __pyx_t_17);
          __Pyx_XGIVEREF(__pyx_t_9);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_ErrRestore(__pyx_t_9, __pyx_t_12, __pyx_t_11);
          __pyx_t_9 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_13 = 0; __pyx_t_17 = 0;
          __pyx_lineno = __pyx_t_26; __pyx_clineno = __pyx_t_27; __pyx_filename = __pyx_t_28;
          goto __pyx_L6_except_error;
        }
        __pyx_L49_return: {
          __pyx_t_17 = __pyx_r;
          __pyx_r = 0;
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          __pyx_r = __pyx_t_17;
          __pyx_t_17 = 0;
          goto __pyx_L7_except_return;
        }
      }
    }
    goto __pyx_L6_except_error;

    /* "ws_package/controllers/activity_controller.py":1303
 *     async def _load_org_settings_from_db(self):
 *         """Load organization settings from local database as fallback."""
 *         try:             # <<<<<<<<<<<<<<
 *             # Use centralized read lock
 *             with db_lock_manager.read_lock():
*/
    __pyx_L6_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L7_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":1301
 *             logger.warning("[TimezonePref] Failed to toggle time monitor: %s", e)
 * 
 *     async def _load_org_settings_from_db(self):             # <<<<<<<<<<<<<<
 *         """Load organization settings from local database as fallback."""
 *         try:
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("_load_org_settings_from_db", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_78generator14(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":1342
 *             return False
 * 
 *     async def _check_and_handle_limits(self, user_entity: UserEntity, org_entity: OrgEntity):             # <<<<<<<<<<<<<<
 *         """
 *         Check if daily or weekly limits are exceeded and handle accordingly.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_77_check_and_handle_limits(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_76_check_and_handle_limits, "\n        Check if daily or weekly limits are exceeded and handle accordingly.\n        \n        Args:\n            user_entity: User entity for API calls\n            org_entity: Organization entity with limit data\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_77_check_and_handle_limits = {"_check_and_handle_limits", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_77_check_and_handle_limits, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_76_check_and_handle_limits};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_77_check_and_handle_limits(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_user_entity = 0;
  PyObject *__pyx_v_org_entity = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_check_and_handle_limits (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_user_entity,&__pyx_mstate_global->__pyx_n_u_org_entity,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 1342, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 1342, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1342, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1342, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_check_and_handle_limits", 0) < (0)) __PYX_ERR(0, 1342, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 3; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_check_and_handle_limits", 1, 3, 3, i); __PYX_ERR(0, 1342, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 3)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1342, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1342, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 1342, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_user_entity = values[1];
    __pyx_v_org_entity = values[2];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_check_and_handle_limits", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 1342, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._check_and_handle_limits", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_76_check_and_handle_limits(__pyx_self, __pyx_v_self, __pyx_v_user_entity, __pyx_v_org_entity);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_76_check_and_handle_limits(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity, PyObject *__pyx_v_org_entity) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_check_and_handle_limits", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1342, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_user_entity = __pyx_v_user_entity;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_user_entity);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_user_entity);
  __pyx_cur_scope->__pyx_v_org_entity = __pyx_v_org_entity;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_org_entity);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_org_entity);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_78generator14, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[14]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_check_and_handle_limits, __pyx_mstate_global->__pyx_n_u_ActivityController__check_and_ha, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 1342, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._check_and_handle_limits", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":1384
 * 
 *                 # Report to API (in background thread to avoid blocking)
 *                 def report_in_background():             # <<<<<<<<<<<<<<
 *                     try:
 *                         loop = asyncio.new_event_loop()
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_24_check_and_handle_limits_1report_in_background(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_24_check_and_handle_limits_1report_in_background = {"report_in_background", (PyCFunction)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_24_check_and_handle_limits_1report_in_background, METH_NOARGS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_24_check_and_handle_limits_1report_in_background(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("report_in_background (wrapper)", 0);
  __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_24_check_and_handle_limits_report_in_background(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_24_check_and_handle_limits_report_in_background(PyObject *__pyx_self) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits *__pyx_cur_scope;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits *__pyx_outer_scope;
  PyObject *__pyx_v_loop = NULL;
  PyObject *__pyx_v_e = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  size_t __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  int __pyx_t_17;
  char const *__pyx_t_18;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  char const *__pyx_t_25;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("report_in_background", 0);
  __pyx_outer_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "ws_package/controllers/activity_controller.py":1385
 *                 # Report to API (in background thread to avoid blocking)
 *                 def report_in_background():
 *                     try:             # <<<<<<<<<<<<<<
 *                         loop = asyncio.new_event_loop()
 *                         asyncio.set_event_loop(loop)
*/
  /*try:*/ {
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
      __Pyx_XGOTREF(__pyx_t_1);
      __Pyx_XGOTREF(__pyx_t_2);
      __Pyx_XGOTREF(__pyx_t_3);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":1386
 *                 def report_in_background():
 *                     try:
 *                         loop = asyncio.new_event_loop()             # <<<<<<<<<<<<<<
 *                         asyncio.set_event_loop(loop)
 *                         loop.run_until_complete(
*/
        __pyx_t_5 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1386, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_new_event_loop); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1386, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
          assert(__pyx_t_5);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1386, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __pyx_v_loop = __pyx_t_4;
        __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":1387
 *                     try:
 *                         loop = asyncio.new_event_loop()
 *                         asyncio.set_event_loop(loop)             # <<<<<<<<<<<<<<
 *                         loop.run_until_complete(
 *                             notification_service.report_limit_exceeded(
*/
        __pyx_t_7 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1387, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_set_event_loop); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1387, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
          assert(__pyx_t_7);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_loop};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1387, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":1388
 *                         loop = asyncio.new_event_loop()
 *                         asyncio.set_event_loop(loop)
 *                         loop.run_until_complete(             # <<<<<<<<<<<<<<
 *                             notification_service.report_limit_exceeded(
 *                                 user_entity=user_entity,
*/
        __pyx_t_6 = __pyx_v_loop;
        __Pyx_INCREF(__pyx_t_6);

        /* "ws_package/controllers/activity_controller.py":1389
 *                         asyncio.set_event_loop(loop)
 *                         loop.run_until_complete(
 *                             notification_service.report_limit_exceeded(             # <<<<<<<<<<<<<<
 *                                 user_entity=user_entity,
 *                                 limit_type=limit_type,
*/
        if (unlikely(!__pyx_cur_scope->__pyx_v_notification_service)) { __Pyx_RaiseClosureNameError("notification_service"); __PYX_ERR(0, 1389, __pyx_L6_error) }
        __pyx_t_5 = __pyx_cur_scope->__pyx_v_notification_service;
        __Pyx_INCREF(__pyx_t_5);

        /* "ws_package/controllers/activity_controller.py":1390
 *                         loop.run_until_complete(
 *                             notification_service.report_limit_exceeded(
 *                                 user_entity=user_entity,             # <<<<<<<<<<<<<<
 *                                 limit_type=limit_type,
 *                                 daily_limit=org_entity.daily_limit,
*/
        if (unlikely(!__pyx_cur_scope->__pyx_v_user_entity)) { __Pyx_RaiseClosureNameError("user_entity"); __PYX_ERR(0, 1390, __pyx_L6_error) }

        /* "ws_package/controllers/activity_controller.py":1391
 *                             notification_service.report_limit_exceeded(
 *                                 user_entity=user_entity,
 *                                 limit_type=limit_type,             # <<<<<<<<<<<<<<
 *                                 daily_limit=org_entity.daily_limit,
 *                                 weekly_limit_hours=org_entity.weekly_limit_hours,
*/
        if (unlikely(!__pyx_cur_scope->__pyx_v_limit_type)) { __Pyx_RaiseClosureNameError("limit_type"); __PYX_ERR(0, 1391, __pyx_L6_error) }

        /* "ws_package/controllers/activity_controller.py":1392
 *                                 user_entity=user_entity,
 *                                 limit_type=limit_type,
 *                                 daily_limit=org_entity.daily_limit,             # <<<<<<<<<<<<<<
 *                                 weekly_limit_hours=org_entity.weekly_limit_hours,
 *                                 worked_total_hours_today=org_entity.worked_total_hours_today,
*/
        if (unlikely(!__pyx_cur_scope->__pyx_v_org_entity)) { __Pyx_RaiseClosureNameError("org_entity"); __PYX_ERR(0, 1392, __pyx_L6_error) }
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_org_entity, __pyx_mstate_global->__pyx_n_u_daily_limit); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1392, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_9);

        /* "ws_package/controllers/activity_controller.py":1393
 *                                 limit_type=limit_type,
 *                                 daily_limit=org_entity.daily_limit,
 *                                 weekly_limit_hours=org_entity.weekly_limit_hours,             # <<<<<<<<<<<<<<
 *                                 worked_total_hours_today=org_entity.worked_total_hours_today,
 *                                 worked_total_hours_week=org_entity.worked_total_hours_week,
*/
        if (unlikely(!__pyx_cur_scope->__pyx_v_org_entity)) { __Pyx_RaiseClosureNameError("org_entity"); __PYX_ERR(0, 1393, __pyx_L6_error) }
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_org_entity, __pyx_mstate_global->__pyx_n_u_weekly_limit_hours); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1393, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_10);

        /* "ws_package/controllers/activity_controller.py":1394
 *                                 daily_limit=org_entity.daily_limit,
 *                                 weekly_limit_hours=org_entity.weekly_limit_hours,
 *                                 worked_total_hours_today=org_entity.worked_total_hours_today,             # <<<<<<<<<<<<<<
 *                                 worked_total_hours_week=org_entity.worked_total_hours_week,
 *                                 limit_action=self.limit_action,
*/
        if (unlikely(!__pyx_cur_scope->__pyx_v_org_entity)) { __Pyx_RaiseClosureNameError("org_entity"); __PYX_ERR(0, 1394, __pyx_L6_error) }
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_org_entity, __pyx_mstate_global->__pyx_n_u_worked_total_hours_today); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1394, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_11);

        /* "ws_package/controllers/activity_controller.py":1395
 *                                 weekly_limit_hours=org_entity.weekly_limit_hours,
 *                                 worked_total_hours_today=org_entity.worked_total_hours_today,
 *                                 worked_total_hours_week=org_entity.worked_total_hours_week,             # <<<<<<<<<<<<<<
 *                                 limit_action=self.limit_action,
 *                                 device_id=self.system_unique_id
*/
        if (unlikely(!__pyx_cur_scope->__pyx_v_org_entity)) { __Pyx_RaiseClosureNameError("org_entity"); __PYX_ERR(0, 1395, __pyx_L6_error) }
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_org_entity, __pyx_mstate_global->__pyx_n_u_worked_total_hours_week); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1395, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_12);

        /* "ws_package/controllers/activity_controller.py":1396
 *                                 worked_total_hours_today=org_entity.worked_total_hours_today,
 *                                 worked_total_hours_week=org_entity.worked_total_hours_week,
 *                                 limit_action=self.limit_action,             # <<<<<<<<<<<<<<
 *                                 device_id=self.system_unique_id
 *                             )
*/
        if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1396, __pyx_L6_error) }
        __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_action); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1396, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_13);

        /* "ws_package/controllers/activity_controller.py":1397
 *                                 worked_total_hours_week=org_entity.worked_total_hours_week,
 *                                 limit_action=self.limit_action,
 *                                 device_id=self.system_unique_id             # <<<<<<<<<<<<<<
 *                             )
 *                         )
*/
        if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1397, __pyx_L6_error) }
        __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_system_unique_id); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1397, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 8 : 0)] = {__pyx_t_5, NULL};
          __pyx_t_15 = __Pyx_MakeVectorcallBuilderKwds(8); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1389, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_15);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_user_entity, __pyx_cur_scope->__pyx_v_user_entity, __pyx_t_15, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 1389, __pyx_L6_error)
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_limit_type, __pyx_cur_scope->__pyx_v_limit_type, __pyx_t_15, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 1389, __pyx_L6_error)
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_daily_limit, __pyx_t_9, __pyx_t_15, __pyx_callargs+1, 2) < (0)) __PYX_ERR(0, 1389, __pyx_L6_error)
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_weekly_limit_hours, __pyx_t_10, __pyx_t_15, __pyx_callargs+1, 3) < (0)) __PYX_ERR(0, 1389, __pyx_L6_error)
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_worked_total_hours_today, __pyx_t_11, __pyx_t_15, __pyx_callargs+1, 4) < (0)) __PYX_ERR(0, 1389, __pyx_L6_error)
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_worked_total_hours_week, __pyx_t_12, __pyx_t_15, __pyx_callargs+1, 5) < (0)) __PYX_ERR(0, 1389, __pyx_L6_error)
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_limit_action, __pyx_t_13, __pyx_t_15, __pyx_callargs+1, 6) < (0)) __PYX_ERR(0, 1389, __pyx_L6_error)
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_device_id, __pyx_t_14, __pyx_t_15, __pyx_callargs+1, 7) < (0)) __PYX_ERR(0, 1389, __pyx_L6_error)
          __pyx_t_7 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_report_limit_exceeded, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_15);
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1389, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_7};
          __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_run_until_complete, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1388, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":1385
 *                 # Report to API (in background thread to avoid blocking)
 *                 def report_in_background():
 *                     try:             # <<<<<<<<<<<<<<
 *                         loop = asyncio.new_event_loop()
 *                         asyncio.set_event_loop(loop)
*/
      }
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L11_try_end;
      __pyx_L6_error:;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

      /* "ws_package/controllers/activity_controller.py":1400
 *                             )
 *                         )
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error in background limit notification: %s", e)
 *                     finally:
*/
      __pyx_t_16 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
      if (__pyx_t_16) {
        __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._check_and_handle_limits.report_in_background", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_7, &__pyx_t_6) < 0) __PYX_ERR(0, 1400, __pyx_L8_except_error)
        __Pyx_XGOTREF(__pyx_t_4);
        __Pyx_XGOTREF(__pyx_t_7);
        __Pyx_XGOTREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __pyx_v_e = __pyx_t_7;
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":1401
 *                         )
 *                     except Exception as e:
 *                         logger.error("Error in background limit notification: %s", e)             # <<<<<<<<<<<<<<
 *                     finally:
 *                         loop.close()
*/
          __pyx_t_14 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1401, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1401, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_12))) {
            __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_12);
            assert(__pyx_t_14);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
            __Pyx_INCREF(__pyx_t_14);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_14, __pyx_mstate_global->__pyx_kp_u_Error_in_background_limit_notifi, __pyx_v_e};
            __pyx_t_15 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1401, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_15);
          }
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        }

        /* "ws_package/controllers/activity_controller.py":1400
 *                             )
 *                         )
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error in background limit notification: %s", e)
 *                     finally:
*/
        /*finally:*/ {
          /*normal exit:*/{
            __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
            goto __pyx_L18;
          }
          __pyx_L17_error:;
          /*exception exit:*/{
            __Pyx_PyThreadState_declare
            __Pyx_PyThreadState_assign
            __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0;
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
             __Pyx_ExceptionSwap(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
            if ( unlikely(__Pyx_GetException(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21) < 0)) __Pyx_ErrFetch(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21);
            __Pyx_XGOTREF(__pyx_t_19);
            __Pyx_XGOTREF(__pyx_t_20);
            __Pyx_XGOTREF(__pyx_t_21);
            __Pyx_XGOTREF(__pyx_t_22);
            __Pyx_XGOTREF(__pyx_t_23);
            __Pyx_XGOTREF(__pyx_t_24);
            __pyx_t_16 = __pyx_lineno; __pyx_t_17 = __pyx_clineno; __pyx_t_18 = __pyx_filename;
            {
              __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
            }
            __Pyx_XGIVEREF(__pyx_t_22);
            __Pyx_XGIVEREF(__pyx_t_23);
            __Pyx_XGIVEREF(__pyx_t_24);
            __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_23, __pyx_t_24);
            __Pyx_XGIVEREF(__pyx_t_19);
            __Pyx_XGIVEREF(__pyx_t_20);
            __Pyx_XGIVEREF(__pyx_t_21);
            __Pyx_ErrRestore(__pyx_t_19, __pyx_t_20, __pyx_t_21);
            __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0;
            __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_17; __pyx_filename = __pyx_t_18;
            goto __pyx_L8_except_error;
          }
          __pyx_L18:;
        }
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        goto __pyx_L7_exception_handled;
      }
      goto __pyx_L8_except_error;

      /* "ws_package/controllers/activity_controller.py":1385
 *                 # Report to API (in background thread to avoid blocking)
 *                 def report_in_background():
 *                     try:             # <<<<<<<<<<<<<<
 *                         loop = asyncio.new_event_loop()
 *                         asyncio.set_event_loop(loop)
*/
      __pyx_L8_except_error:;
      __Pyx_XGIVEREF(__pyx_t_1);
      __Pyx_XGIVEREF(__pyx_t_2);
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
      goto __pyx_L4_error;
      __pyx_L7_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_1);
      __Pyx_XGIVEREF(__pyx_t_2);
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
      __pyx_L11_try_end:;
    }
  }

  /* "ws_package/controllers/activity_controller.py":1403
 *                         logger.error("Error in background limit notification: %s", e)
 *                     finally:
 *                         loop.close()             # <<<<<<<<<<<<<<
 * 
 *                 report_thread = threading.Thread(target=report_in_background, name="WeeklyLimitNotification")
*/
  /*finally:*/ {
    /*normal exit:*/{
      if (unlikely(!__pyx_v_loop)) { __Pyx_RaiseUnboundLocalError("loop"); __PYX_ERR(0, 1403, __pyx_L1_error) }
      __pyx_t_7 = __pyx_v_loop;
      __Pyx_INCREF(__pyx_t_7);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
        __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_close, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1403, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      goto __pyx_L5;
    }
    __pyx_L4_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __pyx_t_3 = 0; __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_t_22 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
       __Pyx_ExceptionSwap(&__pyx_t_24, &__pyx_t_23, &__pyx_t_22);
      if ( unlikely(__Pyx_GetException(&__pyx_t_3, &__pyx_t_2, &__pyx_t_1) < 0)) __Pyx_ErrFetch(&__pyx_t_3, &__pyx_t_2, &__pyx_t_1);
      __Pyx_XGOTREF(__pyx_t_3);
      __Pyx_XGOTREF(__pyx_t_2);
      __Pyx_XGOTREF(__pyx_t_1);
      __Pyx_XGOTREF(__pyx_t_24);
      __Pyx_XGOTREF(__pyx_t_23);
      __Pyx_XGOTREF(__pyx_t_22);
      __pyx_t_17 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_25 = __pyx_filename;
      {
        if (unlikely(!__pyx_v_loop)) { __Pyx_RaiseUnboundLocalError("loop"); __PYX_ERR(0, 1403, __pyx_L24_error) }
        __pyx_t_7 = __pyx_v_loop;
        __Pyx_INCREF(__pyx_t_7);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
          __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_close, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1403, __pyx_L24_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __Pyx_XGIVEREF(__pyx_t_24);
      __Pyx_XGIVEREF(__pyx_t_23);
      __Pyx_XGIVEREF(__pyx_t_22);
      __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_23, __pyx_t_22);
      __Pyx_XGIVEREF(__pyx_t_3);
      __Pyx_XGIVEREF(__pyx_t_2);
      __Pyx_XGIVEREF(__pyx_t_1);
      __Pyx_ErrRestore(__pyx_t_3, __pyx_t_2, __pyx_t_1);
      __pyx_t_3 = 0; __pyx_t_2 = 0; __pyx_t_1 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_t_22 = 0;
      __pyx_lineno = __pyx_t_17; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_25;
      goto __pyx_L1_error;
      __pyx_L24_error:;
      __Pyx_XGIVEREF(__pyx_t_24);
      __Pyx_XGIVEREF(__pyx_t_23);
      __Pyx_XGIVEREF(__pyx_t_22);
      __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_23, __pyx_t_22);
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_t_22 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L5:;
  }

  /* "ws_package/controllers/activity_controller.py":1384
 * 
 *                 # Report to API (in background thread to avoid blocking)
 *                 def report_in_background():             # <<<<<<<<<<<<<<
 *                     try:
 *                         loop = asyncio.new_event_loop()
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._check_and_handle_limits.report_in_background", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_loop);
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":1342
 *             return False
 * 
 *     async def _check_and_handle_limits(self, user_entity: UserEntity, org_entity: OrgEntity):             # <<<<<<<<<<<<<<
 *         """
 *         Check if daily or weekly limits are exceeded and handle accordingly.
*/

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_78generator14(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  size_t __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  int __pyx_t_14;
  int __pyx_t_15;
  char const *__pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_check_and_handle_limits", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 1342, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":1350
 *             org_entity: Organization entity with limit data
 *         """
 *         if is_silent_build():             # <<<<<<<<<<<<<<
 *             return
 *         try:
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_is_silent_build); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1350, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
    __pyx_t_4 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1350, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1350, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "ws_package/controllers/activity_controller.py":1351
 *         """
 *         if is_silent_build():
 *             return             # <<<<<<<<<<<<<<
 *         try:
 *             notification_service = get_weekly_limit_notification_service()
*/
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":1350
 *             org_entity: Organization entity with limit data
 *         """
 *         if is_silent_build():             # <<<<<<<<<<<<<<
 *             return
 *         try:
*/
  }

  /* "ws_package/controllers/activity_controller.py":1352
 *         if is_silent_build():
 *             return
 *         try:             # <<<<<<<<<<<<<<
 *             notification_service = get_weekly_limit_notification_service()
 * 
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
    __Pyx_XGOTREF(__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_7);
    __Pyx_XGOTREF(__pyx_t_8);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":1353
 *             return
 *         try:
 *             notification_service = get_weekly_limit_notification_service()             # <<<<<<<<<<<<<<
 * 
 *             # Check if limits are exceeded
*/
      __pyx_t_3 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_get_weekly_limit_notification_se); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1353, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        assert(__pyx_t_3);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
        __pyx_t_4 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
        __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1353, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_cur_scope->__pyx_v_notification_service = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":1356
 * 
 *             # Check if limits are exceeded
 *             limits_check = notification_service.check_limits_exceeded(             # <<<<<<<<<<<<<<
 *                 daily_limit=org_entity.daily_limit,
 *                 weekly_limit_hours=org_entity.weekly_limit_hours,
*/
      __pyx_t_2 = __pyx_cur_scope->__pyx_v_notification_service;
      __Pyx_INCREF(__pyx_t_2);

      /* "ws_package/controllers/activity_controller.py":1357
 *             # Check if limits are exceeded
 *             limits_check = notification_service.check_limits_exceeded(
 *                 daily_limit=org_entity.daily_limit,             # <<<<<<<<<<<<<<
 *                 weekly_limit_hours=org_entity.weekly_limit_hours,
 *                 worked_total_hours_today=org_entity.worked_total_hours_today,
*/
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_org_entity, __pyx_mstate_global->__pyx_n_u_daily_limit); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1357, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_3);

      /* "ws_package/controllers/activity_controller.py":1358
 *             limits_check = notification_service.check_limits_exceeded(
 *                 daily_limit=org_entity.daily_limit,
 *                 weekly_limit_hours=org_entity.weekly_limit_hours,             # <<<<<<<<<<<<<<
 *                 worked_total_hours_today=org_entity.worked_total_hours_today,
 *                 worked_total_hours_week=org_entity.worked_total_hours_week
*/
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_org_entity, __pyx_mstate_global->__pyx_n_u_weekly_limit_hours); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1358, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_9);

      /* "ws_package/controllers/activity_controller.py":1359
 *                 daily_limit=org_entity.daily_limit,
 *                 weekly_limit_hours=org_entity.weekly_limit_hours,
 *                 worked_total_hours_today=org_entity.worked_total_hours_today,             # <<<<<<<<<<<<<<
 *                 worked_total_hours_week=org_entity.worked_total_hours_week
 *             )
*/
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_org_entity, __pyx_mstate_global->__pyx_n_u_worked_total_hours_today); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1359, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_10);

      /* "ws_package/controllers/activity_controller.py":1360
 *                 weekly_limit_hours=org_entity.weekly_limit_hours,
 *                 worked_total_hours_today=org_entity.worked_total_hours_today,
 *                 worked_total_hours_week=org_entity.worked_total_hours_week             # <<<<<<<<<<<<<<
 *             )
 * 
*/
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_org_entity, __pyx_mstate_global->__pyx_n_u_worked_total_hours_week); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1360, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_4 = 0;
      {
        PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 4 : 0)] = {__pyx_t_2, NULL};
        __pyx_t_12 = __Pyx_MakeVectorcallBuilderKwds(4); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1356, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_12);
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_daily_limit, __pyx_t_3, __pyx_t_12, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 1356, __pyx_L5_error)
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_weekly_limit_hours, __pyx_t_9, __pyx_t_12, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 1356, __pyx_L5_error)
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_worked_total_hours_today, __pyx_t_10, __pyx_t_12, __pyx_callargs+1, 2) < (0)) __PYX_ERR(0, 1356, __pyx_L5_error)
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_worked_total_hours_week, __pyx_t_11, __pyx_t_12, __pyx_callargs+1, 3) < (0)) __PYX_ERR(0, 1356, __pyx_L5_error)
        __pyx_t_1 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_check_limits_exceeded, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_12);
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1356, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_cur_scope->__pyx_v_limits_check = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":1363
 *             )
 * 
 *             daily_exceeded = limits_check.get('daily_exceeded', False)             # <<<<<<<<<<<<<<
 *             weekly_exceeded = limits_check.get('weekly_exceeded', False)
 * 
*/
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_limits_check, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1363, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_mstate_global->__pyx_tuple[13], NULL); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1363, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GIVEREF(__pyx_t_12);
      __pyx_cur_scope->__pyx_v_daily_exceeded = __pyx_t_12;
      __pyx_t_12 = 0;

      /* "ws_package/controllers/activity_controller.py":1364
 * 
 *             daily_exceeded = limits_check.get('daily_exceeded', False)
 *             weekly_exceeded = limits_check.get('weekly_exceeded', False)             # <<<<<<<<<<<<<<
 * 
 *             if daily_exceeded or weekly_exceeded:
*/
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_limits_check, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1364, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_mstate_global->__pyx_tuple[14], NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1364, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_cur_scope->__pyx_v_weekly_exceeded = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":1366
 *             weekly_exceeded = limits_check.get('weekly_exceeded', False)
 * 
 *             if daily_exceeded or weekly_exceeded:             # <<<<<<<<<<<<<<
 *                 # Prioritize daily limit if both are exceeded, otherwise use the one that's exceeded
 *                 limit_type = "daily" if daily_exceeded else "weekly"
*/
      __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_daily_exceeded); if (unlikely((__pyx_t_13 < 0))) __PYX_ERR(0, 1366, __pyx_L5_error)
      if (!__pyx_t_13) {
      } else {
        __pyx_t_5 = __pyx_t_13;
        goto __pyx_L12_bool_binop_done;
      }
      __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_weekly_exceeded); if (unlikely((__pyx_t_13 < 0))) __PYX_ERR(0, 1366, __pyx_L5_error)
      __pyx_t_5 = __pyx_t_13;
      __pyx_L12_bool_binop_done:;
      if (__pyx_t_5) {

        /* "ws_package/controllers/activity_controller.py":1368
 *             if daily_exceeded or weekly_exceeded:
 *                 # Prioritize daily limit if both are exceeded, otherwise use the one that's exceeded
 *                 limit_type = "daily" if daily_exceeded else "weekly"             # <<<<<<<<<<<<<<
 * 
 *                 # Log limit exceeded
*/
        __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_daily_exceeded); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1368, __pyx_L5_error)
        if (__pyx_t_5) {
          __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_daily);
          __pyx_t_1 = __pyx_mstate_global->__pyx_n_u_daily;
        } else {
          __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_weekly);
          __pyx_t_1 = __pyx_mstate_global->__pyx_n_u_weekly;
        }
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_v_limit_type = ((PyObject*)__pyx_t_1);
        __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":1371
 * 
 *                 # Log limit exceeded
 *                 logger.info("")             # <<<<<<<<<<<<<<
 *                 logger.info("=" * 80)
 *                 logger.info("*** %s LIMIT EXCEEDED ***", limit_type.upper())
*/
        __pyx_t_12 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1371, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1371, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_10);
          assert(__pyx_t_12);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_12, __pyx_mstate_global->__pyx_kp_u__2};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1371, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":1372
 *                 # Log limit exceeded
 *                 logger.info("")
 *                 logger.info("=" * 80)             # <<<<<<<<<<<<<<
 *                 logger.info("*** %s LIMIT EXCEEDED ***", limit_type.upper())
 *                 logger.info("=" * 80)
*/
        __pyx_t_10 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1372, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1372, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_11))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11);
          assert(__pyx_t_10);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_11, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u__4};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_11, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1372, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":1373
 *                 logger.info("")
 *                 logger.info("=" * 80)
 *                 logger.info("*** %s LIMIT EXCEEDED ***", limit_type.upper())             # <<<<<<<<<<<<<<
 *                 logger.info("=" * 80)
 *                 logger.info("Daily Limit: %s", org_entity.daily_limit)
*/
        __pyx_t_11 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1373, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1373, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_10 = __Pyx_CallUnboundCMethod0(&__pyx_mstate_global->__pyx_umethod_PyUnicode_Type__upper, __pyx_cur_scope->__pyx_v_limit_type); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1373, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_12))) {
          __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_12);
          assert(__pyx_t_11);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_11, __pyx_mstate_global->__pyx_kp_u_s_LIMIT_EXCEEDED, __pyx_t_10};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1373, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":1374
 *                 logger.info("=" * 80)
 *                 logger.info("*** %s LIMIT EXCEEDED ***", limit_type.upper())
 *                 logger.info("=" * 80)             # <<<<<<<<<<<<<<
 *                 logger.info("Daily Limit: %s", org_entity.daily_limit)
 *                 logger.info("Weekly Limit: %s", org_entity.weekly_limit_hours)
*/
        __pyx_t_12 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1374, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1374, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_11))) {
          __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
          assert(__pyx_t_12);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_11, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_12, __pyx_mstate_global->__pyx_kp_u__4};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_11, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1374, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":1375
 *                 logger.info("*** %s LIMIT EXCEEDED ***", limit_type.upper())
 *                 logger.info("=" * 80)
 *                 logger.info("Daily Limit: %s", org_entity.daily_limit)             # <<<<<<<<<<<<<<
 *                 logger.info("Weekly Limit: %s", org_entity.weekly_limit_hours)
 *                 logger.info("Worked Today: %s", org_entity.worked_total_hours_today)
*/
        __pyx_t_11 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1375, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1375, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_org_entity, __pyx_mstate_global->__pyx_n_u_daily_limit); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1375, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10);
          assert(__pyx_t_11);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_11, __pyx_mstate_global->__pyx_kp_u_Daily_Limit_s, __pyx_t_12};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1375, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":1376
 *                 logger.info("=" * 80)
 *                 logger.info("Daily Limit: %s", org_entity.daily_limit)
 *                 logger.info("Weekly Limit: %s", org_entity.weekly_limit_hours)             # <<<<<<<<<<<<<<
 *                 logger.info("Worked Today: %s", org_entity.worked_total_hours_today)
 *                 logger.info("Worked This Week: %s", org_entity.worked_total_hours_week)
*/
        __pyx_t_10 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1376, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1376, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_org_entity, __pyx_mstate_global->__pyx_n_u_weekly_limit_hours); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1376, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_11))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11);
          assert(__pyx_t_10);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_11, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Weekly_Limit_s, __pyx_t_12};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_11, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1376, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":1377
 *                 logger.info("Daily Limit: %s", org_entity.daily_limit)
 *                 logger.info("Weekly Limit: %s", org_entity.weekly_limit_hours)
 *                 logger.info("Worked Today: %s", org_entity.worked_total_hours_today)             # <<<<<<<<<<<<<<
 *                 logger.info("Worked This Week: %s", org_entity.worked_total_hours_week)
 *                 logger.info("Limit Action: %s", self.limit_action)
*/
        __pyx_t_11 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1377, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1377, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_org_entity, __pyx_mstate_global->__pyx_n_u_worked_total_hours_today); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1377, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10);
          assert(__pyx_t_11);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_11, __pyx_mstate_global->__pyx_kp_u_Worked_Today_s, __pyx_t_12};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1377, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":1378
 *                 logger.info("Weekly Limit: %s", org_entity.weekly_limit_hours)
 *                 logger.info("Worked Today: %s", org_entity.worked_total_hours_today)
 *                 logger.info("Worked This Week: %s", org_entity.worked_total_hours_week)             # <<<<<<<<<<<<<<
 *                 logger.info("Limit Action: %s", self.limit_action)
 *                 logger.info("=" * 80)
*/
        __pyx_t_10 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1378, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1378, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_org_entity, __pyx_mstate_global->__pyx_n_u_worked_total_hours_week); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1378, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_11))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11);
          assert(__pyx_t_10);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_11, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Worked_This_Week_s, __pyx_t_12};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_11, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1378, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":1379
 *                 logger.info("Worked Today: %s", org_entity.worked_total_hours_today)
 *                 logger.info("Worked This Week: %s", org_entity.worked_total_hours_week)
 *                 logger.info("Limit Action: %s", self.limit_action)             # <<<<<<<<<<<<<<
 *                 logger.info("=" * 80)
 *                 logger.info("")
*/
        __pyx_t_11 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1379, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1379, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_action); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1379, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10);
          assert(__pyx_t_11);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_11, __pyx_mstate_global->__pyx_kp_u_Limit_Action_s, __pyx_t_12};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1379, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":1380
 *                 logger.info("Worked This Week: %s", org_entity.worked_total_hours_week)
 *                 logger.info("Limit Action: %s", self.limit_action)
 *                 logger.info("=" * 80)             # <<<<<<<<<<<<<<
 *                 logger.info("")
 * 
*/
        __pyx_t_10 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1380, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1380, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_11))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11);
          assert(__pyx_t_10);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_11, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u__4};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_11, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1380, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":1381
 *                 logger.info("Limit Action: %s", self.limit_action)
 *                 logger.info("=" * 80)
 *                 logger.info("")             # <<<<<<<<<<<<<<
 * 
 *                 # Report to API (in background thread to avoid blocking)
*/
        __pyx_t_11 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1381, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1381, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_12))) {
          __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_12);
          assert(__pyx_t_11);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_11, __pyx_mstate_global->__pyx_kp_u__2};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1381, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":1384
 * 
 *                 # Report to API (in background thread to avoid blocking)
 *                 def report_in_background():             # <<<<<<<<<<<<<<
 *                     try:
 *                         loop = asyncio.new_event_loop()
*/
        __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_24_check_and_handle_limits_1report_in_background, 0, __pyx_mstate_global->__pyx_n_u_ActivityController__check_and_ha_2, ((PyObject*)__pyx_cur_scope), __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[15])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1384, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_v_report_in_background = __pyx_t_1;
        __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":1405
 *                         loop.close()
 * 
 *                 report_thread = threading.Thread(target=report_in_background, name="WeeklyLimitNotification")             # <<<<<<<<<<<<<<
 *                 report_thread.daemon = True
 *                 report_thread.start()
*/
        __pyx_t_12 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_threading); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1405, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_Thread); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1405, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_10);
          assert(__pyx_t_12);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 2 : 0)] = {__pyx_t_12, NULL};
          __pyx_t_11 = __Pyx_MakeVectorcallBuilderKwds(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1405, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_11);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_target, __pyx_cur_scope->__pyx_v_report_in_background, __pyx_t_11, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 1405, __pyx_L5_error)
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_name, __pyx_mstate_global->__pyx_n_u_WeeklyLimitNotification, __pyx_t_11, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 1405, __pyx_L5_error)
          __pyx_t_1 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_11);
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1405, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_v_report_thread = __pyx_t_1;
        __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":1406
 * 
 *                 report_thread = threading.Thread(target=report_in_background, name="WeeklyLimitNotification")
 *                 report_thread.daemon = True             # <<<<<<<<<<<<<<
 *                 report_thread.start()
 * 
*/
        if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_report_thread, __pyx_mstate_global->__pyx_n_u_daemon, Py_True) < (0)) __PYX_ERR(0, 1406, __pyx_L5_error)

        /* "ws_package/controllers/activity_controller.py":1407
 *                 report_thread = threading.Thread(target=report_in_background, name="WeeklyLimitNotification")
 *                 report_thread.daemon = True
 *                 report_thread.start()             # <<<<<<<<<<<<<<
 * 
 *                 # Handle timer stopping if limit_action is "stop_timer"
*/
        __pyx_t_10 = __pyx_cur_scope->__pyx_v_report_thread;
        __Pyx_INCREF(__pyx_t_10);
        __pyx_t_4 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_10, NULL};
          __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_start, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1407, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":1410
 * 
 *                 # Handle timer stopping if limit_action is "stop_timer"
 *                 if self.limit_action == "stop_timer":             # <<<<<<<<<<<<<<
 *                     today = datetime.datetime.now().date()
 * 
*/
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_action); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1410, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_stop_timer, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1410, __pyx_L5_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (__pyx_t_5) {

          /* "ws_package/controllers/activity_controller.py":1411
 *                 # Handle timer stopping if limit_action is "stop_timer"
 *                 if self.limit_action == "stop_timer":
 *                     today = datetime.datetime.now().date()             # <<<<<<<<<<<<<<
 * 
 *                     # Only stop if we haven't already stopped today (or date changed)
*/
          __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1411, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1411, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_12 = __pyx_t_3;
          __Pyx_INCREF(__pyx_t_12);
          __pyx_t_4 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_12, NULL};
            __pyx_t_11 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1411, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_11);
          }
          __pyx_t_10 = __pyx_t_11;
          __Pyx_INCREF(__pyx_t_10);
          __pyx_t_4 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_10, NULL};
            __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_date, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1411, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_1);
          }
          __Pyx_GIVEREF(__pyx_t_1);
          __pyx_cur_scope->__pyx_v_today = __pyx_t_1;
          __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":1414
 * 
 *                     # Only stop if we haven't already stopped today (or date changed)
 *                     if self.limit_stopped_date != today:             # <<<<<<<<<<<<<<
 *                         logger.info("")
 *                         logger.info("=" * 80)
*/
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_stopped_date); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1414, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_11 = PyObject_RichCompare(__pyx_t_1, __pyx_cur_scope->__pyx_v_today, Py_NE); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1414, __pyx_L5_error)
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1414, __pyx_L5_error)
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (__pyx_t_5) {

            /* "ws_package/controllers/activity_controller.py":1415
 *                     # Only stop if we haven't already stopped today (or date changed)
 *                     if self.limit_stopped_date != today:
 *                         logger.info("")             # <<<<<<<<<<<<<<
 *                         logger.info("=" * 80)
 *                         logger.info("*** STOPPING TIMER DUE TO LIMIT EXCEEDED ***")
*/
            __pyx_t_1 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1415, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1415, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_3))) {
              __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
              assert(__pyx_t_1);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
              __Pyx_INCREF(__pyx_t_1);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u__2};
              __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1415, __pyx_L5_error)
              __Pyx_GOTREF(__pyx_t_11);
            }
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

            /* "ws_package/controllers/activity_controller.py":1416
 *                     if self.limit_stopped_date != today:
 *                         logger.info("")
 *                         logger.info("=" * 80)             # <<<<<<<<<<<<<<
 *                         logger.info("*** STOPPING TIMER DUE TO LIMIT EXCEEDED ***")
 *                         logger.info("=" * 80)
*/
            __pyx_t_3 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1416, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1416, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_10))) {
              __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10);
              assert(__pyx_t_3);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u__4};
              __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1416, __pyx_L5_error)
              __Pyx_GOTREF(__pyx_t_11);
            }
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

            /* "ws_package/controllers/activity_controller.py":1417
 *                         logger.info("")
 *                         logger.info("=" * 80)
 *                         logger.info("*** STOPPING TIMER DUE TO LIMIT EXCEEDED ***")             # <<<<<<<<<<<<<<
 *                         logger.info("=" * 80)
 *                         logger.info("Limit Action: %s", self.limit_action)
*/
            __pyx_t_10 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1417, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1417, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_1))) {
              __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1);
              assert(__pyx_t_10);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
              __Pyx_INCREF(__pyx_t_10);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_STOPPING_TIMER_DUE_TO_LIMIT_EXC};
              __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1417, __pyx_L5_error)
              __Pyx_GOTREF(__pyx_t_11);
            }
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

            /* "ws_package/controllers/activity_controller.py":1418
 *                         logger.info("=" * 80)
 *                         logger.info("*** STOPPING TIMER DUE TO LIMIT EXCEEDED ***")
 *                         logger.info("=" * 80)             # <<<<<<<<<<<<<<
 *                         logger.info("Limit Action: %s", self.limit_action)
 *                         logger.info("Limit Type: %s", limit_type)
*/
            __pyx_t_1 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1418, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1418, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_3))) {
              __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
              assert(__pyx_t_1);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
              __Pyx_INCREF(__pyx_t_1);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u__4};
              __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1418, __pyx_L5_error)
              __Pyx_GOTREF(__pyx_t_11);
            }
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

            /* "ws_package/controllers/activity_controller.py":1419
 *                         logger.info("*** STOPPING TIMER DUE TO LIMIT EXCEEDED ***")
 *                         logger.info("=" * 80)
 *                         logger.info("Limit Action: %s", self.limit_action)             # <<<<<<<<<<<<<<
 *                         logger.info("Limit Type: %s", limit_type)
 *                         logger.info("Timer will remain stopped until date changes or system restarts")
*/
            __pyx_t_3 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1419, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1419, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_action); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1419, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_10))) {
              __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10);
              assert(__pyx_t_3);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Limit_Action_s, __pyx_t_1};
              __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1419, __pyx_L5_error)
              __Pyx_GOTREF(__pyx_t_11);
            }
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

            /* "ws_package/controllers/activity_controller.py":1420
 *                         logger.info("=" * 80)
 *                         logger.info("Limit Action: %s", self.limit_action)
 *                         logger.info("Limit Type: %s", limit_type)             # <<<<<<<<<<<<<<
 *                         logger.info("Timer will remain stopped until date changes or system restarts")
 *                         logger.info("=" * 80)
*/
            __pyx_t_10 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1420, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1420, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_3))) {
              __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3);
              assert(__pyx_t_10);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
              __Pyx_INCREF(__pyx_t_10);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Limit_Type_s, __pyx_cur_scope->__pyx_v_limit_type};
              __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1420, __pyx_L5_error)
              __Pyx_GOTREF(__pyx_t_11);
            }
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

            /* "ws_package/controllers/activity_controller.py":1421
 *                         logger.info("Limit Action: %s", self.limit_action)
 *                         logger.info("Limit Type: %s", limit_type)
 *                         logger.info("Timer will remain stopped until date changes or system restarts")             # <<<<<<<<<<<<<<
 *                         logger.info("=" * 80)
 *                         logger.info("")
*/
            __pyx_t_3 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1421, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1421, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_1))) {
              __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
              assert(__pyx_t_3);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Timer_will_remain_stopped_until};
              __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1421, __pyx_L5_error)
              __Pyx_GOTREF(__pyx_t_11);
            }
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

            /* "ws_package/controllers/activity_controller.py":1422
 *                         logger.info("Limit Type: %s", limit_type)
 *                         logger.info("Timer will remain stopped until date changes or system restarts")
 *                         logger.info("=" * 80)             # <<<<<<<<<<<<<<
 *                         logger.info("")
 * 
*/
            __pyx_t_1 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1422, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1422, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_10))) {
              __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_10);
              assert(__pyx_t_1);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
              __Pyx_INCREF(__pyx_t_1);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u__4};
              __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1422, __pyx_L5_error)
              __Pyx_GOTREF(__pyx_t_11);
            }
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

            /* "ws_package/controllers/activity_controller.py":1423
 *                         logger.info("Timer will remain stopped until date changes or system restarts")
 *                         logger.info("=" * 80)
 *                         logger.info("")             # <<<<<<<<<<<<<<
 * 
 *                         self.status = False
*/
            __pyx_t_10 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1423, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1423, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_3))) {
              __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3);
              assert(__pyx_t_10);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
              __Pyx_INCREF(__pyx_t_10);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u__2};
              __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1423, __pyx_L5_error)
              __Pyx_GOTREF(__pyx_t_11);
            }
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

            /* "ws_package/controllers/activity_controller.py":1425
 *                         logger.info("")
 * 
 *                         self.status = False             # <<<<<<<<<<<<<<
 *                         self.limit_stopped_date = today
 *                         self.force_stop = True
*/
            if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status, Py_False) < (0)) __PYX_ERR(0, 1425, __pyx_L5_error)

            /* "ws_package/controllers/activity_controller.py":1426
 * 
 *                         self.status = False
 *                         self.limit_stopped_date = today             # <<<<<<<<<<<<<<
 *                         self.force_stop = True
 * 
*/
            if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_stopped_date, __pyx_cur_scope->__pyx_v_today) < (0)) __PYX_ERR(0, 1426, __pyx_L5_error)

            /* "ws_package/controllers/activity_controller.py":1427
 *                         self.status = False
 *                         self.limit_stopped_date = today
 *                         self.force_stop = True             # <<<<<<<<<<<<<<
 * 
 *                         # Also stop screenshot controller
*/
            if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_force_stop, Py_True) < (0)) __PYX_ERR(0, 1427, __pyx_L5_error)

            /* "ws_package/controllers/activity_controller.py":1430
 * 
 *                         # Also stop screenshot controller
 *                         if hasattr(self.screenshot_controller, 'status'):             # <<<<<<<<<<<<<<
 *                             self.screenshot_controller.status = False
 *                 else:
*/
            __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1430, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_11);
            __pyx_t_5 = __Pyx_HasAttr(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 1430, __pyx_L5_error)
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            if (__pyx_t_5) {

              /* "ws_package/controllers/activity_controller.py":1431
 *                         # Also stop screenshot controller
 *                         if hasattr(self.screenshot_controller, 'status'):
 *                             self.screenshot_controller.status = False             # <<<<<<<<<<<<<<
 *                 else:
 *                     # just_notify - continue tracking, just log
*/
              __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1431, __pyx_L5_error)
              __Pyx_GOTREF(__pyx_t_11);
              if (__Pyx_PyObject_SetAttrStr(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_status, Py_False) < (0)) __PYX_ERR(0, 1431, __pyx_L5_error)
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

              /* "ws_package/controllers/activity_controller.py":1430
 * 
 *                         # Also stop screenshot controller
 *                         if hasattr(self.screenshot_controller, 'status'):             # <<<<<<<<<<<<<<
 *                             self.screenshot_controller.status = False
 *                 else:
*/
            }

            /* "ws_package/controllers/activity_controller.py":1414
 * 
 *                     # Only stop if we haven't already stopped today (or date changed)
 *                     if self.limit_stopped_date != today:             # <<<<<<<<<<<<<<
 *                         logger.info("")
 *                         logger.info("=" * 80)
*/
          }

          /* "ws_package/controllers/activity_controller.py":1410
 * 
 *                 # Handle timer stopping if limit_action is "stop_timer"
 *                 if self.limit_action == "stop_timer":             # <<<<<<<<<<<<<<
 *                     today = datetime.datetime.now().date()
 * 
*/
          goto __pyx_L14;
        }

        /* "ws_package/controllers/activity_controller.py":1434
 *                 else:
 *                     # just_notify - continue tracking, just log
 *                     logger.info("")             # <<<<<<<<<<<<<<
 *                     logger.info("=" * 80)
 *                     logger.info("*** LIMIT EXCEEDED - NOTIFICATION ONLY ***")
*/
        /*else*/ {
          __pyx_t_3 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1434, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1434, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_4 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_1))) {
            __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
            assert(__pyx_t_3);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
            __pyx_t_4 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u__2};
            __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1434, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_11);
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

          /* "ws_package/controllers/activity_controller.py":1435
 *                     # just_notify - continue tracking, just log
 *                     logger.info("")
 *                     logger.info("=" * 80)             # <<<<<<<<<<<<<<
 *                     logger.info("*** LIMIT EXCEEDED - NOTIFICATION ONLY ***")
 *                     logger.info("=" * 80)
*/
          __pyx_t_1 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1435, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1435, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_4 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_10))) {
            __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_10);
            assert(__pyx_t_1);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
            __pyx_t_4 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u__4};
            __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1435, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_11);
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

          /* "ws_package/controllers/activity_controller.py":1436
 *                     logger.info("")
 *                     logger.info("=" * 80)
 *                     logger.info("*** LIMIT EXCEEDED - NOTIFICATION ONLY ***")             # <<<<<<<<<<<<<<
 *                     logger.info("=" * 80)
 *                     logger.info("Limit Action: %s", self.limit_action)
*/
          __pyx_t_10 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1436, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1436, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_4 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_3))) {
            __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3);
            assert(__pyx_t_10);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
            __pyx_t_4 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_LIMIT_EXCEEDED_NOTIFICATION_ONL};
            __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1436, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_11);
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

          /* "ws_package/controllers/activity_controller.py":1437
 *                     logger.info("=" * 80)
 *                     logger.info("*** LIMIT EXCEEDED - NOTIFICATION ONLY ***")
 *                     logger.info("=" * 80)             # <<<<<<<<<<<<<<
 *                     logger.info("Limit Action: %s", self.limit_action)
 *                     logger.info("Tracking will continue as normal")
*/
          __pyx_t_3 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1437, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1437, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_4 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_1))) {
            __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
            assert(__pyx_t_3);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
            __pyx_t_4 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u__4};
            __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1437, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_11);
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

          /* "ws_package/controllers/activity_controller.py":1438
 *                     logger.info("*** LIMIT EXCEEDED - NOTIFICATION ONLY ***")
 *                     logger.info("=" * 80)
 *                     logger.info("Limit Action: %s", self.limit_action)             # <<<<<<<<<<<<<<
 *                     logger.info("Tracking will continue as normal")
 *                     logger.info("=" * 80)
*/
          __pyx_t_1 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1438, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1438, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_action); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1438, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_10))) {
            __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_10);
            assert(__pyx_t_1);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
            __pyx_t_4 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Limit_Action_s, __pyx_t_3};
            __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1438, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_11);
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

          /* "ws_package/controllers/activity_controller.py":1439
 *                     logger.info("=" * 80)
 *                     logger.info("Limit Action: %s", self.limit_action)
 *                     logger.info("Tracking will continue as normal")             # <<<<<<<<<<<<<<
 *                     logger.info("=" * 80)
 *                     logger.info("")
*/
          __pyx_t_10 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1439, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1439, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_4 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_1))) {
            __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1);
            assert(__pyx_t_10);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
            __pyx_t_4 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Tracking_will_continue_as_normal};
            __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1439, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_11);
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

          /* "ws_package/controllers/activity_controller.py":1440
 *                     logger.info("Limit Action: %s", self.limit_action)
 *                     logger.info("Tracking will continue as normal")
 *                     logger.info("=" * 80)             # <<<<<<<<<<<<<<
 *                     logger.info("")
 * 
*/
          __pyx_t_1 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1440, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1440, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_4 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_3))) {
            __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
            assert(__pyx_t_1);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
            __pyx_t_4 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u__4};
            __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1440, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_11);
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

          /* "ws_package/controllers/activity_controller.py":1441
 *                     logger.info("Tracking will continue as normal")
 *                     logger.info("=" * 80)
 *                     logger.info("")             # <<<<<<<<<<<<<<
 * 
 *         except Exception as e:
*/
          __pyx_t_3 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1441, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1441, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_4 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_10))) {
            __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10);
            assert(__pyx_t_3);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
            __pyx_t_4 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u__2};
            __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1441, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_11);
          }
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        }
        __pyx_L14:;

        /* "ws_package/controllers/activity_controller.py":1366
 *             weekly_exceeded = limits_check.get('weekly_exceeded', False)
 * 
 *             if daily_exceeded or weekly_exceeded:             # <<<<<<<<<<<<<<
 *                 # Prioritize daily limit if both are exceeded, otherwise use the one that's exceeded
 *                 limit_type = "daily" if daily_exceeded else "weekly"
*/
      }

      /* "ws_package/controllers/activity_controller.py":1352
 *         if is_silent_build():
 *             return
 *         try:             # <<<<<<<<<<<<<<
 *             notification_service = get_weekly_limit_notification_service()
 * 
*/
    }
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    goto __pyx_L10_try_end;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "ws_package/controllers/activity_controller.py":1443
 *                     logger.info("")
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error checking and handling limits (fail-safe): %s", e)
 * 
*/
    __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_14) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._check_and_handle_limits", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_11, &__pyx_t_10, &__pyx_t_3) < 0) __PYX_ERR(0, 1443, __pyx_L7_except_error)
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_10);
      __pyx_cur_scope->__pyx_v_e = __pyx_t_10;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":1444
 * 
 *         except Exception as e:
 *             logger.error("Error checking and handling limits (fail-safe): %s", e)             # <<<<<<<<<<<<<<
 * 
 *     def _send_subscription_expired_popup(self, _response=None):
*/
        __pyx_t_12 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1444, __pyx_L22_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1444, __pyx_L22_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_2);
          assert(__pyx_t_12);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_12, __pyx_mstate_global->__pyx_kp_u_Error_checking_and_handling_limi, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1444, __pyx_L22_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }

      /* "ws_package/controllers/activity_controller.py":1443
 *                     logger.info("")
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error checking and handling limits (fail-safe): %s", e)
 * 
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          goto __pyx_L23;
        }
        __pyx_L22_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
          if ( unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_17);
          __Pyx_XGOTREF(__pyx_t_18);
          __Pyx_XGOTREF(__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_22);
          __pyx_t_14 = __pyx_lineno; __pyx_t_15 = __pyx_clineno; __pyx_t_16 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_ErrRestore(__pyx_t_17, __pyx_t_18, __pyx_t_19);
          __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0;
          __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_16;
          goto __pyx_L7_except_error;
        }
        __pyx_L23:;
      }
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L6_exception_handled;
    }
    goto __pyx_L7_except_error;

    /* "ws_package/controllers/activity_controller.py":1352
 *         if is_silent_build():
 *             return
 *         try:             # <<<<<<<<<<<<<<
 *             notification_service = get_weekly_limit_notification_service()
 * 
*/
    __pyx_L7_except_error:;
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
    goto __pyx_L1_error;
    __pyx_L6_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
    __pyx_L10_try_end:;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":1342
 *             return False
 * 
 *     async def _check_and_handle_limits(self, user_entity: UserEntity, org_entity: OrgEntity):             # <<<<<<<<<<<<<<
 *         """
 *         Check if daily or weekly limits are exceeded and handle accordingly.
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("_check_and_handle_limits", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":1446
 *             logger.error("Error checking and handling limits (fail-safe): %s", e)
 * 
 *     def _send_subscription_expired_popup(self, _response=None):             # <<<<<<<<<<<<<<
 *         """Send subscription-expired popup to Electron (same message for token expired or plan deactivated). All OSes."""
 *         try:
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_80_send_subscription_expired_popup(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_79_send_subscription_expired_popup, "Send subscription-expired popup to Electron (same message for token expired or plan deactivated). All OSes.");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_80_send_subscription_expired_popup = {"_send_subscription_expired_popup", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_80_send_subscription_expired_popup, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_79_send_subscription_expired_popup};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_80_send_subscription_expired_popup(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v__response = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_send_subscription_expired_popup (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_response_2,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 1446, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1446, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1446, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_send_subscription_expired_popup", 0) < (0)) __PYX_ERR(0, 1446, __pyx_L3_error)
      if (!values[1]) values[1] = __Pyx_NewRef(((PyObject *)Py_None));
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_send_subscription_expired_popup", 0, 1, 2, i); __PYX_ERR(0, 1446, __pyx_L3_error) }
      }
    } else {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1446, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1446, __pyx_L3_error)
        break;
        default: goto __pyx_L5_argtuple_error;
      }
      if (!values[1]) values[1] = __Pyx_NewRef(((PyObject *)Py_None));
    }
    __pyx_v_self = values[0];
    __pyx_v__response = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_send_subscription_expired_popup", 0, 1, 2, __pyx_nargs); __PYX_ERR(0, 1446, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._send_subscription_expired_popup", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_79_send_subscription_expired_popup(__pyx_self, __pyx_v_self, __pyx_v__response);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_79_send_subscription_expired_popup(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v__response) {
  PyObject *__pyx_v_enrich_subscription_payload = NULL;
  PyObject *__pyx_v_category_fields = NULL;
  PyObject *__pyx_v_error_data = NULL;
  PyObject *__pyx_v_e = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  Py_ssize_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  size_t __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12[3];
  int __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  int __pyx_t_17;
  int __pyx_t_18;
  char const *__pyx_t_19;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_send_subscription_expired_popup", 0);

  /* "ws_package/controllers/activity_controller.py":1448
 *     def _send_subscription_expired_popup(self, _response=None):
 *         """Send subscription-expired popup to Electron (same message for token expired or plan deactivated). All OSes."""
 *         try:             # <<<<<<<<<<<<<<
 *             from ws_package.utils.user_error_categories import enrich_subscription_payload
 * 
*/
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":1449
 *         """Send subscription-expired popup to Electron (same message for token expired or plan deactivated). All OSes."""
 *         try:
 *             from ws_package.utils.user_error_categories import enrich_subscription_payload             # <<<<<<<<<<<<<<
 * 
 *             category_fields = enrich_subscription_payload(_response)
*/
      {
        PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_enrich_subscription_payload};
        __pyx_t_5 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_utils_user_error_cate, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1449, __pyx_L3_error)
      }
      __pyx_t_4 = __pyx_t_5;
      __Pyx_GOTREF(__pyx_t_4);
      {
        PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_enrich_subscription_payload};
        __pyx_t_6 = 0; {
          __pyx_t_7 = __Pyx_ImportFrom(__pyx_t_4, __pyx_imported_names[__pyx_t_6]); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1449, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_7);
          switch (__pyx_t_6) {
            case 0:
            __Pyx_INCREF(__pyx_t_7);
            __pyx_v_enrich_subscription_payload = __pyx_t_7;
            break;
            default:;
          }
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":1451
 *             from ws_package.utils.user_error_categories import enrich_subscription_payload
 * 
 *             category_fields = enrich_subscription_payload(_response)             # <<<<<<<<<<<<<<
 *             error_data = {
 *                 'title': f"{category_fields['userCategory']}  {category_fields['userCategoryTitle']}",
*/
      __pyx_t_7 = NULL;
      __Pyx_INCREF(__pyx_v_enrich_subscription_payload);
      __pyx_t_8 = __pyx_v_enrich_subscription_payload; 
      __pyx_t_9 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
        assert(__pyx_t_7);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
        __pyx_t_9 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v__response};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1451, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_v_category_fields = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":1453
 *             category_fields = enrich_subscription_payload(_response)
 *             error_data = {
 *                 'title': f"{category_fields['userCategory']}  {category_fields['userCategoryTitle']}",             # <<<<<<<<<<<<<<
 *                 'message': "Your account is currently inactive (deleted, deactivated, or subscription expired).\nPlease contact your organization administrator to restore access.",
 *                 'planStatus': _response.get('planStatus') if _response else None,
*/
      __pyx_t_8 = __Pyx_PyDict_NewPresized(6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1453, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_7 = __Pyx_PyObject_Dict_GetItem(__pyx_v_category_fields, __pyx_mstate_global->__pyx_n_u_userCategory); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1453, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_10 = __Pyx_PyObject_FormatSimple(__pyx_t_7, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1453, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_PyObject_Dict_GetItem(__pyx_v_category_fields, __pyx_mstate_global->__pyx_n_u_userCategoryTitle); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1453, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_11 = __Pyx_PyObject_FormatSimple(__pyx_t_7, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1453, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_12[0] = __pyx_t_10;
      __pyx_t_12[1] = __pyx_mstate_global->__pyx_kp_u__5;
      __pyx_t_12[2] = __pyx_t_11;
      __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_12, 3, __Pyx_PyUnicode_GET_LENGTH(__pyx_t_10) + 3 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_11), 65535 | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_11));
      if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1453, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_title, __pyx_t_7) < (0)) __PYX_ERR(0, 1453, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_message, __pyx_mstate_global->__pyx_kp_u_Your_account_is_currently_inacti) < (0)) __PYX_ERR(0, 1453, __pyx_L3_error)

      /* "ws_package/controllers/activity_controller.py":1455
 *                 'title': f"{category_fields['userCategory']}  {category_fields['userCategoryTitle']}",
 *                 'message': "Your account is currently inactive (deleted, deactivated, or subscription expired).\nPlease contact your organization administrator to restore access.",
 *                 'planStatus': _response.get('planStatus') if _response else None,             # <<<<<<<<<<<<<<
 *                 'isdeleted': _response.get('isdeleted') if _response else None,
 *                 'isdeactivated': _response.get('isdeactivated') if _response else None,
*/
      __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_v__response); if (unlikely((__pyx_t_13 < 0))) __PYX_ERR(0, 1455, __pyx_L3_error)
      if (__pyx_t_13) {
        __pyx_t_10 = __pyx_v__response;
        __Pyx_INCREF(__pyx_t_10);
        __pyx_t_9 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_mstate_global->__pyx_n_u_planStatus};
          __pyx_t_11 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1455, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_11);
        }
        __pyx_t_7 = __pyx_t_11;
        __pyx_t_11 = 0;
      } else {
        __Pyx_INCREF(Py_None);
        __pyx_t_7 = Py_None;
      }
      if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_planStatus, __pyx_t_7) < (0)) __PYX_ERR(0, 1453, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "ws_package/controllers/activity_controller.py":1456
 *                 'message': "Your account is currently inactive (deleted, deactivated, or subscription expired).\nPlease contact your organization administrator to restore access.",
 *                 'planStatus': _response.get('planStatus') if _response else None,
 *                 'isdeleted': _response.get('isdeleted') if _response else None,             # <<<<<<<<<<<<<<
 *                 'isdeactivated': _response.get('isdeactivated') if _response else None,
 *                 'timestamp': datetime.datetime.now().isoformat(),
*/
      __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_v__response); if (unlikely((__pyx_t_13 < 0))) __PYX_ERR(0, 1456, __pyx_L3_error)
      if (__pyx_t_13) {
        __pyx_t_10 = __pyx_v__response;
        __Pyx_INCREF(__pyx_t_10);
        __pyx_t_9 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_mstate_global->__pyx_n_u_isdeleted};
          __pyx_t_11 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1456, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_11);
        }
        __pyx_t_7 = __pyx_t_11;
        __pyx_t_11 = 0;
      } else {
        __Pyx_INCREF(Py_None);
        __pyx_t_7 = Py_None;
      }
      if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_isdeleted, __pyx_t_7) < (0)) __PYX_ERR(0, 1453, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "ws_package/controllers/activity_controller.py":1457
 *                 'planStatus': _response.get('planStatus') if _response else None,
 *                 'isdeleted': _response.get('isdeleted') if _response else None,
 *                 'isdeactivated': _response.get('isdeactivated') if _response else None,             # <<<<<<<<<<<<<<
 *                 'timestamp': datetime.datetime.now().isoformat(),
 *                 **category_fields,
*/
      __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_v__response); if (unlikely((__pyx_t_13 < 0))) __PYX_ERR(0, 1457, __pyx_L3_error)
      if (__pyx_t_13) {
        __pyx_t_10 = __pyx_v__response;
        __Pyx_INCREF(__pyx_t_10);
        __pyx_t_9 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_mstate_global->__pyx_n_u_isdeactivated};
          __pyx_t_11 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1457, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_11);
        }
        __pyx_t_7 = __pyx_t_11;
        __pyx_t_11 = 0;
      } else {
        __Pyx_INCREF(Py_None);
        __pyx_t_7 = Py_None;
      }
      if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_isdeactivated, __pyx_t_7) < (0)) __PYX_ERR(0, 1453, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "ws_package/controllers/activity_controller.py":1458
 *                 'isdeleted': _response.get('isdeleted') if _response else None,
 *                 'isdeactivated': _response.get('isdeactivated') if _response else None,
 *                 'timestamp': datetime.datetime.now().isoformat(),             # <<<<<<<<<<<<<<
 *                 **category_fields,
 *             }
*/
      __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1458, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1458, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_16);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __pyx_t_14 = __pyx_t_16;
      __Pyx_INCREF(__pyx_t_14);
      __pyx_t_9 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_14, NULL};
        __pyx_t_10 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_9, (1-__pyx_t_9) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
        if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1458, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_10);
      }
      __pyx_t_11 = __pyx_t_10;
      __Pyx_INCREF(__pyx_t_11);
      __pyx_t_9 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_11, NULL};
        __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_isoformat, __pyx_callargs+__pyx_t_9, (1-__pyx_t_9) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1458, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_7);
      }
      if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_timestamp, __pyx_t_7) < (0)) __PYX_ERR(0, 1453, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_4 = __pyx_t_8;
      __pyx_t_8 = 0;

      /* "ws_package/controllers/activity_controller.py":1459
 *                 'isdeactivated': _response.get('isdeactivated') if _response else None,
 *                 'timestamp': datetime.datetime.now().isoformat(),
 *                 **category_fields,             # <<<<<<<<<<<<<<
 *             }
 *             if self._send_to_electron_if_connected('subscription_expired', error_data):
*/
      if (unlikely(__pyx_v_category_fields == Py_None)) {
        PyErr_SetString(PyExc_TypeError, "argument after ** must be a mapping, not NoneType");
        __PYX_ERR(0, 1459, __pyx_L3_error)
      }
      if (unlikely(PyDict_Update(__pyx_t_4, __pyx_v_category_fields) < 0)) {
        if (PyErr_ExceptionMatches(PyExc_AttributeError)) __Pyx_RaiseMappingExpectedError(__pyx_v_category_fields);
        __PYX_ERR(0, 1459, __pyx_L3_error)
      }
      __pyx_v_error_data = ((PyObject*)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":1461
 *                 **category_fields,
 *             }
 *             if self._send_to_electron_if_connected('subscription_expired', error_data):             # <<<<<<<<<<<<<<
 *                 logger.info("Sent subscription expiration error to Electron: %s", error_data)
 *         except Exception as e:
*/
      __pyx_t_8 = __pyx_v_self;
      __Pyx_INCREF(__pyx_t_8);
      __pyx_t_9 = 0;
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_8, __pyx_mstate_global->__pyx_n_u_subscription_expired, __pyx_v_error_data};
        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_send_to_electron_if_connected, __pyx_callargs+__pyx_t_9, (3-__pyx_t_9) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1461, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_13 < 0))) __PYX_ERR(0, 1461, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_13) {

        /* "ws_package/controllers/activity_controller.py":1462
 *             }
 *             if self._send_to_electron_if_connected('subscription_expired', error_data):
 *                 logger.info("Sent subscription expiration error to Electron: %s", error_data)             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             logger.error("Failed to send subscription expiration error to Electron: %s", e)
*/
        __pyx_t_8 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1462, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1462, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_9 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_10);
          assert(__pyx_t_8);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
          __pyx_t_9 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_8, __pyx_mstate_global->__pyx_kp_u_Sent_subscription_expiration_err, __pyx_v_error_data};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_9, (3-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1462, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":1461
 *                 **category_fields,
 *             }
 *             if self._send_to_electron_if_connected('subscription_expired', error_data):             # <<<<<<<<<<<<<<
 *                 logger.info("Sent subscription expiration error to Electron: %s", error_data)
 *         except Exception as e:
*/
      }

      /* "ws_package/controllers/activity_controller.py":1448
 *     def _send_subscription_expired_popup(self, _response=None):
 *         """Send subscription-expired popup to Electron (same message for token expired or plan deactivated). All OSes."""
 *         try:             # <<<<<<<<<<<<<<
 *             from ws_package.utils.user_error_categories import enrich_subscription_payload
 * 
*/
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L8_try_end;
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "ws_package/controllers/activity_controller.py":1463
 *             if self._send_to_electron_if_connected('subscription_expired', error_data):
 *                 logger.info("Sent subscription expiration error to Electron: %s", error_data)
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Failed to send subscription expiration error to Electron: %s", e)
 * 
*/
    __pyx_t_17 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_17) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._send_subscription_expired_popup", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_10, &__pyx_t_8) < 0) __PYX_ERR(0, 1463, __pyx_L5_except_error)
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_10);
      __pyx_v_e = __pyx_t_10;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":1464
 *                 logger.info("Sent subscription expiration error to Electron: %s", error_data)
 *         except Exception as e:
 *             logger.error("Failed to send subscription expiration error to Electron: %s", e)             # <<<<<<<<<<<<<<
 * 
 *     async def start_screenshot_activity(self, user_entity: UserEntity, stop_event=None):
*/
        __pyx_t_11 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1464, __pyx_L15_error)
        __Pyx_GOTREF(__pyx_t_16);
        __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1464, __pyx_L15_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
        __pyx_t_9 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_14))) {
          __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_14);
          assert(__pyx_t_11);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
          __pyx_t_9 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_11, __pyx_mstate_global->__pyx_kp_u_Failed_to_send_subscription_expi, __pyx_v_e};
          __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_9, (3-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1464, __pyx_L15_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }

      /* "ws_package/controllers/activity_controller.py":1463
 *             if self._send_to_electron_if_connected('subscription_expired', error_data):
 *                 logger.info("Sent subscription expiration error to Electron: %s", error_data)
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Failed to send subscription expiration error to Electron: %s", e)
 * 
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
          goto __pyx_L16;
        }
        __pyx_L15_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __pyx_t_5 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
          if ( unlikely(__Pyx_GetException(&__pyx_t_5, &__pyx_t_20, &__pyx_t_21) < 0)) __Pyx_ErrFetch(&__pyx_t_5, &__pyx_t_20, &__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_5);
          __Pyx_XGOTREF(__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_23);
          __Pyx_XGOTREF(__pyx_t_24);
          __pyx_t_17 = __pyx_lineno; __pyx_t_18 = __pyx_clineno; __pyx_t_19 = __pyx_filename;
          {
            __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_XGIVEREF(__pyx_t_24);
          __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_23, __pyx_t_24);
          __Pyx_XGIVEREF(__pyx_t_5);
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_ErrRestore(__pyx_t_5, __pyx_t_20, __pyx_t_21);
          __pyx_t_5 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0;
          __pyx_lineno = __pyx_t_17; __pyx_clineno = __pyx_t_18; __pyx_filename = __pyx_t_19;
          goto __pyx_L5_except_error;
        }
        __pyx_L16:;
      }
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L4_exception_handled;
    }
    goto __pyx_L5_except_error;

    /* "ws_package/controllers/activity_controller.py":1448
 *     def _send_subscription_expired_popup(self, _response=None):
 *         """Send subscription-expired popup to Electron (same message for token expired or plan deactivated). All OSes."""
 *         try:             # <<<<<<<<<<<<<<
 *             from ws_package.utils.user_error_categories import enrich_subscription_payload
 * 
*/
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L4_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    __pyx_L8_try_end:;
  }

  /* "ws_package/controllers/activity_controller.py":1446
 *             logger.error("Error checking and handling limits (fail-safe): %s", e)
 * 
 *     def _send_subscription_expired_popup(self, _response=None):             # <<<<<<<<<<<<<<
 *         """Send subscription-expired popup to Electron (same message for token expired or plan deactivated). All OSes."""
 *         try:
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._send_subscription_expired_popup", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_enrich_subscription_payload);
  __Pyx_XDECREF(__pyx_v_category_fields);
  __Pyx_XDECREF(__pyx_v_error_data);
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_83generator15(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":1466
 *             logger.error("Failed to send subscription expiration error to Electron: %s", e)
 * 
 *     async def start_screenshot_activity(self, user_entity: UserEntity, stop_event=None):             # <<<<<<<<<<<<<<
 *         await precise_sleep(10)
 *         logger.info("Starting screenshot activity with interval: %s and ss frequency: %s blur intensity: %s status: %s limit start: %s limit end: %s no of days: %s", self.interval, self.screenshot_interval, self.blur_intensity, self.status, self.limit_start, self.limit_end, self.no_of_days)
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_82start_screenshot_activity(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_82start_screenshot_activity = {"start_screenshot_activity", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_82start_screenshot_activity, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_82start_screenshot_activity(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_user_entity = 0;
  PyObject *__pyx_v_stop_event = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("start_screenshot_activity (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_user_entity,&__pyx_mstate_global->__pyx_n_u_stop_event,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 1466, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 1466, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1466, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1466, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "start_screenshot_activity", 0) < (0)) __PYX_ERR(0, 1466, __pyx_L3_error)
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject *)Py_None));
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("start_screenshot_activity", 0, 2, 3, i); __PYX_ERR(0, 1466, __pyx_L3_error) }
      }
    } else {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 1466, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1466, __pyx_L3_error)
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1466, __pyx_L3_error)
        break;
        default: goto __pyx_L5_argtuple_error;
      }
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject *)Py_None));
    }
    __pyx_v_self = values[0];
    __pyx_v_user_entity = values[1];
    __pyx_v_stop_event = values[2];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("start_screenshot_activity", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 1466, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.start_screenshot_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_81start_screenshot_activity(__pyx_self, __pyx_v_self, __pyx_v_user_entity, __pyx_v_stop_event);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_81start_screenshot_activity(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity, PyObject *__pyx_v_stop_event) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("start_screenshot_activity", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1466, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_user_entity = __pyx_v_user_entity;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_user_entity);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_user_entity);
  __pyx_cur_scope->__pyx_v_stop_event = __pyx_v_stop_event;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_stop_event);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_stop_event);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_83generator15, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[16]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_start_screenshot_activity, __pyx_mstate_global->__pyx_n_u_ActivityController_start_screens, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 1466, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.start_screenshot_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_83generator15(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  size_t __pyx_t_4;
  __Pyx_PySendResult __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("start_screenshot_activity", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L4_resume_from_await;
    case 2: goto __pyx_L5_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 1466, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":1467
 * 
 *     async def start_screenshot_activity(self, user_entity: UserEntity, stop_event=None):
 *         await precise_sleep(10)             # <<<<<<<<<<<<<<
 *         logger.info("Starting screenshot activity with interval: %s and ss frequency: %s blur intensity: %s status: %s limit start: %s limit end: %s no of days: %s", self.interval, self.screenshot_interval, self.blur_intensity, self.status, self.limit_start, self.limit_end, self.no_of_days)
 *         await self.screenshot_controller.start_screenshot_activity(
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_precise_sleep); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1467, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
    __pyx_t_4 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_int_10};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1467, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_5 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_5 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L4_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1467, __pyx_L1_error)
  } else if (likely(__pyx_t_5 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 1467, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":1468
 *     async def start_screenshot_activity(self, user_entity: UserEntity, stop_event=None):
 *         await precise_sleep(10)
 *         logger.info("Starting screenshot activity with interval: %s and ss frequency: %s blur intensity: %s status: %s limit start: %s limit end: %s no of days: %s", self.interval, self.screenshot_interval, self.blur_intensity, self.status, self.limit_start, self.limit_end, self.no_of_days)             # <<<<<<<<<<<<<<
 *         await self.screenshot_controller.start_screenshot_activity(
 *             user_entity,
*/
  __pyx_t_3 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_interval); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_blur_intensity); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_start); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_end); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_no_of_days); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1468, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_4 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
    assert(__pyx_t_3);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
    __pyx_t_4 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[9] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Starting_screenshot_activity_wit, __pyx_t_2, __pyx_t_7, __pyx_t_8, __pyx_t_9, __pyx_t_10, __pyx_t_11, __pyx_t_12};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_4, (9-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1468, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":1469
 *         await precise_sleep(10)
 *         logger.info("Starting screenshot activity with interval: %s and ss frequency: %s blur intensity: %s status: %s limit start: %s limit end: %s no of days: %s", self.interval, self.screenshot_interval, self.blur_intensity, self.status, self.limit_start, self.limit_end, self.no_of_days)
 *         await self.screenshot_controller.start_screenshot_activity(             # <<<<<<<<<<<<<<
 *             user_entity,
 *             self.limit_start,
*/
  __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1469, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_6 = __pyx_t_12;
  __Pyx_INCREF(__pyx_t_6);

  /* "ws_package/controllers/activity_controller.py":1471
 *         await self.screenshot_controller.start_screenshot_activity(
 *             user_entity,
 *             self.limit_start,             # <<<<<<<<<<<<<<
 *             self.limit_end,
 *             self.no_of_days,
*/
  __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_start); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1471, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);

  /* "ws_package/controllers/activity_controller.py":1472
 *             user_entity,
 *             self.limit_start,
 *             self.limit_end,             # <<<<<<<<<<<<<<
 *             self.no_of_days,
 *             self.screenshot_interval,
*/
  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_end); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1472, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);

  /* "ws_package/controllers/activity_controller.py":1473
 *             self.limit_start,
 *             self.limit_end,
 *             self.no_of_days,             # <<<<<<<<<<<<<<
 *             self.screenshot_interval,
 *             self.interval,
*/
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_no_of_days); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1473, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);

  /* "ws_package/controllers/activity_controller.py":1474
 *             self.limit_end,
 *             self.no_of_days,
 *             self.screenshot_interval,             # <<<<<<<<<<<<<<
 *             self.interval,
 *             self.blur_intensity,
*/
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_interval); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1474, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);

  /* "ws_package/controllers/activity_controller.py":1475
 *             self.no_of_days,
 *             self.screenshot_interval,
 *             self.interval,             # <<<<<<<<<<<<<<
 *             self.blur_intensity,
 *             self.status,
*/
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1475, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "ws_package/controllers/activity_controller.py":1476
 *             self.screenshot_interval,
 *             self.interval,
 *             self.blur_intensity,             # <<<<<<<<<<<<<<
 *             self.status,
 *             stop_event
*/
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_blur_intensity); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1476, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "ws_package/controllers/activity_controller.py":1477
 *             self.interval,
 *             self.blur_intensity,
 *             self.status,             # <<<<<<<<<<<<<<
 *             stop_event
 *         )
*/
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1477, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);

  /* "ws_package/controllers/activity_controller.py":1478
 *             self.blur_intensity,
 *             self.status,
 *             stop_event             # <<<<<<<<<<<<<<
 *         )
 * 
*/
  __pyx_t_4 = 0;
  {
    PyObject *__pyx_callargs[10] = {__pyx_t_6, __pyx_cur_scope->__pyx_v_user_entity, __pyx_t_11, __pyx_t_10, __pyx_t_9, __pyx_t_8, __pyx_t_7, __pyx_t_2, __pyx_t_3, __pyx_cur_scope->__pyx_v_stop_event};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_start_screenshot_activity, __pyx_callargs+__pyx_t_4, (10-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1469, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_5 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_5 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 2;
    return __pyx_r;
    __pyx_L5_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1469, __pyx_L1_error)
  } else if (likely(__pyx_t_5 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 1469, __pyx_L1_error)
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":1466
 *             logger.error("Failed to send subscription expiration error to Electron: %s", e)
 * 
 *     async def start_screenshot_activity(self, user_entity: UserEntity, stop_event=None):             # <<<<<<<<<<<<<<
 *         await precise_sleep(10)
 *         logger.info("Starting screenshot activity with interval: %s and ss frequency: %s blur intensity: %s status: %s limit start: %s limit end: %s no of days: %s", self.interval, self.screenshot_interval, self.blur_intensity, self.status, self.limit_start, self.limit_end, self.no_of_days)
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("start_screenshot_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_86generator16(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":1481
 *         )
 * 
 *     async def start_device_activity(self, user_entity: UserEntity, stop_event: Optional[asyncio.Event] = None) -> None:             # <<<<<<<<<<<<<<
 *         self.user_entity = user_entity
 *         """
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_85start_device_activity(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_85start_device_activity = {"start_device_activity", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_85start_device_activity, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_85start_device_activity(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_user_entity = 0;
  PyObject *__pyx_v_stop_event = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("start_device_activity (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_user_entity,&__pyx_mstate_global->__pyx_n_u_stop_event,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 1481, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 1481, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1481, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1481, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "start_device_activity", 0) < (0)) __PYX_ERR(0, 1481, __pyx_L3_error)
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject *)Py_None));
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("start_device_activity", 0, 2, 3, i); __PYX_ERR(0, 1481, __pyx_L3_error) }
      }
    } else {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 1481, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1481, __pyx_L3_error)
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1481, __pyx_L3_error)
        break;
        default: goto __pyx_L5_argtuple_error;
      }
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject *)Py_None));
    }
    __pyx_v_self = values[0];
    __pyx_v_user_entity = values[1];
    __pyx_v_stop_event = values[2];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("start_device_activity", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 1481, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_84start_device_activity(__pyx_self, __pyx_v_self, __pyx_v_user_entity, __pyx_v_stop_event);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_84start_device_activity(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity, PyObject *__pyx_v_stop_event) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("start_device_activity", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1481, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_user_entity = __pyx_v_user_entity;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_user_entity);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_user_entity);
  __pyx_cur_scope->__pyx_v_stop_event = __pyx_v_stop_event;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_stop_event);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_stop_event);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_86generator16, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[17]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_start_device_activity, __pyx_mstate_global->__pyx_n_u_ActivityController_start_device, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 1481, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_86generator16(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  size_t __pyx_t_3;
  __Pyx_PySendResult __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  Py_ssize_t __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_t_18;
  char const *__pyx_t_19;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  char const *__pyx_t_26;
  int __pyx_t_27;
  int __pyx_t_28;
  char const *__pyx_t_29;
  PyObject *__pyx_t_30 = NULL;
  PyObject *__pyx_t_31 = NULL;
  PyObject *__pyx_t_32 = NULL;
  PyObject *__pyx_t_33 = NULL;
  PyObject *__pyx_t_34 = NULL;
  PyObject *__pyx_t_35 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("start_device_activity", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L4_resume_from_await;
    case 2: goto __pyx_L6_resume_from_await;
    case 3: goto __pyx_L10_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 1481, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":1482
 * 
 *     async def start_device_activity(self, user_entity: UserEntity, stop_event: Optional[asyncio.Event] = None) -> None:
 *         self.user_entity = user_entity             # <<<<<<<<<<<<<<
 *         """
 *         Start the main device activity monitoring loop.
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_cur_scope->__pyx_v_user_entity) < (0)) __PYX_ERR(0, 1482, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":1500
 *         """
 *         # Store user_entity for wake callback access
 *         self._user_entity_for_wake = user_entity             # <<<<<<<<<<<<<<
 * 
 * 
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_user_entity_for_wake, __pyx_cur_scope->__pyx_v_user_entity) < (0)) __PYX_ERR(0, 1500, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":1504
 * 
 *         # Check if it's a new day on app startup and update S3 bucket config if needed
 *         await self._check_and_update_s3_on_startup(user_entity)             # <<<<<<<<<<<<<<
 * 
 *         # Check persistent tracker status before starting
*/
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_3 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_user_entity};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_check_and_update_s3_on_startup, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1504, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_4 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_4 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L4_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1504, __pyx_L1_error)
  } else if (likely(__pyx_t_4 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 1504, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":1507
 * 
 *         # Check persistent tracker status before starting
 *         if not is_tracking_enabled():             # <<<<<<<<<<<<<<
 *             logger.warning("=" * 80)
 *             logger.warning("[Tracker] Tracking is disabled (status='stop') - device activity thread will wait")
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_is_tracking_enabled); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1507, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
    __pyx_t_3 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1507, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1507, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_7 = (!__pyx_t_6);
  if (__pyx_t_7) {

    /* "ws_package/controllers/activity_controller.py":1508
 *         # Check persistent tracker status before starting
 *         if not is_tracking_enabled():
 *             logger.warning("=" * 80)             # <<<<<<<<<<<<<<
 *             logger.warning("[Tracker] Tracking is disabled (status='stop') - device activity thread will wait")
 *             logger.warning("[Tracker] WebSocket connection is active - waiting for 'start' command")
*/
    __pyx_t_5 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1508, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1508, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_3 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_8);
      assert(__pyx_t_5);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
      __pyx_t_3 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u__4};
      __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1508, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "ws_package/controllers/activity_controller.py":1509
 *         if not is_tracking_enabled():
 *             logger.warning("=" * 80)
 *             logger.warning("[Tracker] Tracking is disabled (status='stop') - device activity thread will wait")             # <<<<<<<<<<<<<<
 *             logger.warning("[Tracker] WebSocket connection is active - waiting for 'start' command")
 *             logger.warning("=" * 80)
*/
    __pyx_t_8 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1509, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1509, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_3 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
      assert(__pyx_t_8);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
      __pyx_t_3 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_mstate_global->__pyx_kp_u_Tracker_Tracking_is_disabled_st};
      __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1509, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "ws_package/controllers/activity_controller.py":1510
 *             logger.warning("=" * 80)
 *             logger.warning("[Tracker] Tracking is disabled (status='stop') - device activity thread will wait")
 *             logger.warning("[Tracker] WebSocket connection is active - waiting for 'start' command")             # <<<<<<<<<<<<<<
 *             logger.warning("=" * 80)
 *             # Keep force_stop and status as False, but continue to start the thread
*/
    __pyx_t_2 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1510, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1510, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_3 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
      assert(__pyx_t_2);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
      __pyx_t_3 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Tracker_WebSocket_connection_is};
      __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1510, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "ws_package/controllers/activity_controller.py":1511
 *             logger.warning("[Tracker] Tracking is disabled (status='stop') - device activity thread will wait")
 *             logger.warning("[Tracker] WebSocket connection is active - waiting for 'start' command")
 *             logger.warning("=" * 80)             # <<<<<<<<<<<<<<
 *             # Keep force_stop and status as False, but continue to start the thread
 *             # The thread will check status and wait until it's enabled
*/
    __pyx_t_5 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1511, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1511, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_3 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_8);
      assert(__pyx_t_5);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
      __pyx_t_3 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u__4};
      __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1511, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "ws_package/controllers/activity_controller.py":1514
 *             # Keep force_stop and status as False, but continue to start the thread
 *             # The thread will check status and wait until it's enabled
 *             self.force_stop = True             # <<<<<<<<<<<<<<
 *             self.status = False
 *             # Continue to start the thread - it will wait when status is False
*/
    if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_force_stop, Py_True) < (0)) __PYX_ERR(0, 1514, __pyx_L1_error)

    /* "ws_package/controllers/activity_controller.py":1515
 *             # The thread will check status and wait until it's enabled
 *             self.force_stop = True
 *             self.status = False             # <<<<<<<<<<<<<<
 *             # Continue to start the thread - it will wait when status is False
 * 
*/
    if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status, Py_False) < (0)) __PYX_ERR(0, 1515, __pyx_L1_error)

    /* "ws_package/controllers/activity_controller.py":1507
 * 
 *         # Check persistent tracker status before starting
 *         if not is_tracking_enabled():             # <<<<<<<<<<<<<<
 *             logger.warning("=" * 80)
 *             logger.warning("[Tracker] Tracking is disabled (status='stop') - device activity thread will wait")
*/
  }

  /* "ws_package/controllers/activity_controller.py":1519
 * 
 *         # Start the minute-by-minute rolling average timer
 *         minute_timer_task = asyncio.create_task(self.__start_minute_activity_timer(stop_event))             # <<<<<<<<<<<<<<
 *         self._background_tasks.add(minute_timer_task)
 *         minute_timer_task.add_done_callback(self._background_tasks.discard)
*/
  __pyx_t_8 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1519, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_create_task); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1519, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_9 = __pyx_cur_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_9);
  __pyx_t_3 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_cur_scope->__pyx_v_stop_event};
    __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_ActivityController__start_minut, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
  }
  __pyx_t_3 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
    assert(__pyx_t_8);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_8);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
    __pyx_t_3 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_t_5};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1519, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_minute_timer_task = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":1520
 *         # Start the minute-by-minute rolling average timer
 *         minute_timer_task = asyncio.create_task(self.__start_minute_activity_timer(stop_event))
 *         self._background_tasks.add(minute_timer_task)             # <<<<<<<<<<<<<<
 *         minute_timer_task.add_done_callback(self._background_tasks.discard)
 * 
*/
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_background_tasks); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1520, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_2 = __pyx_t_5;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_3 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_minute_timer_task};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_add, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1520, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":1521
 *         minute_timer_task = asyncio.create_task(self.__start_minute_activity_timer(stop_event))
 *         self._background_tasks.add(minute_timer_task)
 *         minute_timer_task.add_done_callback(self._background_tasks.discard)             # <<<<<<<<<<<<<<
 * 
 *         # ActivityPercentage queue processor removed - using universal db_write_queue instead
*/
  __pyx_t_5 = __pyx_cur_scope->__pyx_v_minute_timer_task;
  __Pyx_INCREF(__pyx_t_5);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_background_tasks); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1521, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_discard); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1521, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_8};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_add_done_callback, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1521, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":1526
 * 
 *         # Start the app monitor flush task for batching
 *         await self.activity_service.start_app_monitor_flush_task()             # <<<<<<<<<<<<<<
 *         logger.info("Started app monitor flush task")
 * 
*/
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1526, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_8 = __pyx_t_5;
  __Pyx_INCREF(__pyx_t_8);
  __pyx_t_3 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_start_app_monitor_flush_task, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1526, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_4 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_4 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 2;
    return __pyx_r;
    __pyx_L6_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1526, __pyx_L1_error)
  } else if (likely(__pyx_t_4 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 1526, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":1527
 *         # Start the app monitor flush task for batching
 *         await self.activity_service.start_app_monitor_flush_task()
 *         logger.info("Started app monitor flush task")             # <<<<<<<<<<<<<<
 * 
 *         try:
*/
  __pyx_t_5 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1527, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_3 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
    assert(__pyx_t_5);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
    __pyx_t_3 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Started_app_monitor_flush_task};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1527, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":1529
 *         logger.info("Started app monitor flush task")
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             # Start the main device activity monitoring
 *             await self.__start_device_activity(user_entity, stop_event)
*/
  /*try:*/ {

    /* "ws_package/controllers/activity_controller.py":1531
 *         try:
 *             # Start the main device activity monitoring
 *             await self.__start_device_activity(user_entity, stop_event)             # <<<<<<<<<<<<<<
 *         finally:
 *             # Ensure the minute timer and all background tasks are cancelled when main loop exits
*/
    __pyx_t_2 = __pyx_cur_scope->__pyx_v_self;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_3 = 0;
    {
      PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_user_entity, __pyx_cur_scope->__pyx_v_stop_event};
      __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_ActivityController__start_devic, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1531, __pyx_L8_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __pyx_t_4 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (likely(__pyx_t_4 == PYGEN_NEXT)) {
      __Pyx_GOTREF(__pyx_r);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 3;
      return __pyx_r;
      __pyx_L10_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1531, __pyx_L8_error)
    } else if (likely(__pyx_t_4 == PYGEN_RETURN)) {
      __Pyx_GOTREF(__pyx_r);
      __Pyx_DECREF(__pyx_r); __pyx_r = 0;
    } else {
      __Pyx_XGOTREF(__pyx_r);
      __PYX_ERR(0, 1531, __pyx_L8_error)
    }
  }

  /* "ws_package/controllers/activity_controller.py":1534
 *         finally:
 *             # Ensure the minute timer and all background tasks are cancelled when main loop exits
 *             minute_timer_task.cancel()             # <<<<<<<<<<<<<<
 *             # queue_processor_task.cancel()
 *             # queue_processor_task removed - using universal db_write_queue instead
*/
  /*finally:*/ {
    /*normal exit:*/{
      __pyx_t_2 = __pyx_cur_scope->__pyx_v_minute_timer_task;
      __Pyx_INCREF(__pyx_t_2);
      __pyx_t_3 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
        __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_cancel, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1534, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":1538
 *             # queue_processor_task removed - using universal db_write_queue instead
 *             # Cancel all background tasks
 *             current_loop = asyncio.get_running_loop()             # <<<<<<<<<<<<<<
 *             for task in list(self._background_tasks):
 *                 if not task.done():
*/
      __pyx_t_2 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1538, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_get_running_loop); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1538, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_3 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_8);
        assert(__pyx_t_2);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
        __pyx_t_3 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
        __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1538, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_cur_scope->__pyx_v_current_loop = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":1539
 *             # Cancel all background tasks
 *             current_loop = asyncio.get_running_loop()
 *             for task in list(self._background_tasks):             # <<<<<<<<<<<<<<
 *                 if not task.done():
 *                     try:
*/
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_background_tasks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1539, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_8 = __Pyx_PySequence_ListKeepNew(__pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1539, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_1 = __pyx_t_8; __Pyx_INCREF(__pyx_t_1);
      __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      for (;;) {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1539, __pyx_L1_error)
          #endif
          if (__pyx_t_10 >= __pyx_temp) break;
        }
        __pyx_t_8 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_1, __pyx_t_10, __Pyx_ReferenceSharing_OwnStrongReference);
        ++__pyx_t_10;
        if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1539, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_task);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_task, __pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_8);
        __pyx_t_8 = 0;

        /* "ws_package/controllers/activity_controller.py":1540
 *             current_loop = asyncio.get_running_loop()
 *             for task in list(self._background_tasks):
 *                 if not task.done():             # <<<<<<<<<<<<<<
 *                     try:
 *                         # Only cancel tasks that belong to the current event loop
*/
        __pyx_t_2 = __pyx_cur_scope->__pyx_v_task;
        __Pyx_INCREF(__pyx_t_2);
        __pyx_t_3 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
          __pyx_t_8 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_done, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1540, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
        }
        __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1540, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_6 = (!__pyx_t_7);
        if (__pyx_t_6) {

          /* "ws_package/controllers/activity_controller.py":1541
 *             for task in list(self._background_tasks):
 *                 if not task.done():
 *                     try:             # <<<<<<<<<<<<<<
 *                         # Only cancel tasks that belong to the current event loop
 *                         task_loop = task.get_loop()
*/
          {
            __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
            __Pyx_XGOTREF(__pyx_t_11);
            __Pyx_XGOTREF(__pyx_t_12);
            __Pyx_XGOTREF(__pyx_t_13);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":1543
 *                     try:
 *                         # Only cancel tasks that belong to the current event loop
 *                         task_loop = task.get_loop()             # <<<<<<<<<<<<<<
 *                         if task_loop == current_loop:
 *                             task.cancel()
*/
              __pyx_t_2 = __pyx_cur_scope->__pyx_v_task;
              __Pyx_INCREF(__pyx_t_2);
              __pyx_t_3 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
                __pyx_t_8 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_loop, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1543, __pyx_L14_error)
                __Pyx_GOTREF(__pyx_t_8);
              }
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_task_loop);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_task_loop, __pyx_t_8);
              __Pyx_GIVEREF(__pyx_t_8);
              __pyx_t_8 = 0;

              /* "ws_package/controllers/activity_controller.py":1544
 *                         # Only cancel tasks that belong to the current event loop
 *                         task_loop = task.get_loop()
 *                         if task_loop == current_loop:             # <<<<<<<<<<<<<<
 *                             task.cancel()
 *                     except Exception as e:
*/
              __pyx_t_8 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_task_loop, __pyx_cur_scope->__pyx_v_current_loop, Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1544, __pyx_L14_error)
              __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1544, __pyx_L14_error)
              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
              if (__pyx_t_6) {

                /* "ws_package/controllers/activity_controller.py":1545
 *                         task_loop = task.get_loop()
 *                         if task_loop == current_loop:
 *                             task.cancel()             # <<<<<<<<<<<<<<
 *                     except Exception as e:
 *                         logger.debug("Error cancelling background task: %s", e)
*/
                __pyx_t_2 = __pyx_cur_scope->__pyx_v_task;
                __Pyx_INCREF(__pyx_t_2);
                __pyx_t_3 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
                  __pyx_t_8 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_cancel, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                  if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1545, __pyx_L14_error)
                  __Pyx_GOTREF(__pyx_t_8);
                }
                __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

                /* "ws_package/controllers/activity_controller.py":1544
 *                         # Only cancel tasks that belong to the current event loop
 *                         task_loop = task.get_loop()
 *                         if task_loop == current_loop:             # <<<<<<<<<<<<<<
 *                             task.cancel()
 *                     except Exception as e:
*/
              }

              /* "ws_package/controllers/activity_controller.py":1541
 *             for task in list(self._background_tasks):
 *                 if not task.done():
 *                     try:             # <<<<<<<<<<<<<<
 *                         # Only cancel tasks that belong to the current event loop
 *                         task_loop = task.get_loop()
*/
            }
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            goto __pyx_L21_try_end;
            __pyx_L14_error:;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

            /* "ws_package/controllers/activity_controller.py":1546
 *                         if task_loop == current_loop:
 *                             task.cancel()
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.debug("Error cancelling background task: %s", e)
 * 
*/
            __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
            if (__pyx_t_14) {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_2, &__pyx_t_5) < 0) __PYX_ERR(0, 1546, __pyx_L16_except_error)
              __Pyx_XGOTREF(__pyx_t_8);
              __Pyx_XGOTREF(__pyx_t_2);
              __Pyx_XGOTREF(__pyx_t_5);
              __Pyx_INCREF(__pyx_t_2);
              __Pyx_GIVEREF(__pyx_t_2);
              __pyx_cur_scope->__pyx_v_e = __pyx_t_2;
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":1547
 *                             task.cancel()
 *                     except Exception as e:
 *                         logger.debug("Error cancelling background task: %s", e)             # <<<<<<<<<<<<<<
 * 
 *             logger.info("Device activity monitoring stopped")
*/
                __pyx_t_15 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1547, __pyx_L28_error)
                __Pyx_GOTREF(__pyx_t_16);
                __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1547, __pyx_L28_error)
                __Pyx_GOTREF(__pyx_t_17);
                __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                __pyx_t_3 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_17))) {
                  __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_17);
                  assert(__pyx_t_15);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
                  __Pyx_INCREF(__pyx_t_15);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
                  __pyx_t_3 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Error_cancelling_background_task, __pyx_cur_scope->__pyx_v_e};
                  __pyx_t_9 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                  if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1547, __pyx_L28_error)
                  __Pyx_GOTREF(__pyx_t_9);
                }
                __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
              }

              /* "ws_package/controllers/activity_controller.py":1546
 *                         if task_loop == current_loop:
 *                             task.cancel()
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.debug("Error cancelling background task: %s", e)
 * 
*/
              /*finally:*/ {
                /*normal exit:*/{
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  goto __pyx_L29;
                }
                __pyx_L28_error:;
                /*exception exit:*/{
                  __Pyx_PyThreadState_assign
                  __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0;
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                  __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                   __Pyx_ExceptionSwap(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25);
                  if ( unlikely(__Pyx_GetException(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22) < 0)) __Pyx_ErrFetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
                  __Pyx_XGOTREF(__pyx_t_20);
                  __Pyx_XGOTREF(__pyx_t_21);
                  __Pyx_XGOTREF(__pyx_t_22);
                  __Pyx_XGOTREF(__pyx_t_23);
                  __Pyx_XGOTREF(__pyx_t_24);
                  __Pyx_XGOTREF(__pyx_t_25);
                  __pyx_t_14 = __pyx_lineno; __pyx_t_18 = __pyx_clineno; __pyx_t_19 = __pyx_filename;
                  {
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  }
                  __Pyx_XGIVEREF(__pyx_t_23);
                  __Pyx_XGIVEREF(__pyx_t_24);
                  __Pyx_XGIVEREF(__pyx_t_25);
                  __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_24, __pyx_t_25);
                  __Pyx_XGIVEREF(__pyx_t_20);
                  __Pyx_XGIVEREF(__pyx_t_21);
                  __Pyx_XGIVEREF(__pyx_t_22);
                  __Pyx_ErrRestore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
                  __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0;
                  __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_18; __pyx_filename = __pyx_t_19;
                  goto __pyx_L16_except_error;
                }
                __pyx_L29:;
              }
              __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              goto __pyx_L15_exception_handled;
            }
            goto __pyx_L16_except_error;

            /* "ws_package/controllers/activity_controller.py":1541
 *             for task in list(self._background_tasks):
 *                 if not task.done():
 *                     try:             # <<<<<<<<<<<<<<
 *                         # Only cancel tasks that belong to the current event loop
 *                         task_loop = task.get_loop()
*/
            __pyx_L16_except_error:;
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
            goto __pyx_L1_error;
            __pyx_L15_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
            __pyx_L21_try_end:;
          }

          /* "ws_package/controllers/activity_controller.py":1540
 *             current_loop = asyncio.get_running_loop()
 *             for task in list(self._background_tasks):
 *                 if not task.done():             # <<<<<<<<<<<<<<
 *                     try:
 *                         # Only cancel tasks that belong to the current event loop
*/
        }

        /* "ws_package/controllers/activity_controller.py":1539
 *             # Cancel all background tasks
 *             current_loop = asyncio.get_running_loop()
 *             for task in list(self._background_tasks):             # <<<<<<<<<<<<<<
 *                 if not task.done():
 *                     try:
*/
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":1549
 *                         logger.debug("Error cancelling background task: %s", e)
 * 
 *             logger.info("Device activity monitoring stopped")             # <<<<<<<<<<<<<<
 * 
 *     # Timer warning monitoring has been moved to Electron client-side
*/
      __pyx_t_5 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1549, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1549, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_3 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_8);
        assert(__pyx_t_5);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
        __pyx_t_3 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Device_activity_monitoring_stopp};
        __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1549, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L9;
    }
    __pyx_L8_error:;
    /*exception exit:*/{
      __Pyx_PyThreadState_assign
      __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
       __Pyx_ExceptionSwap(&__pyx_t_25, &__pyx_t_24, &__pyx_t_23);
      if ( unlikely(__Pyx_GetException(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11) < 0)) __Pyx_ErrFetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_25);
      __Pyx_XGOTREF(__pyx_t_24);
      __Pyx_XGOTREF(__pyx_t_23);
      __pyx_t_18 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_26 = __pyx_filename;
      {

        /* "ws_package/controllers/activity_controller.py":1534
 *         finally:
 *             # Ensure the minute timer and all background tasks are cancelled when main loop exits
 *             minute_timer_task.cancel()             # <<<<<<<<<<<<<<
 *             # queue_processor_task.cancel()
 *             # queue_processor_task removed - using universal db_write_queue instead
*/
        __pyx_t_8 = __pyx_cur_scope->__pyx_v_minute_timer_task;
        __Pyx_INCREF(__pyx_t_8);
        __pyx_t_3 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
          __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_cancel, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1534, __pyx_L36_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":1538
 *             # queue_processor_task removed - using universal db_write_queue instead
 *             # Cancel all background tasks
 *             current_loop = asyncio.get_running_loop()             # <<<<<<<<<<<<<<
 *             for task in list(self._background_tasks):
 *                 if not task.done():
*/
        __pyx_t_8 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1538, __pyx_L36_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_get_running_loop); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1538, __pyx_L36_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_3 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
          assert(__pyx_t_8);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
          __pyx_t_3 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1538, __pyx_L36_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_v_current_loop = __pyx_t_1;
        __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":1539
 *             # Cancel all background tasks
 *             current_loop = asyncio.get_running_loop()
 *             for task in list(self._background_tasks):             # <<<<<<<<<<<<<<
 *                 if not task.done():
 *                     try:
*/
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_background_tasks); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1539, __pyx_L36_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_2 = __Pyx_PySequence_ListKeepNew(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1539, __pyx_L36_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1);
        __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        for (;;) {
          {
            Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
            #if !CYTHON_ASSUME_SAFE_SIZE
            if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1539, __pyx_L36_error)
            #endif
            if (__pyx_t_10 >= __pyx_temp) break;
          }
          __pyx_t_2 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_1, __pyx_t_10, __Pyx_ReferenceSharing_OwnStrongReference);
          ++__pyx_t_10;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1539, __pyx_L36_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_task);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_task, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":1540
 *             current_loop = asyncio.get_running_loop()
 *             for task in list(self._background_tasks):
 *                 if not task.done():             # <<<<<<<<<<<<<<
 *                     try:
 *                         # Only cancel tasks that belong to the current event loop
*/
          __pyx_t_8 = __pyx_cur_scope->__pyx_v_task;
          __Pyx_INCREF(__pyx_t_8);
          __pyx_t_3 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
            __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_done, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1540, __pyx_L36_error)
            __Pyx_GOTREF(__pyx_t_2);
          }
          __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1540, __pyx_L36_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_7 = (!__pyx_t_6);
          if (__pyx_t_7) {

            /* "ws_package/controllers/activity_controller.py":1541
 *             for task in list(self._background_tasks):
 *                 if not task.done():
 *                     try:             # <<<<<<<<<<<<<<
 *                         # Only cancel tasks that belong to the current event loop
 *                         task_loop = task.get_loop()
*/
            {
              __Pyx_ExceptionSave(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
              __Pyx_XGOTREF(__pyx_t_22);
              __Pyx_XGOTREF(__pyx_t_21);
              __Pyx_XGOTREF(__pyx_t_20);
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":1543
 *                     try:
 *                         # Only cancel tasks that belong to the current event loop
 *                         task_loop = task.get_loop()             # <<<<<<<<<<<<<<
 *                         if task_loop == current_loop:
 *                             task.cancel()
*/
                __pyx_t_8 = __pyx_cur_scope->__pyx_v_task;
                __Pyx_INCREF(__pyx_t_8);
                __pyx_t_3 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
                  __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_loop, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1543, __pyx_L40_error)
                  __Pyx_GOTREF(__pyx_t_2);
                }
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_task_loop);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_task_loop, __pyx_t_2);
                __Pyx_GIVEREF(__pyx_t_2);
                __pyx_t_2 = 0;

                /* "ws_package/controllers/activity_controller.py":1544
 *                         # Only cancel tasks that belong to the current event loop
 *                         task_loop = task.get_loop()
 *                         if task_loop == current_loop:             # <<<<<<<<<<<<<<
 *                             task.cancel()
 *                     except Exception as e:
*/
                __pyx_t_2 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_task_loop, __pyx_cur_scope->__pyx_v_current_loop, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1544, __pyx_L40_error)
                __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1544, __pyx_L40_error)
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                if (__pyx_t_7) {

                  /* "ws_package/controllers/activity_controller.py":1545
 *                         task_loop = task.get_loop()
 *                         if task_loop == current_loop:
 *                             task.cancel()             # <<<<<<<<<<<<<<
 *                     except Exception as e:
 *                         logger.debug("Error cancelling background task: %s", e)
*/
                  __pyx_t_8 = __pyx_cur_scope->__pyx_v_task;
                  __Pyx_INCREF(__pyx_t_8);
                  __pyx_t_3 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
                    __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_cancel, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1545, __pyx_L40_error)
                    __Pyx_GOTREF(__pyx_t_2);
                  }
                  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

                  /* "ws_package/controllers/activity_controller.py":1544
 *                         # Only cancel tasks that belong to the current event loop
 *                         task_loop = task.get_loop()
 *                         if task_loop == current_loop:             # <<<<<<<<<<<<<<
 *                             task.cancel()
 *                     except Exception as e:
*/
                }

                /* "ws_package/controllers/activity_controller.py":1541
 *             for task in list(self._background_tasks):
 *                 if not task.done():
 *                     try:             # <<<<<<<<<<<<<<
 *                         # Only cancel tasks that belong to the current event loop
 *                         task_loop = task.get_loop()
*/
              }
              __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
              __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
              __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
              goto __pyx_L47_try_end;
              __pyx_L40_error:;
              __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
              __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
              __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
              __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

              /* "ws_package/controllers/activity_controller.py":1546
 *                         if task_loop == current_loop:
 *                             task.cancel()
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.debug("Error cancelling background task: %s", e)
 * 
*/
              __pyx_t_27 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
              if (__pyx_t_27) {
                __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
                if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_8, &__pyx_t_5) < 0) __PYX_ERR(0, 1546, __pyx_L42_except_error)
                __Pyx_XGOTREF(__pyx_t_2);
                __Pyx_XGOTREF(__pyx_t_8);
                __Pyx_XGOTREF(__pyx_t_5);
                __Pyx_INCREF(__pyx_t_8);
                __Pyx_GIVEREF(__pyx_t_8);
                __pyx_cur_scope->__pyx_v_e = __pyx_t_8;
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":1547
 *                             task.cancel()
 *                     except Exception as e:
 *                         logger.debug("Error cancelling background task: %s", e)             # <<<<<<<<<<<<<<
 * 
 *             logger.info("Device activity monitoring stopped")
*/
                  __pyx_t_17 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1547, __pyx_L54_error)
                  __Pyx_GOTREF(__pyx_t_15);
                  __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1547, __pyx_L54_error)
                  __Pyx_GOTREF(__pyx_t_16);
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __pyx_t_3 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_16))) {
                    __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_16);
                    assert(__pyx_t_17);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_16);
                    __Pyx_INCREF(__pyx_t_17);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_16, __pyx__function);
                    __pyx_t_3 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[3] = {__pyx_t_17, __pyx_mstate_global->__pyx_kp_u_Error_cancelling_background_task, __pyx_cur_scope->__pyx_v_e};
                    __pyx_t_9 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_16, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                    if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1547, __pyx_L54_error)
                    __Pyx_GOTREF(__pyx_t_9);
                  }
                  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                }

                /* "ws_package/controllers/activity_controller.py":1546
 *                         if task_loop == current_loop:
 *                             task.cancel()
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.debug("Error cancelling background task: %s", e)
 * 
*/
                /*finally:*/ {
                  /*normal exit:*/{
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    goto __pyx_L55;
                  }
                  __pyx_L54_error:;
                  /*exception exit:*/{
                    __Pyx_PyThreadState_assign
                    __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0; __pyx_t_33 = 0; __pyx_t_34 = 0; __pyx_t_35 = 0;
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                     __Pyx_ExceptionSwap(&__pyx_t_33, &__pyx_t_34, &__pyx_t_35);
                    if ( unlikely(__Pyx_GetException(&__pyx_t_30, &__pyx_t_31, &__pyx_t_32) < 0)) __Pyx_ErrFetch(&__pyx_t_30, &__pyx_t_31, &__pyx_t_32);
                    __Pyx_XGOTREF(__pyx_t_30);
                    __Pyx_XGOTREF(__pyx_t_31);
                    __Pyx_XGOTREF(__pyx_t_32);
                    __Pyx_XGOTREF(__pyx_t_33);
                    __Pyx_XGOTREF(__pyx_t_34);
                    __Pyx_XGOTREF(__pyx_t_35);
                    __pyx_t_27 = __pyx_lineno; __pyx_t_28 = __pyx_clineno; __pyx_t_29 = __pyx_filename;
                    {
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    }
                    __Pyx_XGIVEREF(__pyx_t_33);
                    __Pyx_XGIVEREF(__pyx_t_34);
                    __Pyx_XGIVEREF(__pyx_t_35);
                    __Pyx_ExceptionReset(__pyx_t_33, __pyx_t_34, __pyx_t_35);
                    __Pyx_XGIVEREF(__pyx_t_30);
                    __Pyx_XGIVEREF(__pyx_t_31);
                    __Pyx_XGIVEREF(__pyx_t_32);
                    __Pyx_ErrRestore(__pyx_t_30, __pyx_t_31, __pyx_t_32);
                    __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0; __pyx_t_33 = 0; __pyx_t_34 = 0; __pyx_t_35 = 0;
                    __pyx_lineno = __pyx_t_27; __pyx_clineno = __pyx_t_28; __pyx_filename = __pyx_t_29;
                    goto __pyx_L42_except_error;
                  }
                  __pyx_L55:;
                }
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                goto __pyx_L41_exception_handled;
              }
              goto __pyx_L42_except_error;

              /* "ws_package/controllers/activity_controller.py":1541
 *             for task in list(self._background_tasks):
 *                 if not task.done():
 *                     try:             # <<<<<<<<<<<<<<
 *                         # Only cancel tasks that belong to the current event loop
 *                         task_loop = task.get_loop()
*/
              __pyx_L42_except_error:;
              __Pyx_XGIVEREF(__pyx_t_22);
              __Pyx_XGIVEREF(__pyx_t_21);
              __Pyx_XGIVEREF(__pyx_t_20);
              __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_21, __pyx_t_20);
              goto __pyx_L36_error;
              __pyx_L41_exception_handled:;
              __Pyx_XGIVEREF(__pyx_t_22);
              __Pyx_XGIVEREF(__pyx_t_21);
              __Pyx_XGIVEREF(__pyx_t_20);
              __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_21, __pyx_t_20);
              __pyx_L47_try_end:;
            }

            /* "ws_package/controllers/activity_controller.py":1540
 *             current_loop = asyncio.get_running_loop()
 *             for task in list(self._background_tasks):
 *                 if not task.done():             # <<<<<<<<<<<<<<
 *                     try:
 *                         # Only cancel tasks that belong to the current event loop
*/
          }

          /* "ws_package/controllers/activity_controller.py":1539
 *             # Cancel all background tasks
 *             current_loop = asyncio.get_running_loop()
 *             for task in list(self._background_tasks):             # <<<<<<<<<<<<<<
 *                 if not task.done():
 *                     try:
*/
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":1549
 *                         logger.debug("Error cancelling background task: %s", e)
 * 
 *             logger.info("Device activity monitoring stopped")             # <<<<<<<<<<<<<<
 * 
 *     # Timer warning monitoring has been moved to Electron client-side
*/
        __pyx_t_5 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1549, __pyx_L36_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1549, __pyx_L36_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_3 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
          assert(__pyx_t_5);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
          __pyx_t_3 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Device_activity_monitoring_stopp};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1549, __pyx_L36_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }
      __Pyx_XGIVEREF(__pyx_t_25);
      __Pyx_XGIVEREF(__pyx_t_24);
      __Pyx_XGIVEREF(__pyx_t_23);
      __Pyx_ExceptionReset(__pyx_t_25, __pyx_t_24, __pyx_t_23);
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_ErrRestore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
      __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0;
      __pyx_lineno = __pyx_t_18; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_26;
      goto __pyx_L1_error;
      __pyx_L36_error:;
      __Pyx_XGIVEREF(__pyx_t_25);
      __Pyx_XGIVEREF(__pyx_t_24);
      __Pyx_XGIVEREF(__pyx_t_23);
      __Pyx_ExceptionReset(__pyx_t_25, __pyx_t_24, __pyx_t_23);
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0;
      goto __pyx_L1_error;
    }
    __pyx_L9:;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":1481
 *         )
 * 
 *     async def start_device_activity(self, user_entity: UserEntity, stop_event: Optional[asyncio.Event] = None) -> None:             # <<<<<<<<<<<<<<
 *         self.user_entity = user_entity
 *         """
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_89generator17(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":1554
 *     # This method is no longer needed - reminder logic is now handled entirely in the Electron renderer
 * 
 *     async def getStartingSlot(self) -> Tuple[datetime.datetime, datetime.datetime]:             # <<<<<<<<<<<<<<
 *         """
 *         Calculate the starting time slot for activity monitoring.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_88getStartingSlot(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_87getStartingSlot, "\n        Calculate the starting time slot for activity monitoring.\n        \n        This method determines the appropriate start and end times for the first\n        activity monitoring interval based on the current time and configured\n        interval duration.\n        \n        Returns:\n            Tuple[datetime.datetime, datetime.datetime]: Start and end times for\n            the initial monitoring slot.\n            \n        Example:\n            >>> controller = ActivityController(last_count=1)\n            >>> start_time, end_time = await controller.getStartingSlot()\n            >>> print(f\"Monitoring from {start_time} to {end_time}\")\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_88getStartingSlot = {"getStartingSlot", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_88getStartingSlot, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_87getStartingSlot};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_88getStartingSlot(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[1] = {0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getStartingSlot (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 1554, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1554, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "getStartingSlot", 0) < (0)) __PYX_ERR(0, 1554, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("getStartingSlot", 1, 1, 1, i); __PYX_ERR(0, 1554, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 1)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1554, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("getStartingSlot", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 1554, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.getStartingSlot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_87getStartingSlot(__pyx_self, __pyx_v_self);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_87getStartingSlot(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getStartingSlot", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1554, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_89generator17, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[18]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_getStartingSlot, __pyx_mstate_global->__pyx_n_u_ActivityController_getStartingSl, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 1554, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.getStartingSlot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_89generator17(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  size_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getStartingSlot", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 1554, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":1571
 *             >>> print(f"Monitoring from {start_time} to {end_time}")
 *         """
 *         last_minute = 50             # <<<<<<<<<<<<<<
 *         if int(self.interval/60) == 15:
 *             last_minute = 45
*/
  __pyx_cur_scope->__pyx_v_last_minute = 50;

  /* "ws_package/controllers/activity_controller.py":1572
 *         """
 *         last_minute = 50
 *         if int(self.interval/60) == 15:             # <<<<<<<<<<<<<<
 *             last_minute = 45
 *         if int(self.interval/60) ==5:
*/
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1572, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyLong_TrueDivideObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_60, 60, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1572, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1572, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_15, 15, 0)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1572, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_3) {

    /* "ws_package/controllers/activity_controller.py":1573
 *         last_minute = 50
 *         if int(self.interval/60) == 15:
 *             last_minute = 45             # <<<<<<<<<<<<<<
 *         if int(self.interval/60) ==5:
 *             last_minute = 55
*/
    __pyx_cur_scope->__pyx_v_last_minute = 45;

    /* "ws_package/controllers/activity_controller.py":1572
 *         """
 *         last_minute = 50
 *         if int(self.interval/60) == 15:             # <<<<<<<<<<<<<<
 *             last_minute = 45
 *         if int(self.interval/60) ==5:
*/
  }

  /* "ws_package/controllers/activity_controller.py":1574
 *         if int(self.interval/60) == 15:
 *             last_minute = 45
 *         if int(self.interval/60) ==5:             # <<<<<<<<<<<<<<
 *             last_minute = 55
 *         start_time=datetime.datetime.now()
*/
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1574, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyLong_TrueDivideObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_60, 60, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1574, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1574, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_3 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_5, 5, 0)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1574, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_3) {

    /* "ws_package/controllers/activity_controller.py":1575
 *             last_minute = 45
 *         if int(self.interval/60) ==5:
 *             last_minute = 55             # <<<<<<<<<<<<<<
 *         start_time=datetime.datetime.now()
 *         self.tzmain = start_time
*/
    __pyx_cur_scope->__pyx_v_last_minute = 55;

    /* "ws_package/controllers/activity_controller.py":1574
 *         if int(self.interval/60) == 15:
 *             last_minute = 45
 *         if int(self.interval/60) ==5:             # <<<<<<<<<<<<<<
 *             last_minute = 55
 *         start_time=datetime.datetime.now()
*/
  }

  /* "ws_package/controllers/activity_controller.py":1576
 *         if int(self.interval/60) ==5:
 *             last_minute = 55
 *         start_time=datetime.datetime.now()             # <<<<<<<<<<<<<<
 *         self.tzmain = start_time
 *         minute=start_time.minute
*/
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1576, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1576, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_2 = __pyx_t_5;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_6 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1576, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_start_time = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":1577
 *             last_minute = 55
 *         start_time=datetime.datetime.now()
 *         self.tzmain = start_time             # <<<<<<<<<<<<<<
 *         minute=start_time.minute
 *         if minute<last_minute:
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_tzmain, __pyx_cur_scope->__pyx_v_start_time) < (0)) __PYX_ERR(0, 1577, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":1578
 *         start_time=datetime.datetime.now()
 *         self.tzmain = start_time
 *         minute=start_time.minute             # <<<<<<<<<<<<<<
 *         if minute<last_minute:
 *             end_time=start_time.replace(minute=((int(self.interval/60)-(minute%int(self.interval/60)))+minute),second=00, microsecond=00)
*/
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_start_time, __pyx_mstate_global->__pyx_n_u_minute); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1578, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_minute = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":1579
 *         self.tzmain = start_time
 *         minute=start_time.minute
 *         if minute<last_minute:             # <<<<<<<<<<<<<<
 *             end_time=start_time.replace(minute=((int(self.interval/60)-(minute%int(self.interval/60)))+minute),second=00, microsecond=00)
 *         else:
*/
  __pyx_t_1 = __Pyx_PyLong_From_long(__pyx_cur_scope->__pyx_v_last_minute); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1579, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_minute, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1579, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1579, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_3) {

    /* "ws_package/controllers/activity_controller.py":1580
 *         minute=start_time.minute
 *         if minute<last_minute:
 *             end_time=start_time.replace(minute=((int(self.interval/60)-(minute%int(self.interval/60)))+minute),second=00, microsecond=00)             # <<<<<<<<<<<<<<
 *         else:
 *             hr=start_time.hour
*/
    __pyx_t_1 = __pyx_cur_scope->__pyx_v_start_time;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1580, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyLong_TrueDivideObjC(__pyx_t_2, __pyx_mstate_global->__pyx_int_60, 60, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1580, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_2 = __Pyx_PyNumber_Int(__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1580, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1580, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_7 = __Pyx_PyLong_TrueDivideObjC(__pyx_t_4, __pyx_mstate_global->__pyx_int_60, 60, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1580, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyNumber_Int(__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1580, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyNumber_Remainder(__pyx_cur_scope->__pyx_v_minute, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1580, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyNumber_Subtract(__pyx_t_2, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1580, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_7 = PyNumber_Add(__pyx_t_4, __pyx_cur_scope->__pyx_v_minute); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1580, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = 0;
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 3 : 0)] = {__pyx_t_1, NULL};
      __pyx_t_4 = __Pyx_MakeVectorcallBuilderKwds(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1580, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_minute, __pyx_t_7, __pyx_t_4, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 1580, __pyx_L1_error)
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_second, __pyx_mstate_global->__pyx_int_0, __pyx_t_4, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 1580, __pyx_L1_error)
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_4, __pyx_callargs+1, 2) < (0)) __PYX_ERR(0, 1580, __pyx_L1_error)
      __pyx_t_5 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_4);
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1580, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_cur_scope->__pyx_v_end_time = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "ws_package/controllers/activity_controller.py":1579
 *         self.tzmain = start_time
 *         minute=start_time.minute
 *         if minute<last_minute:             # <<<<<<<<<<<<<<
 *             end_time=start_time.replace(minute=((int(self.interval/60)-(minute%int(self.interval/60)))+minute),second=00, microsecond=00)
 *         else:
*/
    goto __pyx_L6;
  }

  /* "ws_package/controllers/activity_controller.py":1582
 *             end_time=start_time.replace(minute=((int(self.interval/60)-(minute%int(self.interval/60)))+minute),second=00, microsecond=00)
 *         else:
 *             hr=start_time.hour             # <<<<<<<<<<<<<<
 *             if hr == 23:
 *                 # Use timedelta to handle month/year rollovers correctly
*/
  /*else*/ {
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_start_time, __pyx_mstate_global->__pyx_n_u_hour); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1582, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_cur_scope->__pyx_v_hr = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "ws_package/controllers/activity_controller.py":1583
 *         else:
 *             hr=start_time.hour
 *             if hr == 23:             # <<<<<<<<<<<<<<
 *                 # Use timedelta to handle month/year rollovers correctly
 *                 next_day = start_time + datetime.timedelta(days=1)
*/
    __pyx_t_3 = (__Pyx_PyLong_BoolEqObjC(__pyx_cur_scope->__pyx_v_hr, __pyx_mstate_global->__pyx_int_23, 23, 0)); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 1583, __pyx_L1_error)
    if (__pyx_t_3) {

      /* "ws_package/controllers/activity_controller.py":1585
 *             if hr == 23:
 *                 # Use timedelta to handle month/year rollovers correctly
 *                 next_day = start_time + datetime.timedelta(days=1)             # <<<<<<<<<<<<<<
 *                 logger.debug("Day rollover detected: %s -> %s", start_time.day, next_day.day)
 *                 end_time = next_day.replace(minute=00, hour=00, second=00, microsecond=00)
*/
      __pyx_t_4 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1585, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_timedelta); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1585, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_6 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
        assert(__pyx_t_4);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
        __pyx_t_6 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_4, NULL};
        __pyx_t_7 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1585, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_days, __pyx_mstate_global->__pyx_int_1, __pyx_t_7, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 1585, __pyx_L1_error)
        __pyx_t_5 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_7);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1585, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
      }
      __pyx_t_1 = PyNumber_Add(__pyx_cur_scope->__pyx_v_start_time, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1585, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_cur_scope->__pyx_v_next_day = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":1586
 *                 # Use timedelta to handle month/year rollovers correctly
 *                 next_day = start_time + datetime.timedelta(days=1)
 *                 logger.debug("Day rollover detected: %s -> %s", start_time.day, next_day.day)             # <<<<<<<<<<<<<<
 *                 end_time = next_day.replace(minute=00, hour=00, second=00, microsecond=00)
 *                 return start_time, end_time
*/
      __pyx_t_5 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1586, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1586, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_start_time, __pyx_mstate_global->__pyx_n_u_day); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1586, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_next_day, __pyx_mstate_global->__pyx_n_u_day); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1586, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_6 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        assert(__pyx_t_5);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
        __pyx_t_6 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[4] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Day_rollover_detected_s_s, __pyx_t_7, __pyx_t_2};
        __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_6, (4-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1586, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":1587
 *                 next_day = start_time + datetime.timedelta(days=1)
 *                 logger.debug("Day rollover detected: %s -> %s", start_time.day, next_day.day)
 *                 end_time = next_day.replace(minute=00, hour=00, second=00, microsecond=00)             # <<<<<<<<<<<<<<
 *                 return start_time, end_time
 *             end_time=start_time.replace(minute=00,hour=hr+1,second=00, microsecond=00)
*/
      __pyx_t_4 = __pyx_cur_scope->__pyx_v_next_day;
      __Pyx_INCREF(__pyx_t_4);
      __pyx_t_6 = 0;
      {
        PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 4 : 0)] = {__pyx_t_4, NULL};
        __pyx_t_2 = __Pyx_MakeVectorcallBuilderKwds(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1587, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_minute, __pyx_mstate_global->__pyx_int_0, __pyx_t_2, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 1587, __pyx_L1_error)
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_hour, __pyx_mstate_global->__pyx_int_0, __pyx_t_2, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 1587, __pyx_L1_error)
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_second, __pyx_mstate_global->__pyx_int_0, __pyx_t_2, __pyx_callargs+1, 2) < (0)) __PYX_ERR(0, 1587, __pyx_L1_error)
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_2, __pyx_callargs+1, 3) < (0)) __PYX_ERR(0, 1587, __pyx_L1_error)
        __pyx_t_1 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_2);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1587, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_cur_scope->__pyx_v_end_time = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":1588
 *                 logger.debug("Day rollover detected: %s -> %s", start_time.day, next_day.day)
 *                 end_time = next_day.replace(minute=00, hour=00, second=00, microsecond=00)
 *                 return start_time, end_time             # <<<<<<<<<<<<<<
 *             end_time=start_time.replace(minute=00,hour=hr+1,second=00, microsecond=00)
 *         return start_time,end_time
*/
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1588, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_start_time);
      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_start_time);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_cur_scope->__pyx_v_start_time) != (0)) __PYX_ERR(0, 1588, __pyx_L1_error);
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_end_time);
      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_end_time);
      if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_cur_scope->__pyx_v_end_time) != (0)) __PYX_ERR(0, 1588, __pyx_L1_error);
      __pyx_r = ((PyObject*)__pyx_t_1);
      __pyx_t_1 = 0;
      goto __pyx_L0;

      /* "ws_package/controllers/activity_controller.py":1583
 *         else:
 *             hr=start_time.hour
 *             if hr == 23:             # <<<<<<<<<<<<<<
 *                 # Use timedelta to handle month/year rollovers correctly
 *                 next_day = start_time + datetime.timedelta(days=1)
*/
    }

    /* "ws_package/controllers/activity_controller.py":1589
 *                 end_time = next_day.replace(minute=00, hour=00, second=00, microsecond=00)
 *                 return start_time, end_time
 *             end_time=start_time.replace(minute=00,hour=hr+1,second=00, microsecond=00)             # <<<<<<<<<<<<<<
 *         return start_time,end_time
 * 
*/
    __pyx_t_2 = __pyx_cur_scope->__pyx_v_start_time;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyLong_AddObjC(__pyx_cur_scope->__pyx_v_hr, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1589, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_6 = 0;
    {
      PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 4 : 0)] = {__pyx_t_2, NULL};
      __pyx_t_7 = __Pyx_MakeVectorcallBuilderKwds(4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1589, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_minute, __pyx_mstate_global->__pyx_int_0, __pyx_t_7, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 1589, __pyx_L1_error)
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_hour, __pyx_t_4, __pyx_t_7, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 1589, __pyx_L1_error)
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_second, __pyx_mstate_global->__pyx_int_0, __pyx_t_7, __pyx_callargs+1, 2) < (0)) __PYX_ERR(0, 1589, __pyx_L1_error)
      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_7, __pyx_callargs+1, 3) < (0)) __PYX_ERR(0, 1589, __pyx_L1_error)
      __pyx_t_1 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_7);
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1589, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_v_end_time = __pyx_t_1;
    __pyx_t_1 = 0;
  }
  __pyx_L6:;

  /* "ws_package/controllers/activity_controller.py":1590
 *                 return start_time, end_time
 *             end_time=start_time.replace(minute=00,hour=hr+1,second=00, microsecond=00)
 *         return start_time,end_time             # <<<<<<<<<<<<<<
 * 
 *     async def getCurrentSlot(self):
*/
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1590, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_start_time);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_start_time);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_cur_scope->__pyx_v_start_time) != (0)) __PYX_ERR(0, 1590, __pyx_L1_error);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_end_time);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_end_time);
  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_cur_scope->__pyx_v_end_time) != (0)) __PYX_ERR(0, 1590, __pyx_L1_error);
  __pyx_r = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":1554
 *     # This method is no longer needed - reminder logic is now handled entirely in the Electron renderer
 * 
 *     async def getStartingSlot(self) -> Tuple[datetime.datetime, datetime.datetime]:             # <<<<<<<<<<<<<<
 *         """
 *         Calculate the starting time slot for activity monitoring.
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("getStartingSlot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_92generator18(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":1592
 *         return start_time,end_time
 * 
 *     async def getCurrentSlot(self):             # <<<<<<<<<<<<<<
 *         start_date = datetime.datetime.now()
 *         self.tzmain = start_date
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_91getCurrentSlot(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_91getCurrentSlot = {"getCurrentSlot", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_91getCurrentSlot, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_91getCurrentSlot(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[1] = {0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getCurrentSlot (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 1592, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1592, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "getCurrentSlot", 0) < (0)) __PYX_ERR(0, 1592, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("getCurrentSlot", 1, 1, 1, i); __PYX_ERR(0, 1592, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 1)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1592, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("getCurrentSlot", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 1592, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.getCurrentSlot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_90getCurrentSlot(__pyx_self, __pyx_v_self);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_90getCurrentSlot(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getCurrentSlot", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1592, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_92generator18, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[19]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_getCurrentSlot, __pyx_mstate_global->__pyx_n_u_ActivityController_getCurrentSlo, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 1592, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.getCurrentSlot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_92generator18(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getCurrentSlot", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 1592, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":1593
 * 
 *     async def getCurrentSlot(self):
 *         start_date = datetime.datetime.now()             # <<<<<<<<<<<<<<
 *         self.tzmain = start_date
 *         minute = start_date.minute
*/
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1593, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_2 = __pyx_t_4;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1593, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_start_date = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":1594
 *     async def getCurrentSlot(self):
 *         start_date = datetime.datetime.now()
 *         self.tzmain = start_date             # <<<<<<<<<<<<<<
 *         minute = start_date.minute
 * 
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_tzmain, __pyx_cur_scope->__pyx_v_start_date) < (0)) __PYX_ERR(0, 1594, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":1595
 *         start_date = datetime.datetime.now()
 *         self.tzmain = start_date
 *         minute = start_date.minute             # <<<<<<<<<<<<<<
 * 
 *         # Round down to the nearest 10-minute interval
*/
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_start_date, __pyx_mstate_global->__pyx_n_u_minute); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1595, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_minute = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":1598
 * 
 *         # Round down to the nearest 10-minute interval
 *         rounded_minute = (minute // int(self.interval/60)) * int(self.interval/60)             # <<<<<<<<<<<<<<
 * 
 *         # Create the end date with the rounded minute
*/
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyLong_TrueDivideObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_60, 60, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = PyNumber_FloorDivide(__pyx_cur_scope->__pyx_v_minute, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyLong_TrueDivideObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_60, 60, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = PyNumber_Multiply(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1598, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_cur_scope->__pyx_v_rounded_minute = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":1601
 * 
 *         # Create the end date with the rounded minute
 *         end_date = start_date.replace(minute=rounded_minute, second=0, microsecond=0)             # <<<<<<<<<<<<<<
 *         return end_date
 * 
*/
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_start_date;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 3 : 0)] = {__pyx_t_1, NULL};
    __pyx_t_4 = __Pyx_MakeVectorcallBuilderKwds(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1601, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_minute, __pyx_cur_scope->__pyx_v_rounded_minute, __pyx_t_4, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 1601, __pyx_L1_error)
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_second, __pyx_mstate_global->__pyx_int_0, __pyx_t_4, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 1601, __pyx_L1_error)
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_4, __pyx_callargs+1, 2) < (0)) __PYX_ERR(0, 1601, __pyx_L1_error)
    __pyx_t_2 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1601, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
  }
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_cur_scope->__pyx_v_end_date = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":1602
 *         # Create the end date with the rounded minute
 *         end_date = start_date.replace(minute=rounded_minute, second=0, microsecond=0)
 *         return end_date             # <<<<<<<<<<<<<<
 * 
 *     def _align_to_interval_boundary(self, time: datetime.datetime) -> datetime.datetime:
*/
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_end_date);
  __pyx_r = __pyx_cur_scope->__pyx_v_end_date;
  goto __pyx_L0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":1592
 *         return start_time,end_time
 * 
 *     async def getCurrentSlot(self):             # <<<<<<<<<<<<<<
 *         start_date = datetime.datetime.now()
 *         self.tzmain = start_date
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("getCurrentSlot", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":1604
 *         return end_date
 * 
 *     def _align_to_interval_boundary(self, time: datetime.datetime) -> datetime.datetime:             # <<<<<<<<<<<<<<
 *         """
 *         Align a given time to the nearest interval boundary (round down).
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_94_align_to_interval_boundary(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_93_align_to_interval_boundary, "\n        Align a given time to the nearest interval boundary (round down).\n        \n        For example, with 10-minute intervals:\n        - 16:42:30 -> 16:40:00\n        - 16:40:00 -> 16:40:00\n        - 16:39:59 -> 16:30:00\n        \n        Args:\n            time: The datetime to align\n            \n        Returns:\n            datetime aligned to interval boundary\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_94_align_to_interval_boundary = {"_align_to_interval_boundary", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_94_align_to_interval_boundary, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_93_align_to_interval_boundary};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_94_align_to_interval_boundary(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_time = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_align_to_interval_boundary (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_time,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 1604, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1604, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1604, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_align_to_interval_boundary", 0) < (0)) __PYX_ERR(0, 1604, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_align_to_interval_boundary", 1, 2, 2, i); __PYX_ERR(0, 1604, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1604, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1604, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_time = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_align_to_interval_boundary", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 1604, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._align_to_interval_boundary", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_93_align_to_interval_boundary(__pyx_self, __pyx_v_self, __pyx_v_time);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_93_align_to_interval_boundary(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_time) {
  PyObject *__pyx_v_interval_minutes = NULL;
  PyObject *__pyx_v_minute = NULL;
  PyObject *__pyx_v_rounded_minute = NULL;
  PyObject *__pyx_v_aligned_time = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  size_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_align_to_interval_boundary", 0);

  /* "ws_package/controllers/activity_controller.py":1619
 *             datetime aligned to interval boundary
 *         """
 *         interval_minutes = int(self.interval / 60)             # <<<<<<<<<<<<<<
 *         minute = time.minute
 *         rounded_minute = (minute // interval_minutes) * interval_minutes
*/
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1619, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyLong_TrueDivideObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_60, 60, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1619, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1619, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_v_interval_minutes = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":1620
 *         """
 *         interval_minutes = int(self.interval / 60)
 *         minute = time.minute             # <<<<<<<<<<<<<<
 *         rounded_minute = (minute // interval_minutes) * interval_minutes
 *         aligned_time = time.replace(minute=rounded_minute, second=0, microsecond=0)
*/
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_time, __pyx_mstate_global->__pyx_n_u_minute); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1620, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_minute = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":1621
 *         interval_minutes = int(self.interval / 60)
 *         minute = time.minute
 *         rounded_minute = (minute // interval_minutes) * interval_minutes             # <<<<<<<<<<<<<<
 *         aligned_time = time.replace(minute=rounded_minute, second=0, microsecond=0)
 *         return aligned_time
*/
  __pyx_t_1 = PyNumber_FloorDivide(__pyx_v_minute, __pyx_v_interval_minutes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1621, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = PyNumber_Multiply(__pyx_t_1, __pyx_v_interval_minutes); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1621, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_v_rounded_minute = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":1622
 *         minute = time.minute
 *         rounded_minute = (minute // interval_minutes) * interval_minutes
 *         aligned_time = time.replace(minute=rounded_minute, second=0, microsecond=0)             # <<<<<<<<<<<<<<
 *         return aligned_time
 * 
*/
  __pyx_t_1 = __pyx_v_time;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_3 = 0;
  {
    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 3 : 0)] = {__pyx_t_1, NULL};
    __pyx_t_4 = __Pyx_MakeVectorcallBuilderKwds(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1622, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_minute, __pyx_v_rounded_minute, __pyx_t_4, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 1622, __pyx_L1_error)
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_second, __pyx_mstate_global->__pyx_int_0, __pyx_t_4, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 1622, __pyx_L1_error)
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_4, __pyx_callargs+1, 2) < (0)) __PYX_ERR(0, 1622, __pyx_L1_error)
    __pyx_t_2 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1622, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
  }
  __pyx_v_aligned_time = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":1623
 *         rounded_minute = (minute // interval_minutes) * interval_minutes
 *         aligned_time = time.replace(minute=rounded_minute, second=0, microsecond=0)
 *         return aligned_time             # <<<<<<<<<<<<<<
 * 
 *     def is_browser(self, app_name):
*/
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_aligned_time);
  __pyx_r = __pyx_v_aligned_time;
  goto __pyx_L0;

  /* "ws_package/controllers/activity_controller.py":1604
 *         return end_date
 * 
 *     def _align_to_interval_boundary(self, time: datetime.datetime) -> datetime.datetime:             # <<<<<<<<<<<<<<
 *         """
 *         Align a given time to the nearest interval boundary (round down).
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._align_to_interval_boundary", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_interval_minutes);
  __Pyx_XDECREF(__pyx_v_minute);
  __Pyx_XDECREF(__pyx_v_rounded_minute);
  __Pyx_XDECREF(__pyx_v_aligned_time);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":1625
 *         return aligned_time
 * 
 *     def is_browser(self, app_name):             # <<<<<<<<<<<<<<
 *         # Normalize and clean string
 *         normalized_name = unicodedata.normalize("NFKD", app_name)
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_96is_browser(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_96is_browser = {"is_browser", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_96is_browser, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_96is_browser(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  CYTHON_UNUSED PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_app_name = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_browser (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_app_name,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 1625, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1625, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1625, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "is_browser", 0) < (0)) __PYX_ERR(0, 1625, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("is_browser", 1, 2, 2, i); __PYX_ERR(0, 1625, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1625, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1625, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_app_name = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("is_browser", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 1625, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.is_browser", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_95is_browser(__pyx_self, __pyx_v_self, __pyx_v_app_name);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_10is_browser_2generator51(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":1628
 *         # Normalize and clean string
 *         normalized_name = unicodedata.normalize("NFKD", app_name)
 *         cleaned_name = ''.join(c for c in normalized_name if c.isprintable())             # <<<<<<<<<<<<<<
 *         cleaned_name = re.sub(r'[\u200B-\u200D\uFEFF]', '', cleaned_name)  # Remove zero-width chars
 * 
*/

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_10is_browser_genexpr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1628, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_10is_browser_2generator51, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[20]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_genexpr, __pyx_mstate_global->__pyx_n_u_ActivityController_is_browser_lo, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 1628, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.is_browser.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_10is_browser_2generator51(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  size_t __pyx_t_6;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1628, __pyx_L1_error)
  __pyx_r = PyList_New(0); if (unlikely(!__pyx_r)) __PYX_ERR(0, 1628, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_r);
  if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 1628, __pyx_L1_error) }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1);
    __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_genexpr_arg_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1628, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1628, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1628, __pyx_L1_error)
          #endif
          if (__pyx_t_2 >= __pyx_temp) break;
        }
        __pyx_t_4 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_1, __pyx_t_2, __Pyx_ReferenceSharing_OwnStrongReference);
        ++__pyx_t_2;
      } else {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1628, __pyx_L1_error)
          #endif
          if (__pyx_t_2 >= __pyx_temp) break;
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2));
        #else
        __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2);
        #endif
        ++__pyx_t_2;
      }
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1628, __pyx_L1_error)
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 1628, __pyx_L1_error)
          PyErr_Clear();
        }
        break;
      }
    }
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_c);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_c, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_5 = __pyx_cur_scope->__pyx_v_c;
    __Pyx_INCREF(__pyx_t_5);
    __pyx_t_6 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
      __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_isprintable, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1628, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    }
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1628, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_7) {
      if (unlikely(__Pyx_ListComp_Append(__pyx_r, (PyObject*)__pyx_cur_scope->__pyx_v_c))) __PYX_ERR(0, 1628, __pyx_L1_error)
    }
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_r); __pyx_r = 0;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_10is_browser_5generator52(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":1636
 *         browsers = ['Google Chrome', 'Mozilla Firefox', 'Safari', 'Microsoft Edge', 'Opera', 'Msedge', 'Chrome', 'Firefox', 'Brave Browser']
 *         # Case-insensitive matching
 *         return any(browser.lower() in cleaned_name_lower for browser in browsers)             # <<<<<<<<<<<<<<
 * 
 *     async def __start_minute_activity_timer(self, stop_event):
*/

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_10is_browser_3genexpr(PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1636, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser *) __pyx_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  __pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_10is_browser_5generator52, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[21]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_genexpr, __pyx_mstate_global->__pyx_n_u_ActivityController_is_browser_lo, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 1636, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.is_browser.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_10is_browser_5generator52(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1636, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 1636, __pyx_L1_error) }
  __pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1);
  __pyx_t_2 = 0;
  for (;;) {
    {
      Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
      #if !CYTHON_ASSUME_SAFE_SIZE
      if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 1636, __pyx_L1_error)
      #endif
      if (__pyx_t_2 >= __pyx_temp) break;
    }
    __pyx_t_3 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_1, __pyx_t_2, __Pyx_ReferenceSharing_OwnStrongReference);
    ++__pyx_t_2;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1636, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_browser);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_browser, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __pyx_t_4 = __pyx_cur_scope->__pyx_v_browser;
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_5 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
      __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_lower, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1636, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_cleaned_name_lower)) { __Pyx_RaiseClosureNameError("cleaned_name_lower"); __PYX_ERR(0, 1636, __pyx_L1_error) }
    __pyx_t_6 = (__Pyx_PySequence_ContainsTF(__pyx_t_3, __pyx_cur_scope->__pyx_outer_scope->__pyx_v_cleaned_name_lower, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1636, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_6) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_True);
      __pyx_r = Py_True;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":1625
 *         return aligned_time
 * 
 *     def is_browser(self, app_name):             # <<<<<<<<<<<<<<
 *         # Normalize and clean string
 *         normalized_name = unicodedata.normalize("NFKD", app_name)
*/

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_95is_browser(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_app_name) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser *__pyx_cur_scope;
  PyObject *__pyx_v_normalized_name = NULL;
  PyObject *__pyx_v_cleaned_name = NULL;
  PyObject *__pyx_v_browsers = NULL;
  PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_10is_browser_2generator51 = 0;
  PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_10is_browser_5generator52 = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_browser", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1625, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }

  /* "ws_package/controllers/activity_controller.py":1627
 *     def is_browser(self, app_name):
 *         # Normalize and clean string
 *         normalized_name = unicodedata.normalize("NFKD", app_name)             # <<<<<<<<<<<<<<
 *         cleaned_name = ''.join(c for c in normalized_name if c.isprintable())
 *         cleaned_name = re.sub(r'[\u200B-\u200D\uFEFF]', '', cleaned_name)  # Remove zero-width chars
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_unicodedata); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1627, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_normalize); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1627, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_mstate_global->__pyx_n_u_NFKD, __pyx_v_app_name};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1627, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_v_normalized_name = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":1628
 *         # Normalize and clean string
 *         normalized_name = unicodedata.normalize("NFKD", app_name)
 *         cleaned_name = ''.join(c for c in normalized_name if c.isprintable())             # <<<<<<<<<<<<<<
 *         cleaned_name = re.sub(r'[\u200B-\u200D\uFEFF]', '', cleaned_name)  # Remove zero-width chars
 * 
*/
  __pyx_t_1 = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_10is_browser_genexpr(NULL, __pyx_v_normalized_name); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1628, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_Generator_GetInlinedResult(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1628, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = PyUnicode_Join(__pyx_mstate_global->__pyx_kp_u__2, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1628, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_v_cleaned_name = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":1629
 *         normalized_name = unicodedata.normalize("NFKD", app_name)
 *         cleaned_name = ''.join(c for c in normalized_name if c.isprintable())
 *         cleaned_name = re.sub(r'[\u200B-\u200D\uFEFF]', '', cleaned_name)  # Remove zero-width chars             # <<<<<<<<<<<<<<
 * 
 *         # Convert to lowercase for case-insensitive matching
*/
  __pyx_t_4 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_re); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_sub); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1629, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    assert(__pyx_t_4);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[4] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_u200B_u200D_uFEFF, __pyx_mstate_global->__pyx_kp_u__2, __pyx_v_cleaned_name};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_5, (4-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1629, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF_SET(__pyx_v_cleaned_name, __pyx_t_1);
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":1632
 * 
 *         # Convert to lowercase for case-insensitive matching
 *         cleaned_name_lower = cleaned_name.lower()             # <<<<<<<<<<<<<<
 * 
 *         browsers = ['Google Chrome', 'Mozilla Firefox', 'Safari', 'Microsoft Edge', 'Opera', 'Msedge', 'Chrome', 'Firefox', 'Brave Browser']
*/
  __pyx_t_3 = __pyx_v_cleaned_name;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_lower, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1632, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_cleaned_name_lower = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":1634
 *         cleaned_name_lower = cleaned_name.lower()
 * 
 *         browsers = ['Google Chrome', 'Mozilla Firefox', 'Safari', 'Microsoft Edge', 'Opera', 'Msedge', 'Chrome', 'Firefox', 'Brave Browser']             # <<<<<<<<<<<<<<
 *         # Case-insensitive matching
 *         return any(browser.lower() in cleaned_name_lower for browser in browsers)
*/
  __pyx_t_1 = PyList_New(9); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1634, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_Google_Chrome);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_kp_u_Google_Chrome);
  if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_mstate_global->__pyx_kp_u_Google_Chrome) != (0)) __PYX_ERR(0, 1634, __pyx_L1_error);
  __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_Mozilla_Firefox);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_kp_u_Mozilla_Firefox);
  if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 1, __pyx_mstate_global->__pyx_kp_u_Mozilla_Firefox) != (0)) __PYX_ERR(0, 1634, __pyx_L1_error);
  __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_Safari);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_n_u_Safari);
  if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 2, __pyx_mstate_global->__pyx_n_u_Safari) != (0)) __PYX_ERR(0, 1634, __pyx_L1_error);
  __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_Microsoft_Edge);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_kp_u_Microsoft_Edge);
  if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 3, __pyx_mstate_global->__pyx_kp_u_Microsoft_Edge) != (0)) __PYX_ERR(0, 1634, __pyx_L1_error);
  __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_Opera);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_n_u_Opera);
  if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 4, __pyx_mstate_global->__pyx_n_u_Opera) != (0)) __PYX_ERR(0, 1634, __pyx_L1_error);
  __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_Msedge);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_n_u_Msedge);
  if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 5, __pyx_mstate_global->__pyx_n_u_Msedge) != (0)) __PYX_ERR(0, 1634, __pyx_L1_error);
  __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_Chrome);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_n_u_Chrome);
  if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 6, __pyx_mstate_global->__pyx_n_u_Chrome) != (0)) __PYX_ERR(0, 1634, __pyx_L1_error);
  __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_Firefox);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_n_u_Firefox);
  if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 7, __pyx_mstate_global->__pyx_n_u_Firefox) != (0)) __PYX_ERR(0, 1634, __pyx_L1_error);
  __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_Brave_Browser);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_kp_u_Brave_Browser);
  if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 8, __pyx_mstate_global->__pyx_kp_u_Brave_Browser) != (0)) __PYX_ERR(0, 1634, __pyx_L1_error);
  __pyx_v_browsers = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":1636
 *         browsers = ['Google Chrome', 'Mozilla Firefox', 'Safari', 'Microsoft Edge', 'Opera', 'Msedge', 'Chrome', 'Firefox', 'Brave Browser']
 *         # Case-insensitive matching
 *         return any(browser.lower() in cleaned_name_lower for browser in browsers)             # <<<<<<<<<<<<<<
 * 
 *     async def __start_minute_activity_timer(self, stop_event):
*/
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_10is_browser_3genexpr(((PyObject*)__pyx_cur_scope), __pyx_v_browsers); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1636, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_Generator_GetInlinedResult(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1636, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "ws_package/controllers/activity_controller.py":1625
 *         return aligned_time
 * 
 *     def is_browser(self, app_name):             # <<<<<<<<<<<<<<
 *         # Normalize and clean string
 *         normalized_name = unicodedata.normalize("NFKD", app_name)
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.is_browser", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_normalized_name);
  __Pyx_XDECREF(__pyx_v_cleaned_name);
  __Pyx_XDECREF(__pyx_v_browsers);
  __Pyx_XDECREF(__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_10is_browser_2generator51);
  __Pyx_XDECREF(__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_10is_browser_5generator52);
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_99generator19(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":1638
 *         return any(browser.lower() in cleaned_name_lower for browser in browsers)
 * 
 *     async def __start_minute_activity_timer(self, stop_event):             # <<<<<<<<<<<<<<
 *         """Start minute-by-minute activity rolling average timer"""
 *         logger.info("Starting minute-by-minute activity rolling average timer")
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_98__start_minute_activity_timer(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_97__start_minute_activity_timer, "Start minute-by-minute activity rolling average timer");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_98__start_minute_activity_timer = {"__start_minute_activity_timer", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_98__start_minute_activity_timer, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_97__start_minute_activity_timer};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_98__start_minute_activity_timer(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_stop_event = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__start_minute_activity_timer (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_stop_event,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 1638, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1638, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1638, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__start_minute_activity_timer", 0) < (0)) __PYX_ERR(0, 1638, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__start_minute_activity_timer", 1, 2, 2, i); __PYX_ERR(0, 1638, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1638, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1638, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_stop_event = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__start_minute_activity_timer", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 1638, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_minute_activity_timer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_97__start_minute_activity_timer(__pyx_self, __pyx_v_self, __pyx_v_stop_event);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_97__start_minute_activity_timer(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_stop_event) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__start_minute_activity_timer", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1638, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_stop_event = __pyx_v_stop_event;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_stop_event);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_stop_event);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_99generator19, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[22]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_start_minute_activity_timer, __pyx_mstate_global->__pyx_n_u_ActivityController___start_minut, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 1638, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_minute_activity_timer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_99generator19(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_PySendResult __pyx_t_11;
  int __pyx_t_12;
  PyObject *(*__pyx_t_13)(PyObject *);
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_t_18;
  int __pyx_t_19;
  char const *__pyx_t_20;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  PyObject *__pyx_t_26 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__start_minute_activity_timer", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L14_resume_from_await;
    case 2: goto __pyx_L22_resume_from_await;
    case 3: goto __pyx_L25_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 1638, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":1640
 *     async def __start_minute_activity_timer(self, stop_event):
 *         """Start minute-by-minute activity rolling average timer"""
 *         logger.info("Starting minute-by-minute activity rolling average timer")             # <<<<<<<<<<<<<<
 * 
 *         while not stop_event.is_set():
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1640, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1640, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Starting_minute_by_minute_activi};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1640, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":1642
 *         logger.info("Starting minute-by-minute activity rolling average timer")
 * 
 *         while not stop_event.is_set():             # <<<<<<<<<<<<<<
 *             try:
 *                 # Wait for 1 minute
*/
  while (1) {
    __pyx_t_4 = __pyx_cur_scope->__pyx_v_stop_event;
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_5 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
      __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_set, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1642, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1642, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = (!__pyx_t_6);
    if (!__pyx_t_7) break;

    /* "ws_package/controllers/activity_controller.py":1643
 * 
 *         while not stop_event.is_set():
 *             try:             # <<<<<<<<<<<<<<
 *                 # Wait for 1 minute
 *                 await precise_sleep(60, stop_event)
*/
    {
      __Pyx_ExceptionSave(&__pyx_t_8, &__pyx_t_9, &__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":1645
 *             try:
 *                 # Wait for 1 minute
 *                 await precise_sleep(60, stop_event)             # <<<<<<<<<<<<<<
 * 
 *                 if stop_event.is_set():
*/
        __pyx_t_4 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_precise_sleep); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1645, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_5 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
          assert(__pyx_t_4);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
          __pyx_t_5 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_mstate_global->__pyx_int_60, __pyx_cur_scope->__pyx_v_stop_event};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1645, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (likely(__pyx_t_11 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_8);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_8;
          __Pyx_XGIVEREF(__pyx_t_9);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_9;
          __Pyx_XGIVEREF(__pyx_t_10);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_10;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 1;
          return __pyx_r;
          __pyx_L14_resume_from_await:;
          __pyx_t_8 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_8);
          __pyx_t_9 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_9);
          __pyx_t_10 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_10);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1645, __pyx_L6_error)
        } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_DECREF(__pyx_r); __pyx_r = 0;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 1645, __pyx_L6_error)
        }

        /* "ws_package/controllers/activity_controller.py":1647
 *                 await precise_sleep(60, stop_event)
 * 
 *                 if stop_event.is_set():             # <<<<<<<<<<<<<<
 *                     break
 * 
*/
        __pyx_t_2 = __pyx_cur_scope->__pyx_v_stop_event;
        __Pyx_INCREF(__pyx_t_2);
        __pyx_t_5 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
          __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_set, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1647, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1647, __pyx_L6_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (__pyx_t_7) {

          /* "ws_package/controllers/activity_controller.py":1648
 * 
 *                 if stop_event.is_set():
 *                     break             # <<<<<<<<<<<<<<
 * 
 *                 # CRITICAL: Continue activity calculation when on break (break_id != 0) even if status=False
*/
          goto __pyx_L11_try_break;

          /* "ws_package/controllers/activity_controller.py":1647
 *                 await precise_sleep(60, stop_event)
 * 
 *                 if stop_event.is_set():             # <<<<<<<<<<<<<<
 *                     break
 * 
*/
        }

        /* "ws_package/controllers/activity_controller.py":1652
 *                 # CRITICAL: Continue activity calculation when on break (break_id != 0) even if status=False
 *                 # This ensures activity percentages are calculated and stored during break sessions
 *                 current_break_id = getattr(self, 'break_id', 0) or 0             # <<<<<<<<<<<<<<
 *                 if not self.status and current_break_id == 0:
 *                     logger.debug("[Tracker] Activity calculation skipped - tracking is stopped")
*/
        __pyx_t_2 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_break_id, __pyx_mstate_global->__pyx_int_0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1652, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1652, __pyx_L6_error)
        if (!__pyx_t_7) {
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        } else {
          __Pyx_INCREF(__pyx_t_2);
          __pyx_t_1 = __pyx_t_2;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          goto __pyx_L16_bool_binop_done;
        }
        __pyx_t_2 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1652, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = __pyx_t_2;
        __pyx_t_2 = 0;
        __pyx_L16_bool_binop_done:;
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_current_break_id);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_current_break_id, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":1653
 *                 # This ensures activity percentages are calculated and stored during break sessions
 *                 current_break_id = getattr(self, 'break_id', 0) or 0
 *                 if not self.status and current_break_id == 0:             # <<<<<<<<<<<<<<
 *                     logger.debug("[Tracker] Activity calculation skipped - tracking is stopped")
 *                     continue
*/
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1653, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 1653, __pyx_L6_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_12 = (!__pyx_t_6);
        if (__pyx_t_12) {
        } else {
          __pyx_t_7 = __pyx_t_12;
          goto __pyx_L19_bool_binop_done;
        }
        __pyx_t_12 = (__Pyx_PyLong_BoolEqObjC(__pyx_cur_scope->__pyx_v_current_break_id, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_12 < 0))) __PYX_ERR(0, 1653, __pyx_L6_error)
        __pyx_t_7 = __pyx_t_12;
        __pyx_L19_bool_binop_done:;
        if (__pyx_t_7) {

          /* "ws_package/controllers/activity_controller.py":1654
 *                 current_break_id = getattr(self, 'break_id', 0) or 0
 *                 if not self.status and current_break_id == 0:
 *                     logger.debug("[Tracker] Activity calculation skipped - tracking is stopped")             # <<<<<<<<<<<<<<
 *                     continue
 * 
*/
          __pyx_t_2 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1654, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1654, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_5 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_3))) {
            __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
            assert(__pyx_t_2);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_2);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
            __pyx_t_5 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Tracker_Activity_calculation_sk};
            __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1654, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_1);
          }
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":1655
 *                 if not self.status and current_break_id == 0:
 *                     logger.debug("[Tracker] Activity calculation skipped - tracking is stopped")
 *                     continue             # <<<<<<<<<<<<<<
 * 
 *                 # Skip activity calculation if system is sleeping
*/
          goto __pyx_L12_try_continue;

          /* "ws_package/controllers/activity_controller.py":1653
 *                 # This ensures activity percentages are calculated and stored during break sessions
 *                 current_break_id = getattr(self, 'break_id', 0) or 0
 *                 if not self.status and current_break_id == 0:             # <<<<<<<<<<<<<<
 *                     logger.debug("[Tracker] Activity calculation skipped - tracking is stopped")
 *                     continue
*/
        }

        /* "ws_package/controllers/activity_controller.py":1658
 * 
 *                 # Skip activity calculation if system is sleeping
 *                 if self._is_system_sleeping():             # <<<<<<<<<<<<<<
 *                     logger.info("[ACTIVITY] System is sleeping - skipping activity calculation and storage")
 *                     continue
*/
        __pyx_t_3 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_5 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
          __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_system_sleeping, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1658, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 1658, __pyx_L6_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (__pyx_t_7) {

          /* "ws_package/controllers/activity_controller.py":1659
 *                 # Skip activity calculation if system is sleeping
 *                 if self._is_system_sleeping():
 *                     logger.info("[ACTIVITY] System is sleeping - skipping activity calculation and storage")             # <<<<<<<<<<<<<<
 *                     continue
 * 
*/
          __pyx_t_3 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1659, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1659, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_5 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_4))) {
            __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
            assert(__pyx_t_3);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
            __pyx_t_5 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_ACTIVITY_System_is_sleeping_ski};
            __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1659, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_1);
          }
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":1660
 *                 if self._is_system_sleeping():
 *                     logger.info("[ACTIVITY] System is sleeping - skipping activity calculation and storage")
 *                     continue             # <<<<<<<<<<<<<<
 * 
 *                 # Get current activity level for the past minute
*/
          goto __pyx_L12_try_continue;

          /* "ws_package/controllers/activity_controller.py":1658
 * 
 *                 # Skip activity calculation if system is sleeping
 *                 if self._is_system_sleeping():             # <<<<<<<<<<<<<<
 *                     logger.info("[ACTIVITY] System is sleeping - skipping activity calculation and storage")
 *                     continue
*/
        }

        /* "ws_package/controllers/activity_controller.py":1664
 *                 # Get current activity level for the past minute
 * 
 *                 minute_activity_level, _ = await self.device_listener.get_activity_level(60)             # <<<<<<<<<<<<<<
 * 
 *                 # Store rolling averages in activity_percentage table (updates latest row)
*/
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_device_listener); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1664, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __pyx_t_3;
        __Pyx_INCREF(__pyx_t_4);
        __pyx_t_5 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_int_60};
          __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_activity_level, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1664, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (likely(__pyx_t_11 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_8);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_8;
          __Pyx_XGIVEREF(__pyx_t_9);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_9;
          __Pyx_XGIVEREF(__pyx_t_10);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_10;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 2;
          return __pyx_r;
          __pyx_L22_resume_from_await:;
          __pyx_t_8 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_8);
          __pyx_t_9 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_9);
          __pyx_t_10 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_10);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1664, __pyx_L6_error)
          __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
        } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __pyx_t_1 = __pyx_r; __pyx_r = NULL;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 1664, __pyx_L6_error)
        }
        if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
          PyObject* sequence = __pyx_t_1;
          Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
          if (unlikely(size != 2)) {
            if (size > 2) __Pyx_RaiseTooManyValuesError(2);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            __PYX_ERR(0, 1664, __pyx_L6_error)
          }
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
            __Pyx_INCREF(__pyx_t_3);
            __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1);
            __Pyx_INCREF(__pyx_t_4);
          } else {
            __pyx_t_3 = __Pyx_PyList_GET_ITEM_REF(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1664, __pyx_L6_error)
            __Pyx_XGOTREF(__pyx_t_3);
            __pyx_t_4 = __Pyx_PyList_GET_ITEM_REF(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
            if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1664, __pyx_L6_error)
            __Pyx_XGOTREF(__pyx_t_4);
          }
          #else
          __pyx_t_3 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1664, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1664, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_4);
          #endif
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else {
          Py_ssize_t index = -1;
          __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1664, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_13 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_2);
          index = 0; __pyx_t_3 = __pyx_t_13(__pyx_t_2); if (unlikely(!__pyx_t_3)) goto __pyx_L23_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_3);
          index = 1; __pyx_t_4 = __pyx_t_13(__pyx_t_2); if (unlikely(!__pyx_t_4)) goto __pyx_L23_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_4);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_2), 2) < (0)) __PYX_ERR(0, 1664, __pyx_L6_error)
          __pyx_t_13 = NULL;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          goto __pyx_L24_unpacking_done;
          __pyx_L23_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_13 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          __PYX_ERR(0, 1664, __pyx_L6_error)
          __pyx_L24_unpacking_done:;
        }
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_minute_activity_level);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_minute_activity_level, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_t_3 = 0;
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v__);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v__, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":1668
 *                 # Store rolling averages in activity_percentage table (updates latest row)
 *                 # Pass interval_minutes to ensure minute counter is capped correctly
 *                 await activity_percentage_service.calculate_and_store_rolling_average(             # <<<<<<<<<<<<<<
 *                     keyboard_percentage=float(minute_activity_level.get('keyboard', 0)),
 *                     mouse_percentage=float(minute_activity_level.get('mouse', 0)),
*/
        __pyx_t_4 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_activity_percentage_service); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1668, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_calculate_and_store_rolling_aver); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1668, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "ws_package/controllers/activity_controller.py":1669
 *                 # Pass interval_minutes to ensure minute counter is capped correctly
 *                 await activity_percentage_service.calculate_and_store_rolling_average(
 *                     keyboard_percentage=float(minute_activity_level.get('keyboard', 0)),             # <<<<<<<<<<<<<<
 *                     mouse_percentage=float(minute_activity_level.get('mouse', 0)),
 *                     average_percentage=float(minute_activity_level.get('average', 0)),
*/
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_minute_activity_level, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1669, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_mstate_global->__pyx_tuple[15], NULL); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1669, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = __Pyx_PyNumber_Float(__pyx_t_14); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1669, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

        /* "ws_package/controllers/activity_controller.py":1670
 *                 await activity_percentage_service.calculate_and_store_rolling_average(
 *                     keyboard_percentage=float(minute_activity_level.get('keyboard', 0)),
 *                     mouse_percentage=float(minute_activity_level.get('mouse', 0)),             # <<<<<<<<<<<<<<
 *                     average_percentage=float(minute_activity_level.get('average', 0)),
 *                     interval_minutes=int(self.interval / 60)  # 5, 10, or 15 minutes
*/
        __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_minute_activity_level, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1670, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_mstate_global->__pyx_tuple[16], NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1670, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_14 = __Pyx_PyNumber_Float(__pyx_t_15); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1670, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

        /* "ws_package/controllers/activity_controller.py":1671
 *                     keyboard_percentage=float(minute_activity_level.get('keyboard', 0)),
 *                     mouse_percentage=float(minute_activity_level.get('mouse', 0)),
 *                     average_percentage=float(minute_activity_level.get('average', 0)),             # <<<<<<<<<<<<<<
 *                     interval_minutes=int(self.interval / 60)  # 5, 10, or 15 minutes
 *                 )
*/
        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_minute_activity_level, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1671, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_mstate_global->__pyx_tuple[17], NULL); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1671, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_16);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __pyx_t_15 = __Pyx_PyNumber_Float(__pyx_t_16); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1671, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;

        /* "ws_package/controllers/activity_controller.py":1672
 *                     mouse_percentage=float(minute_activity_level.get('mouse', 0)),
 *                     average_percentage=float(minute_activity_level.get('average', 0)),
 *                     interval_minutes=int(self.interval / 60)  # 5, 10, or 15 minutes             # <<<<<<<<<<<<<<
 *                 )
 * 
*/
        __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1672, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_16);
        __pyx_t_17 = __Pyx_PyLong_TrueDivideObjC(__pyx_t_16, __pyx_mstate_global->__pyx_int_60, 60, 0, 0); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1672, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_17);
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
        __pyx_t_16 = __Pyx_PyNumber_Int(__pyx_t_17); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1672, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_16);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __pyx_t_5 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
          assert(__pyx_t_4);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
          __pyx_t_5 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 4 : 0)] = {__pyx_t_4, NULL};
          __pyx_t_17 = __Pyx_MakeVectorcallBuilderKwds(4); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1668, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_17);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_keyboard_percentage, __pyx_t_3, __pyx_t_17, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 1668, __pyx_L6_error)
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_mouse_percentage, __pyx_t_14, __pyx_t_17, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 1668, __pyx_L6_error)
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_average_percentage, __pyx_t_15, __pyx_t_17, __pyx_callargs+1, 2) < (0)) __PYX_ERR(0, 1668, __pyx_L6_error)
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_interval_minutes, __pyx_t_16, __pyx_t_17, __pyx_callargs+1, 3) < (0)) __PYX_ERR(0, 1668, __pyx_L6_error)
          __pyx_t_1 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_17);
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1668, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (likely(__pyx_t_11 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_8);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_8;
          __Pyx_XGIVEREF(__pyx_t_9);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_9;
          __Pyx_XGIVEREF(__pyx_t_10);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_10;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 3;
          return __pyx_r;
          __pyx_L25_resume_from_await:;
          __pyx_t_8 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_8);
          __pyx_t_9 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_9);
          __pyx_t_10 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_10);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1668, __pyx_L6_error)
        } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_DECREF(__pyx_r); __pyx_r = 0;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 1668, __pyx_L6_error)
        }

        /* "ws_package/controllers/activity_controller.py":1643
 * 
 *         while not stop_event.is_set():
 *             try:             # <<<<<<<<<<<<<<
 *                 # Wait for 1 minute
 *                 await precise_sleep(60, stop_event)
*/
      }
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L13_try_end;
      __pyx_L6_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":1679
 *                 #           f"Average: {minute_activity_level.get('average')}%")  # DISABLED to reduce logging overhead - keyboard/mouse events
 * 
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 logger.exception("Error in minute activity timer: %s", e)
 *                 # Continue running even if there's an error
*/
      __pyx_t_18 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
      if (__pyx_t_18) {
        __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_minute_activity_timer", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_17) < 0) __PYX_ERR(0, 1679, __pyx_L8_except_error)
        __Pyx_XGOTREF(__pyx_t_1);
        __Pyx_XGOTREF(__pyx_t_2);
        __Pyx_XGOTREF(__pyx_t_17);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        __pyx_cur_scope->__pyx_v_e = __pyx_t_2;
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":1680
 * 
 *             except Exception as e:
 *                 logger.exception("Error in minute activity timer: %s", e)             # <<<<<<<<<<<<<<
 *                 # Continue running even if there's an error
 *                 continue
*/
          __pyx_t_15 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1680, __pyx_L31_error)
          __Pyx_GOTREF(__pyx_t_14);
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_exception); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1680, __pyx_L31_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __pyx_t_5 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_3))) {
            __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_3);
            assert(__pyx_t_15);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_15);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
            __pyx_t_5 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Error_in_minute_activity_timer_s, __pyx_cur_scope->__pyx_v_e};
            __pyx_t_16 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1680, __pyx_L31_error)
            __Pyx_GOTREF(__pyx_t_16);
          }
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;

          /* "ws_package/controllers/activity_controller.py":1682
 *                 logger.exception("Error in minute activity timer: %s", e)
 *                 # Continue running even if there's an error
 *                 continue             # <<<<<<<<<<<<<<
 * 
 *         logger.info("Minute activity timer stopped")
*/
          goto __pyx_L28_continue;
        }

        /* "ws_package/controllers/activity_controller.py":1679
 *                 #           f"Average: {minute_activity_level.get('average')}%")  # DISABLED to reduce logging overhead - keyboard/mouse events
 * 
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 logger.exception("Error in minute activity timer: %s", e)
 *                 # Continue running even if there's an error
*/
        /*finally:*/ {
          __pyx_L31_error:;
          /*exception exit:*/{
            __Pyx_PyThreadState_assign
            __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0;
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
             __Pyx_ExceptionSwap(&__pyx_t_24, &__pyx_t_25, &__pyx_t_26);
            if ( unlikely(__Pyx_GetException(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23) < 0)) __Pyx_ErrFetch(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
            __Pyx_XGOTREF(__pyx_t_21);
            __Pyx_XGOTREF(__pyx_t_22);
            __Pyx_XGOTREF(__pyx_t_23);
            __Pyx_XGOTREF(__pyx_t_24);
            __Pyx_XGOTREF(__pyx_t_25);
            __Pyx_XGOTREF(__pyx_t_26);
            __pyx_t_18 = __pyx_lineno; __pyx_t_19 = __pyx_clineno; __pyx_t_20 = __pyx_filename;
            {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
            }
            __Pyx_XGIVEREF(__pyx_t_24);
            __Pyx_XGIVEREF(__pyx_t_25);
            __Pyx_XGIVEREF(__pyx_t_26);
            __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_25, __pyx_t_26);
            __Pyx_XGIVEREF(__pyx_t_21);
            __Pyx_XGIVEREF(__pyx_t_22);
            __Pyx_XGIVEREF(__pyx_t_23);
            __Pyx_ErrRestore(__pyx_t_21, __pyx_t_22, __pyx_t_23);
            __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0;
            __pyx_lineno = __pyx_t_18; __pyx_clineno = __pyx_t_19; __pyx_filename = __pyx_t_20;
            goto __pyx_L8_except_error;
          }
          __pyx_L28_continue: {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
            goto __pyx_L26_except_continue;
          }
        }
        __pyx_L26_except_continue:;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
        goto __pyx_L12_try_continue;
      }
      goto __pyx_L8_except_error;

      /* "ws_package/controllers/activity_controller.py":1643
 * 
 *         while not stop_event.is_set():
 *             try:             # <<<<<<<<<<<<<<
 *                 # Wait for 1 minute
 *                 await precise_sleep(60, stop_event)
*/
      __pyx_L8_except_error:;
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      goto __pyx_L1_error;
      __pyx_L11_try_break:;
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      goto __pyx_L5_break;
      __pyx_L12_try_continue:;
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_ExceptionReset(__pyx_t_8, __pyx_t_9, __pyx_t_10);
      goto __pyx_L4_continue;
      __pyx_L13_try_end:;
    }
    __pyx_L4_continue:;
  }
  __pyx_L5_break:;

  /* "ws_package/controllers/activity_controller.py":1684
 *                 continue
 * 
 *         logger.info("Minute activity timer stopped")             # <<<<<<<<<<<<<<
 * 
 *     async def __start_device_activity(self, user_entity:UserEntity, stop_event):
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1684, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_16);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_16))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_16);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_16);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_16, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Minute_activity_timer_stopped};
    __pyx_t_17 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_16, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
    if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 1684, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_17);
  }
  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":1638
 *         return any(browser.lower() in cleaned_name_lower for browser in browsers)
 * 
 *     async def __start_minute_activity_timer(self, stop_event):             # <<<<<<<<<<<<<<
 *         """Start minute-by-minute activity rolling average timer"""
 *         logger.info("Starting minute-by-minute activity rolling average timer")
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("__start_minute_activity_timer", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_102generator20(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":1686
 *         logger.info("Minute activity timer stopped")
 * 
 *     async def __start_device_activity(self, user_entity:UserEntity, stop_event):             # <<<<<<<<<<<<<<
 * 
 *         # Update start_date to actual timer start time (when user clicks Start)
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_101__start_device_activity(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_101__start_device_activity = {"__start_device_activity", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_101__start_device_activity, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_101__start_device_activity(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_user_entity = 0;
  PyObject *__pyx_v_stop_event = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__start_device_activity (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_user_entity,&__pyx_mstate_global->__pyx_n_u_stop_event,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 1686, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 1686, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1686, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1686, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "__start_device_activity", 0) < (0)) __PYX_ERR(0, 1686, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 3; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("__start_device_activity", 1, 3, 3, i); __PYX_ERR(0, 1686, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 3)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1686, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 1686, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 1686, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_user_entity = values[1];
    __pyx_v_stop_event = values[2];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("__start_device_activity", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 1686, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_100__start_device_activity(__pyx_self, __pyx_v_self, __pyx_v_user_entity, __pyx_v_stop_event);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_100__start_device_activity(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity, PyObject *__pyx_v_stop_event) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *__pyx_cur_scope;
  PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_4generator53 = 0;
  PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_9generator54 = 0;
  PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_14generator55 = 0;
  PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_17generator56 = 0;
  PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_20generator57 = 0;
  PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_23generator58 = 0;
  PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_26generator59 = 0;
  PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_29generator60 = 0;
  PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_32generator61 = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__start_device_activity", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1686, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_user_entity = __pyx_v_user_entity;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_user_entity);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_user_entity);
  __pyx_cur_scope->__pyx_v_stop_event = __pyx_v_stop_event;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_stop_event);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_stop_event);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_102generator20, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[23]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_start_device_activity_2, __pyx_mstate_global->__pyx_n_u_ActivityController___start_devic, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 1686, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XDECREF(__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_4generator53);
  __Pyx_XDECREF(__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_9generator54);
  __Pyx_XDECREF(__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_14generator55);
  __Pyx_XDECREF(__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_17generator56);
  __Pyx_XDECREF(__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_20generator57);
  __Pyx_XDECREF(__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_23generator58);
  __Pyx_XDECREF(__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_26generator59);
  __Pyx_XDECREF(__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_29generator60);
  __Pyx_XDECREF(__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_32generator61);
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":1727
 *             try:
 *                 logger.info("Starting time monitor (%s)...", platform.system())
 *                 def _on_time_error(error_type=None):             # <<<<<<<<<<<<<<
 *                     if not self._timezone_checks_enabled():
 *                         logger.info(
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_1_on_time_error(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_1_on_time_error = {"_on_time_error", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_1_on_time_error, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_1_on_time_error(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_error_type = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[1] = {0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_on_time_error (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_error_type,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 1727, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1727, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_on_time_error", 0) < (0)) __PYX_ERR(0, 1727, __pyx_L3_error)
      if (!values[0]) values[0] = __Pyx_NewRef(((PyObject *)Py_None));
    } else {
      switch (__pyx_nargs) {
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1727, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      if (!values[0]) values[0] = __Pyx_NewRef(((PyObject *)Py_None));
    }
    __pyx_v_error_type = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_on_time_error", 0, 0, 1, __pyx_nargs); __PYX_ERR(0, 1727, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity._on_time_error", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity__on_time_error(__pyx_self, __pyx_v_error_type);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity__on_time_error(PyObject *__pyx_self, PyObject *__pyx_v_error_type) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *__pyx_cur_scope;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *__pyx_outer_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  size_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_on_time_error", 0);
  __pyx_outer_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "ws_package/controllers/activity_controller.py":1728
 *                 logger.info("Starting time monitor (%s)...", platform.system())
 *                 def _on_time_error(error_type=None):
 *                     if not self._timezone_checks_enabled():             # <<<<<<<<<<<<<<
 *                         logger.info(
 *                             "Ignoring time-monitor event because timezone_preference=1 (checks off)"
*/
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1728, __pyx_L1_error) }
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_3 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_timezone_checks_enabled, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1728, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1728, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = (!__pyx_t_4);
  if (__pyx_t_5) {

    /* "ws_package/controllers/activity_controller.py":1729
 *                 def _on_time_error(error_type=None):
 *                     if not self._timezone_checks_enabled():
 *                         logger.info(             # <<<<<<<<<<<<<<
 *                             "Ignoring time-monitor event because timezone_preference=1 (checks off)"
 *                         )
*/
    __pyx_t_2 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1729, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1729, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_3 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_7);
      assert(__pyx_t_2);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
      __pyx_t_3 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Ignoring_time_monitor_event_beca};
      __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1729, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "ws_package/controllers/activity_controller.py":1732
 *                             "Ignoring time-monitor event because timezone_preference=1 (checks off)"
 *                         )
 *                         return             # <<<<<<<<<<<<<<
 *                     # Only true timezone changes block tracking; clock drift is informational.
 *                     self._time_error_type = error_type or "datetime_error"
*/
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":1728
 *                 logger.info("Starting time monitor (%s)...", platform.system())
 *                 def _on_time_error(error_type=None):
 *                     if not self._timezone_checks_enabled():             # <<<<<<<<<<<<<<
 *                         logger.info(
 *                             "Ignoring time-monitor event because timezone_preference=1 (checks off)"
*/
  }

  /* "ws_package/controllers/activity_controller.py":1734
 *                         return
 *                     # Only true timezone changes block tracking; clock drift is informational.
 *                     self._time_error_type = error_type or "datetime_error"             # <<<<<<<<<<<<<<
 *                     if self._time_error_type == "timezone_error":
 *                         self._timezone_mismatch = True
*/
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_error_type); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1734, __pyx_L1_error)
  if (!__pyx_t_5) {
  } else {
    __Pyx_INCREF(__pyx_v_error_type);
    __pyx_t_1 = __pyx_v_error_type;
    goto __pyx_L4_bool_binop_done;
  }
  __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_datetime_error);
  __pyx_t_1 = __pyx_mstate_global->__pyx_n_u_datetime_error;
  __pyx_L4_bool_binop_done:;
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1734, __pyx_L1_error) }
  if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_time_error_type, __pyx_t_1) < (0)) __PYX_ERR(0, 1734, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":1735
 *                     # Only true timezone changes block tracking; clock drift is informational.
 *                     self._time_error_type = error_type or "datetime_error"
 *                     if self._time_error_type == "timezone_error":             # <<<<<<<<<<<<<<
 *                         self._timezone_mismatch = True
 *                         logger.error(
*/
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1735, __pyx_L1_error) }
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_time_error_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1735, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_timezone_error, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1735, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "ws_package/controllers/activity_controller.py":1736
 *                     self._time_error_type = error_type or "datetime_error"
 *                     if self._time_error_type == "timezone_error":
 *                         self._timezone_mismatch = True             # <<<<<<<<<<<<<<
 *                         logger.error(
 *                             "Timezone change detected by time monitor  tracking will stop"
*/
    if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1736, __pyx_L1_error) }
    if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_timezone_mismatch, Py_True) < (0)) __PYX_ERR(0, 1736, __pyx_L1_error)

    /* "ws_package/controllers/activity_controller.py":1737
 *                     if self._time_error_type == "timezone_error":
 *                         self._timezone_mismatch = True
 *                         logger.error(             # <<<<<<<<<<<<<<
 *                             "Timezone change detected by time monitor  tracking will stop"
 *                         )
*/
    __pyx_t_7 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1737, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1737, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_3 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
      assert(__pyx_t_7);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
      __pyx_t_3 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Timezone_change_detected_by_time};
      __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1737, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "ws_package/controllers/activity_controller.py":1735
 *                     # Only true timezone changes block tracking; clock drift is informational.
 *                     self._time_error_type = error_type or "datetime_error"
 *                     if self._time_error_type == "timezone_error":             # <<<<<<<<<<<<<<
 *                         self._timezone_mismatch = True
 *                         logger.error(
*/
    goto __pyx_L6;
  }

  /* "ws_package/controllers/activity_controller.py":1741
 *                         )
 *                     else:
 *                         logger.warning(             # <<<<<<<<<<<<<<
 *                             "System clock drift detected by time monitor  "
 *                             "not treating as timezone mismatch"
*/
  /*else*/ {
    __pyx_t_6 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1741, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1741, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_3 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
      assert(__pyx_t_6);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
      __pyx_t_3 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_System_clock_drift_detected_by_t};
      __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1741, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L6:;

  /* "ws_package/controllers/activity_controller.py":1727
 *             try:
 *                 logger.info("Starting time monitor (%s)...", platform.system())
 *                 def _on_time_error(error_type=None):             # <<<<<<<<<<<<<<
 *                     if not self._timezone_checks_enabled():
 *                         logger.info(
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity._on_time_error", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_4generator53(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":1810
 *         # No complex time monitoring needed - using S3 error detection
 * 
 *         async def monitor_active_apps():             # <<<<<<<<<<<<<<
 *             nonlocal last_app_monitor_time
 *             logger.info(
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_3monitor_active_apps(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_3monitor_active_apps = {"monitor_active_apps", (PyCFunction)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_3monitor_active_apps, METH_NOARGS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_3monitor_active_apps(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("monitor_active_apps (wrapper)", 0);
  __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_2monitor_active_apps(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_2monitor_active_apps(PyObject *__pyx_self) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("monitor_active_apps", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1810, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_4generator53, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[24]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_monitor_active_apps, __pyx_mstate_global->__pyx_n_u_ActivityController___start_devic_2, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 1810, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity.monitor_active_apps", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_4generator53(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  size_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  __Pyx_PySendResult __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  Py_ssize_t __pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  int __pyx_t_17;
  int __pyx_t_18;
  char const *__pyx_t_19;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("monitor_active_apps", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L6_resume_from_await;
    case 2: goto __pyx_L16_resume_from_await;
    case 3: goto __pyx_L31_resume_from_await;
    case 4: goto __pyx_L50_resume_from_await;
    case 5: goto __pyx_L62_resume_from_await;
    case 6: goto __pyx_L69_resume_from_await;
    case 7: goto __pyx_L70_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 1810, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":1812
 *         async def monitor_active_apps():
 *             nonlocal last_app_monitor_time
 *             logger.info(             # <<<<<<<<<<<<<<
 *                 "[AppMonitor] monitor_active_apps started  OS: %s, appandurlstatus: %s, interval: %ss",
 *                 self.get_os_type(), self.appandurlstatus, self.app_monitor_interval_seconds,
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1812, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1812, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "ws_package/controllers/activity_controller.py":1814
 *             logger.info(
 *                 "[AppMonitor] monitor_active_apps started  OS: %s, appandurlstatus: %s, interval: %ss",
 *                 self.get_os_type(), self.appandurlstatus, self.app_monitor_interval_seconds,             # <<<<<<<<<<<<<<
 *             )
 *             while True:
*/
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1814, __pyx_L1_error) }
  __pyx_t_5 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_5);
  __pyx_t_6 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
    __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1814, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  }
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1814, __pyx_L1_error) }
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1814, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1814, __pyx_L1_error) }
  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_app_monitor_interval_seconds); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1814, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __pyx_t_6 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_6 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[5] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_AppMonitor_monitor_active_apps, __pyx_t_3, __pyx_t_5, __pyx_t_7};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_6, (5-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1812, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":1816
 *                 self.get_os_type(), self.appandurlstatus, self.app_monitor_interval_seconds,
 *             )
 *             while True:             # <<<<<<<<<<<<<<
 *                 # Always sleep first to ensure proper interval spacing
 *                 await asyncio.sleep(self.app_monitor_interval_seconds)
*/
  while (1) {

    /* "ws_package/controllers/activity_controller.py":1818
 *             while True:
 *                 # Always sleep first to ensure proper interval spacing
 *                 await asyncio.sleep(self.app_monitor_interval_seconds)             # <<<<<<<<<<<<<<
 * 
 *                 # Skip monitoring if tracking is stopped OR app/URL tracking is disabled.
*/
    __pyx_t_4 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1818, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1818, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1818, __pyx_L1_error) }
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_app_monitor_interval_seconds); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1818, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_6 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
      assert(__pyx_t_4);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
      __pyx_t_6 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_7};
      __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1818, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __pyx_t_8 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (likely(__pyx_t_8 == PYGEN_NEXT)) {
      __Pyx_GOTREF(__pyx_r);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 1;
      return __pyx_r;
      __pyx_L6_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1818, __pyx_L1_error)
    } else if (likely(__pyx_t_8 == PYGEN_RETURN)) {
      __Pyx_GOTREF(__pyx_r);
      __Pyx_DECREF(__pyx_r); __pyx_r = 0;
    } else {
      __Pyx_XGOTREF(__pyx_r);
      __PYX_ERR(0, 1818, __pyx_L1_error)
    }

    /* "ws_package/controllers/activity_controller.py":1822
 *                 # Skip monitoring if tracking is stopped OR app/URL tracking is disabled.
 *                 # Guard against None (can occur if update_interval() hasn't run yet).
 *                 if not self.status or not self.appandurlstatus or self.appandurlstatus <= 0:             # <<<<<<<<<<<<<<
 *                     # Log at INFO on first skip, then DEBUG to avoid repeated noise.
 *                     # appandurlstatus=0 means org admin disabled app/URL tracking.
*/
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1822, __pyx_L1_error) }
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1822, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1822, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_11 = (!__pyx_t_10);
    if (!__pyx_t_11) {
    } else {
      __pyx_t_9 = __pyx_t_11;
      goto __pyx_L8_bool_binop_done;
    }
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1822, __pyx_L1_error) }
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1822, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 1822, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_10 = (!__pyx_t_11);
    if (!__pyx_t_10) {
    } else {
      __pyx_t_9 = __pyx_t_10;
      goto __pyx_L8_bool_binop_done;
    }
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1822, __pyx_L1_error) }
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1822, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = PyObject_RichCompare(__pyx_t_1, __pyx_mstate_global->__pyx_int_0, Py_LE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1822, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1822, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_9 = __pyx_t_10;
    __pyx_L8_bool_binop_done:;
    if (__pyx_t_9) {

      /* "ws_package/controllers/activity_controller.py":1825
 *                     # Log at INFO on first skip, then DEBUG to avoid repeated noise.
 *                     # appandurlstatus=0 means org admin disabled app/URL tracking.
 *                     logger.info(             # <<<<<<<<<<<<<<
 *                         "[AppMonitor] Skipping cycle  status=%s, appandurlstatus=%s "
 *                         "(0 = tracking disabled by org; check org settings in dashboard)",
*/
      __pyx_t_1 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1825, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1825, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "ws_package/controllers/activity_controller.py":1828
 *                         "[AppMonitor] Skipping cycle  status=%s, appandurlstatus=%s "
 *                         "(0 = tracking disabled by org; check org settings in dashboard)",
 *                         self.status, self.appandurlstatus,             # <<<<<<<<<<<<<<
 *                     )
 *                     # Subsequent skips at debug level until the value changes
*/
      if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1828, __pyx_L1_error) }
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1828, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1828, __pyx_L1_error) }
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1828, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
        assert(__pyx_t_1);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
        __pyx_t_6 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[4] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_AppMonitor_Skipping_cycle_statu, __pyx_t_7, __pyx_t_3};
        __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_6, (4-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1825, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "ws_package/controllers/activity_controller.py":1831
 *                     )
 *                     # Subsequent skips at debug level until the value changes
 *                     while (not self.status or not self.appandurlstatus or self.appandurlstatus <= 0):             # <<<<<<<<<<<<<<
 *                         logger.debug(
 *                             "[AppMonitor] Still disabled  status=%s, appandurlstatus=%s",
*/
      while (1) {
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1831, __pyx_L1_error) }
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1831, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1831, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_11 = (!__pyx_t_10);
        if (!__pyx_t_11) {
        } else {
          __pyx_t_9 = __pyx_t_11;
          goto __pyx_L13_bool_binop_done;
        }
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1831, __pyx_L1_error) }
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1831, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 1831, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_10 = (!__pyx_t_11);
        if (!__pyx_t_10) {
        } else {
          __pyx_t_9 = __pyx_t_10;
          goto __pyx_L13_bool_binop_done;
        }
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1831, __pyx_L1_error) }
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1831, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_4 = PyObject_RichCompare(__pyx_t_5, __pyx_mstate_global->__pyx_int_0, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1831, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1831, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_9 = __pyx_t_10;
        __pyx_L13_bool_binop_done:;
        if (!__pyx_t_9) break;

        /* "ws_package/controllers/activity_controller.py":1832
 *                     # Subsequent skips at debug level until the value changes
 *                     while (not self.status or not self.appandurlstatus or self.appandurlstatus <= 0):
 *                         logger.debug(             # <<<<<<<<<<<<<<
 *                             "[AppMonitor] Still disabled  status=%s, appandurlstatus=%s",
 *                             self.status, self.appandurlstatus,
*/
        __pyx_t_5 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1832, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1832, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "ws_package/controllers/activity_controller.py":1834
 *                         logger.debug(
 *                             "[AppMonitor] Still disabled  status=%s, appandurlstatus=%s",
 *                             self.status, self.appandurlstatus,             # <<<<<<<<<<<<<<
 *                         )
 *                         await asyncio.sleep(self.app_monitor_interval_seconds)
*/
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1834, __pyx_L1_error) }
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1834, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1834, __pyx_L1_error) }
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1834, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_6 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
          assert(__pyx_t_5);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
          __pyx_t_6 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[4] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_AppMonitor_Still_disabled_statu, __pyx_t_3, __pyx_t_1};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_6, (4-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1832, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":1836
 *                             self.status, self.appandurlstatus,
 *                         )
 *                         await asyncio.sleep(self.app_monitor_interval_seconds)             # <<<<<<<<<<<<<<
 *                     logger.info("[AppMonitor] Re-enabled  status=%s, appandurlstatus=%s", self.status, self.appandurlstatus)
 *                     continue
*/
        __pyx_t_7 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1836, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1836, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1836, __pyx_L1_error) }
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_app_monitor_interval_seconds); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1836, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_6 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_3);
          assert(__pyx_t_7);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
          __pyx_t_6 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_t_1};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1836, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __pyx_t_8 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (likely(__pyx_t_8 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 2;
          return __pyx_r;
          __pyx_L16_resume_from_await:;
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1836, __pyx_L1_error)
        } else if (likely(__pyx_t_8 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_DECREF(__pyx_r); __pyx_r = 0;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 1836, __pyx_L1_error)
        }
      }

      /* "ws_package/controllers/activity_controller.py":1837
 *                         )
 *                         await asyncio.sleep(self.app_monitor_interval_seconds)
 *                     logger.info("[AppMonitor] Re-enabled  status=%s, appandurlstatus=%s", self.status, self.appandurlstatus)             # <<<<<<<<<<<<<<
 *                     continue
 * 
*/
      __pyx_t_3 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1837, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1837, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1837, __pyx_L1_error) }
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1837, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1837, __pyx_L1_error) }
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1837, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_3);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_6 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[4] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_AppMonitor_Re_enabled_status_s, __pyx_t_1, __pyx_t_5};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_6, (4-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1837, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":1838
 *                         await asyncio.sleep(self.app_monitor_interval_seconds)
 *                     logger.info("[AppMonitor] Re-enabled  status=%s, appandurlstatus=%s", self.status, self.appandurlstatus)
 *                     continue             # <<<<<<<<<<<<<<
 * 
 *                 try:
*/
      goto __pyx_L4_continue;

      /* "ws_package/controllers/activity_controller.py":1822
 *                 # Skip monitoring if tracking is stopped OR app/URL tracking is disabled.
 *                 # Guard against None (can occur if update_interval() hasn't run yet).
 *                 if not self.status or not self.appandurlstatus or self.appandurlstatus <= 0:             # <<<<<<<<<<<<<<
 *                     # Log at INFO on first skip, then DEBUG to avoid repeated noise.
 *                     # appandurlstatus=0 means org admin disabled app/URL tracking.
*/
    }

    /* "ws_package/controllers/activity_controller.py":1840
 *                     continue
 * 
 *                 try:             # <<<<<<<<<<<<<<
 *                         active_app_url = app_listener.get_active_windows()
 *                         logger.debug(
*/
    {
      __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_14);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":1841
 * 
 *                 try:
 *                         active_app_url = app_listener.get_active_windows()             # <<<<<<<<<<<<<<
 *                         logger.debug(
 *                             "[AppMonitor] OS: %s, appandurlstatus: %s, windows: %s",
*/
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_app_listener)) { __Pyx_RaiseClosureNameError("app_listener"); __PYX_ERR(0, 1841, __pyx_L17_error) }
        __pyx_t_7 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_app_listener;
        __Pyx_INCREF(__pyx_t_7);
        __pyx_t_6 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
          __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_active_windows, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1841, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_active_app_url);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_active_app_url, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":1842
 *                 try:
 *                         active_app_url = app_listener.get_active_windows()
 *                         logger.debug(             # <<<<<<<<<<<<<<
 *                             "[AppMonitor] OS: %s, appandurlstatus: %s, windows: %s",
 *                             self.get_os_type(), self.appandurlstatus,
*/
        __pyx_t_7 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1842, __pyx_L17_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1842, __pyx_L17_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":1844
 *                         logger.debug(
 *                             "[AppMonitor] OS: %s, appandurlstatus: %s, windows: %s",
 *                             self.get_os_type(), self.appandurlstatus,             # <<<<<<<<<<<<<<
 *                             len(active_app_url) if active_app_url else 0,
 *                         )
*/
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1844, __pyx_L17_error) }
        __pyx_t_3 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_6 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1844, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1844, __pyx_L17_error) }
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1844, __pyx_L17_error)
        __Pyx_GOTREF(__pyx_t_3);

        /* "ws_package/controllers/activity_controller.py":1845
 *                             "[AppMonitor] OS: %s, appandurlstatus: %s, windows: %s",
 *                             self.get_os_type(), self.appandurlstatus,
 *                             len(active_app_url) if active_app_url else 0,             # <<<<<<<<<<<<<<
 *                         )
 *                         if (self.get_os_type() == "linux") and (self.appandurlstatus == 3 or self.appandurlstatus == 2) and len(active_app_url)>0:
*/
        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_active_app_url); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 1845, __pyx_L17_error)
        if (__pyx_t_9) {
          __pyx_t_15 = PyObject_Length(__pyx_cur_scope->__pyx_v_active_app_url); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1845, __pyx_L17_error)
          __pyx_t_16 = PyLong_FromSsize_t(__pyx_t_15); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1845, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_16);
          __pyx_t_2 = __pyx_t_16;
          __pyx_t_16 = 0;
        } else {
          __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
          __pyx_t_2 = __pyx_mstate_global->__pyx_int_0;
        }
        __pyx_t_6 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_1);
          assert(__pyx_t_7);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
          __pyx_t_6 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[5] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_AppMonitor_OS_s_appandurlstatus, __pyx_t_5, __pyx_t_3, __pyx_t_2};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_6, (5-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1842, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":1847
 *                             len(active_app_url) if active_app_url else 0,
 *                         )
 *                         if (self.get_os_type() == "linux") and (self.appandurlstatus == 3 or self.appandurlstatus == 2) and len(active_app_url)>0:             # <<<<<<<<<<<<<<
 *                             # Apps + URLs mode (2) or full mode (3): resolve URL from browser DB.
 *                             app_name = active_app_url[0]['active_app']
*/
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1847, __pyx_L17_error) }
        __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_6 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
          __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1847, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __pyx_t_10 = (__Pyx_PyUnicode_Equals(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_linux, Py_EQ)); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1847, __pyx_L17_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (__pyx_t_10) {
        } else {
          __pyx_t_9 = __pyx_t_10;
          goto __pyx_L26_bool_binop_done;
        }
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1847, __pyx_L17_error) }
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1847, __pyx_L17_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_10 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_4, __pyx_mstate_global->__pyx_int_3, 3, 0)); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1847, __pyx_L17_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (!__pyx_t_10) {
        } else {
          goto __pyx_L28_next_and;
        }
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1847, __pyx_L17_error) }
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1847, __pyx_L17_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_10 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_4, __pyx_mstate_global->__pyx_int_2, 2, 0)); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1847, __pyx_L17_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (__pyx_t_10) {
        } else {
          __pyx_t_9 = __pyx_t_10;
          goto __pyx_L26_bool_binop_done;
        }
        __pyx_L28_next_and:;
        __pyx_t_15 = PyObject_Length(__pyx_cur_scope->__pyx_v_active_app_url); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1847, __pyx_L17_error)
        __pyx_t_10 = (__pyx_t_15 > 0);
        __pyx_t_9 = __pyx_t_10;
        __pyx_L26_bool_binop_done:;
        if (__pyx_t_9) {

          /* "ws_package/controllers/activity_controller.py":1849
 *                         if (self.get_os_type() == "linux") and (self.appandurlstatus == 3 or self.appandurlstatus == 2) and len(active_app_url)>0:
 *                             # Apps + URLs mode (2) or full mode (3): resolve URL from browser DB.
 *                             app_name = active_app_url[0]['active_app']             # <<<<<<<<<<<<<<
 *                             url = None  # Will be set by URL detection
 * 
*/
          __pyx_t_4 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_active_app_url, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_SharedReference); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1849, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_active_app); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1849, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_app_name);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_app_name, __pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_1);
          __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":1850
 *                             # Apps + URLs mode (2) or full mode (3): resolve URL from browser DB.
 *                             app_name = active_app_url[0]['active_app']
 *                             url = None  # Will be set by URL detection             # <<<<<<<<<<<<<<
 * 
 *                             if self.is_browser(app_name):
*/
          __Pyx_INCREF(Py_None);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_url);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_url, Py_None);
          __Pyx_GIVEREF(Py_None);

          /* "ws_package/controllers/activity_controller.py":1852
 *                             url = None  # Will be set by URL detection
 * 
 *                             if self.is_browser(app_name):             # <<<<<<<<<<<<<<
 *                                 url_result = await get_browser_url_with_fallback(
 *                                     tab_title=app_name,
*/
          if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1852, __pyx_L17_error) }
          __pyx_t_4 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_4);
          __pyx_t_6 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_app_name};
            __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_browser, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1852, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_1);
          }
          __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 1852, __pyx_L17_error)
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (__pyx_t_9) {

            /* "ws_package/controllers/activity_controller.py":1853
 * 
 *                             if self.is_browser(app_name):
 *                                 url_result = await get_browser_url_with_fallback(             # <<<<<<<<<<<<<<
 *                                     tab_title=app_name,
 *                                 )
*/
            __pyx_t_4 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_get_browser_url_with_fallback); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1853, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_2);

            /* "ws_package/controllers/activity_controller.py":1854
 *                             if self.is_browser(app_name):
 *                                 url_result = await get_browser_url_with_fallback(
 *                                     tab_title=app_name,             # <<<<<<<<<<<<<<
 *                                 )
 * 
*/
            __pyx_t_6 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_2))) {
              __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
              assert(__pyx_t_4);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_4);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
              __pyx_t_6 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_4, NULL};
              __pyx_t_3 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1853, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_3);
              if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_tab_title, __pyx_cur_scope->__pyx_v_app_name, __pyx_t_3, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 1853, __pyx_L17_error)
              __pyx_t_1 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_3);
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1853, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_1);
            }
            __pyx_t_8 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (likely(__pyx_t_8 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_12);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_12;
              __Pyx_XGIVEREF(__pyx_t_13);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_13;
              __Pyx_XGIVEREF(__pyx_t_14);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_14;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 3;
              return __pyx_r;
              __pyx_L31_resume_from_await:;
              __pyx_t_12 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_12);
              __pyx_t_13 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_13);
              __pyx_t_14 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_14);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1853, __pyx_L17_error)
              __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
            } else if (likely(__pyx_t_8 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __pyx_t_1 = __pyx_r; __pyx_r = NULL;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 1853, __pyx_L17_error)
            }
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_url_result);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_url_result, __pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_1);
            __pyx_t_1 = 0;

            /* "ws_package/controllers/activity_controller.py":1857
 *                                 )
 * 
 *                                 if url_result and url_result.strip() and url_result != "New Tab":             # <<<<<<<<<<<<<<
 *                                     url = url_result.strip()
 *                                     logger.info("[Linux] URL detected via comprehensive method: %s", url)
*/
            __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_url_result); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1857, __pyx_L17_error)
            if (__pyx_t_10) {
            } else {
              __pyx_t_9 = __pyx_t_10;
              goto __pyx_L33_bool_binop_done;
            }
            __pyx_t_2 = __pyx_cur_scope->__pyx_v_url_result;
            __Pyx_INCREF(__pyx_t_2);
            __pyx_t_6 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
              __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strip, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1857, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_1);
            }
            __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1857, __pyx_L17_error)
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (__pyx_t_10) {
            } else {
              __pyx_t_9 = __pyx_t_10;
              goto __pyx_L33_bool_binop_done;
            }
            __pyx_t_10 = (__Pyx_PyUnicode_Equals(__pyx_cur_scope->__pyx_v_url_result, __pyx_mstate_global->__pyx_kp_u_New_Tab, Py_NE)); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1857, __pyx_L17_error)
            __pyx_t_9 = __pyx_t_10;
            __pyx_L33_bool_binop_done:;
            if (__pyx_t_9) {

              /* "ws_package/controllers/activity_controller.py":1858
 * 
 *                                 if url_result and url_result.strip() and url_result != "New Tab":
 *                                     url = url_result.strip()             # <<<<<<<<<<<<<<
 *                                     logger.info("[Linux] URL detected via comprehensive method: %s", url)
 *                                 else:
*/
              __pyx_t_2 = __pyx_cur_scope->__pyx_v_url_result;
              __Pyx_INCREF(__pyx_t_2);
              __pyx_t_6 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
                __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strip, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1858, __pyx_L17_error)
                __Pyx_GOTREF(__pyx_t_1);
              }
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_url);
              __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_url, __pyx_t_1);
              __Pyx_GIVEREF(__pyx_t_1);
              __pyx_t_1 = 0;

              /* "ws_package/controllers/activity_controller.py":1859
 *                                 if url_result and url_result.strip() and url_result != "New Tab":
 *                                     url = url_result.strip()
 *                                     logger.info("[Linux] URL detected via comprehensive method: %s", url)             # <<<<<<<<<<<<<<
 *                                 else:
 *                                     url = "New Tab"
*/
              __pyx_t_2 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1859, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1859, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __pyx_t_6 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_4))) {
                __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
                assert(__pyx_t_2);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                __Pyx_INCREF(__pyx_t_2);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                __pyx_t_6 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Linux_URL_detected_via_comprehe, __pyx_cur_scope->__pyx_v_url};
                __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1859, __pyx_L17_error)
                __Pyx_GOTREF(__pyx_t_1);
              }
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

              /* "ws_package/controllers/activity_controller.py":1857
 *                                 )
 * 
 *                                 if url_result and url_result.strip() and url_result != "New Tab":             # <<<<<<<<<<<<<<
 *                                     url = url_result.strip()
 *                                     logger.info("[Linux] URL detected via comprehensive method: %s", url)
*/
              goto __pyx_L32;
            }

            /* "ws_package/controllers/activity_controller.py":1861
 *                                     logger.info("[Linux] URL detected via comprehensive method: %s", url)
 *                                 else:
 *                                     url = "New Tab"             # <<<<<<<<<<<<<<
 *                                     logger.info("[Linux] All URL detection methods failed, using 'New Tab'")
 *                             else:
*/
            /*else*/ {
              __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_New_Tab);
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_url);
              __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_url, __pyx_mstate_global->__pyx_kp_u_New_Tab);
              __Pyx_GIVEREF(__pyx_mstate_global->__pyx_kp_u_New_Tab);

              /* "ws_package/controllers/activity_controller.py":1862
 *                                 else:
 *                                     url = "New Tab"
 *                                     logger.info("[Linux] All URL detection methods failed, using 'New Tab'")             # <<<<<<<<<<<<<<
 *                             else:
 *                                 # Not a browser, use app name as URL
*/
              __pyx_t_4 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1862, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1862, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              __pyx_t_6 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_3))) {
                __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
                assert(__pyx_t_4);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
                __Pyx_INCREF(__pyx_t_4);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
                __pyx_t_6 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Linux_All_URL_detection_methods};
                __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1862, __pyx_L17_error)
                __Pyx_GOTREF(__pyx_t_1);
              }
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            }
            __pyx_L32:;

            /* "ws_package/controllers/activity_controller.py":1852
 *                             url = None  # Will be set by URL detection
 * 
 *                             if self.is_browser(app_name):             # <<<<<<<<<<<<<<
 *                                 url_result = await get_browser_url_with_fallback(
 *                                     tab_title=app_name,
*/
            goto __pyx_L30;
          }

          /* "ws_package/controllers/activity_controller.py":1865
 *                             else:
 *                                 # Not a browser, use app name as URL
 *                                 url = app_name             # <<<<<<<<<<<<<<
 * 
 *                             active_app_url = [{
*/
          /*else*/ {
            __Pyx_INCREF(__pyx_cur_scope->__pyx_v_app_name);
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_url);
            __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_url, __pyx_cur_scope->__pyx_v_app_name);
            __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_app_name);
          }
          __pyx_L30:;

          /* "ws_package/controllers/activity_controller.py":1868
 * 
 *                             active_app_url = [{
 *                                 "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),             # <<<<<<<<<<<<<<
 *                                 "module": url,
 *                                 "active_app": app_name,
*/
          __pyx_t_1 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1868, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_4 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_time); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1868, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_strftime); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1868, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_6 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_5))) {
            __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
            assert(__pyx_t_4);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
            __pyx_t_6 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Y_m_d_H_M_S};
            __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1868, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_3);
          }
          __pyx_t_5 = __Pyx_PyObject_Unicode(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1868, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_timestamp, __pyx_t_5) < (0)) __PYX_ERR(0, 1868, __pyx_L17_error)
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":1869
 *                             active_app_url = [{
 *                                 "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),
 *                                 "module": url,             # <<<<<<<<<<<<<<
 *                                 "active_app": app_name,
 *                                 "url": url,
*/
          if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_module, __pyx_cur_scope->__pyx_v_url) < (0)) __PYX_ERR(0, 1868, __pyx_L17_error)

          /* "ws_package/controllers/activity_controller.py":1870
 *                                 "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),
 *                                 "module": url,
 *                                 "active_app": app_name,             # <<<<<<<<<<<<<<
 *                                 "url": url,
 *                             }]
*/
          if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_active_app, __pyx_cur_scope->__pyx_v_app_name) < (0)) __PYX_ERR(0, 1868, __pyx_L17_error)

          /* "ws_package/controllers/activity_controller.py":1871
 *                                 "module": url,
 *                                 "active_app": app_name,
 *                                 "url": url,             # <<<<<<<<<<<<<<
 *                             }]
 * 
*/
          if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_url, __pyx_cur_scope->__pyx_v_url) < (0)) __PYX_ERR(0, 1868, __pyx_L17_error)

          /* "ws_package/controllers/activity_controller.py":1867
 *                                 url = app_name
 * 
 *                             active_app_url = [{             # <<<<<<<<<<<<<<
 *                                 "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),
 *                                 "module": url,
*/
          __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1867, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_1);
          if (__Pyx_PyList_SET_ITEM(__pyx_t_5, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 1867, __pyx_L17_error);
          __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_active_app_url);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_active_app_url, __pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_5);
          __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":1847
 *                             len(active_app_url) if active_app_url else 0,
 *                         )
 *                         if (self.get_os_type() == "linux") and (self.appandurlstatus == 3 or self.appandurlstatus == 2) and len(active_app_url)>0:             # <<<<<<<<<<<<<<
 *                             # Apps + URLs mode (2) or full mode (3): resolve URL from browser DB.
 *                             app_name = active_app_url[0]['active_app']
*/
          goto __pyx_L25;
        }

        /* "ws_package/controllers/activity_controller.py":1874
 *                             }]
 * 
 *                         elif (self.get_os_type() == "linux") and self.appandurlstatus == 1 and len(active_app_url) > 0:             # <<<<<<<<<<<<<<
 *                             # Apps-only mode on Linux: record app name, skip URL resolution.
 *                             app_name = active_app_url[0]['active_app']
*/
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1874, __pyx_L17_error) }
        __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_6 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1874, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __pyx_t_10 = (__Pyx_PyUnicode_Equals(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_linux, Py_EQ)); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1874, __pyx_L17_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (__pyx_t_10) {
        } else {
          __pyx_t_9 = __pyx_t_10;
          goto __pyx_L36_bool_binop_done;
        }
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1874, __pyx_L17_error) }
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1874, __pyx_L17_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_10 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_5, __pyx_mstate_global->__pyx_int_1, 1, 0)); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1874, __pyx_L17_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (__pyx_t_10) {
        } else {
          __pyx_t_9 = __pyx_t_10;
          goto __pyx_L36_bool_binop_done;
        }
        __pyx_t_15 = PyObject_Length(__pyx_cur_scope->__pyx_v_active_app_url); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1874, __pyx_L17_error)
        __pyx_t_10 = (__pyx_t_15 > 0);
        __pyx_t_9 = __pyx_t_10;
        __pyx_L36_bool_binop_done:;
        if (__pyx_t_9) {

          /* "ws_package/controllers/activity_controller.py":1876
 *                         elif (self.get_os_type() == "linux") and self.appandurlstatus == 1 and len(active_app_url) > 0:
 *                             # Apps-only mode on Linux: record app name, skip URL resolution.
 *                             app_name = active_app_url[0]['active_app']             # <<<<<<<<<<<<<<
 *                             active_app_url = [{
 *                                 "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),
*/
          __pyx_t_5 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_active_app_url, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_SharedReference); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1876, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_1 = __Pyx_PyObject_Dict_GetItem(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_active_app); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1876, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_app_name);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_app_name, __pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_1);
          __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":1878
 *                             app_name = active_app_url[0]['active_app']
 *                             active_app_url = [{
 *                                 "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),             # <<<<<<<<<<<<<<
 *                                 "module": app_name,
 *                                 "active_app": app_name,
*/
          __pyx_t_1 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1878, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_3 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_time); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1878, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_strftime); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1878, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_6 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
            assert(__pyx_t_3);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
            __pyx_t_6 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Y_m_d_H_M_S};
            __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1878, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_5);
          }
          __pyx_t_2 = __Pyx_PyObject_Unicode(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1878, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_timestamp, __pyx_t_2) < (0)) __PYX_ERR(0, 1878, __pyx_L17_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":1879
 *                             active_app_url = [{
 *                                 "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),
 *                                 "module": app_name,             # <<<<<<<<<<<<<<
 *                                 "active_app": app_name,
 *                                 "url": app_name,
*/
          if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_module, __pyx_cur_scope->__pyx_v_app_name) < (0)) __PYX_ERR(0, 1878, __pyx_L17_error)

          /* "ws_package/controllers/activity_controller.py":1880
 *                                 "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),
 *                                 "module": app_name,
 *                                 "active_app": app_name,             # <<<<<<<<<<<<<<
 *                                 "url": app_name,
 *                             }]
*/
          if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_active_app, __pyx_cur_scope->__pyx_v_app_name) < (0)) __PYX_ERR(0, 1878, __pyx_L17_error)

          /* "ws_package/controllers/activity_controller.py":1881
 *                                 "module": app_name,
 *                                 "active_app": app_name,
 *                                 "url": app_name,             # <<<<<<<<<<<<<<
 *                             }]
 *                         elif (self.get_os_type() == "windows") and (self.appandurlstatus == 3 or self.appandurlstatus == 2) and len(active_app_url)>0:
*/
          if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_url, __pyx_cur_scope->__pyx_v_app_name) < (0)) __PYX_ERR(0, 1878, __pyx_L17_error)

          /* "ws_package/controllers/activity_controller.py":1877
 *                             # Apps-only mode on Linux: record app name, skip URL resolution.
 *                             app_name = active_app_url[0]['active_app']
 *                             active_app_url = [{             # <<<<<<<<<<<<<<
 *                                 "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),
 *                                 "module": app_name,
*/
          __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1877, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_1);
          if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 1877, __pyx_L17_error);
          __pyx_t_1 = 0;
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_active_app_url);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_active_app_url, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":1874
 *                             }]
 * 
 *                         elif (self.get_os_type() == "linux") and self.appandurlstatus == 1 and len(active_app_url) > 0:             # <<<<<<<<<<<<<<
 *                             # Apps-only mode on Linux: record app name, skip URL resolution.
 *                             app_name = active_app_url[0]['active_app']
*/
          goto __pyx_L25;
        }

        /* "ws_package/controllers/activity_controller.py":1883
 *                                 "url": app_name,
 *                             }]
 *                         elif (self.get_os_type() == "windows") and (self.appandurlstatus == 3 or self.appandurlstatus == 2) and len(active_app_url)>0:             # <<<<<<<<<<<<<<
 *                             # Apps + URLs mode (2) or full mode (3): resolve URL from browser DB.
 *                             row = active_app_url[0]
*/
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1883, __pyx_L17_error) }
        __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_6 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
          __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1883, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_2);
        }
        __pyx_t_10 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_windows, Py_EQ)); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1883, __pyx_L17_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (__pyx_t_10) {
        } else {
          __pyx_t_9 = __pyx_t_10;
          goto __pyx_L39_bool_binop_done;
        }
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1883, __pyx_L17_error) }
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1883, __pyx_L17_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_10 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_2, __pyx_mstate_global->__pyx_int_3, 3, 0)); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1883, __pyx_L17_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (!__pyx_t_10) {
        } else {
          goto __pyx_L41_next_and;
        }
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1883, __pyx_L17_error) }
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1883, __pyx_L17_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_10 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_2, __pyx_mstate_global->__pyx_int_2, 2, 0)); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1883, __pyx_L17_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (__pyx_t_10) {
        } else {
          __pyx_t_9 = __pyx_t_10;
          goto __pyx_L39_bool_binop_done;
        }
        __pyx_L41_next_and:;
        __pyx_t_15 = PyObject_Length(__pyx_cur_scope->__pyx_v_active_app_url); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1883, __pyx_L17_error)
        __pyx_t_10 = (__pyx_t_15 > 0);
        __pyx_t_9 = __pyx_t_10;
        __pyx_L39_bool_binop_done:;
        if (__pyx_t_9) {

          /* "ws_package/controllers/activity_controller.py":1885
 *                         elif (self.get_os_type() == "windows") and (self.appandurlstatus == 3 or self.appandurlstatus == 2) and len(active_app_url)>0:
 *                             # Apps + URLs mode (2) or full mode (3): resolve URL from browser DB.
 *                             row = active_app_url[0]             # <<<<<<<<<<<<<<
 *                             i2t = row.get('url') or row.get('active_app', '')
 *                             display_name = row.get('app_display_name') or row.get('active_app', '')
*/
          __pyx_t_2 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_active_app_url, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_SharedReference); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1885, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_row);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_row, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":1886
 *                             # Apps + URLs mode (2) or full mode (3): resolve URL from browser DB.
 *                             row = active_app_url[0]
 *                             i2t = row.get('url') or row.get('active_app', '')             # <<<<<<<<<<<<<<
 *                             display_name = row.get('app_display_name') or row.get('active_app', '')
 * 
*/
          __pyx_t_5 = __pyx_cur_scope->__pyx_v_row;
          __Pyx_INCREF(__pyx_t_5);
          __pyx_t_6 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_n_u_url};
            __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1886, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_1);
          }
          __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 1886, __pyx_L17_error)
          if (!__pyx_t_9) {
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          } else {
            __Pyx_INCREF(__pyx_t_1);
            __pyx_t_2 = __pyx_t_1;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            goto __pyx_L43_bool_binop_done;
          }
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_row, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1886, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_mstate_global->__pyx_tuple[18], NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1886, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_INCREF(__pyx_t_5);
          __pyx_t_2 = __pyx_t_5;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_L43_bool_binop_done:;
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_i2t);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_i2t, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":1887
 *                             row = active_app_url[0]
 *                             i2t = row.get('url') or row.get('active_app', '')
 *                             display_name = row.get('app_display_name') or row.get('active_app', '')             # <<<<<<<<<<<<<<
 * 
 *                             # get_active_windows_ms() already reads Chrome History  reuse URL when present
*/
          __pyx_t_1 = __pyx_cur_scope->__pyx_v_row;
          __Pyx_INCREF(__pyx_t_1);
          __pyx_t_6 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_n_u_app_display_name};
            __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1887, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_5);
          }
          __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 1887, __pyx_L17_error)
          if (!__pyx_t_9) {
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          } else {
            __Pyx_INCREF(__pyx_t_5);
            __pyx_t_2 = __pyx_t_5;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            goto __pyx_L45_bool_binop_done;
          }
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_row, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1887, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_mstate_global->__pyx_tuple[18], NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1887, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_INCREF(__pyx_t_1);
          __pyx_t_2 = __pyx_t_1;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_L45_bool_binop_done:;
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_display_name);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_display_name, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":1890
 * 
 *                             # get_active_windows_ms() already reads Chrome History  reuse URL when present
 *                             if i2t.startswith(('http://', 'https://')):             # <<<<<<<<<<<<<<
 *                                 pass
 *                             elif self.is_browser(display_name) or self.is_browser(i2t):
*/
          __pyx_t_1 = __pyx_cur_scope->__pyx_v_i2t;
          __Pyx_INCREF(__pyx_t_1);
          __pyx_t_6 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_tuple[19]};
            __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_startswith, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1890, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_2);
          }
          __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 1890, __pyx_L17_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (__pyx_t_9) {
            goto __pyx_L47;
          }

          /* "ws_package/controllers/activity_controller.py":1892
 *                             if i2t.startswith(('http://', 'https://')):
 *                                 pass
 *                             elif self.is_browser(display_name) or self.is_browser(i2t):             # <<<<<<<<<<<<<<
 *                                 url_result = await get_browser_url_with_fallback(
 *                                     tab_title=display_name if self.is_browser(display_name) else i2t,
*/
          if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1892, __pyx_L17_error) }
          __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_1);
          __pyx_t_6 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_cur_scope->__pyx_v_display_name};
            __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_browser, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1892, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_2);
          }
          __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1892, __pyx_L17_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (!__pyx_t_10) {
          } else {
            __pyx_t_9 = __pyx_t_10;
            goto __pyx_L48_bool_binop_done;
          }
          if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1892, __pyx_L17_error) }
          __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_1);
          __pyx_t_6 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_cur_scope->__pyx_v_i2t};
            __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_browser, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1892, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_2);
          }
          __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1892, __pyx_L17_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_9 = __pyx_t_10;
          __pyx_L48_bool_binop_done:;
          if (__pyx_t_9) {

            /* "ws_package/controllers/activity_controller.py":1893
 *                                 pass
 *                             elif self.is_browser(display_name) or self.is_browser(i2t):
 *                                 url_result = await get_browser_url_with_fallback(             # <<<<<<<<<<<<<<
 *                                     tab_title=display_name if self.is_browser(display_name) else i2t,
 *                                 )
*/
            __pyx_t_1 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_get_browser_url_with_fallback); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1893, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_5);

            /* "ws_package/controllers/activity_controller.py":1894
 *                             elif self.is_browser(display_name) or self.is_browser(i2t):
 *                                 url_result = await get_browser_url_with_fallback(
 *                                     tab_title=display_name if self.is_browser(display_name) else i2t,             # <<<<<<<<<<<<<<
 *                                 )
 *                                 if url_result and url_result.strip() and url_result != "New Tab":
*/
            if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1894, __pyx_L17_error) }
            __pyx_t_7 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self;
            __Pyx_INCREF(__pyx_t_7);
            __pyx_t_6 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_cur_scope->__pyx_v_display_name};
              __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_browser, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1894, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_4);
            }
            __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 1894, __pyx_L17_error)
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (__pyx_t_9) {
              __Pyx_INCREF(__pyx_cur_scope->__pyx_v_display_name);
              __pyx_t_3 = __pyx_cur_scope->__pyx_v_display_name;
            } else {
              __Pyx_INCREF(__pyx_cur_scope->__pyx_v_i2t);
              __pyx_t_3 = __pyx_cur_scope->__pyx_v_i2t;
            }
            __pyx_t_6 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_5))) {
              __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
              assert(__pyx_t_1);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
              __Pyx_INCREF(__pyx_t_1);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
              __pyx_t_6 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_1, NULL};
              __pyx_t_4 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1893, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_4);
              if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_tab_title, __pyx_t_3, __pyx_t_4, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 1893, __pyx_L17_error)
              __pyx_t_2 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_4);
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1893, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_2);
            }
            __pyx_t_8 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_2, &__pyx_r);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (likely(__pyx_t_8 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_12);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_12;
              __Pyx_XGIVEREF(__pyx_t_13);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_13;
              __Pyx_XGIVEREF(__pyx_t_14);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_14;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 4;
              return __pyx_r;
              __pyx_L50_resume_from_await:;
              __pyx_t_12 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_12);
              __pyx_t_13 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_13);
              __pyx_t_14 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_14);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1893, __pyx_L17_error)
              __pyx_t_2 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_2);
            } else if (likely(__pyx_t_8 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __pyx_t_2 = __pyx_r; __pyx_r = NULL;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 1893, __pyx_L17_error)
            }
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_url_result);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_url_result, __pyx_t_2);
            __Pyx_GIVEREF(__pyx_t_2);
            __pyx_t_2 = 0;

            /* "ws_package/controllers/activity_controller.py":1896
 *                                     tab_title=display_name if self.is_browser(display_name) else i2t,
 *                                 )
 *                                 if url_result and url_result.strip() and url_result != "New Tab":             # <<<<<<<<<<<<<<
 *                                     i2t = url_result.strip()
 *                                 else:
*/
            __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_url_result); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1896, __pyx_L17_error)
            if (__pyx_t_10) {
            } else {
              __pyx_t_9 = __pyx_t_10;
              goto __pyx_L52_bool_binop_done;
            }
            __pyx_t_5 = __pyx_cur_scope->__pyx_v_url_result;
            __Pyx_INCREF(__pyx_t_5);
            __pyx_t_6 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
              __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strip, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1896, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_2);
            }
            __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1896, __pyx_L17_error)
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (__pyx_t_10) {
            } else {
              __pyx_t_9 = __pyx_t_10;
              goto __pyx_L52_bool_binop_done;
            }
            __pyx_t_10 = (__Pyx_PyUnicode_Equals(__pyx_cur_scope->__pyx_v_url_result, __pyx_mstate_global->__pyx_kp_u_New_Tab, Py_NE)); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1896, __pyx_L17_error)
            __pyx_t_9 = __pyx_t_10;
            __pyx_L52_bool_binop_done:;
            if (__pyx_t_9) {

              /* "ws_package/controllers/activity_controller.py":1897
 *                                 )
 *                                 if url_result and url_result.strip() and url_result != "New Tab":
 *                                     i2t = url_result.strip()             # <<<<<<<<<<<<<<
 *                                 else:
 *                                     i2t = "New Tab"
*/
              __pyx_t_5 = __pyx_cur_scope->__pyx_v_url_result;
              __Pyx_INCREF(__pyx_t_5);
              __pyx_t_6 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strip, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1897, __pyx_L17_error)
                __Pyx_GOTREF(__pyx_t_2);
              }
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_i2t);
              __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_i2t, __pyx_t_2);
              __Pyx_GIVEREF(__pyx_t_2);
              __pyx_t_2 = 0;

              /* "ws_package/controllers/activity_controller.py":1896
 *                                     tab_title=display_name if self.is_browser(display_name) else i2t,
 *                                 )
 *                                 if url_result and url_result.strip() and url_result != "New Tab":             # <<<<<<<<<<<<<<
 *                                     i2t = url_result.strip()
 *                                 else:
*/
              goto __pyx_L51;
            }

            /* "ws_package/controllers/activity_controller.py":1899
 *                                     i2t = url_result.strip()
 *                                 else:
 *                                     i2t = "New Tab"             # <<<<<<<<<<<<<<
 * 
 *                             active_app_url = [{
*/
            /*else*/ {
              __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_New_Tab);
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_i2t);
              __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_i2t, __pyx_mstate_global->__pyx_kp_u_New_Tab);
              __Pyx_GIVEREF(__pyx_mstate_global->__pyx_kp_u_New_Tab);
            }
            __pyx_L51:;

            /* "ws_package/controllers/activity_controller.py":1892
 *                             if i2t.startswith(('http://', 'https://')):
 *                                 pass
 *                             elif self.is_browser(display_name) or self.is_browser(i2t):             # <<<<<<<<<<<<<<
 *                                 url_result = await get_browser_url_with_fallback(
 *                                     tab_title=display_name if self.is_browser(display_name) else i2t,
*/
          }
          __pyx_L47:;

          /* "ws_package/controllers/activity_controller.py":1902
 * 
 *                             active_app_url = [{
 *                                 "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),             # <<<<<<<<<<<<<<
 *                                 "module": row.get('active_app', i2t),
 *                                 "active_app": row.get('active_app', i2t),
*/
          __pyx_t_2 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1902, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_4 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_time); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1902, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_strftime); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1902, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_6 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_1))) {
            __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
            assert(__pyx_t_4);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
            __pyx_t_6 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Y_m_d_H_M_S};
            __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1902, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_5);
          }
          __pyx_t_1 = __Pyx_PyObject_Unicode(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1902, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_timestamp, __pyx_t_1) < (0)) __PYX_ERR(0, 1902, __pyx_L17_error)
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":1903
 *                             active_app_url = [{
 *                                 "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),
 *                                 "module": row.get('active_app', i2t),             # <<<<<<<<<<<<<<
 *                                 "active_app": row.get('active_app', i2t),
 *                                 "url": i2t,
*/
          __pyx_t_5 = __pyx_cur_scope->__pyx_v_row;
          __Pyx_INCREF(__pyx_t_5);
          __pyx_t_6 = 0;
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_n_u_active_app, __pyx_cur_scope->__pyx_v_i2t};
            __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1903, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_1);
          }
          if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_module, __pyx_t_1) < (0)) __PYX_ERR(0, 1902, __pyx_L17_error)
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":1904
 *                                 "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),
 *                                 "module": row.get('active_app', i2t),
 *                                 "active_app": row.get('active_app', i2t),             # <<<<<<<<<<<<<<
 *                                 "url": i2t,
 *                             }]
*/
          __pyx_t_5 = __pyx_cur_scope->__pyx_v_row;
          __Pyx_INCREF(__pyx_t_5);
          __pyx_t_6 = 0;
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_n_u_active_app, __pyx_cur_scope->__pyx_v_i2t};
            __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1904, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_1);
          }
          if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_active_app, __pyx_t_1) < (0)) __PYX_ERR(0, 1902, __pyx_L17_error)
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":1905
 *                                 "module": row.get('active_app', i2t),
 *                                 "active_app": row.get('active_app', i2t),
 *                                 "url": i2t,             # <<<<<<<<<<<<<<
 *                             }]
 * 
*/
          if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_url, __pyx_cur_scope->__pyx_v_i2t) < (0)) __PYX_ERR(0, 1902, __pyx_L17_error)

          /* "ws_package/controllers/activity_controller.py":1901
 *                                     i2t = "New Tab"
 * 
 *                             active_app_url = [{             # <<<<<<<<<<<<<<
 *                                 "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),
 *                                 "module": row.get('active_app', i2t),
*/
          __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1901, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_2);
          if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_2) != (0)) __PYX_ERR(0, 1901, __pyx_L17_error);
          __pyx_t_2 = 0;
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_active_app_url);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_active_app_url, __pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_1);
          __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":1883
 *                                 "url": app_name,
 *                             }]
 *                         elif (self.get_os_type() == "windows") and (self.appandurlstatus == 3 or self.appandurlstatus == 2) and len(active_app_url)>0:             # <<<<<<<<<<<<<<
 *                             # Apps + URLs mode (2) or full mode (3): resolve URL from browser DB.
 *                             row = active_app_url[0]
*/
          goto __pyx_L25;
        }

        /* "ws_package/controllers/activity_controller.py":1908
 *                             }]
 * 
 *                         elif (self.get_os_type() == "windows") and self.appandurlstatus == 1 and len(active_app_url) > 0:             # <<<<<<<<<<<<<<
 *                             # Apps-only mode on Windows: record app name, skip URL resolution.
 *                             app_name = active_app_url[0]['active_app']
*/
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1908, __pyx_L17_error) }
        __pyx_t_2 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_2);
        __pyx_t_6 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
          __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1908, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __pyx_t_10 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_windows, Py_EQ)); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1908, __pyx_L17_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (__pyx_t_10) {
        } else {
          __pyx_t_9 = __pyx_t_10;
          goto __pyx_L55_bool_binop_done;
        }
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1908, __pyx_L17_error) }
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1908, __pyx_L17_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_10 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_1, 1, 0)); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1908, __pyx_L17_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (__pyx_t_10) {
        } else {
          __pyx_t_9 = __pyx_t_10;
          goto __pyx_L55_bool_binop_done;
        }
        __pyx_t_15 = PyObject_Length(__pyx_cur_scope->__pyx_v_active_app_url); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1908, __pyx_L17_error)
        __pyx_t_10 = (__pyx_t_15 > 0);
        __pyx_t_9 = __pyx_t_10;
        __pyx_L55_bool_binop_done:;
        if (__pyx_t_9) {

          /* "ws_package/controllers/activity_controller.py":1910
 *                         elif (self.get_os_type() == "windows") and self.appandurlstatus == 1 and len(active_app_url) > 0:
 *                             # Apps-only mode on Windows: record app name, skip URL resolution.
 *                             app_name = active_app_url[0]['active_app']             # <<<<<<<<<<<<<<
 *                             active_app_url = [{
 *                                 "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),
*/
          __pyx_t_1 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_active_app_url, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_SharedReference); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1910, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_active_app); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1910, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_app_name);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_app_name, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":1912
 *                             app_name = active_app_url[0]['active_app']
 *                             active_app_url = [{
 *                                 "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),             # <<<<<<<<<<<<<<
 *                                 "module": app_name,
 *                                 "active_app": app_name,
*/
          __pyx_t_2 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1912, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_5 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_time); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1912, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_strftime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1912, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_6 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_3))) {
            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
            assert(__pyx_t_5);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
            __pyx_t_6 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Y_m_d_H_M_S};
            __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1912, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_1);
          }
          __pyx_t_3 = __Pyx_PyObject_Unicode(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1912, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_timestamp, __pyx_t_3) < (0)) __PYX_ERR(0, 1912, __pyx_L17_error)
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

          /* "ws_package/controllers/activity_controller.py":1913
 *                             active_app_url = [{
 *                                 "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),
 *                                 "module": app_name,             # <<<<<<<<<<<<<<
 *                                 "active_app": app_name,
 *                                 "url": app_name,
*/
          if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_module, __pyx_cur_scope->__pyx_v_app_name) < (0)) __PYX_ERR(0, 1912, __pyx_L17_error)

          /* "ws_package/controllers/activity_controller.py":1914
 *                                 "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),
 *                                 "module": app_name,
 *                                 "active_app": app_name,             # <<<<<<<<<<<<<<
 *                                 "url": app_name,
 *                             }]
*/
          if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_active_app, __pyx_cur_scope->__pyx_v_app_name) < (0)) __PYX_ERR(0, 1912, __pyx_L17_error)

          /* "ws_package/controllers/activity_controller.py":1915
 *                                 "module": app_name,
 *                                 "active_app": app_name,
 *                                 "url": app_name,             # <<<<<<<<<<<<<<
 *                             }]
 * 
*/
          if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_url, __pyx_cur_scope->__pyx_v_app_name) < (0)) __PYX_ERR(0, 1912, __pyx_L17_error)

          /* "ws_package/controllers/activity_controller.py":1911
 *                             # Apps-only mode on Windows: record app name, skip URL resolution.
 *                             app_name = active_app_url[0]['active_app']
 *                             active_app_url = [{             # <<<<<<<<<<<<<<
 *                                 "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),
 *                                 "module": app_name,
*/
          __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1911, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_2);
          if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_2) != (0)) __PYX_ERR(0, 1911, __pyx_L17_error);
          __pyx_t_2 = 0;
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_active_app_url);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_active_app_url, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_3);
          __pyx_t_3 = 0;

          /* "ws_package/controllers/activity_controller.py":1908
 *                             }]
 * 
 *                         elif (self.get_os_type() == "windows") and self.appandurlstatus == 1 and len(active_app_url) > 0:             # <<<<<<<<<<<<<<
 *                             # Apps-only mode on Windows: record app name, skip URL resolution.
 *                             app_name = active_app_url[0]['active_app']
*/
          goto __pyx_L25;
        }

        /* "ws_package/controllers/activity_controller.py":1918
 *                             }]
 * 
 *                         elif (self.get_os_type() == "darwin") and (self.appandurlstatus >= 1) and len(active_app_url)>0:             # <<<<<<<<<<<<<<
 *                             # Initialize i2t with default value
 *                             i2t = active_app_url[0]['active_app']  # Default to the app name
*/
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1918, __pyx_L17_error) }
        __pyx_t_2 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_2);
        __pyx_t_6 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
          __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1918, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_3);
        }
        __pyx_t_10 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_darwin, Py_EQ)); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1918, __pyx_L17_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (__pyx_t_10) {
        } else {
          __pyx_t_9 = __pyx_t_10;
          goto __pyx_L58_bool_binop_done;
        }
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1918, __pyx_L17_error) }
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1918, __pyx_L17_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_mstate_global->__pyx_int_1, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1918, __pyx_L17_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1918, __pyx_L17_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (__pyx_t_10) {
        } else {
          __pyx_t_9 = __pyx_t_10;
          goto __pyx_L58_bool_binop_done;
        }
        __pyx_t_15 = PyObject_Length(__pyx_cur_scope->__pyx_v_active_app_url); if (unlikely(__pyx_t_15 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1918, __pyx_L17_error)
        __pyx_t_10 = (__pyx_t_15 > 0);
        __pyx_t_9 = __pyx_t_10;
        __pyx_L58_bool_binop_done:;
        if (__pyx_t_9) {

          /* "ws_package/controllers/activity_controller.py":1920
 *                         elif (self.get_os_type() == "darwin") and (self.appandurlstatus >= 1) and len(active_app_url)>0:
 *                             # Initialize i2t with default value
 *                             i2t = active_app_url[0]['active_app']  # Default to the app name             # <<<<<<<<<<<<<<
 * 
 *                             detected_app = active_app_url[0]['active_app']
*/
          __pyx_t_2 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_active_app_url, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_SharedReference); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1920, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_3 = __Pyx_PyObject_Dict_GetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_active_app); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1920, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_i2t);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_i2t, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_3);
          __pyx_t_3 = 0;

          /* "ws_package/controllers/activity_controller.py":1922
 *                             i2t = active_app_url[0]['active_app']  # Default to the app name
 * 
 *                             detected_app = active_app_url[0]['active_app']             # <<<<<<<<<<<<<<
 * 
 *                             if self.is_browser(detected_app):
*/
          __pyx_t_3 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_active_app_url, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_SharedReference); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1922, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_active_app); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1922, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_detected_app);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_detected_app, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":1924
 *                             detected_app = active_app_url[0]['active_app']
 * 
 *                             if self.is_browser(detected_app):             # <<<<<<<<<<<<<<
 *                                 # Browser-database URL detection only.
 *                                 url_result = await get_browser_url_with_fallback(
*/
          if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1924, __pyx_L17_error) }
          __pyx_t_3 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_3);
          __pyx_t_6 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_detected_app};
            __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_browser, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1924, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_2);
          }
          __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 1924, __pyx_L17_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (__pyx_t_9) {

            /* "ws_package/controllers/activity_controller.py":1926
 *                             if self.is_browser(detected_app):
 *                                 # Browser-database URL detection only.
 *                                 url_result = await get_browser_url_with_fallback(             # <<<<<<<<<<<<<<
 *                                     tab_title=detected_app,
 *                                 )
*/
            __pyx_t_3 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_get_browser_url_with_fallback); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1926, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_1);

            /* "ws_package/controllers/activity_controller.py":1927
 *                                 # Browser-database URL detection only.
 *                                 url_result = await get_browser_url_with_fallback(
 *                                     tab_title=detected_app,             # <<<<<<<<<<<<<<
 *                                 )
 *                                 if url_result and url_result.strip() and url_result != "New Tab":
*/
            __pyx_t_6 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_1))) {
              __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
              assert(__pyx_t_3);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
              __pyx_t_6 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_3, NULL};
              __pyx_t_5 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1926, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_5);
              if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_tab_title, __pyx_cur_scope->__pyx_v_detected_app, __pyx_t_5, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 1926, __pyx_L17_error)
              __pyx_t_2 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_5);
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1926, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_2);
            }
            __pyx_t_8 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_2, &__pyx_r);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (likely(__pyx_t_8 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_12);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_12;
              __Pyx_XGIVEREF(__pyx_t_13);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_13;
              __Pyx_XGIVEREF(__pyx_t_14);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_14;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 5;
              return __pyx_r;
              __pyx_L62_resume_from_await:;
              __pyx_t_12 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_12);
              __pyx_t_13 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_13);
              __pyx_t_14 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_14);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1926, __pyx_L17_error)
              __pyx_t_2 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_2);
            } else if (likely(__pyx_t_8 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __pyx_t_2 = __pyx_r; __pyx_r = NULL;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 1926, __pyx_L17_error)
            }
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_url_result);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_url_result, __pyx_t_2);
            __Pyx_GIVEREF(__pyx_t_2);
            __pyx_t_2 = 0;

            /* "ws_package/controllers/activity_controller.py":1929
 *                                     tab_title=detected_app,
 *                                 )
 *                                 if url_result and url_result.strip() and url_result != "New Tab":             # <<<<<<<<<<<<<<
 *                                     i2t = url_result.strip()
 *                                 else:
*/
            __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_url_result); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1929, __pyx_L17_error)
            if (__pyx_t_10) {
            } else {
              __pyx_t_9 = __pyx_t_10;
              goto __pyx_L64_bool_binop_done;
            }
            __pyx_t_1 = __pyx_cur_scope->__pyx_v_url_result;
            __Pyx_INCREF(__pyx_t_1);
            __pyx_t_6 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
              __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strip, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1929, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_2);
            }
            __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1929, __pyx_L17_error)
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (__pyx_t_10) {
            } else {
              __pyx_t_9 = __pyx_t_10;
              goto __pyx_L64_bool_binop_done;
            }
            __pyx_t_10 = (__Pyx_PyUnicode_Equals(__pyx_cur_scope->__pyx_v_url_result, __pyx_mstate_global->__pyx_kp_u_New_Tab, Py_NE)); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1929, __pyx_L17_error)
            __pyx_t_9 = __pyx_t_10;
            __pyx_L64_bool_binop_done:;
            if (__pyx_t_9) {

              /* "ws_package/controllers/activity_controller.py":1930
 *                                 )
 *                                 if url_result and url_result.strip() and url_result != "New Tab":
 *                                     i2t = url_result.strip()             # <<<<<<<<<<<<<<
 *                                 else:
 *                                     if self.appandurlstatus == 1:
*/
              __pyx_t_1 = __pyx_cur_scope->__pyx_v_url_result;
              __Pyx_INCREF(__pyx_t_1);
              __pyx_t_6 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
                __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strip, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1930, __pyx_L17_error)
                __Pyx_GOTREF(__pyx_t_2);
              }
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_i2t);
              __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_i2t, __pyx_t_2);
              __Pyx_GIVEREF(__pyx_t_2);
              __pyx_t_2 = 0;

              /* "ws_package/controllers/activity_controller.py":1929
 *                                     tab_title=detected_app,
 *                                 )
 *                                 if url_result and url_result.strip() and url_result != "New Tab":             # <<<<<<<<<<<<<<
 *                                     i2t = url_result.strip()
 *                                 else:
*/
              goto __pyx_L63;
            }

            /* "ws_package/controllers/activity_controller.py":1932
 *                                     i2t = url_result.strip()
 *                                 else:
 *                                     if self.appandurlstatus == 1:             # <<<<<<<<<<<<<<
 *                                         i2t = detected_app
 *                                         logger.debug("[macOS] Apps only mode: Using browser name '%s' instead of 'New Tab'", i2t)
*/
            /*else*/ {
              if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1932, __pyx_L17_error) }
              __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1932, __pyx_L17_error)
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_t_9 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_2, __pyx_mstate_global->__pyx_int_1, 1, 0)); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 1932, __pyx_L17_error)
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              if (__pyx_t_9) {

                /* "ws_package/controllers/activity_controller.py":1933
 *                                 else:
 *                                     if self.appandurlstatus == 1:
 *                                         i2t = detected_app             # <<<<<<<<<<<<<<
 *                                         logger.debug("[macOS] Apps only mode: Using browser name '%s' instead of 'New Tab'", i2t)
 *                                     else:
*/
                __Pyx_INCREF(__pyx_cur_scope->__pyx_v_detected_app);
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_i2t);
                __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_i2t, __pyx_cur_scope->__pyx_v_detected_app);
                __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_detected_app);

                /* "ws_package/controllers/activity_controller.py":1934
 *                                     if self.appandurlstatus == 1:
 *                                         i2t = detected_app
 *                                         logger.debug("[macOS] Apps only mode: Using browser name '%s' instead of 'New Tab'", i2t)             # <<<<<<<<<<<<<<
 *                                     else:
 *                                         i2t = "New Tab"
*/
                __pyx_t_1 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1934, __pyx_L17_error)
                __Pyx_GOTREF(__pyx_t_5);
                __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1934, __pyx_L17_error)
                __Pyx_GOTREF(__pyx_t_3);
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __pyx_t_6 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_3))) {
                  __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
                  assert(__pyx_t_1);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
                  __Pyx_INCREF(__pyx_t_1);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
                  __pyx_t_6 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_macOS_Apps_only_mode_Using_brow, __pyx_cur_scope->__pyx_v_i2t};
                  __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1934, __pyx_L17_error)
                  __Pyx_GOTREF(__pyx_t_2);
                }
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

                /* "ws_package/controllers/activity_controller.py":1932
 *                                     i2t = url_result.strip()
 *                                 else:
 *                                     if self.appandurlstatus == 1:             # <<<<<<<<<<<<<<
 *                                         i2t = detected_app
 *                                         logger.debug("[macOS] Apps only mode: Using browser name '%s' instead of 'New Tab'", i2t)
*/
                goto __pyx_L67;
              }

              /* "ws_package/controllers/activity_controller.py":1936
 *                                         logger.debug("[macOS] Apps only mode: Using browser name '%s' instead of 'New Tab'", i2t)
 *                                     else:
 *                                         i2t = "New Tab"             # <<<<<<<<<<<<<<
 * 
 *                             active_app_url = [{
*/
              /*else*/ {
                __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_New_Tab);
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_i2t);
                __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_i2t, __pyx_mstate_global->__pyx_kp_u_New_Tab);
                __Pyx_GIVEREF(__pyx_mstate_global->__pyx_kp_u_New_Tab);
              }
              __pyx_L67:;
            }
            __pyx_L63:;

            /* "ws_package/controllers/activity_controller.py":1924
 *                             detected_app = active_app_url[0]['active_app']
 * 
 *                             if self.is_browser(detected_app):             # <<<<<<<<<<<<<<
 *                                 # Browser-database URL detection only.
 *                                 url_result = await get_browser_url_with_fallback(
*/
          }

          /* "ws_package/controllers/activity_controller.py":1939
 * 
 *                             active_app_url = [{
 *                                 "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),             # <<<<<<<<<<<<<<
 *                                 "module": i2t,
 *                                 "active_app": i2t,
*/
          __pyx_t_2 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1939, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_1 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_time); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1939, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_strftime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1939, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_6 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_4))) {
            __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
            assert(__pyx_t_1);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
            __pyx_t_6 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Y_m_d_H_M_S};
            __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1939, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_3);
          }
          __pyx_t_4 = __Pyx_PyObject_Unicode(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1939, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_timestamp, __pyx_t_4) < (0)) __PYX_ERR(0, 1939, __pyx_L17_error)
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

          /* "ws_package/controllers/activity_controller.py":1940
 *                             active_app_url = [{
 *                                 "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),
 *                                 "module": i2t,             # <<<<<<<<<<<<<<
 *                                 "active_app": i2t,
 *                                 "url": i2t,
*/
          if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_module, __pyx_cur_scope->__pyx_v_i2t) < (0)) __PYX_ERR(0, 1939, __pyx_L17_error)

          /* "ws_package/controllers/activity_controller.py":1941
 *                                 "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),
 *                                 "module": i2t,
 *                                 "active_app": i2t,             # <<<<<<<<<<<<<<
 *                                 "url": i2t,
 *                             }]
*/
          if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_active_app, __pyx_cur_scope->__pyx_v_i2t) < (0)) __PYX_ERR(0, 1939, __pyx_L17_error)

          /* "ws_package/controllers/activity_controller.py":1942
 *                                 "module": i2t,
 *                                 "active_app": i2t,
 *                                 "url": i2t,             # <<<<<<<<<<<<<<
 *                             }]
 * 
*/
          if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_url, __pyx_cur_scope->__pyx_v_i2t) < (0)) __PYX_ERR(0, 1939, __pyx_L17_error)

          /* "ws_package/controllers/activity_controller.py":1938
 *                                         i2t = "New Tab"
 * 
 *                             active_app_url = [{             # <<<<<<<<<<<<<<
 *                                 "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),
 *                                 "module": i2t,
*/
          __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1938, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_2);
          if (__Pyx_PyList_SET_ITEM(__pyx_t_4, 0, __pyx_t_2) != (0)) __PYX_ERR(0, 1938, __pyx_L17_error);
          __pyx_t_2 = 0;
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_active_app_url);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_active_app_url, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_4);
          __pyx_t_4 = 0;

          /* "ws_package/controllers/activity_controller.py":1918
 *                             }]
 * 
 *                         elif (self.get_os_type() == "darwin") and (self.appandurlstatus >= 1) and len(active_app_url)>0:             # <<<<<<<<<<<<<<
 *                             # Initialize i2t with default value
 *                             i2t = active_app_url[0]['active_app']  # Default to the app name
*/
        }
        __pyx_L25:;

        /* "ws_package/controllers/activity_controller.py":1945
 *                             }]
 * 
 *                         if self.status == False:             # <<<<<<<<<<<<<<
 *                             await self.activity_service.save_app_monitors(active_app_url, self.last_count+1, True) # Sleep + Shutdown case + Correct timezone
 *                         else:
*/
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1945, __pyx_L17_error) }
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1945, __pyx_L17_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, Py_False, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1945, __pyx_L17_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 1945, __pyx_L17_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (__pyx_t_9) {

          /* "ws_package/controllers/activity_controller.py":1946
 * 
 *                         if self.status == False:
 *                             await self.activity_service.save_app_monitors(active_app_url, self.last_count+1, True) # Sleep + Shutdown case + Correct timezone             # <<<<<<<<<<<<<<
 *                         else:
 *                             await self.activity_service.save_app_monitors(active_app_url, self.last_count+1, False)
*/
          if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1946, __pyx_L17_error) }
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1946, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_4 = __pyx_t_3;
          __Pyx_INCREF(__pyx_t_4);
          if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1946, __pyx_L17_error) }
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1946, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_5 = __Pyx_PyLong_AddObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1946, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_6 = 0;
          {
            PyObject *__pyx_callargs[4] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_active_app_url, __pyx_t_5, Py_True};
            __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_save_app_monitors, __pyx_callargs+__pyx_t_6, (4-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1946, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_2);
          }
          __pyx_t_8 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_2, &__pyx_r);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (likely(__pyx_t_8 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_12);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_12;
            __Pyx_XGIVEREF(__pyx_t_13);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_13;
            __Pyx_XGIVEREF(__pyx_t_14);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_14;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 6;
            return __pyx_r;
            __pyx_L69_resume_from_await:;
            __pyx_t_12 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_12);
            __pyx_t_13 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_13);
            __pyx_t_14 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_14);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1946, __pyx_L17_error)
          } else if (likely(__pyx_t_8 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_DECREF(__pyx_r); __pyx_r = 0;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 1946, __pyx_L17_error)
          }

          /* "ws_package/controllers/activity_controller.py":1945
 *                             }]
 * 
 *                         if self.status == False:             # <<<<<<<<<<<<<<
 *                             await self.activity_service.save_app_monitors(active_app_url, self.last_count+1, True) # Sleep + Shutdown case + Correct timezone
 *                         else:
*/
          goto __pyx_L68;
        }

        /* "ws_package/controllers/activity_controller.py":1948
 *                             await self.activity_service.save_app_monitors(active_app_url, self.last_count+1, True) # Sleep + Shutdown case + Correct timezone
 *                         else:
 *                             await self.activity_service.save_app_monitors(active_app_url, self.last_count+1, False)             # <<<<<<<<<<<<<<
 * 
 *                         # Update the last time we checked for active apps
*/
        /*else*/ {
          if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1948, __pyx_L17_error) }
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1948, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_3 = __pyx_t_5;
          __Pyx_INCREF(__pyx_t_3);
          if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1948, __pyx_L17_error) }
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1948, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_1 = __Pyx_PyLong_AddObjC(__pyx_t_4, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1948, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_6 = 0;
          {
            PyObject *__pyx_callargs[4] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_active_app_url, __pyx_t_1, Py_False};
            __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_save_app_monitors, __pyx_callargs+__pyx_t_6, (4-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1948, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_2);
          }
          __pyx_t_8 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_2, &__pyx_r);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (likely(__pyx_t_8 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_12);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_12;
            __Pyx_XGIVEREF(__pyx_t_13);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_13;
            __Pyx_XGIVEREF(__pyx_t_14);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_14;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 7;
            return __pyx_r;
            __pyx_L70_resume_from_await:;
            __pyx_t_12 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_12);
            __pyx_t_13 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_13);
            __pyx_t_14 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_14);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1948, __pyx_L17_error)
          } else if (likely(__pyx_t_8 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_DECREF(__pyx_r); __pyx_r = 0;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 1948, __pyx_L17_error)
          }
        }
        __pyx_L68:;

        /* "ws_package/controllers/activity_controller.py":1951
 * 
 *                         # Update the last time we checked for active apps
 *                         last_app_monitor_time = datetime.datetime.now()             # <<<<<<<<<<<<<<
 *                 except Exception as e:
 *                     logger.exception("Error in monitoring active apps: %s", e)
*/
        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1951, __pyx_L17_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1951, __pyx_L17_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_5 = __pyx_t_3;
        __Pyx_INCREF(__pyx_t_5);
        __pyx_t_6 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
          __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1951, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_2);
        }
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_app_monitor_time);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_app_monitor_time, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        __pyx_t_2 = 0;

        /* "ws_package/controllers/activity_controller.py":1840
 *                     continue
 * 
 *                 try:             # <<<<<<<<<<<<<<
 *                         active_app_url = app_listener.get_active_windows()
 *                         logger.debug(
*/
      }
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      goto __pyx_L24_try_end;
      __pyx_L17_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "ws_package/controllers/activity_controller.py":1952
 *                         # Update the last time we checked for active apps
 *                         last_app_monitor_time = datetime.datetime.now()
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.exception("Error in monitoring active apps: %s", e)
 *                     # Update timestamp even on error to prevent rapid retries
*/
      __pyx_t_17 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
      if (__pyx_t_17) {
        __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity.monitor_active_apps", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_5) < 0) __PYX_ERR(0, 1952, __pyx_L19_except_error)
        __Pyx_XGOTREF(__pyx_t_2);
        __Pyx_XGOTREF(__pyx_t_3);
        __Pyx_XGOTREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_v_e = __pyx_t_3;
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":1953
 *                         last_app_monitor_time = datetime.datetime.now()
 *                 except Exception as e:
 *                     logger.exception("Error in monitoring active apps: %s", e)             # <<<<<<<<<<<<<<
 *                     # Update timestamp even on error to prevent rapid retries
 *                     last_app_monitor_time = datetime.datetime.now()
*/
          __pyx_t_4 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1953, __pyx_L76_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_exception); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 1953, __pyx_L76_error)
          __Pyx_GOTREF(__pyx_t_16);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_6 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_16))) {
            __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_16);
            assert(__pyx_t_4);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_16);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_16, __pyx__function);
            __pyx_t_6 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Error_in_monitoring_active_apps, __pyx_cur_scope->__pyx_v_e};
            __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_16, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1953, __pyx_L76_error)
            __Pyx_GOTREF(__pyx_t_1);
          }
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":1955
 *                     logger.exception("Error in monitoring active apps: %s", e)
 *                     # Update timestamp even on error to prevent rapid retries
 *                     last_app_monitor_time = datetime.datetime.now()             # <<<<<<<<<<<<<<
 * 
 *         # Create and track the monitor_active_apps task to prevent silent failures
*/
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1955, __pyx_L76_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 1955, __pyx_L76_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_16 = __pyx_t_7;
          __Pyx_INCREF(__pyx_t_16);
          __pyx_t_6 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_16, NULL};
            __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1955, __pyx_L76_error)
            __Pyx_GOTREF(__pyx_t_1);
          }
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_app_monitor_time);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_app_monitor_time, __pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_1);
          __pyx_t_1 = 0;
        }

        /* "ws_package/controllers/activity_controller.py":1952
 *                         # Update the last time we checked for active apps
 *                         last_app_monitor_time = datetime.datetime.now()
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.exception("Error in monitoring active apps: %s", e)
 *                     # Update timestamp even on error to prevent rapid retries
*/
        /*finally:*/ {
          /*normal exit:*/{
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
            goto __pyx_L77;
          }
          __pyx_L76_error:;
          /*exception exit:*/{
            __Pyx_PyThreadState_assign
            __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0;
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
             __Pyx_ExceptionSwap(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25);
            if ( unlikely(__Pyx_GetException(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22) < 0)) __Pyx_ErrFetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
            __Pyx_XGOTREF(__pyx_t_20);
            __Pyx_XGOTREF(__pyx_t_21);
            __Pyx_XGOTREF(__pyx_t_22);
            __Pyx_XGOTREF(__pyx_t_23);
            __Pyx_XGOTREF(__pyx_t_24);
            __Pyx_XGOTREF(__pyx_t_25);
            __pyx_t_17 = __pyx_lineno; __pyx_t_18 = __pyx_clineno; __pyx_t_19 = __pyx_filename;
            {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
            }
            __Pyx_XGIVEREF(__pyx_t_23);
            __Pyx_XGIVEREF(__pyx_t_24);
            __Pyx_XGIVEREF(__pyx_t_25);
            __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_24, __pyx_t_25);
            __Pyx_XGIVEREF(__pyx_t_20);
            __Pyx_XGIVEREF(__pyx_t_21);
            __Pyx_XGIVEREF(__pyx_t_22);
            __Pyx_ErrRestore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
            __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0;
            __pyx_lineno = __pyx_t_17; __pyx_clineno = __pyx_t_18; __pyx_filename = __pyx_t_19;
            goto __pyx_L19_except_error;
          }
          __pyx_L77:;
        }
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        goto __pyx_L18_exception_handled;
      }
      goto __pyx_L19_except_error;

      /* "ws_package/controllers/activity_controller.py":1840
 *                     continue
 * 
 *                 try:             # <<<<<<<<<<<<<<
 *                         active_app_url = app_listener.get_active_windows()
 *                         logger.debug(
*/
      __pyx_L19_except_error:;
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_XGIVEREF(__pyx_t_14);
      __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
      goto __pyx_L1_error;
      __pyx_L18_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_XGIVEREF(__pyx_t_14);
      __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
      __pyx_L24_try_end:;
    }
    __pyx_L4_continue:;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":1810
 *         # No complex time monitoring needed - using S3 error detection
 * 
 *         async def monitor_active_apps():             # <<<<<<<<<<<<<<
 *             nonlocal last_app_monitor_time
 *             logger.info(
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_16);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("monitor_active_apps", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":1961
 *         self._background_tasks.add(monitor_task)
 * 
 *         def task_done_callback(task):             # <<<<<<<<<<<<<<
 *             """Handle task completion and log any exceptions"""
 *             self._background_tasks.discard(task)
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_6task_done_callback(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_5task_done_callback, "Handle task completion and log any exceptions");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_6task_done_callback = {"task_done_callback", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_6task_done_callback, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_5task_done_callback};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_6task_done_callback(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_task = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[1] = {0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("task_done_callback (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_task,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 1961, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1961, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "task_done_callback", 0) < (0)) __PYX_ERR(0, 1961, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("task_done_callback", 1, 1, 1, i); __PYX_ERR(0, 1961, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 1)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 1961, __pyx_L3_error)
    }
    __pyx_v_task = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("task_done_callback", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 1961, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity.task_done_callback", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_5task_done_callback(__pyx_self, __pyx_v_task);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_5task_done_callback(PyObject *__pyx_self, PyObject *__pyx_v_task) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *__pyx_cur_scope;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *__pyx_outer_scope;
  PyObject *__pyx_v_e = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  size_t __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  char const *__pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("task_done_callback", 0);
  __pyx_outer_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "ws_package/controllers/activity_controller.py":1963
 *         def task_done_callback(task):
 *             """Handle task completion and log any exceptions"""
 *             self._background_tasks.discard(task)             # <<<<<<<<<<<<<<
 *             if task.done():
 *                 try:
*/
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1963, __pyx_L1_error) }
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_background_tasks); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1963, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __pyx_t_3;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_4 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_task};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_discard, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1963, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":1964
 *             """Handle task completion and log any exceptions"""
 *             self._background_tasks.discard(task)
 *             if task.done():             # <<<<<<<<<<<<<<
 *                 try:
 *                     task.result()  # This will raise any exception that occurred
*/
  __pyx_t_3 = __pyx_v_task;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_4 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_done, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1964, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1964, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "ws_package/controllers/activity_controller.py":1965
 *             self._background_tasks.discard(task)
 *             if task.done():
 *                 try:             # <<<<<<<<<<<<<<
 *                     task.result()  # This will raise any exception that occurred
 *                 except asyncio.CancelledError:
*/
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":1966
 *             if task.done():
 *                 try:
 *                     task.result()  # This will raise any exception that occurred             # <<<<<<<<<<<<<<
 *                 except asyncio.CancelledError:
 *                     # Task was cancelled (expected during shutdown), don't log as error
*/
        __pyx_t_3 = __pyx_v_task;
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_4 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
          __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_result, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1966, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":1965
 *             self._background_tasks.discard(task)
 *             if task.done():
 *                 try:             # <<<<<<<<<<<<<<
 *                     task.result()  # This will raise any exception that occurred
 *                 except asyncio.CancelledError:
*/
      }
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L9_try_end;
      __pyx_L4_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "ws_package/controllers/activity_controller.py":1967
 *                 try:
 *                     task.result()  # This will raise any exception that occurred
 *                 except asyncio.CancelledError:             # <<<<<<<<<<<<<<
 *                     # Task was cancelled (expected during shutdown), don't log as error
 *                     logger.debug("Background task monitor_active_apps was cancelled")
*/
      __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_3, &__pyx_t_2);
      __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1967, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_CancelledError); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1967, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_11 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_10);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_ErrRestore(__pyx_t_1, __pyx_t_3, __pyx_t_2);
      __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_t_2 = 0;
      if (__pyx_t_11) {
        __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity.task_done_callback", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_1) < 0) __PYX_ERR(0, 1967, __pyx_L6_except_error)
        __Pyx_XGOTREF(__pyx_t_2);
        __Pyx_XGOTREF(__pyx_t_3);
        __Pyx_XGOTREF(__pyx_t_1);

        /* "ws_package/controllers/activity_controller.py":1969
 *                 except asyncio.CancelledError:
 *                     # Task was cancelled (expected during shutdown), don't log as error
 *                     logger.debug("Background task monitor_active_apps was cancelled")             # <<<<<<<<<<<<<<
 *                 except Exception as e:
 *                     logger.error("Background task monitor_active_apps failed: %s", e, exc_info=True)
*/
        __pyx_t_9 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1969, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 1969, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_13))) {
          __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_13);
          assert(__pyx_t_9);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_mstate_global->__pyx_kp_u_Background_task_monitor_active_a};
          __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1969, __pyx_L6_except_error)
          __Pyx_GOTREF(__pyx_t_10);
        }
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L5_exception_handled;
      }

      /* "ws_package/controllers/activity_controller.py":1970
 *                     # Task was cancelled (expected during shutdown), don't log as error
 *                     logger.debug("Background task monitor_active_apps was cancelled")
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Background task monitor_active_apps failed: %s", e, exc_info=True)
 * 
*/
      __pyx_t_11 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
      if (__pyx_t_11) {
        __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity.task_done_callback", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_2) < 0) __PYX_ERR(0, 1970, __pyx_L6_except_error)
        __Pyx_XGOTREF(__pyx_t_1);
        __Pyx_XGOTREF(__pyx_t_3);
        __Pyx_XGOTREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __pyx_v_e = __pyx_t_3;
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":1971
 *                     logger.debug("Background task monitor_active_apps was cancelled")
 *                 except Exception as e:
 *                     logger.error("Background task monitor_active_apps failed: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *         monitor_task.add_done_callback(task_done_callback)
*/
          __pyx_t_13 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1971, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 1971, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_4 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_12))) {
            __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12);
            assert(__pyx_t_13);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
            __pyx_t_4 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Background_task_monitor_active_a_2, __pyx_v_e};
            __pyx_t_9 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 1971, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_9);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_9, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 1971, __pyx_L17_error)
            __pyx_t_10 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_9);
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1971, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_10);
          }
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }

        /* "ws_package/controllers/activity_controller.py":1970
 *                     # Task was cancelled (expected during shutdown), don't log as error
 *                     logger.debug("Background task monitor_active_apps was cancelled")
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Background task monitor_active_apps failed: %s", e, exc_info=True)
 * 
*/
        /*finally:*/ {
          /*normal exit:*/{
            __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
            goto __pyx_L18;
          }
          __pyx_L17_error:;
          /*exception exit:*/{
            __Pyx_PyThreadState_declare
            __Pyx_PyThreadState_assign
            __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0;
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
             __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21);
            if ( unlikely(__Pyx_GetException(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18) < 0)) __Pyx_ErrFetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
            __Pyx_XGOTREF(__pyx_t_16);
            __Pyx_XGOTREF(__pyx_t_17);
            __Pyx_XGOTREF(__pyx_t_18);
            __Pyx_XGOTREF(__pyx_t_19);
            __Pyx_XGOTREF(__pyx_t_20);
            __Pyx_XGOTREF(__pyx_t_21);
            __pyx_t_11 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_15 = __pyx_filename;
            {
              __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
            }
            __Pyx_XGIVEREF(__pyx_t_19);
            __Pyx_XGIVEREF(__pyx_t_20);
            __Pyx_XGIVEREF(__pyx_t_21);
            __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21);
            __Pyx_XGIVEREF(__pyx_t_16);
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_ErrRestore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
            __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0;
            __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_15;
            goto __pyx_L6_except_error;
          }
          __pyx_L18:;
        }
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        goto __pyx_L5_exception_handled;
      }
      goto __pyx_L6_except_error;

      /* "ws_package/controllers/activity_controller.py":1965
 *             self._background_tasks.discard(task)
 *             if task.done():
 *                 try:             # <<<<<<<<<<<<<<
 *                     task.result()  # This will raise any exception that occurred
 *                 except asyncio.CancelledError:
*/
      __pyx_L6_except_error:;
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
      goto __pyx_L1_error;
      __pyx_L5_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
      __pyx_L9_try_end:;
    }

    /* "ws_package/controllers/activity_controller.py":1964
 *             """Handle task completion and log any exceptions"""
 *             self._background_tasks.discard(task)
 *             if task.done():             # <<<<<<<<<<<<<<
 *                 try:
 *                     task.result()  # This will raise any exception that occurred
*/
  }

  /* "ws_package/controllers/activity_controller.py":1961
 *         self._background_tasks.add(monitor_task)
 * 
 *         def task_done_callback(task):             # <<<<<<<<<<<<<<
 *             """Handle task completion and log any exceptions"""
 *             self._background_tasks.discard(task)
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity.task_done_callback", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_9generator54(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":1976
 * 
 *         # Monitor active app changes for UI display (real-time updates)
 *         async def monitor_active_app_for_ui():             # <<<<<<<<<<<<<<
 *             """Monitor active app changes and send updates to Electron for UI display."""
 *             while not stop_event.is_set():
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_8monitor_active_app_for_ui(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_7monitor_active_app_for_ui, "Monitor active app changes and send updates to Electron for UI display.");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_8monitor_active_app_for_ui = {"monitor_active_app_for_ui", (PyCFunction)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_8monitor_active_app_for_ui, METH_NOARGS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_7monitor_active_app_for_ui};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_8monitor_active_app_for_ui(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("monitor_active_app_for_ui (wrapper)", 0);
  __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_7monitor_active_app_for_ui(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_7monitor_active_app_for_ui(PyObject *__pyx_self) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("monitor_active_app_for_ui", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 1976, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_9generator54, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[25]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_monitor_active_app_for_ui, __pyx_mstate_global->__pyx_n_u_ActivityController___start_devic_3, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 1976, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity.monitor_active_app_for_ui", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_9generator54(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  size_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  __Pyx_PySendResult __pyx_t_12;
  Py_ssize_t __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  int __pyx_t_17;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  int __pyx_t_21;
  char const *__pyx_t_22;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  PyObject *__pyx_t_26 = NULL;
  PyObject *__pyx_t_27 = NULL;
  PyObject *__pyx_t_28 = NULL;
  char const *__pyx_t_29;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("monitor_active_app_for_ui", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L18_resume_from_await;
    case 2: goto __pyx_L44_resume_from_await;
    case 3: goto __pyx_L45_resume_from_await;
    case 4: goto __pyx_L53_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 1976, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":1978
 *         async def monitor_active_app_for_ui():
 *             """Monitor active app changes and send updates to Electron for UI display."""
 *             while not stop_event.is_set():             # <<<<<<<<<<<<<<
 *                 try:
 *                     # Skip if tracking is stopped or on break
*/
  while (1) {
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_stop_event)) { __Pyx_RaiseClosureNameError("stop_event"); __PYX_ERR(0, 1978, __pyx_L1_error) }
    __pyx_t_2 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_stop_event;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_3 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
      __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_set, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1978, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1978, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = (!__pyx_t_4);
    if (!__pyx_t_5) break;

    /* "ws_package/controllers/activity_controller.py":1979
 *             """Monitor active app changes and send updates to Electron for UI display."""
 *             while not stop_event.is_set():
 *                 try:             # <<<<<<<<<<<<<<
 *                     # Skip if tracking is stopped or on break
 *                     if not self.status or (getattr(self, 'break_id', 0) != 0 or self.is_break != 0):
*/
    {
      __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":1981
 *                 try:
 *                     # Skip if tracking is stopped or on break
 *                     if not self.status or (getattr(self, 'break_id', 0) != 0 or self.is_break != 0):             # <<<<<<<<<<<<<<
 *                         await asyncio.sleep(2)  # Check every 2 seconds
 *                         continue
*/
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1981, __pyx_L6_error) }
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1981, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 1981, __pyx_L6_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_9 = (!__pyx_t_4);
        if (!__pyx_t_9) {
        } else {
          __pyx_t_5 = __pyx_t_9;
          goto __pyx_L15_bool_binop_done;
        }
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1981, __pyx_L6_error) }
        __pyx_t_1 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_2 = __Pyx_GetAttr3(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_break_id, __pyx_mstate_global->__pyx_int_0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1981, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_9 = (__Pyx_PyLong_BoolNeObjC(__pyx_t_2, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 1981, __pyx_L6_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (!__pyx_t_9) {
        } else {
          __pyx_t_5 = __pyx_t_9;
          goto __pyx_L15_bool_binop_done;
        }
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1981, __pyx_L6_error) }
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_is_break); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1981, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_9 = (__Pyx_PyLong_BoolNeObjC(__pyx_t_2, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 1981, __pyx_L6_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_5 = __pyx_t_9;
        __pyx_L15_bool_binop_done:;
        if (__pyx_t_5) {

          /* "ws_package/controllers/activity_controller.py":1982
 *                     # Skip if tracking is stopped or on break
 *                     if not self.status or (getattr(self, 'break_id', 0) != 0 or self.is_break != 0):
 *                         await asyncio.sleep(2)  # Check every 2 seconds             # <<<<<<<<<<<<<<
 *                         continue
 * 
*/
          __pyx_t_1 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1982, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1982, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_3 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_11))) {
            __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_11);
            assert(__pyx_t_1);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_11);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_11, __pyx__function);
            __pyx_t_3 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_int_2};
            __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_11, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1982, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_2);
          }
          __pyx_t_12 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_2, &__pyx_r);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (likely(__pyx_t_12 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_6);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
            __Pyx_XGIVEREF(__pyx_t_7);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
            __Pyx_XGIVEREF(__pyx_t_8);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 1;
            return __pyx_r;
            __pyx_L18_resume_from_await:;
            __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_6);
            __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_7);
            __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_8);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1982, __pyx_L6_error)
          } else if (likely(__pyx_t_12 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_DECREF(__pyx_r); __pyx_r = 0;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 1982, __pyx_L6_error)
          }

          /* "ws_package/controllers/activity_controller.py":1983
 *                     if not self.status or (getattr(self, 'break_id', 0) != 0 or self.is_break != 0):
 *                         await asyncio.sleep(2)  # Check every 2 seconds
 *                         continue             # <<<<<<<<<<<<<<
 * 
 *                     # Get current active window (title only  skip Chrome History SQLite reads)
*/
          goto __pyx_L12_try_continue;

          /* "ws_package/controllers/activity_controller.py":1981
 *                 try:
 *                     # Skip if tracking is stopped or on break
 *                     if not self.status or (getattr(self, 'break_id', 0) != 0 or self.is_break != 0):             # <<<<<<<<<<<<<<
 *                         await asyncio.sleep(2)  # Check every 2 seconds
 *                         continue
*/
        }

        /* "ws_package/controllers/activity_controller.py":1986
 * 
 *                     # Get current active window (title only  skip Chrome History SQLite reads)
 *                     active_windows = app_listener.get_active_windows(             # <<<<<<<<<<<<<<
 *                         fetch_browser_url=False,
 *                         include_printers=False,
*/
        if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_app_listener)) { __Pyx_RaiseClosureNameError("app_listener"); __PYX_ERR(0, 1986, __pyx_L6_error) }
        __pyx_t_11 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_app_listener;
        __Pyx_INCREF(__pyx_t_11);

        /* "ws_package/controllers/activity_controller.py":1988
 *                     active_windows = app_listener.get_active_windows(
 *                         fetch_browser_url=False,
 *                         include_printers=False,             # <<<<<<<<<<<<<<
 *                     )
 * 
*/
        __pyx_t_3 = 0;
        {
          PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 2 : 0)] = {__pyx_t_11, NULL};
          __pyx_t_1 = __Pyx_MakeVectorcallBuilderKwds(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1986, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_fetch_browser_url, Py_False, __pyx_t_1, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 1986, __pyx_L6_error)
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_include_printers, Py_False, __pyx_t_1, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 1986, __pyx_L6_error)
          __pyx_t_2 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_get_active_windows, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_1);
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1986, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_2);
        }
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_active_windows);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_active_windows, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        __pyx_t_2 = 0;

        /* "ws_package/controllers/activity_controller.py":1991
 *                     )
 * 
 *                     if active_windows and len(active_windows) > 0:             # <<<<<<<<<<<<<<
 *                         current_app_data = active_windows[0]
 *                         current_app_name = current_app_data.get('app_display_name') or current_app_data.get('active_app', 'Unknown')
*/
        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_active_windows); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 1991, __pyx_L6_error)
        if (__pyx_t_9) {
        } else {
          __pyx_t_5 = __pyx_t_9;
          goto __pyx_L20_bool_binop_done;
        }
        __pyx_t_13 = PyObject_Length(__pyx_cur_scope->__pyx_v_active_windows); if (unlikely(__pyx_t_13 == ((Py_ssize_t)-1))) __PYX_ERR(0, 1991, __pyx_L6_error)
        __pyx_t_9 = (__pyx_t_13 > 0);
        __pyx_t_5 = __pyx_t_9;
        __pyx_L20_bool_binop_done:;
        if (__pyx_t_5) {

          /* "ws_package/controllers/activity_controller.py":1992
 * 
 *                     if active_windows and len(active_windows) > 0:
 *                         current_app_data = active_windows[0]             # <<<<<<<<<<<<<<
 *                         current_app_name = current_app_data.get('app_display_name') or current_app_data.get('active_app', 'Unknown')
 *                         current_app_path = current_app_data.get('app_path')
*/
          __pyx_t_2 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_active_windows, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_SharedReference); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1992, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_current_app_data);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_current_app_data, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":1993
 *                     if active_windows and len(active_windows) > 0:
 *                         current_app_data = active_windows[0]
 *                         current_app_name = current_app_data.get('app_display_name') or current_app_data.get('active_app', 'Unknown')             # <<<<<<<<<<<<<<
 *                         current_app_path = current_app_data.get('app_path')
 * 
*/
          __pyx_t_11 = __pyx_cur_scope->__pyx_v_current_app_data;
          __Pyx_INCREF(__pyx_t_11);
          __pyx_t_3 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_11, __pyx_mstate_global->__pyx_n_u_app_display_name};
            __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1993, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_1);
          }
          __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1993, __pyx_L6_error)
          if (!__pyx_t_5) {
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          } else {
            __Pyx_INCREF(__pyx_t_1);
            __pyx_t_2 = __pyx_t_1;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            goto __pyx_L22_bool_binop_done;
          }
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_current_app_data, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1993, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_mstate_global->__pyx_tuple[20], NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1993, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_INCREF(__pyx_t_11);
          __pyx_t_2 = __pyx_t_11;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __pyx_L22_bool_binop_done:;
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_current_app_name);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_current_app_name, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":1994
 *                         current_app_data = active_windows[0]
 *                         current_app_name = current_app_data.get('app_display_name') or current_app_data.get('active_app', 'Unknown')
 *                         current_app_path = current_app_data.get('app_path')             # <<<<<<<<<<<<<<
 * 
 *                         # Check if app has changed
*/
          __pyx_t_11 = __pyx_cur_scope->__pyx_v_current_app_data;
          __Pyx_INCREF(__pyx_t_11);
          __pyx_t_3 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_11, __pyx_mstate_global->__pyx_n_u_app_path};
            __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1994, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_2);
          }
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_current_app_path);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_current_app_path, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":1997
 * 
 *                         # Check if app has changed
 *                         if current_app_name != self._current_active_app:             # <<<<<<<<<<<<<<
 *                             logger.debug("Active app changed: %s -> %s", self._current_active_app, current_app_name)
 * 
*/
          if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1997, __pyx_L6_error) }
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_active_app); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1997, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_11 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_current_app_name, __pyx_t_2, Py_NE); __Pyx_XGOTREF(__pyx_t_11); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1997, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 1997, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (__pyx_t_5) {

            /* "ws_package/controllers/activity_controller.py":1998
 *                         # Check if app has changed
 *                         if current_app_name != self._current_active_app:
 *                             logger.debug("Active app changed: %s -> %s", self._current_active_app, current_app_name)             # <<<<<<<<<<<<<<
 * 
 *                             # Extract icon
*/
            __pyx_t_2 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1998, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 1998, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 1998, __pyx_L6_error) }
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_active_app); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1998, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_3 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_10))) {
              __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_10);
              assert(__pyx_t_2);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
              __Pyx_INCREF(__pyx_t_2);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
              __pyx_t_3 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[4] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Active_app_changed_s_s, __pyx_t_1, __pyx_cur_scope->__pyx_v_current_app_name};
              __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_3, (4-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 1998, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_11);
            }
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

            /* "ws_package/controllers/activity_controller.py":2001
 * 
 *                             # Extract icon
 *                             app_icon = None             # <<<<<<<<<<<<<<
 *                             try:
 *                                 app_icon = app_listener.get_app_icon(current_app_name, current_app_path)
*/
            __Pyx_INCREF(Py_None);
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_app_icon);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_app_icon, Py_None);
            __Pyx_GIVEREF(Py_None);

            /* "ws_package/controllers/activity_controller.py":2002
 *                             # Extract icon
 *                             app_icon = None
 *                             try:             # <<<<<<<<<<<<<<
 *                                 app_icon = app_listener.get_app_icon(current_app_name, current_app_path)
 *                             except Exception as e:
*/
            {
              __Pyx_ExceptionSave(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
              __Pyx_XGOTREF(__pyx_t_14);
              __Pyx_XGOTREF(__pyx_t_15);
              __Pyx_XGOTREF(__pyx_t_16);
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":2003
 *                             app_icon = None
 *                             try:
 *                                 app_icon = app_listener.get_app_icon(current_app_name, current_app_path)             # <<<<<<<<<<<<<<
 *                             except Exception as e:
 *                                 logger.debug("Failed to extract icon for %s: %s", current_app_name, e)
*/
                if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_app_listener)) { __Pyx_RaiseClosureNameError("app_listener"); __PYX_ERR(0, 2003, __pyx_L25_error) }
                __pyx_t_10 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_app_listener;
                __Pyx_INCREF(__pyx_t_10);
                __pyx_t_3 = 0;
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_10, __pyx_cur_scope->__pyx_v_current_app_name, __pyx_cur_scope->__pyx_v_current_app_path};
                  __pyx_t_11 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_app_icon, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                  if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2003, __pyx_L25_error)
                  __Pyx_GOTREF(__pyx_t_11);
                }
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_app_icon);
                __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_app_icon, __pyx_t_11);
                __Pyx_GIVEREF(__pyx_t_11);
                __pyx_t_11 = 0;

                /* "ws_package/controllers/activity_controller.py":2002
 *                             # Extract icon
 *                             app_icon = None
 *                             try:             # <<<<<<<<<<<<<<
 *                                 app_icon = app_listener.get_app_icon(current_app_name, current_app_path)
 *                             except Exception as e:
*/
              }
              __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
              __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
              goto __pyx_L32_try_end;
              __pyx_L25_error:;
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

              /* "ws_package/controllers/activity_controller.py":2004
 *                             try:
 *                                 app_icon = app_listener.get_app_icon(current_app_name, current_app_path)
 *                             except Exception as e:             # <<<<<<<<<<<<<<
 *                                 logger.debug("Failed to extract icon for %s: %s", current_app_name, e)
 * 
*/
              __pyx_t_17 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
              if (__pyx_t_17) {
                __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity.monitor_active_app_for_ui", __pyx_clineno, __pyx_lineno, __pyx_filename);
                if (__Pyx_GetException(&__pyx_t_11, &__pyx_t_10, &__pyx_t_1) < 0) __PYX_ERR(0, 2004, __pyx_L27_except_error)
                __Pyx_XGOTREF(__pyx_t_11);
                __Pyx_XGOTREF(__pyx_t_10);
                __Pyx_XGOTREF(__pyx_t_1);
                __Pyx_INCREF(__pyx_t_10);
                __Pyx_GIVEREF(__pyx_t_10);
                __pyx_cur_scope->__pyx_v_e = __pyx_t_10;
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":2005
 *                                 app_icon = app_listener.get_app_icon(current_app_name, current_app_path)
 *                             except Exception as e:
 *                                 logger.debug("Failed to extract icon for %s: %s", current_app_name, e)             # <<<<<<<<<<<<<<
 * 
 *                             # Update tracked values
*/
                  __pyx_t_18 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 2005, __pyx_L38_error)
                  __Pyx_GOTREF(__pyx_t_19);
                  __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 2005, __pyx_L38_error)
                  __Pyx_GOTREF(__pyx_t_20);
                  __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                  __pyx_t_3 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_20))) {
                    __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_20);
                    assert(__pyx_t_18);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_20);
                    __Pyx_INCREF(__pyx_t_18);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_20, __pyx__function);
                    __pyx_t_3 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[4] = {__pyx_t_18, __pyx_mstate_global->__pyx_kp_u_Failed_to_extract_icon_for_s_s, __pyx_cur_scope->__pyx_v_current_app_name, __pyx_cur_scope->__pyx_v_e};
                    __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_20, __pyx_callargs+__pyx_t_3, (4-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2005, __pyx_L38_error)
                    __Pyx_GOTREF(__pyx_t_2);
                  }
                  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                }

                /* "ws_package/controllers/activity_controller.py":2004
 *                             try:
 *                                 app_icon = app_listener.get_app_icon(current_app_name, current_app_path)
 *                             except Exception as e:             # <<<<<<<<<<<<<<
 *                                 logger.debug("Failed to extract icon for %s: %s", current_app_name, e)
 * 
*/
                /*finally:*/ {
                  /*normal exit:*/{
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    goto __pyx_L39;
                  }
                  __pyx_L38_error:;
                  /*exception exit:*/{
                    __Pyx_PyThreadState_assign
                    __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0;
                    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                     __Pyx_ExceptionSwap(&__pyx_t_26, &__pyx_t_27, &__pyx_t_28);
                    if ( unlikely(__Pyx_GetException(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25) < 0)) __Pyx_ErrFetch(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25);
                    __Pyx_XGOTREF(__pyx_t_23);
                    __Pyx_XGOTREF(__pyx_t_24);
                    __Pyx_XGOTREF(__pyx_t_25);
                    __Pyx_XGOTREF(__pyx_t_26);
                    __Pyx_XGOTREF(__pyx_t_27);
                    __Pyx_XGOTREF(__pyx_t_28);
                    __pyx_t_17 = __pyx_lineno; __pyx_t_21 = __pyx_clineno; __pyx_t_22 = __pyx_filename;
                    {
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    }
                    __Pyx_XGIVEREF(__pyx_t_26);
                    __Pyx_XGIVEREF(__pyx_t_27);
                    __Pyx_XGIVEREF(__pyx_t_28);
                    __Pyx_ExceptionReset(__pyx_t_26, __pyx_t_27, __pyx_t_28);
                    __Pyx_XGIVEREF(__pyx_t_23);
                    __Pyx_XGIVEREF(__pyx_t_24);
                    __Pyx_XGIVEREF(__pyx_t_25);
                    __Pyx_ErrRestore(__pyx_t_23, __pyx_t_24, __pyx_t_25);
                    __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0;
                    __pyx_lineno = __pyx_t_17; __pyx_clineno = __pyx_t_21; __pyx_filename = __pyx_t_22;
                    goto __pyx_L27_except_error;
                  }
                  __pyx_L39:;
                }
                __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                goto __pyx_L26_exception_handled;
              }
              goto __pyx_L27_except_error;

              /* "ws_package/controllers/activity_controller.py":2002
 *                             # Extract icon
 *                             app_icon = None
 *                             try:             # <<<<<<<<<<<<<<
 *                                 app_icon = app_listener.get_app_icon(current_app_name, current_app_path)
 *                             except Exception as e:
*/
              __pyx_L27_except_error:;
              __Pyx_XGIVEREF(__pyx_t_14);
              __Pyx_XGIVEREF(__pyx_t_15);
              __Pyx_XGIVEREF(__pyx_t_16);
              __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
              goto __pyx_L6_error;
              __pyx_L26_exception_handled:;
              __Pyx_XGIVEREF(__pyx_t_14);
              __Pyx_XGIVEREF(__pyx_t_15);
              __Pyx_XGIVEREF(__pyx_t_16);
              __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
              __pyx_L32_try_end:;
            }

            /* "ws_package/controllers/activity_controller.py":2008
 * 
 *                             # Update tracked values
 *                             self._current_active_app = current_app_name             # <<<<<<<<<<<<<<
 *                             self._current_active_app_path = current_app_path
 *                             self._current_active_app_icon = app_icon
*/
            if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 2008, __pyx_L6_error) }
            if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_active_app, __pyx_cur_scope->__pyx_v_current_app_name) < (0)) __PYX_ERR(0, 2008, __pyx_L6_error)

            /* "ws_package/controllers/activity_controller.py":2009
 *                             # Update tracked values
 *                             self._current_active_app = current_app_name
 *                             self._current_active_app_path = current_app_path             # <<<<<<<<<<<<<<
 *                             self._current_active_app_icon = app_icon
 * 
*/
            if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 2009, __pyx_L6_error) }
            if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_active_app_path, __pyx_cur_scope->__pyx_v_current_app_path) < (0)) __PYX_ERR(0, 2009, __pyx_L6_error)

            /* "ws_package/controllers/activity_controller.py":2010
 *                             self._current_active_app = current_app_name
 *                             self._current_active_app_path = current_app_path
 *                             self._current_active_app_icon = app_icon             # <<<<<<<<<<<<<<
 * 
 *                             # Send update to Electron
*/
            if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 2010, __pyx_L6_error) }
            if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_active_app_icon, __pyx_cur_scope->__pyx_v_app_icon) < (0)) __PYX_ERR(0, 2010, __pyx_L6_error)

            /* "ws_package/controllers/activity_controller.py":2013
 * 
 *                             # Send update to Electron
 *                             await self._send_active_app_update_to_electron(             # <<<<<<<<<<<<<<
 *                                 app_name=current_app_name,
 *                                 app_icon=app_icon
*/
            if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 2013, __pyx_L6_error) }
            __pyx_t_10 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self;
            __Pyx_INCREF(__pyx_t_10);

            /* "ws_package/controllers/activity_controller.py":2015
 *                             await self._send_active_app_update_to_electron(
 *                                 app_name=current_app_name,
 *                                 app_icon=app_icon             # <<<<<<<<<<<<<<
 *                             )
 * 
*/
            __pyx_t_3 = 0;
            {
              PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 2 : 0)] = {__pyx_t_10, NULL};
              __pyx_t_11 = __Pyx_MakeVectorcallBuilderKwds(2); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 2013, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_11);
              if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_app_name, __pyx_cur_scope->__pyx_v_current_app_name, __pyx_t_11, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 2013, __pyx_L6_error)
              if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_app_icon, __pyx_cur_scope->__pyx_v_app_icon, __pyx_t_11, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 2013, __pyx_L6_error)
              __pyx_t_1 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_send_active_app_update_to_elect, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_11);
              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
              if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2013, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_1);
            }
            __pyx_t_12 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (likely(__pyx_t_12 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_6);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
              __Pyx_XGIVEREF(__pyx_t_7);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
              __Pyx_XGIVEREF(__pyx_t_8);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 2;
              return __pyx_r;
              __pyx_L44_resume_from_await:;
              __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_6);
              __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_7);
              __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_8);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2013, __pyx_L6_error)
            } else if (likely(__pyx_t_12 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_DECREF(__pyx_r); __pyx_r = 0;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 2013, __pyx_L6_error)
            }

            /* "ws_package/controllers/activity_controller.py":1997
 * 
 *                         # Check if app has changed
 *                         if current_app_name != self._current_active_app:             # <<<<<<<<<<<<<<
 *                             logger.debug("Active app changed: %s -> %s", self._current_active_app, current_app_name)
 * 
*/
          }

          /* "ws_package/controllers/activity_controller.py":1991
 *                     )
 * 
 *                     if active_windows and len(active_windows) > 0:             # <<<<<<<<<<<<<<
 *                         current_app_data = active_windows[0]
 *                         current_app_name = current_app_data.get('app_display_name') or current_app_data.get('active_app', 'Unknown')
*/
        }

        /* "ws_package/controllers/activity_controller.py":2019
 * 
 *                     # Poll every 8s  frequent foreground-window checks add hook/IO overhead on Windows
 *                     await asyncio.sleep(8)             # <<<<<<<<<<<<<<
 * 
 *                 except Exception as e:
*/
        __pyx_t_11 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2019, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2019, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_3 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_2);
          assert(__pyx_t_11);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
          __pyx_t_3 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_11, __pyx_mstate_global->__pyx_int_8};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2019, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __pyx_t_12 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (likely(__pyx_t_12 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_6);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
          __Pyx_XGIVEREF(__pyx_t_7);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
          __Pyx_XGIVEREF(__pyx_t_8);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 3;
          return __pyx_r;
          __pyx_L45_resume_from_await:;
          __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_6);
          __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_7);
          __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_8);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2019, __pyx_L6_error)
        } else if (likely(__pyx_t_12 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_DECREF(__pyx_r); __pyx_r = 0;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 2019, __pyx_L6_error)
        }

        /* "ws_package/controllers/activity_controller.py":1979
 *             """Monitor active app changes and send updates to Electron for UI display."""
 *             while not stop_event.is_set():
 *                 try:             # <<<<<<<<<<<<<<
 *                     # Skip if tracking is stopped or on break
 *                     if not self.status or (getattr(self, 'break_id', 0) != 0 or self.is_break != 0):
*/
      }
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L13_try_end;
      __pyx_L6_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
      __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;

      /* "ws_package/controllers/activity_controller.py":2021
 *                     await asyncio.sleep(8)
 * 
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Error in monitor_active_app_for_ui: %s", e, exc_info=True)
 *                     await asyncio.sleep(2)  # Wait before retrying
*/
      __pyx_t_21 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
      if (__pyx_t_21) {
        __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity.monitor_active_app_for_ui", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_11) < 0) __PYX_ERR(0, 2021, __pyx_L8_except_error)
        __Pyx_XGOTREF(__pyx_t_1);
        __Pyx_XGOTREF(__pyx_t_2);
        __Pyx_XGOTREF(__pyx_t_11);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":2022
 * 
 *                 except Exception as e:
 *                     logger.error("Error in monitor_active_app_for_ui: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 *                     await asyncio.sleep(2)  # Wait before retrying
 * 
*/
          __pyx_t_20 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 2022, __pyx_L51_error)
          __Pyx_GOTREF(__pyx_t_18);
          __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 2022, __pyx_L51_error)
          __Pyx_GOTREF(__pyx_t_19);
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
          __pyx_t_3 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_19))) {
            __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_19);
            assert(__pyx_t_20);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_19);
            __Pyx_INCREF(__pyx_t_20);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_19, __pyx__function);
            __pyx_t_3 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_20, __pyx_mstate_global->__pyx_kp_u_Error_in_monitor_active_app_for, __pyx_cur_scope->__pyx_v_e};
            __pyx_t_18 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 2022, __pyx_L51_error)
            __Pyx_GOTREF(__pyx_t_18);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_18, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 2022, __pyx_L51_error)
            __pyx_t_10 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_19, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_18);
            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
            if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2022, __pyx_L51_error)
            __Pyx_GOTREF(__pyx_t_10);
          }
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

          /* "ws_package/controllers/activity_controller.py":2023
 *                 except Exception as e:
 *                     logger.error("Error in monitor_active_app_for_ui: %s", e, exc_info=True)
 *                     await asyncio.sleep(2)  # Wait before retrying             # <<<<<<<<<<<<<<
 * 
 *         # Create and track the active app UI monitoring task
*/
          __pyx_t_19 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 2023, __pyx_L51_error)
          __Pyx_GOTREF(__pyx_t_18);
          __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 2023, __pyx_L51_error)
          __Pyx_GOTREF(__pyx_t_20);
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
          __pyx_t_3 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_20))) {
            __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_20);
            assert(__pyx_t_19);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_20);
            __Pyx_INCREF(__pyx_t_19);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_20, __pyx__function);
            __pyx_t_3 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_19, __pyx_mstate_global->__pyx_int_2};
            __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_20, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
            __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
            if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2023, __pyx_L51_error)
            __Pyx_GOTREF(__pyx_t_10);
          }
          __pyx_t_12 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_10, &__pyx_r);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (likely(__pyx_t_12 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_1);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
            __Pyx_XGIVEREF(__pyx_t_2);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
            __Pyx_XGIVEREF(__pyx_t_6);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_6;
            __Pyx_XGIVEREF(__pyx_t_7);
            __pyx_cur_scope->__pyx_t_3 = __pyx_t_7;
            __Pyx_XGIVEREF(__pyx_t_8);
            __pyx_cur_scope->__pyx_t_4 = __pyx_t_8;
            __Pyx_XGIVEREF(__pyx_t_11);
            __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_SwapException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 4;
            return __pyx_r;
            __pyx_L53_resume_from_await:;
            __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_1);
            __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_2);
            __pyx_t_6 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_6);
            __pyx_t_7 = __pyx_cur_scope->__pyx_t_3;
            __pyx_cur_scope->__pyx_t_3 = 0;
            __Pyx_XGOTREF(__pyx_t_7);
            __pyx_t_8 = __pyx_cur_scope->__pyx_t_4;
            __pyx_cur_scope->__pyx_t_4 = 0;
            __Pyx_XGOTREF(__pyx_t_8);
            __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
            __pyx_cur_scope->__pyx_t_5 = 0;
            __Pyx_XGOTREF(__pyx_t_11);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2023, __pyx_L51_error)
          } else if (likely(__pyx_t_12 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_DECREF(__pyx_r); __pyx_r = 0;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 2023, __pyx_L51_error)
          }
        }

        /* "ws_package/controllers/activity_controller.py":2021
 *                     await asyncio.sleep(8)
 * 
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Error in monitor_active_app_for_ui: %s", e, exc_info=True)
 *                     await asyncio.sleep(2)  # Wait before retrying
*/
        /*finally:*/ {
          /*normal exit:*/{
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
            goto __pyx_L52;
          }
          __pyx_L51_error:;
          /*exception exit:*/{
            __Pyx_PyThreadState_assign
            __pyx_t_16 = 0; __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_28 = 0; __pyx_t_27 = 0; __pyx_t_26 = 0;
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
             __Pyx_ExceptionSwap(&__pyx_t_28, &__pyx_t_27, &__pyx_t_26);
            if ( unlikely(__Pyx_GetException(&__pyx_t_16, &__pyx_t_15, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_16, &__pyx_t_15, &__pyx_t_14);
            __Pyx_XGOTREF(__pyx_t_16);
            __Pyx_XGOTREF(__pyx_t_15);
            __Pyx_XGOTREF(__pyx_t_14);
            __Pyx_XGOTREF(__pyx_t_28);
            __Pyx_XGOTREF(__pyx_t_27);
            __Pyx_XGOTREF(__pyx_t_26);
            __pyx_t_21 = __pyx_lineno; __pyx_t_17 = __pyx_clineno; __pyx_t_29 = __pyx_filename;
            {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
            }
            __Pyx_XGIVEREF(__pyx_t_28);
            __Pyx_XGIVEREF(__pyx_t_27);
            __Pyx_XGIVEREF(__pyx_t_26);
            __Pyx_ExceptionReset(__pyx_t_28, __pyx_t_27, __pyx_t_26);
            __Pyx_XGIVEREF(__pyx_t_16);
            __Pyx_XGIVEREF(__pyx_t_15);
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_ErrRestore(__pyx_t_16, __pyx_t_15, __pyx_t_14);
            __pyx_t_16 = 0; __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_28 = 0; __pyx_t_27 = 0; __pyx_t_26 = 0;
            __pyx_lineno = __pyx_t_21; __pyx_clineno = __pyx_t_17; __pyx_filename = __pyx_t_29;
            goto __pyx_L8_except_error;
          }
          __pyx_L52:;
        }
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L7_exception_handled;
      }
      goto __pyx_L8_except_error;

      /* "ws_package/controllers/activity_controller.py":1979
 *             """Monitor active app changes and send updates to Electron for UI display."""
 *             while not stop_event.is_set():
 *                 try:             # <<<<<<<<<<<<<<
 *                     # Skip if tracking is stopped or on break
 *                     if not self.status or (getattr(self, 'break_id', 0) != 0 or self.is_break != 0):
*/
      __pyx_L8_except_error:;
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
      goto __pyx_L1_error;
      __pyx_L12_try_continue:;
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
      goto __pyx_L4_continue;
      __pyx_L7_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
      __pyx_L13_try_end:;
    }
    __pyx_L4_continue:;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":1976
 * 
 *         # Monitor active app changes for UI display (real-time updates)
 *         async def monitor_active_app_for_ui():             # <<<<<<<<<<<<<<
 *             """Monitor active app changes and send updates to Electron for UI display."""
 *             while not stop_event.is_set():
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("monitor_active_app_for_ui", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":2029
 *         self._background_tasks.add(active_app_ui_task)
 * 
 *         def active_app_ui_task_done_callback(task):             # <<<<<<<<<<<<<<
 *             """Handle active app UI task completion"""
 *             self._background_tasks.discard(task)
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_11active_app_ui_task_done_callback(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_10active_app_ui_task_done_callback, "Handle active app UI task completion");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_11active_app_ui_task_done_callback = {"active_app_ui_task_done_callback", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_11active_app_ui_task_done_callback, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_10active_app_ui_task_done_callback};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_11active_app_ui_task_done_callback(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_task = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[1] = {0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("active_app_ui_task_done_callback (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_task,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 2029, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 2029, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "active_app_ui_task_done_callback", 0) < (0)) __PYX_ERR(0, 2029, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("active_app_ui_task_done_callback", 1, 1, 1, i); __PYX_ERR(0, 2029, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 1)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 2029, __pyx_L3_error)
    }
    __pyx_v_task = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("active_app_ui_task_done_callback", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 2029, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity.active_app_ui_task_done_callback", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_10active_app_ui_task_done_callback(__pyx_self, __pyx_v_task);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_10active_app_ui_task_done_callback(PyObject *__pyx_self, PyObject *__pyx_v_task) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *__pyx_cur_scope;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *__pyx_outer_scope;
  PyObject *__pyx_v_e = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  size_t __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  int __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  char const *__pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("active_app_ui_task_done_callback", 0);
  __pyx_outer_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __pyx_cur_scope = __pyx_outer_scope;

  /* "ws_package/controllers/activity_controller.py":2031
 *         def active_app_ui_task_done_callback(task):
 *             """Handle active app UI task completion"""
 *             self._background_tasks.discard(task)             # <<<<<<<<<<<<<<
 *             if task.done():
 *                 try:
*/
  if (unlikely(!__pyx_cur_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 2031, __pyx_L1_error) }
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_background_tasks); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2031, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __pyx_t_3;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_4 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_task};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_discard, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2031, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":2032
 *             """Handle active app UI task completion"""
 *             self._background_tasks.discard(task)
 *             if task.done():             # <<<<<<<<<<<<<<
 *                 try:
 *                     task.result()
*/
  __pyx_t_3 = __pyx_v_task;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_4 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_done, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2032, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 2032, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "ws_package/controllers/activity_controller.py":2033
 *             self._background_tasks.discard(task)
 *             if task.done():
 *                 try:             # <<<<<<<<<<<<<<
 *                     task.result()
 *                 except asyncio.CancelledError:
*/
    {
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":2034
 *             if task.done():
 *                 try:
 *                     task.result()             # <<<<<<<<<<<<<<
 *                 except asyncio.CancelledError:
 *                     logger.debug("Background task monitor_active_app_for_ui was cancelled")
*/
        __pyx_t_3 = __pyx_v_task;
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_4 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
          __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_result, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2034, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":2033
 *             self._background_tasks.discard(task)
 *             if task.done():
 *                 try:             # <<<<<<<<<<<<<<
 *                     task.result()
 *                 except asyncio.CancelledError:
*/
      }
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L9_try_end;
      __pyx_L4_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "ws_package/controllers/activity_controller.py":2035
 *                 try:
 *                     task.result()
 *                 except asyncio.CancelledError:             # <<<<<<<<<<<<<<
 *                     logger.debug("Background task monitor_active_app_for_ui was cancelled")
 *                 except Exception as e:
*/
      __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_3, &__pyx_t_2);
      __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2035, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_CancelledError); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2035, __pyx_L6_except_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_11 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_10);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_ErrRestore(__pyx_t_1, __pyx_t_3, __pyx_t_2);
      __pyx_t_1 = 0; __pyx_t_3 = 0; __pyx_t_2 = 0;
      if (__pyx_t_11) {
        __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity.active_app_ui_task_done_callback", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_1) < 0) __PYX_ERR(0, 2035, __pyx_L6_except_error)
        __Pyx_XGOTREF(__pyx_t_2);
        __Pyx_XGOTREF(__pyx_t_3);
        __Pyx_XGOTREF(__pyx_t_1);

        /* "ws_package/controllers/activity_controller.py":2036
 *                     task.result()
 *                 except asyncio.CancelledError:
 *                     logger.debug("Background task monitor_active_app_for_ui was cancelled")             # <<<<<<<<<<<<<<
 *                 except Exception as e:
 *                     logger.error("Background task monitor_active_app_for_ui failed: %s", e, exc_info=True)
*/
        __pyx_t_9 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2036, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2036, __pyx_L6_except_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_13))) {
          __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_13);
          assert(__pyx_t_9);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_mstate_global->__pyx_kp_u_Background_task_monitor_active_a_3};
          __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2036, __pyx_L6_except_error)
          __Pyx_GOTREF(__pyx_t_10);
        }
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        goto __pyx_L5_exception_handled;
      }

      /* "ws_package/controllers/activity_controller.py":2037
 *                 except asyncio.CancelledError:
 *                     logger.debug("Background task monitor_active_app_for_ui was cancelled")
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Background task monitor_active_app_for_ui failed: %s", e, exc_info=True)
 * 
*/
      __pyx_t_11 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
      if (__pyx_t_11) {
        __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity.active_app_ui_task_done_callback", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_2) < 0) __PYX_ERR(0, 2037, __pyx_L6_except_error)
        __Pyx_XGOTREF(__pyx_t_1);
        __Pyx_XGOTREF(__pyx_t_3);
        __Pyx_XGOTREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __pyx_v_e = __pyx_t_3;
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":2038
 *                     logger.debug("Background task monitor_active_app_for_ui was cancelled")
 *                 except Exception as e:
 *                     logger.error("Background task monitor_active_app_for_ui failed: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *         active_app_ui_task.add_done_callback(active_app_ui_task_done_callback)
*/
          __pyx_t_13 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2038, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_9);
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 2038, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __pyx_t_4 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_12))) {
            __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12);
            assert(__pyx_t_13);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
            __pyx_t_4 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Background_task_monitor_active_a_4, __pyx_v_e};
            __pyx_t_9 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2038, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_9);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_9, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 2038, __pyx_L17_error)
            __pyx_t_10 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_9);
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2038, __pyx_L17_error)
            __Pyx_GOTREF(__pyx_t_10);
          }
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }

        /* "ws_package/controllers/activity_controller.py":2037
 *                 except asyncio.CancelledError:
 *                     logger.debug("Background task monitor_active_app_for_ui was cancelled")
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Background task monitor_active_app_for_ui failed: %s", e, exc_info=True)
 * 
*/
        /*finally:*/ {
          /*normal exit:*/{
            __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
            goto __pyx_L18;
          }
          __pyx_L17_error:;
          /*exception exit:*/{
            __Pyx_PyThreadState_declare
            __Pyx_PyThreadState_assign
            __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0;
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
             __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21);
            if ( unlikely(__Pyx_GetException(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18) < 0)) __Pyx_ErrFetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
            __Pyx_XGOTREF(__pyx_t_16);
            __Pyx_XGOTREF(__pyx_t_17);
            __Pyx_XGOTREF(__pyx_t_18);
            __Pyx_XGOTREF(__pyx_t_19);
            __Pyx_XGOTREF(__pyx_t_20);
            __Pyx_XGOTREF(__pyx_t_21);
            __pyx_t_11 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_15 = __pyx_filename;
            {
              __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
            }
            __Pyx_XGIVEREF(__pyx_t_19);
            __Pyx_XGIVEREF(__pyx_t_20);
            __Pyx_XGIVEREF(__pyx_t_21);
            __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21);
            __Pyx_XGIVEREF(__pyx_t_16);
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_ErrRestore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
            __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0;
            __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_15;
            goto __pyx_L6_except_error;
          }
          __pyx_L18:;
        }
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        goto __pyx_L5_exception_handled;
      }
      goto __pyx_L6_except_error;

      /* "ws_package/controllers/activity_controller.py":2033
 *             self._background_tasks.discard(task)
 *             if task.done():
 *                 try:             # <<<<<<<<<<<<<<
 *                     task.result()
 *                 except asyncio.CancelledError:
*/
      __pyx_L6_except_error:;
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
      goto __pyx_L1_error;
      __pyx_L5_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
      __pyx_L9_try_end:;
    }

    /* "ws_package/controllers/activity_controller.py":2032
 *             """Handle active app UI task completion"""
 *             self._background_tasks.discard(task)
 *             if task.done():             # <<<<<<<<<<<<<<
 *                 try:
 *                     task.result()
*/
  }

  /* "ws_package/controllers/activity_controller.py":2029
 *         self._background_tasks.add(active_app_ui_task)
 * 
 *         def active_app_ui_task_done_callback(task):             # <<<<<<<<<<<<<<
 *             """Handle active app UI task completion"""
 *             self._background_tasks.discard(task)
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity.active_app_ui_task_done_callback", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_14generator55(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":2454
 *                                     activity_percentage_entity.minute)
 *                                 # Remove from set after a delay to allow database write to complete
 *                                 async def remove_after_delay():             # <<<<<<<<<<<<<<
 *                                     await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                                     self._creating_activity_percentages.discard(activity_percentage_key)
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_13remove_after_delay(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_13remove_after_delay = {"remove_after_delay", (PyCFunction)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_13remove_after_delay, METH_NOARGS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_13remove_after_delay(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remove_after_delay (wrapper)", 0);
  __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_12remove_after_delay(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_12remove_after_delay(PyObject *__pyx_self) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remove_after_delay", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 2454, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_14generator55, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[26]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_remove_after_delay, __pyx_mstate_global->__pyx_n_u_ActivityController___start_devic_4, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 2454, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity.remove_after_delay", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_14generator55(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  __Pyx_PySendResult __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remove_after_delay", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L4_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 2454, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":2455
 *                                 # Remove from set after a delay to allow database write to complete
 *                                 async def remove_after_delay():
 *                                     await asyncio.sleep(2)  # Wait 2 seconds for DB write             # <<<<<<<<<<<<<<
 *                                     self._creating_activity_percentages.discard(activity_percentage_key)
 *                                 asyncio.create_task(remove_after_delay())
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2455, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2455, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_int_2};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2455, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_6 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_6 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L4_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2455, __pyx_L1_error)
  } else if (likely(__pyx_t_6 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 2455, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":2456
 *                                 async def remove_after_delay():
 *                                     await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                                     self._creating_activity_percentages.discard(activity_percentage_key)             # <<<<<<<<<<<<<<
 *                                 asyncio.create_task(remove_after_delay())
 *                             else:
*/
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 2456, __pyx_L1_error) }
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_creating_activity_percentages); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2456, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __pyx_t_2;
  __Pyx_INCREF(__pyx_t_4);
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_activity_percentage_key)) { __Pyx_RaiseClosureNameError("activity_percentage_key"); __PYX_ERR(0, 2456, __pyx_L1_error) }
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_cur_scope->__pyx_outer_scope->__pyx_v_activity_percentage_key};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_discard, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2456, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":2454
 *                                     activity_percentage_entity.minute)
 *                                 # Remove from set after a delay to allow database write to complete
 *                                 async def remove_after_delay():             # <<<<<<<<<<<<<<
 *                                     await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                                     self._creating_activity_percentages.discard(activity_percentage_key)
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("remove_after_delay", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_17generator56(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":2644
 *                         # Check for idle detection after break interval is saved
 *                         # NEW REQUIREMENT: Check for 2 consecutive idle intervals and trigger popup
 *                         async def check_idle_after_delay():             # <<<<<<<<<<<<<<
 *                             await asyncio.sleep(1)  # Wait for DB write to complete
 *                             logger.info("[IdleDetection] Checking for idle after break interval save")
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_16check_idle_after_delay(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_16check_idle_after_delay = {"check_idle_after_delay", (PyCFunction)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_16check_idle_after_delay, METH_NOARGS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_16check_idle_after_delay(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("check_idle_after_delay (wrapper)", 0);
  __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_15check_idle_after_delay(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_15check_idle_after_delay(PyObject *__pyx_self) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("check_idle_after_delay", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 2644, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_17generator56, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[27]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_check_idle_after_delay, __pyx_mstate_global->__pyx_n_u_ActivityController___start_devic_5, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 2644, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity.check_idle_after_delay", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_17generator56(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  __Pyx_PySendResult __pyx_t_6;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("check_idle_after_delay", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L4_resume_from_await;
    case 2: goto __pyx_L6_resume_from_await;
    case 3: goto __pyx_L7_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 2644, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":2645
 *                         # NEW REQUIREMENT: Check for 2 consecutive idle intervals and trigger popup
 *                         async def check_idle_after_delay():
 *                             await asyncio.sleep(1)  # Wait for DB write to complete             # <<<<<<<<<<<<<<
 *                             logger.info("[IdleDetection] Checking for idle after break interval save")
 *                             if await self.check_idle_detection():
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2645, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2645, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_int_1};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2645, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_6 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_6 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L4_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2645, __pyx_L1_error)
  } else if (likely(__pyx_t_6 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 2645, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":2646
 *                         async def check_idle_after_delay():
 *                             await asyncio.sleep(1)  # Wait for DB write to complete
 *                             logger.info("[IdleDetection] Checking for idle after break interval save")             # <<<<<<<<<<<<<<
 *                             if await self.check_idle_detection():
 *                                 logger.info("[IdleDetection] Idle detected - triggering popup")
*/
  __pyx_t_4 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2646, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2646, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    assert(__pyx_t_4);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_IdleDetection_Checking_for_idle};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2646, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":2647
 *                             await asyncio.sleep(1)  # Wait for DB write to complete
 *                             logger.info("[IdleDetection] Checking for idle after break interval save")
 *                             if await self.check_idle_detection():             # <<<<<<<<<<<<<<
 *                                 logger.info("[IdleDetection] Idle detected - triggering popup")
 *                                 await self.arise_idle_popup()
*/
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 2647, __pyx_L1_error) }
  __pyx_t_3 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_check_idle_detection, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2647, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_6 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_6 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 2;
    return __pyx_r;
    __pyx_L6_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2647, __pyx_L1_error)
    __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
  } else if (likely(__pyx_t_6 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __pyx_t_1 = __pyx_r; __pyx_r = NULL;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 2647, __pyx_L1_error)
  }
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 2647, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_7) {

    /* "ws_package/controllers/activity_controller.py":2648
 *                             logger.info("[IdleDetection] Checking for idle after break interval save")
 *                             if await self.check_idle_detection():
 *                                 logger.info("[IdleDetection] Idle detected - triggering popup")             # <<<<<<<<<<<<<<
 *                                 await self.arise_idle_popup()
 *                             else:
*/
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2648, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2648, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_IdleDetection_Idle_detected_tri};
      __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2648, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "ws_package/controllers/activity_controller.py":2649
 *                             if await self.check_idle_detection():
 *                                 logger.info("[IdleDetection] Idle detected - triggering popup")
 *                                 await self.arise_idle_popup()             # <<<<<<<<<<<<<<
 *                             else:
 *                                 logger.debug("[IdleDetection] No idle detected after break interval save")
*/
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 2649, __pyx_L1_error) }
    __pyx_t_2 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_5 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
      __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_arise_idle_popup, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2649, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __pyx_t_6 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (likely(__pyx_t_6 == PYGEN_NEXT)) {
      __Pyx_GOTREF(__pyx_r);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 3;
      return __pyx_r;
      __pyx_L7_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2649, __pyx_L1_error)
    } else if (likely(__pyx_t_6 == PYGEN_RETURN)) {
      __Pyx_GOTREF(__pyx_r);
      __Pyx_DECREF(__pyx_r); __pyx_r = 0;
    } else {
      __Pyx_XGOTREF(__pyx_r);
      __PYX_ERR(0, 2649, __pyx_L1_error)
    }

    /* "ws_package/controllers/activity_controller.py":2647
 *                             await asyncio.sleep(1)  # Wait for DB write to complete
 *                             logger.info("[IdleDetection] Checking for idle after break interval save")
 *                             if await self.check_idle_detection():             # <<<<<<<<<<<<<<
 *                                 logger.info("[IdleDetection] Idle detected - triggering popup")
 *                                 await self.arise_idle_popup()
*/
    goto __pyx_L5;
  }

  /* "ws_package/controllers/activity_controller.py":2651
 *                                 await self.arise_idle_popup()
 *                             else:
 *                                 logger.debug("[IdleDetection] No idle detected after break interval save")             # <<<<<<<<<<<<<<
 *                         asyncio.create_task(check_idle_after_delay())
 *                     finally:
*/
  /*else*/ {
    __pyx_t_2 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2651, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2651, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      assert(__pyx_t_2);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_IdleDetection_No_idle_detected};
      __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2651, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L5:;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":2644
 *                         # Check for idle detection after break interval is saved
 *                         # NEW REQUIREMENT: Check for 2 consecutive idle intervals and trigger popup
 *                         async def check_idle_after_delay():             # <<<<<<<<<<<<<<
 *                             await asyncio.sleep(1)  # Wait for DB write to complete
 *                             logger.info("[IdleDetection] Checking for idle after break interval save")
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("check_idle_after_delay", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_23generator58(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":2655
 *                     finally:
 *                         # Remove from set after a delay to allow database write to complete
 *                         async def remove_after_delay():             # <<<<<<<<<<<<<<
 *                             await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                             self._creating_intervals.discard(interval_key)
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_22remove_after_delay(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_22remove_after_delay = {"remove_after_delay", (PyCFunction)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_22remove_after_delay, METH_NOARGS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_22remove_after_delay(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remove_after_delay (wrapper)", 0);
  __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_21remove_after_delay(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_21remove_after_delay(PyObject *__pyx_self) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remove_after_delay", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 2655, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_23generator58, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[28]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_remove_after_delay, __pyx_mstate_global->__pyx_n_u_ActivityController___start_devic_4, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 2655, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity.remove_after_delay", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_23generator58(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  __Pyx_PySendResult __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remove_after_delay", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L4_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 2655, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":2656
 *                         # Remove from set after a delay to allow database write to complete
 *                         async def remove_after_delay():
 *                             await asyncio.sleep(2)  # Wait 2 seconds for DB write             # <<<<<<<<<<<<<<
 *                             self._creating_intervals.discard(interval_key)
 *                         asyncio.create_task(remove_after_delay())
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2656, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2656, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_int_2};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2656, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_6 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_6 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L4_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2656, __pyx_L1_error)
  } else if (likely(__pyx_t_6 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 2656, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":2657
 *                         async def remove_after_delay():
 *                             await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                             self._creating_intervals.discard(interval_key)             # <<<<<<<<<<<<<<
 *                         asyncio.create_task(remove_after_delay())
 *                 elif in_range and self.status == True:
*/
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 2657, __pyx_L1_error) }
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_creating_intervals); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2657, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __pyx_t_2;
  __Pyx_INCREF(__pyx_t_4);
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_interval_key)) { __Pyx_RaiseClosureNameError("interval_key"); __PYX_ERR(0, 2657, __pyx_L1_error) }
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_cur_scope->__pyx_outer_scope->__pyx_v_interval_key};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_discard, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2657, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":2655
 *                     finally:
 *                         # Remove from set after a delay to allow database write to complete
 *                         async def remove_after_delay():             # <<<<<<<<<<<<<<
 *                             await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                             self._creating_intervals.discard(interval_key)
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("remove_after_delay", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_20generator57(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_19remove_after_delay(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_19remove_after_delay = {"remove_after_delay", (PyCFunction)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_19remove_after_delay, METH_NOARGS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_19remove_after_delay(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remove_after_delay (wrapper)", 0);
  __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_18remove_after_delay(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_18remove_after_delay(PyObject *__pyx_self) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remove_after_delay", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 2655, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_20generator57, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[29]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_remove_after_delay, __pyx_mstate_global->__pyx_n_u_ActivityController___start_devic_4, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 2655, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity.remove_after_delay", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_20generator57(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  __Pyx_PySendResult __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remove_after_delay", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L4_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 2655, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":2656
 *                         # Remove from set after a delay to allow database write to complete
 *                         async def remove_after_delay():
 *                             await asyncio.sleep(2)  # Wait 2 seconds for DB write             # <<<<<<<<<<<<<<
 *                             self._creating_intervals.discard(interval_key)
 *                         asyncio.create_task(remove_after_delay())
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2656, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2656, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_int_2};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2656, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_6 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_6 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L4_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2656, __pyx_L1_error)
  } else if (likely(__pyx_t_6 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 2656, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":2657
 *                         async def remove_after_delay():
 *                             await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                             self._creating_intervals.discard(interval_key)             # <<<<<<<<<<<<<<
 *                         asyncio.create_task(remove_after_delay())
 *                 elif in_range and self.status == True:
*/
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 2657, __pyx_L1_error) }
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_creating_intervals); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2657, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __pyx_t_2;
  __Pyx_INCREF(__pyx_t_4);
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_interval_key)) { __Pyx_RaiseClosureNameError("interval_key"); __PYX_ERR(0, 2657, __pyx_L1_error) }
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_cur_scope->__pyx_outer_scope->__pyx_v_interval_key};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_discard, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2657, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":2655
 *                     finally:
 *                         # Remove from set after a delay to allow database write to complete
 *                         async def remove_after_delay():             # <<<<<<<<<<<<<<
 *                             await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                             self._creating_intervals.discard(interval_key)
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("remove_after_delay", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_29generator60(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":2849
 *                         finally:
 *                             # Remove from set after a delay to allow database write to complete
 *                             async def remove_after_delay():             # <<<<<<<<<<<<<<
 *                                 await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                                 self._creating_intervals.discard(interval_key)
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_28remove_after_delay(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_28remove_after_delay = {"remove_after_delay", (PyCFunction)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_28remove_after_delay, METH_NOARGS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_28remove_after_delay(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remove_after_delay (wrapper)", 0);
  __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_27remove_after_delay(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_27remove_after_delay(PyObject *__pyx_self) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remove_after_delay", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 2849, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_29generator60, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[30]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_remove_after_delay, __pyx_mstate_global->__pyx_n_u_ActivityController___start_devic_4, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 2849, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity.remove_after_delay", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_29generator60(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  __Pyx_PySendResult __pyx_t_6;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remove_after_delay", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L4_resume_from_await;
    case 2: goto __pyx_L6_resume_from_await;
    case 3: goto __pyx_L7_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 2849, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":2850
 *                             # Remove from set after a delay to allow database write to complete
 *                             async def remove_after_delay():
 *                                 await asyncio.sleep(2)  # Wait 2 seconds for DB write             # <<<<<<<<<<<<<<
 *                                 self._creating_intervals.discard(interval_key)
 * 
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2850, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2850, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_int_2};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2850, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_6 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_6 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L4_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2850, __pyx_L1_error)
  } else if (likely(__pyx_t_6 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 2850, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":2851
 *                             async def remove_after_delay():
 *                                 await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                                 self._creating_intervals.discard(interval_key)             # <<<<<<<<<<<<<<
 * 
 *                                 # Check for idle detection after interval is saved and DB write completed
*/
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 2851, __pyx_L1_error) }
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_creating_intervals); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2851, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __pyx_t_2;
  __Pyx_INCREF(__pyx_t_4);
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_interval_key)) { __Pyx_RaiseClosureNameError("interval_key"); __PYX_ERR(0, 2851, __pyx_L1_error) }
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_cur_scope->__pyx_outer_scope->__pyx_v_interval_key};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_discard, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2851, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":2855
 *                                 # Check for idle detection after interval is saved and DB write completed
 *                                 # NEW REQUIREMENT: Check for 2 consecutive idle intervals and trigger popup
 *                                 logger.info("[IdleDetection] Checking for idle after interval save (in range)")             # <<<<<<<<<<<<<<
 *                                 if await self.check_idle_detection():
 *                                     logger.info("[IdleDetection] Idle detected - triggering popup")
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2855, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2855, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_IdleDetection_Checking_for_idle_2};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2855, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":2856
 *                                 # NEW REQUIREMENT: Check for 2 consecutive idle intervals and trigger popup
 *                                 logger.info("[IdleDetection] Checking for idle after interval save (in range)")
 *                                 if await self.check_idle_detection():             # <<<<<<<<<<<<<<
 *                                     logger.info("[IdleDetection] Idle detected - triggering popup")
 *                                     await self.arise_idle_popup()
*/
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 2856, __pyx_L1_error) }
  __pyx_t_3 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_check_idle_detection, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2856, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_6 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_6 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 2;
    return __pyx_r;
    __pyx_L6_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2856, __pyx_L1_error)
    __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
  } else if (likely(__pyx_t_6 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __pyx_t_1 = __pyx_r; __pyx_r = NULL;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 2856, __pyx_L1_error)
  }
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 2856, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_7) {

    /* "ws_package/controllers/activity_controller.py":2857
 *                                 logger.info("[IdleDetection] Checking for idle after interval save (in range)")
 *                                 if await self.check_idle_detection():
 *                                     logger.info("[IdleDetection] Idle detected - triggering popup")             # <<<<<<<<<<<<<<
 *                                     await self.arise_idle_popup()
 *                                 else:
*/
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2857, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2857, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_IdleDetection_Idle_detected_tri};
      __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2857, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "ws_package/controllers/activity_controller.py":2858
 *                                 if await self.check_idle_detection():
 *                                     logger.info("[IdleDetection] Idle detected - triggering popup")
 *                                     await self.arise_idle_popup()             # <<<<<<<<<<<<<<
 *                                 else:
 *                                     logger.debug("[IdleDetection] No idle detected after interval save")
*/
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 2858, __pyx_L1_error) }
    __pyx_t_4 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self;
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_5 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
      __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_arise_idle_popup, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2858, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __pyx_t_6 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (likely(__pyx_t_6 == PYGEN_NEXT)) {
      __Pyx_GOTREF(__pyx_r);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 3;
      return __pyx_r;
      __pyx_L7_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2858, __pyx_L1_error)
    } else if (likely(__pyx_t_6 == PYGEN_RETURN)) {
      __Pyx_GOTREF(__pyx_r);
      __Pyx_DECREF(__pyx_r); __pyx_r = 0;
    } else {
      __Pyx_XGOTREF(__pyx_r);
      __PYX_ERR(0, 2858, __pyx_L1_error)
    }

    /* "ws_package/controllers/activity_controller.py":2856
 *                                 # NEW REQUIREMENT: Check for 2 consecutive idle intervals and trigger popup
 *                                 logger.info("[IdleDetection] Checking for idle after interval save (in range)")
 *                                 if await self.check_idle_detection():             # <<<<<<<<<<<<<<
 *                                     logger.info("[IdleDetection] Idle detected - triggering popup")
 *                                     await self.arise_idle_popup()
*/
    goto __pyx_L5;
  }

  /* "ws_package/controllers/activity_controller.py":2860
 *                                     await self.arise_idle_popup()
 *                                 else:
 *                                     logger.debug("[IdleDetection] No idle detected after interval save")             # <<<<<<<<<<<<<<
 *                             asyncio.create_task(remove_after_delay())
 *                     else:
*/
  /*else*/ {
    __pyx_t_4 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2860, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2860, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
      assert(__pyx_t_4);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_IdleDetection_No_idle_detected_2};
      __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2860, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L5:;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":2849
 *                         finally:
 *                             # Remove from set after a delay to allow database write to complete
 *                             async def remove_after_delay():             # <<<<<<<<<<<<<<
 *                                 await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                                 self._creating_intervals.discard(interval_key)
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("remove_after_delay", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_26generator59(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_25remove_after_delay(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_25remove_after_delay = {"remove_after_delay", (PyCFunction)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_25remove_after_delay, METH_NOARGS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_25remove_after_delay(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remove_after_delay (wrapper)", 0);
  __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_24remove_after_delay(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_24remove_after_delay(PyObject *__pyx_self) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("remove_after_delay", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 2849, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_26generator59, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[31]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_remove_after_delay, __pyx_mstate_global->__pyx_n_u_ActivityController___start_devic_4, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 2849, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity.remove_after_delay", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_26generator59(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  __Pyx_PySendResult __pyx_t_6;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("remove_after_delay", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L4_resume_from_await;
    case 2: goto __pyx_L6_resume_from_await;
    case 3: goto __pyx_L7_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 2849, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":2850
 *                             # Remove from set after a delay to allow database write to complete
 *                             async def remove_after_delay():
 *                                 await asyncio.sleep(2)  # Wait 2 seconds for DB write             # <<<<<<<<<<<<<<
 *                                 self._creating_intervals.discard(interval_key)
 * 
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2850, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2850, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_int_2};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2850, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_6 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_6 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L4_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2850, __pyx_L1_error)
  } else if (likely(__pyx_t_6 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 2850, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":2851
 *                             async def remove_after_delay():
 *                                 await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                                 self._creating_intervals.discard(interval_key)             # <<<<<<<<<<<<<<
 * 
 *                                 # Check for idle detection after interval is saved and DB write completed
*/
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 2851, __pyx_L1_error) }
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_creating_intervals); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2851, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __pyx_t_2;
  __Pyx_INCREF(__pyx_t_4);
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_interval_key)) { __Pyx_RaiseClosureNameError("interval_key"); __PYX_ERR(0, 2851, __pyx_L1_error) }
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_cur_scope->__pyx_outer_scope->__pyx_v_interval_key};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_discard, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2851, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":2855
 *                                 # Check for idle detection after interval is saved and DB write completed
 *                                 # NEW REQUIREMENT: Check for 2 consecutive idle intervals and trigger popup
 *                                 logger.info("[IdleDetection] Checking for idle after interval save (in range)")             # <<<<<<<<<<<<<<
 *                                 if await self.check_idle_detection():
 *                                     logger.info("[IdleDetection] Idle detected - triggering popup")
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2855, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2855, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_IdleDetection_Checking_for_idle_2};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2855, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":2856
 *                                 # NEW REQUIREMENT: Check for 2 consecutive idle intervals and trigger popup
 *                                 logger.info("[IdleDetection] Checking for idle after interval save (in range)")
 *                                 if await self.check_idle_detection():             # <<<<<<<<<<<<<<
 *                                     logger.info("[IdleDetection] Idle detected - triggering popup")
 *                                     await self.arise_idle_popup()
*/
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 2856, __pyx_L1_error) }
  __pyx_t_3 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_check_idle_detection, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2856, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_6 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_6 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 2;
    return __pyx_r;
    __pyx_L6_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2856, __pyx_L1_error)
    __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
  } else if (likely(__pyx_t_6 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __pyx_t_1 = __pyx_r; __pyx_r = NULL;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 2856, __pyx_L1_error)
  }
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 2856, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_7) {

    /* "ws_package/controllers/activity_controller.py":2857
 *                                 logger.info("[IdleDetection] Checking for idle after interval save (in range)")
 *                                 if await self.check_idle_detection():
 *                                     logger.info("[IdleDetection] Idle detected - triggering popup")             # <<<<<<<<<<<<<<
 *                                     await self.arise_idle_popup()
 *                                 else:
*/
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2857, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2857, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_IdleDetection_Idle_detected_tri};
      __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2857, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "ws_package/controllers/activity_controller.py":2858
 *                                 if await self.check_idle_detection():
 *                                     logger.info("[IdleDetection] Idle detected - triggering popup")
 *                                     await self.arise_idle_popup()             # <<<<<<<<<<<<<<
 *                                 else:
 *                                     logger.debug("[IdleDetection] No idle detected after interval save")
*/
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 2858, __pyx_L1_error) }
    __pyx_t_4 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self;
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_5 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
      __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_arise_idle_popup, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2858, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __pyx_t_6 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (likely(__pyx_t_6 == PYGEN_NEXT)) {
      __Pyx_GOTREF(__pyx_r);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 3;
      return __pyx_r;
      __pyx_L7_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2858, __pyx_L1_error)
    } else if (likely(__pyx_t_6 == PYGEN_RETURN)) {
      __Pyx_GOTREF(__pyx_r);
      __Pyx_DECREF(__pyx_r); __pyx_r = 0;
    } else {
      __Pyx_XGOTREF(__pyx_r);
      __PYX_ERR(0, 2858, __pyx_L1_error)
    }

    /* "ws_package/controllers/activity_controller.py":2856
 *                                 # NEW REQUIREMENT: Check for 2 consecutive idle intervals and trigger popup
 *                                 logger.info("[IdleDetection] Checking for idle after interval save (in range)")
 *                                 if await self.check_idle_detection():             # <<<<<<<<<<<<<<
 *                                     logger.info("[IdleDetection] Idle detected - triggering popup")
 *                                     await self.arise_idle_popup()
*/
    goto __pyx_L5;
  }

  /* "ws_package/controllers/activity_controller.py":2860
 *                                     await self.arise_idle_popup()
 *                                 else:
 *                                     logger.debug("[IdleDetection] No idle detected after interval save")             # <<<<<<<<<<<<<<
 *                             asyncio.create_task(remove_after_delay())
 *                     else:
*/
  /*else*/ {
    __pyx_t_4 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2860, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2860, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
      assert(__pyx_t_4);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_IdleDetection_No_idle_detected_2};
      __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2860, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L5:;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":2849
 *                         finally:
 *                             # Remove from set after a delay to allow database write to complete
 *                             async def remove_after_delay():             # <<<<<<<<<<<<<<
 *                                 await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                                 self._creating_intervals.discard(interval_key)
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("remove_after_delay", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_32generator61(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":2897
 *                     # Check for idle detection after out-of-range interval is saved
 *                     # NEW REQUIREMENT: Check for 2 consecutive idle intervals and trigger popup
 *                     async def check_idle_after_delay():             # <<<<<<<<<<<<<<
 *                         await asyncio.sleep(1)  # Wait for DB write to complete
 *                         logger.info("[IdleDetection] Checking for idle after interval save (out of range)")
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_31check_idle_after_delay(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_31check_idle_after_delay = {"check_idle_after_delay", (PyCFunction)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_31check_idle_after_delay, METH_NOARGS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_31check_idle_after_delay(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("check_idle_after_delay (wrapper)", 0);
  __pyx_kwvalues = __Pyx_KwValues_VARARGS(__pyx_args, __pyx_nargs);
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_30check_idle_after_delay(__pyx_self);

  /* function exit code */
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_30check_idle_after_delay(PyObject *__pyx_self) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("check_idle_after_delay", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 2897, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *) __Pyx_CyFunction_GetClosure(__pyx_self);
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_32generator61, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[32]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_check_idle_after_delay, __pyx_mstate_global->__pyx_n_u_ActivityController___start_devic_5, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 2897, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity.check_idle_after_delay", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_32generator61(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  __Pyx_PySendResult __pyx_t_6;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("check_idle_after_delay", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L4_resume_from_await;
    case 2: goto __pyx_L6_resume_from_await;
    case 3: goto __pyx_L7_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 2897, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":2898
 *                     # NEW REQUIREMENT: Check for 2 consecutive idle intervals and trigger popup
 *                     async def check_idle_after_delay():
 *                         await asyncio.sleep(1)  # Wait for DB write to complete             # <<<<<<<<<<<<<<
 *                         logger.info("[IdleDetection] Checking for idle after interval save (out of range)")
 *                         if await self.check_idle_detection():
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2898, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2898, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_int_1};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2898, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_6 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_6 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L4_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2898, __pyx_L1_error)
  } else if (likely(__pyx_t_6 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 2898, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":2899
 *                     async def check_idle_after_delay():
 *                         await asyncio.sleep(1)  # Wait for DB write to complete
 *                         logger.info("[IdleDetection] Checking for idle after interval save (out of range)")             # <<<<<<<<<<<<<<
 *                         if await self.check_idle_detection():
 *                             logger.info("[IdleDetection] Idle detected - triggering popup")
*/
  __pyx_t_4 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2899, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    assert(__pyx_t_4);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_IdleDetection_Checking_for_idle_3};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2899, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":2900
 *                         await asyncio.sleep(1)  # Wait for DB write to complete
 *                         logger.info("[IdleDetection] Checking for idle after interval save (out of range)")
 *                         if await self.check_idle_detection():             # <<<<<<<<<<<<<<
 *                             logger.info("[IdleDetection] Idle detected - triggering popup")
 *                             await self.arise_idle_popup()
*/
  if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 2900, __pyx_L1_error) }
  __pyx_t_3 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_check_idle_detection, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2900, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_6 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_6 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 2;
    return __pyx_r;
    __pyx_L6_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2900, __pyx_L1_error)
    __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
  } else if (likely(__pyx_t_6 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __pyx_t_1 = __pyx_r; __pyx_r = NULL;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 2900, __pyx_L1_error)
  }
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 2900, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_7) {

    /* "ws_package/controllers/activity_controller.py":2901
 *                         logger.info("[IdleDetection] Checking for idle after interval save (out of range)")
 *                         if await self.check_idle_detection():
 *                             logger.info("[IdleDetection] Idle detected - triggering popup")             # <<<<<<<<<<<<<<
 *                             await self.arise_idle_popup()
 *                         else:
*/
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2901, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2901, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_IdleDetection_Idle_detected_tri};
      __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2901, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

    /* "ws_package/controllers/activity_controller.py":2902
 *                         if await self.check_idle_detection():
 *                             logger.info("[IdleDetection] Idle detected - triggering popup")
 *                             await self.arise_idle_popup()             # <<<<<<<<<<<<<<
 *                         else:
 *                             logger.debug("[IdleDetection] No idle detected after interval save")
*/
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_self)) { __Pyx_RaiseClosureNameError("self"); __PYX_ERR(0, 2902, __pyx_L1_error) }
    __pyx_t_2 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_self;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_5 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
      __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_arise_idle_popup, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2902, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __pyx_t_6 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (likely(__pyx_t_6 == PYGEN_NEXT)) {
      __Pyx_GOTREF(__pyx_r);
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 3;
      return __pyx_r;
      __pyx_L7_resume_from_await:;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2902, __pyx_L1_error)
    } else if (likely(__pyx_t_6 == PYGEN_RETURN)) {
      __Pyx_GOTREF(__pyx_r);
      __Pyx_DECREF(__pyx_r); __pyx_r = 0;
    } else {
      __Pyx_XGOTREF(__pyx_r);
      __PYX_ERR(0, 2902, __pyx_L1_error)
    }

    /* "ws_package/controllers/activity_controller.py":2900
 *                         await asyncio.sleep(1)  # Wait for DB write to complete
 *                         logger.info("[IdleDetection] Checking for idle after interval save (out of range)")
 *                         if await self.check_idle_detection():             # <<<<<<<<<<<<<<
 *                             logger.info("[IdleDetection] Idle detected - triggering popup")
 *                             await self.arise_idle_popup()
*/
    goto __pyx_L5;
  }

  /* "ws_package/controllers/activity_controller.py":2904
 *                             await self.arise_idle_popup()
 *                         else:
 *                             logger.debug("[IdleDetection] No idle detected after interval save")             # <<<<<<<<<<<<<<
 *                     asyncio.create_task(check_idle_after_delay())
 * 
*/
  /*else*/ {
    __pyx_t_2 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2904, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2904, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
      assert(__pyx_t_2);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_IdleDetection_No_idle_detected_2};
      __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2904, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  }
  __pyx_L5:;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":2897
 *                     # Check for idle detection after out-of-range interval is saved
 *                     # NEW REQUIREMENT: Check for 2 consecutive idle intervals and trigger popup
 *                     async def check_idle_after_delay():             # <<<<<<<<<<<<<<
 *                         await asyncio.sleep(1)  # Wait for DB write to complete
 *                         logger.info("[IdleDetection] Checking for idle after interval save (out of range)")
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("check_idle_after_delay", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":1686
 *         logger.info("Minute activity timer stopped")
 * 
 *     async def __start_device_activity(self, user_entity:UserEntity, stop_event):             # <<<<<<<<<<<<<<
 * 
 *         # Update start_date to actual timer start time (when user clicks Start)
*/

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_102generator20(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  size_t __pyx_t_7;
  int __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  char const *__pyx_t_17;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  char const *__pyx_t_24;
  char const *__pyx_t_25;
  __Pyx_PySendResult __pyx_t_26;
  char const *__pyx_t_27;
  char const *__pyx_t_28;
  Py_ssize_t __pyx_t_29;
  char const *__pyx_t_30;
  PyObject *__pyx_t_31 = NULL;
  PyObject *__pyx_t_32 = NULL;
  PyObject *__pyx_t_33 = NULL;
  PyObject *__pyx_t_34 = NULL;
  PyObject *__pyx_t_35 = NULL;
  PyObject *__pyx_t_36 = NULL;
  PyObject *__pyx_t_37 = NULL;
  PyObject *__pyx_t_38 = NULL;
  PyObject *__pyx_t_39 = NULL;
  char const *__pyx_t_40;
  char const *__pyx_t_41;
  char const *__pyx_t_42;
  char const *__pyx_t_43;
  PyObject *(*__pyx_t_44)(PyObject *);
  char const *__pyx_t_45;
  PyObject *__pyx_t_46 = NULL;
  PyObject *__pyx_t_47 = NULL;
  PyObject *__pyx_t_48 = NULL;
  char const *__pyx_t_49;
  char const *__pyx_t_50;
  char const *__pyx_t_51;
  double __pyx_t_52;
  char const *__pyx_t_53;
  PyObject *(*__pyx_t_54)(PyObject *);
  char const *__pyx_t_55;
  char const *__pyx_t_56;
  char const *__pyx_t_57;
  char const *__pyx_t_58;
  char const *__pyx_t_59;
  char const *__pyx_t_60;
  char const *__pyx_t_61;
  char const *__pyx_t_62;
  char const *__pyx_t_63;
  char const *__pyx_t_64;
  char const *__pyx_t_65;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("__start_device_activity", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L74_resume_from_await;
    case 2: goto __pyx_L76_resume_from_await;
    case 3: goto __pyx_L85_resume_from_await;
    case 4: goto __pyx_L99_resume_from_await;
    case 5: goto __pyx_L137_resume_from_await;
    case 6: goto __pyx_L138_resume_from_await;
    case 7: goto __pyx_L150_resume_from_await;
    case 8: goto __pyx_L160_resume_from_await;
    case 9: goto __pyx_L162_resume_from_await;
    case 10: goto __pyx_L166_resume_from_await;
    case 11: goto __pyx_L167_resume_from_await;
    case 12: goto __pyx_L180_resume_from_await;
    case 13: goto __pyx_L191_resume_from_await;
    case 14: goto __pyx_L212_resume_from_await;
    case 15: goto __pyx_L275_resume_from_await;
    case 16: goto __pyx_L277_resume_from_await;
    case 17: goto __pyx_L281_resume_from_await;
    case 18: goto __pyx_L292_resume_from_await;
    case 19: goto __pyx_L304_resume_from_await;
    case 20: goto __pyx_L307_resume_from_await;
    case 21: goto __pyx_L311_resume_from_await;
    case 22: goto __pyx_L342_resume_from_await;
    case 23: goto __pyx_L386_resume_from_await;
    case 24: goto __pyx_L396_resume_from_await;
    case 25: goto __pyx_L397_resume_from_await;
    case 26: goto __pyx_L398_resume_from_await;
    case 27: goto __pyx_L400_resume_from_await;
    case 28: goto __pyx_L422_resume_from_await;
    case 29: goto __pyx_L426_resume_from_await;
    case 30: goto __pyx_L430_resume_from_await;
    case 31: goto __pyx_L438_resume_from_await;
    case 32: goto __pyx_L447_resume_from_await;
    case 33: goto __pyx_L448_resume_from_await;
    case 34: goto __pyx_L459_resume_from_await;
    case 35: goto __pyx_L484_resume_from_await;
    case 36: goto __pyx_L508_resume_from_await;
    case 37: goto __pyx_L512_resume_from_await;
    case 38: goto __pyx_L516_resume_from_await;
    case 39: goto __pyx_L525_resume_from_await;
    case 40: goto __pyx_L579_resume_from_await;
    case 41: goto __pyx_L593_resume_from_await;
    case 42: goto __pyx_L595_resume_from_await;
    case 43: goto __pyx_L615_resume_from_await;
    case 44: goto __pyx_L616_resume_from_await;
    case 45: goto __pyx_L643_resume_from_await;
    case 46: goto __pyx_L662_resume_from_await;
    case 47: goto __pyx_L709_resume_from_await;
    case 48: goto __pyx_L723_resume_from_await;
    case 49: goto __pyx_L743_resume_from_await;
    case 50: goto __pyx_L744_resume_from_await;
    case 51: goto __pyx_L771_resume_from_await;
    case 52: goto __pyx_L775_resume_from_await;
    case 53: goto __pyx_L782_resume_from_await;
    case 54: goto __pyx_L790_resume_from_await;
    case 55: goto __pyx_L794_resume_from_await;
    case 56: goto __pyx_L808_resume_from_await;
    case 57: goto __pyx_L840_resume_from_await;
    case 58: goto __pyx_L849_resume_from_await;
    case 59: goto __pyx_L853_resume_from_await;
    case 60: goto __pyx_L854_resume_from_await;
    case 61: goto __pyx_L858_resume_from_await;
    case 62: goto __pyx_L859_resume_from_await;
    case 63: goto __pyx_L860_resume_from_await;
    case 64: goto __pyx_L872_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 1686, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":1689
 * 
 *         # Update start_date to actual timer start time (when user clicks Start)
 *         self.start_date = datetime.datetime.now().replace(microsecond=0)             # <<<<<<<<<<<<<<
 *         # Clear session start so payload "start" uses start_date (full timer start, not post-break)
 *         self.current_session_start_time = None
*/
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1689, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1689, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_4 = __pyx_t_6;
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_7 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
    __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1689, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  }
  __pyx_t_2 = __pyx_t_3;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_7 = 0;
  {
    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_2, NULL};
    __pyx_t_6 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1689, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_6, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 1689, __pyx_L1_error)
    __pyx_t_1 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1689, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_start_date, __pyx_t_1) < (0)) __PYX_ERR(0, 1689, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":1691
 *         self.start_date = datetime.datetime.now().replace(microsecond=0)
 *         # Clear session start so payload "start" uses start_date (full timer start, not post-break)
 *         self.current_session_start_time = None             # <<<<<<<<<<<<<<
 *         self._activity_log_payload_start = None
 * 
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_session_start_time, Py_None) < (0)) __PYX_ERR(0, 1691, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":1692
 *         # Clear session start so payload "start" uses start_date (full timer start, not post-break)
 *         self.current_session_start_time = None
 *         self._activity_log_payload_start = None             # <<<<<<<<<<<<<<
 * 
 *         # CRITICAL: Ensure status is True when device activity starts (unless force_stop is set)
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_log_payload_start, Py_None) < (0)) __PYX_ERR(0, 1692, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":1698
 *         # This is especially important after break stops when monitoring resumes
 *         # Only set to True if force_stop is not True (tracking is not explicitly disabled)
 *         if (not hasattr(self, 'status') or self.status is False) and not getattr(self, 'force_stop', False):             # <<<<<<<<<<<<<<
 *             # Set status to True as fallback - status thread will update it later based on API response
 *             self.status = True
*/
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_9 = __Pyx_HasAttr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1698, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_10 = (!__pyx_t_9);
  if (!__pyx_t_10) {
  } else {
    goto __pyx_L6_next_and;
  }
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1698, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_10 = (__pyx_t_1 == Py_False);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_10) {
  } else {
    __pyx_t_8 = __pyx_t_10;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_L6_next_and:;
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_GetAttr3(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_force_stop, Py_False); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1698, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 1698, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_9 = (!__pyx_t_10);
  __pyx_t_8 = __pyx_t_9;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_8) {

    /* "ws_package/controllers/activity_controller.py":1700
 *         if (not hasattr(self, 'status') or self.status is False) and not getattr(self, 'force_stop', False):
 *             # Set status to True as fallback - status thread will update it later based on API response
 *             self.status = True             # <<<<<<<<<<<<<<
 *             logger.info("Set status=True as fallback when starting device activity (status thread will update it based on API response)")
 * 
*/
    if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status, Py_True) < (0)) __PYX_ERR(0, 1700, __pyx_L1_error)

    /* "ws_package/controllers/activity_controller.py":1701
 *             # Set status to True as fallback - status thread will update it later based on API response
 *             self.status = True
 *             logger.info("Set status=True as fallback when starting device activity (status thread will update it based on API response)")             # <<<<<<<<<<<<<<
 * 
 *         # CRITICAL: Always restart device listeners when device activity starts
*/
    __pyx_t_1 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1701, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1701, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
      assert(__pyx_t_1);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Set_status_True_as_fallback_when};
      __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1701, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "ws_package/controllers/activity_controller.py":1698
 *         # This is especially important after break stops when monitoring resumes
 *         # Only set to True if force_stop is not True (tracking is not explicitly disabled)
 *         if (not hasattr(self, 'status') or self.status is False) and not getattr(self, 'force_stop', False):             # <<<<<<<<<<<<<<
 *             # Set status to True as fallback - status thread will update it later based on API response
 *             self.status = True
*/
  }

  /* "ws_package/controllers/activity_controller.py":1706
 *         # This ensures listeners are working after breaks, restarts, or any other scenario
 *         # Reset the tracking resumed flag so the loop can also check and log
 *         if hasattr(self, 'device_listener') and self.device_listener:             # <<<<<<<<<<<<<<
 *             try:
 *                 # Reset flag so the loop can also handle it
*/
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_9 = __Pyx_HasAttr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_device_listener); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1706, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_9) {
  } else {
    __pyx_t_8 = __pyx_t_9;
    goto __pyx_L9_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_device_listener); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1706, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 1706, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_8 = __pyx_t_9;
  __pyx_L9_bool_binop_done:;
  if (__pyx_t_8) {

    /* "ws_package/controllers/activity_controller.py":1707
 *         # Reset the tracking resumed flag so the loop can also check and log
 *         if hasattr(self, 'device_listener') and self.device_listener:
 *             try:             # <<<<<<<<<<<<<<
 *                 # Reset flag so the loop can also handle it
 *                 self._tracking_resumed_logged = False
*/
    {
      __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":1709
 *             try:
 *                 # Reset flag so the loop can also handle it
 *                 self._tracking_resumed_logged = False             # <<<<<<<<<<<<<<
 * 
 *                 logger.info("Restarting device listeners at start of device activity...")
*/
        if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_tracking_resumed_logged, Py_False) < (0)) __PYX_ERR(0, 1709, __pyx_L11_error)

        /* "ws_package/controllers/activity_controller.py":1711
 *                 self._tracking_resumed_logged = False
 * 
 *                 logger.info("Restarting device listeners at start of device activity...")             # <<<<<<<<<<<<<<
 *                 self.device_listener.restart_listeners()
 *                 logger.info("Device listeners restarted at start of device activity - keyboard and mouse events should now be logged")
*/
        __pyx_t_2 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1711, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1711, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
          assert(__pyx_t_2);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Restarting_device_listeners_at_s};
          __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1711, __pyx_L11_error)
          __Pyx_GOTREF(__pyx_t_3);
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "ws_package/controllers/activity_controller.py":1712
 * 
 *                 logger.info("Restarting device listeners at start of device activity...")
 *                 self.device_listener.restart_listeners()             # <<<<<<<<<<<<<<
 *                 logger.info("Device listeners restarted at start of device activity - keyboard and mouse events should now be logged")
 *             except Exception as e:
*/
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_device_listener); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1712, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_6 = __pyx_t_2;
        __Pyx_INCREF(__pyx_t_6);
        __pyx_t_7 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
          __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_restart_listeners, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1712, __pyx_L11_error)
          __Pyx_GOTREF(__pyx_t_3);
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "ws_package/controllers/activity_controller.py":1713
 *                 logger.info("Restarting device listeners at start of device activity...")
 *                 self.device_listener.restart_listeners()
 *                 logger.info("Device listeners restarted at start of device activity - keyboard and mouse events should now be logged")             # <<<<<<<<<<<<<<
 *             except Exception as e:
 *                 logger.error("Error restarting device listeners at start of device activity: %s", e, exc_info=True)
*/
        __pyx_t_2 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1713, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1713, __pyx_L11_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
          assert(__pyx_t_2);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Device_listeners_restarted_at_st};
          __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1713, __pyx_L11_error)
          __Pyx_GOTREF(__pyx_t_3);
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "ws_package/controllers/activity_controller.py":1707
 *         # Reset the tracking resumed flag so the loop can also check and log
 *         if hasattr(self, 'device_listener') and self.device_listener:
 *             try:             # <<<<<<<<<<<<<<
 *                 # Reset flag so the loop can also handle it
 *                 self._tracking_resumed_logged = False
*/
      }
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      goto __pyx_L16_try_end;
      __pyx_L11_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":1714
 *                 self.device_listener.restart_listeners()
 *                 logger.info("Device listeners restarted at start of device activity - keyboard and mouse events should now be logged")
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 logger.error("Error restarting device listeners at start of device activity: %s", e, exc_info=True)
 * 
*/
      __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
      if (__pyx_t_14) {
        __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_1, &__pyx_t_2) < 0) __PYX_ERR(0, 1714, __pyx_L13_except_error)
        __Pyx_XGOTREF(__pyx_t_3);
        __Pyx_XGOTREF(__pyx_t_1);
        __Pyx_XGOTREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_v_e = __pyx_t_1;
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":1715
 *                 logger.info("Device listeners restarted at start of device activity - keyboard and mouse events should now be logged")
 *             except Exception as e:
 *                 logger.error("Error restarting device listeners at start of device activity: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *         # Start the platform-appropriate time monitor when device activity begins.
*/
          __pyx_t_4 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1715, __pyx_L22_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1715, __pyx_L22_error)
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_7 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_15))) {
            __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_15);
            assert(__pyx_t_4);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
            __pyx_t_7 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Error_restarting_device_listener, __pyx_cur_scope->__pyx_v_e};
            __pyx_t_5 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1715, __pyx_L22_error)
            __Pyx_GOTREF(__pyx_t_5);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_5, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 1715, __pyx_L22_error)
            __pyx_t_6 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_5);
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1715, __pyx_L22_error)
            __Pyx_GOTREF(__pyx_t_6);
          }
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }

        /* "ws_package/controllers/activity_controller.py":1714
 *                 self.device_listener.restart_listeners()
 *                 logger.info("Device listeners restarted at start of device activity - keyboard and mouse events should now be logged")
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 logger.error("Error restarting device listeners at start of device activity: %s", e, exc_info=True)
 * 
*/
        /*finally:*/ {
          /*normal exit:*/{
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
            goto __pyx_L23;
          }
          __pyx_L22_error:;
          /*exception exit:*/{
            __Pyx_PyThreadState_assign
            __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
             __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
            if ( unlikely(__Pyx_GetException(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20) < 0)) __Pyx_ErrFetch(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20);
            __Pyx_XGOTREF(__pyx_t_18);
            __Pyx_XGOTREF(__pyx_t_19);
            __Pyx_XGOTREF(__pyx_t_20);
            __Pyx_XGOTREF(__pyx_t_21);
            __Pyx_XGOTREF(__pyx_t_22);
            __Pyx_XGOTREF(__pyx_t_23);
            __pyx_t_14 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_17 = __pyx_filename;
            {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
            }
            __Pyx_XGIVEREF(__pyx_t_21);
            __Pyx_XGIVEREF(__pyx_t_22);
            __Pyx_XGIVEREF(__pyx_t_23);
            __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_23);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_XGIVEREF(__pyx_t_19);
            __Pyx_XGIVEREF(__pyx_t_20);
            __Pyx_ErrRestore(__pyx_t_18, __pyx_t_19, __pyx_t_20);
            __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
            __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_17;
            goto __pyx_L13_except_error;
          }
          __pyx_L23:;
        }
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        goto __pyx_L12_exception_handled;
      }
      goto __pyx_L13_except_error;

      /* "ws_package/controllers/activity_controller.py":1707
 *         # Reset the tracking resumed flag so the loop can also check and log
 *         if hasattr(self, 'device_listener') and self.device_listener:
 *             try:             # <<<<<<<<<<<<<<
 *                 # Reset flag so the loop can also handle it
 *                 self._tracking_resumed_logged = False
*/
      __pyx_L13_except_error:;
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      goto __pyx_L1_error;
      __pyx_L12_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      __pyx_L16_try_end:;
    }

    /* "ws_package/controllers/activity_controller.py":1706
 *         # This ensures listeners are working after breaks, restarts, or any other scenario
 *         # Reset the tracking resumed flag so the loop can also check and log
 *         if hasattr(self, 'device_listener') and self.device_listener:             # <<<<<<<<<<<<<<
 *             try:
 *                 # Reset flag so the loop can also handle it
*/
  }

  /* "ws_package/controllers/activity_controller.py":1721
 *         # macOS/Linux: CrossPlatformTimeMonitor (monotonic-drift).
 *         if (
 *             hasattr(self, 'activity_manager')             # <<<<<<<<<<<<<<
 *             and self.activity_manager.time_monitor
 *             and self._timezone_checks_enabled(user_entity)
*/
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_9 = __Pyx_HasAttr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_activity_manager); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1721, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_9) {
  } else {
    __pyx_t_8 = __pyx_t_9;
    goto __pyx_L29_bool_binop_done;
  }

  /* "ws_package/controllers/activity_controller.py":1722
 *         if (
 *             hasattr(self, 'activity_manager')
 *             and self.activity_manager.time_monitor             # <<<<<<<<<<<<<<
 *             and self._timezone_checks_enabled(user_entity)
 *         ):
*/
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_manager); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1722, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_time_monitor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1722, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 1722, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_9) {
  } else {
    __pyx_t_8 = __pyx_t_9;
    goto __pyx_L29_bool_binop_done;
  }

  /* "ws_package/controllers/activity_controller.py":1723
 *             hasattr(self, 'activity_manager')
 *             and self.activity_manager.time_monitor
 *             and self._timezone_checks_enabled(user_entity)             # <<<<<<<<<<<<<<
 *         ):
 *             try:
*/
  __pyx_t_2 = __pyx_cur_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_7 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_user_entity};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_timezone_checks_enabled, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1723, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 1723, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_8 = __pyx_t_9;
  __pyx_L29_bool_binop_done:;

  /* "ws_package/controllers/activity_controller.py":1720
 *         # Windows: OptimizedWindowsTimeMonitor (registry-based).
 *         # macOS/Linux: CrossPlatformTimeMonitor (monotonic-drift).
 *         if (             # <<<<<<<<<<<<<<
 *             hasattr(self, 'activity_manager')
 *             and self.activity_manager.time_monitor
*/
  if (__pyx_t_8) {

    /* "ws_package/controllers/activity_controller.py":1725
 *             and self._timezone_checks_enabled(user_entity)
 *         ):
 *             try:             # <<<<<<<<<<<<<<
 *                 logger.info("Starting time monitor (%s)...", platform.system())
 *                 def _on_time_error(error_type=None):
*/
    {
      __Pyx_ExceptionSave(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_11);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":1726
 *         ):
 *             try:
 *                 logger.info("Starting time monitor (%s)...", platform.system())             # <<<<<<<<<<<<<<
 *                 def _on_time_error(error_type=None):
 *                     if not self._timezone_checks_enabled():
*/
        __pyx_t_2 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1726, __pyx_L32_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1726, __pyx_L32_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_15 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1726, __pyx_L32_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_system); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1726, __pyx_L32_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_4);
          assert(__pyx_t_15);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_15);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL};
          __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1726, __pyx_L32_error)
          __Pyx_GOTREF(__pyx_t_3);
        }
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
          assert(__pyx_t_2);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Starting_time_monitor_s, __pyx_t_3};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1726, __pyx_L32_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":1727
 *             try:
 *                 logger.info("Starting time monitor (%s)...", platform.system())
 *                 def _on_time_error(error_type=None):             # <<<<<<<<<<<<<<
 *                     if not self._timezone_checks_enabled():
 *                         logger.info(
*/
        __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_1_on_time_error, 0, __pyx_mstate_global->__pyx_n_u_ActivityController___start_devic_6, ((PyObject*)__pyx_cur_scope), __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[33])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1727, __pyx_L32_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_1, __pyx_mstate_global->__pyx_tuple[21]);
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_v__on_time_error = __pyx_t_1;
        __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":1745
 *                             "not treating as timezone mismatch"
 *                         )
 *                 self.activity_manager.time_monitor.set_on_time_error_callback(_on_time_error)             # <<<<<<<<<<<<<<
 *                 self.activity_manager.time_monitor.start_monitoring()
 *                 logger.info("Time monitor started  timezone and datetime changes will be detected")
*/
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_manager); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1745, __pyx_L32_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_time_monitor); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1745, __pyx_L32_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_6 = __pyx_t_2;
        __Pyx_INCREF(__pyx_t_6);
        __pyx_t_7 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_cur_scope->__pyx_v__on_time_error};
          __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_set_on_time_error_callback, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1745, __pyx_L32_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":1746
 *                         )
 *                 self.activity_manager.time_monitor.set_on_time_error_callback(_on_time_error)
 *                 self.activity_manager.time_monitor.start_monitoring()             # <<<<<<<<<<<<<<
 *                 logger.info("Time monitor started  timezone and datetime changes will be detected")
 *             except Exception as e:
*/
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_manager); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1746, __pyx_L32_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_time_monitor); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1746, __pyx_L32_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_2 = __pyx_t_3;
        __Pyx_INCREF(__pyx_t_2);
        __pyx_t_7 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
          __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_start_monitoring, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1746, __pyx_L32_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":1747
 *                 self.activity_manager.time_monitor.set_on_time_error_callback(_on_time_error)
 *                 self.activity_manager.time_monitor.start_monitoring()
 *                 logger.info("Time monitor started  timezone and datetime changes will be detected")             # <<<<<<<<<<<<<<
 *             except Exception as e:
 *                 logger.error("Error starting time monitor: %s", e, exc_info=True)
*/
        __pyx_t_3 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1747, __pyx_L32_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1747, __pyx_L32_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
          assert(__pyx_t_3);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Time_monitor_started_timezone_an};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1747, __pyx_L32_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":1725
 *             and self._timezone_checks_enabled(user_entity)
 *         ):
 *             try:             # <<<<<<<<<<<<<<
 *                 logger.info("Starting time monitor (%s)...", platform.system())
 *                 def _on_time_error(error_type=None):
*/
      }
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      goto __pyx_L37_try_end;
      __pyx_L32_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":1748
 *                 self.activity_manager.time_monitor.start_monitoring()
 *                 logger.info("Time monitor started  timezone and datetime changes will be detected")
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 logger.error("Error starting time monitor: %s", e, exc_info=True)
 *         elif hasattr(self, 'activity_manager') and self.activity_manager.time_monitor:
*/
      __pyx_t_16 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
      if (__pyx_t_16) {
        __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_6, &__pyx_t_3) < 0) __PYX_ERR(0, 1748, __pyx_L34_except_error)
        __Pyx_XGOTREF(__pyx_t_1);
        __Pyx_XGOTREF(__pyx_t_6);
        __Pyx_XGOTREF(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_6);
        __pyx_cur_scope->__pyx_v_e = __pyx_t_6;
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":1749
 *                 logger.info("Time monitor started  timezone and datetime changes will be detected")
 *             except Exception as e:
 *                 logger.error("Error starting time monitor: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 *         elif hasattr(self, 'activity_manager') and self.activity_manager.time_monitor:
 *             logger.info(
*/
          __pyx_t_4 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1749, __pyx_L43_error)
          __Pyx_GOTREF(__pyx_t_15);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1749, __pyx_L43_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __pyx_t_7 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_5))) {
            __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
            assert(__pyx_t_4);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
            __pyx_t_7 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Error_starting_time_monitor_s, __pyx_cur_scope->__pyx_v_e};
            __pyx_t_15 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1749, __pyx_L43_error)
            __Pyx_GOTREF(__pyx_t_15);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_15, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 1749, __pyx_L43_error)
            __pyx_t_2 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_15);
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1749, __pyx_L43_error)
            __Pyx_GOTREF(__pyx_t_2);
          }
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        }

        /* "ws_package/controllers/activity_controller.py":1748
 *                 self.activity_manager.time_monitor.start_monitoring()
 *                 logger.info("Time monitor started  timezone and datetime changes will be detected")
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 logger.error("Error starting time monitor: %s", e, exc_info=True)
 *         elif hasattr(self, 'activity_manager') and self.activity_manager.time_monitor:
*/
        /*finally:*/ {
          /*normal exit:*/{
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
            goto __pyx_L44;
          }
          __pyx_L43_error:;
          /*exception exit:*/{
            __Pyx_PyThreadState_assign
            __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0;
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
             __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_19, &__pyx_t_18);
            if ( unlikely(__Pyx_GetException(&__pyx_t_23, &__pyx_t_22, &__pyx_t_21) < 0)) __Pyx_ErrFetch(&__pyx_t_23, &__pyx_t_22, &__pyx_t_21);
            __Pyx_XGOTREF(__pyx_t_23);
            __Pyx_XGOTREF(__pyx_t_22);
            __Pyx_XGOTREF(__pyx_t_21);
            __Pyx_XGOTREF(__pyx_t_20);
            __Pyx_XGOTREF(__pyx_t_19);
            __Pyx_XGOTREF(__pyx_t_18);
            __pyx_t_16 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_24 = __pyx_filename;
            {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
            }
            __Pyx_XGIVEREF(__pyx_t_20);
            __Pyx_XGIVEREF(__pyx_t_19);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_19, __pyx_t_18);
            __Pyx_XGIVEREF(__pyx_t_23);
            __Pyx_XGIVEREF(__pyx_t_22);
            __Pyx_XGIVEREF(__pyx_t_21);
            __Pyx_ErrRestore(__pyx_t_23, __pyx_t_22, __pyx_t_21);
            __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0;
            __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_24;
            goto __pyx_L34_except_error;
          }
          __pyx_L44:;
        }
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        goto __pyx_L33_exception_handled;
      }
      goto __pyx_L34_except_error;

      /* "ws_package/controllers/activity_controller.py":1725
 *             and self._timezone_checks_enabled(user_entity)
 *         ):
 *             try:             # <<<<<<<<<<<<<<
 *                 logger.info("Starting time monitor (%s)...", platform.system())
 *                 def _on_time_error(error_type=None):
*/
      __pyx_L34_except_error:;
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_12, __pyx_t_11);
      goto __pyx_L1_error;
      __pyx_L33_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_12, __pyx_t_11);
      __pyx_L37_try_end:;
    }

    /* "ws_package/controllers/activity_controller.py":1720
 *         # Windows: OptimizedWindowsTimeMonitor (registry-based).
 *         # macOS/Linux: CrossPlatformTimeMonitor (monotonic-drift).
 *         if (             # <<<<<<<<<<<<<<
 *             hasattr(self, 'activity_manager')
 *             and self.activity_manager.time_monitor
*/
    goto __pyx_L28;
  }

  /* "ws_package/controllers/activity_controller.py":1750
 *             except Exception as e:
 *                 logger.error("Error starting time monitor: %s", e, exc_info=True)
 *         elif hasattr(self, 'activity_manager') and self.activity_manager.time_monitor:             # <<<<<<<<<<<<<<
 *             logger.info(
 *                 "Timezone/time monitor disabled by login timezone_preference=1"
*/
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_9 = __Pyx_HasAttr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_activity_manager); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 1750, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_9) {
  } else {
    __pyx_t_8 = __pyx_t_9;
    goto __pyx_L49_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_manager); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1750, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_time_monitor); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1750, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 1750, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_8 = __pyx_t_9;
  __pyx_L49_bool_binop_done:;
  if (__pyx_t_8) {

    /* "ws_package/controllers/activity_controller.py":1751
 *                 logger.error("Error starting time monitor: %s", e, exc_info=True)
 *         elif hasattr(self, 'activity_manager') and self.activity_manager.time_monitor:
 *             logger.info(             # <<<<<<<<<<<<<<
 *                 "Timezone/time monitor disabled by login timezone_preference=1"
 *             )
*/
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1751, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1751, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Timezone_time_monitor_disabled_b};
      __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1751, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "ws_package/controllers/activity_controller.py":1754
 *                 "Timezone/time monitor disabled by login timezone_preference=1"
 *             )
 *             try:             # <<<<<<<<<<<<<<
 *                 self.activity_manager.time_monitor.stop_monitoring()
 *             except Exception as e:
*/
    {
      __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":1755
 *             )
 *             try:
 *                 self.activity_manager.time_monitor.stop_monitoring()             # <<<<<<<<<<<<<<
 *             except Exception as e:
 *                 logger.warning("Could not stop disabled time monitor: %s", e)
*/
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_manager); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1755, __pyx_L51_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_time_monitor); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1755, __pyx_L51_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_2 = __pyx_t_1;
        __Pyx_INCREF(__pyx_t_2);
        __pyx_t_7 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
          __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_stop_monitoring, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1755, __pyx_L51_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "ws_package/controllers/activity_controller.py":1754
 *                 "Timezone/time monitor disabled by login timezone_preference=1"
 *             )
 *             try:             # <<<<<<<<<<<<<<
 *                 self.activity_manager.time_monitor.stop_monitoring()
 *             except Exception as e:
*/
      }
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      goto __pyx_L56_try_end;
      __pyx_L51_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":1756
 *             try:
 *                 self.activity_manager.time_monitor.stop_monitoring()
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 logger.warning("Could not stop disabled time monitor: %s", e)
 * 
*/
      __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
      if (__pyx_t_14) {
        __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_1, &__pyx_t_2) < 0) __PYX_ERR(0, 1756, __pyx_L53_except_error)
        __Pyx_XGOTREF(__pyx_t_6);
        __Pyx_XGOTREF(__pyx_t_1);
        __Pyx_XGOTREF(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_v_e = __pyx_t_1;
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":1757
 *                 self.activity_manager.time_monitor.stop_monitoring()
 *             except Exception as e:
 *                 logger.warning("Could not stop disabled time monitor: %s", e)             # <<<<<<<<<<<<<<
 * 
 *         # CRITICAL FIX: Ensure org settings (especially timezone) are loaded
*/
          __pyx_t_5 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1757, __pyx_L62_error)
          __Pyx_GOTREF(__pyx_t_15);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1757, __pyx_L62_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __pyx_t_7 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_4))) {
            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
            assert(__pyx_t_5);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
            __pyx_t_7 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Could_not_stop_disabled_time_mon, __pyx_cur_scope->__pyx_v_e};
            __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1757, __pyx_L62_error)
            __Pyx_GOTREF(__pyx_t_3);
          }
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        }

        /* "ws_package/controllers/activity_controller.py":1756
 *             try:
 *                 self.activity_manager.time_monitor.stop_monitoring()
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 logger.warning("Could not stop disabled time monitor: %s", e)
 * 
*/
        /*finally:*/ {
          /*normal exit:*/{
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
            goto __pyx_L63;
          }
          __pyx_L62_error:;
          /*exception exit:*/{
            __Pyx_PyThreadState_assign
            __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
             __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
            if ( unlikely(__Pyx_GetException(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20) < 0)) __Pyx_ErrFetch(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20);
            __Pyx_XGOTREF(__pyx_t_18);
            __Pyx_XGOTREF(__pyx_t_19);
            __Pyx_XGOTREF(__pyx_t_20);
            __Pyx_XGOTREF(__pyx_t_21);
            __Pyx_XGOTREF(__pyx_t_22);
            __Pyx_XGOTREF(__pyx_t_23);
            __pyx_t_14 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_25 = __pyx_filename;
            {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
            }
            __Pyx_XGIVEREF(__pyx_t_21);
            __Pyx_XGIVEREF(__pyx_t_22);
            __Pyx_XGIVEREF(__pyx_t_23);
            __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_23);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_XGIVEREF(__pyx_t_19);
            __Pyx_XGIVEREF(__pyx_t_20);
            __Pyx_ErrRestore(__pyx_t_18, __pyx_t_19, __pyx_t_20);
            __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
            __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_25;
            goto __pyx_L53_except_error;
          }
          __pyx_L63:;
        }
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        goto __pyx_L52_exception_handled;
      }
      goto __pyx_L53_except_error;

      /* "ws_package/controllers/activity_controller.py":1754
 *                 "Timezone/time monitor disabled by login timezone_preference=1"
 *             )
 *             try:             # <<<<<<<<<<<<<<
 *                 self.activity_manager.time_monitor.stop_monitoring()
 *             except Exception as e:
*/
      __pyx_L53_except_error:;
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      goto __pyx_L1_error;
      __pyx_L52_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      __pyx_L56_try_end:;
    }

    /* "ws_package/controllers/activity_controller.py":1750
 *             except Exception as e:
 *                 logger.error("Error starting time monitor: %s", e, exc_info=True)
 *         elif hasattr(self, 'activity_manager') and self.activity_manager.time_monitor:             # <<<<<<<<<<<<<<
 *             logger.info(
 *                 "Timezone/time monitor disabled by login timezone_preference=1"
*/
  }
  __pyx_L28:;

  /* "ws_package/controllers/activity_controller.py":1760
 * 
 *         # CRITICAL FIX: Ensure org settings (especially timezone) are loaded
 *         try:             # <<<<<<<<<<<<<<
 *             logger.info("Fetching latest org settings before starting activity loop...")
 *             logger.debug("[Timing][Python] Fetching org settings in __start_device_activity")
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
    __Pyx_XGOTREF(__pyx_t_13);
    __Pyx_XGOTREF(__pyx_t_12);
    __Pyx_XGOTREF(__pyx_t_11);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":1761
 *         # CRITICAL FIX: Ensure org settings (especially timezone) are loaded
 *         try:
 *             logger.info("Fetching latest org settings before starting activity loop...")             # <<<<<<<<<<<<<<
 *             logger.debug("[Timing][Python] Fetching org settings in __start_device_activity")
 *             await self.update_interval(user_entity)
*/
      __pyx_t_1 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1761, __pyx_L68_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1761, __pyx_L68_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_7 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
        assert(__pyx_t_1);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
        __pyx_t_7 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Fetching_latest_org_settings_bef};
        __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1761, __pyx_L68_error)
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "ws_package/controllers/activity_controller.py":1762
 *         try:
 *             logger.info("Fetching latest org settings before starting activity loop...")
 *             logger.debug("[Timing][Python] Fetching org settings in __start_device_activity")             # <<<<<<<<<<<<<<
 *             await self.update_interval(user_entity)
 *             logger.debug("[Timing][Python] Org settings fetched. Timezone: %s", self.org_api_timezone)
*/
      __pyx_t_3 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1762, __pyx_L68_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1762, __pyx_L68_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_7 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
        assert(__pyx_t_3);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
        __pyx_t_7 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Timing_Python_Fetching_org_sett};
        __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1762, __pyx_L68_error)
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "ws_package/controllers/activity_controller.py":1763
 *             logger.info("Fetching latest org settings before starting activity loop...")
 *             logger.debug("[Timing][Python] Fetching org settings in __start_device_activity")
 *             await self.update_interval(user_entity)             # <<<<<<<<<<<<<<
 *             logger.debug("[Timing][Python] Org settings fetched. Timezone: %s", self.org_api_timezone)
 * 
*/
      __pyx_t_6 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_6);
      __pyx_t_7 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_cur_scope->__pyx_v_user_entity};
        __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_update_interval, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1763, __pyx_L68_error)
        __Pyx_GOTREF(__pyx_t_2);
      }
      __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_2, &__pyx_r);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (likely(__pyx_t_26 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_11);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
        __Pyx_XGIVEREF(__pyx_t_12);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
        __Pyx_XGIVEREF(__pyx_t_13);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 1;
        return __pyx_r;
        __pyx_L74_resume_from_await:;
        __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_11);
        __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_12);
        __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_13);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1763, __pyx_L68_error)
      } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_DECREF(__pyx_r); __pyx_r = 0;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 1763, __pyx_L68_error)
      }

      /* "ws_package/controllers/activity_controller.py":1764
 *             logger.debug("[Timing][Python] Fetching org settings in __start_device_activity")
 *             await self.update_interval(user_entity)
 *             logger.debug("[Timing][Python] Org settings fetched. Timezone: %s", self.org_api_timezone)             # <<<<<<<<<<<<<<
 * 
 *             # If timezone is still missing (e.g. offline or update_interval failed), try DB
*/
      __pyx_t_6 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1764, __pyx_L68_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1764, __pyx_L68_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_org_api_timezone); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1764, __pyx_L68_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_7 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
        assert(__pyx_t_6);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
        __pyx_t_7 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Timing_Python_Org_settings_fetc, __pyx_t_3};
        __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1764, __pyx_L68_error)
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "ws_package/controllers/activity_controller.py":1767
 * 
 *             # If timezone is still missing (e.g. offline or update_interval failed), try DB
 *             if self.org_api_timezone is None:             # <<<<<<<<<<<<<<
 *                 logger.warning("org_api_timezone is None after update_interval, trying local DB...")
 *                 logger.debug("[Timing][Python] org_api_timezone is None, trying DB...")
*/
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_org_api_timezone); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1767, __pyx_L68_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_8 = (__pyx_t_2 == Py_None);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__pyx_t_8) {

        /* "ws_package/controllers/activity_controller.py":1768
 *             # If timezone is still missing (e.g. offline or update_interval failed), try DB
 *             if self.org_api_timezone is None:
 *                 logger.warning("org_api_timezone is None after update_interval, trying local DB...")             # <<<<<<<<<<<<<<
 *                 logger.debug("[Timing][Python] org_api_timezone is None, trying DB...")
 *                 await self._load_org_settings_from_db()
*/
        __pyx_t_1 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1768, __pyx_L68_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1768, __pyx_L68_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
          assert(__pyx_t_1);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_org_api_timezone_is_None_after_u};
          __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1768, __pyx_L68_error)
          __Pyx_GOTREF(__pyx_t_2);
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "ws_package/controllers/activity_controller.py":1769
 *             if self.org_api_timezone is None:
 *                 logger.warning("org_api_timezone is None after update_interval, trying local DB...")
 *                 logger.debug("[Timing][Python] org_api_timezone is None, trying DB...")             # <<<<<<<<<<<<<<
 *                 await self._load_org_settings_from_db()
 * 
*/
        __pyx_t_6 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1769, __pyx_L68_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1769, __pyx_L68_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
          assert(__pyx_t_6);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Timing_Python_org_api_timezone};
          __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1769, __pyx_L68_error)
          __Pyx_GOTREF(__pyx_t_2);
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "ws_package/controllers/activity_controller.py":1770
 *                 logger.warning("org_api_timezone is None after update_interval, trying local DB...")
 *                 logger.debug("[Timing][Python] org_api_timezone is None, trying DB...")
 *                 await self._load_org_settings_from_db()             # <<<<<<<<<<<<<<
 * 
 *             if self.org_api_timezone is None:
*/
        __pyx_t_3 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_7 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
          __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_load_org_settings_from_db, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1770, __pyx_L68_error)
          __Pyx_GOTREF(__pyx_t_2);
        }
        __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_2, &__pyx_r);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (likely(__pyx_t_26 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_11);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
          __Pyx_XGIVEREF(__pyx_t_12);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
          __Pyx_XGIVEREF(__pyx_t_13);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 2;
          return __pyx_r;
          __pyx_L76_resume_from_await:;
          __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_11);
          __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_12);
          __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_13);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1770, __pyx_L68_error)
        } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_DECREF(__pyx_r); __pyx_r = 0;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 1770, __pyx_L68_error)
        }

        /* "ws_package/controllers/activity_controller.py":1767
 * 
 *             # If timezone is still missing (e.g. offline or update_interval failed), try DB
 *             if self.org_api_timezone is None:             # <<<<<<<<<<<<<<
 *                 logger.warning("org_api_timezone is None after update_interval, trying local DB...")
 *                 logger.debug("[Timing][Python] org_api_timezone is None, trying DB...")
*/
      }

      /* "ws_package/controllers/activity_controller.py":1772
 *                 await self._load_org_settings_from_db()
 * 
 *             if self.org_api_timezone is None:             # <<<<<<<<<<<<<<
 *                 logger.error("CRITICAL: org_api_timezone is still None. Timezone checks may fail!")
 *         except Exception as e:
*/
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_org_api_timezone); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1772, __pyx_L68_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_8 = (__pyx_t_2 == Py_None);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__pyx_t_8) {

        /* "ws_package/controllers/activity_controller.py":1773
 * 
 *             if self.org_api_timezone is None:
 *                 logger.error("CRITICAL: org_api_timezone is still None. Timezone checks may fail!")             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             logger.error("Error initializing org settings: %s", e)
*/
        __pyx_t_3 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1773, __pyx_L68_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1773, __pyx_L68_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
          assert(__pyx_t_3);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_CRITICAL_org_api_timezone_is_sti};
          __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1773, __pyx_L68_error)
          __Pyx_GOTREF(__pyx_t_2);
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "ws_package/controllers/activity_controller.py":1772
 *                 await self._load_org_settings_from_db()
 * 
 *             if self.org_api_timezone is None:             # <<<<<<<<<<<<<<
 *                 logger.error("CRITICAL: org_api_timezone is still None. Timezone checks may fail!")
 *         except Exception as e:
*/
      }

      /* "ws_package/controllers/activity_controller.py":1760
 * 
 *         # CRITICAL FIX: Ensure org settings (especially timezone) are loaded
 *         try:             # <<<<<<<<<<<<<<
 *             logger.info("Fetching latest org settings before starting activity loop...")
 *             logger.debug("[Timing][Python] Fetching org settings in __start_device_activity")
*/
    }
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    goto __pyx_L73_try_end;
    __pyx_L68_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "ws_package/controllers/activity_controller.py":1774
 *             if self.org_api_timezone is None:
 *                 logger.error("CRITICAL: org_api_timezone is still None. Timezone checks may fail!")
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error initializing org settings: %s", e)
 *             # Try DB as last resort
*/
    __pyx_t_16 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_16) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_1, &__pyx_t_3) < 0) __PYX_ERR(0, 1774, __pyx_L70_except_error)
      __Pyx_XGOTREF(__pyx_t_2);
      __Pyx_XGOTREF(__pyx_t_1);
      __Pyx_XGOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_cur_scope->__pyx_v_e = __pyx_t_1;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":1775
 *                 logger.error("CRITICAL: org_api_timezone is still None. Timezone checks may fail!")
 *         except Exception as e:
 *             logger.error("Error initializing org settings: %s", e)             # <<<<<<<<<<<<<<
 *             # Try DB as last resort
 *             await self._load_org_settings_from_db()
*/
        __pyx_t_4 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1775, __pyx_L83_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1775, __pyx_L83_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_15))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_15);
          assert(__pyx_t_4);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Error_initializing_org_settings, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1775, __pyx_L83_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "ws_package/controllers/activity_controller.py":1777
 *             logger.error("Error initializing org settings: %s", e)
 *             # Try DB as last resort
 *             await self._load_org_settings_from_db()             # <<<<<<<<<<<<<<
 * 
 *         # Reset Flag to False for new session to ensure getStartingSlot() is used on first iteration
*/
        __pyx_t_15 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_15);
        __pyx_t_7 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL};
          __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_load_org_settings_from_db, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1777, __pyx_L83_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_6, &__pyx_r);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (likely(__pyx_t_26 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_1);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
          __Pyx_XGIVEREF(__pyx_t_2);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
          __Pyx_XGIVEREF(__pyx_t_3);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
          __Pyx_XGIVEREF(__pyx_t_11);
          __pyx_cur_scope->__pyx_t_3 = __pyx_t_11;
          __Pyx_XGIVEREF(__pyx_t_12);
          __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
          __Pyx_XGIVEREF(__pyx_t_13);
          __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_SwapException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 3;
          return __pyx_r;
          __pyx_L85_resume_from_await:;
          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_1);
          __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_2);
          __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_3);
          __pyx_t_11 = __pyx_cur_scope->__pyx_t_3;
          __pyx_cur_scope->__pyx_t_3 = 0;
          __Pyx_XGOTREF(__pyx_t_11);
          __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
          __pyx_cur_scope->__pyx_t_4 = 0;
          __Pyx_XGOTREF(__pyx_t_12);
          __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
          __pyx_cur_scope->__pyx_t_5 = 0;
          __Pyx_XGOTREF(__pyx_t_13);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1777, __pyx_L83_error)
        } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_DECREF(__pyx_r); __pyx_r = 0;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 1777, __pyx_L83_error)
        }
      }

      /* "ws_package/controllers/activity_controller.py":1774
 *             if self.org_api_timezone is None:
 *                 logger.error("CRITICAL: org_api_timezone is still None. Timezone checks may fail!")
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error initializing org settings: %s", e)
 *             # Try DB as last resort
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          goto __pyx_L84;
        }
        __pyx_L83_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_19, &__pyx_t_18);
          if ( unlikely(__Pyx_GetException(&__pyx_t_23, &__pyx_t_22, &__pyx_t_21) < 0)) __Pyx_ErrFetch(&__pyx_t_23, &__pyx_t_22, &__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_23);
          __Pyx_XGOTREF(__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_18);
          __pyx_t_16 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_27 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_19, __pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_ErrRestore(__pyx_t_23, __pyx_t_22, __pyx_t_21);
          __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0;
          __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_27;
          goto __pyx_L70_except_error;
        }
        __pyx_L84:;
      }
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L69_exception_handled;
    }
    goto __pyx_L70_except_error;

    /* "ws_package/controllers/activity_controller.py":1760
 * 
 *         # CRITICAL FIX: Ensure org settings (especially timezone) are loaded
 *         try:             # <<<<<<<<<<<<<<
 *             logger.info("Fetching latest org settings before starting activity loop...")
 *             logger.debug("[Timing][Python] Fetching org settings in __start_device_activity")
*/
    __pyx_L70_except_error:;
    __Pyx_XGIVEREF(__pyx_t_13);
    __Pyx_XGIVEREF(__pyx_t_12);
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_12, __pyx_t_11);
    goto __pyx_L1_error;
    __pyx_L69_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_13);
    __Pyx_XGIVEREF(__pyx_t_12);
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_12, __pyx_t_11);
    __pyx_L73_try_end:;
  }

  /* "ws_package/controllers/activity_controller.py":1780
 * 
 *         # Reset Flag to False for new session to ensure getStartingSlot() is used on first iteration
 *         self.Flag = False             # <<<<<<<<<<<<<<
 *         logger.info("Timer started at: %s, appsandurlstatus: %s, interval: %s, Flag reset to False for new session", self.start_date, self.appandurlstatus, self.interval)
 * 
*/
  if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_Flag, Py_False) < (0)) __PYX_ERR(0, 1780, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":1781
 *         # Reset Flag to False for new session to ensure getStartingSlot() is used on first iteration
 *         self.Flag = False
 *         logger.info("Timer started at: %s, appsandurlstatus: %s, interval: %s, Flag reset to False for new session", self.start_date, self.appandurlstatus, self.interval)             # <<<<<<<<<<<<<<
 * 
 *         if user_entity is not None and getattr(self, "is_break", 0) != 1:
*/
  __pyx_t_1 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1781, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1781, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_start_date); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1781, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1781, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1781, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_7 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
    assert(__pyx_t_1);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
    __pyx_t_7 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[5] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Timer_started_at_s_appsandurlsta, __pyx_t_2, __pyx_t_15, __pyx_t_4};
    __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (5-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1781, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "ws_package/controllers/activity_controller.py":1783
 *         logger.info("Timer started at: %s, appsandurlstatus: %s, interval: %s, Flag reset to False for new session", self.start_date, self.appandurlstatus, self.interval)
 * 
 *         if user_entity is not None and getattr(self, "is_break", 0) != 1:             # <<<<<<<<<<<<<<
 *             try:
 *                 work_session_start = self._normalize_activity_log_start(self.start_date)
*/
  __pyx_t_9 = (__pyx_cur_scope->__pyx_v_user_entity != Py_None);
  if (__pyx_t_9) {
  } else {
    __pyx_t_8 = __pyx_t_9;
    goto __pyx_L91_bool_binop_done;
  }
  __pyx_t_3 = __pyx_cur_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_6 = __Pyx_GetAttr3(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_is_break, __pyx_mstate_global->__pyx_int_0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1783, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_9 = (__Pyx_PyLong_BoolNeObjC(__pyx_t_6, __pyx_mstate_global->__pyx_int_1, 1, 0)); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 1783, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_8 = __pyx_t_9;
  __pyx_L91_bool_binop_done:;
  if (__pyx_t_8) {

    /* "ws_package/controllers/activity_controller.py":1784
 * 
 *         if user_entity is not None and getattr(self, "is_break", 0) != 1:
 *             try:             # <<<<<<<<<<<<<<
 *                 work_session_start = self._normalize_activity_log_start(self.start_date)
 *                 self.start_date = work_session_start
*/
    {
      __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_13);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":1785
 *         if user_entity is not None and getattr(self, "is_break", 0) != 1:
 *             try:
 *                 work_session_start = self._normalize_activity_log_start(self.start_date)             # <<<<<<<<<<<<<<
 *                 self.start_date = work_session_start
 *                 await self.push_open_session_activity_log(
*/
        __pyx_t_3 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_start_date); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1785, __pyx_L93_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_7 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_4};
          __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_normalize_activity_log_start, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1785, __pyx_L93_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __Pyx_GIVEREF(__pyx_t_6);
        __pyx_cur_scope->__pyx_v_work_session_start = __pyx_t_6;
        __pyx_t_6 = 0;

        /* "ws_package/controllers/activity_controller.py":1786
 *             try:
 *                 work_session_start = self._normalize_activity_log_start(self.start_date)
 *                 self.start_date = work_session_start             # <<<<<<<<<<<<<<
 *                 await self.push_open_session_activity_log(
 *                     user_entity,
*/
        if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_start_date, __pyx_cur_scope->__pyx_v_work_session_start) < (0)) __PYX_ERR(0, 1786, __pyx_L93_error)

        /* "ws_package/controllers/activity_controller.py":1787
 *                 work_session_start = self._normalize_activity_log_start(self.start_date)
 *                 self.start_date = work_session_start
 *                 await self.push_open_session_activity_log(             # <<<<<<<<<<<<<<
 *                     user_entity,
 *                     start_time=work_session_start,
*/
        __pyx_t_4 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_4);

        /* "ws_package/controllers/activity_controller.py":1790
 *                     user_entity,
 *                     start_time=work_session_start,
 *                     break_id=None,             # <<<<<<<<<<<<<<
 *                 )
 *             except Exception as e:
*/
        __pyx_t_7 = 0;
        {
          PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 2 : 0)] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_user_entity};
          __pyx_t_3 = __Pyx_MakeVectorcallBuilderKwds(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1787, __pyx_L93_error)
          __Pyx_GOTREF(__pyx_t_3);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_start_time, __pyx_cur_scope->__pyx_v_work_session_start, __pyx_t_3, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 1787, __pyx_L93_error)
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_break_id, Py_None, __pyx_t_3, __pyx_callargs+2, 1) < (0)) __PYX_ERR(0, 1787, __pyx_L93_error)
          __pyx_t_6 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_push_open_session_activity_log, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_3);
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1787, __pyx_L93_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_6, &__pyx_r);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (likely(__pyx_t_26 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_11);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
          __Pyx_XGIVEREF(__pyx_t_12);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
          __Pyx_XGIVEREF(__pyx_t_13);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 4;
          return __pyx_r;
          __pyx_L99_resume_from_await:;
          __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_11);
          __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_12);
          __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_13);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 1787, __pyx_L93_error)
        } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_DECREF(__pyx_r); __pyx_r = 0;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 1787, __pyx_L93_error)
        }

        /* "ws_package/controllers/activity_controller.py":1784
 * 
 *         if user_entity is not None and getattr(self, "is_break", 0) != 1:
 *             try:             # <<<<<<<<<<<<<<
 *                 work_session_start = self._normalize_activity_log_start(self.start_date)
 *                 self.start_date = work_session_start
*/
      }
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      goto __pyx_L98_try_end;
      __pyx_L93_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":1792
 *                     break_id=None,
 *                 )
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 logger.error("Error posting open work session activity/log at monitoring start: %s", e, exc_info=True)
 * 
*/
      __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
      if (__pyx_t_14) {
        __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_3, &__pyx_t_4) < 0) __PYX_ERR(0, 1792, __pyx_L95_except_error)
        __Pyx_XGOTREF(__pyx_t_6);
        __Pyx_XGOTREF(__pyx_t_3);
        __Pyx_XGOTREF(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_v_e = __pyx_t_3;
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":1793
 *                 )
 *             except Exception as e:
 *                 logger.error("Error posting open work session activity/log at monitoring start: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *         if user_entity is not None:
*/
          __pyx_t_2 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1793, __pyx_L105_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1793, __pyx_L105_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_7 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_5))) {
            __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
            assert(__pyx_t_2);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_2);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
            __pyx_t_7 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Error_posting_open_work_session, __pyx_cur_scope->__pyx_v_e};
            __pyx_t_1 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1793, __pyx_L105_error)
            __Pyx_GOTREF(__pyx_t_1);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_1, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 1793, __pyx_L105_error)
            __pyx_t_15 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_1);
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1793, __pyx_L105_error)
            __Pyx_GOTREF(__pyx_t_15);
          }
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        }

        /* "ws_package/controllers/activity_controller.py":1792
 *                     break_id=None,
 *                 )
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 logger.error("Error posting open work session activity/log at monitoring start: %s", e, exc_info=True)
 * 
*/
        /*finally:*/ {
          /*normal exit:*/{
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
            goto __pyx_L106;
          }
          __pyx_L105_error:;
          /*exception exit:*/{
            __Pyx_PyThreadState_assign
            __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
             __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
            if ( unlikely(__Pyx_GetException(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20) < 0)) __Pyx_ErrFetch(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20);
            __Pyx_XGOTREF(__pyx_t_18);
            __Pyx_XGOTREF(__pyx_t_19);
            __Pyx_XGOTREF(__pyx_t_20);
            __Pyx_XGOTREF(__pyx_t_21);
            __Pyx_XGOTREF(__pyx_t_22);
            __Pyx_XGOTREF(__pyx_t_23);
            __pyx_t_14 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_28 = __pyx_filename;
            {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
            }
            __Pyx_XGIVEREF(__pyx_t_21);
            __Pyx_XGIVEREF(__pyx_t_22);
            __Pyx_XGIVEREF(__pyx_t_23);
            __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_23);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_XGIVEREF(__pyx_t_19);
            __Pyx_XGIVEREF(__pyx_t_20);
            __Pyx_ErrRestore(__pyx_t_18, __pyx_t_19, __pyx_t_20);
            __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
            __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_28;
            goto __pyx_L95_except_error;
          }
          __pyx_L106:;
        }
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L94_exception_handled;
      }
      goto __pyx_L95_except_error;

      /* "ws_package/controllers/activity_controller.py":1784
 * 
 *         if user_entity is not None and getattr(self, "is_break", 0) != 1:
 *             try:             # <<<<<<<<<<<<<<
 *                 work_session_start = self._normalize_activity_log_start(self.start_date)
 *                 self.start_date = work_session_start
*/
      __pyx_L95_except_error:;
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      goto __pyx_L1_error;
      __pyx_L94_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
      __pyx_L98_try_end:;
    }

    /* "ws_package/controllers/activity_controller.py":1783
 *         logger.info("Timer started at: %s, appsandurlstatus: %s, interval: %s, Flag reset to False for new session", self.start_date, self.appandurlstatus, self.interval)
 * 
 *         if user_entity is not None and getattr(self, "is_break", 0) != 1:             # <<<<<<<<<<<<<<
 *             try:
 *                 work_session_start = self._normalize_activity_log_start(self.start_date)
*/
  }

  /* "ws_package/controllers/activity_controller.py":1795
 *                 logger.error("Error posting open work session activity/log at monitoring start: %s", e, exc_info=True)
 * 
 *         if user_entity is not None:             # <<<<<<<<<<<<<<
 *             try:
 *                 from ws_package.log.writer import enable_hourly_log_upload
*/
  __pyx_t_8 = (__pyx_cur_scope->__pyx_v_user_entity != Py_None);
  if (__pyx_t_8) {

    /* "ws_package/controllers/activity_controller.py":1796
 * 
 *         if user_entity is not None:
 *             try:             # <<<<<<<<<<<<<<
 *                 from ws_package.log.writer import enable_hourly_log_upload
 *                 enable_hourly_log_upload(user_entity, user_entity.org_id, self.s3_logs_path)
*/
    {
      __Pyx_ExceptionSave(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_11);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":1797
 *         if user_entity is not None:
 *             try:
 *                 from ws_package.log.writer import enable_hourly_log_upload             # <<<<<<<<<<<<<<
 *                 enable_hourly_log_upload(user_entity, user_entity.org_id, self.s3_logs_path)
 *                 logger.info("Hourly log upload enabled through logging thread")
*/
        {
          PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_enable_hourly_log_upload};
          __pyx_t_23 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_log_writer, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 1797, __pyx_L112_error)
        }
        __pyx_t_4 = __pyx_t_23;
        __Pyx_GOTREF(__pyx_t_4);
        {
          PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_enable_hourly_log_upload};
          __pyx_t_29 = 0; {
            __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_4, __pyx_imported_names[__pyx_t_29]); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 1797, __pyx_L112_error)
            __Pyx_GOTREF(__pyx_t_3);
            switch (__pyx_t_29) {
              case 0:
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_GIVEREF(__pyx_t_3);
              __pyx_cur_scope->__pyx_v_enable_hourly_log_upload = __pyx_t_3;
              break;
              default:;
            }
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":1798
 *             try:
 *                 from ws_package.log.writer import enable_hourly_log_upload
 *                 enable_hourly_log_upload(user_entity, user_entity.org_id, self.s3_logs_path)             # <<<<<<<<<<<<<<
 *                 logger.info("Hourly log upload enabled through logging thread")
 *             except Exception as e:
*/
        __pyx_t_3 = NULL;
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_enable_hourly_log_upload);
        __pyx_t_6 = __pyx_cur_scope->__pyx_v_enable_hourly_log_upload; 
        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_org_id); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1798, __pyx_L112_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_s3_logs_path); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1798, __pyx_L112_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
          assert(__pyx_t_3);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[4] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_user_entity, __pyx_t_15, __pyx_t_5};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1798, __pyx_L112_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":1799
 *                 from ws_package.log.writer import enable_hourly_log_upload
 *                 enable_hourly_log_upload(user_entity, user_entity.org_id, self.s3_logs_path)
 *                 logger.info("Hourly log upload enabled through logging thread")             # <<<<<<<<<<<<<<
 *             except Exception as e:
 *                 logger.error("Failed to enable hourly log upload: %s", e)
*/
        __pyx_t_6 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1799, __pyx_L112_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1799, __pyx_L112_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_15))) {
          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_15);
          assert(__pyx_t_6);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Hourly_log_upload_enabled_throug};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1799, __pyx_L112_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":1796
 * 
 *         if user_entity is not None:
 *             try:             # <<<<<<<<<<<<<<
 *                 from ws_package.log.writer import enable_hourly_log_upload
 *                 enable_hourly_log_upload(user_entity, user_entity.org_id, self.s3_logs_path)
*/
      }
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      goto __pyx_L117_try_end;
      __pyx_L112_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":1800
 *                 enable_hourly_log_upload(user_entity, user_entity.org_id, self.s3_logs_path)
 *                 logger.info("Hourly log upload enabled through logging thread")
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 logger.error("Failed to enable hourly log upload: %s", e)
 *         else:
*/
      __pyx_t_16 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
      if (__pyx_t_16) {
        __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_15, &__pyx_t_6) < 0) __PYX_ERR(0, 1800, __pyx_L114_except_error)
        __Pyx_XGOTREF(__pyx_t_4);
        __Pyx_XGOTREF(__pyx_t_15);
        __Pyx_XGOTREF(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_15);
        __Pyx_GIVEREF(__pyx_t_15);
        __pyx_cur_scope->__pyx_v_e = __pyx_t_15;
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":1801
 *                 logger.info("Hourly log upload enabled through logging thread")
 *             except Exception as e:
 *                 logger.error("Failed to enable hourly log upload: %s", e)             # <<<<<<<<<<<<<<
 *         else:
 *             logger.warning("Skipping hourly log upload initialization: user_entity is None")
*/
          __pyx_t_3 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1801, __pyx_L123_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1801, __pyx_L123_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_7 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
            assert(__pyx_t_3);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
            __pyx_t_7 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Failed_to_enable_hourly_log_uplo, __pyx_cur_scope->__pyx_v_e};
            __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1801, __pyx_L123_error)
            __Pyx_GOTREF(__pyx_t_5);
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        }

        /* "ws_package/controllers/activity_controller.py":1800
 *                 enable_hourly_log_upload(user_entity, user_entity.org_id, self.s3_logs_path)
 *                 logger.info("Hourly log upload enabled through logging thread")
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 logger.error("Failed to enable hourly log upload: %s", e)
 *         else:
*/
        /*finally:*/ {
          /*normal exit:*/{
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
            goto __pyx_L124;
          }
          __pyx_L123_error:;
          /*exception exit:*/{
            __Pyx_PyThreadState_assign
            __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0;
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
             __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_19, &__pyx_t_18);
            if ( unlikely(__Pyx_GetException(&__pyx_t_23, &__pyx_t_22, &__pyx_t_21) < 0)) __Pyx_ErrFetch(&__pyx_t_23, &__pyx_t_22, &__pyx_t_21);
            __Pyx_XGOTREF(__pyx_t_23);
            __Pyx_XGOTREF(__pyx_t_22);
            __Pyx_XGOTREF(__pyx_t_21);
            __Pyx_XGOTREF(__pyx_t_20);
            __Pyx_XGOTREF(__pyx_t_19);
            __Pyx_XGOTREF(__pyx_t_18);
            __pyx_t_16 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_30 = __pyx_filename;
            {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
            }
            __Pyx_XGIVEREF(__pyx_t_20);
            __Pyx_XGIVEREF(__pyx_t_19);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_19, __pyx_t_18);
            __Pyx_XGIVEREF(__pyx_t_23);
            __Pyx_XGIVEREF(__pyx_t_22);
            __Pyx_XGIVEREF(__pyx_t_21);
            __Pyx_ErrRestore(__pyx_t_23, __pyx_t_22, __pyx_t_21);
            __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0;
            __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_30;
            goto __pyx_L114_except_error;
          }
          __pyx_L124:;
        }
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        goto __pyx_L113_exception_handled;
      }
      goto __pyx_L114_except_error;

      /* "ws_package/controllers/activity_controller.py":1796
 * 
 *         if user_entity is not None:
 *             try:             # <<<<<<<<<<<<<<
 *                 from ws_package.log.writer import enable_hourly_log_upload
 *                 enable_hourly_log_upload(user_entity, user_entity.org_id, self.s3_logs_path)
*/
      __pyx_L114_except_error:;
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_12, __pyx_t_11);
      goto __pyx_L1_error;
      __pyx_L113_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_12, __pyx_t_11);
      __pyx_L117_try_end:;
    }

    /* "ws_package/controllers/activity_controller.py":1795
 *                 logger.error("Error posting open work session activity/log at monitoring start: %s", e, exc_info=True)
 * 
 *         if user_entity is not None:             # <<<<<<<<<<<<<<
 *             try:
 *                 from ws_package.log.writer import enable_hourly_log_upload
*/
    goto __pyx_L111;
  }

  /* "ws_package/controllers/activity_controller.py":1803
 *                 logger.error("Failed to enable hourly log upload: %s", e)
 *         else:
 *             logger.warning("Skipping hourly log upload initialization: user_entity is None")             # <<<<<<<<<<<<<<
 * 
 *         app_listener = Window()
*/
  /*else*/ {
    __pyx_t_15 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1803, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1803, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5);
      assert(__pyx_t_15);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Skipping_hourly_log_upload_initi};
      __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1803, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    }
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  }
  __pyx_L111:;

  /* "ws_package/controllers/activity_controller.py":1805
 *             logger.warning("Skipping hourly log upload initialization: user_entity is None")
 * 
 *         app_listener = Window()             # <<<<<<<<<<<<<<
 *         last_app_monitor_time = datetime.datetime.now()
 * 
*/
  __pyx_t_5 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_Window); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1805, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_7 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_15))) {
    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_15);
    assert(__pyx_t_5);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
    __Pyx_INCREF(__pyx_t_5);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
    __pyx_t_7 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
    __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1805, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
  }
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_cur_scope->__pyx_v_app_listener = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "ws_package/controllers/activity_controller.py":1806
 * 
 *         app_listener = Window()
 *         last_app_monitor_time = datetime.datetime.now()             # <<<<<<<<<<<<<<
 * 
 *         # No complex time monitoring needed - using S3 error detection
*/
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1806, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 1806, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_15 = __pyx_t_4;
  __Pyx_INCREF(__pyx_t_15);
  __pyx_t_7 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL};
    __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1806, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
  }
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_cur_scope->__pyx_v_last_app_monitor_time = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "ws_package/controllers/activity_controller.py":1810
 *         # No complex time monitoring needed - using S3 error detection
 * 
 *         async def monitor_active_apps():             # <<<<<<<<<<<<<<
 *             nonlocal last_app_monitor_time
 *             logger.info(
*/
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_3monitor_active_apps, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController___start_devic_2, ((PyObject*)__pyx_cur_scope), __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[24])); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1810, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_cur_scope->__pyx_v_monitor_active_apps = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "ws_package/controllers/activity_controller.py":1958
 * 
 *         # Create and track the monitor_active_apps task to prevent silent failures
 *         monitor_task = asyncio.create_task(monitor_active_apps())             # <<<<<<<<<<<<<<
 *         self._background_tasks.add(monitor_task)
 * 
*/
  __pyx_t_4 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1958, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_create_task); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 1958, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_t_15 = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_2monitor_active_apps(__pyx_cur_scope->__pyx_v_monitor_active_apps); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1958, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_7 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
    assert(__pyx_t_4);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
    __pyx_t_7 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_15};
    __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1958, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
  }
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_cur_scope->__pyx_v_monitor_task = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "ws_package/controllers/activity_controller.py":1959
 *         # Create and track the monitor_active_apps task to prevent silent failures
 *         monitor_task = asyncio.create_task(monitor_active_apps())
 *         self._background_tasks.add(monitor_task)             # <<<<<<<<<<<<<<
 * 
 *         def task_done_callback(task):
*/
  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_background_tasks); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1959, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_5 = __pyx_t_15;
  __Pyx_INCREF(__pyx_t_5);
  __pyx_t_7 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_monitor_task};
    __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_add, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1959, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "ws_package/controllers/activity_controller.py":1961
 *         self._background_tasks.add(monitor_task)
 * 
 *         def task_done_callback(task):             # <<<<<<<<<<<<<<
 *             """Handle task completion and log any exceptions"""
 *             self._background_tasks.discard(task)
*/
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_6task_done_callback, 0, __pyx_mstate_global->__pyx_n_u_ActivityController___start_devic_7, ((PyObject*)__pyx_cur_scope), __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[34])); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1961, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_cur_scope->__pyx_v_task_done_callback = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "ws_package/controllers/activity_controller.py":1973
 *                     logger.error("Background task monitor_active_apps failed: %s", e, exc_info=True)
 * 
 *         monitor_task.add_done_callback(task_done_callback)             # <<<<<<<<<<<<<<
 * 
 *         # Monitor active app changes for UI display (real-time updates)
*/
  __pyx_t_15 = __pyx_cur_scope->__pyx_v_monitor_task;
  __Pyx_INCREF(__pyx_t_15);
  __pyx_t_7 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_cur_scope->__pyx_v_task_done_callback};
    __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_add_done_callback, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1973, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "ws_package/controllers/activity_controller.py":1976
 * 
 *         # Monitor active app changes for UI display (real-time updates)
 *         async def monitor_active_app_for_ui():             # <<<<<<<<<<<<<<
 *             """Monitor active app changes and send updates to Electron for UI display."""
 *             while not stop_event.is_set():
*/
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_8monitor_active_app_for_ui, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController___start_devic_3, ((PyObject*)__pyx_cur_scope), __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[25])); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 1976, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_cur_scope->__pyx_v_monitor_active_app_for_ui = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "ws_package/controllers/activity_controller.py":2026
 * 
 *         # Create and track the active app UI monitoring task
 *         active_app_ui_task = asyncio.create_task(monitor_active_app_for_ui())             # <<<<<<<<<<<<<<
 *         self._background_tasks.add(active_app_ui_task)
 * 
*/
  __pyx_t_15 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2026, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_create_task); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2026, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_5 = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_7monitor_active_app_for_ui(__pyx_cur_scope->__pyx_v_monitor_active_app_for_ui); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2026, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_7 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_15);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_15);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_7 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_t_5};
    __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2026, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
  }
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_cur_scope->__pyx_v_active_app_ui_task = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "ws_package/controllers/activity_controller.py":2027
 *         # Create and track the active app UI monitoring task
 *         active_app_ui_task = asyncio.create_task(monitor_active_app_for_ui())
 *         self._background_tasks.add(active_app_ui_task)             # <<<<<<<<<<<<<<
 * 
 *         def active_app_ui_task_done_callback(task):
*/
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_background_tasks); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2027, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_4 = __pyx_t_5;
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_7 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_active_app_ui_task};
    __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_add, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2027, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "ws_package/controllers/activity_controller.py":2029
 *         self._background_tasks.add(active_app_ui_task)
 * 
 *         def active_app_ui_task_done_callback(task):             # <<<<<<<<<<<<<<
 *             """Handle active app UI task completion"""
 *             self._background_tasks.discard(task)
*/
  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_11active_app_ui_task_done_callback, 0, __pyx_mstate_global->__pyx_n_u_ActivityController___start_devic_8, ((PyObject*)__pyx_cur_scope), __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[35])); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2029, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_cur_scope->__pyx_v_active_app_ui_task_done_callback = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "ws_package/controllers/activity_controller.py":2040
 *                     logger.error("Background task monitor_active_app_for_ui failed: %s", e, exc_info=True)
 * 
 *         active_app_ui_task.add_done_callback(active_app_ui_task_done_callback)             # <<<<<<<<<<<<<<
 * 
 *         # Create first dummy entry when timer starts (is_uploaded=True to mark session start, not to be uploaded)
*/
  __pyx_t_5 = __pyx_cur_scope->__pyx_v_active_app_ui_task;
  __Pyx_INCREF(__pyx_t_5);
  __pyx_t_7 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_active_app_ui_task_done_callback};
    __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_add_done_callback, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2040, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
  }
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

  /* "ws_package/controllers/activity_controller.py":2043
 * 
 *         # Create first dummy entry when timer starts (is_uploaded=True to mark session start, not to be uploaded)
 *         empty_activity_level =  {'mouse': '1.0', 'average': '0.0', 'keyboard': '0.0'} #for not consider idle if 2nd interval is idle as program consider 2 consicutive idle interval             # <<<<<<<<<<<<<<
 *         # CRITICAL: Read is_break at the time of saving to ensure current value is used
 *         current_break_id = getattr(self, 'break_id', 0) or 0  # Default to 0 if not available
*/
  __pyx_t_6 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2043, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  if (PyDict_SetItem(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_mouse, __pyx_mstate_global->__pyx_kp_u_1_0) < (0)) __PYX_ERR(0, 2043, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_average, __pyx_mstate_global->__pyx_kp_u_0_0) < (0)) __PYX_ERR(0, 2043, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_keyboard, __pyx_mstate_global->__pyx_kp_u_0_0) < (0)) __PYX_ERR(0, 2043, __pyx_L1_error)
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_cur_scope->__pyx_v_empty_activity_level = ((PyObject*)__pyx_t_6);
  __pyx_t_6 = 0;

  /* "ws_package/controllers/activity_controller.py":2045
 *         empty_activity_level =  {'mouse': '1.0', 'average': '0.0', 'keyboard': '0.0'} #for not consider idle if 2nd interval is idle as program consider 2 consicutive idle interval
 *         # CRITICAL: Read is_break at the time of saving to ensure current value is used
 *         current_break_id = getattr(self, 'break_id', 0) or 0  # Default to 0 if not available             # <<<<<<<<<<<<<<
 * 
 *         # CRITICAL: Check if first dummy entry already exists to prevent duplicates
*/
  __pyx_t_5 = __pyx_cur_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_5);
  __pyx_t_4 = __Pyx_GetAttr3(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_break_id, __pyx_mstate_global->__pyx_int_0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2045, __pyx_L1_error)
  if (!__pyx_t_8) {
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  } else {
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_6 = __pyx_t_4;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    goto __pyx_L129_bool_binop_done;
  }
  __pyx_t_4 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2045, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_6 = __pyx_t_4;
  __pyx_t_4 = 0;
  __pyx_L129_bool_binop_done:;
  __Pyx_GIVEREF(__pyx_t_6);
  __pyx_cur_scope->__pyx_v_current_break_id = __pyx_t_6;
  __pyx_t_6 = 0;

  /* "ws_package/controllers/activity_controller.py":2049
 *         # CRITICAL: Check if first dummy entry already exists to prevent duplicates
 *         # This can happen if __start_device_activity is called multiple times (e.g., from deferred messages)
 *         try:             # <<<<<<<<<<<<<<
 *             # First, flush queue to ensure any pending writes are visible
 *             await db_writer_service.process_immediately()
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
    __Pyx_XGOTREF(__pyx_t_11);
    __Pyx_XGOTREF(__pyx_t_12);
    __Pyx_XGOTREF(__pyx_t_13);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":2051
 *         try:
 *             # First, flush queue to ensure any pending writes are visible
 *             await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 *             await asyncio.sleep(0.1)  # Small delay to ensure commit is visible
 * 
*/
      __pyx_t_4 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2051, __pyx_L131_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2051, __pyx_L131_error)
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_7 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_15))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_15);
        assert(__pyx_t_4);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
        __pyx_t_7 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
        __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2051, __pyx_L131_error)
        __Pyx_GOTREF(__pyx_t_6);
      }
      __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_6, &__pyx_r);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (likely(__pyx_t_26 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_11);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
        __Pyx_XGIVEREF(__pyx_t_12);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
        __Pyx_XGIVEREF(__pyx_t_13);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 5;
        return __pyx_r;
        __pyx_L137_resume_from_await:;
        __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_11);
        __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_12);
        __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_13);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2051, __pyx_L131_error)
      } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_DECREF(__pyx_r); __pyx_r = 0;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 2051, __pyx_L131_error)
      }

      /* "ws_package/controllers/activity_controller.py":2052
 *             # First, flush queue to ensure any pending writes are visible
 *             await db_writer_service.process_immediately()
 *             await asyncio.sleep(0.1)  # Small delay to ensure commit is visible             # <<<<<<<<<<<<<<
 * 
 *             with db_lock_manager.read_lock():
*/
      __pyx_t_15 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2052, __pyx_L131_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2052, __pyx_L131_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_7 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5);
        assert(__pyx_t_15);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_15);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
        __pyx_t_7 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_mstate_global->__pyx_float_0_1};
        __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2052, __pyx_L131_error)
        __Pyx_GOTREF(__pyx_t_6);
      }
      __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_6, &__pyx_r);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (likely(__pyx_t_26 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_11);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
        __Pyx_XGIVEREF(__pyx_t_12);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
        __Pyx_XGIVEREF(__pyx_t_13);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 6;
        return __pyx_r;
        __pyx_L138_resume_from_await:;
        __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_11);
        __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_12);
        __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_13);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2052, __pyx_L131_error)
      } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_DECREF(__pyx_r); __pyx_r = 0;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 2052, __pyx_L131_error)
      }

      /* "ws_package/controllers/activity_controller.py":2054
 *             await asyncio.sleep(0.1)  # Small delay to ensure commit is visible
 * 
 *             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     # Check for exact match: start_time == end_time == self.start_date AND counter matches
*/
      /*with:*/ {
        __pyx_t_5 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2054, __pyx_L131_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2054, __pyx_L131_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
          assert(__pyx_t_5);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
          __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2054, __pyx_L131_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __pyx_t_18 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 2054, __pyx_L131_error)
        __Pyx_GOTREF(__pyx_t_18);
        __pyx_t_5 = NULL;
        __pyx_t_15 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2054, __pyx_L139_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (likely(PyMethod_Check(__pyx_t_15))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_15);
          assert(__pyx_t_5);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2054, __pyx_L139_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        /*try:*/ {
          {
            __Pyx_ExceptionSave(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21);
            __Pyx_XGOTREF(__pyx_t_19);
            __Pyx_XGOTREF(__pyx_t_20);
            __Pyx_XGOTREF(__pyx_t_21);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":2055
 * 
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     # Check for exact match: start_time == end_time == self.start_date AND counter matches
 *                     # This identifies the first dummy entry (which has start_time == end_time)
*/
              /*with:*/ {
                __pyx_t_4 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2055, __pyx_L143_error)
                __Pyx_GOTREF(__pyx_t_15);
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_15))) {
                  __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_15);
                  assert(__pyx_t_4);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                  __Pyx_INCREF(__pyx_t_4);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
                  __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2055, __pyx_L143_error)
                  __Pyx_GOTREF(__pyx_t_6);
                }
                __pyx_t_22 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 2055, __pyx_L143_error)
                __Pyx_GOTREF(__pyx_t_22);
                __pyx_t_4 = NULL;
                __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2055, __pyx_L149_error)
                __Pyx_GOTREF(__pyx_t_5);
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (likely(PyMethod_Check(__pyx_t_5))) {
                  __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
                  assert(__pyx_t_4);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                  __Pyx_INCREF(__pyx_t_4);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
                  __pyx_t_15 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2055, __pyx_L149_error)
                  __Pyx_GOTREF(__pyx_t_15);
                }
                __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_15, &__pyx_r);
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_6);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
                  __Pyx_XGIVEREF(__pyx_t_11);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_11;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_18;
                  __Pyx_XGIVEREF(__pyx_t_19);
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_19;
                  __Pyx_XGIVEREF(__pyx_t_20);
                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_20;
                  __Pyx_XGIVEREF(__pyx_t_21);
                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_21;
                  __Pyx_XGIVEREF(__pyx_t_22);
                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_22;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 7;
                  return __pyx_r;
                  __pyx_L150_resume_from_await:;
                  __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_6);
                  __pyx_t_11 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_11);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  __pyx_t_18 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_18);
                  __pyx_t_19 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = 0;
                  __Pyx_XGOTREF(__pyx_t_19);
                  __pyx_t_20 = __pyx_cur_scope->__pyx_t_6;
                  __pyx_cur_scope->__pyx_t_6 = 0;
                  __Pyx_XGOTREF(__pyx_t_20);
                  __pyx_t_21 = __pyx_cur_scope->__pyx_t_7;
                  __pyx_cur_scope->__pyx_t_7 = 0;
                  __Pyx_XGOTREF(__pyx_t_21);
                  __pyx_t_22 = __pyx_cur_scope->__pyx_t_8;
                  __pyx_cur_scope->__pyx_t_8 = 0;
                  __Pyx_XGOTREF(__pyx_t_22);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2055, __pyx_L149_error)
                  __pyx_t_15 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_15);
                } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __pyx_t_15 = __pyx_r; __pyx_r = NULL;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 2055, __pyx_L149_error)
                }
                __pyx_t_5 = __pyx_t_15;
                __pyx_t_15 = 0;
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                /*try:*/ {
                  {
                    __Pyx_ExceptionSave(&__pyx_t_23, &__pyx_t_31, &__pyx_t_32);
                    __Pyx_XGOTREF(__pyx_t_23);
                    __Pyx_XGOTREF(__pyx_t_31);
                    __Pyx_XGOTREF(__pyx_t_32);
                    /*try:*/ {
                      __Pyx_GIVEREF(__pyx_t_5);
                      __pyx_cur_scope->__pyx_v_session = __pyx_t_5;
                      __pyx_t_5 = 0;

                      /* "ws_package/controllers/activity_controller.py":2058
 *                     # Check for exact match: start_time == end_time == self.start_date AND counter matches
 *                     # This identifies the first dummy entry (which has start_time == end_time)
 *                     query = select(ActivityInterval).where(             # <<<<<<<<<<<<<<
 *                         and_(
 *                             ActivityInterval.start_time == self.start_date,
*/
                      __pyx_t_3 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2058, __pyx_L154_error)
                      __Pyx_GOTREF(__pyx_t_1);
                      __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2058, __pyx_L154_error)
                      __Pyx_GOTREF(__pyx_t_33);
                      __pyx_t_7 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_1))) {
                        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
                        assert(__pyx_t_3);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
                        __Pyx_INCREF(__pyx_t_3);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
                        __pyx_t_7 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_33};
                        __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2058, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_2);
                      }
                      __pyx_t_4 = __pyx_t_2;
                      __Pyx_INCREF(__pyx_t_4);

                      /* "ws_package/controllers/activity_controller.py":2059
 *                     # This identifies the first dummy entry (which has start_time == end_time)
 *                     query = select(ActivityInterval).where(
 *                         and_(             # <<<<<<<<<<<<<<
 *                             ActivityInterval.start_time == self.start_date,
 *                             ActivityInterval.end_time == self.start_date,
*/
                      __pyx_t_33 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_and); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2059, __pyx_L154_error)
                      __Pyx_GOTREF(__pyx_t_3);

                      /* "ws_package/controllers/activity_controller.py":2060
 *                     query = select(ActivityInterval).where(
 *                         and_(
 *                             ActivityInterval.start_time == self.start_date,             # <<<<<<<<<<<<<<
 *                             ActivityInterval.end_time == self.start_date,
 *                             ActivityInterval.counter == self.last_count + 1
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2060, __pyx_L154_error)
                      __Pyx_GOTREF(__pyx_t_34);
                      __pyx_t_35 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_35)) __PYX_ERR(0, 2060, __pyx_L154_error)
                      __Pyx_GOTREF(__pyx_t_35);
                      __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                      __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_start_date); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2060, __pyx_L154_error)
                      __Pyx_GOTREF(__pyx_t_34);
                      __pyx_t_36 = PyObject_RichCompare(__pyx_t_35, __pyx_t_34, Py_EQ); __Pyx_XGOTREF(__pyx_t_36); if (unlikely(!__pyx_t_36)) __PYX_ERR(0, 2060, __pyx_L154_error)
                      __Pyx_DECREF(__pyx_t_35); __pyx_t_35 = 0;
                      __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;

                      /* "ws_package/controllers/activity_controller.py":2061
 *                         and_(
 *                             ActivityInterval.start_time == self.start_date,
 *                             ActivityInterval.end_time == self.start_date,             # <<<<<<<<<<<<<<
 *                             ActivityInterval.counter == self.last_count + 1
 *                         )
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2061, __pyx_L154_error)
                      __Pyx_GOTREF(__pyx_t_34);
                      __pyx_t_35 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_35)) __PYX_ERR(0, 2061, __pyx_L154_error)
                      __Pyx_GOTREF(__pyx_t_35);
                      __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                      __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_start_date); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2061, __pyx_L154_error)
                      __Pyx_GOTREF(__pyx_t_34);
                      __pyx_t_37 = PyObject_RichCompare(__pyx_t_35, __pyx_t_34, Py_EQ); __Pyx_XGOTREF(__pyx_t_37); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2061, __pyx_L154_error)
                      __Pyx_DECREF(__pyx_t_35); __pyx_t_35 = 0;
                      __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;

                      /* "ws_package/controllers/activity_controller.py":2062
 *                             ActivityInterval.start_time == self.start_date,
 *                             ActivityInterval.end_time == self.start_date,
 *                             ActivityInterval.counter == self.last_count + 1             # <<<<<<<<<<<<<<
 *                         )
 *                     ).limit(1)
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2062, __pyx_L154_error)
                      __Pyx_GOTREF(__pyx_t_34);
                      __pyx_t_35 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_35)) __PYX_ERR(0, 2062, __pyx_L154_error)
                      __Pyx_GOTREF(__pyx_t_35);
                      __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                      __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2062, __pyx_L154_error)
                      __Pyx_GOTREF(__pyx_t_34);
                      __pyx_t_38 = __Pyx_PyLong_AddObjC(__pyx_t_34, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_38)) __PYX_ERR(0, 2062, __pyx_L154_error)
                      __Pyx_GOTREF(__pyx_t_38);
                      __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                      __pyx_t_34 = PyObject_RichCompare(__pyx_t_35, __pyx_t_38, Py_EQ); __Pyx_XGOTREF(__pyx_t_34); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2062, __pyx_L154_error)
                      __Pyx_DECREF(__pyx_t_35); __pyx_t_35 = 0;
                      __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0;
                      __pyx_t_7 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_3))) {
                        __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_3);
                        assert(__pyx_t_33);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
                        __Pyx_INCREF(__pyx_t_33);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
                        __pyx_t_7 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[4] = {__pyx_t_33, __pyx_t_36, __pyx_t_37, __pyx_t_34};
                        __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                        __Pyx_DECREF(__pyx_t_36); __pyx_t_36 = 0;
                        __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2059, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_1);
                      }
                      __pyx_t_7 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_1};
                        __pyx_t_15 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                        if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2058, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_15);
                      }
                      __pyx_t_6 = __pyx_t_15;
                      __Pyx_INCREF(__pyx_t_6);
                      __pyx_t_7 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_int_1};
                        __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_limit, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2064, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_5);
                      }
                      __Pyx_GIVEREF(__pyx_t_5);
                      __pyx_cur_scope->__pyx_v_query = __pyx_t_5;
                      __pyx_t_5 = 0;

                      /* "ws_package/controllers/activity_controller.py":2065
 *                         )
 *                     ).limit(1)
 *                     result = await session.execute(query)             # <<<<<<<<<<<<<<
 *                     existing_dummy = result.scalars().first()
 * 
*/
                      __pyx_t_15 = __pyx_cur_scope->__pyx_v_session;
                      __Pyx_INCREF(__pyx_t_15);
                      __pyx_t_7 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_cur_scope->__pyx_v_query};
                        __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2065, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_5);
                      }
                      __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_t_19);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_19;
                        __Pyx_XGIVEREF(__pyx_t_20);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_20;
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_21;
                        __Pyx_XGIVEREF(__pyx_t_22);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_22;
                        __Pyx_XGIVEREF(__pyx_t_23);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_23;
                        __Pyx_XGIVEREF(__pyx_t_31);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_31;
                        __Pyx_XGIVEREF(__pyx_t_32);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_32;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 8;
                        return __pyx_r;
                        __pyx_L160_resume_from_await:;
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        __pyx_t_19 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_19);
                        __pyx_t_20 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_20);
                        __pyx_t_21 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_21);
                        __pyx_t_22 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_22);
                        __pyx_t_23 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_23);
                        __pyx_t_31 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_31);
                        __pyx_t_32 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_32);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2065, __pyx_L154_error)
                        __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
                      } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_5 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 2065, __pyx_L154_error)
                      }
                      __Pyx_GIVEREF(__pyx_t_5);
                      __pyx_cur_scope->__pyx_v_result = __pyx_t_5;
                      __pyx_t_5 = 0;

                      /* "ws_package/controllers/activity_controller.py":2066
 *                     ).limit(1)
 *                     result = await session.execute(query)
 *                     existing_dummy = result.scalars().first()             # <<<<<<<<<<<<<<
 * 
 *                     if existing_dummy:
*/
                      __pyx_t_2 = __pyx_cur_scope->__pyx_v_result;
                      __Pyx_INCREF(__pyx_t_2);
                      __pyx_t_7 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
                        __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalars, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2066, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_6);
                      }
                      __pyx_t_15 = __pyx_t_6;
                      __Pyx_INCREF(__pyx_t_15);
                      __pyx_t_7 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL};
                        __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_first, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2066, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_5);
                      }
                      __Pyx_GIVEREF(__pyx_t_5);
                      __pyx_cur_scope->__pyx_v_existing_dummy = __pyx_t_5;
                      __pyx_t_5 = 0;

                      /* "ws_package/controllers/activity_controller.py":2068
 *                     existing_dummy = result.scalars().first()
 * 
 *                     if existing_dummy:             # <<<<<<<<<<<<<<
 *                         logger.info("First dummy entry already exists for start_date=%s, counter=%s - skipping duplicate creation", self.start_date, self.last_count+1)
 *                         logger.info("Existing dummy entry: start_time=%s, end_time=%s, counter=%s, is_uploaded=%s", existing_dummy.start_time, existing_dummy.end_time, existing_dummy.counter, existing_dummy.is_uploaded)
*/
                      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_existing_dummy); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2068, __pyx_L154_error)
                      if (__pyx_t_8) {

                        /* "ws_package/controllers/activity_controller.py":2069
 * 
 *                     if existing_dummy:
 *                         logger.info("First dummy entry already exists for start_date=%s, counter=%s - skipping duplicate creation", self.start_date, self.last_count+1)             # <<<<<<<<<<<<<<
 *                         logger.info("Existing dummy entry: start_time=%s, end_time=%s, counter=%s, is_uploaded=%s", existing_dummy.start_time, existing_dummy.end_time, existing_dummy.counter, existing_dummy.is_uploaded)
 *                         first_entry = existing_dummy
*/
                        __pyx_t_6 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2069, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_15);
                        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2069, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_2);
                        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_start_date); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2069, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_15);
                        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2069, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_1);
                        __pyx_t_4 = __Pyx_PyLong_AddObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2069, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_4);
                        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                        __pyx_t_7 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_2))) {
                          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
                          assert(__pyx_t_6);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
                          __Pyx_INCREF(__pyx_t_6);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
                          __pyx_t_7 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[4] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_First_dummy_entry_already_exists, __pyx_t_15, __pyx_t_4};
                          __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2069, __pyx_L154_error)
                          __Pyx_GOTREF(__pyx_t_5);
                        }
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                        /* "ws_package/controllers/activity_controller.py":2070
 *                     if existing_dummy:
 *                         logger.info("First dummy entry already exists for start_date=%s, counter=%s - skipping duplicate creation", self.start_date, self.last_count+1)
 *                         logger.info("Existing dummy entry: start_time=%s, end_time=%s, counter=%s, is_uploaded=%s", existing_dummy.start_time, existing_dummy.end_time, existing_dummy.counter, existing_dummy.is_uploaded)             # <<<<<<<<<<<<<<
 *                         first_entry = existing_dummy
 *                     else:
*/
                        __pyx_t_2 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2070, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_4);
                        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2070, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_15);
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_existing_dummy, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2070, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_4);
                        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_existing_dummy, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2070, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_6);
                        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_existing_dummy, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2070, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_1);
                        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_existing_dummy, __pyx_mstate_global->__pyx_n_u_is_uploaded); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2070, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_3);
                        __pyx_t_7 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_15))) {
                          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_15);
                          assert(__pyx_t_2);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                          __Pyx_INCREF(__pyx_t_2);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                          __pyx_t_7 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[6] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Existing_dummy_entry_start_time, __pyx_t_4, __pyx_t_6, __pyx_t_1, __pyx_t_3};
                          __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (6-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2070, __pyx_L154_error)
                          __Pyx_GOTREF(__pyx_t_5);
                        }
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                        /* "ws_package/controllers/activity_controller.py":2071
 *                         logger.info("First dummy entry already exists for start_date=%s, counter=%s - skipping duplicate creation", self.start_date, self.last_count+1)
 *                         logger.info("Existing dummy entry: start_time=%s, end_time=%s, counter=%s, is_uploaded=%s", existing_dummy.start_time, existing_dummy.end_time, existing_dummy.counter, existing_dummy.is_uploaded)
 *                         first_entry = existing_dummy             # <<<<<<<<<<<<<<
 *                     else:
 *                         logger.info("Creating first dummy entry: start_date=%s, counter=%s, is_uploaded=True, break_id=%s, will be saved as is_break=%s", self.start_date, self.last_count+1, current_break_id, current_break_id if current_break_id else 0)
*/
                        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_existing_dummy);
                        __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_existing_dummy);
                        __pyx_cur_scope->__pyx_v_first_entry = __pyx_cur_scope->__pyx_v_existing_dummy;

                        /* "ws_package/controllers/activity_controller.py":2068
 *                     existing_dummy = result.scalars().first()
 * 
 *                     if existing_dummy:             # <<<<<<<<<<<<<<
 *                         logger.info("First dummy entry already exists for start_date=%s, counter=%s - skipping duplicate creation", self.start_date, self.last_count+1)
 *                         logger.info("Existing dummy entry: start_time=%s, end_time=%s, counter=%s, is_uploaded=%s", existing_dummy.start_time, existing_dummy.end_time, existing_dummy.counter, existing_dummy.is_uploaded)
*/
                        goto __pyx_L161;
                      }

                      /* "ws_package/controllers/activity_controller.py":2073
 *                         first_entry = existing_dummy
 *                     else:
 *                         logger.info("Creating first dummy entry: start_date=%s, counter=%s, is_uploaded=True, break_id=%s, will be saved as is_break=%s", self.start_date, self.last_count+1, current_break_id, current_break_id if current_break_id else 0)             # <<<<<<<<<<<<<<
 *                         logger.debug("[Timing][Python] Creating first dummy entry with break_id=%s...", current_break_id)
 *                         first_entry = await self.activity_service.save_first_activity_log(empty_activity_level, self.start_date, self.start_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id)
*/
                      /*else*/ {
                        __pyx_t_15 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2073, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_3);
                        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2073, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_1);
                        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_start_date); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2073, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_3);
                        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2073, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_6);
                        __pyx_t_4 = __Pyx_PyLong_AddObjC(__pyx_t_6, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2073, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_4);
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_current_break_id); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2073, __pyx_L154_error)
                        if (__pyx_t_8) {
                          __Pyx_INCREF(__pyx_cur_scope->__pyx_v_current_break_id);
                          __pyx_t_6 = __pyx_cur_scope->__pyx_v_current_break_id;
                        } else {
                          __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
                          __pyx_t_6 = __pyx_mstate_global->__pyx_int_0;
                        }
                        __pyx_t_7 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_1))) {
                          __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_1);
                          assert(__pyx_t_15);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
                          __Pyx_INCREF(__pyx_t_15);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
                          __pyx_t_7 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[6] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Creating_first_dummy_entry_start, __pyx_t_3, __pyx_t_4, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_t_6};
                          __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_7, (6-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2073, __pyx_L154_error)
                          __Pyx_GOTREF(__pyx_t_5);
                        }
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                        /* "ws_package/controllers/activity_controller.py":2074
 *                     else:
 *                         logger.info("Creating first dummy entry: start_date=%s, counter=%s, is_uploaded=True, break_id=%s, will be saved as is_break=%s", self.start_date, self.last_count+1, current_break_id, current_break_id if current_break_id else 0)
 *                         logger.debug("[Timing][Python] Creating first dummy entry with break_id=%s...", current_break_id)             # <<<<<<<<<<<<<<
 *                         first_entry = await self.activity_service.save_first_activity_log(empty_activity_level, self.start_date, self.start_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id)
 *                         logger.debug("[Timing][Python] First dummy entry created")
*/
                        __pyx_t_1 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2074, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_6);
                        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2074, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_4);
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __pyx_t_7 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_4))) {
                          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
                          assert(__pyx_t_1);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                          __Pyx_INCREF(__pyx_t_1);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                          __pyx_t_7 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Timing_Python_Creating_first_du, __pyx_cur_scope->__pyx_v_current_break_id};
                          __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2074, __pyx_L154_error)
                          __Pyx_GOTREF(__pyx_t_5);
                        }
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                        /* "ws_package/controllers/activity_controller.py":2075
 *                         logger.info("Creating first dummy entry: start_date=%s, counter=%s, is_uploaded=True, break_id=%s, will be saved as is_break=%s", self.start_date, self.last_count+1, current_break_id, current_break_id if current_break_id else 0)
 *                         logger.debug("[Timing][Python] Creating first dummy entry with break_id=%s...", current_break_id)
 *                         first_entry = await self.activity_service.save_first_activity_log(empty_activity_level, self.start_date, self.start_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id)             # <<<<<<<<<<<<<<
 *                         logger.debug("[Timing][Python] First dummy entry created")
 *         except Exception as e:
*/
                        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2075, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_1);
                        __pyx_t_4 = __pyx_t_1;
                        __Pyx_INCREF(__pyx_t_4);
                        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_start_date); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2075, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_6);
                        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_start_date); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2075, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_3);
                        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2075, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_15);
                        __pyx_t_2 = __Pyx_PyLong_AddObjC(__pyx_t_15, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2075, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_2);
                        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                        __pyx_t_34 = __pyx_cur_scope->__pyx_v_self;
                        __Pyx_INCREF(__pyx_t_34);
                        __pyx_t_7 = 0;
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_34, NULL};
                          __pyx_t_15 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_today_weekday, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                          if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2075, __pyx_L154_error)
                          __Pyx_GOTREF(__pyx_t_15);
                        }
                        __pyx_t_7 = 0;
                        {
                          PyObject *__pyx_callargs[6 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_empty_activity_level, __pyx_t_6, __pyx_t_3, __pyx_t_2, __pyx_t_15};
                          __pyx_t_34 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2075, __pyx_L154_error)
                          __Pyx_GOTREF(__pyx_t_34);
                          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_break_id, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_t_34, __pyx_callargs+6, 0) < (0)) __PYX_ERR(0, 2075, __pyx_L154_error)
                          __pyx_t_5 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_save_first_activity_log, __pyx_callargs+__pyx_t_7, (6-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_34);
                          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                          __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2075, __pyx_L154_error)
                          __Pyx_GOTREF(__pyx_t_5);
                        }
                        __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                        if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                          __Pyx_GOTREF(__pyx_r);
                          __Pyx_XGIVEREF(__pyx_t_11);
                          __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                          __Pyx_XGIVEREF(__pyx_t_12);
                          __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                          __Pyx_XGIVEREF(__pyx_t_13);
                          __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                          __Pyx_XGIVEREF(__pyx_t_18);
                          __pyx_cur_scope->__pyx_t_3 = __pyx_t_18;
                          __Pyx_XGIVEREF(__pyx_t_19);
                          __pyx_cur_scope->__pyx_t_4 = __pyx_t_19;
                          __Pyx_XGIVEREF(__pyx_t_20);
                          __pyx_cur_scope->__pyx_t_5 = __pyx_t_20;
                          __Pyx_XGIVEREF(__pyx_t_21);
                          __pyx_cur_scope->__pyx_t_6 = __pyx_t_21;
                          __Pyx_XGIVEREF(__pyx_t_22);
                          __pyx_cur_scope->__pyx_t_7 = __pyx_t_22;
                          __Pyx_XGIVEREF(__pyx_t_23);
                          __pyx_cur_scope->__pyx_t_8 = __pyx_t_23;
                          __Pyx_XGIVEREF(__pyx_t_31);
                          __pyx_cur_scope->__pyx_t_9 = __pyx_t_31;
                          __Pyx_XGIVEREF(__pyx_t_32);
                          __pyx_cur_scope->__pyx_t_10 = __pyx_t_32;
                          __Pyx_XGIVEREF(__pyx_r);
                          __Pyx_RefNannyFinishContext();
                          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                          /* return from generator, awaiting value */
                          __pyx_generator->resume_label = 9;
                          return __pyx_r;
                          __pyx_L162_resume_from_await:;
                          __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                          __pyx_cur_scope->__pyx_t_0 = 0;
                          __Pyx_XGOTREF(__pyx_t_11);
                          __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                          __pyx_cur_scope->__pyx_t_1 = 0;
                          __Pyx_XGOTREF(__pyx_t_12);
                          __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                          __pyx_cur_scope->__pyx_t_2 = 0;
                          __Pyx_XGOTREF(__pyx_t_13);
                          __pyx_t_18 = __pyx_cur_scope->__pyx_t_3;
                          __pyx_cur_scope->__pyx_t_3 = 0;
                          __Pyx_XGOTREF(__pyx_t_18);
                          __pyx_t_19 = __pyx_cur_scope->__pyx_t_4;
                          __pyx_cur_scope->__pyx_t_4 = 0;
                          __Pyx_XGOTREF(__pyx_t_19);
                          __pyx_t_20 = __pyx_cur_scope->__pyx_t_5;
                          __pyx_cur_scope->__pyx_t_5 = 0;
                          __Pyx_XGOTREF(__pyx_t_20);
                          __pyx_t_21 = __pyx_cur_scope->__pyx_t_6;
                          __pyx_cur_scope->__pyx_t_6 = 0;
                          __Pyx_XGOTREF(__pyx_t_21);
                          __pyx_t_22 = __pyx_cur_scope->__pyx_t_7;
                          __pyx_cur_scope->__pyx_t_7 = 0;
                          __Pyx_XGOTREF(__pyx_t_22);
                          __pyx_t_23 = __pyx_cur_scope->__pyx_t_8;
                          __pyx_cur_scope->__pyx_t_8 = 0;
                          __Pyx_XGOTREF(__pyx_t_23);
                          __pyx_t_31 = __pyx_cur_scope->__pyx_t_9;
                          __pyx_cur_scope->__pyx_t_9 = 0;
                          __Pyx_XGOTREF(__pyx_t_31);
                          __pyx_t_32 = __pyx_cur_scope->__pyx_t_10;
                          __pyx_cur_scope->__pyx_t_10 = 0;
                          __Pyx_XGOTREF(__pyx_t_32);
                          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2075, __pyx_L154_error)
                          __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
                        } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                          __Pyx_GOTREF(__pyx_r);
                          __pyx_t_5 = __pyx_r; __pyx_r = NULL;
                        } else {
                          __Pyx_XGOTREF(__pyx_r);
                          __PYX_ERR(0, 2075, __pyx_L154_error)
                        }
                        __Pyx_GIVEREF(__pyx_t_5);
                        __pyx_cur_scope->__pyx_v_first_entry = __pyx_t_5;
                        __pyx_t_5 = 0;

                        /* "ws_package/controllers/activity_controller.py":2076
 *                         logger.debug("[Timing][Python] Creating first dummy entry with break_id=%s...", current_break_id)
 *                         first_entry = await self.activity_service.save_first_activity_log(empty_activity_level, self.start_date, self.start_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id)
 *                         logger.debug("[Timing][Python] First dummy entry created")             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             # If check fails, proceed with creation (fail-safe to ensure functionality continues)
*/
                        __pyx_t_1 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2076, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_34);
                        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2076, __pyx_L154_error)
                        __Pyx_GOTREF(__pyx_t_15);
                        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                        __pyx_t_7 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_15))) {
                          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_15);
                          assert(__pyx_t_1);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                          __Pyx_INCREF(__pyx_t_1);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                          __pyx_t_7 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Timing_Python_First_dummy_entry};
                          __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2076, __pyx_L154_error)
                          __Pyx_GOTREF(__pyx_t_5);
                        }
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      }
                      __pyx_L161:;

                      /* "ws_package/controllers/activity_controller.py":2055
 * 
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     # Check for exact match: start_time == end_time == self.start_date AND counter matches
 *                     # This identifies the first dummy entry (which has start_time == end_time)
*/
                    }
                    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                    __Pyx_XDECREF(__pyx_t_31); __pyx_t_31 = 0;
                    __Pyx_XDECREF(__pyx_t_32); __pyx_t_32 = 0;
                    goto __pyx_L159_try_end;
                    __pyx_L154_error:;
                    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                    __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                    __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                    __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                    __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                    __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                    /*except:*/ {
                      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_15, &__pyx_t_1) < 0) __PYX_ERR(0, 2055, __pyx_L156_except_error)
                      __Pyx_XGOTREF(__pyx_t_5);
                      __Pyx_XGOTREF(__pyx_t_15);
                      __Pyx_XGOTREF(__pyx_t_1);
                      __pyx_t_34 = PyTuple_Pack(3, __pyx_t_5, __pyx_t_15, __pyx_t_1); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2055, __pyx_L156_except_error)
                      __Pyx_GOTREF(__pyx_t_34);
                      __pyx_t_39 = __Pyx_PyObject_Call(__pyx_t_22, __pyx_t_34, NULL);
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                      __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                      if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 2055, __pyx_L156_except_error)
                      __Pyx_GOTREF(__pyx_t_39);
                      __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_39, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                      if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_5);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_5;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_t_19);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_19;
                        __Pyx_XGIVEREF(__pyx_t_20);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_20;
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_21;
                        __Pyx_XGIVEREF(__pyx_t_22);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_22;
                        __Pyx_XGIVEREF(__pyx_t_23);
                        __pyx_cur_scope->__pyx_t_11 = __pyx_t_23;
                        __Pyx_XGIVEREF(__pyx_t_31);
                        __pyx_cur_scope->__pyx_t_12 = __pyx_t_31;
                        __Pyx_XGIVEREF(__pyx_t_32);
                        __pyx_cur_scope->__pyx_t_13 = __pyx_t_32;
                        __Pyx_XGIVEREF(__pyx_t_39);
                        __pyx_cur_scope->__pyx_t_14 = __pyx_t_39;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_SwapException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 10;
                        return __pyx_r;
                        __pyx_L166_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_5 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_5);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        __pyx_t_19 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_19);
                        __pyx_t_20 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_20);
                        __pyx_t_21 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_21);
                        __pyx_t_22 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_22);
                        __pyx_t_23 = __pyx_cur_scope->__pyx_t_11;
                        __pyx_cur_scope->__pyx_t_11 = 0;
                        __Pyx_XGOTREF(__pyx_t_23);
                        __pyx_t_31 = __pyx_cur_scope->__pyx_t_12;
                        __pyx_cur_scope->__pyx_t_12 = 0;
                        __Pyx_XGOTREF(__pyx_t_31);
                        __pyx_t_32 = __pyx_cur_scope->__pyx_t_13;
                        __pyx_cur_scope->__pyx_t_13 = 0;
                        __Pyx_XGOTREF(__pyx_t_32);
                        __pyx_t_39 = __pyx_cur_scope->__pyx_t_14;
                        __pyx_cur_scope->__pyx_t_14 = 0;
                        __Pyx_XGOTREF(__pyx_t_39);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2055, __pyx_L156_except_error)
                        __pyx_t_34 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_34);
                      } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_34 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 2055, __pyx_L156_except_error)
                      }
                      __pyx_t_39 = __pyx_t_34;
                      __pyx_t_34 = 0;
                      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_39);
                      __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                      if (__pyx_t_8 < (0)) __PYX_ERR(0, 2055, __pyx_L156_except_error)
                      __pyx_t_9 = (!__pyx_t_8);
                      if (unlikely(__pyx_t_9)) {
                        __Pyx_GIVEREF(__pyx_t_5);
                        __Pyx_GIVEREF(__pyx_t_15);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __Pyx_ErrRestoreWithState(__pyx_t_5, __pyx_t_15, __pyx_t_1);
                        __pyx_t_5 = 0;  __pyx_t_15 = 0;  __pyx_t_1 = 0; 
                        __PYX_ERR(0, 2055, __pyx_L156_except_error)
                      }
                      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                      goto __pyx_L155_exception_handled;
                    }
                    __pyx_L156_except_error:;
                    __Pyx_XGIVEREF(__pyx_t_23);
                    __Pyx_XGIVEREF(__pyx_t_31);
                    __Pyx_XGIVEREF(__pyx_t_32);
                    __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_31, __pyx_t_32);
                    goto __pyx_L143_error;
                    __pyx_L155_exception_handled:;
                    __Pyx_XGIVEREF(__pyx_t_23);
                    __Pyx_XGIVEREF(__pyx_t_31);
                    __Pyx_XGIVEREF(__pyx_t_32);
                    __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_31, __pyx_t_32);
                    __pyx_L159_try_end:;
                  }
                }
                /*finally:*/ {
                  /*normal exit:*/{
                    if (__pyx_t_22) {
                      __pyx_t_32 = __Pyx_PyObject_Call(__pyx_t_22, __pyx_mstate_global->__pyx_tuple[7], NULL);
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                      if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 2055, __pyx_L143_error)
                      __Pyx_GOTREF(__pyx_t_32);
                      __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_32, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0;
                      if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_t_19);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_19;
                        __Pyx_XGIVEREF(__pyx_t_20);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_20;
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_21;
                        __Pyx_XGIVEREF(__pyx_t_22);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_22;
                        __Pyx_XGIVEREF(__pyx_t_32);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_32;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 11;
                        return __pyx_r;
                        __pyx_L167_resume_from_await:;
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        __pyx_t_19 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_19);
                        __pyx_t_20 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_20);
                        __pyx_t_21 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_21);
                        __pyx_t_22 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_22);
                        __pyx_t_32 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_32);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2055, __pyx_L143_error)
                        __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
                      } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_1 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 2055, __pyx_L143_error)
                      }
                      __pyx_t_32 = __pyx_t_1;
                      __pyx_t_1 = 0;
                      __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0;
                    }
                    goto __pyx_L153;
                  }
                  __pyx_L153:;
                }
                goto __pyx_L168;
                __pyx_L149_error:;
                __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                goto __pyx_L143_error;
                __pyx_L168:;
              }

              /* "ws_package/controllers/activity_controller.py":2054
 *             await asyncio.sleep(0.1)  # Small delay to ensure commit is visible
 * 
 *             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     # Check for exact match: start_time == end_time == self.start_date AND counter matches
*/
            }
            __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
            __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
            goto __pyx_L148_try_end;
            __pyx_L143_error:;
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
            __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
            __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
            __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
            __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
            __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            /*except:*/ {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_15, &__pyx_t_5) < 0) __PYX_ERR(0, 2054, __pyx_L145_except_error)
              __Pyx_XGOTREF(__pyx_t_1);
              __Pyx_XGOTREF(__pyx_t_15);
              __Pyx_XGOTREF(__pyx_t_5);
              __pyx_t_34 = PyTuple_Pack(3, __pyx_t_1, __pyx_t_15, __pyx_t_5); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2054, __pyx_L145_except_error)
              __Pyx_GOTREF(__pyx_t_34);
              __pyx_t_22 = __Pyx_PyObject_Call(__pyx_t_18, __pyx_t_34, NULL);
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
              __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
              if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 2054, __pyx_L145_except_error)
              __Pyx_GOTREF(__pyx_t_22);
              __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_22);
              __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
              if (__pyx_t_9 < (0)) __PYX_ERR(0, 2054, __pyx_L145_except_error)
              __pyx_t_8 = (!__pyx_t_9);
              if (unlikely(__pyx_t_8)) {
                __Pyx_GIVEREF(__pyx_t_1);
                __Pyx_GIVEREF(__pyx_t_15);
                __Pyx_XGIVEREF(__pyx_t_5);
                __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_15, __pyx_t_5);
                __pyx_t_1 = 0;  __pyx_t_15 = 0;  __pyx_t_5 = 0; 
                __PYX_ERR(0, 2054, __pyx_L145_except_error)
              }
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              goto __pyx_L144_exception_handled;
            }
            __pyx_L145_except_error:;
            __Pyx_XGIVEREF(__pyx_t_19);
            __Pyx_XGIVEREF(__pyx_t_20);
            __Pyx_XGIVEREF(__pyx_t_21);
            __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21);
            goto __pyx_L131_error;
            __pyx_L144_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_19);
            __Pyx_XGIVEREF(__pyx_t_20);
            __Pyx_XGIVEREF(__pyx_t_21);
            __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21);
            __pyx_L148_try_end:;
          }
        }
        /*finally:*/ {
          /*normal exit:*/{
            if (__pyx_t_18) {
              __pyx_t_21 = __Pyx_PyObject_Call(__pyx_t_18, __pyx_mstate_global->__pyx_tuple[7], NULL);
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
              if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 2054, __pyx_L131_error)
              __Pyx_GOTREF(__pyx_t_21);
              __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
            }
            goto __pyx_L142;
          }
          __pyx_L142:;
        }
        goto __pyx_L172;
        __pyx_L139_error:;
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        goto __pyx_L131_error;
        __pyx_L172:;
      }

      /* "ws_package/controllers/activity_controller.py":2049
 *         # CRITICAL: Check if first dummy entry already exists to prevent duplicates
 *         # This can happen if __start_device_activity is called multiple times (e.g., from deferred messages)
 *         try:             # <<<<<<<<<<<<<<
 *             # First, flush queue to ensure any pending writes are visible
 *             await db_writer_service.process_immediately()
*/
    }
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    goto __pyx_L136_try_end;
    __pyx_L131_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
    __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
    __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
    __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
    __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
    __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "ws_package/controllers/activity_controller.py":2077
 *                         first_entry = await self.activity_service.save_first_activity_log(empty_activity_level, self.start_date, self.start_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id)
 *                         logger.debug("[Timing][Python] First dummy entry created")
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             # If check fails, proceed with creation (fail-safe to ensure functionality continues)
 *             logger.warning("Error checking for existing first dummy entry: %s - proceeding with creation", e)
*/
    __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_14) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_15, &__pyx_t_1) < 0) __PYX_ERR(0, 2077, __pyx_L133_except_error)
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_15);
      __Pyx_XGOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_15);
      __Pyx_GIVEREF(__pyx_t_15);
      __pyx_cur_scope->__pyx_v_e = __pyx_t_15;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":2079
 *         except Exception as e:
 *             # If check fails, proceed with creation (fail-safe to ensure functionality continues)
 *             logger.warning("Error checking for existing first dummy entry: %s - proceeding with creation", e)             # <<<<<<<<<<<<<<
 *             logger.info("Creating first dummy entry: start_date=%s, counter=%s, is_uploaded=True, break_id=%s, will be saved as is_break=%s", self.start_date, self.last_count+1, current_break_id, current_break_id if current_break_id else 0)
 *             logger.debug("[Timing][Python] Creating first dummy entry with break_id=%s...", current_break_id)
*/
        __pyx_t_2 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2079, __pyx_L178_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2079, __pyx_L178_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
          assert(__pyx_t_2);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Error_checking_for_existing_firs, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_34 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2079, __pyx_L178_error)
          __Pyx_GOTREF(__pyx_t_34);
        }
        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;

        /* "ws_package/controllers/activity_controller.py":2080
 *             # If check fails, proceed with creation (fail-safe to ensure functionality continues)
 *             logger.warning("Error checking for existing first dummy entry: %s - proceeding with creation", e)
 *             logger.info("Creating first dummy entry: start_date=%s, counter=%s, is_uploaded=True, break_id=%s, will be saved as is_break=%s", self.start_date, self.last_count+1, current_break_id, current_break_id if current_break_id else 0)             # <<<<<<<<<<<<<<
 *             logger.debug("[Timing][Python] Creating first dummy entry with break_id=%s...", current_break_id)
 *             first_entry = await self.activity_service.save_first_activity_log(empty_activity_level, self.start_date, self.start_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id)
*/
        __pyx_t_6 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2080, __pyx_L178_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2080, __pyx_L178_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_start_date); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2080, __pyx_L178_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2080, __pyx_L178_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_37 = __Pyx_PyLong_AddObjC(__pyx_t_4, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2080, __pyx_L178_error)
        __Pyx_GOTREF(__pyx_t_37);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_current_break_id); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2080, __pyx_L178_error)
        if (__pyx_t_8) {
          __Pyx_INCREF(__pyx_cur_scope->__pyx_v_current_break_id);
          __pyx_t_4 = __pyx_cur_scope->__pyx_v_current_break_id;
        } else {
          __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
          __pyx_t_4 = __pyx_mstate_global->__pyx_int_0;
        }
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
          assert(__pyx_t_6);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[6] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Creating_first_dummy_entry_start, __pyx_t_2, __pyx_t_37, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_t_4};
          __pyx_t_34 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (6-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2080, __pyx_L178_error)
          __Pyx_GOTREF(__pyx_t_34);
        }
        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;

        /* "ws_package/controllers/activity_controller.py":2081
 *             logger.warning("Error checking for existing first dummy entry: %s - proceeding with creation", e)
 *             logger.info("Creating first dummy entry: start_date=%s, counter=%s, is_uploaded=True, break_id=%s, will be saved as is_break=%s", self.start_date, self.last_count+1, current_break_id, current_break_id if current_break_id else 0)
 *             logger.debug("[Timing][Python] Creating first dummy entry with break_id=%s...", current_break_id)             # <<<<<<<<<<<<<<
 *             first_entry = await self.activity_service.save_first_activity_log(empty_activity_level, self.start_date, self.start_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id)
 *             logger.debug("[Timing][Python] First dummy entry created")
*/
        __pyx_t_3 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2081, __pyx_L178_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_37 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2081, __pyx_L178_error)
        __Pyx_GOTREF(__pyx_t_37);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_37))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_37);
          assert(__pyx_t_3);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_37);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_37, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Timing_Python_Creating_first_du, __pyx_cur_scope->__pyx_v_current_break_id};
          __pyx_t_34 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_37, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
          if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2081, __pyx_L178_error)
          __Pyx_GOTREF(__pyx_t_34);
        }
        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;

        /* "ws_package/controllers/activity_controller.py":2082
 *             logger.info("Creating first dummy entry: start_date=%s, counter=%s, is_uploaded=True, break_id=%s, will be saved as is_break=%s", self.start_date, self.last_count+1, current_break_id, current_break_id if current_break_id else 0)
 *             logger.debug("[Timing][Python] Creating first dummy entry with break_id=%s...", current_break_id)
 *             first_entry = await self.activity_service.save_first_activity_log(empty_activity_level, self.start_date, self.start_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id)             # <<<<<<<<<<<<<<
 *             logger.debug("[Timing][Python] First dummy entry created")
 * 
*/
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2082, __pyx_L178_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_37 = __pyx_t_3;
        __Pyx_INCREF(__pyx_t_37);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_start_date); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2082, __pyx_L178_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_start_date); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2082, __pyx_L178_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2082, __pyx_L178_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_36 = __Pyx_PyLong_AddObjC(__pyx_t_6, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_36)) __PYX_ERR(0, 2082, __pyx_L178_error)
        __Pyx_GOTREF(__pyx_t_36);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_33 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_33);
        __pyx_t_7 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_33, NULL};
          __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_today_weekday, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2082, __pyx_L178_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __pyx_t_7 = 0;
        {
          PyObject *__pyx_callargs[6 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_37, __pyx_cur_scope->__pyx_v_empty_activity_level, __pyx_t_4, __pyx_t_2, __pyx_t_36, __pyx_t_6};
          __pyx_t_33 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2082, __pyx_L178_error)
          __Pyx_GOTREF(__pyx_t_33);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_break_id, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_t_33, __pyx_callargs+6, 0) < (0)) __PYX_ERR(0, 2082, __pyx_L178_error)
          __pyx_t_34 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_save_first_activity_log, __pyx_callargs+__pyx_t_7, (6-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_33);
          __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_36); __pyx_t_36 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2082, __pyx_L178_error)
          __Pyx_GOTREF(__pyx_t_34);
        }
        __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_34, &__pyx_r);
        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
        if (likely(__pyx_t_26 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_1);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
          __Pyx_XGIVEREF(__pyx_t_5);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_5;
          __Pyx_XGIVEREF(__pyx_t_11);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_11;
          __Pyx_XGIVEREF(__pyx_t_12);
          __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
          __Pyx_XGIVEREF(__pyx_t_13);
          __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
          __Pyx_XGIVEREF(__pyx_t_15);
          __pyx_cur_scope->__pyx_t_5 = __pyx_t_15;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_SwapException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 12;
          return __pyx_r;
          __pyx_L180_resume_from_await:;
          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_1);
          __pyx_t_5 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_5);
          __pyx_t_11 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_11);
          __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
          __pyx_cur_scope->__pyx_t_3 = 0;
          __Pyx_XGOTREF(__pyx_t_12);
          __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
          __pyx_cur_scope->__pyx_t_4 = 0;
          __Pyx_XGOTREF(__pyx_t_13);
          __pyx_t_15 = __pyx_cur_scope->__pyx_t_5;
          __pyx_cur_scope->__pyx_t_5 = 0;
          __Pyx_XGOTREF(__pyx_t_15);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2082, __pyx_L178_error)
          __pyx_t_34 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_34);
        } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __pyx_t_34 = __pyx_r; __pyx_r = NULL;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 2082, __pyx_L178_error)
        }
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_first_entry);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_first_entry, __pyx_t_34);
        __Pyx_GIVEREF(__pyx_t_34);
        __pyx_t_34 = 0;

        /* "ws_package/controllers/activity_controller.py":2083
 *             logger.debug("[Timing][Python] Creating first dummy entry with break_id=%s...", current_break_id)
 *             first_entry = await self.activity_service.save_first_activity_log(empty_activity_level, self.start_date, self.start_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id)
 *             logger.debug("[Timing][Python] First dummy entry created")             # <<<<<<<<<<<<<<
 * 
 *         logger.info("First dummy entry created successfully: start_time=%s, end_time=%s, counter=%s, is_uploaded=%s", first_entry.start_time if first_entry else 'None', first_entry.end_time if first_entry else 'None', first_entry.counter if first_entry else 'None', first_entry.is_uploaded if first_entry else 'None')
*/
        __pyx_t_3 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2083, __pyx_L178_error)
        __Pyx_GOTREF(__pyx_t_33);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2083, __pyx_L178_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
          assert(__pyx_t_3);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Timing_Python_First_dummy_entry};
          __pyx_t_34 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2083, __pyx_L178_error)
          __Pyx_GOTREF(__pyx_t_34);
        }
        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
      }

      /* "ws_package/controllers/activity_controller.py":2077
 *                         first_entry = await self.activity_service.save_first_activity_log(empty_activity_level, self.start_date, self.start_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id)
 *                         logger.debug("[Timing][Python] First dummy entry created")
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             # If check fails, proceed with creation (fail-safe to ensure functionality continues)
 *             logger.warning("Error checking for existing first dummy entry: %s - proceeding with creation", e)
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          goto __pyx_L179;
        }
        __pyx_L178_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_18 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_22 = 0; __pyx_t_32 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
          __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
          __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
          __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
          __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
          __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_22, &__pyx_t_32);
          if ( unlikely(__Pyx_GetException(&__pyx_t_18, &__pyx_t_21, &__pyx_t_20) < 0)) __Pyx_ErrFetch(&__pyx_t_18, &__pyx_t_21, &__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_18);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_32);
          __pyx_t_14 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_40 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_32);
          __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_22, __pyx_t_32);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_ErrRestore(__pyx_t_18, __pyx_t_21, __pyx_t_20);
          __pyx_t_18 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_22 = 0; __pyx_t_32 = 0;
          __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_40;
          goto __pyx_L133_except_error;
        }
        __pyx_L179:;
      }
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L132_exception_handled;
    }
    goto __pyx_L133_except_error;

    /* "ws_package/controllers/activity_controller.py":2049
 *         # CRITICAL: Check if first dummy entry already exists to prevent duplicates
 *         # This can happen if __start_device_activity is called multiple times (e.g., from deferred messages)
 *         try:             # <<<<<<<<<<<<<<
 *             # First, flush queue to ensure any pending writes are visible
 *             await db_writer_service.process_immediately()
*/
    __pyx_L133_except_error:;
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_XGIVEREF(__pyx_t_12);
    __Pyx_XGIVEREF(__pyx_t_13);
    __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
    goto __pyx_L1_error;
    __pyx_L132_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_XGIVEREF(__pyx_t_12);
    __Pyx_XGIVEREF(__pyx_t_13);
    __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
    __pyx_L136_try_end:;
  }

  /* "ws_package/controllers/activity_controller.py":2085
 *             logger.debug("[Timing][Python] First dummy entry created")
 * 
 *         logger.info("First dummy entry created successfully: start_time=%s, end_time=%s, counter=%s, is_uploaded=%s", first_entry.start_time if first_entry else 'None', first_entry.end_time if first_entry else 'None', first_entry.counter if first_entry else 'None', first_entry.is_uploaded if first_entry else 'None')             # <<<<<<<<<<<<<<
 * 
 *         # Flush the queue immediately to ensure first entry is committed to database
*/
  __pyx_t_15 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2085, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2085, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_34);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (unlikely(!__pyx_cur_scope->__pyx_v_first_entry)) { __Pyx_RaiseUnboundLocalError("first_entry"); __PYX_ERR(0, 2085, __pyx_L1_error) }
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_first_entry); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2085, __pyx_L1_error)
  if (__pyx_t_8) {
    if (unlikely(!__pyx_cur_scope->__pyx_v_first_entry)) { __Pyx_RaiseUnboundLocalError("first_entry"); __PYX_ERR(0, 2085, __pyx_L1_error) }
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_first_entry, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2085, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_5 = __pyx_t_6;
    __pyx_t_6 = 0;
  } else {
    __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_None);
    __pyx_t_5 = __pyx_mstate_global->__pyx_n_u_None;
  }
  if (unlikely(!__pyx_cur_scope->__pyx_v_first_entry)) { __Pyx_RaiseUnboundLocalError("first_entry"); __PYX_ERR(0, 2085, __pyx_L1_error) }
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_first_entry); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2085, __pyx_L1_error)
  if (__pyx_t_8) {
    if (unlikely(!__pyx_cur_scope->__pyx_v_first_entry)) { __Pyx_RaiseUnboundLocalError("first_entry"); __PYX_ERR(0, 2085, __pyx_L1_error) }
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_first_entry, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2085, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_6 = __pyx_t_3;
    __pyx_t_3 = 0;
  } else {
    __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_None);
    __pyx_t_6 = __pyx_mstate_global->__pyx_n_u_None;
  }
  if (unlikely(!__pyx_cur_scope->__pyx_v_first_entry)) { __Pyx_RaiseUnboundLocalError("first_entry"); __PYX_ERR(0, 2085, __pyx_L1_error) }
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_first_entry); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2085, __pyx_L1_error)
  if (__pyx_t_8) {
    if (unlikely(!__pyx_cur_scope->__pyx_v_first_entry)) { __Pyx_RaiseUnboundLocalError("first_entry"); __PYX_ERR(0, 2085, __pyx_L1_error) }
    __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_first_entry, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2085, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_33);
    __pyx_t_3 = __pyx_t_33;
    __pyx_t_33 = 0;
  } else {
    __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_None);
    __pyx_t_3 = __pyx_mstate_global->__pyx_n_u_None;
  }
  if (unlikely(!__pyx_cur_scope->__pyx_v_first_entry)) { __Pyx_RaiseUnboundLocalError("first_entry"); __PYX_ERR(0, 2085, __pyx_L1_error) }
  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_first_entry); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2085, __pyx_L1_error)
  if (__pyx_t_8) {
    if (unlikely(!__pyx_cur_scope->__pyx_v_first_entry)) { __Pyx_RaiseUnboundLocalError("first_entry"); __PYX_ERR(0, 2085, __pyx_L1_error) }
    __pyx_t_36 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_first_entry, __pyx_mstate_global->__pyx_n_u_is_uploaded); if (unlikely(!__pyx_t_36)) __PYX_ERR(0, 2085, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_36);
    __pyx_t_33 = __pyx_t_36;
    __pyx_t_36 = 0;
  } else {
    __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_None);
    __pyx_t_33 = __pyx_mstate_global->__pyx_n_u_None;
  }
  __pyx_t_7 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_34))) {
    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_34);
    assert(__pyx_t_15);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_34);
    __Pyx_INCREF(__pyx_t_15);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_34, __pyx__function);
    __pyx_t_7 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[6] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_First_dummy_entry_created_succes, __pyx_t_5, __pyx_t_6, __pyx_t_3, __pyx_t_33};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_34, __pyx_callargs+__pyx_t_7, (6-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
    __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2085, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":2088
 * 
 *         # Flush the queue immediately to ensure first entry is committed to database
 *         try:             # <<<<<<<<<<<<<<
 *             logger.debug("[Timing][Python] Flushing DB write queue...")
 *             processed_count = await db_writer_service.process_immediately()
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
    __Pyx_XGOTREF(__pyx_t_13);
    __Pyx_XGOTREF(__pyx_t_12);
    __Pyx_XGOTREF(__pyx_t_11);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":2089
 *         # Flush the queue immediately to ensure first entry is committed to database
 *         try:
 *             logger.debug("[Timing][Python] Flushing DB write queue...")             # <<<<<<<<<<<<<<
 *             processed_count = await db_writer_service.process_immediately()
 *             logger.debug("[Timing][Python] DB write queue flushed")
*/
      __pyx_t_34 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2089, __pyx_L185_error)
      __Pyx_GOTREF(__pyx_t_33);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2089, __pyx_L185_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
      __pyx_t_7 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_34 = PyMethod_GET_SELF(__pyx_t_3);
        assert(__pyx_t_34);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_34);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
        __pyx_t_7 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_34, __pyx_mstate_global->__pyx_kp_u_Timing_Python_Flushing_DB_write};
        __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2089, __pyx_L185_error)
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":2090
 *         try:
 *             logger.debug("[Timing][Python] Flushing DB write queue...")
 *             processed_count = await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 *             logger.debug("[Timing][Python] DB write queue flushed")
 *             logger.info("Flushed %s queued database writes - first dummy entry should now be in database", processed_count)
*/
      __pyx_t_3 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2090, __pyx_L185_error)
      __Pyx_GOTREF(__pyx_t_34);
      __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2090, __pyx_L185_error)
      __Pyx_GOTREF(__pyx_t_33);
      __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
      __pyx_t_7 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_33))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_33);
        assert(__pyx_t_3);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
        __pyx_t_7 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
        __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2090, __pyx_L185_error)
        __Pyx_GOTREF(__pyx_t_1);
      }
      __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (likely(__pyx_t_26 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_11);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
        __Pyx_XGIVEREF(__pyx_t_12);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
        __Pyx_XGIVEREF(__pyx_t_13);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 13;
        return __pyx_r;
        __pyx_L191_resume_from_await:;
        __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_11);
        __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_12);
        __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_13);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2090, __pyx_L185_error)
        __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
      } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __pyx_t_1 = __pyx_r; __pyx_r = NULL;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 2090, __pyx_L185_error)
      }
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_cur_scope->__pyx_v_processed_count = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":2091
 *             logger.debug("[Timing][Python] Flushing DB write queue...")
 *             processed_count = await db_writer_service.process_immediately()
 *             logger.debug("[Timing][Python] DB write queue flushed")             # <<<<<<<<<<<<<<
 *             logger.info("Flushed %s queued database writes - first dummy entry should now be in database", processed_count)
 * 
*/
      __pyx_t_33 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2091, __pyx_L185_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2091, __pyx_L185_error)
      __Pyx_GOTREF(__pyx_t_34);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_7 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_34))) {
        __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_34);
        assert(__pyx_t_33);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_34);
        __Pyx_INCREF(__pyx_t_33);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_34, __pyx__function);
        __pyx_t_7 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_33, __pyx_mstate_global->__pyx_kp_u_Timing_Python_DB_write_queue_fl};
        __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_34, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2091, __pyx_L185_error)
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":2092
 *             processed_count = await db_writer_service.process_immediately()
 *             logger.debug("[Timing][Python] DB write queue flushed")
 *             logger.info("Flushed %s queued database writes - first dummy entry should now be in database", processed_count)             # <<<<<<<<<<<<<<
 * 
 *         except Exception as e:
*/
      __pyx_t_34 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2092, __pyx_L185_error)
      __Pyx_GOTREF(__pyx_t_33);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2092, __pyx_L185_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
      __pyx_t_7 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_34 = PyMethod_GET_SELF(__pyx_t_3);
        assert(__pyx_t_34);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_34);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
        __pyx_t_7 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_34, __pyx_mstate_global->__pyx_kp_u_Flushed_s_queued_database_writes, __pyx_cur_scope->__pyx_v_processed_count};
        __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2092, __pyx_L185_error)
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":2088
 * 
 *         # Flush the queue immediately to ensure first entry is committed to database
 *         try:             # <<<<<<<<<<<<<<
 *             logger.debug("[Timing][Python] Flushing DB write queue...")
 *             processed_count = await db_writer_service.process_immediately()
*/
    }
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    goto __pyx_L190_try_end;
    __pyx_L185_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
    __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
    __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
    __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
    __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
    __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "ws_package/controllers/activity_controller.py":2094
 *             logger.info("Flushed %s queued database writes - first dummy entry should now be in database", processed_count)
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error flushing database write queue after first entry: %s", e, exc_info=True)
 * 
*/
    __pyx_t_16 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_16) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_34) < 0) __PYX_ERR(0, 2094, __pyx_L187_except_error)
      __Pyx_XGOTREF(__pyx_t_1);
      __Pyx_XGOTREF(__pyx_t_3);
      __Pyx_XGOTREF(__pyx_t_34);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_GIVEREF(__pyx_t_3);
      __pyx_cur_scope->__pyx_v_e = __pyx_t_3;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":2095
 * 
 *         except Exception as e:
 *             logger.error("Error flushing database write queue after first entry: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *         while not stop_event.is_set():
*/
        __pyx_t_6 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2095, __pyx_L197_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2095, __pyx_L197_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_15))) {
          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_15);
          assert(__pyx_t_6);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Error_flushing_database_write_qu, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_5 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2095, __pyx_L197_error)
          __Pyx_GOTREF(__pyx_t_5);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_5, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 2095, __pyx_L197_error)
          __pyx_t_33 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_5);
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2095, __pyx_L197_error)
          __Pyx_GOTREF(__pyx_t_33);
        }
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
      }

      /* "ws_package/controllers/activity_controller.py":2094
 *             logger.info("Flushed %s queued database writes - first dummy entry should now be in database", processed_count)
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error flushing database write queue after first entry: %s", e, exc_info=True)
 * 
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          goto __pyx_L198;
        }
        __pyx_L197_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_32 = 0; __pyx_t_22 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_18 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
          __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
          __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
          __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
          __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_21, &__pyx_t_18);
          if ( unlikely(__Pyx_GetException(&__pyx_t_32, &__pyx_t_22, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_32, &__pyx_t_22, &__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_32);
          __Pyx_XGOTREF(__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_18);
          __pyx_t_16 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_41 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_32);
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_ErrRestore(__pyx_t_32, __pyx_t_22, __pyx_t_19);
          __pyx_t_32 = 0; __pyx_t_22 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_18 = 0;
          __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_41;
          goto __pyx_L187_except_error;
        }
        __pyx_L198:;
      }
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
      goto __pyx_L186_exception_handled;
    }
    goto __pyx_L187_except_error;

    /* "ws_package/controllers/activity_controller.py":2088
 * 
 *         # Flush the queue immediately to ensure first entry is committed to database
 *         try:             # <<<<<<<<<<<<<<
 *             logger.debug("[Timing][Python] Flushing DB write queue...")
 *             processed_count = await db_writer_service.process_immediately()
*/
    __pyx_L187_except_error:;
    __Pyx_XGIVEREF(__pyx_t_13);
    __Pyx_XGIVEREF(__pyx_t_12);
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_12, __pyx_t_11);
    goto __pyx_L1_error;
    __pyx_L186_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_13);
    __Pyx_XGIVEREF(__pyx_t_12);
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_12, __pyx_t_11);
    __pyx_L190_try_end:;
  }

  /* "ws_package/controllers/activity_controller.py":2097
 *             logger.error("Error flushing database write queue after first entry: %s", e, exc_info=True)
 * 
 *         while not stop_event.is_set():             # <<<<<<<<<<<<<<
 * 
 *             logger.info("****************************************************************has_on_demand_screenshot: %s*********************************************************", self.has_on_demand)
*/
  while (1) {
    __pyx_t_3 = __pyx_cur_scope->__pyx_v_stop_event;
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_7 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
      __pyx_t_34 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_set, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2097, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_34);
    }
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_34); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2097, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
    __pyx_t_9 = (!__pyx_t_8);
    if (!__pyx_t_9) break;

    /* "ws_package/controllers/activity_controller.py":2099
 *         while not stop_event.is_set():
 * 
 *             logger.info("****************************************************************has_on_demand_screenshot: %s*********************************************************", self.has_on_demand)             # <<<<<<<<<<<<<<
 *             # Wait if tracking is stopped (via WebSocket command or persistent status)
 *             # CRITICAL: Continue monitoring when on break (break_id != 0) even if status=False
*/
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2099, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2099, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_33);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_has_on_demand); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2099, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_33))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_33);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_has_on_demand_screenshot_s, __pyx_t_1};
      __pyx_t_34 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
      if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2099, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_34);
    }
    __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;

    /* "ws_package/controllers/activity_controller.py":2103
 *             # CRITICAL: Continue monitoring when on break (break_id != 0) even if status=False
 *             # This ensures intervals are created in real-time during break sessions
 *             current_break_id = getattr(self, 'break_id', 0) or 0             # <<<<<<<<<<<<<<
 *             while not self.status and current_break_id != 0 and not stop_event.is_set():
 *                 logger.info("=" * 80)
*/
    __pyx_t_33 = __pyx_cur_scope->__pyx_v_self;
    __Pyx_INCREF(__pyx_t_33);
    __pyx_t_1 = __Pyx_GetAttr3(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_break_id, __pyx_mstate_global->__pyx_int_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2103, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2103, __pyx_L1_error)
    if (!__pyx_t_9) {
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    } else {
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_34 = __pyx_t_1;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L205_bool_binop_done;
    }
    __pyx_t_1 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2103, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_34 = __pyx_t_1;
    __pyx_t_1 = 0;
    __pyx_L205_bool_binop_done:;
    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_current_break_id);
    __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_current_break_id, __pyx_t_34);
    __Pyx_GIVEREF(__pyx_t_34);
    __pyx_t_34 = 0;

    /* "ws_package/controllers/activity_controller.py":2104
 *             # This ensures intervals are created in real-time during break sessions
 *             current_break_id = getattr(self, 'break_id', 0) or 0
 *             while not self.status and current_break_id != 0 and not stop_event.is_set():             # <<<<<<<<<<<<<<
 *                 logger.info("=" * 80)
 *                 logger.info("[Tracker] Tracking is STOPPED - waiting for 'start' command via WebSocket...")
*/
    while (1) {
      __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2104, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_34);
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_34); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2104, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
      __pyx_t_10 = (!__pyx_t_8);
      if (__pyx_t_10) {
      } else {
        __pyx_t_9 = __pyx_t_10;
        goto __pyx_L209_bool_binop_done;
      }
      __pyx_t_10 = (__Pyx_PyLong_BoolNeObjC(__pyx_cur_scope->__pyx_v_current_break_id, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 2104, __pyx_L1_error)
      if (__pyx_t_10) {
      } else {
        __pyx_t_9 = __pyx_t_10;
        goto __pyx_L209_bool_binop_done;
      }
      __pyx_t_1 = __pyx_cur_scope->__pyx_v_stop_event;
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_7 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
        __pyx_t_34 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_set, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2104, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_34);
      }
      __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_34); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 2104, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
      __pyx_t_8 = (!__pyx_t_10);
      __pyx_t_9 = __pyx_t_8;
      __pyx_L209_bool_binop_done:;
      if (!__pyx_t_9) break;

      /* "ws_package/controllers/activity_controller.py":2105
 *             current_break_id = getattr(self, 'break_id', 0) or 0
 *             while not self.status and current_break_id != 0 and not stop_event.is_set():
 *                 logger.info("=" * 80)             # <<<<<<<<<<<<<<
 *                 logger.info("[Tracker] Tracking is STOPPED - waiting for 'start' command via WebSocket...")
 *                 logger.info("[Tracker] Activity monitoring paused - WebSocket connection remains active")
*/
      __pyx_t_1 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2105, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_33);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2105, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
      __pyx_t_7 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
        assert(__pyx_t_1);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
        __pyx_t_7 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u__4};
        __pyx_t_34 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2105, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_34);
      }
      __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;

      /* "ws_package/controllers/activity_controller.py":2106
 *             while not self.status and current_break_id != 0 and not stop_event.is_set():
 *                 logger.info("=" * 80)
 *                 logger.info("[Tracker] Tracking is STOPPED - waiting for 'start' command via WebSocket...")             # <<<<<<<<<<<<<<
 *                 logger.info("[Tracker] Activity monitoring paused - WebSocket connection remains active")
 *                 logger.info("=" * 80)
*/
      __pyx_t_3 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2106, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2106, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_33);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_7 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_33))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_33);
        assert(__pyx_t_3);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
        __pyx_t_7 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Tracker_Tracking_is_STOPPED_wai};
        __pyx_t_34 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
        if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2106, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_34);
      }
      __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;

      /* "ws_package/controllers/activity_controller.py":2107
 *                 logger.info("=" * 80)
 *                 logger.info("[Tracker] Tracking is STOPPED - waiting for 'start' command via WebSocket...")
 *                 logger.info("[Tracker] Activity monitoring paused - WebSocket connection remains active")             # <<<<<<<<<<<<<<
 *                 logger.info("=" * 80)
 *                 await asyncio.sleep(5)
*/
      __pyx_t_33 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2107, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2107, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_7 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_1);
        assert(__pyx_t_33);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_33);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
        __pyx_t_7 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_33, __pyx_mstate_global->__pyx_kp_u_Tracker_Activity_monitoring_pau};
        __pyx_t_34 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2107, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_34);
      }
      __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;

      /* "ws_package/controllers/activity_controller.py":2108
 *                 logger.info("[Tracker] Tracking is STOPPED - waiting for 'start' command via WebSocket...")
 *                 logger.info("[Tracker] Activity monitoring paused - WebSocket connection remains active")
 *                 logger.info("=" * 80)             # <<<<<<<<<<<<<<
 *                 await asyncio.sleep(5)
 *                 # Re-check break_id in case break started while waiting
*/
      __pyx_t_1 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2108, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_33);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2108, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
      __pyx_t_7 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
        assert(__pyx_t_1);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
        __pyx_t_7 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u__4};
        __pyx_t_34 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2108, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_34);
      }
      __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;

      /* "ws_package/controllers/activity_controller.py":2109
 *                 logger.info("[Tracker] Activity monitoring paused - WebSocket connection remains active")
 *                 logger.info("=" * 80)
 *                 await asyncio.sleep(5)             # <<<<<<<<<<<<<<
 *                 # Re-check break_id in case break started while waiting
 *                 current_break_id = getattr(self, 'break_id', 0) or 0
*/
      __pyx_t_3 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2109, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2109, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_33);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_7 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_33))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_33);
        assert(__pyx_t_3);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
        __pyx_t_7 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_int_5};
        __pyx_t_34 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
        if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2109, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_34);
      }
      __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_34, &__pyx_r);
      __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
      if (likely(__pyx_t_26 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 14;
        return __pyx_r;
        __pyx_L212_resume_from_await:;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2109, __pyx_L1_error)
      } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_DECREF(__pyx_r); __pyx_r = 0;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 2109, __pyx_L1_error)
      }

      /* "ws_package/controllers/activity_controller.py":2111
 *                 await asyncio.sleep(5)
 *                 # Re-check break_id in case break started while waiting
 *                 current_break_id = getattr(self, 'break_id', 0) or 0             # <<<<<<<<<<<<<<
 * 
 *             # If stop_event was set while waiting, exit
*/
      __pyx_t_33 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_33);
      __pyx_t_3 = __Pyx_GetAttr3(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_break_id, __pyx_mstate_global->__pyx_int_0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2111, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2111, __pyx_L1_error)
      if (!__pyx_t_9) {
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      } else {
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_34 = __pyx_t_3;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        goto __pyx_L213_bool_binop_done;
      }
      __pyx_t_3 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2111, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_34 = __pyx_t_3;
      __pyx_t_3 = 0;
      __pyx_L213_bool_binop_done:;
      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_current_break_id);
      __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_current_break_id, __pyx_t_34);
      __Pyx_GIVEREF(__pyx_t_34);
      __pyx_t_34 = 0;
    }

    /* "ws_package/controllers/activity_controller.py":2114
 * 
 *             # If stop_event was set while waiting, exit
 *             if stop_event.is_set():             # <<<<<<<<<<<<<<
 *                 break
 * 
*/
    __pyx_t_3 = __pyx_cur_scope->__pyx_v_stop_event;
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_7 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
      __pyx_t_34 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_set, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2114, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_34);
    }
    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_34); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2114, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
    if (__pyx_t_9) {

      /* "ws_package/controllers/activity_controller.py":2115
 *             # If stop_event was set while waiting, exit
 *             if stop_event.is_set():
 *                 break             # <<<<<<<<<<<<<<
 * 
 *             # Log when tracking resumes or continues during break
*/
      goto __pyx_L204_break;

      /* "ws_package/controllers/activity_controller.py":2114
 * 
 *             # If stop_event was set while waiting, exit
 *             if stop_event.is_set():             # <<<<<<<<<<<<<<
 *                 break
 * 
*/
    }

    /* "ws_package/controllers/activity_controller.py":2118
 * 
 *             # Log when tracking resumes or continues during break
 *             if self.status and not getattr(self, '_tracking_resumed_logged', False):             # <<<<<<<<<<<<<<
 *                 logger.info("=" * 80)
 *                 logger.info("[Tracker]  Tracking RESUMED - activity monitoring active")
*/
    __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2118, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_34);
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_34); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2118, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
    if (__pyx_t_8) {
    } else {
      __pyx_t_9 = __pyx_t_8;
      goto __pyx_L217_bool_binop_done;
    }
    __pyx_t_34 = __pyx_cur_scope->__pyx_v_self;
    __Pyx_INCREF(__pyx_t_34);
    __pyx_t_3 = __Pyx_GetAttr3(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_tracking_resumed_logged, Py_False); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2118, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2118, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_10 = (!__pyx_t_8);
    __pyx_t_9 = __pyx_t_10;
    __pyx_L217_bool_binop_done:;
    if (__pyx_t_9) {

      /* "ws_package/controllers/activity_controller.py":2119
 *             # Log when tracking resumes or continues during break
 *             if self.status and not getattr(self, '_tracking_resumed_logged', False):
 *                 logger.info("=" * 80)             # <<<<<<<<<<<<<<
 *                 logger.info("[Tracker]  Tracking RESUMED - activity monitoring active")
 *                 logger.info("=" * 80)
*/
      __pyx_t_34 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2119, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_33);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2119, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
      __pyx_t_7 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_34 = PyMethod_GET_SELF(__pyx_t_1);
        assert(__pyx_t_34);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_34);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
        __pyx_t_7 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_34, __pyx_mstate_global->__pyx_kp_u__4};
        __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2119, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "ws_package/controllers/activity_controller.py":2120
 *             if self.status and not getattr(self, '_tracking_resumed_logged', False):
 *                 logger.info("=" * 80)
 *                 logger.info("[Tracker]  Tracking RESUMED - activity monitoring active")             # <<<<<<<<<<<<<<
 *                 logger.info("=" * 80)
 *                 self._tracking_resumed_logged = True
*/
      __pyx_t_1 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2120, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_34);
      __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2120, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_33);
      __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
      __pyx_t_7 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_33))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_33);
        assert(__pyx_t_1);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
        __pyx_t_7 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Tracker_Tracking_RESUMED_activi};
        __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2120, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "ws_package/controllers/activity_controller.py":2121
 *                 logger.info("=" * 80)
 *                 logger.info("[Tracker]  Tracking RESUMED - activity monitoring active")
 *                 logger.info("=" * 80)             # <<<<<<<<<<<<<<
 *                 self._tracking_resumed_logged = True
 * 
*/
      __pyx_t_33 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2121, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2121, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_34);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_7 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_34))) {
        __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_34);
        assert(__pyx_t_33);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_34);
        __Pyx_INCREF(__pyx_t_33);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_34, __pyx__function);
        __pyx_t_7 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_33, __pyx_mstate_global->__pyx_kp_u__4};
        __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_34, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2121, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
      }
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "ws_package/controllers/activity_controller.py":2122
 *                 logger.info("[Tracker]  Tracking RESUMED - activity monitoring active")
 *                 logger.info("=" * 80)
 *                 self._tracking_resumed_logged = True             # <<<<<<<<<<<<<<
 * 
 *                 # CRITICAL: Always restart device listeners after break ends
*/
      if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_tracking_resumed_logged, Py_True) < (0)) __PYX_ERR(0, 2122, __pyx_L1_error)

      /* "ws_package/controllers/activity_controller.py":2127
 *                 # This ensures keyboard/mouse events are captured when tracking resumes
 *                 # Listeners may have been stopped during break_stop_event or other operations
 *                 if hasattr(self, 'device_listener') and self.device_listener:             # <<<<<<<<<<<<<<
 *                     try:
 *                         # Check current state for logging
*/
      __pyx_t_3 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_3);
      __pyx_t_10 = __Pyx_HasAttr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_device_listener); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 2127, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_10) {
      } else {
        __pyx_t_9 = __pyx_t_10;
        goto __pyx_L220_bool_binop_done;
      }
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_device_listener); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2127, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 2127, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_9 = __pyx_t_10;
      __pyx_L220_bool_binop_done:;
      if (__pyx_t_9) {

        /* "ws_package/controllers/activity_controller.py":2128
 *                 # Listeners may have been stopped during break_stop_event or other operations
 *                 if hasattr(self, 'device_listener') and self.device_listener:
 *                     try:             # <<<<<<<<<<<<<<
 *                         # Check current state for logging
 *                         stop_listeners = getattr(self.device_listener, 'stop_listeners', True)
*/
        {
          __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_13);
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":2130
 *                     try:
 *                         # Check current state for logging
 *                         stop_listeners = getattr(self.device_listener, 'stop_listeners', True)             # <<<<<<<<<<<<<<
 *                         mouse_active = getattr(self.device_listener, 'mouse_listener_active', False)
 *                         keyboard_active = getattr(self.device_listener, 'keyboard_listener_active', False)
*/
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_device_listener); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2130, __pyx_L222_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_34 = __Pyx_GetAttr3(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_stop_listeners, Py_True); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2130, __pyx_L222_error)
            __Pyx_GOTREF(__pyx_t_34);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_stop_listeners);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_stop_listeners, __pyx_t_34);
            __Pyx_GIVEREF(__pyx_t_34);
            __pyx_t_34 = 0;

            /* "ws_package/controllers/activity_controller.py":2131
 *                         # Check current state for logging
 *                         stop_listeners = getattr(self.device_listener, 'stop_listeners', True)
 *                         mouse_active = getattr(self.device_listener, 'mouse_listener_active', False)             # <<<<<<<<<<<<<<
 *                         keyboard_active = getattr(self.device_listener, 'keyboard_listener_active', False)
 *                         mouse_verified = getattr(self.device_listener, 'mouse_listener_verified', False)
*/
            __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_device_listener); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2131, __pyx_L222_error)
            __Pyx_GOTREF(__pyx_t_34);
            __pyx_t_3 = __Pyx_GetAttr3(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_mouse_listener_active, Py_False); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2131, __pyx_L222_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_mouse_active);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_mouse_active, __pyx_t_3);
            __Pyx_GIVEREF(__pyx_t_3);
            __pyx_t_3 = 0;

            /* "ws_package/controllers/activity_controller.py":2132
 *                         stop_listeners = getattr(self.device_listener, 'stop_listeners', True)
 *                         mouse_active = getattr(self.device_listener, 'mouse_listener_active', False)
 *                         keyboard_active = getattr(self.device_listener, 'keyboard_listener_active', False)             # <<<<<<<<<<<<<<
 *                         mouse_verified = getattr(self.device_listener, 'mouse_listener_verified', False)
 *                         keyboard_verified = getattr(self.device_listener, 'keyboard_listener_verified', False)
*/
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_device_listener); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2132, __pyx_L222_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_34 = __Pyx_GetAttr3(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_keyboard_listener_active, Py_False); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2132, __pyx_L222_error)
            __Pyx_GOTREF(__pyx_t_34);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_keyboard_active);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_keyboard_active, __pyx_t_34);
            __Pyx_GIVEREF(__pyx_t_34);
            __pyx_t_34 = 0;

            /* "ws_package/controllers/activity_controller.py":2133
 *                         mouse_active = getattr(self.device_listener, 'mouse_listener_active', False)
 *                         keyboard_active = getattr(self.device_listener, 'keyboard_listener_active', False)
 *                         mouse_verified = getattr(self.device_listener, 'mouse_listener_verified', False)             # <<<<<<<<<<<<<<
 *                         keyboard_verified = getattr(self.device_listener, 'keyboard_listener_verified', False)
 * 
*/
            __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_device_listener); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2133, __pyx_L222_error)
            __Pyx_GOTREF(__pyx_t_34);
            __pyx_t_3 = __Pyx_GetAttr3(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_mouse_listener_verified, Py_False); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2133, __pyx_L222_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_mouse_verified);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_mouse_verified, __pyx_t_3);
            __Pyx_GIVEREF(__pyx_t_3);
            __pyx_t_3 = 0;

            /* "ws_package/controllers/activity_controller.py":2134
 *                         keyboard_active = getattr(self.device_listener, 'keyboard_listener_active', False)
 *                         mouse_verified = getattr(self.device_listener, 'mouse_listener_verified', False)
 *                         keyboard_verified = getattr(self.device_listener, 'keyboard_listener_verified', False)             # <<<<<<<<<<<<<<
 * 
 *                         logger.info(
*/
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_device_listener); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2134, __pyx_L222_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_34 = __Pyx_GetAttr3(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_keyboard_listener_verified, Py_False); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2134, __pyx_L222_error)
            __Pyx_GOTREF(__pyx_t_34);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_keyboard_verified);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_keyboard_verified, __pyx_t_34);
            __Pyx_GIVEREF(__pyx_t_34);
            __pyx_t_34 = 0;

            /* "ws_package/controllers/activity_controller.py":2136
 *                         keyboard_verified = getattr(self.device_listener, 'keyboard_listener_verified', False)
 * 
 *                         logger.info(             # <<<<<<<<<<<<<<
 *                             "Device listener state after break - stop_listeners: %s, "
 *                             "Mouse active: %s, Keyboard active: %s, "
*/
            __pyx_t_3 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2136, __pyx_L222_error)
            __Pyx_GOTREF(__pyx_t_33);
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2136, __pyx_L222_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

            /* "ws_package/controllers/activity_controller.py":2141
 *                             "Mouse verified: %s, Keyboard verified: %s",
 *                             stop_listeners, mouse_active, keyboard_active,
 *                             mouse_verified, keyboard_verified)             # <<<<<<<<<<<<<<
 * 
 *                         # ALWAYS restart listeners after break to ensure they're working
*/
            __pyx_t_7 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_1))) {
              __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
              assert(__pyx_t_3);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
              __pyx_t_7 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[7] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Device_listener_state_after_brea, __pyx_cur_scope->__pyx_v_stop_listeners, __pyx_cur_scope->__pyx_v_mouse_active, __pyx_cur_scope->__pyx_v_keyboard_active, __pyx_cur_scope->__pyx_v_mouse_verified, __pyx_cur_scope->__pyx_v_keyboard_verified};
              __pyx_t_34 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_7, (7-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2136, __pyx_L222_error)
              __Pyx_GOTREF(__pyx_t_34);
            }
            __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;

            /* "ws_package/controllers/activity_controller.py":2145
 *                         # ALWAYS restart listeners after break to ensure they're working
 *                         # This is necessary because listeners may have been stopped during break_stop_event
 *                         logger.info("Restarting device listeners after break to ensure activity tracking works...")             # <<<<<<<<<<<<<<
 *                         self.device_listener.restart_listeners()
 *                         logger.info("Device listeners restarted successfully - keyboard and mouse events should now be logged")
*/
            __pyx_t_1 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2145, __pyx_L222_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2145, __pyx_L222_error)
            __Pyx_GOTREF(__pyx_t_33);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __pyx_t_7 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_33))) {
              __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_33);
              assert(__pyx_t_1);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
              __Pyx_INCREF(__pyx_t_1);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
              __pyx_t_7 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Restarting_device_listeners_afte};
              __pyx_t_34 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2145, __pyx_L222_error)
              __Pyx_GOTREF(__pyx_t_34);
            }
            __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;

            /* "ws_package/controllers/activity_controller.py":2146
 *                         # This is necessary because listeners may have been stopped during break_stop_event
 *                         logger.info("Restarting device listeners after break to ensure activity tracking works...")
 *                         self.device_listener.restart_listeners()             # <<<<<<<<<<<<<<
 *                         logger.info("Device listeners restarted successfully - keyboard and mouse events should now be logged")
 *                     except Exception as e:
*/
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_device_listener); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2146, __pyx_L222_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_33 = __pyx_t_1;
            __Pyx_INCREF(__pyx_t_33);
            __pyx_t_7 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_33, NULL};
              __pyx_t_34 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_restart_listeners, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2146, __pyx_L222_error)
              __Pyx_GOTREF(__pyx_t_34);
            }
            __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;

            /* "ws_package/controllers/activity_controller.py":2147
 *                         logger.info("Restarting device listeners after break to ensure activity tracking works...")
 *                         self.device_listener.restart_listeners()
 *                         logger.info("Device listeners restarted successfully - keyboard and mouse events should now be logged")             # <<<<<<<<<<<<<<
 *                     except Exception as e:
 *                         logger.error("Error restarting device listeners after break: %s", e, exc_info=True)
*/
            __pyx_t_1 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2147, __pyx_L222_error)
            __Pyx_GOTREF(__pyx_t_33);
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2147, __pyx_L222_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
            __pyx_t_7 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_3))) {
              __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
              assert(__pyx_t_1);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
              __Pyx_INCREF(__pyx_t_1);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
              __pyx_t_7 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Device_listeners_restarted_succe};
              __pyx_t_34 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2147, __pyx_L222_error)
              __Pyx_GOTREF(__pyx_t_34);
            }
            __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;

            /* "ws_package/controllers/activity_controller.py":2128
 *                 # Listeners may have been stopped during break_stop_event or other operations
 *                 if hasattr(self, 'device_listener') and self.device_listener:
 *                     try:             # <<<<<<<<<<<<<<
 *                         # Check current state for logging
 *                         stop_listeners = getattr(self.device_listener, 'stop_listeners', True)
*/
          }
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          goto __pyx_L229_try_end;
          __pyx_L222_error:;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
          __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
          __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
          __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
          __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
          __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

          /* "ws_package/controllers/activity_controller.py":2148
 *                         self.device_listener.restart_listeners()
 *                         logger.info("Device listeners restarted successfully - keyboard and mouse events should now be logged")
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error restarting device listeners after break: %s", e, exc_info=True)
 *                         # Try to restart anyway as fallback
*/
          __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
          if (__pyx_t_14) {
            __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_34, &__pyx_t_3, &__pyx_t_1) < 0) __PYX_ERR(0, 2148, __pyx_L224_except_error)
            __Pyx_XGOTREF(__pyx_t_34);
            __Pyx_XGOTREF(__pyx_t_3);
            __Pyx_XGOTREF(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_GIVEREF(__pyx_t_3);
            __pyx_cur_scope->__pyx_v_e = __pyx_t_3;
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":2149
 *                         logger.info("Device listeners restarted successfully - keyboard and mouse events should now be logged")
 *                     except Exception as e:
 *                         logger.error("Error restarting device listeners after break: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 *                         # Try to restart anyway as fallback
 *                         try:
*/
              __pyx_t_15 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2149, __pyx_L235_error)
              __Pyx_GOTREF(__pyx_t_5);
              __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2149, __pyx_L235_error)
              __Pyx_GOTREF(__pyx_t_6);
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_6))) {
                __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_6);
                assert(__pyx_t_15);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                __Pyx_INCREF(__pyx_t_15);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Error_restarting_device_listener_2, __pyx_cur_scope->__pyx_v_e};
                __pyx_t_5 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2149, __pyx_L235_error)
                __Pyx_GOTREF(__pyx_t_5);
                if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_5, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 2149, __pyx_L235_error)
                __pyx_t_33 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_5);
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2149, __pyx_L235_error)
                __Pyx_GOTREF(__pyx_t_33);
              }
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

              /* "ws_package/controllers/activity_controller.py":2151
 *                         logger.error("Error restarting device listeners after break: %s", e, exc_info=True)
 *                         # Try to restart anyway as fallback
 *                         try:             # <<<<<<<<<<<<<<
 *                             logger.info("Attempting fallback restart of device listeners...")
 *                             self.device_listener.restart_listeners()
*/
              {
                __Pyx_ExceptionSave(&__pyx_t_18, &__pyx_t_21, &__pyx_t_20);
                __Pyx_XGOTREF(__pyx_t_18);
                __Pyx_XGOTREF(__pyx_t_21);
                __Pyx_XGOTREF(__pyx_t_20);
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":2152
 *                         # Try to restart anyway as fallback
 *                         try:
 *                             logger.info("Attempting fallback restart of device listeners...")             # <<<<<<<<<<<<<<
 *                             self.device_listener.restart_listeners()
 *                             logger.info("Fallback restart succeeded")
*/
                  __pyx_t_6 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2152, __pyx_L237_error)
                  __Pyx_GOTREF(__pyx_t_5);
                  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2152, __pyx_L237_error)
                  __Pyx_GOTREF(__pyx_t_15);
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_15))) {
                    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_15);
                    assert(__pyx_t_6);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                    __Pyx_INCREF(__pyx_t_6);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Attempting_fallback_restart_of_d};
                    __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                    if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2152, __pyx_L237_error)
                    __Pyx_GOTREF(__pyx_t_33);
                  }
                  __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

                  /* "ws_package/controllers/activity_controller.py":2153
 *                         try:
 *                             logger.info("Attempting fallback restart of device listeners...")
 *                             self.device_listener.restart_listeners()             # <<<<<<<<<<<<<<
 *                             logger.info("Fallback restart succeeded")
 *                         except Exception as fallback_error:
*/
                  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_device_listener); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2153, __pyx_L237_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  __pyx_t_15 = __pyx_t_6;
                  __Pyx_INCREF(__pyx_t_15);
                  __pyx_t_7 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL};
                    __pyx_t_33 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_restart_listeners, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2153, __pyx_L237_error)
                    __Pyx_GOTREF(__pyx_t_33);
                  }
                  __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

                  /* "ws_package/controllers/activity_controller.py":2154
 *                             logger.info("Attempting fallback restart of device listeners...")
 *                             self.device_listener.restart_listeners()
 *                             logger.info("Fallback restart succeeded")             # <<<<<<<<<<<<<<
 *                         except Exception as fallback_error:
 *                             from ws_package.utils.error_codes import ErrorCode
*/
                  __pyx_t_6 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2154, __pyx_L237_error)
                  __Pyx_GOTREF(__pyx_t_15);
                  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2154, __pyx_L237_error)
                  __Pyx_GOTREF(__pyx_t_5);
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_5))) {
                    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
                    assert(__pyx_t_6);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                    __Pyx_INCREF(__pyx_t_6);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Fallback_restart_succeeded};
                    __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                    if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2154, __pyx_L237_error)
                    __Pyx_GOTREF(__pyx_t_33);
                  }
                  __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

                  /* "ws_package/controllers/activity_controller.py":2151
 *                         logger.error("Error restarting device listeners after break: %s", e, exc_info=True)
 *                         # Try to restart anyway as fallback
 *                         try:             # <<<<<<<<<<<<<<
 *                             logger.info("Attempting fallback restart of device listeners...")
 *                             self.device_listener.restart_listeners()
*/
                }
                __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                goto __pyx_L244_try_end;
                __pyx_L237_error:;
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

                /* "ws_package/controllers/activity_controller.py":2155
 *                             self.device_listener.restart_listeners()
 *                             logger.info("Fallback restart succeeded")
 *                         except Exception as fallback_error:             # <<<<<<<<<<<<<<
 *                             from ws_package.utils.error_codes import ErrorCode
 *                             logger.error("%s: %s", ErrorCode.DEVICE_LISTENER_DEAD, fallback_error, exc_info=True)
*/
                __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                if (__pyx_t_14) {
                  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
                  if (__Pyx_GetException(&__pyx_t_33, &__pyx_t_5, &__pyx_t_6) < 0) __PYX_ERR(0, 2155, __pyx_L239_except_error)
                  __Pyx_XGOTREF(__pyx_t_33);
                  __Pyx_XGOTREF(__pyx_t_5);
                  __Pyx_XGOTREF(__pyx_t_6);
                  __Pyx_INCREF(__pyx_t_5);
                  __Pyx_GIVEREF(__pyx_t_5);
                  __pyx_cur_scope->__pyx_v_fallback_error = __pyx_t_5;
                  /*try:*/ {

                    /* "ws_package/controllers/activity_controller.py":2156
 *                             logger.info("Fallback restart succeeded")
 *                         except Exception as fallback_error:
 *                             from ws_package.utils.error_codes import ErrorCode             # <<<<<<<<<<<<<<
 *                             logger.error("%s: %s", ErrorCode.DEVICE_LISTENER_DEAD, fallback_error, exc_info=True)
 *                             self._send_to_electron_if_connected("tracking_error", {
*/
                    {
                      PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ErrorCode};
                      __pyx_t_19 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_utils_error_codes, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 2156, __pyx_L250_error)
                    }
                    __pyx_t_15 = __pyx_t_19;
                    __Pyx_GOTREF(__pyx_t_15);
                    {
                      PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ErrorCode};
                      __pyx_t_29 = 0; {
                        __pyx_t_36 = __Pyx_ImportFrom(__pyx_t_15, __pyx_imported_names[__pyx_t_29]); if (unlikely(!__pyx_t_36)) __PYX_ERR(0, 2156, __pyx_L250_error)
                        __Pyx_GOTREF(__pyx_t_36);
                        switch (__pyx_t_29) {
                          case 0:
                          __Pyx_INCREF(__pyx_t_36);
                          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_ErrorCode);
                          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_ErrorCode, __pyx_t_36);
                          __Pyx_GIVEREF(__pyx_t_36);
                          break;
                          default:;
                        }
                        __Pyx_DECREF(__pyx_t_36); __pyx_t_36 = 0;
                      }
                    }
                    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

                    /* "ws_package/controllers/activity_controller.py":2157
 *                         except Exception as fallback_error:
 *                             from ws_package.utils.error_codes import ErrorCode
 *                             logger.error("%s: %s", ErrorCode.DEVICE_LISTENER_DEAD, fallback_error, exc_info=True)             # <<<<<<<<<<<<<<
 *                             self._send_to_electron_if_connected("tracking_error", {
 *                                 "code": str(ErrorCode.DEVICE_LISTENER_DEAD),
*/
                    __pyx_t_36 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2157, __pyx_L250_error)
                    __Pyx_GOTREF(__pyx_t_2);
                    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2157, __pyx_L250_error)
                    __Pyx_GOTREF(__pyx_t_4);
                    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_ErrorCode, __pyx_mstate_global->__pyx_n_u_DEVICE_LISTENER_DEAD); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2157, __pyx_L250_error)
                    __Pyx_GOTREF(__pyx_t_2);
                    __pyx_t_7 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_4))) {
                      __pyx_t_36 = PyMethod_GET_SELF(__pyx_t_4);
                      assert(__pyx_t_36);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                      __Pyx_INCREF(__pyx_t_36);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                      __pyx_t_7 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[4 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_36, __pyx_mstate_global->__pyx_kp_u_s_s, __pyx_t_2, __pyx_cur_scope->__pyx_v_fallback_error};
                      __pyx_t_37 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2157, __pyx_L250_error)
                      __Pyx_GOTREF(__pyx_t_37);
                      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_37, __pyx_callargs+4, 0) < (0)) __PYX_ERR(0, 2157, __pyx_L250_error)
                      __pyx_t_15 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_37);
                      __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                      __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2157, __pyx_L250_error)
                      __Pyx_GOTREF(__pyx_t_15);
                    }
                    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

                    /* "ws_package/controllers/activity_controller.py":2158
 *                             from ws_package.utils.error_codes import ErrorCode
 *                             logger.error("%s: %s", ErrorCode.DEVICE_LISTENER_DEAD, fallback_error, exc_info=True)
 *                             self._send_to_electron_if_connected("tracking_error", {             # <<<<<<<<<<<<<<
 *                                 "code": str(ErrorCode.DEVICE_LISTENER_DEAD),
 *                                 "message": (
*/
                    __pyx_t_4 = __pyx_cur_scope->__pyx_v_self;
                    __Pyx_INCREF(__pyx_t_4);

                    /* "ws_package/controllers/activity_controller.py":2159
 *                             logger.error("%s: %s", ErrorCode.DEVICE_LISTENER_DEAD, fallback_error, exc_info=True)
 *                             self._send_to_electron_if_connected("tracking_error", {
 *                                 "code": str(ErrorCode.DEVICE_LISTENER_DEAD),             # <<<<<<<<<<<<<<
 *                                 "message": (
 *                                     "Keyboard and mouse activity tracking has stopped and could not "
*/
                    __pyx_t_37 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2159, __pyx_L250_error)
                    __Pyx_GOTREF(__pyx_t_37);
                    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_ErrorCode, __pyx_mstate_global->__pyx_n_u_DEVICE_LISTENER_DEAD); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2159, __pyx_L250_error)
                    __Pyx_GOTREF(__pyx_t_2);
                    __pyx_t_36 = __Pyx_PyObject_Unicode(__pyx_t_2); if (unlikely(!__pyx_t_36)) __PYX_ERR(0, 2159, __pyx_L250_error)
                    __Pyx_GOTREF(__pyx_t_36);
                    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                    if (PyDict_SetItem(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_code, __pyx_t_36) < (0)) __PYX_ERR(0, 2159, __pyx_L250_error)
                    __Pyx_DECREF(__pyx_t_36); __pyx_t_36 = 0;
                    if (PyDict_SetItem(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_message, __pyx_mstate_global->__pyx_kp_u_Keyboard_and_mouse_activity_trac) < (0)) __PYX_ERR(0, 2159, __pyx_L250_error)

                    /* "ws_package/controllers/activity_controller.py":2166
 *                                     "Privacy & Security  Accessibility. Then restart Workstatus."
 *                                 ),
 *                                 "recoverable": False,             # <<<<<<<<<<<<<<
 *                                 "source": "activity",
 *                             })
*/
                    if (PyDict_SetItem(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_recoverable, Py_False) < (0)) __PYX_ERR(0, 2159, __pyx_L250_error)
                    if (PyDict_SetItem(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_source, __pyx_mstate_global->__pyx_n_u_activity) < (0)) __PYX_ERR(0, 2159, __pyx_L250_error)
                    __pyx_t_7 = 0;
                    {
                      PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_mstate_global->__pyx_n_u_tracking_error, __pyx_t_37};
                      __pyx_t_15 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_send_to_electron_if_connected, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                      if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2158, __pyx_L250_error)
                      __Pyx_GOTREF(__pyx_t_15);
                    }
                    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  }

                  /* "ws_package/controllers/activity_controller.py":2155
 *                             self.device_listener.restart_listeners()
 *                             logger.info("Fallback restart succeeded")
 *                         except Exception as fallback_error:             # <<<<<<<<<<<<<<
 *                             from ws_package.utils.error_codes import ErrorCode
 *                             logger.error("%s: %s", ErrorCode.DEVICE_LISTENER_DEAD, fallback_error, exc_info=True)
*/
                  /*finally:*/ {
                    /*normal exit:*/{
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_fallback_error);
                      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_fallback_error); __pyx_cur_scope->__pyx_v_fallback_error = 0;
                      goto __pyx_L251;
                    }
                    __pyx_L250_error:;
                    /*exception exit:*/{
                      __Pyx_PyThreadState_assign
                      __pyx_t_19 = 0; __pyx_t_22 = 0; __pyx_t_32 = 0; __pyx_t_31 = 0; __pyx_t_23 = 0; __pyx_t_39 = 0;
                      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                      __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                      __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                      __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                      __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                       __Pyx_ExceptionSwap(&__pyx_t_31, &__pyx_t_23, &__pyx_t_39);
                      if ( unlikely(__Pyx_GetException(&__pyx_t_19, &__pyx_t_22, &__pyx_t_32) < 0)) __Pyx_ErrFetch(&__pyx_t_19, &__pyx_t_22, &__pyx_t_32);
                      __Pyx_XGOTREF(__pyx_t_19);
                      __Pyx_XGOTREF(__pyx_t_22);
                      __Pyx_XGOTREF(__pyx_t_32);
                      __Pyx_XGOTREF(__pyx_t_31);
                      __Pyx_XGOTREF(__pyx_t_23);
                      __Pyx_XGOTREF(__pyx_t_39);
                      __pyx_t_14 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_42 = __pyx_filename;
                      {
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_fallback_error);
                        __Pyx_DECREF(__pyx_cur_scope->__pyx_v_fallback_error); __pyx_cur_scope->__pyx_v_fallback_error = 0;
                      }
                      __Pyx_XGIVEREF(__pyx_t_31);
                      __Pyx_XGIVEREF(__pyx_t_23);
                      __Pyx_XGIVEREF(__pyx_t_39);
                      __Pyx_ExceptionReset(__pyx_t_31, __pyx_t_23, __pyx_t_39);
                      __Pyx_XGIVEREF(__pyx_t_19);
                      __Pyx_XGIVEREF(__pyx_t_22);
                      __Pyx_XGIVEREF(__pyx_t_32);
                      __Pyx_ErrRestore(__pyx_t_19, __pyx_t_22, __pyx_t_32);
                      __pyx_t_19 = 0; __pyx_t_22 = 0; __pyx_t_32 = 0; __pyx_t_31 = 0; __pyx_t_23 = 0; __pyx_t_39 = 0;
                      __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_42;
                      goto __pyx_L239_except_error;
                    }
                    __pyx_L251:;
                  }
                  __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                  goto __pyx_L238_exception_handled;
                }
                goto __pyx_L239_except_error;

                /* "ws_package/controllers/activity_controller.py":2151
 *                         logger.error("Error restarting device listeners after break: %s", e, exc_info=True)
 *                         # Try to restart anyway as fallback
 *                         try:             # <<<<<<<<<<<<<<
 *                             logger.info("Attempting fallback restart of device listeners...")
 *                             self.device_listener.restart_listeners()
*/
                __pyx_L239_except_error:;
                __Pyx_XGIVEREF(__pyx_t_18);
                __Pyx_XGIVEREF(__pyx_t_21);
                __Pyx_XGIVEREF(__pyx_t_20);
                __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_21, __pyx_t_20);
                goto __pyx_L235_error;
                __pyx_L238_exception_handled:;
                __Pyx_XGIVEREF(__pyx_t_18);
                __Pyx_XGIVEREF(__pyx_t_21);
                __Pyx_XGIVEREF(__pyx_t_20);
                __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_21, __pyx_t_20);
                __pyx_L244_try_end:;
              }
            }

            /* "ws_package/controllers/activity_controller.py":2148
 *                         self.device_listener.restart_listeners()
 *                         logger.info("Device listeners restarted successfully - keyboard and mouse events should now be logged")
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error restarting device listeners after break: %s", e, exc_info=True)
 *                         # Try to restart anyway as fallback
*/
            /*finally:*/ {
              /*normal exit:*/{
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                goto __pyx_L236;
              }
              __pyx_L235_error:;
              /*exception exit:*/{
                __Pyx_PyThreadState_assign
                __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_18 = 0; __pyx_t_39 = 0; __pyx_t_23 = 0; __pyx_t_31 = 0;
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                 __Pyx_ExceptionSwap(&__pyx_t_39, &__pyx_t_23, &__pyx_t_31);
                if ( unlikely(__Pyx_GetException(&__pyx_t_20, &__pyx_t_21, &__pyx_t_18) < 0)) __Pyx_ErrFetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_18);
                __Pyx_XGOTREF(__pyx_t_20);
                __Pyx_XGOTREF(__pyx_t_21);
                __Pyx_XGOTREF(__pyx_t_18);
                __Pyx_XGOTREF(__pyx_t_39);
                __Pyx_XGOTREF(__pyx_t_23);
                __Pyx_XGOTREF(__pyx_t_31);
                __pyx_t_16 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_43 = __pyx_filename;
                {
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                }
                __Pyx_XGIVEREF(__pyx_t_39);
                __Pyx_XGIVEREF(__pyx_t_23);
                __Pyx_XGIVEREF(__pyx_t_31);
                __Pyx_ExceptionReset(__pyx_t_39, __pyx_t_23, __pyx_t_31);
                __Pyx_XGIVEREF(__pyx_t_20);
                __Pyx_XGIVEREF(__pyx_t_21);
                __Pyx_XGIVEREF(__pyx_t_18);
                __Pyx_ErrRestore(__pyx_t_20, __pyx_t_21, __pyx_t_18);
                __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_18 = 0; __pyx_t_39 = 0; __pyx_t_23 = 0; __pyx_t_31 = 0;
                __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_43;
                goto __pyx_L224_except_error;
              }
              __pyx_L236:;
            }
            __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            goto __pyx_L223_exception_handled;
          }
          goto __pyx_L224_except_error;

          /* "ws_package/controllers/activity_controller.py":2128
 *                 # Listeners may have been stopped during break_stop_event or other operations
 *                 if hasattr(self, 'device_listener') and self.device_listener:
 *                     try:             # <<<<<<<<<<<<<<
 *                         # Check current state for logging
 *                         stop_listeners = getattr(self.device_listener, 'stop_listeners', True)
*/
          __pyx_L224_except_error:;
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
          goto __pyx_L1_error;
          __pyx_L223_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
          __pyx_L229_try_end:;
        }

        /* "ws_package/controllers/activity_controller.py":2127
 *                 # This ensures keyboard/mouse events are captured when tracking resumes
 *                 # Listeners may have been stopped during break_stop_event or other operations
 *                 if hasattr(self, 'device_listener') and self.device_listener:             # <<<<<<<<<<<<<<
 *                     try:
 *                         # Check current state for logging
*/
      }

      /* "ws_package/controllers/activity_controller.py":2118
 * 
 *             # Log when tracking resumes or continues during break
 *             if self.status and not getattr(self, '_tracking_resumed_logged', False):             # <<<<<<<<<<<<<<
 *                 logger.info("=" * 80)
 *                 logger.info("[Tracker]  Tracking RESUMED - activity monitoring active")
*/
      goto __pyx_L216;
    }

    /* "ws_package/controllers/activity_controller.py":2169
 *                                 "source": "activity",
 *                             })
 *             elif not self.status and current_break_id != 0:             # <<<<<<<<<<<<<<
 *                 # On break - monitoring continues even though status is False
 *                 if not getattr(self, '_break_monitoring_logged', False):
*/
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2169, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 2169, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_8 = (!__pyx_t_10);
    if (__pyx_t_8) {
    } else {
      __pyx_t_9 = __pyx_t_8;
      goto __pyx_L260_bool_binop_done;
    }
    __pyx_t_8 = (__Pyx_PyLong_BoolNeObjC(__pyx_cur_scope->__pyx_v_current_break_id, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2169, __pyx_L1_error)
    __pyx_t_9 = __pyx_t_8;
    __pyx_L260_bool_binop_done:;
    if (__pyx_t_9) {

      /* "ws_package/controllers/activity_controller.py":2171
 *             elif not self.status and current_break_id != 0:
 *                 # On break - monitoring continues even though status is False
 *                 if not getattr(self, '_break_monitoring_logged', False):             # <<<<<<<<<<<<<<
 *                     logger.info("=" * 80)
 *                     logger.info("[Break]  Monitoring CONTINUES during break (break_id=%s)", current_break_id)
*/
      __pyx_t_1 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_1);
      __pyx_t_3 = __Pyx_GetAttr3(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_break_monitoring_logged, Py_False); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2171, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2171, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_8 = (!__pyx_t_9);
      if (__pyx_t_8) {

        /* "ws_package/controllers/activity_controller.py":2172
 *                 # On break - monitoring continues even though status is False
 *                 if not getattr(self, '_break_monitoring_logged', False):
 *                     logger.info("=" * 80)             # <<<<<<<<<<<<<<
 *                     logger.info("[Break]  Monitoring CONTINUES during break (break_id=%s)", current_break_id)
 *                     logger.info("[Break] Intervals will be created in real-time with is_break=%s", current_break_id)
*/
        __pyx_t_1 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2172, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_34);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2172, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
          assert(__pyx_t_1);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u__4};
          __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2172, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "ws_package/controllers/activity_controller.py":2173
 *                 if not getattr(self, '_break_monitoring_logged', False):
 *                     logger.info("=" * 80)
 *                     logger.info("[Break]  Monitoring CONTINUES during break (break_id=%s)", current_break_id)             # <<<<<<<<<<<<<<
 *                     logger.info("[Break] Intervals will be created in real-time with is_break=%s", current_break_id)
 *                     logger.info("=" * 80)
*/
        __pyx_t_6 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2173, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2173, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_34);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_34))) {
          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_34);
          assert(__pyx_t_6);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_34);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_34, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Break_Monitoring_CONTINUES_duri, __pyx_cur_scope->__pyx_v_current_break_id};
          __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_34, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2173, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "ws_package/controllers/activity_controller.py":2174
 *                     logger.info("=" * 80)
 *                     logger.info("[Break]  Monitoring CONTINUES during break (break_id=%s)", current_break_id)
 *                     logger.info("[Break] Intervals will be created in real-time with is_break=%s", current_break_id)             # <<<<<<<<<<<<<<
 *                     logger.info("=" * 80)
 *                     self._break_monitoring_logged = True
*/
        __pyx_t_34 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2174, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2174, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_34 = PyMethod_GET_SELF(__pyx_t_1);
          assert(__pyx_t_34);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_34);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_34, __pyx_mstate_global->__pyx_kp_u_Break_Intervals_will_be_created, __pyx_cur_scope->__pyx_v_current_break_id};
          __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2174, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "ws_package/controllers/activity_controller.py":2175
 *                     logger.info("[Break]  Monitoring CONTINUES during break (break_id=%s)", current_break_id)
 *                     logger.info("[Break] Intervals will be created in real-time with is_break=%s", current_break_id)
 *                     logger.info("=" * 80)             # <<<<<<<<<<<<<<
 *                     self._break_monitoring_logged = True
 *             else:
*/
        __pyx_t_1 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2175, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_34);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2175, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
          assert(__pyx_t_1);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u__4};
          __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2175, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "ws_package/controllers/activity_controller.py":2176
 *                     logger.info("[Break] Intervals will be created in real-time with is_break=%s", current_break_id)
 *                     logger.info("=" * 80)
 *                     self._break_monitoring_logged = True             # <<<<<<<<<<<<<<
 *             else:
 *                 # Reset the break monitoring logged flag when not on break
*/
        if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_break_monitoring_logged, Py_True) < (0)) __PYX_ERR(0, 2176, __pyx_L1_error)

        /* "ws_package/controllers/activity_controller.py":2171
 *             elif not self.status and current_break_id != 0:
 *                 # On break - monitoring continues even though status is False
 *                 if not getattr(self, '_break_monitoring_logged', False):             # <<<<<<<<<<<<<<
 *                     logger.info("=" * 80)
 *                     logger.info("[Break]  Monitoring CONTINUES during break (break_id=%s)", current_break_id)
*/
      }

      /* "ws_package/controllers/activity_controller.py":2169
 *                                 "source": "activity",
 *                             })
 *             elif not self.status and current_break_id != 0:             # <<<<<<<<<<<<<<
 *                 # On break - monitoring continues even though status is False
 *                 if not getattr(self, '_break_monitoring_logged', False):
*/
      goto __pyx_L216;
    }

    /* "ws_package/controllers/activity_controller.py":2179
 *             else:
 *                 # Reset the break monitoring logged flag when not on break
 *                 self._break_monitoring_logged = False             # <<<<<<<<<<<<<<
 * 
 *             try:
*/
    /*else*/ {
      if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_break_monitoring_logged, Py_False) < (0)) __PYX_ERR(0, 2179, __pyx_L1_error)
    }
    __pyx_L216:;

    /* "ws_package/controllers/activity_controller.py":2181
 *                 self._break_monitoring_logged = False
 * 
 *             try:             # <<<<<<<<<<<<<<
 *                 logger.debug("[Timing][Python] Inside main activity loop")
 *                 logger.info("Current Interval Status: %s Screenshot Interval frequency: %s App and URL Status: %s Blur Intensity: %s", self.interval, self.screenshot_interval, self.appandurlstatus, self.blur_intensity)
*/
    {
      __Pyx_ExceptionSave(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_11);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":2182
 * 
 *             try:
 *                 logger.debug("[Timing][Python] Inside main activity loop")             # <<<<<<<<<<<<<<
 *                 logger.info("Current Interval Status: %s Screenshot Interval frequency: %s App and URL Status: %s Blur Intensity: %s", self.interval, self.screenshot_interval, self.appandurlstatus, self.blur_intensity)
 * 
*/
        __pyx_t_6 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2182, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2182, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_34);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_34))) {
          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_34);
          assert(__pyx_t_6);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_34);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_34, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Timing_Python_Inside_main_activ};
          __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_34, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2182, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_3);
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "ws_package/controllers/activity_controller.py":2183
 *             try:
 *                 logger.debug("[Timing][Python] Inside main activity loop")
 *                 logger.info("Current Interval Status: %s Screenshot Interval frequency: %s App and URL Status: %s Blur Intensity: %s", self.interval, self.screenshot_interval, self.appandurlstatus, self.blur_intensity)             # <<<<<<<<<<<<<<
 * 
 * 
*/
        __pyx_t_34 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2183, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2183, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2183, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_interval); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2183, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2183, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_33);
        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_blur_intensity); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2183, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_34 = PyMethod_GET_SELF(__pyx_t_1);
          assert(__pyx_t_34);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_34);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[6] = {__pyx_t_34, __pyx_mstate_global->__pyx_kp_u_Current_Interval_Status_s_Screen, __pyx_t_6, __pyx_t_5, __pyx_t_33, __pyx_t_15};
          __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_7, (6-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2183, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_3);
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "ws_package/controllers/activity_controller.py":2186
 * 
 * 
 *                 if getattr(sys, 'frozen', False):  # Running as a PyInstaller EXE             # <<<<<<<<<<<<<<
 *                     script_path = Path(sys.executable).resolve()
 *                     target_directory = script_path.parents[0]
*/
        __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_sys); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2186, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_1 = __Pyx_GetAttr3(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_frozen, Py_False); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2186, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2186, __pyx_L263_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (__pyx_t_8) {

          /* "ws_package/controllers/activity_controller.py":2187
 * 
 *                 if getattr(sys, 'frozen', False):  # Running as a PyInstaller EXE
 *                     script_path = Path(sys.executable).resolve()             # <<<<<<<<<<<<<<
 *                     target_directory = script_path.parents[0]
 *                     target_directory_stealth = script_path.parents[1]
*/
          __pyx_t_33 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_Path); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2187, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_sys); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2187, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_executable); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2187, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_34);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_7 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_5))) {
            __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_5);
            assert(__pyx_t_33);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_33);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
            __pyx_t_7 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_33, __pyx_t_34};
            __pyx_t_15 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
            __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2187, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_15);
          }
          __pyx_t_3 = __pyx_t_15;
          __Pyx_INCREF(__pyx_t_3);
          __pyx_t_7 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
            __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_resolve, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2187, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_1);
          }
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_script_path);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_script_path, __pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_1);
          __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":2188
 *                 if getattr(sys, 'frozen', False):  # Running as a PyInstaller EXE
 *                     script_path = Path(sys.executable).resolve()
 *                     target_directory = script_path.parents[0]             # <<<<<<<<<<<<<<
 *                     target_directory_stealth = script_path.parents[1]
 *                 else:  # Running as a normal Python script
*/
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_script_path, __pyx_mstate_global->__pyx_n_u_parents); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2188, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_15 = __Pyx_GetItemInt(__pyx_t_1, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2188, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_target_directory);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_target_directory, __pyx_t_15);
          __Pyx_GIVEREF(__pyx_t_15);
          __pyx_t_15 = 0;

          /* "ws_package/controllers/activity_controller.py":2189
 *                     script_path = Path(sys.executable).resolve()
 *                     target_directory = script_path.parents[0]
 *                     target_directory_stealth = script_path.parents[1]             # <<<<<<<<<<<<<<
 *                 else:  # Running as a normal Python script
 *                     script_path = Path(__file__).resolve()
*/
          __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_script_path, __pyx_mstate_global->__pyx_n_u_parents); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2189, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_15);
          __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_15, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2189, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_target_directory_stealth);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_target_directory_stealth, __pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_1);
          __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":2186
 * 
 * 
 *                 if getattr(sys, 'frozen', False):  # Running as a PyInstaller EXE             # <<<<<<<<<<<<<<
 *                     script_path = Path(sys.executable).resolve()
 *                     target_directory = script_path.parents[0]
*/
          goto __pyx_L271;
        }

        /* "ws_package/controllers/activity_controller.py":2191
 *                     target_directory_stealth = script_path.parents[1]
 *                 else:  # Running as a normal Python script
 *                     script_path = Path(__file__).resolve()             # <<<<<<<<<<<<<<
 *                     target_directory = f"{script_path.parents[3]}/workstatus"
 * 
*/
        /*else*/ {
          __pyx_t_5 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_Path); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2191, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_34);
          __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_file); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2191, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_33);
          __pyx_t_7 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_34))) {
            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_34);
            assert(__pyx_t_5);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_34);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_34, __pyx__function);
            __pyx_t_7 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_33};
            __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_34, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
            __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2191, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_3);
          }
          __pyx_t_15 = __pyx_t_3;
          __Pyx_INCREF(__pyx_t_15);
          __pyx_t_7 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL};
            __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_resolve, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2191, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_1);
          }
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_script_path);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_script_path, __pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_1);
          __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":2192
 *                 else:  # Running as a normal Python script
 *                     script_path = Path(__file__).resolve()
 *                     target_directory = f"{script_path.parents[3]}/workstatus"             # <<<<<<<<<<<<<<
 * 
 *                 logger.info("Running device activity force status %s", self.force_stop)
*/
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_script_path, __pyx_mstate_global->__pyx_n_u_parents); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2192, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, 3, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2192, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2192, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = __Pyx_PyUnicode_Concat__Pyx_ReferenceSharing_OwnStrongReferenceInPlace(__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_workstatus); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2192, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_target_directory);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_target_directory, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_3);
          __pyx_t_3 = 0;
        }
        __pyx_L271:;

        /* "ws_package/controllers/activity_controller.py":2194
 *                     target_directory = f"{script_path.parents[3]}/workstatus"
 * 
 *                 logger.info("Running device activity force status %s", self.force_stop)             # <<<<<<<<<<<<<<
 *                 if self.status and self.current_session_start_time is not None:
 *                     await self._try_finalize_post_switch_slot_interval(user_entity)
*/
        __pyx_t_1 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2194, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2194, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_34);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_force_stop); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2194, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_34))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_34);
          assert(__pyx_t_1);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_34);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_34, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Running_device_activity_force_st, __pyx_t_15};
          __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_34, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2194, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_3);
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "ws_package/controllers/activity_controller.py":2195
 * 
 *                 logger.info("Running device activity force status %s", self.force_stop)
 *                 if self.status and self.current_session_start_time is not None:             # <<<<<<<<<<<<<<
 *                     await self._try_finalize_post_switch_slot_interval(user_entity)
 * 
*/
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2195, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2195, __pyx_L263_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (__pyx_t_9) {
        } else {
          __pyx_t_8 = __pyx_t_9;
          goto __pyx_L273_bool_binop_done;
        }
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_session_start_time); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2195, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_9 = (__pyx_t_3 != Py_None);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_8 = __pyx_t_9;
        __pyx_L273_bool_binop_done:;
        if (__pyx_t_8) {

          /* "ws_package/controllers/activity_controller.py":2196
 *                 logger.info("Running device activity force status %s", self.force_stop)
 *                 if self.status and self.current_session_start_time is not None:
 *                     await self._try_finalize_post_switch_slot_interval(user_entity)             # <<<<<<<<<<<<<<
 * 
 *                 if self.Flag==True: # This is not the first time slot, so we need to get the current slot
*/
          __pyx_t_34 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_34);
          __pyx_t_7 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_34, __pyx_cur_scope->__pyx_v_user_entity};
            __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_try_finalize_post_switch_slot_i, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2196, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_3);
          }
          __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_3, &__pyx_r);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (likely(__pyx_t_26 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_11);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
            __Pyx_XGIVEREF(__pyx_t_12);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
            __Pyx_XGIVEREF(__pyx_t_13);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 15;
            return __pyx_r;
            __pyx_L275_resume_from_await:;
            __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_11);
            __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_12);
            __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_13);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2196, __pyx_L263_error)
          } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_DECREF(__pyx_r); __pyx_r = 0;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 2196, __pyx_L263_error)
          }

          /* "ws_package/controllers/activity_controller.py":2195
 * 
 *                 logger.info("Running device activity force status %s", self.force_stop)
 *                 if self.status and self.current_session_start_time is not None:             # <<<<<<<<<<<<<<
 *                     await self._try_finalize_post_switch_slot_interval(user_entity)
 * 
*/
        }

        /* "ws_package/controllers/activity_controller.py":2198
 *                     await self._try_finalize_post_switch_slot_interval(user_entity)
 * 
 *                 if self.Flag==True: # This is not the first time slot, so we need to get the current slot             # <<<<<<<<<<<<<<
 * 
 *                     start_date= await self.getCurrentSlot()
*/
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_Flag); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2198, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_34 = PyObject_RichCompare(__pyx_t_3, Py_True, Py_EQ); __Pyx_XGOTREF(__pyx_t_34); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2198, __pyx_L263_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_34); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2198, __pyx_L263_error)
        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
        if (__pyx_t_8) {

          /* "ws_package/controllers/activity_controller.py":2200
 *                 if self.Flag==True: # This is not the first time slot, so we need to get the current slot
 * 
 *                     start_date= await self.getCurrentSlot()             # <<<<<<<<<<<<<<
 *                     end_date = start_date + datetime.timedelta(minutes=int(self.interval/60))
 *                     # If the last saved interval or break stop time falls inside this slot (e.g. break stopped at 17:17, slot is 17:15-17:20),
*/
          __pyx_t_3 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_3);
          __pyx_t_7 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
            __pyx_t_34 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_getCurrentSlot, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2200, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_34);
          }
          __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_34, &__pyx_r);
          __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
          if (likely(__pyx_t_26 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_11);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
            __Pyx_XGIVEREF(__pyx_t_12);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
            __Pyx_XGIVEREF(__pyx_t_13);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 16;
            return __pyx_r;
            __pyx_L277_resume_from_await:;
            __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_11);
            __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_12);
            __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_13);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2200, __pyx_L263_error)
            __pyx_t_34 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_34);
          } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __pyx_t_34 = __pyx_r; __pyx_r = NULL;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 2200, __pyx_L263_error)
          }
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_start_date);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_start_date, __pyx_t_34);
          __Pyx_GIVEREF(__pyx_t_34);
          __pyx_t_34 = 0;

          /* "ws_package/controllers/activity_controller.py":2201
 * 
 *                     start_date= await self.getCurrentSlot()
 *                     end_date = start_date + datetime.timedelta(minutes=int(self.interval/60))             # <<<<<<<<<<<<<<
 *                     # If the last saved interval or break stop time falls inside this slot (e.g. break stopped at 17:17, slot is 17:15-17:20),
 *                     # start this interval at that time so we don't double-count 17:15-17:17 as work time.
*/
          __pyx_t_3 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2201, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_15);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_timedelta); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2201, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2201, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_15);
          __pyx_t_33 = __Pyx_PyLong_TrueDivideObjC(__pyx_t_15, __pyx_mstate_global->__pyx_int_60, 60, 0, 0); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2201, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_33);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __pyx_t_15 = __Pyx_PyNumber_Int(__pyx_t_33); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2201, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
          __pyx_t_7 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_1))) {
            __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
            assert(__pyx_t_3);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
            __pyx_t_7 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_3, NULL};
            __pyx_t_33 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2201, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_33);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_minutes, __pyx_t_15, __pyx_t_33, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 2201, __pyx_L263_error)
            __pyx_t_34 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_33);
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2201, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_34);
          }
          __pyx_t_1 = PyNumber_Add(__pyx_cur_scope->__pyx_v_start_date, __pyx_t_34); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2201, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_end_date);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_end_date, __pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_1);
          __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":2204
 *                     # If the last saved interval or break stop time falls inside this slot (e.g. break stopped at 17:17, slot is 17:15-17:20),
 *                     # start this interval at that time so we don't double-count 17:15-17:17 as work time.
 *                     current_break_id_slot = getattr(self, 'break_id', 0) or 0             # <<<<<<<<<<<<<<
 *                     if current_break_id_slot == 0:
 *                         trim_to = start_date
*/
          __pyx_t_34 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_34);
          __pyx_t_33 = __Pyx_GetAttr3(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_break_id, __pyx_mstate_global->__pyx_int_0); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2204, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_33);
          __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
          __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_33); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2204, __pyx_L263_error)
          if (!__pyx_t_8) {
            __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
          } else {
            __Pyx_INCREF(__pyx_t_33);
            __pyx_t_1 = __pyx_t_33;
            __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
            goto __pyx_L278_bool_binop_done;
          }
          __pyx_t_33 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2204, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_33);
          __pyx_t_1 = __pyx_t_33;
          __pyx_t_33 = 0;
          __pyx_L278_bool_binop_done:;
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_current_break_id_slot);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_current_break_id_slot, __pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_1);
          __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":2205
 *                     # start this interval at that time so we don't double-count 17:15-17:17 as work time.
 *                     current_break_id_slot = getattr(self, 'break_id', 0) or 0
 *                     if current_break_id_slot == 0:             # <<<<<<<<<<<<<<
 *                         trim_to = start_date
 *                         last_end = await self.activity_service.get_last_activity_interval()
*/
          __pyx_t_8 = (__Pyx_PyLong_BoolEqObjC(__pyx_cur_scope->__pyx_v_current_break_id_slot, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2205, __pyx_L263_error)
          if (__pyx_t_8) {

            /* "ws_package/controllers/activity_controller.py":2206
 *                     current_break_id_slot = getattr(self, 'break_id', 0) or 0
 *                     if current_break_id_slot == 0:
 *                         trim_to = start_date             # <<<<<<<<<<<<<<
 *                         last_end = await self.activity_service.get_last_activity_interval()
 *                         if last_end is not None and start_date < last_end < end_date:
*/
            __Pyx_INCREF(__pyx_cur_scope->__pyx_v_start_date);
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_trim_to);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_trim_to, __pyx_cur_scope->__pyx_v_start_date);
            __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_start_date);

            /* "ws_package/controllers/activity_controller.py":2207
 *                     if current_break_id_slot == 0:
 *                         trim_to = start_date
 *                         last_end = await self.activity_service.get_last_activity_interval()             # <<<<<<<<<<<<<<
 *                         if last_end is not None and start_date < last_end < end_date:
 *                             trim_to = max(trim_to, last_end)
*/
            __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2207, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_34);
            __pyx_t_33 = __pyx_t_34;
            __Pyx_INCREF(__pyx_t_33);
            __pyx_t_7 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_33, NULL};
              __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_last_activity_interval, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
              __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
              if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2207, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_1);
            }
            __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (likely(__pyx_t_26 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_11);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
              __Pyx_XGIVEREF(__pyx_t_12);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
              __Pyx_XGIVEREF(__pyx_t_13);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 17;
              return __pyx_r;
              __pyx_L281_resume_from_await:;
              __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_11);
              __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_12);
              __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_13);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2207, __pyx_L263_error)
              __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
            } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __pyx_t_1 = __pyx_r; __pyx_r = NULL;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 2207, __pyx_L263_error)
            }
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_last_end);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_last_end, __pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_1);
            __pyx_t_1 = 0;

            /* "ws_package/controllers/activity_controller.py":2208
 *                         trim_to = start_date
 *                         last_end = await self.activity_service.get_last_activity_interval()
 *                         if last_end is not None and start_date < last_end < end_date:             # <<<<<<<<<<<<<<
 *                             trim_to = max(trim_to, last_end)
 *                         session_start = self.current_session_start_time
*/
            __pyx_t_9 = (__pyx_cur_scope->__pyx_v_last_end != Py_None);
            if (__pyx_t_9) {
            } else {
              __pyx_t_8 = __pyx_t_9;
              goto __pyx_L283_bool_binop_done;
            }
            __pyx_t_1 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_last_end, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2208, __pyx_L263_error)
            if (__Pyx_PyObject_IsTrue(__pyx_t_1)) {
              __Pyx_DECREF(__pyx_t_1);
              __pyx_t_1 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_last_end, __pyx_cur_scope->__pyx_v_end_date, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2208, __pyx_L263_error)
            }
            __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2208, __pyx_L263_error)
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_8 = __pyx_t_9;
            __pyx_L283_bool_binop_done:;
            if (__pyx_t_8) {

              /* "ws_package/controllers/activity_controller.py":2209
 *                         last_end = await self.activity_service.get_last_activity_interval()
 *                         if last_end is not None and start_date < last_end < end_date:
 *                             trim_to = max(trim_to, last_end)             # <<<<<<<<<<<<<<
 *                         session_start = self.current_session_start_time
 *                         if (
*/
              __Pyx_INCREF(__pyx_cur_scope->__pyx_v_last_end);
              __pyx_t_1 = __pyx_cur_scope->__pyx_v_last_end;
              __Pyx_INCREF(__pyx_cur_scope->__pyx_v_trim_to);
              __pyx_t_34 = __pyx_cur_scope->__pyx_v_trim_to;
              __pyx_t_15 = PyObject_RichCompare(__pyx_t_1, __pyx_t_34, Py_GT); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2209, __pyx_L263_error)
              __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2209, __pyx_L263_error)
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (__pyx_t_8) {
                __Pyx_INCREF(__pyx_t_1);
                __pyx_t_33 = __pyx_t_1;
              } else {
                __Pyx_INCREF(__pyx_t_34);
                __pyx_t_33 = __pyx_t_34;
              }
              __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __pyx_t_1 = __pyx_t_33;
              __Pyx_INCREF(__pyx_t_1);
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_trim_to);
              __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_trim_to, __pyx_t_1);
              __Pyx_GIVEREF(__pyx_t_1);
              __pyx_t_1 = 0;

              /* "ws_package/controllers/activity_controller.py":2208
 *                         trim_to = start_date
 *                         last_end = await self.activity_service.get_last_activity_interval()
 *                         if last_end is not None and start_date < last_end < end_date:             # <<<<<<<<<<<<<<
 *                             trim_to = max(trim_to, last_end)
 *                         session_start = self.current_session_start_time
*/
            }

            /* "ws_package/controllers/activity_controller.py":2210
 *                         if last_end is not None and start_date < last_end < end_date:
 *                             trim_to = max(trim_to, last_end)
 *                         session_start = self.current_session_start_time             # <<<<<<<<<<<<<<
 *                         if (
 *                             session_start is not None
*/
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_session_start_time); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2210, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_session_start);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_session_start, __pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_1);
            __pyx_t_1 = 0;

            /* "ws_package/controllers/activity_controller.py":2212
 *                         session_start = self.current_session_start_time
 *                         if (
 *                             session_start is not None             # <<<<<<<<<<<<<<
 *                             and start_date < session_start < end_date
 *                         ):
*/
            __pyx_t_9 = (__pyx_cur_scope->__pyx_v_session_start != Py_None);
            if (__pyx_t_9) {
            } else {
              __pyx_t_8 = __pyx_t_9;
              goto __pyx_L286_bool_binop_done;
            }

            /* "ws_package/controllers/activity_controller.py":2213
 *                         if (
 *                             session_start is not None
 *                             and start_date < session_start < end_date             # <<<<<<<<<<<<<<
 *                         ):
 *                             trim_to = max(
*/
            __pyx_t_1 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_session_start, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2213, __pyx_L263_error)
            if (__Pyx_PyObject_IsTrue(__pyx_t_1)) {
              __Pyx_DECREF(__pyx_t_1);
              __pyx_t_1 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_session_start, __pyx_cur_scope->__pyx_v_end_date, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2213, __pyx_L263_error)
            }
            __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2213, __pyx_L263_error)
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_8 = __pyx_t_9;
            __pyx_L286_bool_binop_done:;

            /* "ws_package/controllers/activity_controller.py":2211
 *                             trim_to = max(trim_to, last_end)
 *                         session_start = self.current_session_start_time
 *                         if (             # <<<<<<<<<<<<<<
 *                             session_start is not None
 *                             and start_date < session_start < end_date
*/
            if (__pyx_t_8) {

              /* "ws_package/controllers/activity_controller.py":2216
 *                         ):
 *                             trim_to = max(
 *                                 trim_to, session_start.replace(microsecond=0)             # <<<<<<<<<<<<<<
 *                             )
 *                         break_stop_time_attr = getattr(self, '_break_stop_time', None)
*/
              __pyx_t_33 = __pyx_cur_scope->__pyx_v_session_start;
              __Pyx_INCREF(__pyx_t_33);
              __pyx_t_7 = 0;
              {
                PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_33, NULL};
                __pyx_t_34 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2216, __pyx_L263_error)
                __Pyx_GOTREF(__pyx_t_34);
                if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_34, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 2216, __pyx_L263_error)
                __pyx_t_1 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_34);
                __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2216, __pyx_L263_error)
                __Pyx_GOTREF(__pyx_t_1);
              }
              __Pyx_INCREF(__pyx_cur_scope->__pyx_v_trim_to);
              __pyx_t_34 = __pyx_cur_scope->__pyx_v_trim_to;
              __pyx_t_15 = PyObject_RichCompare(__pyx_t_1, __pyx_t_34, Py_GT); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2216, __pyx_L263_error)
              __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2216, __pyx_L263_error)
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (__pyx_t_8) {
                __Pyx_INCREF(__pyx_t_1);
                __pyx_t_33 = __pyx_t_1;
              } else {
                __Pyx_INCREF(__pyx_t_34);
                __pyx_t_33 = __pyx_t_34;
              }
              __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __pyx_t_1 = __pyx_t_33;
              __Pyx_INCREF(__pyx_t_1);
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_trim_to);
              __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_trim_to, __pyx_t_1);
              __Pyx_GIVEREF(__pyx_t_1);
              __pyx_t_1 = 0;

              /* "ws_package/controllers/activity_controller.py":2211
 *                             trim_to = max(trim_to, last_end)
 *                         session_start = self.current_session_start_time
 *                         if (             # <<<<<<<<<<<<<<
 *                             session_start is not None
 *                             and start_date < session_start < end_date
*/
            }

            /* "ws_package/controllers/activity_controller.py":2218
 *                                 trim_to, session_start.replace(microsecond=0)
 *                             )
 *                         break_stop_time_attr = getattr(self, '_break_stop_time', None)             # <<<<<<<<<<<<<<
 *                         if break_stop_time_attr is not None and start_date < break_stop_time_attr < end_date:
 *                             trim_to = max(trim_to, break_stop_time_attr)
*/
            __pyx_t_1 = __pyx_cur_scope->__pyx_v_self;
            __Pyx_INCREF(__pyx_t_1);
            __pyx_t_33 = __Pyx_GetAttr3(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_break_stop_time, Py_None); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2218, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_33);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_break_stop_time_attr);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_break_stop_time_attr, __pyx_t_33);
            __Pyx_GIVEREF(__pyx_t_33);
            __pyx_t_33 = 0;

            /* "ws_package/controllers/activity_controller.py":2219
 *                             )
 *                         break_stop_time_attr = getattr(self, '_break_stop_time', None)
 *                         if break_stop_time_attr is not None and start_date < break_stop_time_attr < end_date:             # <<<<<<<<<<<<<<
 *                             trim_to = max(trim_to, break_stop_time_attr)
 *                             self._break_stop_time = None  # Use once so next slot is not trimmed
*/
            __pyx_t_9 = (__pyx_cur_scope->__pyx_v_break_stop_time_attr != Py_None);
            if (__pyx_t_9) {
            } else {
              __pyx_t_8 = __pyx_t_9;
              goto __pyx_L289_bool_binop_done;
            }
            __pyx_t_33 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_break_stop_time_attr, Py_LT); __Pyx_XGOTREF(__pyx_t_33); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2219, __pyx_L263_error)
            if (__Pyx_PyObject_IsTrue(__pyx_t_33)) {
              __Pyx_DECREF(__pyx_t_33);
              __pyx_t_33 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_break_stop_time_attr, __pyx_cur_scope->__pyx_v_end_date, Py_LT); __Pyx_XGOTREF(__pyx_t_33); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2219, __pyx_L263_error)
            }
            __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_33); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2219, __pyx_L263_error)
            __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
            __pyx_t_8 = __pyx_t_9;
            __pyx_L289_bool_binop_done:;
            if (__pyx_t_8) {

              /* "ws_package/controllers/activity_controller.py":2220
 *                         break_stop_time_attr = getattr(self, '_break_stop_time', None)
 *                         if break_stop_time_attr is not None and start_date < break_stop_time_attr < end_date:
 *                             trim_to = max(trim_to, break_stop_time_attr)             # <<<<<<<<<<<<<<
 *                             self._break_stop_time = None  # Use once so next slot is not trimmed
 *                         if trim_to > start_date:
*/
              __Pyx_INCREF(__pyx_cur_scope->__pyx_v_break_stop_time_attr);
              __pyx_t_33 = __pyx_cur_scope->__pyx_v_break_stop_time_attr;
              __Pyx_INCREF(__pyx_cur_scope->__pyx_v_trim_to);
              __pyx_t_1 = __pyx_cur_scope->__pyx_v_trim_to;
              __pyx_t_15 = PyObject_RichCompare(__pyx_t_33, __pyx_t_1, Py_GT); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2220, __pyx_L263_error)
              __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2220, __pyx_L263_error)
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (__pyx_t_8) {
                __Pyx_INCREF(__pyx_t_33);
                __pyx_t_34 = __pyx_t_33;
              } else {
                __Pyx_INCREF(__pyx_t_1);
                __pyx_t_34 = __pyx_t_1;
              }
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              __pyx_t_33 = __pyx_t_34;
              __Pyx_INCREF(__pyx_t_33);
              __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_trim_to);
              __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_trim_to, __pyx_t_33);
              __Pyx_GIVEREF(__pyx_t_33);
              __pyx_t_33 = 0;

              /* "ws_package/controllers/activity_controller.py":2221
 *                         if break_stop_time_attr is not None and start_date < break_stop_time_attr < end_date:
 *                             trim_to = max(trim_to, break_stop_time_attr)
 *                             self._break_stop_time = None  # Use once so next slot is not trimmed             # <<<<<<<<<<<<<<
 *                         if trim_to > start_date:
 *                             start_date = trim_to
*/
              if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_break_stop_time, Py_None) < (0)) __PYX_ERR(0, 2221, __pyx_L263_error)

              /* "ws_package/controllers/activity_controller.py":2219
 *                             )
 *                         break_stop_time_attr = getattr(self, '_break_stop_time', None)
 *                         if break_stop_time_attr is not None and start_date < break_stop_time_attr < end_date:             # <<<<<<<<<<<<<<
 *                             trim_to = max(trim_to, break_stop_time_attr)
 *                             self._break_stop_time = None  # Use once so next slot is not trimmed
*/
            }

            /* "ws_package/controllers/activity_controller.py":2222
 *                             trim_to = max(trim_to, break_stop_time_attr)
 *                             self._break_stop_time = None  # Use once so next slot is not trimmed
 *                         if trim_to > start_date:             # <<<<<<<<<<<<<<
 *                             start_date = trim_to
 *                             logger.info("Trimmed interval start after break stop / last interval end: %s to %s", start_date, end_date)
*/
            __pyx_t_33 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_trim_to, __pyx_cur_scope->__pyx_v_start_date, Py_GT); __Pyx_XGOTREF(__pyx_t_33); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2222, __pyx_L263_error)
            __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_33); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2222, __pyx_L263_error)
            __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
            if (__pyx_t_8) {

              /* "ws_package/controllers/activity_controller.py":2223
 *                             self._break_stop_time = None  # Use once so next slot is not trimmed
 *                         if trim_to > start_date:
 *                             start_date = trim_to             # <<<<<<<<<<<<<<
 *                             logger.info("Trimmed interval start after break stop / last interval end: %s to %s", start_date, end_date)
 *                     self.main_start_date = start_date
*/
              __Pyx_INCREF(__pyx_cur_scope->__pyx_v_trim_to);
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_start_date);
              __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_trim_to);
              __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_trim_to);

              /* "ws_package/controllers/activity_controller.py":2224
 *                         if trim_to > start_date:
 *                             start_date = trim_to
 *                             logger.info("Trimmed interval start after break stop / last interval end: %s to %s", start_date, end_date)             # <<<<<<<<<<<<<<
 *                     self.main_start_date = start_date
 *                     self.main_end_date = end_date
*/
              __pyx_t_34 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2224, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2224, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_15);
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_15))) {
                __pyx_t_34 = PyMethod_GET_SELF(__pyx_t_15);
                assert(__pyx_t_34);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                __Pyx_INCREF(__pyx_t_34);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[4] = {__pyx_t_34, __pyx_mstate_global->__pyx_kp_u_Trimmed_interval_start_after_bre, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
                __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2224, __pyx_L263_error)
                __Pyx_GOTREF(__pyx_t_33);
              }
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

              /* "ws_package/controllers/activity_controller.py":2222
 *                             trim_to = max(trim_to, break_stop_time_attr)
 *                             self._break_stop_time = None  # Use once so next slot is not trimmed
 *                         if trim_to > start_date:             # <<<<<<<<<<<<<<
 *                             start_date = trim_to
 *                             logger.info("Trimmed interval start after break stop / last interval end: %s to %s", start_date, end_date)
*/
            }

            /* "ws_package/controllers/activity_controller.py":2205
 *                     # start this interval at that time so we don't double-count 17:15-17:17 as work time.
 *                     current_break_id_slot = getattr(self, 'break_id', 0) or 0
 *                     if current_break_id_slot == 0:             # <<<<<<<<<<<<<<
 *                         trim_to = start_date
 *                         last_end = await self.activity_service.get_last_activity_interval()
*/
          }

          /* "ws_package/controllers/activity_controller.py":2225
 *                             start_date = trim_to
 *                             logger.info("Trimmed interval start after break stop / last interval end: %s to %s", start_date, end_date)
 *                     self.main_start_date = start_date             # <<<<<<<<<<<<<<
 *                     self.main_end_date = end_date
 * 
*/
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_main_start_date, __pyx_cur_scope->__pyx_v_start_date) < (0)) __PYX_ERR(0, 2225, __pyx_L263_error)

          /* "ws_package/controllers/activity_controller.py":2226
 *                             logger.info("Trimmed interval start after break stop / last interval end: %s to %s", start_date, end_date)
 *                     self.main_start_date = start_date
 *                     self.main_end_date = end_date             # <<<<<<<<<<<<<<
 * 
 *                 else:
*/
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_main_end_date, __pyx_cur_scope->__pyx_v_end_date) < (0)) __PYX_ERR(0, 2226, __pyx_L263_error)

          /* "ws_package/controllers/activity_controller.py":2198
 *                     await self._try_finalize_post_switch_slot_interval(user_entity)
 * 
 *                 if self.Flag==True: # This is not the first time slot, so we need to get the current slot             # <<<<<<<<<<<<<<
 * 
 *                     start_date= await self.getCurrentSlot()
*/
          goto __pyx_L276;
        }

        /* "ws_package/controllers/activity_controller.py":2229
 * 
 *                 else:
 *                     self.Flag=True # This is the first time slot, so we need to get the starting slot             # <<<<<<<<<<<<<<
 *                     start_date,end_date=await self.getStartingSlot()
 *                     self.main_start_date = start_date
*/
        /*else*/ {
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_Flag, Py_True) < (0)) __PYX_ERR(0, 2229, __pyx_L263_error)

          /* "ws_package/controllers/activity_controller.py":2230
 *                 else:
 *                     self.Flag=True # This is the first time slot, so we need to get the starting slot
 *                     start_date,end_date=await self.getStartingSlot()             # <<<<<<<<<<<<<<
 *                     self.main_start_date = start_date
 *                     self.main_end_date = end_date
*/
          __pyx_t_15 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_15);
          __pyx_t_7 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL};
            __pyx_t_33 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_getStartingSlot, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2230, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_33);
          }
          __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_33, &__pyx_r);
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
          if (likely(__pyx_t_26 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_11);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
            __Pyx_XGIVEREF(__pyx_t_12);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
            __Pyx_XGIVEREF(__pyx_t_13);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 18;
            return __pyx_r;
            __pyx_L292_resume_from_await:;
            __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_11);
            __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_12);
            __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_13);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2230, __pyx_L263_error)
            __pyx_t_33 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_33);
          } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __pyx_t_33 = __pyx_r; __pyx_r = NULL;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 2230, __pyx_L263_error)
          }
          if ((likely(PyTuple_CheckExact(__pyx_t_33))) || (PyList_CheckExact(__pyx_t_33))) {
            PyObject* sequence = __pyx_t_33;
            Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
            if (unlikely(size != 2)) {
              if (size > 2) __Pyx_RaiseTooManyValuesError(2);
              else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
              __PYX_ERR(0, 2230, __pyx_L263_error)
            }
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            if (likely(PyTuple_CheckExact(sequence))) {
              __pyx_t_15 = PyTuple_GET_ITEM(sequence, 0);
              __Pyx_INCREF(__pyx_t_15);
              __pyx_t_34 = PyTuple_GET_ITEM(sequence, 1);
              __Pyx_INCREF(__pyx_t_34);
            } else {
              __pyx_t_15 = __Pyx_PyList_GET_ITEM_REF(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
              if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2230, __pyx_L263_error)
              __Pyx_XGOTREF(__pyx_t_15);
              __pyx_t_34 = __Pyx_PyList_GET_ITEM_REF(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
              if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2230, __pyx_L263_error)
              __Pyx_XGOTREF(__pyx_t_34);
            }
            #else
            __pyx_t_15 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2230, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_15);
            __pyx_t_34 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2230, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_34);
            #endif
            __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
          } else {
            Py_ssize_t index = -1;
            __pyx_t_1 = PyObject_GetIter(__pyx_t_33); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2230, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
            __pyx_t_44 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_1);
            index = 0; __pyx_t_15 = __pyx_t_44(__pyx_t_1); if (unlikely(!__pyx_t_15)) goto __pyx_L293_unpacking_failed;
            __Pyx_GOTREF(__pyx_t_15);
            index = 1; __pyx_t_34 = __pyx_t_44(__pyx_t_1); if (unlikely(!__pyx_t_34)) goto __pyx_L293_unpacking_failed;
            __Pyx_GOTREF(__pyx_t_34);
            if (__Pyx_IternextUnpackEndCheck(__pyx_t_44(__pyx_t_1), 2) < (0)) __PYX_ERR(0, 2230, __pyx_L263_error)
            __pyx_t_44 = NULL;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            goto __pyx_L294_unpacking_done;
            __pyx_L293_unpacking_failed:;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_44 = NULL;
            if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
            __PYX_ERR(0, 2230, __pyx_L263_error)
            __pyx_L294_unpacking_done:;
          }
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_start_date);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_start_date, __pyx_t_15);
          __Pyx_GIVEREF(__pyx_t_15);
          __pyx_t_15 = 0;
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_end_date);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_end_date, __pyx_t_34);
          __Pyx_GIVEREF(__pyx_t_34);
          __pyx_t_34 = 0;

          /* "ws_package/controllers/activity_controller.py":2231
 *                     self.Flag=True # This is the first time slot, so we need to get the starting slot
 *                     start_date,end_date=await self.getStartingSlot()
 *                     self.main_start_date = start_date             # <<<<<<<<<<<<<<
 *                     self.main_end_date = end_date
 *                 logger.info(">>"*100)
*/
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_main_start_date, __pyx_cur_scope->__pyx_v_start_date) < (0)) __PYX_ERR(0, 2231, __pyx_L263_error)

          /* "ws_package/controllers/activity_controller.py":2232
 *                     start_date,end_date=await self.getStartingSlot()
 *                     self.main_start_date = start_date
 *                     self.main_end_date = end_date             # <<<<<<<<<<<<<<
 *                 logger.info(">>"*100)
 *                 logger.info("appVersion: %s", self.appVersion)
*/
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_main_end_date, __pyx_cur_scope->__pyx_v_end_date) < (0)) __PYX_ERR(0, 2232, __pyx_L263_error)
        }
        __pyx_L276:;

        /* "ws_package/controllers/activity_controller.py":2233
 *                     self.main_start_date = start_date
 *                     self.main_end_date = end_date
 *                 logger.info(">>"*100)             # <<<<<<<<<<<<<<
 *                 logger.info("appVersion: %s", self.appVersion)
 *                 logger.info("current Project id: %s, current task id : %s", self.current_project_id, self.current_task_id)
*/
        __pyx_t_34 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2233, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2233, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_34 = PyMethod_GET_SELF(__pyx_t_1);
          assert(__pyx_t_34);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_34);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_34, __pyx_mstate_global->__pyx_kp_u__6};
          __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2233, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_33);
        }
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

        /* "ws_package/controllers/activity_controller.py":2234
 *                     self.main_end_date = end_date
 *                 logger.info(">>"*100)
 *                 logger.info("appVersion: %s", self.appVersion)             # <<<<<<<<<<<<<<
 *                 logger.info("current Project id: %s, current task id : %s", self.current_project_id, self.current_task_id)
 *                 logger.info("current break id: %s, current is break: %s", self.break_id, self.is_break)
*/
        __pyx_t_1 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2234, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_34);
        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2234, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
        __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appVersion); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2234, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_34);
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_15))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_15);
          assert(__pyx_t_1);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_appVersion_s, __pyx_t_34};
          __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2234, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_33);
        }
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

        /* "ws_package/controllers/activity_controller.py":2235
 *                 logger.info(">>"*100)
 *                 logger.info("appVersion: %s", self.appVersion)
 *                 logger.info("current Project id: %s, current task id : %s", self.current_project_id, self.current_task_id)             # <<<<<<<<<<<<<<
 *                 logger.info("current break id: %s, current is break: %s", self.break_id, self.is_break)
 *                 logger.info(">>"*100)
*/
        __pyx_t_15 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2235, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_34);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2235, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
        __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_project_id); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2235, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_34);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_task_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2235, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_1);
          assert(__pyx_t_15);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_15);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[4] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_current_Project_id_s_current_tas, __pyx_t_34, __pyx_t_3};
          __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2235, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_33);
        }
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

        /* "ws_package/controllers/activity_controller.py":2236
 *                 logger.info("appVersion: %s", self.appVersion)
 *                 logger.info("current Project id: %s, current task id : %s", self.current_project_id, self.current_task_id)
 *                 logger.info("current break id: %s, current is break: %s", self.break_id, self.is_break)             # <<<<<<<<<<<<<<
 *                 logger.info(">>"*100)
 *                 # time/timezone check (skipped when timezone_preference=1)
*/
        __pyx_t_1 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2236, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2236, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_34);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_break_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2236, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_is_break); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2236, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_34))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_34);
          assert(__pyx_t_1);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_34);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_34, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[4] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_current_break_id_s_current_is_br, __pyx_t_3, __pyx_t_15};
          __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_34, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
          if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2236, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_33);
        }
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

        /* "ws_package/controllers/activity_controller.py":2237
 *                 logger.info("current Project id: %s, current task id : %s", self.current_project_id, self.current_task_id)
 *                 logger.info("current break id: %s, current is break: %s", self.break_id, self.is_break)
 *                 logger.info(">>"*100)             # <<<<<<<<<<<<<<
 *                 # time/timezone check (skipped when timezone_preference=1)
 *                 try:
*/
        __pyx_t_34 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2237, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2237, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_34 = PyMethod_GET_SELF(__pyx_t_3);
          assert(__pyx_t_34);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_34);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_34, __pyx_mstate_global->__pyx_kp_u__6};
          __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2237, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_33);
        }
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

        /* "ws_package/controllers/activity_controller.py":2239
 *                 logger.info(">>"*100)
 *                 # time/timezone check (skipped when timezone_preference=1)
 *                 try:             # <<<<<<<<<<<<<<
 *                     from ws_package.utils.desktop_key import apply_desktop_key
 *                     url = ""
*/
        {
          __Pyx_ExceptionSave(&__pyx_t_31, &__pyx_t_23, &__pyx_t_39);
          __Pyx_XGOTREF(__pyx_t_31);
          __Pyx_XGOTREF(__pyx_t_23);
          __Pyx_XGOTREF(__pyx_t_39);
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":2240
 *                 # time/timezone check (skipped when timezone_preference=1)
 *                 try:
 *                     from ws_package.utils.desktop_key import apply_desktop_key             # <<<<<<<<<<<<<<
 *                     url = ""
 *                     headers = {}
*/
            {
              PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_apply_desktop_key};
              __pyx_t_18 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_utils_desktop_key, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 2240, __pyx_L295_error)
            }
            __pyx_t_33 = __pyx_t_18;
            __Pyx_GOTREF(__pyx_t_33);
            {
              PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_apply_desktop_key};
              __pyx_t_29 = 0; {
                __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_33, __pyx_imported_names[__pyx_t_29]); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2240, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_3);
                switch (__pyx_t_29) {
                  case 0:
                  __Pyx_INCREF(__pyx_t_3);
                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_apply_desktop_key);
                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_apply_desktop_key, __pyx_t_3);
                  __Pyx_GIVEREF(__pyx_t_3);
                  break;
                  default:;
                }
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              }
            }
            __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

            /* "ws_package/controllers/activity_controller.py":2241
 *                 try:
 *                     from ws_package.utils.desktop_key import apply_desktop_key
 *                     url = ""             # <<<<<<<<<<<<<<
 *                     headers = {}
 *                     if self.org_api_timezone is None:
*/
            __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u__2);
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_url);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_url, __pyx_mstate_global->__pyx_kp_u__2);
            __Pyx_GIVEREF(__pyx_mstate_global->__pyx_kp_u__2);

            /* "ws_package/controllers/activity_controller.py":2242
 *                     from ws_package.utils.desktop_key import apply_desktop_key
 *                     url = ""
 *                     headers = {}             # <<<<<<<<<<<<<<
 *                     if self.org_api_timezone is None:
 *                         await self._load_org_settings_from_db()
*/
            __pyx_t_33 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2242, __pyx_L295_error)
            __Pyx_GOTREF(__pyx_t_33);
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_headers);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_headers, __pyx_t_33);
            __Pyx_GIVEREF(__pyx_t_33);
            __pyx_t_33 = 0;

            /* "ws_package/controllers/activity_controller.py":2243
 *                     url = ""
 *                     headers = {}
 *                     if self.org_api_timezone is None:             # <<<<<<<<<<<<<<
 *                         await self._load_org_settings_from_db()
 *                     timecheck_failed = False
*/
            __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_org_api_timezone); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2243, __pyx_L295_error)
            __Pyx_GOTREF(__pyx_t_33);
            __pyx_t_8 = (__pyx_t_33 == Py_None);
            __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
            if (__pyx_t_8) {

              /* "ws_package/controllers/activity_controller.py":2244
 *                     headers = {}
 *                     if self.org_api_timezone is None:
 *                         await self._load_org_settings_from_db()             # <<<<<<<<<<<<<<
 *                     timecheck_failed = False
 *                     if user_entity is not None:
*/
              __pyx_t_3 = __pyx_cur_scope->__pyx_v_self;
              __Pyx_INCREF(__pyx_t_3);
              __pyx_t_7 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
                __pyx_t_33 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_load_org_settings_from_db, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2244, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_33);
              }
              __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_33, &__pyx_r);
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_XGIVEREF(__pyx_t_11);
                __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                __Pyx_XGIVEREF(__pyx_t_12);
                __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                __Pyx_XGIVEREF(__pyx_t_13);
                __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                __Pyx_XGIVEREF(__pyx_t_23);
                __pyx_cur_scope->__pyx_t_3 = __pyx_t_23;
                __Pyx_XGIVEREF(__pyx_t_31);
                __pyx_cur_scope->__pyx_t_4 = __pyx_t_31;
                __Pyx_XGIVEREF(__pyx_t_39);
                __pyx_cur_scope->__pyx_t_5 = __pyx_t_39;
                __Pyx_XGIVEREF(__pyx_r);
                __Pyx_RefNannyFinishContext();
                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                /* return from generator, awaiting value */
                __pyx_generator->resume_label = 19;
                return __pyx_r;
                __pyx_L304_resume_from_await:;
                __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                __pyx_cur_scope->__pyx_t_0 = 0;
                __Pyx_XGOTREF(__pyx_t_11);
                __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                __pyx_cur_scope->__pyx_t_1 = 0;
                __Pyx_XGOTREF(__pyx_t_12);
                __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                __pyx_cur_scope->__pyx_t_2 = 0;
                __Pyx_XGOTREF(__pyx_t_13);
                __pyx_t_23 = __pyx_cur_scope->__pyx_t_3;
                __pyx_cur_scope->__pyx_t_3 = 0;
                __Pyx_XGOTREF(__pyx_t_23);
                __pyx_t_31 = __pyx_cur_scope->__pyx_t_4;
                __pyx_cur_scope->__pyx_t_4 = 0;
                __Pyx_XGOTREF(__pyx_t_31);
                __pyx_t_39 = __pyx_cur_scope->__pyx_t_5;
                __pyx_cur_scope->__pyx_t_5 = 0;
                __Pyx_XGOTREF(__pyx_t_39);
                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2244, __pyx_L295_error)
              } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_DECREF(__pyx_r); __pyx_r = 0;
              } else {
                __Pyx_XGOTREF(__pyx_r);
                __PYX_ERR(0, 2244, __pyx_L295_error)
              }

              /* "ws_package/controllers/activity_controller.py":2243
 *                     url = ""
 *                     headers = {}
 *                     if self.org_api_timezone is None:             # <<<<<<<<<<<<<<
 *                         await self._load_org_settings_from_db()
 *                     timecheck_failed = False
*/
            }

            /* "ws_package/controllers/activity_controller.py":2245
 *                     if self.org_api_timezone is None:
 *                         await self._load_org_settings_from_db()
 *                     timecheck_failed = False             # <<<<<<<<<<<<<<
 *                     if user_entity is not None:
 *                         if not self._timezone_checks_enabled(user_entity):
*/
            __pyx_cur_scope->__pyx_v_timecheck_failed = 0;

            /* "ws_package/controllers/activity_controller.py":2246
 *                         await self._load_org_settings_from_db()
 *                     timecheck_failed = False
 *                     if user_entity is not None:             # <<<<<<<<<<<<<<
 *                         if not self._timezone_checks_enabled(user_entity):
 *                             logger.info(
*/
            __pyx_t_8 = (__pyx_cur_scope->__pyx_v_user_entity != Py_None);
            if (__pyx_t_8) {

              /* "ws_package/controllers/activity_controller.py":2247
 *                     timecheck_failed = False
 *                     if user_entity is not None:
 *                         if not self._timezone_checks_enabled(user_entity):             # <<<<<<<<<<<<<<
 *                             logger.info(
 *                                 "Skipping timecheck  timezone_preference=%s (checks OFF)",
*/
              __pyx_t_3 = __pyx_cur_scope->__pyx_v_self;
              __Pyx_INCREF(__pyx_t_3);
              __pyx_t_7 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_user_entity};
                __pyx_t_33 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_timezone_checks_enabled, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2247, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_33);
              }
              __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_33); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2247, __pyx_L295_error)
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              __pyx_t_9 = (!__pyx_t_8);
              if (__pyx_t_9) {

                /* "ws_package/controllers/activity_controller.py":2248
 *                     if user_entity is not None:
 *                         if not self._timezone_checks_enabled(user_entity):
 *                             logger.info(             # <<<<<<<<<<<<<<
 *                                 "Skipping timecheck  timezone_preference=%s (checks OFF)",
 *                                 getattr(self, "timezone_preference", getattr(user_entity, "timezone_preference", None)),
*/
                __pyx_t_3 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2248, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_34);
                __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2248, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_15);
                __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;

                /* "ws_package/controllers/activity_controller.py":2250
 *                             logger.info(
 *                                 "Skipping timecheck  timezone_preference=%s (checks OFF)",
 *                                 getattr(self, "timezone_preference", getattr(user_entity, "timezone_preference", None)),             # <<<<<<<<<<<<<<
 *                             )
 *                         elif self.org_api_timezone is None:
*/
                __pyx_t_34 = __pyx_cur_scope->__pyx_v_self;
                __Pyx_INCREF(__pyx_t_34);
                __pyx_t_1 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_timezone_preference, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2250, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_1);
                __pyx_t_5 = __Pyx_GetAttr3(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_timezone_preference, __pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2250, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_5);
                __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_15))) {
                  __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_15);
                  assert(__pyx_t_3);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                  __Pyx_INCREF(__pyx_t_3);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Skipping_timecheck_timezone_pref, __pyx_t_5};
                  __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2248, __pyx_L295_error)
                  __Pyx_GOTREF(__pyx_t_33);
                }
                __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

                /* "ws_package/controllers/activity_controller.py":2247
 *                     timecheck_failed = False
 *                     if user_entity is not None:
 *                         if not self._timezone_checks_enabled(user_entity):             # <<<<<<<<<<<<<<
 *                             logger.info(
 *                                 "Skipping timecheck  timezone_preference=%s (checks OFF)",
*/
                goto __pyx_L306;
              }

              /* "ws_package/controllers/activity_controller.py":2252
 *                                 getattr(self, "timezone_preference", getattr(user_entity, "timezone_preference", None)),
 *                             )
 *                         elif self.org_api_timezone is None:             # <<<<<<<<<<<<<<
 *                             logger.warning(
 *                                 "Skipping timecheck  org timezone not loaded yet"
*/
              __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_org_api_timezone); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2252, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_33);
              __pyx_t_9 = (__pyx_t_33 == Py_None);
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              if (__pyx_t_9) {

                /* "ws_package/controllers/activity_controller.py":2253
 *                             )
 *                         elif self.org_api_timezone is None:
 *                             logger.warning(             # <<<<<<<<<<<<<<
 *                                 "Skipping timecheck  org timezone not loaded yet"
 *                             )
*/
                __pyx_t_15 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2253, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_5);
                __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2253, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_3);
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_3))) {
                  __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_3);
                  assert(__pyx_t_15);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
                  __Pyx_INCREF(__pyx_t_15);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Skipping_timecheck_org_timezone};
                  __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2253, __pyx_L295_error)
                  __Pyx_GOTREF(__pyx_t_33);
                }
                __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

                /* "ws_package/controllers/activity_controller.py":2252
 *                                 getattr(self, "timezone_preference", getattr(user_entity, "timezone_preference", None)),
 *                             )
 *                         elif self.org_api_timezone is None:             # <<<<<<<<<<<<<<
 *                             logger.warning(
 *                                 "Skipping timecheck  org timezone not loaded yet"
*/
                goto __pyx_L306;
              }

              /* "ws_package/controllers/activity_controller.py":2257
 *                             )
 *                         else:
 *                             logger.info(             # <<<<<<<<<<<<<<
 *                                 "Running timecheck  timezone_preference=%s (checks ON)",
 *                                 getattr(self, "timezone_preference", getattr(user_entity, "timezone_preference", None)),
*/
              /*else*/ {
                __pyx_t_3 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2257, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_15);
                __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2257, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_5);
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

                /* "ws_package/controllers/activity_controller.py":2259
 *                             logger.info(
 *                                 "Running timecheck  timezone_preference=%s (checks ON)",
 *                                 getattr(self, "timezone_preference", getattr(user_entity, "timezone_preference", None)),             # <<<<<<<<<<<<<<
 *                             )
 *                             timecheck_failed = not await self.timecheck_with_recheck(
*/
                __pyx_t_15 = __pyx_cur_scope->__pyx_v_self;
                __Pyx_INCREF(__pyx_t_15);
                __pyx_t_1 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_timezone_preference, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2259, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_1);
                __pyx_t_34 = __Pyx_GetAttr3(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_timezone_preference, __pyx_t_1); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2259, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_34);
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_5))) {
                  __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
                  assert(__pyx_t_3);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                  __Pyx_INCREF(__pyx_t_3);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Running_timecheck_timezone_prefe, __pyx_t_34};
                  __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2257, __pyx_L295_error)
                  __Pyx_GOTREF(__pyx_t_33);
                }
                __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

                /* "ws_package/controllers/activity_controller.py":2261
 *                                 getattr(self, "timezone_preference", getattr(user_entity, "timezone_preference", None)),
 *                             )
 *                             timecheck_failed = not await self.timecheck_with_recheck(             # <<<<<<<<<<<<<<
 *                                 user_entity, stop_event
 *                             )
*/
                __pyx_t_5 = __pyx_cur_scope->__pyx_v_self;
                __Pyx_INCREF(__pyx_t_5);

                /* "ws_package/controllers/activity_controller.py":2262
 *                             )
 *                             timecheck_failed = not await self.timecheck_with_recheck(
 *                                 user_entity, stop_event             # <<<<<<<<<<<<<<
 *                             )
 *                     if user_entity is not None and timecheck_failed:
*/
                __pyx_t_7 = 0;
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_user_entity, __pyx_cur_scope->__pyx_v_stop_event};
                  __pyx_t_33 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_timecheck_with_recheck, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2261, __pyx_L295_error)
                  __Pyx_GOTREF(__pyx_t_33);
                }
                __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_33, &__pyx_r);
                __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_11);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_t_23);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_23;
                  __Pyx_XGIVEREF(__pyx_t_31);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_31;
                  __Pyx_XGIVEREF(__pyx_t_39);
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_39;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 20;
                  return __pyx_r;
                  __pyx_L307_resume_from_await:;
                  __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_11);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  __pyx_t_23 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_23);
                  __pyx_t_31 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_31);
                  __pyx_t_39 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = 0;
                  __Pyx_XGOTREF(__pyx_t_39);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2261, __pyx_L295_error)
                  __pyx_t_33 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_33);
                } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __pyx_t_33 = __pyx_r; __pyx_r = NULL;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 2261, __pyx_L295_error)
                }

                /* "ws_package/controllers/activity_controller.py":2261
 *                                 getattr(self, "timezone_preference", getattr(user_entity, "timezone_preference", None)),
 *                             )
 *                             timecheck_failed = not await self.timecheck_with_recheck(             # <<<<<<<<<<<<<<
 *                                 user_entity, stop_event
 *                             )
*/
                __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_33); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2261, __pyx_L295_error)
                __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                __pyx_cur_scope->__pyx_v_timecheck_failed = (!__pyx_t_9);
              }
              __pyx_L306:;

              /* "ws_package/controllers/activity_controller.py":2246
 *                         await self._load_org_settings_from_db()
 *                     timecheck_failed = False
 *                     if user_entity is not None:             # <<<<<<<<<<<<<<
 *                         if not self._timezone_checks_enabled(user_entity):
 *                             logger.info(
*/
            }

            /* "ws_package/controllers/activity_controller.py":2264
 *                                 user_entity, stop_event
 *                             )
 *                     if user_entity is not None and timecheck_failed:             # <<<<<<<<<<<<<<
 *                         logger.info("Time mismatch under activity")
 *                         active_app_url = [{
*/
            __pyx_t_8 = (__pyx_cur_scope->__pyx_v_user_entity != Py_None);
            if (__pyx_t_8) {
            } else {
              __pyx_t_9 = __pyx_t_8;
              goto __pyx_L309_bool_binop_done;
            }
            __pyx_t_9 = __pyx_cur_scope->__pyx_v_timecheck_failed;
            __pyx_L309_bool_binop_done:;
            if (__pyx_t_9) {

              /* "ws_package/controllers/activity_controller.py":2265
 *                             )
 *                     if user_entity is not None and timecheck_failed:
 *                         logger.info("Time mismatch under activity")             # <<<<<<<<<<<<<<
 *                         active_app_url = [{
 *                             "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),
*/
              __pyx_t_5 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2265, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_34);
              __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2265, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_3))) {
                __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
                assert(__pyx_t_5);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
                __Pyx_INCREF(__pyx_t_5);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Time_mismatch_under_activity};
                __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2265, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_33);
              }
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

              /* "ws_package/controllers/activity_controller.py":2267
 *                         logger.info("Time mismatch under activity")
 *                         active_app_url = [{
 *                             "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),             # <<<<<<<<<<<<<<
 *                             "module": "Wrong Timestamp",
 *                             "active_app": "Wrong Timestamp",
*/
              __pyx_t_33 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2267, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_33);
              __pyx_t_5 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_time); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2267, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_34);
              __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_strftime); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2267, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_1))) {
                __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
                assert(__pyx_t_5);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
                __Pyx_INCREF(__pyx_t_5);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Y_m_d_H_M_S};
                __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2267, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_3);
              }
              __pyx_t_1 = __Pyx_PyObject_Unicode(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2267, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              if (PyDict_SetItem(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_timestamp, __pyx_t_1) < (0)) __PYX_ERR(0, 2267, __pyx_L295_error)
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (PyDict_SetItem(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_module, __pyx_mstate_global->__pyx_kp_u_Wrong_Timestamp) < (0)) __PYX_ERR(0, 2267, __pyx_L295_error)
              if (PyDict_SetItem(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_active_app, __pyx_mstate_global->__pyx_kp_u_Wrong_Timestamp) < (0)) __PYX_ERR(0, 2267, __pyx_L295_error)
              if (PyDict_SetItem(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_url, __pyx_mstate_global->__pyx_kp_u_Wrong_Timestamp) < (0)) __PYX_ERR(0, 2267, __pyx_L295_error)

              /* "ws_package/controllers/activity_controller.py":2266
 *                     if user_entity is not None and timecheck_failed:
 *                         logger.info("Time mismatch under activity")
 *                         active_app_url = [{             # <<<<<<<<<<<<<<
 *                             "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),
 *                             "module": "Wrong Timestamp",
*/
              __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2266, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_GIVEREF(__pyx_t_33);
              if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_t_33) != (0)) __PYX_ERR(0, 2266, __pyx_L295_error);
              __pyx_t_33 = 0;
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_active_app_url);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_active_app_url, ((PyObject*)__pyx_t_1));
              __Pyx_GIVEREF(__pyx_t_1);
              __pyx_t_1 = 0;

              /* "ws_package/controllers/activity_controller.py":2273
 *                         }]
 * 
 *                         await self.activity_service.save_app_monitors(active_app_url, self.last_count+1, True),             # <<<<<<<<<<<<<<
 * 
 *                         logger.info("save last active app as true because of wrong timezone deteceted so next last min save can't be wrong from activity")
*/
              __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2273, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_33 = __pyx_t_3;
              __Pyx_INCREF(__pyx_t_33);
              __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2273, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_5);
              __pyx_t_34 = __Pyx_PyLong_AddObjC(__pyx_t_5, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2273, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_34);
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __pyx_t_7 = 0;
              {
                PyObject *__pyx_callargs[4] = {__pyx_t_33, __pyx_cur_scope->__pyx_v_active_app_url, __pyx_t_34, Py_True};
                __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_save_app_monitors, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2273, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_1);
              }
              __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_XGIVEREF(__pyx_t_11);
                __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                __Pyx_XGIVEREF(__pyx_t_12);
                __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                __Pyx_XGIVEREF(__pyx_t_13);
                __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                __Pyx_XGIVEREF(__pyx_t_23);
                __pyx_cur_scope->__pyx_t_3 = __pyx_t_23;
                __Pyx_XGIVEREF(__pyx_t_31);
                __pyx_cur_scope->__pyx_t_4 = __pyx_t_31;
                __Pyx_XGIVEREF(__pyx_t_39);
                __pyx_cur_scope->__pyx_t_5 = __pyx_t_39;
                __Pyx_XGIVEREF(__pyx_r);
                __Pyx_RefNannyFinishContext();
                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                /* return from generator, awaiting value */
                __pyx_generator->resume_label = 21;
                return __pyx_r;
                __pyx_L311_resume_from_await:;
                __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                __pyx_cur_scope->__pyx_t_0 = 0;
                __Pyx_XGOTREF(__pyx_t_11);
                __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                __pyx_cur_scope->__pyx_t_1 = 0;
                __Pyx_XGOTREF(__pyx_t_12);
                __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                __pyx_cur_scope->__pyx_t_2 = 0;
                __Pyx_XGOTREF(__pyx_t_13);
                __pyx_t_23 = __pyx_cur_scope->__pyx_t_3;
                __pyx_cur_scope->__pyx_t_3 = 0;
                __Pyx_XGOTREF(__pyx_t_23);
                __pyx_t_31 = __pyx_cur_scope->__pyx_t_4;
                __pyx_cur_scope->__pyx_t_4 = 0;
                __Pyx_XGOTREF(__pyx_t_31);
                __pyx_t_39 = __pyx_cur_scope->__pyx_t_5;
                __pyx_cur_scope->__pyx_t_5 = 0;
                __Pyx_XGOTREF(__pyx_t_39);
                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2273, __pyx_L295_error)
                __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
              } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                __Pyx_GOTREF(__pyx_r);
                __pyx_t_1 = __pyx_r; __pyx_r = NULL;
              } else {
                __Pyx_XGOTREF(__pyx_r);
                __PYX_ERR(0, 2273, __pyx_L295_error)
              }
              __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2273, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_GIVEREF(__pyx_t_1);
              if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 2273, __pyx_L295_error);
              __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

              /* "ws_package/controllers/activity_controller.py":2275
 *                         await self.activity_service.save_app_monitors(active_app_url, self.last_count+1, True),
 * 
 *                         logger.info("save last active app as true because of wrong timezone deteceted so next last min save can't be wrong from activity")             # <<<<<<<<<<<<<<
 *                         url = config('timezone_mismatch', 'Application')
 *                         headers = {
*/
              __pyx_t_1 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2275, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_34);
              __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2275, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_33);
              __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_33))) {
                __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_33);
                assert(__pyx_t_1);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
                __Pyx_INCREF(__pyx_t_1);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_save_last_active_app_as_true_bec};
                __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2275, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_3);
              }
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

              /* "ws_package/controllers/activity_controller.py":2276
 * 
 *                         logger.info("save last active app as true because of wrong timezone deteceted so next last min save can't be wrong from activity")
 *                         url = config('timezone_mismatch', 'Application')             # <<<<<<<<<<<<<<
 *                         headers = {
 *                             "Content-Type": "application/json",
*/
              __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_config); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2276, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_33 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_mstate_global->__pyx_tuple[22], NULL); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2276, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_33);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_url);
              __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_url, __pyx_t_33);
              __Pyx_GIVEREF(__pyx_t_33);
              __pyx_t_33 = 0;

              /* "ws_package/controllers/activity_controller.py":2278
 *                         url = config('timezone_mismatch', 'Application')
 *                         headers = {
 *                             "Content-Type": "application/json",             # <<<<<<<<<<<<<<
 *                             "Authorization": f"Bearer {user_entity.sd_token}",
 *                             "OrgID": f"{user_entity.org_id}",
*/
              __pyx_t_33 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2278, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_33);
              if (PyDict_SetItem(__pyx_t_33, __pyx_mstate_global->__pyx_kp_u_Content_Type, __pyx_mstate_global->__pyx_kp_u_application_json) < (0)) __PYX_ERR(0, 2278, __pyx_L295_error)

              /* "ws_package/controllers/activity_controller.py":2279
 *                         headers = {
 *                             "Content-Type": "application/json",
 *                             "Authorization": f"Bearer {user_entity.sd_token}",             # <<<<<<<<<<<<<<
 *                             "OrgID": f"{user_entity.org_id}",
 *                             "SDToken": f"{user_entity.sd_token}",
*/
              __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_sd_token); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2279, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_1 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2279, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __pyx_t_3 = __Pyx_PyUnicode_Concat(__pyx_mstate_global->__pyx_kp_u_Bearer, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2279, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (PyDict_SetItem(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_Authorization, __pyx_t_3) < (0)) __PYX_ERR(0, 2278, __pyx_L295_error)
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

              /* "ws_package/controllers/activity_controller.py":2280
 *                             "Content-Type": "application/json",
 *                             "Authorization": f"Bearer {user_entity.sd_token}",
 *                             "OrgID": f"{user_entity.org_id}",             # <<<<<<<<<<<<<<
 *                             "SDToken": f"{user_entity.sd_token}",
 *                             "UserID": f"{user_entity.user_id}"
*/
              __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_org_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2280, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_1 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2280, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              if (PyDict_SetItem(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_OrgID, __pyx_t_1) < (0)) __PYX_ERR(0, 2278, __pyx_L295_error)
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

              /* "ws_package/controllers/activity_controller.py":2281
 *                             "Authorization": f"Bearer {user_entity.sd_token}",
 *                             "OrgID": f"{user_entity.org_id}",
 *                             "SDToken": f"{user_entity.sd_token}",             # <<<<<<<<<<<<<<
 *                             "UserID": f"{user_entity.user_id}"
 *                         }
*/
              __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_sd_token); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2281, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_t_1, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2281, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (PyDict_SetItem(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_SDToken, __pyx_t_3) < (0)) __PYX_ERR(0, 2278, __pyx_L295_error)
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

              /* "ws_package/controllers/activity_controller.py":2282
 *                             "OrgID": f"{user_entity.org_id}",
 *                             "SDToken": f"{user_entity.sd_token}",
 *                             "UserID": f"{user_entity.user_id}"             # <<<<<<<<<<<<<<
 *                         }
 *                         headers = apply_desktop_key(headers)
*/
              __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_user_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2282, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_1 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2282, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              if (PyDict_SetItem(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_UserID, __pyx_t_1) < (0)) __PYX_ERR(0, 2278, __pyx_L295_error)
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_headers);
              __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_headers, __pyx_t_33);
              __Pyx_GIVEREF(__pyx_t_33);
              __pyx_t_33 = 0;

              /* "ws_package/controllers/activity_controller.py":2284
 *                             "UserID": f"{user_entity.user_id}"
 *                         }
 *                         headers = apply_desktop_key(headers)             # <<<<<<<<<<<<<<
 *                         payload = {
 *                             "device_type": self.get_os_type_caps(),
*/
              __pyx_t_1 = NULL;
              __Pyx_INCREF(__pyx_cur_scope->__pyx_v_apply_desktop_key);
              __pyx_t_3 = __pyx_cur_scope->__pyx_v_apply_desktop_key; 
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_3))) {
                __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
                assert(__pyx_t_1);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
                __Pyx_INCREF(__pyx_t_1);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_cur_scope->__pyx_v_headers};
                __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2284, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_33);
              }
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_headers);
              __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_headers, __pyx_t_33);
              __Pyx_GIVEREF(__pyx_t_33);
              __pyx_t_33 = 0;

              /* "ws_package/controllers/activity_controller.py":2286
 *                         headers = apply_desktop_key(headers)
 *                         payload = {
 *                             "device_type": self.get_os_type_caps(),             # <<<<<<<<<<<<<<
 *                             "os_name": self.get_os_type_caps(),
 *                             "os_version": get_os_version(),
*/
              __pyx_t_33 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2286, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_33);
              __pyx_t_1 = __pyx_cur_scope->__pyx_v_self;
              __Pyx_INCREF(__pyx_t_1);
              __pyx_t_7 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
                __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type_caps, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2286, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_3);
              }
              if (PyDict_SetItem(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_device_type, __pyx_t_3) < (0)) __PYX_ERR(0, 2286, __pyx_L295_error)
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

              /* "ws_package/controllers/activity_controller.py":2287
 *                         payload = {
 *                             "device_type": self.get_os_type_caps(),
 *                             "os_name": self.get_os_type_caps(),             # <<<<<<<<<<<<<<
 *                             "os_version": get_os_version(),
 *                             "device_id": self.system_unique_id,
*/
              __pyx_t_1 = __pyx_cur_scope->__pyx_v_self;
              __Pyx_INCREF(__pyx_t_1);
              __pyx_t_7 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
                __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type_caps, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2287, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_3);
              }
              if (PyDict_SetItem(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_os_name, __pyx_t_3) < (0)) __PYX_ERR(0, 2286, __pyx_L295_error)
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

              /* "ws_package/controllers/activity_controller.py":2288
 *                             "device_type": self.get_os_type_caps(),
 *                             "os_name": self.get_os_type_caps(),
 *                             "os_version": get_os_version(),             # <<<<<<<<<<<<<<
 *                             "device_id": self.system_unique_id,
 *                             "status": 1
*/
              __pyx_t_1 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_get_os_version); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2288, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_34);
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_34))) {
                __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_34);
                assert(__pyx_t_1);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_34);
                __Pyx_INCREF(__pyx_t_1);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_34, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
                __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_34, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2288, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_3);
              }
              if (PyDict_SetItem(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_os_version, __pyx_t_3) < (0)) __PYX_ERR(0, 2286, __pyx_L295_error)
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

              /* "ws_package/controllers/activity_controller.py":2289
 *                             "os_name": self.get_os_type_caps(),
 *                             "os_version": get_os_version(),
 *                             "device_id": self.system_unique_id,             # <<<<<<<<<<<<<<
 *                             "status": 1
 *                         }
*/
              __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_system_unique_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2289, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_3);
              if (PyDict_SetItem(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_device_id, __pyx_t_3) < (0)) __PYX_ERR(0, 2286, __pyx_L295_error)
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              if (PyDict_SetItem(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_status, __pyx_mstate_global->__pyx_int_1) < (0)) __PYX_ERR(0, 2286, __pyx_L295_error)
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_payload);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_payload, ((PyObject*)__pyx_t_33));
              __Pyx_GIVEREF(__pyx_t_33);
              __pyx_t_33 = 0;

              /* "ws_package/controllers/activity_controller.py":2292
 *                             "status": 1
 *                         }
 *                         try:             # <<<<<<<<<<<<<<
 *                             log_testing_request_headers(logger, "POST", url, headers, payload)
 *                             response = requests.post(url, headers=headers, json=payload, timeout=10)
*/
              {
                __Pyx_ExceptionSave(&__pyx_t_18, &__pyx_t_21, &__pyx_t_20);
                __Pyx_XGOTREF(__pyx_t_18);
                __Pyx_XGOTREF(__pyx_t_21);
                __Pyx_XGOTREF(__pyx_t_20);
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":2293
 *                         }
 *                         try:
 *                             log_testing_request_headers(logger, "POST", url, headers, payload)             # <<<<<<<<<<<<<<
 *                             response = requests.post(url, headers=headers, json=payload, timeout=10)
 *                             log_api_response_summary(
*/
                  __pyx_t_3 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_log_testing_request_headers); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2293, __pyx_L312_error)
                  __Pyx_GOTREF(__pyx_t_34);
                  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2293, __pyx_L312_error)
                  __Pyx_GOTREF(__pyx_t_1);
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_34))) {
                    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_34);
                    assert(__pyx_t_3);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_34);
                    __Pyx_INCREF(__pyx_t_3);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_34, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[6] = {__pyx_t_3, __pyx_t_1, __pyx_mstate_global->__pyx_n_u_POST, __pyx_cur_scope->__pyx_v_url, __pyx_cur_scope->__pyx_v_headers, __pyx_cur_scope->__pyx_v_payload};
                    __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_34, __pyx_callargs+__pyx_t_7, (6-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                    if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2293, __pyx_L312_error)
                    __Pyx_GOTREF(__pyx_t_33);
                  }
                  __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

                  /* "ws_package/controllers/activity_controller.py":2294
 *                         try:
 *                             log_testing_request_headers(logger, "POST", url, headers, payload)
 *                             response = requests.post(url, headers=headers, json=payload, timeout=10)             # <<<<<<<<<<<<<<
 *                             log_api_response_summary(
 *                                 logger,
*/
                  __pyx_t_34 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_requests); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2294, __pyx_L312_error)
                  __Pyx_GOTREF(__pyx_t_1);
                  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_post); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2294, __pyx_L312_error)
                  __Pyx_GOTREF(__pyx_t_3);
                  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_3))) {
                    __pyx_t_34 = PyMethod_GET_SELF(__pyx_t_3);
                    assert(__pyx_t_34);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
                    __Pyx_INCREF(__pyx_t_34);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 3 : 0)] = {__pyx_t_34, __pyx_cur_scope->__pyx_v_url};
                    __pyx_t_1 = __Pyx_MakeVectorcallBuilderKwds(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2294, __pyx_L312_error)
                    __Pyx_GOTREF(__pyx_t_1);
                    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_headers, __pyx_cur_scope->__pyx_v_headers, __pyx_t_1, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 2294, __pyx_L312_error)
                    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_json, __pyx_cur_scope->__pyx_v_payload, __pyx_t_1, __pyx_callargs+2, 1) < (0)) __PYX_ERR(0, 2294, __pyx_L312_error)
                    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_timeout, __pyx_mstate_global->__pyx_int_10, __pyx_t_1, __pyx_callargs+2, 2) < (0)) __PYX_ERR(0, 2294, __pyx_L312_error)
                    __pyx_t_33 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_1);
                    __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2294, __pyx_L312_error)
                    __Pyx_GOTREF(__pyx_t_33);
                  }
                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_response);
                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_response, __pyx_t_33);
                  __Pyx_GIVEREF(__pyx_t_33);
                  __pyx_t_33 = 0;

                  /* "ws_package/controllers/activity_controller.py":2295
 *                             log_testing_request_headers(logger, "POST", url, headers, payload)
 *                             response = requests.post(url, headers=headers, json=payload, timeout=10)
 *                             log_api_response_summary(             # <<<<<<<<<<<<<<
 *                                 logger,
 *                                 api_name_from_url(url),
*/
                  __pyx_t_3 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_log_api_response_summary); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2295, __pyx_L312_error)
                  __Pyx_GOTREF(__pyx_t_1);

                  /* "ws_package/controllers/activity_controller.py":2296
 *                             response = requests.post(url, headers=headers, json=payload, timeout=10)
 *                             log_api_response_summary(
 *                                 logger,             # <<<<<<<<<<<<<<
 *                                 api_name_from_url(url),
 *                                 response.status_code,
*/
                  __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2296, __pyx_L312_error)
                  __Pyx_GOTREF(__pyx_t_34);

                  /* "ws_package/controllers/activity_controller.py":2297
 *                             log_api_response_summary(
 *                                 logger,
 *                                 api_name_from_url(url),             # <<<<<<<<<<<<<<
 *                                 response.status_code,
 *                                 response.text,
*/
                  __pyx_t_15 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_api_name_from_url); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2297, __pyx_L312_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_6))) {
                    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_6);
                    assert(__pyx_t_15);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                    __Pyx_INCREF(__pyx_t_15);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_cur_scope->__pyx_v_url};
                    __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2297, __pyx_L312_error)
                    __Pyx_GOTREF(__pyx_t_5);
                  }

                  /* "ws_package/controllers/activity_controller.py":2298
 *                                 logger,
 *                                 api_name_from_url(url),
 *                                 response.status_code,             # <<<<<<<<<<<<<<
 *                                 response.text,
 *                             )
*/
                  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_response, __pyx_mstate_global->__pyx_n_u_status_code); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2298, __pyx_L312_error)
                  __Pyx_GOTREF(__pyx_t_6);

                  /* "ws_package/controllers/activity_controller.py":2299
 *                                 api_name_from_url(url),
 *                                 response.status_code,
 *                                 response.text,             # <<<<<<<<<<<<<<
 *                             )
 *                         except requests.exceptions.Timeout:
*/
                  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_response, __pyx_mstate_global->__pyx_n_u_text); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2299, __pyx_L312_error)
                  __Pyx_GOTREF(__pyx_t_15);
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_1))) {
                    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
                    assert(__pyx_t_3);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
                    __Pyx_INCREF(__pyx_t_3);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[5] = {__pyx_t_3, __pyx_t_34, __pyx_t_5, __pyx_t_6, __pyx_t_15};
                    __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_7, (5-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                    if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2295, __pyx_L312_error)
                    __Pyx_GOTREF(__pyx_t_33);
                  }
                  __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

                  /* "ws_package/controllers/activity_controller.py":2292
 *                             "status": 1
 *                         }
 *                         try:             # <<<<<<<<<<<<<<
 *                             log_testing_request_headers(logger, "POST", url, headers, payload)
 *                             response = requests.post(url, headers=headers, json=payload, timeout=10)
*/
                }
                __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                goto __pyx_L319_try_end;
                __pyx_L312_error:;
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

                /* "ws_package/controllers/activity_controller.py":2301
 *                                 response.text,
 *                             )
 *                         except requests.exceptions.Timeout:             # <<<<<<<<<<<<<<
 *                             logger.error("[API] %s | timeout", api_name_from_url(url))
 *                         except requests.exceptions.RequestException as e:
*/
                __Pyx_ErrFetch(&__pyx_t_33, &__pyx_t_1, &__pyx_t_15);
                __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_requests); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2301, __pyx_L314_except_error)
                __Pyx_GOTREF(__pyx_t_6);
                __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_exceptions); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2301, __pyx_L314_except_error)
                __Pyx_GOTREF(__pyx_t_5);
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_Timeout); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2301, __pyx_L314_except_error)
                __Pyx_GOTREF(__pyx_t_6);
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __pyx_t_14 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_33, __pyx_t_6);
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                __Pyx_ErrRestore(__pyx_t_33, __pyx_t_1, __pyx_t_15);
                __pyx_t_33 = 0; __pyx_t_1 = 0; __pyx_t_15 = 0;
                if (__pyx_t_14) {
                  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
                  if (__Pyx_GetException(&__pyx_t_15, &__pyx_t_1, &__pyx_t_33) < 0) __PYX_ERR(0, 2301, __pyx_L314_except_error)
                  __Pyx_XGOTREF(__pyx_t_15);
                  __Pyx_XGOTREF(__pyx_t_1);
                  __Pyx_XGOTREF(__pyx_t_33);

                  /* "ws_package/controllers/activity_controller.py":2302
 *                             )
 *                         except requests.exceptions.Timeout:
 *                             logger.error("[API] %s | timeout", api_name_from_url(url))             # <<<<<<<<<<<<<<
 *                         except requests.exceptions.RequestException as e:
 *                             logger.error("[API] %s | request failed: %s", api_name_from_url(url), e)
*/
                  __pyx_t_5 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2302, __pyx_L314_except_error)
                  __Pyx_GOTREF(__pyx_t_34);
                  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2302, __pyx_L314_except_error)
                  __Pyx_GOTREF(__pyx_t_3);
                  __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                  __pyx_t_37 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_api_name_from_url); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2302, __pyx_L314_except_error)
                  __Pyx_GOTREF(__pyx_t_4);
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_4))) {
                    __pyx_t_37 = PyMethod_GET_SELF(__pyx_t_4);
                    assert(__pyx_t_37);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                    __Pyx_INCREF(__pyx_t_37);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_37, __pyx_cur_scope->__pyx_v_url};
                    __pyx_t_34 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2302, __pyx_L314_except_error)
                    __Pyx_GOTREF(__pyx_t_34);
                  }
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_3))) {
                    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
                    assert(__pyx_t_5);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
                    __Pyx_INCREF(__pyx_t_5);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_API_s_timeout, __pyx_t_34};
                    __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2302, __pyx_L314_except_error)
                    __Pyx_GOTREF(__pyx_t_6);
                  }
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                  __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                  goto __pyx_L313_exception_handled;
                }

                /* "ws_package/controllers/activity_controller.py":2303
 *                         except requests.exceptions.Timeout:
 *                             logger.error("[API] %s | timeout", api_name_from_url(url))
 *                         except requests.exceptions.RequestException as e:             # <<<<<<<<<<<<<<
 *                             logger.error("[API] %s | request failed: %s", api_name_from_url(url), e)
 * 
*/
                __Pyx_ErrFetch(&__pyx_t_33, &__pyx_t_1, &__pyx_t_15);
                __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_requests); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2303, __pyx_L314_except_error)
                __Pyx_GOTREF(__pyx_t_6);
                __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_exceptions); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2303, __pyx_L314_except_error)
                __Pyx_GOTREF(__pyx_t_3);
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_RequestException); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2303, __pyx_L314_except_error)
                __Pyx_GOTREF(__pyx_t_6);
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                __pyx_t_14 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_33, __pyx_t_6);
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                __Pyx_ErrRestore(__pyx_t_33, __pyx_t_1, __pyx_t_15);
                __pyx_t_33 = 0; __pyx_t_1 = 0; __pyx_t_15 = 0;
                if (__pyx_t_14) {
                  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
                  if (__Pyx_GetException(&__pyx_t_15, &__pyx_t_1, &__pyx_t_33) < 0) __PYX_ERR(0, 2303, __pyx_L314_except_error)
                  __Pyx_XGOTREF(__pyx_t_15);
                  __Pyx_XGOTREF(__pyx_t_1);
                  __Pyx_XGOTREF(__pyx_t_33);
                  __Pyx_INCREF(__pyx_t_1);
                  __Pyx_GIVEREF(__pyx_t_1);
                  __pyx_cur_scope->__pyx_v_e = __pyx_t_1;
                  /*try:*/ {

                    /* "ws_package/controllers/activity_controller.py":2304
 *                             logger.error("[API] %s | timeout", api_name_from_url(url))
 *                         except requests.exceptions.RequestException as e:
 *                             logger.error("[API] %s | request failed: %s", api_name_from_url(url), e)             # <<<<<<<<<<<<<<
 * 
 *                         # Send timezone error message to Electron before stopping
*/
                    __pyx_t_3 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2304, __pyx_L327_error)
                    __Pyx_GOTREF(__pyx_t_34);
                    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2304, __pyx_L327_error)
                    __Pyx_GOTREF(__pyx_t_5);
                    __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                    __pyx_t_4 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_api_name_from_url); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2304, __pyx_L327_error)
                    __Pyx_GOTREF(__pyx_t_37);
                    __pyx_t_7 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_37))) {
                      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_37);
                      assert(__pyx_t_4);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_37);
                      __Pyx_INCREF(__pyx_t_4);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_37, __pyx__function);
                      __pyx_t_7 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_url};
                      __pyx_t_34 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_37, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                      if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2304, __pyx_L327_error)
                      __Pyx_GOTREF(__pyx_t_34);
                    }
                    __pyx_t_7 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_5))) {
                      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
                      assert(__pyx_t_3);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                      __Pyx_INCREF(__pyx_t_3);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                      __pyx_t_7 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[4] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_API_s_request_failed_s, __pyx_t_34, __pyx_cur_scope->__pyx_v_e};
                      __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                      __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2304, __pyx_L327_error)
                      __Pyx_GOTREF(__pyx_t_6);
                    }
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  }

                  /* "ws_package/controllers/activity_controller.py":2303
 *                         except requests.exceptions.Timeout:
 *                             logger.error("[API] %s | timeout", api_name_from_url(url))
 *                         except requests.exceptions.RequestException as e:             # <<<<<<<<<<<<<<
 *                             logger.error("[API] %s | request failed: %s", api_name_from_url(url), e)
 * 
*/
                  /*finally:*/ {
                    /*normal exit:*/{
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                      goto __pyx_L328;
                    }
                    __pyx_L327_error:;
                    /*exception exit:*/{
                      __Pyx_PyThreadState_assign
                      __pyx_t_32 = 0; __pyx_t_22 = 0; __pyx_t_19 = 0; __pyx_t_46 = 0; __pyx_t_47 = 0; __pyx_t_48 = 0;
                      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                      __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                      __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                      __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                      __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                      __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                       __Pyx_ExceptionSwap(&__pyx_t_46, &__pyx_t_47, &__pyx_t_48);
                      if ( unlikely(__Pyx_GetException(&__pyx_t_32, &__pyx_t_22, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_32, &__pyx_t_22, &__pyx_t_19);
                      __Pyx_XGOTREF(__pyx_t_32);
                      __Pyx_XGOTREF(__pyx_t_22);
                      __Pyx_XGOTREF(__pyx_t_19);
                      __Pyx_XGOTREF(__pyx_t_46);
                      __Pyx_XGOTREF(__pyx_t_47);
                      __Pyx_XGOTREF(__pyx_t_48);
                      __pyx_t_14 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_45 = __pyx_filename;
                      {
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                        __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                      }
                      __Pyx_XGIVEREF(__pyx_t_46);
                      __Pyx_XGIVEREF(__pyx_t_47);
                      __Pyx_XGIVEREF(__pyx_t_48);
                      __Pyx_ExceptionReset(__pyx_t_46, __pyx_t_47, __pyx_t_48);
                      __Pyx_XGIVEREF(__pyx_t_32);
                      __Pyx_XGIVEREF(__pyx_t_22);
                      __Pyx_XGIVEREF(__pyx_t_19);
                      __Pyx_ErrRestore(__pyx_t_32, __pyx_t_22, __pyx_t_19);
                      __pyx_t_32 = 0; __pyx_t_22 = 0; __pyx_t_19 = 0; __pyx_t_46 = 0; __pyx_t_47 = 0; __pyx_t_48 = 0;
                      __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_45;
                      goto __pyx_L314_except_error;
                    }
                    __pyx_L328:;
                  }
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                  __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                  goto __pyx_L313_exception_handled;
                }
                goto __pyx_L314_except_error;

                /* "ws_package/controllers/activity_controller.py":2292
 *                             "status": 1
 *                         }
 *                         try:             # <<<<<<<<<<<<<<
 *                             log_testing_request_headers(logger, "POST", url, headers, payload)
 *                             response = requests.post(url, headers=headers, json=payload, timeout=10)
*/
                __pyx_L314_except_error:;
                __Pyx_XGIVEREF(__pyx_t_18);
                __Pyx_XGIVEREF(__pyx_t_21);
                __Pyx_XGIVEREF(__pyx_t_20);
                __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_21, __pyx_t_20);
                goto __pyx_L295_error;
                __pyx_L313_exception_handled:;
                __Pyx_XGIVEREF(__pyx_t_18);
                __Pyx_XGIVEREF(__pyx_t_21);
                __Pyx_XGIVEREF(__pyx_t_20);
                __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_21, __pyx_t_20);
                __pyx_L319_try_end:;
              }

              /* "ws_package/controllers/activity_controller.py":2307
 * 
 *                         # Send timezone error message to Electron before stopping
 *                         try:             # <<<<<<<<<<<<<<
 *                             error_data = {
 *                                 'title': 'Timezone Mismatch Detected',
*/
              {
                __Pyx_ExceptionSave(&__pyx_t_20, &__pyx_t_21, &__pyx_t_18);
                __Pyx_XGOTREF(__pyx_t_20);
                __Pyx_XGOTREF(__pyx_t_21);
                __Pyx_XGOTREF(__pyx_t_18);
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":2309
 *                         try:
 *                             error_data = {
 *                                 'title': 'Timezone Mismatch Detected',             # <<<<<<<<<<<<<<
 *                                 'message': "Your system timezone does not match the organization's configured timezone.\nPlease update your system time settings to continue tracking",
 *                                 'timestamp': datetime.datetime.now().isoformat()
*/
                  __pyx_t_33 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2309, __pyx_L333_error)
                  __Pyx_GOTREF(__pyx_t_33);
                  if (PyDict_SetItem(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_title, __pyx_mstate_global->__pyx_kp_u_Timezone_Mismatch_Detected) < (0)) __PYX_ERR(0, 2309, __pyx_L333_error)
                  if (PyDict_SetItem(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_message, __pyx_mstate_global->__pyx_kp_u_Your_system_timezone_does_not_ma) < (0)) __PYX_ERR(0, 2309, __pyx_L333_error)

                  /* "ws_package/controllers/activity_controller.py":2311
 *                                 'title': 'Timezone Mismatch Detected',
 *                                 'message': "Your system timezone does not match the organization's configured timezone.\nPlease update your system time settings to continue tracking",
 *                                 'timestamp': datetime.datetime.now().isoformat()             # <<<<<<<<<<<<<<
 *                             }
 *                             if self._send_to_electron_if_connected('timezone_error', error_data):
*/
                  __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2311, __pyx_L333_error)
                  __Pyx_GOTREF(__pyx_t_34);
                  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2311, __pyx_L333_error)
                  __Pyx_GOTREF(__pyx_t_3);
                  __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                  __pyx_t_5 = __pyx_t_3;
                  __Pyx_INCREF(__pyx_t_5);
                  __pyx_t_7 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                    __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2311, __pyx_L333_error)
                    __Pyx_GOTREF(__pyx_t_6);
                  }
                  __pyx_t_15 = __pyx_t_6;
                  __Pyx_INCREF(__pyx_t_15);
                  __pyx_t_7 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL};
                    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_isoformat, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2311, __pyx_L333_error)
                    __Pyx_GOTREF(__pyx_t_1);
                  }
                  if (PyDict_SetItem(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_timestamp, __pyx_t_1) < (0)) __PYX_ERR(0, 2309, __pyx_L333_error)
                  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_error_data);
                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_error_data, ((PyObject*)__pyx_t_33));
                  __Pyx_GIVEREF(__pyx_t_33);
                  __pyx_t_33 = 0;

                  /* "ws_package/controllers/activity_controller.py":2313
 *                                 'timestamp': datetime.datetime.now().isoformat()
 *                             }
 *                             if self._send_to_electron_if_connected('timezone_error', error_data):             # <<<<<<<<<<<<<<
 *                                 logger.info("Sent timezone mismatch error to Electron from activity loop: %s", error_data)
 *                                 await precise_sleep(5, stop_event)
*/
                  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self;
                  __Pyx_INCREF(__pyx_t_1);
                  __pyx_t_7 = 0;
                  {
                    PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_mstate_global->__pyx_n_u_timezone_error, __pyx_cur_scope->__pyx_v_error_data};
                    __pyx_t_33 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_send_to_electron_if_connected, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                    if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2313, __pyx_L333_error)
                    __Pyx_GOTREF(__pyx_t_33);
                  }
                  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_33); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2313, __pyx_L333_error)
                  __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                  if (__pyx_t_9) {

                    /* "ws_package/controllers/activity_controller.py":2314
 *                             }
 *                             if self._send_to_electron_if_connected('timezone_error', error_data):
 *                                 logger.info("Sent timezone mismatch error to Electron from activity loop: %s", error_data)             # <<<<<<<<<<<<<<
 *                                 await precise_sleep(5, stop_event)
 *                                 # CRITICAL: Don't call os._exit(1) - keep Python process alive for error recovery
*/
                    __pyx_t_1 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2314, __pyx_L333_error)
                    __Pyx_GOTREF(__pyx_t_6);
                    __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2314, __pyx_L333_error)
                    __Pyx_GOTREF(__pyx_t_15);
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __pyx_t_7 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_15))) {
                      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_15);
                      assert(__pyx_t_1);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                      __Pyx_INCREF(__pyx_t_1);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                      __pyx_t_7 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Sent_timezone_mismatch_error_to, __pyx_cur_scope->__pyx_v_error_data};
                      __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                      if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2314, __pyx_L333_error)
                      __Pyx_GOTREF(__pyx_t_33);
                    }
                    __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

                    /* "ws_package/controllers/activity_controller.py":2315
 *                             if self._send_to_electron_if_connected('timezone_error', error_data):
 *                                 logger.info("Sent timezone mismatch error to Electron from activity loop: %s", error_data)
 *                                 await precise_sleep(5, stop_event)             # <<<<<<<<<<<<<<
 *                                 # CRITICAL: Don't call os._exit(1) - keep Python process alive for error recovery
 *                                 # Electron will handle stopping the timer, but Python should remain running
*/
                    __pyx_t_15 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_precise_sleep); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2315, __pyx_L333_error)
                    __Pyx_GOTREF(__pyx_t_1);
                    __pyx_t_7 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_1))) {
                      __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_1);
                      assert(__pyx_t_15);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
                      __Pyx_INCREF(__pyx_t_15);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
                      __pyx_t_7 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[3] = {__pyx_t_15, __pyx_mstate_global->__pyx_int_5, __pyx_cur_scope->__pyx_v_stop_event};
                      __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                      if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2315, __pyx_L333_error)
                      __Pyx_GOTREF(__pyx_t_33);
                    }
                    __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_33, &__pyx_r);
                    __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                    if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                      __Pyx_GOTREF(__pyx_r);
                      __Pyx_XGIVEREF(__pyx_t_11);
                      __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                      __Pyx_XGIVEREF(__pyx_t_12);
                      __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                      __Pyx_XGIVEREF(__pyx_t_13);
                      __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                      __Pyx_XGIVEREF(__pyx_t_18);
                      __pyx_cur_scope->__pyx_t_3 = __pyx_t_18;
                      __Pyx_XGIVEREF(__pyx_t_20);
                      __pyx_cur_scope->__pyx_t_4 = __pyx_t_20;
                      __Pyx_XGIVEREF(__pyx_t_21);
                      __pyx_cur_scope->__pyx_t_5 = __pyx_t_21;
                      __Pyx_XGIVEREF(__pyx_t_23);
                      __pyx_cur_scope->__pyx_t_6 = __pyx_t_23;
                      __Pyx_XGIVEREF(__pyx_t_31);
                      __pyx_cur_scope->__pyx_t_7 = __pyx_t_31;
                      __Pyx_XGIVEREF(__pyx_t_39);
                      __pyx_cur_scope->__pyx_t_8 = __pyx_t_39;
                      __Pyx_XGIVEREF(__pyx_r);
                      __Pyx_RefNannyFinishContext();
                      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                      /* return from generator, awaiting value */
                      __pyx_generator->resume_label = 22;
                      return __pyx_r;
                      __pyx_L342_resume_from_await:;
                      __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                      __pyx_cur_scope->__pyx_t_0 = 0;
                      __Pyx_XGOTREF(__pyx_t_11);
                      __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                      __pyx_cur_scope->__pyx_t_1 = 0;
                      __Pyx_XGOTREF(__pyx_t_12);
                      __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                      __pyx_cur_scope->__pyx_t_2 = 0;
                      __Pyx_XGOTREF(__pyx_t_13);
                      __pyx_t_18 = __pyx_cur_scope->__pyx_t_3;
                      __pyx_cur_scope->__pyx_t_3 = 0;
                      __Pyx_XGOTREF(__pyx_t_18);
                      __pyx_t_20 = __pyx_cur_scope->__pyx_t_4;
                      __pyx_cur_scope->__pyx_t_4 = 0;
                      __Pyx_XGOTREF(__pyx_t_20);
                      __pyx_t_21 = __pyx_cur_scope->__pyx_t_5;
                      __pyx_cur_scope->__pyx_t_5 = 0;
                      __Pyx_XGOTREF(__pyx_t_21);
                      __pyx_t_23 = __pyx_cur_scope->__pyx_t_6;
                      __pyx_cur_scope->__pyx_t_6 = 0;
                      __Pyx_XGOTREF(__pyx_t_23);
                      __pyx_t_31 = __pyx_cur_scope->__pyx_t_7;
                      __pyx_cur_scope->__pyx_t_7 = 0;
                      __Pyx_XGOTREF(__pyx_t_31);
                      __pyx_t_39 = __pyx_cur_scope->__pyx_t_8;
                      __pyx_cur_scope->__pyx_t_8 = 0;
                      __Pyx_XGOTREF(__pyx_t_39);
                      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2315, __pyx_L333_error)
                    } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                      __Pyx_GOTREF(__pyx_r);
                      __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                    } else {
                      __Pyx_XGOTREF(__pyx_r);
                      __PYX_ERR(0, 2315, __pyx_L333_error)
                    }

                    /* "ws_package/controllers/activity_controller.py":2318
 *                                 # CRITICAL: Don't call os._exit(1) - keep Python process alive for error recovery
 *                                 # Electron will handle stopping the timer, but Python should remain running
 *                                 logger.info("Timezone error sent to Electron - Python process will remain alive (not exiting)")             # <<<<<<<<<<<<<<
 *                         except Exception as e:
 *                             logger.error("Failed to send timezone error to Electron from activity loop: %s", e)
*/
                    __pyx_t_1 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2318, __pyx_L333_error)
                    __Pyx_GOTREF(__pyx_t_15);
                    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2318, __pyx_L333_error)
                    __Pyx_GOTREF(__pyx_t_6);
                    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __pyx_t_7 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_6))) {
                      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
                      assert(__pyx_t_1);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                      __Pyx_INCREF(__pyx_t_1);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                      __pyx_t_7 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Timezone_error_sent_to_Electron};
                      __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                      if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2318, __pyx_L333_error)
                      __Pyx_GOTREF(__pyx_t_33);
                    }
                    __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

                    /* "ws_package/controllers/activity_controller.py":2313
 *                                 'timestamp': datetime.datetime.now().isoformat()
 *                             }
 *                             if self._send_to_electron_if_connected('timezone_error', error_data):             # <<<<<<<<<<<<<<
 *                                 logger.info("Sent timezone mismatch error to Electron from activity loop: %s", error_data)
 *                                 await precise_sleep(5, stop_event)
*/
                  }

                  /* "ws_package/controllers/activity_controller.py":2307
 * 
 *                         # Send timezone error message to Electron before stopping
 *                         try:             # <<<<<<<<<<<<<<
 *                             error_data = {
 *                                 'title': 'Timezone Mismatch Detected',
*/
                }
                __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                goto __pyx_L340_try_end;
                __pyx_L333_error:;
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

                /* "ws_package/controllers/activity_controller.py":2319
 *                                 # Electron will handle stopping the timer, but Python should remain running
 *                                 logger.info("Timezone error sent to Electron - Python process will remain alive (not exiting)")
 *                         except Exception as e:             # <<<<<<<<<<<<<<
 *                             logger.error("Failed to send timezone error to Electron from activity loop: %s", e)
 * 
*/
                __pyx_t_16 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                if (__pyx_t_16) {
                  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
                  if (__Pyx_GetException(&__pyx_t_33, &__pyx_t_6, &__pyx_t_1) < 0) __PYX_ERR(0, 2319, __pyx_L335_except_error)
                  __Pyx_XGOTREF(__pyx_t_33);
                  __Pyx_XGOTREF(__pyx_t_6);
                  __Pyx_XGOTREF(__pyx_t_1);
                  __Pyx_INCREF(__pyx_t_6);
                  __Pyx_GIVEREF(__pyx_t_6);
                  __pyx_cur_scope->__pyx_v_e = __pyx_t_6;
                  /*try:*/ {

                    /* "ws_package/controllers/activity_controller.py":2320
 *                                 logger.info("Timezone error sent to Electron - Python process will remain alive (not exiting)")
 *                         except Exception as e:
 *                             logger.error("Failed to send timezone error to Electron from activity loop: %s", e)             # <<<<<<<<<<<<<<
 * 
 *                         # Mark mismatch so the push loop can react and stop safely
*/
                    __pyx_t_3 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2320, __pyx_L348_error)
                    __Pyx_GOTREF(__pyx_t_5);
                    __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2320, __pyx_L348_error)
                    __Pyx_GOTREF(__pyx_t_34);
                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __pyx_t_7 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_34))) {
                      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_34);
                      assert(__pyx_t_3);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_34);
                      __Pyx_INCREF(__pyx_t_3);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_34, __pyx__function);
                      __pyx_t_7 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Failed_to_send_timezone_error_to, __pyx_cur_scope->__pyx_v_e};
                      __pyx_t_15 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_34, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                      __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                      if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2320, __pyx_L348_error)
                      __Pyx_GOTREF(__pyx_t_15);
                    }
                    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  }

                  /* "ws_package/controllers/activity_controller.py":2319
 *                                 # Electron will handle stopping the timer, but Python should remain running
 *                                 logger.info("Timezone error sent to Electron - Python process will remain alive (not exiting)")
 *                         except Exception as e:             # <<<<<<<<<<<<<<
 *                             logger.error("Failed to send timezone error to Electron from activity loop: %s", e)
 * 
*/
                  /*finally:*/ {
                    /*normal exit:*/{
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                      goto __pyx_L349;
                    }
                    __pyx_L348_error:;
                    /*exception exit:*/{
                      __Pyx_PyThreadState_assign
                      __pyx_t_48 = 0; __pyx_t_47 = 0; __pyx_t_46 = 0; __pyx_t_19 = 0; __pyx_t_22 = 0; __pyx_t_32 = 0;
                      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                      __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                      __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                      __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                      __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                      __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                       __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_22, &__pyx_t_32);
                      if ( unlikely(__Pyx_GetException(&__pyx_t_48, &__pyx_t_47, &__pyx_t_46) < 0)) __Pyx_ErrFetch(&__pyx_t_48, &__pyx_t_47, &__pyx_t_46);
                      __Pyx_XGOTREF(__pyx_t_48);
                      __Pyx_XGOTREF(__pyx_t_47);
                      __Pyx_XGOTREF(__pyx_t_46);
                      __Pyx_XGOTREF(__pyx_t_19);
                      __Pyx_XGOTREF(__pyx_t_22);
                      __Pyx_XGOTREF(__pyx_t_32);
                      __pyx_t_16 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_49 = __pyx_filename;
                      {
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                        __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                      }
                      __Pyx_XGIVEREF(__pyx_t_19);
                      __Pyx_XGIVEREF(__pyx_t_22);
                      __Pyx_XGIVEREF(__pyx_t_32);
                      __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_22, __pyx_t_32);
                      __Pyx_XGIVEREF(__pyx_t_48);
                      __Pyx_XGIVEREF(__pyx_t_47);
                      __Pyx_XGIVEREF(__pyx_t_46);
                      __Pyx_ErrRestore(__pyx_t_48, __pyx_t_47, __pyx_t_46);
                      __pyx_t_48 = 0; __pyx_t_47 = 0; __pyx_t_46 = 0; __pyx_t_19 = 0; __pyx_t_22 = 0; __pyx_t_32 = 0;
                      __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_49;
                      goto __pyx_L335_except_error;
                    }
                    __pyx_L349:;
                  }
                  __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                  goto __pyx_L334_exception_handled;
                }
                goto __pyx_L335_except_error;

                /* "ws_package/controllers/activity_controller.py":2307
 * 
 *                         # Send timezone error message to Electron before stopping
 *                         try:             # <<<<<<<<<<<<<<
 *                             error_data = {
 *                                 'title': 'Timezone Mismatch Detected',
*/
                __pyx_L335_except_error:;
                __Pyx_XGIVEREF(__pyx_t_20);
                __Pyx_XGIVEREF(__pyx_t_21);
                __Pyx_XGIVEREF(__pyx_t_18);
                __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_18);
                goto __pyx_L295_error;
                __pyx_L334_exception_handled:;
                __Pyx_XGIVEREF(__pyx_t_20);
                __Pyx_XGIVEREF(__pyx_t_21);
                __Pyx_XGIVEREF(__pyx_t_18);
                __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_18);
                __pyx_L340_try_end:;
              }

              /* "ws_package/controllers/activity_controller.py":2323
 * 
 *                         # Mark mismatch so the push loop can react and stop safely
 *                         logger.error("Timezone mismatch detected in activity loop - stopping tracker")             # <<<<<<<<<<<<<<
 *                         self._timezone_mismatch = True
 *                         self._time_error_type = "timezone_error"
*/
              __pyx_t_6 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2323, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_33);
              __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2323, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_15);
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_15))) {
                __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_15);
                assert(__pyx_t_6);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                __Pyx_INCREF(__pyx_t_6);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Timezone_mismatch_detected_in_ac};
                __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2323, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_1);
              }
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

              /* "ws_package/controllers/activity_controller.py":2324
 *                         # Mark mismatch so the push loop can react and stop safely
 *                         logger.error("Timezone mismatch detected in activity loop - stopping tracker")
 *                         self._timezone_mismatch = True             # <<<<<<<<<<<<<<
 *                         self._time_error_type = "timezone_error"
 *                         self.force_stop = True
*/
              if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_timezone_mismatch, Py_True) < (0)) __PYX_ERR(0, 2324, __pyx_L295_error)

              /* "ws_package/controllers/activity_controller.py":2325
 *                         logger.error("Timezone mismatch detected in activity loop - stopping tracker")
 *                         self._timezone_mismatch = True
 *                         self._time_error_type = "timezone_error"             # <<<<<<<<<<<<<<
 *                         self.force_stop = True
 *                         # CRITICAL: Don't call os._exit(1) - keep Python process alive for error recovery
*/
              if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_time_error_type, __pyx_mstate_global->__pyx_n_u_timezone_error) < (0)) __PYX_ERR(0, 2325, __pyx_L295_error)

              /* "ws_package/controllers/activity_controller.py":2326
 *                         self._timezone_mismatch = True
 *                         self._time_error_type = "timezone_error"
 *                         self.force_stop = True             # <<<<<<<<<<<<<<
 *                         # CRITICAL: Don't call os._exit(1) - keep Python process alive for error recovery
 *                         logger.info("Python process will remain alive - monitoring stopped but process continues running")
*/
              if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_force_stop, Py_True) < (0)) __PYX_ERR(0, 2326, __pyx_L295_error)

              /* "ws_package/controllers/activity_controller.py":2328
 *                         self.force_stop = True
 *                         # CRITICAL: Don't call os._exit(1) - keep Python process alive for error recovery
 *                         logger.info("Python process will remain alive - monitoring stopped but process continues running")             # <<<<<<<<<<<<<<
 *                     elif user_entity is None:
 *                         logger.warning("Skipping timecheck: user_entity is None")
*/
              __pyx_t_15 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2328, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_6);
              __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2328, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_33);
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_33))) {
                __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_33);
                assert(__pyx_t_15);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
                __Pyx_INCREF(__pyx_t_15);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Python_process_will_remain_alive};
                __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2328, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_1);
              }
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

              /* "ws_package/controllers/activity_controller.py":2264
 *                                 user_entity, stop_event
 *                             )
 *                     if user_entity is not None and timecheck_failed:             # <<<<<<<<<<<<<<
 *                         logger.info("Time mismatch under activity")
 *                         active_app_url = [{
*/
              goto __pyx_L308;
            }

            /* "ws_package/controllers/activity_controller.py":2329
 *                         # CRITICAL: Don't call os._exit(1) - keep Python process alive for error recovery
 *                         logger.info("Python process will remain alive - monitoring stopped but process continues running")
 *                     elif user_entity is None:             # <<<<<<<<<<<<<<
 *                         logger.warning("Skipping timecheck: user_entity is None")
 *                         payload = {
*/
            __pyx_t_9 = (__pyx_cur_scope->__pyx_v_user_entity == Py_None);
            if (__pyx_t_9) {

              /* "ws_package/controllers/activity_controller.py":2330
 *                         logger.info("Python process will remain alive - monitoring stopped but process continues running")
 *                     elif user_entity is None:
 *                         logger.warning("Skipping timecheck: user_entity is None")             # <<<<<<<<<<<<<<
 *                         payload = {
 *                             "device_type": self.get_os_type_caps(),
*/
              __pyx_t_33 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2330, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_15);
              __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2330, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_6);
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_6))) {
                __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_6);
                assert(__pyx_t_33);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                __Pyx_INCREF(__pyx_t_33);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_33, __pyx_mstate_global->__pyx_kp_u_Skipping_timecheck_user_entity_i};
                __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2330, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_1);
              }
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

              /* "ws_package/controllers/activity_controller.py":2332
 *                         logger.warning("Skipping timecheck: user_entity is None")
 *                         payload = {
 *                             "device_type": self.get_os_type_caps(),             # <<<<<<<<<<<<<<
 *                             "os_name": self.get_os_type_caps(),
 *                             "os_version": get_os_version(),
*/
              __pyx_t_1 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2332, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_t_33 = __pyx_cur_scope->__pyx_v_self;
              __Pyx_INCREF(__pyx_t_33);
              __pyx_t_7 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_33, NULL};
                __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type_caps, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2332, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_6);
              }
              if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_device_type, __pyx_t_6) < (0)) __PYX_ERR(0, 2332, __pyx_L295_error)
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

              /* "ws_package/controllers/activity_controller.py":2333
 *                         payload = {
 *                             "device_type": self.get_os_type_caps(),
 *                             "os_name": self.get_os_type_caps(),             # <<<<<<<<<<<<<<
 *                             "os_version": get_os_version(),
 *                             "device_id": self.system_unique_id,
*/
              __pyx_t_33 = __pyx_cur_scope->__pyx_v_self;
              __Pyx_INCREF(__pyx_t_33);
              __pyx_t_7 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_33, NULL};
                __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type_caps, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2333, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_6);
              }
              if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_os_name, __pyx_t_6) < (0)) __PYX_ERR(0, 2332, __pyx_L295_error)
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

              /* "ws_package/controllers/activity_controller.py":2334
 *                             "device_type": self.get_os_type_caps(),
 *                             "os_name": self.get_os_type_caps(),
 *                             "os_version": get_os_version(),             # <<<<<<<<<<<<<<
 *                             "device_id": self.system_unique_id,
 *                             "status": 1
*/
              __pyx_t_33 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_get_os_version); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2334, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_15);
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_15))) {
                __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_15);
                assert(__pyx_t_33);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                __Pyx_INCREF(__pyx_t_33);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_33, NULL};
                __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2334, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_6);
              }
              if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_os_version, __pyx_t_6) < (0)) __PYX_ERR(0, 2332, __pyx_L295_error)
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

              /* "ws_package/controllers/activity_controller.py":2335
 *                             "os_name": self.get_os_type_caps(),
 *                             "os_version": get_os_version(),
 *                             "device_id": self.system_unique_id,             # <<<<<<<<<<<<<<
 *                             "status": 1
 *                         }
*/
              __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_system_unique_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2335, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_6);
              if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_device_id, __pyx_t_6) < (0)) __PYX_ERR(0, 2332, __pyx_L295_error)
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_status, __pyx_mstate_global->__pyx_int_1) < (0)) __PYX_ERR(0, 2332, __pyx_L295_error)
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_payload);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_payload, ((PyObject*)__pyx_t_1));
              __Pyx_GIVEREF(__pyx_t_1);
              __pyx_t_1 = 0;

              /* "ws_package/controllers/activity_controller.py":2338
 *                             "status": 1
 *                         }
 *                         try:             # <<<<<<<<<<<<<<
 *                             headers = apply_desktop_key(headers)
 *                             log_testing_request_headers(logger, "POST", url, headers, payload)
*/
              {
                __Pyx_ExceptionSave(&__pyx_t_18, &__pyx_t_21, &__pyx_t_20);
                __Pyx_XGOTREF(__pyx_t_18);
                __Pyx_XGOTREF(__pyx_t_21);
                __Pyx_XGOTREF(__pyx_t_20);
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":2339
 *                         }
 *                         try:
 *                             headers = apply_desktop_key(headers)             # <<<<<<<<<<<<<<
 *                             log_testing_request_headers(logger, "POST", url, headers, payload)
 *                             response = requests.post(url, headers=headers, json=payload, timeout=10)
*/
                  __pyx_t_6 = NULL;
                  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_apply_desktop_key);
                  __pyx_t_15 = __pyx_cur_scope->__pyx_v_apply_desktop_key; 
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_15))) {
                    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_15);
                    assert(__pyx_t_6);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                    __Pyx_INCREF(__pyx_t_6);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_cur_scope->__pyx_v_headers};
                    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2339, __pyx_L354_error)
                    __Pyx_GOTREF(__pyx_t_1);
                  }
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_headers);
                  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_headers, __pyx_t_1);
                  __Pyx_GIVEREF(__pyx_t_1);
                  __pyx_t_1 = 0;

                  /* "ws_package/controllers/activity_controller.py":2340
 *                         try:
 *                             headers = apply_desktop_key(headers)
 *                             log_testing_request_headers(logger, "POST", url, headers, payload)             # <<<<<<<<<<<<<<
 *                             response = requests.post(url, headers=headers, json=payload, timeout=10)
 *                             log_api_response_summary(
*/
                  __pyx_t_15 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_log_testing_request_headers); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2340, __pyx_L354_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2340, __pyx_L354_error)
                  __Pyx_GOTREF(__pyx_t_33);
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_6))) {
                    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_6);
                    assert(__pyx_t_15);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                    __Pyx_INCREF(__pyx_t_15);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[6] = {__pyx_t_15, __pyx_t_33, __pyx_mstate_global->__pyx_n_u_POST, __pyx_cur_scope->__pyx_v_url, __pyx_cur_scope->__pyx_v_headers, __pyx_cur_scope->__pyx_v_payload};
                    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (6-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2340, __pyx_L354_error)
                    __Pyx_GOTREF(__pyx_t_1);
                  }
                  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

                  /* "ws_package/controllers/activity_controller.py":2341
 *                             headers = apply_desktop_key(headers)
 *                             log_testing_request_headers(logger, "POST", url, headers, payload)
 *                             response = requests.post(url, headers=headers, json=payload, timeout=10)             # <<<<<<<<<<<<<<
 *                             log_api_response_summary(
 *                                 logger,
*/
                  __pyx_t_6 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_requests); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2341, __pyx_L354_error)
                  __Pyx_GOTREF(__pyx_t_33);
                  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_post); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2341, __pyx_L354_error)
                  __Pyx_GOTREF(__pyx_t_15);
                  __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_15))) {
                    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_15);
                    assert(__pyx_t_6);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                    __Pyx_INCREF(__pyx_t_6);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 3 : 0)] = {__pyx_t_6, __pyx_cur_scope->__pyx_v_url};
                    __pyx_t_33 = __Pyx_MakeVectorcallBuilderKwds(3); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2341, __pyx_L354_error)
                    __Pyx_GOTREF(__pyx_t_33);
                    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_headers, __pyx_cur_scope->__pyx_v_headers, __pyx_t_33, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 2341, __pyx_L354_error)
                    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_json, __pyx_cur_scope->__pyx_v_payload, __pyx_t_33, __pyx_callargs+2, 1) < (0)) __PYX_ERR(0, 2341, __pyx_L354_error)
                    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_timeout, __pyx_mstate_global->__pyx_int_10, __pyx_t_33, __pyx_callargs+2, 2) < (0)) __PYX_ERR(0, 2341, __pyx_L354_error)
                    __pyx_t_1 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_33);
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2341, __pyx_L354_error)
                    __Pyx_GOTREF(__pyx_t_1);
                  }
                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_response);
                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_response, __pyx_t_1);
                  __Pyx_GIVEREF(__pyx_t_1);
                  __pyx_t_1 = 0;

                  /* "ws_package/controllers/activity_controller.py":2342
 *                             log_testing_request_headers(logger, "POST", url, headers, payload)
 *                             response = requests.post(url, headers=headers, json=payload, timeout=10)
 *                             log_api_response_summary(             # <<<<<<<<<<<<<<
 *                                 logger,
 *                                 api_name_from_url(url),
*/
                  __pyx_t_15 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_log_api_response_summary); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2342, __pyx_L354_error)
                  __Pyx_GOTREF(__pyx_t_33);

                  /* "ws_package/controllers/activity_controller.py":2343
 *                             response = requests.post(url, headers=headers, json=payload, timeout=10)
 *                             log_api_response_summary(
 *                                 logger,             # <<<<<<<<<<<<<<
 *                                 api_name_from_url(url),
 *                                 response.status_code,
*/
                  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2343, __pyx_L354_error)
                  __Pyx_GOTREF(__pyx_t_6);

                  /* "ws_package/controllers/activity_controller.py":2344
 *                             log_api_response_summary(
 *                                 logger,
 *                                 api_name_from_url(url),             # <<<<<<<<<<<<<<
 *                                 response.status_code,
 *                                 response.text,
*/
                  __pyx_t_3 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_api_name_from_url); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2344, __pyx_L354_error)
                  __Pyx_GOTREF(__pyx_t_5);
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_5))) {
                    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
                    assert(__pyx_t_3);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                    __Pyx_INCREF(__pyx_t_3);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_url};
                    __pyx_t_34 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                    if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2344, __pyx_L354_error)
                    __Pyx_GOTREF(__pyx_t_34);
                  }

                  /* "ws_package/controllers/activity_controller.py":2345
 *                                 logger,
 *                                 api_name_from_url(url),
 *                                 response.status_code,             # <<<<<<<<<<<<<<
 *                                 response.text,
 *                             )
*/
                  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_response, __pyx_mstate_global->__pyx_n_u_status_code); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2345, __pyx_L354_error)
                  __Pyx_GOTREF(__pyx_t_5);

                  /* "ws_package/controllers/activity_controller.py":2346
 *                                 api_name_from_url(url),
 *                                 response.status_code,
 *                                 response.text,             # <<<<<<<<<<<<<<
 *                             )
 *                         except requests.exceptions.Timeout:
*/
                  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_response, __pyx_mstate_global->__pyx_n_u_text); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2346, __pyx_L354_error)
                  __Pyx_GOTREF(__pyx_t_3);
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_33))) {
                    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_33);
                    assert(__pyx_t_15);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
                    __Pyx_INCREF(__pyx_t_15);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[5] = {__pyx_t_15, __pyx_t_6, __pyx_t_34, __pyx_t_5, __pyx_t_3};
                    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_7, (5-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2342, __pyx_L354_error)
                    __Pyx_GOTREF(__pyx_t_1);
                  }
                  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

                  /* "ws_package/controllers/activity_controller.py":2338
 *                             "status": 1
 *                         }
 *                         try:             # <<<<<<<<<<<<<<
 *                             headers = apply_desktop_key(headers)
 *                             log_testing_request_headers(logger, "POST", url, headers, payload)
*/
                }
                __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                goto __pyx_L361_try_end;
                __pyx_L354_error:;
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

                /* "ws_package/controllers/activity_controller.py":2348
 *                                 response.text,
 *                             )
 *                         except requests.exceptions.Timeout:             # <<<<<<<<<<<<<<
 *                             logger.error("[API] %s | timeout", api_name_from_url(url))
 *                         except requests.exceptions.RequestException as e:
*/
                __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_33, &__pyx_t_3);
                __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_requests); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2348, __pyx_L356_except_error)
                __Pyx_GOTREF(__pyx_t_5);
                __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_exceptions); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2348, __pyx_L356_except_error)
                __Pyx_GOTREF(__pyx_t_34);
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_Timeout); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2348, __pyx_L356_except_error)
                __Pyx_GOTREF(__pyx_t_5);
                __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                __pyx_t_14 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_5);
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_ErrRestore(__pyx_t_1, __pyx_t_33, __pyx_t_3);
                __pyx_t_1 = 0; __pyx_t_33 = 0; __pyx_t_3 = 0;
                if (__pyx_t_14) {
                  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
                  if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_33, &__pyx_t_1) < 0) __PYX_ERR(0, 2348, __pyx_L356_except_error)
                  __Pyx_XGOTREF(__pyx_t_3);
                  __Pyx_XGOTREF(__pyx_t_33);
                  __Pyx_XGOTREF(__pyx_t_1);

                  /* "ws_package/controllers/activity_controller.py":2349
 *                             )
 *                         except requests.exceptions.Timeout:
 *                             logger.error("[API] %s | timeout", api_name_from_url(url))             # <<<<<<<<<<<<<<
 *                         except requests.exceptions.RequestException as e:
 *                             logger.error("[API] %s | request failed: %s", api_name_from_url(url), e)
*/
                  __pyx_t_34 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2349, __pyx_L356_except_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2349, __pyx_L356_except_error)
                  __Pyx_GOTREF(__pyx_t_15);
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __pyx_t_37 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_api_name_from_url); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2349, __pyx_L356_except_error)
                  __Pyx_GOTREF(__pyx_t_4);
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_4))) {
                    __pyx_t_37 = PyMethod_GET_SELF(__pyx_t_4);
                    assert(__pyx_t_37);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                    __Pyx_INCREF(__pyx_t_37);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_37, __pyx_cur_scope->__pyx_v_url};
                    __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2349, __pyx_L356_except_error)
                    __Pyx_GOTREF(__pyx_t_6);
                  }
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_15))) {
                    __pyx_t_34 = PyMethod_GET_SELF(__pyx_t_15);
                    assert(__pyx_t_34);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                    __Pyx_INCREF(__pyx_t_34);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[3] = {__pyx_t_34, __pyx_mstate_global->__pyx_kp_u_API_s_timeout, __pyx_t_6};
                    __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2349, __pyx_L356_except_error)
                    __Pyx_GOTREF(__pyx_t_5);
                  }
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                  goto __pyx_L355_exception_handled;
                }

                /* "ws_package/controllers/activity_controller.py":2350
 *                         except requests.exceptions.Timeout:
 *                             logger.error("[API] %s | timeout", api_name_from_url(url))
 *                         except requests.exceptions.RequestException as e:             # <<<<<<<<<<<<<<
 *                             logger.error("[API] %s | request failed: %s", api_name_from_url(url), e)
 * 
*/
                __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_33, &__pyx_t_3);
                __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_requests); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2350, __pyx_L356_except_error)
                __Pyx_GOTREF(__pyx_t_5);
                __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_exceptions); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2350, __pyx_L356_except_error)
                __Pyx_GOTREF(__pyx_t_15);
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_RequestException); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2350, __pyx_L356_except_error)
                __Pyx_GOTREF(__pyx_t_5);
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                __pyx_t_14 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_5);
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_ErrRestore(__pyx_t_1, __pyx_t_33, __pyx_t_3);
                __pyx_t_1 = 0; __pyx_t_33 = 0; __pyx_t_3 = 0;
                if (__pyx_t_14) {
                  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
                  if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_33, &__pyx_t_1) < 0) __PYX_ERR(0, 2350, __pyx_L356_except_error)
                  __Pyx_XGOTREF(__pyx_t_3);
                  __Pyx_XGOTREF(__pyx_t_33);
                  __Pyx_XGOTREF(__pyx_t_1);
                  __Pyx_INCREF(__pyx_t_33);
                  __Pyx_GIVEREF(__pyx_t_33);
                  __pyx_cur_scope->__pyx_v_e = __pyx_t_33;
                  /*try:*/ {

                    /* "ws_package/controllers/activity_controller.py":2351
 *                             logger.error("[API] %s | timeout", api_name_from_url(url))
 *                         except requests.exceptions.RequestException as e:
 *                             logger.error("[API] %s | request failed: %s", api_name_from_url(url), e)             # <<<<<<<<<<<<<<
 * 
 *                         logger.error("User entity is None - stopping tracker")
*/
                    __pyx_t_15 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2351, __pyx_L369_error)
                    __Pyx_GOTREF(__pyx_t_6);
                    __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2351, __pyx_L369_error)
                    __Pyx_GOTREF(__pyx_t_34);
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __pyx_t_4 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_api_name_from_url); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2351, __pyx_L369_error)
                    __Pyx_GOTREF(__pyx_t_37);
                    __pyx_t_7 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_37))) {
                      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_37);
                      assert(__pyx_t_4);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_37);
                      __Pyx_INCREF(__pyx_t_4);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_37, __pyx__function);
                      __pyx_t_7 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_url};
                      __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_37, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2351, __pyx_L369_error)
                      __Pyx_GOTREF(__pyx_t_6);
                    }
                    __pyx_t_7 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_34))) {
                      __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_34);
                      assert(__pyx_t_15);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_34);
                      __Pyx_INCREF(__pyx_t_15);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_34, __pyx__function);
                      __pyx_t_7 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[4] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_API_s_request_failed_s, __pyx_t_6, __pyx_cur_scope->__pyx_v_e};
                      __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_34, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                      __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2351, __pyx_L369_error)
                      __Pyx_GOTREF(__pyx_t_5);
                    }
                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  }

                  /* "ws_package/controllers/activity_controller.py":2350
 *                         except requests.exceptions.Timeout:
 *                             logger.error("[API] %s | timeout", api_name_from_url(url))
 *                         except requests.exceptions.RequestException as e:             # <<<<<<<<<<<<<<
 *                             logger.error("[API] %s | request failed: %s", api_name_from_url(url), e)
 * 
*/
                  /*finally:*/ {
                    /*normal exit:*/{
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                      goto __pyx_L370;
                    }
                    __pyx_L369_error:;
                    /*exception exit:*/{
                      __Pyx_PyThreadState_assign
                      __pyx_t_32 = 0; __pyx_t_22 = 0; __pyx_t_19 = 0; __pyx_t_46 = 0; __pyx_t_47 = 0; __pyx_t_48 = 0;
                      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                      __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                      __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                      __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                      __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                      __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                       __Pyx_ExceptionSwap(&__pyx_t_46, &__pyx_t_47, &__pyx_t_48);
                      if ( unlikely(__Pyx_GetException(&__pyx_t_32, &__pyx_t_22, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_32, &__pyx_t_22, &__pyx_t_19);
                      __Pyx_XGOTREF(__pyx_t_32);
                      __Pyx_XGOTREF(__pyx_t_22);
                      __Pyx_XGOTREF(__pyx_t_19);
                      __Pyx_XGOTREF(__pyx_t_46);
                      __Pyx_XGOTREF(__pyx_t_47);
                      __Pyx_XGOTREF(__pyx_t_48);
                      __pyx_t_14 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_50 = __pyx_filename;
                      {
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                        __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                      }
                      __Pyx_XGIVEREF(__pyx_t_46);
                      __Pyx_XGIVEREF(__pyx_t_47);
                      __Pyx_XGIVEREF(__pyx_t_48);
                      __Pyx_ExceptionReset(__pyx_t_46, __pyx_t_47, __pyx_t_48);
                      __Pyx_XGIVEREF(__pyx_t_32);
                      __Pyx_XGIVEREF(__pyx_t_22);
                      __Pyx_XGIVEREF(__pyx_t_19);
                      __Pyx_ErrRestore(__pyx_t_32, __pyx_t_22, __pyx_t_19);
                      __pyx_t_32 = 0; __pyx_t_22 = 0; __pyx_t_19 = 0; __pyx_t_46 = 0; __pyx_t_47 = 0; __pyx_t_48 = 0;
                      __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_50;
                      goto __pyx_L356_except_error;
                    }
                    __pyx_L370:;
                  }
                  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                  goto __pyx_L355_exception_handled;
                }
                goto __pyx_L356_except_error;

                /* "ws_package/controllers/activity_controller.py":2338
 *                             "status": 1
 *                         }
 *                         try:             # <<<<<<<<<<<<<<
 *                             headers = apply_desktop_key(headers)
 *                             log_testing_request_headers(logger, "POST", url, headers, payload)
*/
                __pyx_L356_except_error:;
                __Pyx_XGIVEREF(__pyx_t_18);
                __Pyx_XGIVEREF(__pyx_t_21);
                __Pyx_XGIVEREF(__pyx_t_20);
                __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_21, __pyx_t_20);
                goto __pyx_L295_error;
                __pyx_L355_exception_handled:;
                __Pyx_XGIVEREF(__pyx_t_18);
                __Pyx_XGIVEREF(__pyx_t_21);
                __Pyx_XGIVEREF(__pyx_t_20);
                __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_21, __pyx_t_20);
                __pyx_L361_try_end:;
              }

              /* "ws_package/controllers/activity_controller.py":2353
 *                             logger.error("[API] %s | request failed: %s", api_name_from_url(url), e)
 * 
 *                         logger.error("User entity is None - stopping tracker")             # <<<<<<<<<<<<<<
 *                         self._datetime_mismatch = True
 *                         self._time_error_type = "datetime_error"
*/
              __pyx_t_33 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2353, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2353, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_5))) {
                __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_5);
                assert(__pyx_t_33);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                __Pyx_INCREF(__pyx_t_33);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_33, __pyx_mstate_global->__pyx_kp_u_User_entity_is_None_stopping_tra};
                __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2353, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_1);
              }
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

              /* "ws_package/controllers/activity_controller.py":2354
 * 
 *                         logger.error("User entity is None - stopping tracker")
 *                         self._datetime_mismatch = True             # <<<<<<<<<<<<<<
 *                         self._time_error_type = "datetime_error"
 *                         self.force_stop = True
*/
              if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_datetime_mismatch, Py_True) < (0)) __PYX_ERR(0, 2354, __pyx_L295_error)

              /* "ws_package/controllers/activity_controller.py":2355
 *                         logger.error("User entity is None - stopping tracker")
 *                         self._datetime_mismatch = True
 *                         self._time_error_type = "datetime_error"             # <<<<<<<<<<<<<<
 *                         self.force_stop = True
 *                         # Don't call os._exit(1) - let the monitoring loop handle graceful shutdown
*/
              if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_time_error_type, __pyx_mstate_global->__pyx_n_u_datetime_error) < (0)) __PYX_ERR(0, 2355, __pyx_L295_error)

              /* "ws_package/controllers/activity_controller.py":2356
 *                         self._datetime_mismatch = True
 *                         self._time_error_type = "datetime_error"
 *                         self.force_stop = True             # <<<<<<<<<<<<<<
 *                         # Don't call os._exit(1) - let the monitoring loop handle graceful shutdown
 *                     else:
*/
              if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_force_stop, Py_True) < (0)) __PYX_ERR(0, 2356, __pyx_L295_error)

              /* "ws_package/controllers/activity_controller.py":2329
 *                         # CRITICAL: Don't call os._exit(1) - keep Python process alive for error recovery
 *                         logger.info("Python process will remain alive - monitoring stopped but process continues running")
 *                     elif user_entity is None:             # <<<<<<<<<<<<<<
 *                         logger.warning("Skipping timecheck: user_entity is None")
 *                         payload = {
*/
              goto __pyx_L308;
            }

            /* "ws_package/controllers/activity_controller.py":2359
 *                         # Don't call os._exit(1) - let the monitoring loop handle graceful shutdown
 *                     else:
 *                         logger.info("Timezone and Time matched successfully")             # <<<<<<<<<<<<<<
 *                 except Exception as e:
 *                     logger.error("No Connection for timestamp and update interval %s", e)
*/
            /*else*/ {
              __pyx_t_5 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2359, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_33);
              __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2359, __pyx_L295_error)
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_3))) {
                __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
                assert(__pyx_t_5);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
                __Pyx_INCREF(__pyx_t_5);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Timezone_and_Time_matched_succes};
                __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2359, __pyx_L295_error)
                __Pyx_GOTREF(__pyx_t_1);
              }
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            }
            __pyx_L308:;

            /* "ws_package/controllers/activity_controller.py":2239
 *                 logger.info(">>"*100)
 *                 # time/timezone check (skipped when timezone_preference=1)
 *                 try:             # <<<<<<<<<<<<<<
 *                     from ws_package.utils.desktop_key import apply_desktop_key
 *                     url = ""
*/
          }
          __Pyx_XDECREF(__pyx_t_31); __pyx_t_31 = 0;
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
          goto __pyx_L302_try_end;
          __pyx_L295_error:;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
          __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
          __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
          __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
          __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
          __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

          /* "ws_package/controllers/activity_controller.py":2360
 *                     else:
 *                         logger.info("Timezone and Time matched successfully")
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("No Connection for timestamp and update interval %s", e)
 * 
*/
          __pyx_t_16 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
          if (__pyx_t_16) {
            __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_5) < 0) __PYX_ERR(0, 2360, __pyx_L297_except_error)
            __Pyx_XGOTREF(__pyx_t_1);
            __Pyx_XGOTREF(__pyx_t_3);
            __Pyx_XGOTREF(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_3);
            __Pyx_GIVEREF(__pyx_t_3);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":2361
 *                         logger.info("Timezone and Time matched successfully")
 *                 except Exception as e:
 *                     logger.error("No Connection for timestamp and update interval %s", e)             # <<<<<<<<<<<<<<
 * 
 * 
*/
              __pyx_t_34 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2361, __pyx_L380_error)
              __Pyx_GOTREF(__pyx_t_6);
              __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2361, __pyx_L380_error)
              __Pyx_GOTREF(__pyx_t_15);
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_15))) {
                __pyx_t_34 = PyMethod_GET_SELF(__pyx_t_15);
                assert(__pyx_t_34);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                __Pyx_INCREF(__pyx_t_34);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_34, __pyx_mstate_global->__pyx_kp_u_No_Connection_for_timestamp_and, __pyx_cur_scope->__pyx_v_e};
                __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2361, __pyx_L380_error)
                __Pyx_GOTREF(__pyx_t_33);
              }
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
            }

            /* "ws_package/controllers/activity_controller.py":2360
 *                     else:
 *                         logger.info("Timezone and Time matched successfully")
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("No Connection for timestamp and update interval %s", e)
 * 
*/
            /*finally:*/ {
              /*normal exit:*/{
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                goto __pyx_L381;
              }
              __pyx_L380_error:;
              /*exception exit:*/{
                __Pyx_PyThreadState_assign
                __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_18 = 0; __pyx_t_48 = 0; __pyx_t_47 = 0; __pyx_t_46 = 0;
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                 __Pyx_ExceptionSwap(&__pyx_t_48, &__pyx_t_47, &__pyx_t_46);
                if ( unlikely(__Pyx_GetException(&__pyx_t_20, &__pyx_t_21, &__pyx_t_18) < 0)) __Pyx_ErrFetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_18);
                __Pyx_XGOTREF(__pyx_t_20);
                __Pyx_XGOTREF(__pyx_t_21);
                __Pyx_XGOTREF(__pyx_t_18);
                __Pyx_XGOTREF(__pyx_t_48);
                __Pyx_XGOTREF(__pyx_t_47);
                __Pyx_XGOTREF(__pyx_t_46);
                __pyx_t_16 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_51 = __pyx_filename;
                {
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                }
                __Pyx_XGIVEREF(__pyx_t_48);
                __Pyx_XGIVEREF(__pyx_t_47);
                __Pyx_XGIVEREF(__pyx_t_46);
                __Pyx_ExceptionReset(__pyx_t_48, __pyx_t_47, __pyx_t_46);
                __Pyx_XGIVEREF(__pyx_t_20);
                __Pyx_XGIVEREF(__pyx_t_21);
                __Pyx_XGIVEREF(__pyx_t_18);
                __Pyx_ErrRestore(__pyx_t_20, __pyx_t_21, __pyx_t_18);
                __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_18 = 0; __pyx_t_48 = 0; __pyx_t_47 = 0; __pyx_t_46 = 0;
                __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_51;
                goto __pyx_L297_except_error;
              }
              __pyx_L381:;
            }
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            goto __pyx_L296_exception_handled;
          }
          goto __pyx_L297_except_error;

          /* "ws_package/controllers/activity_controller.py":2239
 *                 logger.info(">>"*100)
 *                 # time/timezone check (skipped when timezone_preference=1)
 *                 try:             # <<<<<<<<<<<<<<
 *                     from ws_package.utils.desktop_key import apply_desktop_key
 *                     url = ""
*/
          __pyx_L297_except_error:;
          __Pyx_XGIVEREF(__pyx_t_31);
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_XGIVEREF(__pyx_t_39);
          __Pyx_ExceptionReset(__pyx_t_31, __pyx_t_23, __pyx_t_39);
          goto __pyx_L263_error;
          __pyx_L296_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_31);
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_XGIVEREF(__pyx_t_39);
          __Pyx_ExceptionReset(__pyx_t_31, __pyx_t_23, __pyx_t_39);
          __pyx_L302_try_end:;
        }

        /* "ws_package/controllers/activity_controller.py":2365
 * 
 *                 # logger.info(f"Adjusted timestamps - start: {start_date}, end: {end_date}")
 *                 activity_percentage_start = await self.getCurrentSlot()             # <<<<<<<<<<<<<<
 *                 activity_percentage_end = activity_percentage_start + datetime.timedelta(minutes=int(self.interval/60))
 * 
*/
        __pyx_t_3 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_7 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_getCurrentSlot, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2365, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (likely(__pyx_t_26 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_11);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
          __Pyx_XGIVEREF(__pyx_t_12);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
          __Pyx_XGIVEREF(__pyx_t_13);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 23;
          return __pyx_r;
          __pyx_L386_resume_from_await:;
          __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_11);
          __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_12);
          __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_13);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2365, __pyx_L263_error)
          __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
        } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __pyx_t_5 = __pyx_r; __pyx_r = NULL;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 2365, __pyx_L263_error)
        }
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_activity_percentage_start);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_activity_percentage_start, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":2366
 *                 # logger.info(f"Adjusted timestamps - start: {start_date}, end: {end_date}")
 *                 activity_percentage_start = await self.getCurrentSlot()
 *                 activity_percentage_end = activity_percentage_start + datetime.timedelta(minutes=int(self.interval/60))             # <<<<<<<<<<<<<<
 * 
 *                 # Round timestamps to seconds for consistent duplicate detection
*/
        __pyx_t_3 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2366, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_timedelta); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2366, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_33);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2366, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_15 = __Pyx_PyLong_TrueDivideObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_60, 60, 0, 0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2366, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_t_15); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2366, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_33))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_33);
          assert(__pyx_t_3);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_3, NULL};
          __pyx_t_15 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2366, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_15);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_minutes, __pyx_t_1, __pyx_t_15, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 2366, __pyx_L263_error)
          __pyx_t_5 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_15);
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2366, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __pyx_t_33 = PyNumber_Add(__pyx_cur_scope->__pyx_v_activity_percentage_start, __pyx_t_5); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2366, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_33);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_activity_percentage_end);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_activity_percentage_end, __pyx_t_33);
        __Pyx_GIVEREF(__pyx_t_33);
        __pyx_t_33 = 0;

        /* "ws_package/controllers/activity_controller.py":2369
 * 
 *                 # Round timestamps to seconds for consistent duplicate detection
 *                 activity_percentage_start_seconds = activity_percentage_start.replace(microsecond=0)             # <<<<<<<<<<<<<<
 *                 activity_percentage_end_seconds = activity_percentage_end.replace(microsecond=0)
 *                 activity_percentage_key = (activity_percentage_start_seconds, activity_percentage_end_seconds)
*/
        __pyx_t_5 = __pyx_cur_scope->__pyx_v_activity_percentage_start;
        __Pyx_INCREF(__pyx_t_5);
        __pyx_t_7 = 0;
        {
          PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_5, NULL};
          __pyx_t_15 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2369, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_15);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_15, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 2369, __pyx_L263_error)
          __pyx_t_33 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_15);
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2369, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_33);
        }
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_activity_percentage_start_seconds);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_activity_percentage_start_seconds, __pyx_t_33);
        __Pyx_GIVEREF(__pyx_t_33);
        __pyx_t_33 = 0;

        /* "ws_package/controllers/activity_controller.py":2370
 *                 # Round timestamps to seconds for consistent duplicate detection
 *                 activity_percentage_start_seconds = activity_percentage_start.replace(microsecond=0)
 *                 activity_percentage_end_seconds = activity_percentage_end.replace(microsecond=0)             # <<<<<<<<<<<<<<
 *                 activity_percentage_key = (activity_percentage_start_seconds, activity_percentage_end_seconds)
 * 
*/
        __pyx_t_15 = __pyx_cur_scope->__pyx_v_activity_percentage_end;
        __Pyx_INCREF(__pyx_t_15);
        __pyx_t_7 = 0;
        {
          PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_15, NULL};
          __pyx_t_5 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2370, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_5);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_5, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 2370, __pyx_L263_error)
          __pyx_t_33 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_5);
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2370, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_33);
        }
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_activity_percentage_end_seconds);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_activity_percentage_end_seconds, __pyx_t_33);
        __Pyx_GIVEREF(__pyx_t_33);
        __pyx_t_33 = 0;

        /* "ws_package/controllers/activity_controller.py":2371
 *                 activity_percentage_start_seconds = activity_percentage_start.replace(microsecond=0)
 *                 activity_percentage_end_seconds = activity_percentage_end.replace(microsecond=0)
 *                 activity_percentage_key = (activity_percentage_start_seconds, activity_percentage_end_seconds)             # <<<<<<<<<<<<<<
 * 
 *                 # Check in-memory set first (fast check, prevents race conditions)
*/
        __pyx_t_33 = PyTuple_New(2); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2371, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_33);
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_activity_percentage_start_seconds);
        __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_activity_percentage_start_seconds);
        if (__Pyx_PyTuple_SET_ITEM(__pyx_t_33, 0, __pyx_cur_scope->__pyx_v_activity_percentage_start_seconds) != (0)) __PYX_ERR(0, 2371, __pyx_L263_error);
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_activity_percentage_end_seconds);
        __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_activity_percentage_end_seconds);
        if (__Pyx_PyTuple_SET_ITEM(__pyx_t_33, 1, __pyx_cur_scope->__pyx_v_activity_percentage_end_seconds) != (0)) __PYX_ERR(0, 2371, __pyx_L263_error);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_activity_percentage_key);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_activity_percentage_key, ((PyObject*)__pyx_t_33));
        __Pyx_GIVEREF(__pyx_t_33);
        __pyx_t_33 = 0;

        /* "ws_package/controllers/activity_controller.py":2374
 * 
 *                 # Check in-memory set first (fast check, prevents race conditions)
 *                 if activity_percentage_key in self._creating_activity_percentages:             # <<<<<<<<<<<<<<
 *                     logger.info("Activity percentage record already being created for slot %s to %s. Skipping duplicate creation.", activity_percentage_start_seconds, activity_percentage_end_seconds)
 *                 else:
*/
        __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_creating_activity_percentages); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2374, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_33);
        __pyx_t_9 = (__Pyx_PySequence_ContainsTF(__pyx_cur_scope->__pyx_v_activity_percentage_key, __pyx_t_33, Py_EQ)); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2374, __pyx_L263_error)
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
        if (__pyx_t_9) {

          /* "ws_package/controllers/activity_controller.py":2375
 *                 # Check in-memory set first (fast check, prevents race conditions)
 *                 if activity_percentage_key in self._creating_activity_percentages:
 *                     logger.info("Activity percentage record already being created for slot %s to %s. Skipping duplicate creation.", activity_percentage_start_seconds, activity_percentage_end_seconds)             # <<<<<<<<<<<<<<
 *                 else:
 *                     # Mark as creating to prevent concurrent duplicates
*/
          __pyx_t_5 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2375, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_15);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2375, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __pyx_t_7 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_1))) {
            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
            assert(__pyx_t_5);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
            __pyx_t_7 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[4] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Activity_percentage_record_alrea, __pyx_cur_scope->__pyx_v_activity_percentage_start_seconds, __pyx_cur_scope->__pyx_v_activity_percentage_end_seconds};
            __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2375, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_33);
          }
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

          /* "ws_package/controllers/activity_controller.py":2374
 * 
 *                 # Check in-memory set first (fast check, prevents race conditions)
 *                 if activity_percentage_key in self._creating_activity_percentages:             # <<<<<<<<<<<<<<
 *                     logger.info("Activity percentage record already being created for slot %s to %s. Skipping duplicate creation.", activity_percentage_start_seconds, activity_percentage_end_seconds)
 *                 else:
*/
          goto __pyx_L387;
        }

        /* "ws_package/controllers/activity_controller.py":2378
 *                 else:
 *                     # Mark as creating to prevent concurrent duplicates
 *                     self._creating_activity_percentages.add(activity_percentage_key)             # <<<<<<<<<<<<<<
 * 
 *                     try:
*/
        /*else*/ {
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_creating_activity_percentages); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2378, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_1 = __pyx_t_5;
          __Pyx_INCREF(__pyx_t_1);
          __pyx_t_7 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_cur_scope->__pyx_v_activity_percentage_key};
            __pyx_t_33 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_add, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2378, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_33);
          }
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

          /* "ws_package/controllers/activity_controller.py":2380
 *                     self._creating_activity_percentages.add(activity_percentage_key)
 * 
 *                     try:             # <<<<<<<<<<<<<<
 *                         # Flush queue first to ensure any pending writes are visible in database
 *                         await db_writer_service.process_immediately()
*/
          {
            __Pyx_ExceptionSave(&__pyx_t_39, &__pyx_t_23, &__pyx_t_31);
            __Pyx_XGOTREF(__pyx_t_39);
            __Pyx_XGOTREF(__pyx_t_23);
            __Pyx_XGOTREF(__pyx_t_31);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":2382
 *                     try:
 *                         # Flush queue first to ensure any pending writes are visible in database
 *                         await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 *                         await asyncio.sleep(0.2)  # Small delay to ensure commit is visible
 * 
*/
              __pyx_t_5 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2382, __pyx_L388_error)
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2382, __pyx_L388_error)
              __Pyx_GOTREF(__pyx_t_15);
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_15))) {
                __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_15);
                assert(__pyx_t_5);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                __Pyx_INCREF(__pyx_t_5);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2382, __pyx_L388_error)
                __Pyx_GOTREF(__pyx_t_33);
              }
              __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_33, &__pyx_r);
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_XGIVEREF(__pyx_t_11);
                __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                __Pyx_XGIVEREF(__pyx_t_12);
                __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                __Pyx_XGIVEREF(__pyx_t_13);
                __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                __Pyx_XGIVEREF(__pyx_t_23);
                __pyx_cur_scope->__pyx_t_3 = __pyx_t_23;
                __Pyx_XGIVEREF(__pyx_t_31);
                __pyx_cur_scope->__pyx_t_4 = __pyx_t_31;
                __Pyx_XGIVEREF(__pyx_t_39);
                __pyx_cur_scope->__pyx_t_5 = __pyx_t_39;
                __Pyx_XGIVEREF(__pyx_r);
                __Pyx_RefNannyFinishContext();
                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                /* return from generator, awaiting value */
                __pyx_generator->resume_label = 24;
                return __pyx_r;
                __pyx_L396_resume_from_await:;
                __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                __pyx_cur_scope->__pyx_t_0 = 0;
                __Pyx_XGOTREF(__pyx_t_11);
                __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                __pyx_cur_scope->__pyx_t_1 = 0;
                __Pyx_XGOTREF(__pyx_t_12);
                __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                __pyx_cur_scope->__pyx_t_2 = 0;
                __Pyx_XGOTREF(__pyx_t_13);
                __pyx_t_23 = __pyx_cur_scope->__pyx_t_3;
                __pyx_cur_scope->__pyx_t_3 = 0;
                __Pyx_XGOTREF(__pyx_t_23);
                __pyx_t_31 = __pyx_cur_scope->__pyx_t_4;
                __pyx_cur_scope->__pyx_t_4 = 0;
                __Pyx_XGOTREF(__pyx_t_31);
                __pyx_t_39 = __pyx_cur_scope->__pyx_t_5;
                __pyx_cur_scope->__pyx_t_5 = 0;
                __Pyx_XGOTREF(__pyx_t_39);
                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2382, __pyx_L388_error)
              } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_DECREF(__pyx_r); __pyx_r = 0;
              } else {
                __Pyx_XGOTREF(__pyx_r);
                __PYX_ERR(0, 2382, __pyx_L388_error)
              }

              /* "ws_package/controllers/activity_controller.py":2383
 *                         # Flush queue first to ensure any pending writes are visible in database
 *                         await db_writer_service.process_immediately()
 *                         await asyncio.sleep(0.2)  # Small delay to ensure commit is visible             # <<<<<<<<<<<<<<
 * 
 *                         # Check if a record for this 10-minute slot already exists to prevent duplicates
*/
              __pyx_t_15 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2383, __pyx_L388_error)
              __Pyx_GOTREF(__pyx_t_5);
              __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2383, __pyx_L388_error)
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_1))) {
                __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_1);
                assert(__pyx_t_15);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
                __Pyx_INCREF(__pyx_t_15);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_mstate_global->__pyx_float_0_2};
                __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2383, __pyx_L388_error)
                __Pyx_GOTREF(__pyx_t_33);
              }
              __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_33, &__pyx_r);
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_XGIVEREF(__pyx_t_11);
                __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                __Pyx_XGIVEREF(__pyx_t_12);
                __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                __Pyx_XGIVEREF(__pyx_t_13);
                __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                __Pyx_XGIVEREF(__pyx_t_23);
                __pyx_cur_scope->__pyx_t_3 = __pyx_t_23;
                __Pyx_XGIVEREF(__pyx_t_31);
                __pyx_cur_scope->__pyx_t_4 = __pyx_t_31;
                __Pyx_XGIVEREF(__pyx_t_39);
                __pyx_cur_scope->__pyx_t_5 = __pyx_t_39;
                __Pyx_XGIVEREF(__pyx_r);
                __Pyx_RefNannyFinishContext();
                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                /* return from generator, awaiting value */
                __pyx_generator->resume_label = 25;
                return __pyx_r;
                __pyx_L397_resume_from_await:;
                __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                __pyx_cur_scope->__pyx_t_0 = 0;
                __Pyx_XGOTREF(__pyx_t_11);
                __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                __pyx_cur_scope->__pyx_t_1 = 0;
                __Pyx_XGOTREF(__pyx_t_12);
                __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                __pyx_cur_scope->__pyx_t_2 = 0;
                __Pyx_XGOTREF(__pyx_t_13);
                __pyx_t_23 = __pyx_cur_scope->__pyx_t_3;
                __pyx_cur_scope->__pyx_t_3 = 0;
                __Pyx_XGOTREF(__pyx_t_23);
                __pyx_t_31 = __pyx_cur_scope->__pyx_t_4;
                __pyx_cur_scope->__pyx_t_4 = 0;
                __Pyx_XGOTREF(__pyx_t_31);
                __pyx_t_39 = __pyx_cur_scope->__pyx_t_5;
                __pyx_cur_scope->__pyx_t_5 = 0;
                __Pyx_XGOTREF(__pyx_t_39);
                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2383, __pyx_L388_error)
              } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_DECREF(__pyx_r); __pyx_r = 0;
              } else {
                __Pyx_XGOTREF(__pyx_r);
                __PYX_ERR(0, 2383, __pyx_L388_error)
              }

              /* "ws_package/controllers/activity_controller.py":2386
 * 
 *                         # Check if a record for this 10-minute slot already exists to prevent duplicates
 *                         existing_record = await activity_percentage_manager.find_overlapping_activity_percentage(             # <<<<<<<<<<<<<<
 *                             activity_percentage_start,
 *                             activity_percentage_end
*/
              __pyx_t_1 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_activity_percentage_manager); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2386, __pyx_L388_error)
              __Pyx_GOTREF(__pyx_t_15);
              __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_find_overlapping_activity_percen); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2386, __pyx_L388_error)
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

              /* "ws_package/controllers/activity_controller.py":2388
 *                         existing_record = await activity_percentage_manager.find_overlapping_activity_percentage(
 *                             activity_percentage_start,
 *                             activity_percentage_end             # <<<<<<<<<<<<<<
 *                         )
 * 
*/
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_5))) {
                __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_5);
                assert(__pyx_t_1);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                __Pyx_INCREF(__pyx_t_1);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_cur_scope->__pyx_v_activity_percentage_start, __pyx_cur_scope->__pyx_v_activity_percentage_end};
                __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2386, __pyx_L388_error)
                __Pyx_GOTREF(__pyx_t_33);
              }
              __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_33, &__pyx_r);
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_XGIVEREF(__pyx_t_11);
                __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                __Pyx_XGIVEREF(__pyx_t_12);
                __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                __Pyx_XGIVEREF(__pyx_t_13);
                __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                __Pyx_XGIVEREF(__pyx_t_23);
                __pyx_cur_scope->__pyx_t_3 = __pyx_t_23;
                __Pyx_XGIVEREF(__pyx_t_31);
                __pyx_cur_scope->__pyx_t_4 = __pyx_t_31;
                __Pyx_XGIVEREF(__pyx_t_39);
                __pyx_cur_scope->__pyx_t_5 = __pyx_t_39;
                __Pyx_XGIVEREF(__pyx_r);
                __Pyx_RefNannyFinishContext();
                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                /* return from generator, awaiting value */
                __pyx_generator->resume_label = 26;
                return __pyx_r;
                __pyx_L398_resume_from_await:;
                __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                __pyx_cur_scope->__pyx_t_0 = 0;
                __Pyx_XGOTREF(__pyx_t_11);
                __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                __pyx_cur_scope->__pyx_t_1 = 0;
                __Pyx_XGOTREF(__pyx_t_12);
                __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                __pyx_cur_scope->__pyx_t_2 = 0;
                __Pyx_XGOTREF(__pyx_t_13);
                __pyx_t_23 = __pyx_cur_scope->__pyx_t_3;
                __pyx_cur_scope->__pyx_t_3 = 0;
                __Pyx_XGOTREF(__pyx_t_23);
                __pyx_t_31 = __pyx_cur_scope->__pyx_t_4;
                __pyx_cur_scope->__pyx_t_4 = 0;
                __Pyx_XGOTREF(__pyx_t_31);
                __pyx_t_39 = __pyx_cur_scope->__pyx_t_5;
                __pyx_cur_scope->__pyx_t_5 = 0;
                __Pyx_XGOTREF(__pyx_t_39);
                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2386, __pyx_L388_error)
                __pyx_t_33 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_33);
              } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                __Pyx_GOTREF(__pyx_r);
                __pyx_t_33 = __pyx_r; __pyx_r = NULL;
              } else {
                __Pyx_XGOTREF(__pyx_r);
                __PYX_ERR(0, 2386, __pyx_L388_error)
              }
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_existing_record);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_existing_record, __pyx_t_33);
              __Pyx_GIVEREF(__pyx_t_33);
              __pyx_t_33 = 0;

              /* "ws_package/controllers/activity_controller.py":2391
 *                         )
 * 
 *                         if existing_record:             # <<<<<<<<<<<<<<
 *                             logger.info("Activity percentage record already exists for slot %s to %s. Skipping creation to prevent duplicates.", activity_percentage_start, activity_percentage_end)
 *                             # Remove from set since we're not creating
*/
              __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_existing_record); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2391, __pyx_L388_error)
              if (__pyx_t_9) {

                /* "ws_package/controllers/activity_controller.py":2392
 * 
 *                         if existing_record:
 *                             logger.info("Activity percentage record already exists for slot %s to %s. Skipping creation to prevent duplicates.", activity_percentage_start, activity_percentage_end)             # <<<<<<<<<<<<<<
 *                             # Remove from set since we're not creating
 *                             self._creating_activity_percentages.discard(activity_percentage_key)
*/
                __pyx_t_5 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2392, __pyx_L388_error)
                __Pyx_GOTREF(__pyx_t_1);
                __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2392, __pyx_L388_error)
                __Pyx_GOTREF(__pyx_t_15);
                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_15))) {
                  __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_15);
                  assert(__pyx_t_5);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                  __Pyx_INCREF(__pyx_t_5);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[4] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Activity_percentage_record_alrea_2, __pyx_cur_scope->__pyx_v_activity_percentage_start, __pyx_cur_scope->__pyx_v_activity_percentage_end};
                  __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2392, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_33);
                }
                __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

                /* "ws_package/controllers/activity_controller.py":2394
 *                             logger.info("Activity percentage record already exists for slot %s to %s. Skipping creation to prevent duplicates.", activity_percentage_start, activity_percentage_end)
 *                             # Remove from set since we're not creating
 *                             self._creating_activity_percentages.discard(activity_percentage_key)             # <<<<<<<<<<<<<<
 *                         else:
 *                             # Check if this is the very first activity percentage record after app start
*/
                __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_creating_activity_percentages); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2394, __pyx_L388_error)
                __Pyx_GOTREF(__pyx_t_5);
                __pyx_t_15 = __pyx_t_5;
                __Pyx_INCREF(__pyx_t_15);
                __pyx_t_7 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_cur_scope->__pyx_v_activity_percentage_key};
                  __pyx_t_33 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_discard, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2394, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_33);
                }
                __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

                /* "ws_package/controllers/activity_controller.py":2391
 *                         )
 * 
 *                         if existing_record:             # <<<<<<<<<<<<<<
 *                             logger.info("Activity percentage record already exists for slot %s to %s. Skipping creation to prevent duplicates.", activity_percentage_start, activity_percentage_end)
 *                             # Remove from set since we're not creating
*/
                goto __pyx_L399;
              }

              /* "ws_package/controllers/activity_controller.py":2401
 *                             # 2. The latest record starts BEFORE self.start_date (actual timer start time when user clicked Start)
 *                             #    meaning this is the first entry for this session
 *                             latest_record = await activity_percentage_manager.get_latest_activity_percentage()             # <<<<<<<<<<<<<<
 * 
 *                             is_first_entry = False
*/
              /*else*/ {
                __pyx_t_5 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_activity_percentage_manager); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2401, __pyx_L388_error)
                __Pyx_GOTREF(__pyx_t_15);
                __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_get_latest_activity_percentage); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2401, __pyx_L388_error)
                __Pyx_GOTREF(__pyx_t_1);
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_1))) {
                  __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
                  assert(__pyx_t_5);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
                  __Pyx_INCREF(__pyx_t_5);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                  __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                  if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2401, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_33);
                }
                __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_33, &__pyx_r);
                __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_11);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_t_23);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_23;
                  __Pyx_XGIVEREF(__pyx_t_31);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_31;
                  __Pyx_XGIVEREF(__pyx_t_39);
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_39;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 27;
                  return __pyx_r;
                  __pyx_L400_resume_from_await:;
                  __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_11);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  __pyx_t_23 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_23);
                  __pyx_t_31 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_31);
                  __pyx_t_39 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = 0;
                  __Pyx_XGOTREF(__pyx_t_39);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2401, __pyx_L388_error)
                  __pyx_t_33 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_33);
                } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __pyx_t_33 = __pyx_r; __pyx_r = NULL;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 2401, __pyx_L388_error)
                }
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_latest_record);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_latest_record, __pyx_t_33);
                __Pyx_GIVEREF(__pyx_t_33);
                __pyx_t_33 = 0;

                /* "ws_package/controllers/activity_controller.py":2403
 *                             latest_record = await activity_percentage_manager.get_latest_activity_percentage()
 * 
 *                             is_first_entry = False             # <<<<<<<<<<<<<<
 *                             if latest_record is None:
 *                                 # No records exist - this is definitely the first entry
*/
                __pyx_cur_scope->__pyx_v_is_first_entry = 0;

                /* "ws_package/controllers/activity_controller.py":2404
 * 
 *                             is_first_entry = False
 *                             if latest_record is None:             # <<<<<<<<<<<<<<
 *                                 # No records exist - this is definitely the first entry
 *                                 is_first_entry = True
*/
                __pyx_t_9 = (__pyx_cur_scope->__pyx_v_latest_record == Py_None);
                if (__pyx_t_9) {

                  /* "ws_package/controllers/activity_controller.py":2406
 *                             if latest_record is None:
 *                                 # No records exist - this is definitely the first entry
 *                                 is_first_entry = True             # <<<<<<<<<<<<<<
 *                                 logger.info("First entry detected: No existing records in database")
 *                             elif hasattr(self, 'start_date') and self.start_date is not None:
*/
                  __pyx_cur_scope->__pyx_v_is_first_entry = 1;

                  /* "ws_package/controllers/activity_controller.py":2407
 *                                 # No records exist - this is definitely the first entry
 *                                 is_first_entry = True
 *                                 logger.info("First entry detected: No existing records in database")             # <<<<<<<<<<<<<<
 *                             elif hasattr(self, 'start_date') and self.start_date is not None:
 *                                 # Check if latest record is before actual timer start time - if so, this is first entry for this session
*/
                  __pyx_t_1 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2407, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_5);
                  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2407, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_15);
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_15))) {
                    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_15);
                    assert(__pyx_t_1);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                    __Pyx_INCREF(__pyx_t_1);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_First_entry_detected_No_existing};
                    __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                    if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2407, __pyx_L388_error)
                    __Pyx_GOTREF(__pyx_t_33);
                  }
                  __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

                  /* "ws_package/controllers/activity_controller.py":2404
 * 
 *                             is_first_entry = False
 *                             if latest_record is None:             # <<<<<<<<<<<<<<
 *                                 # No records exist - this is definitely the first entry
 *                                 is_first_entry = True
*/
                  goto __pyx_L401;
                }

                /* "ws_package/controllers/activity_controller.py":2408
 *                                 is_first_entry = True
 *                                 logger.info("First entry detected: No existing records in database")
 *                             elif hasattr(self, 'start_date') and self.start_date is not None:             # <<<<<<<<<<<<<<
 *                                 # Check if latest record is before actual timer start time - if so, this is first entry for this session
 *                                 # self.start_date is set to datetime.datetime.now() when user clicks Start button
*/
                __pyx_t_33 = __pyx_cur_scope->__pyx_v_self;
                __Pyx_INCREF(__pyx_t_33);
                __pyx_t_8 = __Pyx_HasAttr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_start_date); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 2408, __pyx_L388_error)
                __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                if (__pyx_t_8) {
                } else {
                  __pyx_t_9 = __pyx_t_8;
                  goto __pyx_L402_bool_binop_done;
                }
                __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_start_date); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2408, __pyx_L388_error)
                __Pyx_GOTREF(__pyx_t_33);
                __pyx_t_8 = (__pyx_t_33 != Py_None);
                __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                __pyx_t_9 = __pyx_t_8;
                __pyx_L402_bool_binop_done:;
                if (__pyx_t_9) {

                  /* "ws_package/controllers/activity_controller.py":2411
 *                                 # Check if latest record is before actual timer start time - if so, this is first entry for this session
 *                                 # self.start_date is set to datetime.datetime.now() when user clicks Start button
 *                                 if latest_record.start < self.start_date:             # <<<<<<<<<<<<<<
 *                                     is_first_entry = True
 *                                     logger.info("First entry detected: latest_record.start (%s) < start_date (%s) - first entry after app start", latest_record.start, self.start_date)
*/
                  __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_latest_record, __pyx_mstate_global->__pyx_n_u_start); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2411, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_33);
                  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_start_date); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2411, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_15);
                  __pyx_t_1 = PyObject_RichCompare(__pyx_t_33, __pyx_t_15, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2411, __pyx_L388_error)
                  __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2411, __pyx_L388_error)
                  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                  if (__pyx_t_9) {

                    /* "ws_package/controllers/activity_controller.py":2412
 *                                 # self.start_date is set to datetime.datetime.now() when user clicks Start button
 *                                 if latest_record.start < self.start_date:
 *                                     is_first_entry = True             # <<<<<<<<<<<<<<
 *                                     logger.info("First entry detected: latest_record.start (%s) < start_date (%s) - first entry after app start", latest_record.start, self.start_date)
 *                             else:
*/
                    __pyx_cur_scope->__pyx_v_is_first_entry = 1;

                    /* "ws_package/controllers/activity_controller.py":2413
 *                                 if latest_record.start < self.start_date:
 *                                     is_first_entry = True
 *                                     logger.info("First entry detected: latest_record.start (%s) < start_date (%s) - first entry after app start", latest_record.start, self.start_date)             # <<<<<<<<<<<<<<
 *                             else:
 *                                 logger.warning("start_date not available - cannot determine if this is first entry. Using default mouse=0")
*/
                    __pyx_t_15 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2413, __pyx_L388_error)
                    __Pyx_GOTREF(__pyx_t_33);
                    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2413, __pyx_L388_error)
                    __Pyx_GOTREF(__pyx_t_5);
                    __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                    __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_latest_record, __pyx_mstate_global->__pyx_n_u_start); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2413, __pyx_L388_error)
                    __Pyx_GOTREF(__pyx_t_33);
                    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_start_date); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2413, __pyx_L388_error)
                    __Pyx_GOTREF(__pyx_t_3);
                    __pyx_t_7 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_5))) {
                      __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5);
                      assert(__pyx_t_15);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                      __Pyx_INCREF(__pyx_t_15);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                      __pyx_t_7 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[4] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_First_entry_detected_latest_reco, __pyx_t_33, __pyx_t_3};
                      __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                      __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2413, __pyx_L388_error)
                      __Pyx_GOTREF(__pyx_t_1);
                    }
                    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

                    /* "ws_package/controllers/activity_controller.py":2411
 *                                 # Check if latest record is before actual timer start time - if so, this is first entry for this session
 *                                 # self.start_date is set to datetime.datetime.now() when user clicks Start button
 *                                 if latest_record.start < self.start_date:             # <<<<<<<<<<<<<<
 *                                     is_first_entry = True
 *                                     logger.info("First entry detected: latest_record.start (%s) < start_date (%s) - first entry after app start", latest_record.start, self.start_date)
*/
                  }

                  /* "ws_package/controllers/activity_controller.py":2408
 *                                 is_first_entry = True
 *                                 logger.info("First entry detected: No existing records in database")
 *                             elif hasattr(self, 'start_date') and self.start_date is not None:             # <<<<<<<<<<<<<<
 *                                 # Check if latest record is before actual timer start time - if so, this is first entry for this session
 *                                 # self.start_date is set to datetime.datetime.now() when user clicks Start button
*/
                  goto __pyx_L401;
                }

                /* "ws_package/controllers/activity_controller.py":2415
 *                                     logger.info("First entry detected: latest_record.start (%s) < start_date (%s) - first entry after app start", latest_record.start, self.start_date)
 *                             else:
 *                                 logger.warning("start_date not available - cannot determine if this is first entry. Using default mouse=0")             # <<<<<<<<<<<<<<
 * 
 *                             # For the very first entry after app start, set mouse activity = 1 by default
*/
                /*else*/ {
                  __pyx_t_5 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2415, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_3);
                  __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2415, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_33);
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_33))) {
                    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_33);
                    assert(__pyx_t_5);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
                    __Pyx_INCREF(__pyx_t_5);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_start_date_not_available_cannot};
                    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2415, __pyx_L388_error)
                    __Pyx_GOTREF(__pyx_t_1);
                  }
                  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                }
                __pyx_L401:;

                /* "ws_package/controllers/activity_controller.py":2419
 *                             # For the very first entry after app start, set mouse activity = 1 by default
 *                             # For subsequent entries, use 0 (will be updated by minute timer)
 *                             initial_mouse = 1.0 if is_first_entry else 0.0             # <<<<<<<<<<<<<<
 *                             initial_average = 1.0 if is_first_entry else 0.0  # Average = mouse + keyboard, so 1.0 if mouse=1
 * 
*/
                if (__pyx_cur_scope->__pyx_v_is_first_entry) {
                  __pyx_t_52 = 1.0;
                } else {
                  __pyx_t_52 = 0.0;
                }
                __pyx_cur_scope->__pyx_v_initial_mouse = __pyx_t_52;

                /* "ws_package/controllers/activity_controller.py":2420
 *                             # For subsequent entries, use 0 (will be updated by minute timer)
 *                             initial_mouse = 1.0 if is_first_entry else 0.0
 *                             initial_average = 1.0 if is_first_entry else 0.0  # Average = mouse + keyboard, so 1.0 if mouse=1             # <<<<<<<<<<<<<<
 * 
 *                             # Create new activity percentage entity only if it doesn't exist
*/
                if (__pyx_cur_scope->__pyx_v_is_first_entry) {
                  __pyx_t_52 = 1.0;
                } else {
                  __pyx_t_52 = 0.0;
                }
                __pyx_cur_scope->__pyx_v_initial_average = __pyx_t_52;

                /* "ws_package/controllers/activity_controller.py":2423
 * 
 *                             # Create new activity percentage entity only if it doesn't exist
 *                             activity_percentage_entity = ActivityPercentageEntity(             # <<<<<<<<<<<<<<
 *                                 start=activity_percentage_start,
 *                                 stop=activity_percentage_end,
*/
                __pyx_t_33 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_ActivityPercentageEntity); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2423, __pyx_L388_error)
                __Pyx_GOTREF(__pyx_t_5);

                /* "ws_package/controllers/activity_controller.py":2427
 *                                 stop=activity_percentage_end,
 *                                 keyboard=0,
 *                                 mouse=initial_mouse,             # <<<<<<<<<<<<<<
 *                                 average=initial_average,
 *                                 minute=0  # Start at 0 - minute timer will increment to 1 on first update: ((0*0) + activity) / 1 = activity
*/
                __pyx_t_3 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_initial_mouse); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2427, __pyx_L388_error)
                __Pyx_GOTREF(__pyx_t_3);

                /* "ws_package/controllers/activity_controller.py":2428
 *                                 keyboard=0,
 *                                 mouse=initial_mouse,
 *                                 average=initial_average,             # <<<<<<<<<<<<<<
 *                                 minute=0  # Start at 0 - minute timer will increment to 1 on first update: ((0*0) + activity) / 1 = activity
 *                             )
*/
                __pyx_t_15 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_initial_average); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2428, __pyx_L388_error)
                __Pyx_GOTREF(__pyx_t_15);
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_5))) {
                  __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_5);
                  assert(__pyx_t_33);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                  __Pyx_INCREF(__pyx_t_33);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 6 : 0)] = {__pyx_t_33, NULL};
                  __pyx_t_34 = __Pyx_MakeVectorcallBuilderKwds(6); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2423, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_34);
                  if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_start, __pyx_cur_scope->__pyx_v_activity_percentage_start, __pyx_t_34, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 2423, __pyx_L388_error)
                  if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_stop, __pyx_cur_scope->__pyx_v_activity_percentage_end, __pyx_t_34, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 2423, __pyx_L388_error)
                  if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_keyboard, __pyx_mstate_global->__pyx_int_0, __pyx_t_34, __pyx_callargs+1, 2) < (0)) __PYX_ERR(0, 2423, __pyx_L388_error)
                  if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_mouse, __pyx_t_3, __pyx_t_34, __pyx_callargs+1, 3) < (0)) __PYX_ERR(0, 2423, __pyx_L388_error)
                  if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_average, __pyx_t_15, __pyx_t_34, __pyx_callargs+1, 4) < (0)) __PYX_ERR(0, 2423, __pyx_L388_error)
                  if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_minute, __pyx_mstate_global->__pyx_int_0, __pyx_t_34, __pyx_callargs+1, 5) < (0)) __PYX_ERR(0, 2423, __pyx_L388_error)
                  __pyx_t_1 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_34);
                  __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2423, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_1);
                }
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_activity_percentage_entity);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_activity_percentage_entity, __pyx_t_1);
                __Pyx_GIVEREF(__pyx_t_1);
                __pyx_t_1 = 0;

                /* "ws_package/controllers/activity_controller.py":2434
 *                             # Use universal queue instead of separate activity_percentage_queue
 *                             # Note: enqueue is synchronous (thread-safe), not async
 *                             enqueued = db_write_queue.enqueue(             # <<<<<<<<<<<<<<
 *                                 operation_type=WriteOperationType.ACTIVITY_PERCENTAGE,
 *                                 table_name="activity_percentage",
*/
                __pyx_t_5 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_db_write_queue); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2434, __pyx_L388_error)
                __Pyx_GOTREF(__pyx_t_34);
                __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_enqueue); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2434, __pyx_L388_error)
                __Pyx_GOTREF(__pyx_t_15);
                __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;

                /* "ws_package/controllers/activity_controller.py":2435
 *                             # Note: enqueue is synchronous (thread-safe), not async
 *                             enqueued = db_write_queue.enqueue(
 *                                 operation_type=WriteOperationType.ACTIVITY_PERCENTAGE,             # <<<<<<<<<<<<<<
 *                                 table_name="activity_percentage",
 *                                 data=activity_percentage_entity.model_dump()
*/
                __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_WriteOperationType); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2435, __pyx_L388_error)
                __Pyx_GOTREF(__pyx_t_34);
                __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_ACTIVITY_PERCENTAGE); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2435, __pyx_L388_error)
                __Pyx_GOTREF(__pyx_t_3);
                __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;

                /* "ws_package/controllers/activity_controller.py":2437
 *                                 operation_type=WriteOperationType.ACTIVITY_PERCENTAGE,
 *                                 table_name="activity_percentage",
 *                                 data=activity_percentage_entity.model_dump()             # <<<<<<<<<<<<<<
 *                             )
 * 
*/
                __pyx_t_33 = __pyx_cur_scope->__pyx_v_activity_percentage_entity;
                __Pyx_INCREF(__pyx_t_33);
                __pyx_t_7 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_33, NULL};
                  __pyx_t_34 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_model_dump, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                  if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2437, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_34);
                }
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_15))) {
                  __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_15);
                  assert(__pyx_t_5);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                  __Pyx_INCREF(__pyx_t_5);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 3 : 0)] = {__pyx_t_5, NULL};
                  __pyx_t_33 = __Pyx_MakeVectorcallBuilderKwds(3); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2434, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_33);
                  if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_operation_type, __pyx_t_3, __pyx_t_33, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 2434, __pyx_L388_error)
                  if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_table_name, __pyx_mstate_global->__pyx_n_u_activity_percentage, __pyx_t_33, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 2434, __pyx_L388_error)
                  if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_data, __pyx_t_34, __pyx_t_33, __pyx_callargs+1, 2) < (0)) __PYX_ERR(0, 2434, __pyx_L388_error)
                  __pyx_t_1 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_33);
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                  __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2434, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_1);
                }
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_enqueued);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_enqueued, __pyx_t_1);
                __Pyx_GIVEREF(__pyx_t_1);
                __pyx_t_1 = 0;

                /* "ws_package/controllers/activity_controller.py":2440
 *                             )
 * 
 *                             if enqueued:             # <<<<<<<<<<<<<<
 *                                 first_entry_note = " (FIRST ENTRY - mouse=1 by default)" if is_first_entry else ""
 *                                 logger.info(
*/
                __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_enqueued); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2440, __pyx_L388_error)
                if (__pyx_t_9) {

                  /* "ws_package/controllers/activity_controller.py":2441
 * 
 *                             if enqueued:
 *                                 first_entry_note = " (FIRST ENTRY - mouse=1 by default)" if is_first_entry else ""             # <<<<<<<<<<<<<<
 *                                 logger.info(
 *                                     "Enqueued initial activity percentage%s: "
*/
                  if (__pyx_cur_scope->__pyx_v_is_first_entry) {
                    __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_FIRST_ENTRY_mouse_1_by_default);
                    __pyx_t_1 = __pyx_mstate_global->__pyx_kp_u_FIRST_ENTRY_mouse_1_by_default;
                  } else {
                    __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u__2);
                    __pyx_t_1 = __pyx_mstate_global->__pyx_kp_u__2;
                  }
                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_first_entry_note);
                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_first_entry_note, ((PyObject*)__pyx_t_1));
                  __Pyx_GIVEREF(__pyx_t_1);
                  __pyx_t_1 = 0;

                  /* "ws_package/controllers/activity_controller.py":2442
 *                             if enqueued:
 *                                 first_entry_note = " (FIRST ENTRY - mouse=1 by default)" if is_first_entry else ""
 *                                 logger.info(             # <<<<<<<<<<<<<<
 *                                     "Enqueued initial activity percentage%s: "
 *                                     "Slot: %s to %s, Keyboard: %s%%, Mouse: %s%%, "
*/
                  __pyx_t_15 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2442, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_33);
                  __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2442, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_34);
                  __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

                  /* "ws_package/controllers/activity_controller.py":2449
 *                                     first_entry_note,
 *                                     activity_percentage_start, activity_percentage_end,
 *                                     activity_percentage_entity.keyboard,             # <<<<<<<<<<<<<<
 *                                     activity_percentage_entity.mouse,
 *                                     activity_percentage_entity.average,
*/
                  __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activity_percentage_entity, __pyx_mstate_global->__pyx_n_u_keyboard); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2449, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_33);

                  /* "ws_package/controllers/activity_controller.py":2450
 *                                     activity_percentage_start, activity_percentage_end,
 *                                     activity_percentage_entity.keyboard,
 *                                     activity_percentage_entity.mouse,             # <<<<<<<<<<<<<<
 *                                     activity_percentage_entity.average,
 *                                     activity_percentage_entity.minute)
*/
                  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activity_percentage_entity, __pyx_mstate_global->__pyx_n_u_mouse); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2450, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_3);

                  /* "ws_package/controllers/activity_controller.py":2451
 *                                     activity_percentage_entity.keyboard,
 *                                     activity_percentage_entity.mouse,
 *                                     activity_percentage_entity.average,             # <<<<<<<<<<<<<<
 *                                     activity_percentage_entity.minute)
 *                                 # Remove from set after a delay to allow database write to complete
*/
                  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activity_percentage_entity, __pyx_mstate_global->__pyx_n_u_average); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2451, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_5);

                  /* "ws_package/controllers/activity_controller.py":2452
 *                                     activity_percentage_entity.mouse,
 *                                     activity_percentage_entity.average,
 *                                     activity_percentage_entity.minute)             # <<<<<<<<<<<<<<
 *                                 # Remove from set after a delay to allow database write to complete
 *                                 async def remove_after_delay():
*/
                  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activity_percentage_entity, __pyx_mstate_global->__pyx_n_u_minute); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2452, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_34))) {
                    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_34);
                    assert(__pyx_t_15);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_34);
                    __Pyx_INCREF(__pyx_t_15);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_34, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[9] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Enqueued_initial_activity_percen, __pyx_cur_scope->__pyx_v_first_entry_note, __pyx_cur_scope->__pyx_v_activity_percentage_start, __pyx_cur_scope->__pyx_v_activity_percentage_end, __pyx_t_33, __pyx_t_3, __pyx_t_5, __pyx_t_6};
                    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_34, __pyx_callargs+__pyx_t_7, (9-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2442, __pyx_L388_error)
                    __Pyx_GOTREF(__pyx_t_1);
                  }
                  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

                  /* "ws_package/controllers/activity_controller.py":2454
 *                                     activity_percentage_entity.minute)
 *                                 # Remove from set after a delay to allow database write to complete
 *                                 async def remove_after_delay():             # <<<<<<<<<<<<<<
 *                                     await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                                     self._creating_activity_percentages.discard(activity_percentage_key)
*/
                  __pyx_t_1 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_13remove_after_delay, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController___start_devic_4, ((PyObject*)__pyx_cur_scope), __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[26])); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2454, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_1);
                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_remove_after_delay);
                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_remove_after_delay, __pyx_t_1);
                  __Pyx_GIVEREF(__pyx_t_1);
                  __pyx_t_1 = 0;

                  /* "ws_package/controllers/activity_controller.py":2457
 *                                     await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                                     self._creating_activity_percentages.discard(activity_percentage_key)
 *                                 asyncio.create_task(remove_after_delay())             # <<<<<<<<<<<<<<
 *                             else:
 *                                 logger.error("Failed to save activity percentage record")
*/
                  __pyx_t_34 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2457, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_create_task); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2457, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_5);
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_cur_scope->__pyx_v_remove_after_delay); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2457, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_5))) {
                    __pyx_t_34 = PyMethod_GET_SELF(__pyx_t_5);
                    assert(__pyx_t_34);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                    __Pyx_INCREF(__pyx_t_34);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_34, __pyx_t_6};
                    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2457, __pyx_L388_error)
                    __Pyx_GOTREF(__pyx_t_1);
                  }
                  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

                  /* "ws_package/controllers/activity_controller.py":2440
 *                             )
 * 
 *                             if enqueued:             # <<<<<<<<<<<<<<
 *                                 first_entry_note = " (FIRST ENTRY - mouse=1 by default)" if is_first_entry else ""
 *                                 logger.info(
*/
                  goto __pyx_L405;
                }

                /* "ws_package/controllers/activity_controller.py":2459
 *                                 asyncio.create_task(remove_after_delay())
 *                             else:
 *                                 logger.error("Failed to save activity percentage record")             # <<<<<<<<<<<<<<
 *                                 # Remove from set immediately on failure
 *                                 self._creating_activity_percentages.discard(activity_percentage_key)
*/
                /*else*/ {
                  __pyx_t_5 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2459, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2459, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_34);
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_34))) {
                    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_34);
                    assert(__pyx_t_5);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_34);
                    __Pyx_INCREF(__pyx_t_5);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_34, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Failed_to_save_activity_percenta};
                    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_34, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2459, __pyx_L388_error)
                    __Pyx_GOTREF(__pyx_t_1);
                  }
                  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

                  /* "ws_package/controllers/activity_controller.py":2461
 *                                 logger.error("Failed to save activity percentage record")
 *                                 # Remove from set immediately on failure
 *                                 self._creating_activity_percentages.discard(activity_percentage_key)             # <<<<<<<<<<<<<<
 *                     except Exception as e:
 *                         logger.error("Error checking/creating activity percentage: %s", e, exc_info=True)
*/
                  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_creating_activity_percentages); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2461, __pyx_L388_error)
                  __Pyx_GOTREF(__pyx_t_5);
                  __pyx_t_34 = __pyx_t_5;
                  __Pyx_INCREF(__pyx_t_34);
                  __pyx_t_7 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_34, __pyx_cur_scope->__pyx_v_activity_percentage_key};
                    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_discard, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2461, __pyx_L388_error)
                    __Pyx_GOTREF(__pyx_t_1);
                  }
                  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                }
                __pyx_L405:;
              }
              __pyx_L399:;

              /* "ws_package/controllers/activity_controller.py":2380
 *                     self._creating_activity_percentages.add(activity_percentage_key)
 * 
 *                     try:             # <<<<<<<<<<<<<<
 *                         # Flush queue first to ensure any pending writes are visible in database
 *                         await db_writer_service.process_immediately()
*/
            }
            __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
            __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_XDECREF(__pyx_t_31); __pyx_t_31 = 0;
            goto __pyx_L395_try_end;
            __pyx_L388_error:;
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
            __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
            __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
            __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
            __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
            __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

            /* "ws_package/controllers/activity_controller.py":2462
 *                                 # Remove from set immediately on failure
 *                                 self._creating_activity_percentages.discard(activity_percentage_key)
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error checking/creating activity percentage: %s", e, exc_info=True)
 *                         # Remove from set on error
*/
            __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
            if (__pyx_t_14) {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_34) < 0) __PYX_ERR(0, 2462, __pyx_L390_except_error)
              __Pyx_XGOTREF(__pyx_t_1);
              __Pyx_XGOTREF(__pyx_t_5);
              __Pyx_XGOTREF(__pyx_t_34);
              __Pyx_INCREF(__pyx_t_5);
              __Pyx_GIVEREF(__pyx_t_5);
              __pyx_cur_scope->__pyx_v_e = __pyx_t_5;
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":2463
 *                                 self._creating_activity_percentages.discard(activity_percentage_key)
 *                     except Exception as e:
 *                         logger.error("Error checking/creating activity percentage: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 *                         # Remove from set on error
 *                         self._creating_activity_percentages.discard(activity_percentage_key)
*/
                __pyx_t_3 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2463, __pyx_L411_error)
                __Pyx_GOTREF(__pyx_t_33);
                __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2463, __pyx_L411_error)
                __Pyx_GOTREF(__pyx_t_15);
                __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_15))) {
                  __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_15);
                  assert(__pyx_t_3);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                  __Pyx_INCREF(__pyx_t_3);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Error_checking_creating_activity, __pyx_cur_scope->__pyx_v_e};
                  __pyx_t_33 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2463, __pyx_L411_error)
                  __Pyx_GOTREF(__pyx_t_33);
                  if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_33, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 2463, __pyx_L411_error)
                  __pyx_t_6 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_33);
                  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2463, __pyx_L411_error)
                  __Pyx_GOTREF(__pyx_t_6);
                }
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

                /* "ws_package/controllers/activity_controller.py":2465
 *                         logger.error("Error checking/creating activity percentage: %s", e, exc_info=True)
 *                         # Remove from set on error
 *                         self._creating_activity_percentages.discard(activity_percentage_key)             # <<<<<<<<<<<<<<
 * 
 *                 # Check if we should stop BEFORE creating interval (prevent creating interval after stop)
*/
                __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_creating_activity_percentages); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2465, __pyx_L411_error)
                __Pyx_GOTREF(__pyx_t_33);
                __pyx_t_15 = __pyx_t_33;
                __Pyx_INCREF(__pyx_t_15);
                __pyx_t_7 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_cur_scope->__pyx_v_activity_percentage_key};
                  __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_discard, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2465, __pyx_L411_error)
                  __Pyx_GOTREF(__pyx_t_6);
                }
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              }

              /* "ws_package/controllers/activity_controller.py":2462
 *                                 # Remove from set immediately on failure
 *                                 self._creating_activity_percentages.discard(activity_percentage_key)
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error checking/creating activity percentage: %s", e, exc_info=True)
 *                         # Remove from set on error
*/
              /*finally:*/ {
                /*normal exit:*/{
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  goto __pyx_L412;
                }
                __pyx_L411_error:;
                /*exception exit:*/{
                  __Pyx_PyThreadState_assign
                  __pyx_t_46 = 0; __pyx_t_47 = 0; __pyx_t_48 = 0; __pyx_t_18 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0;
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                  __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                  __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                  __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                  __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                   __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_21, &__pyx_t_20);
                  if ( unlikely(__Pyx_GetException(&__pyx_t_46, &__pyx_t_47, &__pyx_t_48) < 0)) __Pyx_ErrFetch(&__pyx_t_46, &__pyx_t_47, &__pyx_t_48);
                  __Pyx_XGOTREF(__pyx_t_46);
                  __Pyx_XGOTREF(__pyx_t_47);
                  __Pyx_XGOTREF(__pyx_t_48);
                  __Pyx_XGOTREF(__pyx_t_18);
                  __Pyx_XGOTREF(__pyx_t_21);
                  __Pyx_XGOTREF(__pyx_t_20);
                  __pyx_t_14 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_53 = __pyx_filename;
                  {
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  }
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __Pyx_XGIVEREF(__pyx_t_21);
                  __Pyx_XGIVEREF(__pyx_t_20);
                  __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_21, __pyx_t_20);
                  __Pyx_XGIVEREF(__pyx_t_46);
                  __Pyx_XGIVEREF(__pyx_t_47);
                  __Pyx_XGIVEREF(__pyx_t_48);
                  __Pyx_ErrRestore(__pyx_t_46, __pyx_t_47, __pyx_t_48);
                  __pyx_t_46 = 0; __pyx_t_47 = 0; __pyx_t_48 = 0; __pyx_t_18 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0;
                  __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_53;
                  goto __pyx_L390_except_error;
                }
                __pyx_L412:;
              }
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
              goto __pyx_L389_exception_handled;
            }
            goto __pyx_L390_except_error;

            /* "ws_package/controllers/activity_controller.py":2380
 *                     self._creating_activity_percentages.add(activity_percentage_key)
 * 
 *                     try:             # <<<<<<<<<<<<<<
 *                         # Flush queue first to ensure any pending writes are visible in database
 *                         await db_writer_service.process_immediately()
*/
            __pyx_L390_except_error:;
            __Pyx_XGIVEREF(__pyx_t_39);
            __Pyx_XGIVEREF(__pyx_t_23);
            __Pyx_XGIVEREF(__pyx_t_31);
            __Pyx_ExceptionReset(__pyx_t_39, __pyx_t_23, __pyx_t_31);
            goto __pyx_L263_error;
            __pyx_L389_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_39);
            __Pyx_XGIVEREF(__pyx_t_23);
            __Pyx_XGIVEREF(__pyx_t_31);
            __Pyx_ExceptionReset(__pyx_t_39, __pyx_t_23, __pyx_t_31);
            __pyx_L395_try_end:;
          }
        }
        __pyx_L387:;

        /* "ws_package/controllers/activity_controller.py":2468
 * 
 *                 # Check if we should stop BEFORE creating interval (prevent creating interval after stop)
 *                 if stop_event.is_set():             # <<<<<<<<<<<<<<
 *                     logger.info("Stop event detected - breaking loop before creating interval")
 *                     break
*/
        __pyx_t_5 = __pyx_cur_scope->__pyx_v_stop_event;
        __Pyx_INCREF(__pyx_t_5);
        __pyx_t_7 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
          __pyx_t_34 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_set, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2468, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_34);
        }
        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_34); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2468, __pyx_L263_error)
        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
        if (__pyx_t_9) {

          /* "ws_package/controllers/activity_controller.py":2469
 *                 # Check if we should stop BEFORE creating interval (prevent creating interval after stop)
 *                 if stop_event.is_set():
 *                     logger.info("Stop event detected - breaking loop before creating interval")             # <<<<<<<<<<<<<<
 *                     break
 *                 # Check if timer was stopped due to limit and date hasn't changed
*/
          __pyx_t_5 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2469, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2469, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_7 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_6))) {
            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
            assert(__pyx_t_5);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
            __pyx_t_7 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Stop_event_detected_breaking_loo};
            __pyx_t_34 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2469, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_34);
          }
          __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;

          /* "ws_package/controllers/activity_controller.py":2470
 *                 if stop_event.is_set():
 *                     logger.info("Stop event detected - breaking loop before creating interval")
 *                     break             # <<<<<<<<<<<<<<
 *                 # Check if timer was stopped due to limit and date hasn't changed
 *                 today = datetime.datetime.now().date()
*/
          goto __pyx_L268_try_break;

          /* "ws_package/controllers/activity_controller.py":2468
 * 
 *                 # Check if we should stop BEFORE creating interval (prevent creating interval after stop)
 *                 if stop_event.is_set():             # <<<<<<<<<<<<<<
 *                     logger.info("Stop event detected - breaking loop before creating interval")
 *                     break
*/
        }

        /* "ws_package/controllers/activity_controller.py":2472
 *                     break
 *                 # Check if timer was stopped due to limit and date hasn't changed
 *                 today = datetime.datetime.now().date()             # <<<<<<<<<<<<<<
 *                 if self.limit_stopped_date is not None and self.limit_stopped_date == today:
 *                     # Timer was stopped due to limit today - keep it stopped
*/
        __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2472, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_33);
        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2472, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
        __pyx_t_1 = __pyx_t_15;
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_7 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2472, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __pyx_t_6 = __pyx_t_5;
        __Pyx_INCREF(__pyx_t_6);
        __pyx_t_7 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
          __pyx_t_34 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_date, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2472, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_34);
        }
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_today);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_today, __pyx_t_34);
        __Pyx_GIVEREF(__pyx_t_34);
        __pyx_t_34 = 0;

        /* "ws_package/controllers/activity_controller.py":2473
 *                 # Check if timer was stopped due to limit and date hasn't changed
 *                 today = datetime.datetime.now().date()
 *                 if self.limit_stopped_date is not None and self.limit_stopped_date == today:             # <<<<<<<<<<<<<<
 *                     # Timer was stopped due to limit today - keep it stopped
 *                     self.status = False
*/
        __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_stopped_date); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2473, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_34);
        __pyx_t_8 = (__pyx_t_34 != Py_None);
        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
        if (__pyx_t_8) {
        } else {
          __pyx_t_9 = __pyx_t_8;
          goto __pyx_L419_bool_binop_done;
        }
        __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_stopped_date); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2473, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_34);
        __pyx_t_5 = PyObject_RichCompare(__pyx_t_34, __pyx_cur_scope->__pyx_v_today, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2473, __pyx_L263_error)
        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
        __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2473, __pyx_L263_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_9 = __pyx_t_8;
        __pyx_L419_bool_binop_done:;
        if (__pyx_t_9) {

          /* "ws_package/controllers/activity_controller.py":2475
 *                 if self.limit_stopped_date is not None and self.limit_stopped_date == today:
 *                     # Timer was stopped due to limit today - keep it stopped
 *                     self.status = False             # <<<<<<<<<<<<<<
 *                     logger.debug("Timer remains stopped due to limit exceeded (stopped on %s)", self.limit_stopped_date)
 * 
*/
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status, Py_False) < (0)) __PYX_ERR(0, 2475, __pyx_L263_error)

          /* "ws_package/controllers/activity_controller.py":2476
 *                     # Timer was stopped due to limit today - keep it stopped
 *                     self.status = False
 *                     logger.debug("Timer remains stopped due to limit exceeded (stopped on %s)", self.limit_stopped_date)             # <<<<<<<<<<<<<<
 * 
 *                 if self.status == True:
*/
          __pyx_t_34 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2476, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2476, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_stopped_date); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2476, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_7 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_15))) {
            __pyx_t_34 = PyMethod_GET_SELF(__pyx_t_15);
            assert(__pyx_t_34);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
            __Pyx_INCREF(__pyx_t_34);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
            __pyx_t_7 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_34, __pyx_mstate_global->__pyx_kp_u_Timer_remains_stopped_due_to_lim, __pyx_t_6};
            __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2476, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_5);
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":2473
 *                 # Check if timer was stopped due to limit and date hasn't changed
 *                 today = datetime.datetime.now().date()
 *                 if self.limit_stopped_date is not None and self.limit_stopped_date == today:             # <<<<<<<<<<<<<<
 *                     # Timer was stopped due to limit today - keep it stopped
 *                     self.status = False
*/
        }

        /* "ws_package/controllers/activity_controller.py":2478
 *                     logger.debug("Timer remains stopped due to limit exceeded (stopped on %s)", self.limit_stopped_date)
 * 
 *                 if self.status == True:             # <<<<<<<<<<<<<<
 *                     await precise_sleep(3)  # Avoid boundary_time()==0 immediate re-loop at exact slot edges
 *                     # Sleep until the end of the slot we are tracking (main_end_date / end_date),
*/
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2478, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_15 = PyObject_RichCompare(__pyx_t_5, Py_True, Py_EQ); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2478, __pyx_L263_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2478, __pyx_L263_error)
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        if (__pyx_t_9) {

          /* "ws_package/controllers/activity_controller.py":2479
 * 
 *                 if self.status == True:
 *                     await precise_sleep(3)  # Avoid boundary_time()==0 immediate re-loop at exact slot edges             # <<<<<<<<<<<<<<
 *                     # Sleep until the end of the slot we are tracking (main_end_date / end_date),
 *                     # not the next calendar boundary  slow loop iterations must not skip a full slot.
*/
          __pyx_t_5 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_precise_sleep); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2479, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_7 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_6))) {
            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
            assert(__pyx_t_5);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
            __pyx_t_7 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_int_3};
            __pyx_t_15 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2479, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_15);
          }
          __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_15, &__pyx_r);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (likely(__pyx_t_26 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_11);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
            __Pyx_XGIVEREF(__pyx_t_12);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
            __Pyx_XGIVEREF(__pyx_t_13);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 28;
            return __pyx_r;
            __pyx_L422_resume_from_await:;
            __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_11);
            __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_12);
            __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_13);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2479, __pyx_L263_error)
          } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_DECREF(__pyx_r); __pyx_r = 0;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 2479, __pyx_L263_error)
          }

          /* "ws_package/controllers/activity_controller.py":2482
 *                     # Sleep until the end of the slot we are tracking (main_end_date / end_date),
 *                     # not the next calendar boundary  slow loop iterations must not skip a full slot.
 *                     slot_end = getattr(self, "main_end_date", None) or end_date             # <<<<<<<<<<<<<<
 *                     sleep_seconds = self._seconds_until_datetime(slot_end)
 *                     logger.debug(
*/
          __pyx_t_6 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_6);
          __pyx_t_5 = __Pyx_GetAttr3(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_main_end_date, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2482, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2482, __pyx_L263_error)
          if (!__pyx_t_9) {
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          } else {
            __Pyx_INCREF(__pyx_t_5);
            __pyx_t_15 = __pyx_t_5;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            goto __pyx_L423_bool_binop_done;
          }
          __Pyx_INCREF(__pyx_cur_scope->__pyx_v_end_date);
          __pyx_t_15 = __pyx_cur_scope->__pyx_v_end_date;
          __pyx_L423_bool_binop_done:;
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_slot_end);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_slot_end, __pyx_t_15);
          __Pyx_GIVEREF(__pyx_t_15);
          __pyx_t_15 = 0;

          /* "ws_package/controllers/activity_controller.py":2483
 *                     # not the next calendar boundary  slow loop iterations must not skip a full slot.
 *                     slot_end = getattr(self, "main_end_date", None) or end_date
 *                     sleep_seconds = self._seconds_until_datetime(slot_end)             # <<<<<<<<<<<<<<
 *                     logger.debug(
 *                         "Sleeping %.1fs until interval end %s (slot %s to %s)",
*/
          __pyx_t_5 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_5);
          __pyx_t_7 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_slot_end};
            __pyx_t_15 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_seconds_until_datetime, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2483, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_15);
          }
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_sleep_seconds);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_sleep_seconds, __pyx_t_15);
          __Pyx_GIVEREF(__pyx_t_15);
          __pyx_t_15 = 0;

          /* "ws_package/controllers/activity_controller.py":2484
 *                     slot_end = getattr(self, "main_end_date", None) or end_date
 *                     sleep_seconds = self._seconds_until_datetime(slot_end)
 *                     logger.debug(             # <<<<<<<<<<<<<<
 *                         "Sleeping %.1fs until interval end %s (slot %s to %s)",
 *                         sleep_seconds,
*/
          __pyx_t_5 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2484, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2484, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_34);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

          /* "ws_package/controllers/activity_controller.py":2489
 *                         slot_end,
 *                         start_date,
 *                         end_date,             # <<<<<<<<<<<<<<
 *                     )
 *                     if sleep_seconds > 0:
*/
          __pyx_t_7 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_34))) {
            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_34);
            assert(__pyx_t_5);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_34);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_34, __pyx__function);
            __pyx_t_7 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[6] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Sleeping_1fs_until_interval_end, __pyx_cur_scope->__pyx_v_sleep_seconds, __pyx_cur_scope->__pyx_v_slot_end, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
            __pyx_t_15 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_34, __pyx_callargs+__pyx_t_7, (6-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
            if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2484, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_15);
          }
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

          /* "ws_package/controllers/activity_controller.py":2491
 *                         end_date,
 *                     )
 *                     if sleep_seconds > 0:             # <<<<<<<<<<<<<<
 *                         await precise_sleep(sleep_seconds, stop_event)
 *                 else:
*/
          __pyx_t_15 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_sleep_seconds, __pyx_mstate_global->__pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2491, __pyx_L263_error)
          __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2491, __pyx_L263_error)
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (__pyx_t_9) {

            /* "ws_package/controllers/activity_controller.py":2492
 *                     )
 *                     if sleep_seconds > 0:
 *                         await precise_sleep(sleep_seconds, stop_event)             # <<<<<<<<<<<<<<
 *                 else:
 *                     # Break 4-hour sleep into 10-minute chunks for better stop_event responsiveness
*/
            __pyx_t_34 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_precise_sleep); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2492, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_7 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_5))) {
              __pyx_t_34 = PyMethod_GET_SELF(__pyx_t_5);
              assert(__pyx_t_34);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
              __Pyx_INCREF(__pyx_t_34);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
              __pyx_t_7 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_34, __pyx_cur_scope->__pyx_v_sleep_seconds, __pyx_cur_scope->__pyx_v_stop_event};
              __pyx_t_15 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2492, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_15);
            }
            __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_15, &__pyx_r);
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            if (likely(__pyx_t_26 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_11);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
              __Pyx_XGIVEREF(__pyx_t_12);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
              __Pyx_XGIVEREF(__pyx_t_13);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 29;
              return __pyx_r;
              __pyx_L426_resume_from_await:;
              __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_11);
              __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_12);
              __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_13);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2492, __pyx_L263_error)
            } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_DECREF(__pyx_r); __pyx_r = 0;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 2492, __pyx_L263_error)
            }

            /* "ws_package/controllers/activity_controller.py":2491
 *                         end_date,
 *                     )
 *                     if sleep_seconds > 0:             # <<<<<<<<<<<<<<
 *                         await precise_sleep(sleep_seconds, stop_event)
 *                 else:
*/
          }

          /* "ws_package/controllers/activity_controller.py":2478
 *                     logger.debug("Timer remains stopped due to limit exceeded (stopped on %s)", self.limit_stopped_date)
 * 
 *                 if self.status == True:             # <<<<<<<<<<<<<<
 *                     await precise_sleep(3)  # Avoid boundary_time()==0 immediate re-loop at exact slot edges
 *                     # Sleep until the end of the slot we are tracking (main_end_date / end_date),
*/
          goto __pyx_L421;
        }

        /* "ws_package/controllers/activity_controller.py":2496
 *                     # Break 4-hour sleep into 10-minute chunks for better stop_event responsiveness
 *                     # This prevents threads from appearing dead during long idle periods
 *                     total_sleep = 14400  # 4 hours             # <<<<<<<<<<<<<<
 *                     chunk_duration = 600  # 10 minutes per chunk
 *                     chunks = total_sleep // chunk_duration
*/
        /*else*/ {
          __Pyx_INCREF(__pyx_mstate_global->__pyx_int_14400);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_total_sleep);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_total_sleep, __pyx_mstate_global->__pyx_int_14400);
          __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_14400);

          /* "ws_package/controllers/activity_controller.py":2497
 *                     # This prevents threads from appearing dead during long idle periods
 *                     total_sleep = 14400  # 4 hours
 *                     chunk_duration = 600  # 10 minutes per chunk             # <<<<<<<<<<<<<<
 *                     chunks = total_sleep // chunk_duration
 *                     for _ in range(chunks):
*/
          __Pyx_INCREF(__pyx_mstate_global->__pyx_int_600);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_chunk_duration);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_chunk_duration, __pyx_mstate_global->__pyx_int_600);
          __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_600);

          /* "ws_package/controllers/activity_controller.py":2498
 *                     total_sleep = 14400  # 4 hours
 *                     chunk_duration = 600  # 10 minutes per chunk
 *                     chunks = total_sleep // chunk_duration             # <<<<<<<<<<<<<<
 *                     for _ in range(chunks):
 *                         if stop_event.is_set():
*/
          __pyx_t_15 = PyNumber_FloorDivide(__pyx_cur_scope->__pyx_v_total_sleep, __pyx_cur_scope->__pyx_v_chunk_duration); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2498, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_chunks);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_chunks, __pyx_t_15);
          __Pyx_GIVEREF(__pyx_t_15);
          __pyx_t_15 = 0;

          /* "ws_package/controllers/activity_controller.py":2499
 *                     chunk_duration = 600  # 10 minutes per chunk
 *                     chunks = total_sleep // chunk_duration
 *                     for _ in range(chunks):             # <<<<<<<<<<<<<<
 *                         if stop_event.is_set():
 *                             break
*/
          __pyx_t_5 = NULL;
          __pyx_t_7 = 1;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_chunks};
            __pyx_t_15 = __Pyx_PyObject_FastCall((PyObject*)(&PyRange_Type), __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2499, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_15);
          }
          __pyx_t_5 = PyObject_GetIter(__pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2499, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_54 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); if (unlikely(!__pyx_t_54)) __PYX_ERR(0, 2499, __pyx_L263_error)
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          for (;;) {
            {
              __pyx_t_15 = __pyx_t_54(__pyx_t_5);
              if (unlikely(!__pyx_t_15)) {
                PyObject* exc_type = PyErr_Occurred();
                if (exc_type) {
                  if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 2499, __pyx_L263_error)
                  PyErr_Clear();
                }
                break;
              }
            }
            __Pyx_GOTREF(__pyx_t_15);
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v__);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v__, __pyx_t_15);
            __Pyx_GIVEREF(__pyx_t_15);
            __pyx_t_15 = 0;

            /* "ws_package/controllers/activity_controller.py":2500
 *                     chunks = total_sleep // chunk_duration
 *                     for _ in range(chunks):
 *                         if stop_event.is_set():             # <<<<<<<<<<<<<<
 *                             break
 *                         await precise_sleep(chunk_duration, stop_event)
*/
            __pyx_t_34 = __pyx_cur_scope->__pyx_v_stop_event;
            __Pyx_INCREF(__pyx_t_34);
            __pyx_t_7 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_34, NULL};
              __pyx_t_15 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_set, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
              if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2500, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_15);
            }
            __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2500, __pyx_L263_error)
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            if (__pyx_t_9) {

              /* "ws_package/controllers/activity_controller.py":2501
 *                     for _ in range(chunks):
 *                         if stop_event.is_set():
 *                             break             # <<<<<<<<<<<<<<
 *                         await precise_sleep(chunk_duration, stop_event)
 * 
*/
              goto __pyx_L428_break;

              /* "ws_package/controllers/activity_controller.py":2500
 *                     chunks = total_sleep // chunk_duration
 *                     for _ in range(chunks):
 *                         if stop_event.is_set():             # <<<<<<<<<<<<<<
 *                             break
 *                         await precise_sleep(chunk_duration, stop_event)
*/
            }

            /* "ws_package/controllers/activity_controller.py":2502
 *                         if stop_event.is_set():
 *                             break
 *                         await precise_sleep(chunk_duration, stop_event)             # <<<<<<<<<<<<<<
 * 
 *                 # Check again after sleep - if stop was requested, don't create interval
*/
            __pyx_t_34 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_precise_sleep); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2502, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_7 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_6))) {
              __pyx_t_34 = PyMethod_GET_SELF(__pyx_t_6);
              assert(__pyx_t_34);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
              __Pyx_INCREF(__pyx_t_34);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
              __pyx_t_7 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_34, __pyx_cur_scope->__pyx_v_chunk_duration, __pyx_cur_scope->__pyx_v_stop_event};
              __pyx_t_15 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2502, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_15);
            }
            __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_15, &__pyx_r);
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            if (likely(__pyx_t_26 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_5);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_5;
              __Pyx_XGIVEREF(__pyx_t_11);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_11;
              __Pyx_XGIVEREF(__pyx_t_12);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_12;
              __Pyx_XGIVEREF(__pyx_t_13);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_13;
              __pyx_cur_scope->__pyx_t_15 = __pyx_t_54;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 30;
              return __pyx_r;
              __pyx_L430_resume_from_await:;
              __pyx_t_5 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_5);
              __pyx_t_11 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_11);
              __pyx_t_12 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_12);
              __pyx_t_13 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_13);
              __pyx_t_54 = __pyx_cur_scope->__pyx_t_15;
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2502, __pyx_L263_error)
            } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_DECREF(__pyx_r); __pyx_r = 0;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 2502, __pyx_L263_error)
            }

            /* "ws_package/controllers/activity_controller.py":2499
 *                     chunk_duration = 600  # 10 minutes per chunk
 *                     chunks = total_sleep // chunk_duration
 *                     for _ in range(chunks):             # <<<<<<<<<<<<<<
 *                         if stop_event.is_set():
 *                             break
*/
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          goto __pyx_L431_for_end;
          __pyx_L428_break:;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          goto __pyx_L431_for_end;
          __pyx_L431_for_end:;
        }
        __pyx_L421:;

        /* "ws_package/controllers/activity_controller.py":2505
 * 
 *                 # Check again after sleep - if stop was requested, don't create interval
 *                 if stop_event.is_set():             # <<<<<<<<<<<<<<
 *                     logger.info("Stop event detected after sleep - breaking loop before creating interval")
 *                     break
*/
        __pyx_t_15 = __pyx_cur_scope->__pyx_v_stop_event;
        __Pyx_INCREF(__pyx_t_15);
        __pyx_t_7 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL};
          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_set, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2505, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2505, __pyx_L263_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (__pyx_t_9) {

          /* "ws_package/controllers/activity_controller.py":2506
 *                 # Check again after sleep - if stop was requested, don't create interval
 *                 if stop_event.is_set():
 *                     logger.info("Stop event detected after sleep - breaking loop before creating interval")             # <<<<<<<<<<<<<<
 *                     break
 *                 # Reset limit_stopped_date if date changed (new day started)
*/
          __pyx_t_15 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2506, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2506, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_34);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_7 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_34))) {
            __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_34);
            assert(__pyx_t_15);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_34);
            __Pyx_INCREF(__pyx_t_15);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_34, __pyx__function);
            __pyx_t_7 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Stop_event_detected_after_sleep};
            __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_34, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2506, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_5);
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":2507
 *                 if stop_event.is_set():
 *                     logger.info("Stop event detected after sleep - breaking loop before creating interval")
 *                     break             # <<<<<<<<<<<<<<
 *                 # Reset limit_stopped_date if date changed (new day started)
 *                 if self.limit_stopped_date is not None and self.limit_stopped_date != today:
*/
          goto __pyx_L268_try_break;

          /* "ws_package/controllers/activity_controller.py":2505
 * 
 *                 # Check again after sleep - if stop was requested, don't create interval
 *                 if stop_event.is_set():             # <<<<<<<<<<<<<<
 *                     logger.info("Stop event detected after sleep - breaking loop before creating interval")
 *                     break
*/
        }

        /* "ws_package/controllers/activity_controller.py":2509
 *                     break
 *                 # Reset limit_stopped_date if date changed (new day started)
 *                 if self.limit_stopped_date is not None and self.limit_stopped_date != today:             # <<<<<<<<<<<<<<
 *                     logger.info("Date changed from %s to %s - resetting limit stop status", self.limit_stopped_date, today)
 *                     self.limit_stopped_date = None
*/
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_stopped_date); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2509, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_8 = (__pyx_t_5 != Py_None);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (__pyx_t_8) {
        } else {
          __pyx_t_9 = __pyx_t_8;
          goto __pyx_L434_bool_binop_done;
        }
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_stopped_date); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2509, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_34 = PyObject_RichCompare(__pyx_t_5, __pyx_cur_scope->__pyx_v_today, Py_NE); __Pyx_XGOTREF(__pyx_t_34); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2509, __pyx_L263_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_34); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2509, __pyx_L263_error)
        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
        __pyx_t_9 = __pyx_t_8;
        __pyx_L434_bool_binop_done:;
        if (__pyx_t_9) {

          /* "ws_package/controllers/activity_controller.py":2510
 *                 # Reset limit_stopped_date if date changed (new day started)
 *                 if self.limit_stopped_date is not None and self.limit_stopped_date != today:
 *                     logger.info("Date changed from %s to %s - resetting limit stop status", self.limit_stopped_date, today)             # <<<<<<<<<<<<<<
 *                     self.limit_stopped_date = None
 *                     # Don't automatically restart - let status_controller handle it
*/
          __pyx_t_5 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2510, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_15);
          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2510, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_stopped_date); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2510, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_15);
          __pyx_t_7 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_6))) {
            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
            assert(__pyx_t_5);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
            __pyx_t_7 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[4] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Date_changed_from_s_to_s_resetti, __pyx_t_15, __pyx_cur_scope->__pyx_v_today};
            __pyx_t_34 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2510, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_34);
          }
          __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;

          /* "ws_package/controllers/activity_controller.py":2511
 *                 if self.limit_stopped_date is not None and self.limit_stopped_date != today:
 *                     logger.info("Date changed from %s to %s - resetting limit stop status", self.limit_stopped_date, today)
 *                     self.limit_stopped_date = None             # <<<<<<<<<<<<<<
 *                     # Don't automatically restart - let status_controller handle it
 * 
*/
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_limit_stopped_date, Py_None) < (0)) __PYX_ERR(0, 2511, __pyx_L263_error)

          /* "ws_package/controllers/activity_controller.py":2509
 *                     break
 *                 # Reset limit_stopped_date if date changed (new day started)
 *                 if self.limit_stopped_date is not None and self.limit_stopped_date != today:             # <<<<<<<<<<<<<<
 *                     logger.info("Date changed from %s to %s - resetting limit stop status", self.limit_stopped_date, today)
 *                     self.limit_stopped_date = None
*/
        }

        /* "ws_package/controllers/activity_controller.py":2515
 * 
 *                 # Initialize defaults so interval saving can proceed even if activity fetch fails
 *                 activityLevel = {'mouse': '0.0', 'average': '0.0', 'keyboard': '0.0'}             # <<<<<<<<<<<<<<
 *                 # Save uploadable intervals only inside the fixed-mode window (in_range).
 *                 # Out-of-range slots use save_first_activity_log (is_uploaded=True) and are not sent.
*/
        __pyx_t_34 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2515, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_34);
        if (PyDict_SetItem(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_mouse, __pyx_mstate_global->__pyx_kp_u_0_0) < (0)) __PYX_ERR(0, 2515, __pyx_L263_error)
        if (PyDict_SetItem(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_average, __pyx_mstate_global->__pyx_kp_u_0_0) < (0)) __PYX_ERR(0, 2515, __pyx_L263_error)
        if (PyDict_SetItem(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_keyboard, __pyx_mstate_global->__pyx_kp_u_0_0) < (0)) __PYX_ERR(0, 2515, __pyx_L263_error)
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_activityLevel);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_activityLevel, __pyx_t_34);
        __Pyx_GIVEREF(__pyx_t_34);
        __pyx_t_34 = 0;

        /* "ws_package/controllers/activity_controller.py":2520
 *                 # CRITICAL: Read break_id at the time of saving to ensure current value is used
 *                 # break_id will be saved in is_break field (0 if break_id is null/0)
 *                 current_break_id = getattr(self, 'break_id', 0) or 0  # Default to 0 if not available             # <<<<<<<<<<<<<<
 * 
 *                 # DEBUG: Log break state when saving intervals
*/
        __pyx_t_6 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_6);
        __pyx_t_15 = __Pyx_GetAttr3(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_break_id, __pyx_mstate_global->__pyx_int_0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2520, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2520, __pyx_L263_error)
        if (!__pyx_t_9) {
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        } else {
          __Pyx_INCREF(__pyx_t_15);
          __pyx_t_34 = __pyx_t_15;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          goto __pyx_L436_bool_binop_done;
        }
        __pyx_t_15 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2520, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_34 = __pyx_t_15;
        __pyx_t_15 = 0;
        __pyx_L436_bool_binop_done:;
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_current_break_id);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_current_break_id, __pyx_t_34);
        __Pyx_GIVEREF(__pyx_t_34);
        __pyx_t_34 = 0;

        /* "ws_package/controllers/activity_controller.py":2523
 * 
 *                 # DEBUG: Log break state when saving intervals
 *                 logger.info("[DEBUG][Break State] Saving interval - break_id=%s, is_break=%s, status=%s, start_date=%s, end_date=%s", current_break_id, getattr(self, 'is_break', 0), self.status, start_date, end_date)             # <<<<<<<<<<<<<<
 * 
 *                 in_range = await self.inrange(start_date, end_date)
*/
        __pyx_t_15 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2523, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2523, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_6);
        __pyx_t_1 = __Pyx_GetAttr3(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_is_break, __pyx_mstate_global->__pyx_int_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2523, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2523, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5);
          assert(__pyx_t_15);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_15);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[7] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_DEBUG_Break_State_Saving_interv, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_t_1, __pyx_t_6, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
          __pyx_t_34 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (7-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2523, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_34);
        }
        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;

        /* "ws_package/controllers/activity_controller.py":2525
 *                 logger.info("[DEBUG][Break State] Saving interval - break_id=%s, is_break=%s, status=%s, start_date=%s, end_date=%s", current_break_id, getattr(self, 'is_break', 0), self.status, start_date, end_date)
 * 
 *                 in_range = await self.inrange(start_date, end_date)             # <<<<<<<<<<<<<<
 *                 has_any_activity = False
 * 
*/
        __pyx_t_5 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_5);
        __pyx_t_7 = 0;
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
          __pyx_t_34 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_inrange, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2525, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_34);
        }
        __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_34, &__pyx_r);
        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
        if (likely(__pyx_t_26 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_11);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
          __Pyx_XGIVEREF(__pyx_t_12);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
          __Pyx_XGIVEREF(__pyx_t_13);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 31;
          return __pyx_r;
          __pyx_L438_resume_from_await:;
          __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_11);
          __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_12);
          __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_13);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2525, __pyx_L263_error)
          __pyx_t_34 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_34);
        } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __pyx_t_34 = __pyx_r; __pyx_r = NULL;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 2525, __pyx_L263_error)
        }
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_in_range);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_in_range, __pyx_t_34);
        __Pyx_GIVEREF(__pyx_t_34);
        __pyx_t_34 = 0;

        /* "ws_package/controllers/activity_controller.py":2526
 * 
 *                 in_range = await self.inrange(start_date, end_date)
 *                 has_any_activity = False             # <<<<<<<<<<<<<<
 * 
 *                 # Gather activity data; errors here should not block interval creation
*/
        __Pyx_INCREF(Py_False);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_has_any_activity);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_has_any_activity, Py_False);
        __Pyx_GIVEREF(Py_False);

        /* "ws_package/controllers/activity_controller.py":2529
 * 
 *                 # Gather activity data; errors here should not block interval creation
 *                 try:             # <<<<<<<<<<<<<<
 *                     await self.midnight(user_entity, self.last_count)
 * 
*/
        {
          __Pyx_ExceptionSave(&__pyx_t_31, &__pyx_t_23, &__pyx_t_39);
          __Pyx_XGOTREF(__pyx_t_31);
          __Pyx_XGOTREF(__pyx_t_23);
          __Pyx_XGOTREF(__pyx_t_39);
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":2530
 *                 # Gather activity data; errors here should not block interval creation
 *                 try:
 *                     await self.midnight(user_entity, self.last_count)             # <<<<<<<<<<<<<<
 * 
 *                     logger.info("Device Thread")
*/
            __pyx_t_5 = __pyx_cur_scope->__pyx_v_self;
            __Pyx_INCREF(__pyx_t_5);
            __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2530, __pyx_L439_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_7 = 0;
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_user_entity, __pyx_t_6};
              __pyx_t_34 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_midnight, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2530, __pyx_L439_error)
              __Pyx_GOTREF(__pyx_t_34);
            }
            __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_34, &__pyx_r);
            __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
            if (likely(__pyx_t_26 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_11);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
              __Pyx_XGIVEREF(__pyx_t_12);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
              __Pyx_XGIVEREF(__pyx_t_13);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
              __Pyx_XGIVEREF(__pyx_t_23);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_23;
              __Pyx_XGIVEREF(__pyx_t_31);
              __pyx_cur_scope->__pyx_t_4 = __pyx_t_31;
              __Pyx_XGIVEREF(__pyx_t_39);
              __pyx_cur_scope->__pyx_t_5 = __pyx_t_39;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 32;
              return __pyx_r;
              __pyx_L447_resume_from_await:;
              __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_11);
              __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_12);
              __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_13);
              __pyx_t_23 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_23);
              __pyx_t_31 = __pyx_cur_scope->__pyx_t_4;
              __pyx_cur_scope->__pyx_t_4 = 0;
              __Pyx_XGOTREF(__pyx_t_31);
              __pyx_t_39 = __pyx_cur_scope->__pyx_t_5;
              __pyx_cur_scope->__pyx_t_5 = 0;
              __Pyx_XGOTREF(__pyx_t_39);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2530, __pyx_L439_error)
            } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_DECREF(__pyx_r); __pyx_r = 0;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 2530, __pyx_L439_error)
            }

            /* "ws_package/controllers/activity_controller.py":2532
 *                     await self.midnight(user_entity, self.last_count)
 * 
 *                     logger.info("Device Thread")             # <<<<<<<<<<<<<<
 *                     # self.log_system_resources()
 * 
*/
            __pyx_t_6 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2532, __pyx_L439_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2532, __pyx_L439_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_t_7 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_1))) {
              __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
              assert(__pyx_t_6);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
              __Pyx_INCREF(__pyx_t_6);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
              __pyx_t_7 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Device_Thread};
              __pyx_t_34 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2532, __pyx_L439_error)
              __Pyx_GOTREF(__pyx_t_34);
            }
            __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;

            /* "ws_package/controllers/activity_controller.py":2536
 * 
 *                     # Get actual activity level from database instead of hardcoded 0%
 *                     activityLevel = await self.get_activity_level_from_db(start_date, end_date)             # <<<<<<<<<<<<<<
 * 
 *                     # Check if there was ANY activity during the interval
*/
            __pyx_t_1 = __pyx_cur_scope->__pyx_v_self;
            __Pyx_INCREF(__pyx_t_1);
            __pyx_t_7 = 0;
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
              __pyx_t_34 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_activity_level_from_db, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2536, __pyx_L439_error)
              __Pyx_GOTREF(__pyx_t_34);
            }
            __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_34, &__pyx_r);
            __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
            if (likely(__pyx_t_26 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_11);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
              __Pyx_XGIVEREF(__pyx_t_12);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
              __Pyx_XGIVEREF(__pyx_t_13);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
              __Pyx_XGIVEREF(__pyx_t_23);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_23;
              __Pyx_XGIVEREF(__pyx_t_31);
              __pyx_cur_scope->__pyx_t_4 = __pyx_t_31;
              __Pyx_XGIVEREF(__pyx_t_39);
              __pyx_cur_scope->__pyx_t_5 = __pyx_t_39;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 33;
              return __pyx_r;
              __pyx_L448_resume_from_await:;
              __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_11);
              __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_12);
              __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_13);
              __pyx_t_23 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_23);
              __pyx_t_31 = __pyx_cur_scope->__pyx_t_4;
              __pyx_cur_scope->__pyx_t_4 = 0;
              __Pyx_XGOTREF(__pyx_t_31);
              __pyx_t_39 = __pyx_cur_scope->__pyx_t_5;
              __pyx_cur_scope->__pyx_t_5 = 0;
              __Pyx_XGOTREF(__pyx_t_39);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2536, __pyx_L439_error)
              __pyx_t_34 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_34);
            } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __pyx_t_34 = __pyx_r; __pyx_r = NULL;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 2536, __pyx_L439_error)
            }
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_activityLevel);
            __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_activityLevel, __pyx_t_34);
            __Pyx_GIVEREF(__pyx_t_34);
            __pyx_t_34 = 0;

            /* "ws_package/controllers/activity_controller.py":2540
 *                     # Check if there was ANY activity during the interval
 *                     # If user worked even a few seconds, mark interval as active (not idle)
 *                     keyboard_activity = float(activityLevel.get('keyboard', 0) or 0)             # <<<<<<<<<<<<<<
 *                     mouse_activity = float(activityLevel.get('mouse', 0) or 0)
 *                     average_activity = float(activityLevel.get('average', 0) or 0)
*/
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activityLevel, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2540, __pyx_L439_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_mstate_global->__pyx_tuple[15], NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2540, __pyx_L439_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2540, __pyx_L439_error)
            if (!__pyx_t_9) {
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            } else {
              __Pyx_INCREF(__pyx_t_6);
              __pyx_t_34 = __pyx_t_6;
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              goto __pyx_L449_bool_binop_done;
            }
            __pyx_t_6 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2540, __pyx_L439_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_34 = __pyx_t_6;
            __pyx_t_6 = 0;
            __pyx_L449_bool_binop_done:;
            __pyx_t_52 = __Pyx_PyObject_AsDouble(__pyx_t_34); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_52, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 2540, __pyx_L439_error)
            __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
            __pyx_cur_scope->__pyx_v_keyboard_activity = __pyx_t_52;

            /* "ws_package/controllers/activity_controller.py":2541
 *                     # If user worked even a few seconds, mark interval as active (not idle)
 *                     keyboard_activity = float(activityLevel.get('keyboard', 0) or 0)
 *                     mouse_activity = float(activityLevel.get('mouse', 0) or 0)             # <<<<<<<<<<<<<<
 *                     average_activity = float(activityLevel.get('average', 0) or 0)
 * 
*/
            __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activityLevel, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2541, __pyx_L439_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_mstate_global->__pyx_tuple[16], NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2541, __pyx_L439_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2541, __pyx_L439_error)
            if (!__pyx_t_9) {
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            } else {
              __Pyx_INCREF(__pyx_t_1);
              __pyx_t_34 = __pyx_t_1;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              goto __pyx_L451_bool_binop_done;
            }
            __pyx_t_1 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2541, __pyx_L439_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_34 = __pyx_t_1;
            __pyx_t_1 = 0;
            __pyx_L451_bool_binop_done:;
            __pyx_t_52 = __Pyx_PyObject_AsDouble(__pyx_t_34); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_52, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 2541, __pyx_L439_error)
            __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
            __pyx_cur_scope->__pyx_v_mouse_activity = __pyx_t_52;

            /* "ws_package/controllers/activity_controller.py":2542
 *                     keyboard_activity = float(activityLevel.get('keyboard', 0) or 0)
 *                     mouse_activity = float(activityLevel.get('mouse', 0) or 0)
 *                     average_activity = float(activityLevel.get('average', 0) or 0)             # <<<<<<<<<<<<<<
 * 
 *                     # Check if there was ANY activity (even minimal)
*/
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activityLevel, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2542, __pyx_L439_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_mstate_global->__pyx_tuple[17], NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2542, __pyx_L439_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2542, __pyx_L439_error)
            if (!__pyx_t_9) {
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            } else {
              __Pyx_INCREF(__pyx_t_6);
              __pyx_t_34 = __pyx_t_6;
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              goto __pyx_L453_bool_binop_done;
            }
            __pyx_t_6 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2542, __pyx_L439_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_34 = __pyx_t_6;
            __pyx_t_6 = 0;
            __pyx_L453_bool_binop_done:;
            __pyx_t_52 = __Pyx_PyObject_AsDouble(__pyx_t_34); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_52, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 2542, __pyx_L439_error)
            __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
            __pyx_cur_scope->__pyx_v_average_activity = __pyx_t_52;

            /* "ws_package/controllers/activity_controller.py":2545
 * 
 *                     # Check if there was ANY activity (even minimal)
 *                     has_any_activity = keyboard_activity > 0 or mouse_activity > 0 or average_activity > 0             # <<<<<<<<<<<<<<
 * 
 *                     if not has_any_activity:
*/
            __pyx_t_9 = (__pyx_cur_scope->__pyx_v_keyboard_activity > 0.0);
            if (!__pyx_t_9) {
            } else {
              __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2545, __pyx_L439_error)
              __Pyx_GOTREF(__pyx_t_6);
              __pyx_t_34 = __pyx_t_6;
              __pyx_t_6 = 0;
              goto __pyx_L455_bool_binop_done;
            }
            __pyx_t_9 = (__pyx_cur_scope->__pyx_v_mouse_activity > 0.0);
            if (!__pyx_t_9) {
            } else {
              __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2545, __pyx_L439_error)
              __Pyx_GOTREF(__pyx_t_6);
              __pyx_t_34 = __pyx_t_6;
              __pyx_t_6 = 0;
              goto __pyx_L455_bool_binop_done;
            }
            __pyx_t_9 = (__pyx_cur_scope->__pyx_v_average_activity > 0.0);
            __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2545, __pyx_L439_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_34 = __pyx_t_6;
            __pyx_t_6 = 0;
            __pyx_L455_bool_binop_done:;
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_has_any_activity);
            __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_has_any_activity, __pyx_t_34);
            __Pyx_GIVEREF(__pyx_t_34);
            __pyx_t_34 = 0;

            /* "ws_package/controllers/activity_controller.py":2547
 *                     has_any_activity = keyboard_activity > 0 or mouse_activity > 0 or average_activity > 0
 * 
 *                     if not has_any_activity:             # <<<<<<<<<<<<<<
 *                         # Double-check: look for app monitor activity during this interval
 *                         has_any_activity = await self._has_any_activity_in_interval(
*/
            __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_has_any_activity); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2547, __pyx_L439_error)
            __pyx_t_8 = (!__pyx_t_9);
            if (__pyx_t_8) {

              /* "ws_package/controllers/activity_controller.py":2549
 *                     if not has_any_activity:
 *                         # Double-check: look for app monitor activity during this interval
 *                         has_any_activity = await self._has_any_activity_in_interval(             # <<<<<<<<<<<<<<
 *                             start_date, end_date, self.last_count + 1
 *                         )
*/
              __pyx_t_6 = __pyx_cur_scope->__pyx_v_self;
              __Pyx_INCREF(__pyx_t_6);

              /* "ws_package/controllers/activity_controller.py":2550
 *                         # Double-check: look for app monitor activity during this interval
 *                         has_any_activity = await self._has_any_activity_in_interval(
 *                             start_date, end_date, self.last_count + 1             # <<<<<<<<<<<<<<
 *                         )
 * 
*/
              __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2550, __pyx_L439_error)
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_t_5 = __Pyx_PyLong_AddObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2550, __pyx_L439_error)
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __pyx_t_7 = 0;
              {
                PyObject *__pyx_callargs[4] = {__pyx_t_6, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date, __pyx_t_5};
                __pyx_t_34 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_has_any_activity_in_interval, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2549, __pyx_L439_error)
                __Pyx_GOTREF(__pyx_t_34);
              }
              __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_34, &__pyx_r);
              __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
              if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_XGIVEREF(__pyx_t_11);
                __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                __Pyx_XGIVEREF(__pyx_t_12);
                __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                __Pyx_XGIVEREF(__pyx_t_13);
                __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                __Pyx_XGIVEREF(__pyx_t_23);
                __pyx_cur_scope->__pyx_t_3 = __pyx_t_23;
                __Pyx_XGIVEREF(__pyx_t_31);
                __pyx_cur_scope->__pyx_t_4 = __pyx_t_31;
                __Pyx_XGIVEREF(__pyx_t_39);
                __pyx_cur_scope->__pyx_t_5 = __pyx_t_39;
                __Pyx_XGIVEREF(__pyx_r);
                __Pyx_RefNannyFinishContext();
                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                /* return from generator, awaiting value */
                __pyx_generator->resume_label = 34;
                return __pyx_r;
                __pyx_L459_resume_from_await:;
                __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                __pyx_cur_scope->__pyx_t_0 = 0;
                __Pyx_XGOTREF(__pyx_t_11);
                __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                __pyx_cur_scope->__pyx_t_1 = 0;
                __Pyx_XGOTREF(__pyx_t_12);
                __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                __pyx_cur_scope->__pyx_t_2 = 0;
                __Pyx_XGOTREF(__pyx_t_13);
                __pyx_t_23 = __pyx_cur_scope->__pyx_t_3;
                __pyx_cur_scope->__pyx_t_3 = 0;
                __Pyx_XGOTREF(__pyx_t_23);
                __pyx_t_31 = __pyx_cur_scope->__pyx_t_4;
                __pyx_cur_scope->__pyx_t_4 = 0;
                __Pyx_XGOTREF(__pyx_t_31);
                __pyx_t_39 = __pyx_cur_scope->__pyx_t_5;
                __pyx_cur_scope->__pyx_t_5 = 0;
                __Pyx_XGOTREF(__pyx_t_39);
                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2549, __pyx_L439_error)
                __pyx_t_34 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_34);
              } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                __Pyx_GOTREF(__pyx_r);
                __pyx_t_34 = __pyx_r; __pyx_r = NULL;
              } else {
                __Pyx_XGOTREF(__pyx_r);
                __PYX_ERR(0, 2549, __pyx_L439_error)
              }
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_has_any_activity);
              __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_has_any_activity, __pyx_t_34);
              __Pyx_GIVEREF(__pyx_t_34);
              __pyx_t_34 = 0;

              /* "ws_package/controllers/activity_controller.py":2553
 *                         )
 * 
 *                         if has_any_activity:             # <<<<<<<<<<<<<<
 *                             logger.info("App monitor activity found for interval %s to %s - marking as active", start_date, end_date)
 * 
*/
              __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_has_any_activity); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2553, __pyx_L439_error)
              if (__pyx_t_8) {

                /* "ws_package/controllers/activity_controller.py":2554
 * 
 *                         if has_any_activity:
 *                             logger.info("App monitor activity found for interval %s to %s - marking as active", start_date, end_date)             # <<<<<<<<<<<<<<
 * 
 *                 except Exception as activity_error:
*/
                __pyx_t_5 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2554, __pyx_L439_error)
                __Pyx_GOTREF(__pyx_t_6);
                __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2554, __pyx_L439_error)
                __Pyx_GOTREF(__pyx_t_1);
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_1))) {
                  __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1);
                  assert(__pyx_t_5);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
                  __Pyx_INCREF(__pyx_t_5);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[4] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_App_monitor_activity_found_for_i, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
                  __pyx_t_34 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                  if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2554, __pyx_L439_error)
                  __Pyx_GOTREF(__pyx_t_34);
                }
                __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;

                /* "ws_package/controllers/activity_controller.py":2553
 *                         )
 * 
 *                         if has_any_activity:             # <<<<<<<<<<<<<<
 *                             logger.info("App monitor activity found for interval %s to %s - marking as active", start_date, end_date)
 * 
*/
              }

              /* "ws_package/controllers/activity_controller.py":2547
 *                     has_any_activity = keyboard_activity > 0 or mouse_activity > 0 or average_activity > 0
 * 
 *                     if not has_any_activity:             # <<<<<<<<<<<<<<
 *                         # Double-check: look for app monitor activity during this interval
 *                         has_any_activity = await self._has_any_activity_in_interval(
*/
            }

            /* "ws_package/controllers/activity_controller.py":2529
 * 
 *                 # Gather activity data; errors here should not block interval creation
 *                 try:             # <<<<<<<<<<<<<<
 *                     await self.midnight(user_entity, self.last_count)
 * 
*/
          }
          __Pyx_XDECREF(__pyx_t_31); __pyx_t_31 = 0;
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
          goto __pyx_L446_try_end;
          __pyx_L439_error:;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
          __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
          __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
          __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
          __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
          __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

          /* "ws_package/controllers/activity_controller.py":2556
 *                             logger.info("App monitor activity found for interval %s to %s - marking as active", start_date, end_date)
 * 
 *                 except Exception as activity_error:             # <<<<<<<<<<<<<<
 *                     # Log and continue to saving with defaults/fallback
 *                     logger.error("Error retrieving/processing activity level for interval %s to %s: %s", start_date, end_date, activity_error, exc_info=True)
*/
          __pyx_t_16 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
          if (__pyx_t_16) {
            __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_34, &__pyx_t_1, &__pyx_t_5) < 0) __PYX_ERR(0, 2556, __pyx_L441_except_error)
            __Pyx_XGOTREF(__pyx_t_34);
            __Pyx_XGOTREF(__pyx_t_1);
            __Pyx_XGOTREF(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_activity_error);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_activity_error, __pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_1);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":2558
 *                 except Exception as activity_error:
 *                     # Log and continue to saving with defaults/fallback
 *                     logger.error("Error retrieving/processing activity level for interval %s to %s: %s", start_date, end_date, activity_error, exc_info=True)             # <<<<<<<<<<<<<<
 *                     logger.warning("Proceeding to save interval with default activity level due to error")
 * 
*/
              __pyx_t_15 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2558, __pyx_L466_error)
              __Pyx_GOTREF(__pyx_t_33);
              __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2558, __pyx_L466_error)
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_3))) {
                __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_3);
                assert(__pyx_t_15);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
                __Pyx_INCREF(__pyx_t_15);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[5 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Error_retrieving_processing_acti, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date, __pyx_cur_scope->__pyx_v_activity_error};
                __pyx_t_33 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2558, __pyx_L466_error)
                __Pyx_GOTREF(__pyx_t_33);
                if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_33, __pyx_callargs+5, 0) < (0)) __PYX_ERR(0, 2558, __pyx_L466_error)
                __pyx_t_6 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (5-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_33);
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2558, __pyx_L466_error)
                __Pyx_GOTREF(__pyx_t_6);
              }
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

              /* "ws_package/controllers/activity_controller.py":2559
 *                     # Log and continue to saving with defaults/fallback
 *                     logger.error("Error retrieving/processing activity level for interval %s to %s: %s", start_date, end_date, activity_error, exc_info=True)
 *                     logger.warning("Proceeding to save interval with default activity level due to error")             # <<<<<<<<<<<<<<
 * 
 *                 # CRITICAL: Only mark interval as break interval if it starts AFTER break start time
*/
              __pyx_t_3 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2559, __pyx_L466_error)
              __Pyx_GOTREF(__pyx_t_33);
              __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2559, __pyx_L466_error)
              __Pyx_GOTREF(__pyx_t_15);
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_15))) {
                __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_15);
                assert(__pyx_t_3);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                __Pyx_INCREF(__pyx_t_3);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Proceeding_to_save_interval_with};
                __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2559, __pyx_L466_error)
                __Pyx_GOTREF(__pyx_t_6);
              }
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            }

            /* "ws_package/controllers/activity_controller.py":2556
 *                             logger.info("App monitor activity found for interval %s to %s - marking as active", start_date, end_date)
 * 
 *                 except Exception as activity_error:             # <<<<<<<<<<<<<<
 *                     # Log and continue to saving with defaults/fallback
 *                     logger.error("Error retrieving/processing activity level for interval %s to %s: %s", start_date, end_date, activity_error, exc_info=True)
*/
            /*finally:*/ {
              /*normal exit:*/{
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_activity_error);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_activity_error); __pyx_cur_scope->__pyx_v_activity_error = 0;
                goto __pyx_L467;
              }
              __pyx_L466_error:;
              /*exception exit:*/{
                __Pyx_PyThreadState_assign
                __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_18 = 0; __pyx_t_48 = 0; __pyx_t_47 = 0; __pyx_t_46 = 0;
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                 __Pyx_ExceptionSwap(&__pyx_t_48, &__pyx_t_47, &__pyx_t_46);
                if ( unlikely(__Pyx_GetException(&__pyx_t_20, &__pyx_t_21, &__pyx_t_18) < 0)) __Pyx_ErrFetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_18);
                __Pyx_XGOTREF(__pyx_t_20);
                __Pyx_XGOTREF(__pyx_t_21);
                __Pyx_XGOTREF(__pyx_t_18);
                __Pyx_XGOTREF(__pyx_t_48);
                __Pyx_XGOTREF(__pyx_t_47);
                __Pyx_XGOTREF(__pyx_t_46);
                __pyx_t_16 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_55 = __pyx_filename;
                {
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_activity_error);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_activity_error); __pyx_cur_scope->__pyx_v_activity_error = 0;
                }
                __Pyx_XGIVEREF(__pyx_t_48);
                __Pyx_XGIVEREF(__pyx_t_47);
                __Pyx_XGIVEREF(__pyx_t_46);
                __Pyx_ExceptionReset(__pyx_t_48, __pyx_t_47, __pyx_t_46);
                __Pyx_XGIVEREF(__pyx_t_20);
                __Pyx_XGIVEREF(__pyx_t_21);
                __Pyx_XGIVEREF(__pyx_t_18);
                __Pyx_ErrRestore(__pyx_t_20, __pyx_t_21, __pyx_t_18);
                __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_18 = 0; __pyx_t_48 = 0; __pyx_t_47 = 0; __pyx_t_46 = 0;
                __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_55;
                goto __pyx_L441_except_error;
              }
              __pyx_L467:;
            }
            __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            goto __pyx_L440_exception_handled;
          }
          goto __pyx_L441_except_error;

          /* "ws_package/controllers/activity_controller.py":2529
 * 
 *                 # Gather activity data; errors here should not block interval creation
 *                 try:             # <<<<<<<<<<<<<<
 *                     await self.midnight(user_entity, self.last_count)
 * 
*/
          __pyx_L441_except_error:;
          __Pyx_XGIVEREF(__pyx_t_31);
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_XGIVEREF(__pyx_t_39);
          __Pyx_ExceptionReset(__pyx_t_31, __pyx_t_23, __pyx_t_39);
          goto __pyx_L263_error;
          __pyx_L440_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_31);
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_XGIVEREF(__pyx_t_39);
          __Pyx_ExceptionReset(__pyx_t_31, __pyx_t_23, __pyx_t_39);
          __pyx_L446_try_end:;
        }

        /* "ws_package/controllers/activity_controller.py":2563
 *                 # CRITICAL: Only mark interval as break interval if it starts AFTER break start time
 *                 # If slot overlaps break (start_date < break_start_time < end_date), save only from break_start_time to end_date as break interval.
 *                 break_start_time = getattr(self, 'break_start_time', None)             # <<<<<<<<<<<<<<
 *                 is_break_interval = False
 *                 effective_start = start_date
*/
        __pyx_t_5 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_5);
        __pyx_t_1 = __Pyx_GetAttr3(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_break_start_time, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2563, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_break_start_time);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_break_start_time, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":2564
 *                 # If slot overlaps break (start_date < break_start_time < end_date), save only from break_start_time to end_date as break interval.
 *                 break_start_time = getattr(self, 'break_start_time', None)
 *                 is_break_interval = False             # <<<<<<<<<<<<<<
 *                 effective_start = start_date
 *                 effective_end = end_date
*/
        __pyx_cur_scope->__pyx_v_is_break_interval = 0;

        /* "ws_package/controllers/activity_controller.py":2565
 *                 break_start_time = getattr(self, 'break_start_time', None)
 *                 is_break_interval = False
 *                 effective_start = start_date             # <<<<<<<<<<<<<<
 *                 effective_end = end_date
 * 
*/
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_start_date);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_effective_start);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_effective_start, __pyx_cur_scope->__pyx_v_start_date);
        __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_start_date);

        /* "ws_package/controllers/activity_controller.py":2566
 *                 is_break_interval = False
 *                 effective_start = start_date
 *                 effective_end = end_date             # <<<<<<<<<<<<<<
 * 
 *                 if current_break_id != 0 and break_start_time is not None:
*/
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_end_date);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_effective_end);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_effective_end, __pyx_cur_scope->__pyx_v_end_date);
        __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_end_date);

        /* "ws_package/controllers/activity_controller.py":2568
 *                 effective_end = end_date
 * 
 *                 if current_break_id != 0 and break_start_time is not None:             # <<<<<<<<<<<<<<
 *                     if start_date >= break_start_time:
 *                         is_break_interval = True
*/
        __pyx_t_9 = (__Pyx_PyLong_BoolNeObjC(__pyx_cur_scope->__pyx_v_current_break_id, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2568, __pyx_L263_error)
        if (__pyx_t_9) {
        } else {
          __pyx_t_8 = __pyx_t_9;
          goto __pyx_L473_bool_binop_done;
        }
        __pyx_t_9 = (__pyx_cur_scope->__pyx_v_break_start_time != Py_None);
        __pyx_t_8 = __pyx_t_9;
        __pyx_L473_bool_binop_done:;
        if (__pyx_t_8) {

          /* "ws_package/controllers/activity_controller.py":2569
 * 
 *                 if current_break_id != 0 and break_start_time is not None:
 *                     if start_date >= break_start_time:             # <<<<<<<<<<<<<<
 *                         is_break_interval = True
 *                         logger.info("Break is active (break_id=%s) and interval starts on/after break start (start=%s, break_start=%s) - marking as break interval", current_break_id, start_date, break_start_time)
*/
          __pyx_t_1 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_break_start_time, Py_GE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2569, __pyx_L263_error)
          __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2569, __pyx_L263_error)
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (__pyx_t_8) {

            /* "ws_package/controllers/activity_controller.py":2570
 *                 if current_break_id != 0 and break_start_time is not None:
 *                     if start_date >= break_start_time:
 *                         is_break_interval = True             # <<<<<<<<<<<<<<
 *                         logger.info("Break is active (break_id=%s) and interval starts on/after break start (start=%s, break_start=%s) - marking as break interval", current_break_id, start_date, break_start_time)
 *                     elif end_date > break_start_time:
*/
            __pyx_cur_scope->__pyx_v_is_break_interval = 1;

            /* "ws_package/controllers/activity_controller.py":2571
 *                     if start_date >= break_start_time:
 *                         is_break_interval = True
 *                         logger.info("Break is active (break_id=%s) and interval starts on/after break start (start=%s, break_start=%s) - marking as break interval", current_break_id, start_date, break_start_time)             # <<<<<<<<<<<<<<
 *                     elif end_date > break_start_time:
 *                         # Slot overlaps break: save only the part from break_start_time to end_date as break interval (e.g. 16:06-16:10, not 16:05-16:10 as regular)
*/
            __pyx_t_5 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2571, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_34);
            __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2571, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
            __pyx_t_7 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_6))) {
              __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
              assert(__pyx_t_5);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
              __Pyx_INCREF(__pyx_t_5);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
              __pyx_t_7 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[5] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Break_is_active_break_id_s_and_i, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_break_start_time};
              __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (5-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2571, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_1);
            }
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

            /* "ws_package/controllers/activity_controller.py":2569
 * 
 *                 if current_break_id != 0 and break_start_time is not None:
 *                     if start_date >= break_start_time:             # <<<<<<<<<<<<<<
 *                         is_break_interval = True
 *                         logger.info("Break is active (break_id=%s) and interval starts on/after break start (start=%s, break_start=%s) - marking as break interval", current_break_id, start_date, break_start_time)
*/
            goto __pyx_L475;
          }

          /* "ws_package/controllers/activity_controller.py":2572
 *                         is_break_interval = True
 *                         logger.info("Break is active (break_id=%s) and interval starts on/after break start (start=%s, break_start=%s) - marking as break interval", current_break_id, start_date, break_start_time)
 *                     elif end_date > break_start_time:             # <<<<<<<<<<<<<<
 *                         # Slot overlaps break: save only the part from break_start_time to end_date as break interval (e.g. 16:06-16:10, not 16:05-16:10 as regular)
 *                         is_break_interval = True
*/
          __pyx_t_1 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_end_date, __pyx_cur_scope->__pyx_v_break_start_time, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2572, __pyx_L263_error)
          __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2572, __pyx_L263_error)
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (__pyx_t_8) {

            /* "ws_package/controllers/activity_controller.py":2574
 *                     elif end_date > break_start_time:
 *                         # Slot overlaps break: save only the part from break_start_time to end_date as break interval (e.g. 16:06-16:10, not 16:05-16:10 as regular)
 *                         is_break_interval = True             # <<<<<<<<<<<<<<
 *                         effective_start = break_start_time
 *                         effective_end = end_date
*/
            __pyx_cur_scope->__pyx_v_is_break_interval = 1;

            /* "ws_package/controllers/activity_controller.py":2575
 *                         # Slot overlaps break: save only the part from break_start_time to end_date as break interval (e.g. 16:06-16:10, not 16:05-16:10 as regular)
 *                         is_break_interval = True
 *                         effective_start = break_start_time             # <<<<<<<<<<<<<<
 *                         effective_end = end_date
 *                         try:
*/
            __Pyx_INCREF(__pyx_cur_scope->__pyx_v_break_start_time);
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_effective_start);
            __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_effective_start, __pyx_cur_scope->__pyx_v_break_start_time);
            __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_break_start_time);

            /* "ws_package/controllers/activity_controller.py":2576
 *                         is_break_interval = True
 *                         effective_start = break_start_time
 *                         effective_end = end_date             # <<<<<<<<<<<<<<
 *                         try:
 *                             activityLevel = await self.get_activity_level_from_db(effective_start, effective_end)
*/
            __Pyx_INCREF(__pyx_cur_scope->__pyx_v_end_date);
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_effective_end);
            __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_effective_end, __pyx_cur_scope->__pyx_v_end_date);
            __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_end_date);

            /* "ws_package/controllers/activity_controller.py":2577
 *                         effective_start = break_start_time
 *                         effective_end = end_date
 *                         try:             # <<<<<<<<<<<<<<
 *                             activityLevel = await self.get_activity_level_from_db(effective_start, effective_end)
 *                         except Exception as e:
*/
            {
              __Pyx_ExceptionSave(&__pyx_t_39, &__pyx_t_23, &__pyx_t_31);
              __Pyx_XGOTREF(__pyx_t_39);
              __Pyx_XGOTREF(__pyx_t_23);
              __Pyx_XGOTREF(__pyx_t_31);
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":2578
 *                         effective_end = end_date
 *                         try:
 *                             activityLevel = await self.get_activity_level_from_db(effective_start, effective_end)             # <<<<<<<<<<<<<<
 *                         except Exception as e:
 *                             logger.warning("Error getting activity for break-overlap interval: %s", e)
*/
                __pyx_t_6 = __pyx_cur_scope->__pyx_v_self;
                __Pyx_INCREF(__pyx_t_6);
                __pyx_t_7 = 0;
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_cur_scope->__pyx_v_effective_start, __pyx_cur_scope->__pyx_v_effective_end};
                  __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_activity_level_from_db, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2578, __pyx_L476_error)
                  __Pyx_GOTREF(__pyx_t_1);
                }
                __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_11);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_t_23);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_23;
                  __Pyx_XGIVEREF(__pyx_t_31);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_31;
                  __Pyx_XGIVEREF(__pyx_t_39);
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_39;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 35;
                  return __pyx_r;
                  __pyx_L484_resume_from_await:;
                  __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_11);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  __pyx_t_23 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_23);
                  __pyx_t_31 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_31);
                  __pyx_t_39 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = 0;
                  __Pyx_XGOTREF(__pyx_t_39);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2578, __pyx_L476_error)
                  __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
                } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __pyx_t_1 = __pyx_r; __pyx_r = NULL;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 2578, __pyx_L476_error)
                }
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_activityLevel);
                __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_activityLevel, __pyx_t_1);
                __Pyx_GIVEREF(__pyx_t_1);
                __pyx_t_1 = 0;

                /* "ws_package/controllers/activity_controller.py":2577
 *                         effective_start = break_start_time
 *                         effective_end = end_date
 *                         try:             # <<<<<<<<<<<<<<
 *                             activityLevel = await self.get_activity_level_from_db(effective_start, effective_end)
 *                         except Exception as e:
*/
              }
              __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_XDECREF(__pyx_t_31); __pyx_t_31 = 0;
              goto __pyx_L483_try_end;
              __pyx_L476_error:;
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
              __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
              __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
              __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
              __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
              __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

              /* "ws_package/controllers/activity_controller.py":2579
 *                         try:
 *                             activityLevel = await self.get_activity_level_from_db(effective_start, effective_end)
 *                         except Exception as e:             # <<<<<<<<<<<<<<
 *                             logger.warning("Error getting activity for break-overlap interval: %s", e)
 *                             activityLevel = {'mouse': '0.0', 'average': '0.0', 'keyboard': '0.0'}
*/
              __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
              if (__pyx_t_14) {
                __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
                if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_6, &__pyx_t_5) < 0) __PYX_ERR(0, 2579, __pyx_L478_except_error)
                __Pyx_XGOTREF(__pyx_t_1);
                __Pyx_XGOTREF(__pyx_t_6);
                __Pyx_XGOTREF(__pyx_t_5);
                __Pyx_INCREF(__pyx_t_6);
                __Pyx_GIVEREF(__pyx_t_6);
                __pyx_cur_scope->__pyx_v_e = __pyx_t_6;
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":2580
 *                             activityLevel = await self.get_activity_level_from_db(effective_start, effective_end)
 *                         except Exception as e:
 *                             logger.warning("Error getting activity for break-overlap interval: %s", e)             # <<<<<<<<<<<<<<
 *                             activityLevel = {'mouse': '0.0', 'average': '0.0', 'keyboard': '0.0'}
 *                         logger.info("Break is active (break_id=%s) and slot overlaps break (slot %s to %s, break_start=%s) - saving only break part as break interval: %s to %s", current_break_id, start_date, end_date, break_start_time, effective_start, effective_end)
*/
                  __pyx_t_15 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2580, __pyx_L490_error)
                  __Pyx_GOTREF(__pyx_t_3);
                  __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2580, __pyx_L490_error)
                  __Pyx_GOTREF(__pyx_t_33);
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_33))) {
                    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_33);
                    assert(__pyx_t_15);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
                    __Pyx_INCREF(__pyx_t_15);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[3] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Error_getting_activity_for_break, __pyx_cur_scope->__pyx_v_e};
                    __pyx_t_34 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                    if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2580, __pyx_L490_error)
                    __Pyx_GOTREF(__pyx_t_34);
                  }
                  __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;

                  /* "ws_package/controllers/activity_controller.py":2581
 *                         except Exception as e:
 *                             logger.warning("Error getting activity for break-overlap interval: %s", e)
 *                             activityLevel = {'mouse': '0.0', 'average': '0.0', 'keyboard': '0.0'}             # <<<<<<<<<<<<<<
 *                         logger.info("Break is active (break_id=%s) and slot overlaps break (slot %s to %s, break_start=%s) - saving only break part as break interval: %s to %s", current_break_id, start_date, end_date, break_start_time, effective_start, effective_end)
 *                     else:
*/
                  __pyx_t_34 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2581, __pyx_L490_error)
                  __Pyx_GOTREF(__pyx_t_34);
                  if (PyDict_SetItem(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_mouse, __pyx_mstate_global->__pyx_kp_u_0_0) < (0)) __PYX_ERR(0, 2581, __pyx_L490_error)
                  if (PyDict_SetItem(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_average, __pyx_mstate_global->__pyx_kp_u_0_0) < (0)) __PYX_ERR(0, 2581, __pyx_L490_error)
                  if (PyDict_SetItem(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_keyboard, __pyx_mstate_global->__pyx_kp_u_0_0) < (0)) __PYX_ERR(0, 2581, __pyx_L490_error)
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_activityLevel);
                  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_activityLevel, __pyx_t_34);
                  __Pyx_GIVEREF(__pyx_t_34);
                  __pyx_t_34 = 0;
                }

                /* "ws_package/controllers/activity_controller.py":2579
 *                         try:
 *                             activityLevel = await self.get_activity_level_from_db(effective_start, effective_end)
 *                         except Exception as e:             # <<<<<<<<<<<<<<
 *                             logger.warning("Error getting activity for break-overlap interval: %s", e)
 *                             activityLevel = {'mouse': '0.0', 'average': '0.0', 'keyboard': '0.0'}
*/
                /*finally:*/ {
                  /*normal exit:*/{
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    goto __pyx_L491;
                  }
                  __pyx_L490_error:;
                  /*exception exit:*/{
                    __Pyx_PyThreadState_assign
                    __pyx_t_46 = 0; __pyx_t_47 = 0; __pyx_t_48 = 0; __pyx_t_18 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0;
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                    __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                    __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                    __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                    __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                    __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                     __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_21, &__pyx_t_20);
                    if ( unlikely(__Pyx_GetException(&__pyx_t_46, &__pyx_t_47, &__pyx_t_48) < 0)) __Pyx_ErrFetch(&__pyx_t_46, &__pyx_t_47, &__pyx_t_48);
                    __Pyx_XGOTREF(__pyx_t_46);
                    __Pyx_XGOTREF(__pyx_t_47);
                    __Pyx_XGOTREF(__pyx_t_48);
                    __Pyx_XGOTREF(__pyx_t_18);
                    __Pyx_XGOTREF(__pyx_t_21);
                    __Pyx_XGOTREF(__pyx_t_20);
                    __pyx_t_14 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_56 = __pyx_filename;
                    {
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    }
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __Pyx_XGIVEREF(__pyx_t_21);
                    __Pyx_XGIVEREF(__pyx_t_20);
                    __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_21, __pyx_t_20);
                    __Pyx_XGIVEREF(__pyx_t_46);
                    __Pyx_XGIVEREF(__pyx_t_47);
                    __Pyx_XGIVEREF(__pyx_t_48);
                    __Pyx_ErrRestore(__pyx_t_46, __pyx_t_47, __pyx_t_48);
                    __pyx_t_46 = 0; __pyx_t_47 = 0; __pyx_t_48 = 0; __pyx_t_18 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0;
                    __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_56;
                    goto __pyx_L478_except_error;
                  }
                  __pyx_L491:;
                }
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                goto __pyx_L477_exception_handled;
              }
              goto __pyx_L478_except_error;

              /* "ws_package/controllers/activity_controller.py":2577
 *                         effective_start = break_start_time
 *                         effective_end = end_date
 *                         try:             # <<<<<<<<<<<<<<
 *                             activityLevel = await self.get_activity_level_from_db(effective_start, effective_end)
 *                         except Exception as e:
*/
              __pyx_L478_except_error:;
              __Pyx_XGIVEREF(__pyx_t_39);
              __Pyx_XGIVEREF(__pyx_t_23);
              __Pyx_XGIVEREF(__pyx_t_31);
              __Pyx_ExceptionReset(__pyx_t_39, __pyx_t_23, __pyx_t_31);
              goto __pyx_L263_error;
              __pyx_L477_exception_handled:;
              __Pyx_XGIVEREF(__pyx_t_39);
              __Pyx_XGIVEREF(__pyx_t_23);
              __Pyx_XGIVEREF(__pyx_t_31);
              __Pyx_ExceptionReset(__pyx_t_39, __pyx_t_23, __pyx_t_31);
              __pyx_L483_try_end:;
            }

            /* "ws_package/controllers/activity_controller.py":2582
 *                             logger.warning("Error getting activity for break-overlap interval: %s", e)
 *                             activityLevel = {'mouse': '0.0', 'average': '0.0', 'keyboard': '0.0'}
 *                         logger.info("Break is active (break_id=%s) and slot overlaps break (slot %s to %s, break_start=%s) - saving only break part as break interval: %s to %s", current_break_id, start_date, end_date, break_start_time, effective_start, effective_end)             # <<<<<<<<<<<<<<
 *                     else:
 *                         logger.info("Break is active (break_id=%s) but interval ends before break start (start=%s, end=%s, break_start=%s) - marking as regular interval", current_break_id, start_date, end_date, break_start_time)
*/
            __pyx_t_6 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2582, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2582, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_34);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_7 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_34))) {
              __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_34);
              assert(__pyx_t_6);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_34);
              __Pyx_INCREF(__pyx_t_6);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_34, __pyx__function);
              __pyx_t_7 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[8] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Break_is_active_break_id_s_and_s, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date, __pyx_cur_scope->__pyx_v_break_start_time, __pyx_cur_scope->__pyx_v_effective_start, __pyx_cur_scope->__pyx_v_effective_end};
              __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_34, __pyx_callargs+__pyx_t_7, (8-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
              if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2582, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_5);
            }
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

            /* "ws_package/controllers/activity_controller.py":2572
 *                         is_break_interval = True
 *                         logger.info("Break is active (break_id=%s) and interval starts on/after break start (start=%s, break_start=%s) - marking as break interval", current_break_id, start_date, break_start_time)
 *                     elif end_date > break_start_time:             # <<<<<<<<<<<<<<
 *                         # Slot overlaps break: save only the part from break_start_time to end_date as break interval (e.g. 16:06-16:10, not 16:05-16:10 as regular)
 *                         is_break_interval = True
*/
            goto __pyx_L475;
          }

          /* "ws_package/controllers/activity_controller.py":2584
 *                         logger.info("Break is active (break_id=%s) and slot overlaps break (slot %s to %s, break_start=%s) - saving only break part as break interval: %s to %s", current_break_id, start_date, end_date, break_start_time, effective_start, effective_end)
 *                     else:
 *                         logger.info("Break is active (break_id=%s) but interval ends before break start (start=%s, end=%s, break_start=%s) - marking as regular interval", current_break_id, start_date, end_date, break_start_time)             # <<<<<<<<<<<<<<
 *                         current_break_id = 0
 *                 elif current_break_id != 0:
*/
          /*else*/ {
            __pyx_t_34 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2584, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2584, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __pyx_t_7 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_1))) {
              __pyx_t_34 = PyMethod_GET_SELF(__pyx_t_1);
              assert(__pyx_t_34);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
              __Pyx_INCREF(__pyx_t_34);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
              __pyx_t_7 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[6] = {__pyx_t_34, __pyx_mstate_global->__pyx_kp_u_Break_is_active_break_id_s_but_i, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date, __pyx_cur_scope->__pyx_v_break_start_time};
              __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_7, (6-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2584, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_5);
            }
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

            /* "ws_package/controllers/activity_controller.py":2585
 *                     else:
 *                         logger.info("Break is active (break_id=%s) but interval ends before break start (start=%s, end=%s, break_start=%s) - marking as regular interval", current_break_id, start_date, end_date, break_start_time)
 *                         current_break_id = 0             # <<<<<<<<<<<<<<
 *                 elif current_break_id != 0:
 *                     logger.info("Break is active (break_id=%s) but interval starts before break start (start=%s, break_start=%s) - marking as regular interval", current_break_id, start_date, break_start_time)
*/
            __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_current_break_id);
            __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_current_break_id, __pyx_mstate_global->__pyx_int_0);
            __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_0);
          }
          __pyx_L475:;

          /* "ws_package/controllers/activity_controller.py":2568
 *                 effective_end = end_date
 * 
 *                 if current_break_id != 0 and break_start_time is not None:             # <<<<<<<<<<<<<<
 *                     if start_date >= break_start_time:
 *                         is_break_interval = True
*/
          goto __pyx_L472;
        }

        /* "ws_package/controllers/activity_controller.py":2586
 *                         logger.info("Break is active (break_id=%s) but interval ends before break start (start=%s, end=%s, break_start=%s) - marking as regular interval", current_break_id, start_date, end_date, break_start_time)
 *                         current_break_id = 0
 *                 elif current_break_id != 0:             # <<<<<<<<<<<<<<
 *                     logger.info("Break is active (break_id=%s) but interval starts before break start (start=%s, break_start=%s) - marking as regular interval", current_break_id, start_date, break_start_time)
 *                     current_break_id = 0
*/
        __pyx_t_8 = (__Pyx_PyLong_BoolNeObjC(__pyx_cur_scope->__pyx_v_current_break_id, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2586, __pyx_L263_error)
        if (__pyx_t_8) {

          /* "ws_package/controllers/activity_controller.py":2587
 *                         current_break_id = 0
 *                 elif current_break_id != 0:
 *                     logger.info("Break is active (break_id=%s) but interval starts before break start (start=%s, break_start=%s) - marking as regular interval", current_break_id, start_date, break_start_time)             # <<<<<<<<<<<<<<
 *                     current_break_id = 0
 * 
*/
          __pyx_t_1 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2587, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_34);
          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2587, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
          __pyx_t_7 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_6))) {
            __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
            assert(__pyx_t_1);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
            __pyx_t_7 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[5] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Break_is_active_break_id_s_but_i_2, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_break_start_time};
            __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (5-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2587, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_5);
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":2588
 *                 elif current_break_id != 0:
 *                     logger.info("Break is active (break_id=%s) but interval starts before break start (start=%s, break_start=%s) - marking as regular interval", current_break_id, start_date, break_start_time)
 *                     current_break_id = 0             # <<<<<<<<<<<<<<
 * 
 *                 if is_break_interval and current_break_id != 0:
*/
          __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_current_break_id);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_current_break_id, __pyx_mstate_global->__pyx_int_0);
          __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_0);

          /* "ws_package/controllers/activity_controller.py":2586
 *                         logger.info("Break is active (break_id=%s) but interval ends before break start (start=%s, end=%s, break_start=%s) - marking as regular interval", current_break_id, start_date, end_date, break_start_time)
 *                         current_break_id = 0
 *                 elif current_break_id != 0:             # <<<<<<<<<<<<<<
 *                     logger.info("Break is active (break_id=%s) but interval starts before break start (start=%s, break_start=%s) - marking as regular interval", current_break_id, start_date, break_start_time)
 *                     current_break_id = 0
*/
        }
        __pyx_L472:;

        /* "ws_package/controllers/activity_controller.py":2590
 *                     current_break_id = 0
 * 
 *                 if is_break_interval and current_break_id != 0:             # <<<<<<<<<<<<<<
 *                     start_date = effective_start
 *                     end_date = effective_end
*/
        if (__pyx_cur_scope->__pyx_v_is_break_interval) {
        } else {
          __pyx_t_8 = __pyx_cur_scope->__pyx_v_is_break_interval;
          goto __pyx_L497_bool_binop_done;
        }
        __pyx_t_9 = (__Pyx_PyLong_BoolNeObjC(__pyx_cur_scope->__pyx_v_current_break_id, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2590, __pyx_L263_error)
        __pyx_t_8 = __pyx_t_9;
        __pyx_L497_bool_binop_done:;
        if (__pyx_t_8) {

          /* "ws_package/controllers/activity_controller.py":2591
 * 
 *                 if is_break_interval and current_break_id != 0:
 *                     start_date = effective_start             # <<<<<<<<<<<<<<
 *                     end_date = effective_end
 * 
*/
          __Pyx_INCREF(__pyx_cur_scope->__pyx_v_effective_start);
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_start_date);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_effective_start);
          __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_effective_start);

          /* "ws_package/controllers/activity_controller.py":2592
 *                 if is_break_interval and current_break_id != 0:
 *                     start_date = effective_start
 *                     end_date = effective_end             # <<<<<<<<<<<<<<
 * 
 *                 # CRITICAL: Break intervals must always use save_activity_log (is_uploaded=False) so they can be uploaded
*/
          __Pyx_INCREF(__pyx_cur_scope->__pyx_v_effective_end);
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_end_date);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_end_date, __pyx_cur_scope->__pyx_v_effective_end);
          __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_effective_end);

          /* "ws_package/controllers/activity_controller.py":2590
 *                     current_break_id = 0
 * 
 *                 if is_break_interval and current_break_id != 0:             # <<<<<<<<<<<<<<
 *                     start_date = effective_start
 *                     end_date = effective_end
*/
        }

        /* "ws_package/controllers/activity_controller.py":2596
 *                 # CRITICAL: Break intervals must always use save_activity_log (is_uploaded=False) so they can be uploaded
 *                 # Only use save_first_activity_log (is_uploaded=True) for non-break intervals that are out of range
 *                 if is_break_interval and current_break_id != 0:             # <<<<<<<<<<<<<<
 *                     # Round timestamps to seconds for consistent duplicate detection
 *                     # This prevents microsecond differences from creating duplicate intervals
*/
        if (__pyx_cur_scope->__pyx_v_is_break_interval) {
        } else {
          __pyx_t_8 = __pyx_cur_scope->__pyx_v_is_break_interval;
          goto __pyx_L500_bool_binop_done;
        }
        __pyx_t_9 = (__Pyx_PyLong_BoolNeObjC(__pyx_cur_scope->__pyx_v_current_break_id, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2596, __pyx_L263_error)
        __pyx_t_8 = __pyx_t_9;
        __pyx_L500_bool_binop_done:;
        if (__pyx_t_8) {

          /* "ws_package/controllers/activity_controller.py":2599
 *                     # Round timestamps to seconds for consistent duplicate detection
 *                     # This prevents microsecond differences from creating duplicate intervals
 *                     start_date_seconds = start_date.replace(microsecond=0)             # <<<<<<<<<<<<<<
 *                     end_date_seconds = end_date.replace(microsecond=0)
 *                     interval_key = (self.last_count + 1, start_date_seconds, end_date_seconds)
*/
          __pyx_t_6 = __pyx_cur_scope->__pyx_v_start_date;
          __Pyx_INCREF(__pyx_t_6);
          __pyx_t_7 = 0;
          {
            PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_6, NULL};
            __pyx_t_1 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2599, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_1);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_1, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 2599, __pyx_L263_error)
            __pyx_t_5 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_1);
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2599, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_5);
          }
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_start_date_seconds);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_start_date_seconds, __pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_5);
          __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":2600
 *                     # This prevents microsecond differences from creating duplicate intervals
 *                     start_date_seconds = start_date.replace(microsecond=0)
 *                     end_date_seconds = end_date.replace(microsecond=0)             # <<<<<<<<<<<<<<
 *                     interval_key = (self.last_count + 1, start_date_seconds, end_date_seconds)
 * 
*/
          __pyx_t_1 = __pyx_cur_scope->__pyx_v_end_date;
          __Pyx_INCREF(__pyx_t_1);
          __pyx_t_7 = 0;
          {
            PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_1, NULL};
            __pyx_t_6 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2600, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_6);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_6, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 2600, __pyx_L263_error)
            __pyx_t_5 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_6);
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2600, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_5);
          }
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_end_date_seconds);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_end_date_seconds, __pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_5);
          __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":2601
 *                     start_date_seconds = start_date.replace(microsecond=0)
 *                     end_date_seconds = end_date.replace(microsecond=0)
 *                     interval_key = (self.last_count + 1, start_date_seconds, end_date_seconds)             # <<<<<<<<<<<<<<
 * 
 *                     # Check in-memory set first (fast check, prevents DB queries)
*/
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2601, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_6 = __Pyx_PyLong_AddObjC(__pyx_t_5, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2601, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2601, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_6);
          if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6) != (0)) __PYX_ERR(0, 2601, __pyx_L263_error);
          __Pyx_INCREF(__pyx_cur_scope->__pyx_v_start_date_seconds);
          __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_start_date_seconds);
          if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_cur_scope->__pyx_v_start_date_seconds) != (0)) __PYX_ERR(0, 2601, __pyx_L263_error);
          __Pyx_INCREF(__pyx_cur_scope->__pyx_v_end_date_seconds);
          __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_end_date_seconds);
          if (__Pyx_PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_cur_scope->__pyx_v_end_date_seconds) != (0)) __PYX_ERR(0, 2601, __pyx_L263_error);
          __pyx_t_6 = 0;
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval_key);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval_key, ((PyObject*)__pyx_t_5));
          __Pyx_GIVEREF(__pyx_t_5);
          __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":2604
 * 
 *                     # Check in-memory set first (fast check, prevents DB queries)
 *                     if interval_key in self._creating_intervals:             # <<<<<<<<<<<<<<
 *                         logger.info("Skipping duplicate break interval - already creating %s to %s (counter=%s)", start_date_seconds, end_date_seconds, self.last_count + 1)
 *                         continue
*/
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_creating_intervals); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2604, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_8 = (__Pyx_PySequence_ContainsTF(__pyx_cur_scope->__pyx_v_interval_key, __pyx_t_5, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2604, __pyx_L263_error)
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (__pyx_t_8) {

            /* "ws_package/controllers/activity_controller.py":2605
 *                     # Check in-memory set first (fast check, prevents DB queries)
 *                     if interval_key in self._creating_intervals:
 *                         logger.info("Skipping duplicate break interval - already creating %s to %s (counter=%s)", start_date_seconds, end_date_seconds, self.last_count + 1)             # <<<<<<<<<<<<<<
 *                         continue
 * 
*/
            __pyx_t_6 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2605, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2605, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_34);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2605, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_33 = __Pyx_PyLong_AddObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2605, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_33);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_7 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_34))) {
              __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_34);
              assert(__pyx_t_6);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_34);
              __Pyx_INCREF(__pyx_t_6);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_34, __pyx__function);
              __pyx_t_7 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[5] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Skipping_duplicate_break_interva, __pyx_cur_scope->__pyx_v_start_date_seconds, __pyx_cur_scope->__pyx_v_end_date_seconds, __pyx_t_33};
              __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_34, __pyx_callargs+__pyx_t_7, (5-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
              if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2605, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_5);
            }
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

            /* "ws_package/controllers/activity_controller.py":2606
 *                     if interval_key in self._creating_intervals:
 *                         logger.info("Skipping duplicate break interval - already creating %s to %s (counter=%s)", start_date_seconds, end_date_seconds, self.last_count + 1)
 *                         continue             # <<<<<<<<<<<<<<
 * 
 *                     # Mark as creating to prevent concurrent duplicates
*/
            goto __pyx_L269_try_continue;

            /* "ws_package/controllers/activity_controller.py":2604
 * 
 *                     # Check in-memory set first (fast check, prevents DB queries)
 *                     if interval_key in self._creating_intervals:             # <<<<<<<<<<<<<<
 *                         logger.info("Skipping duplicate break interval - already creating %s to %s (counter=%s)", start_date_seconds, end_date_seconds, self.last_count + 1)
 *                         continue
*/
          }

          /* "ws_package/controllers/activity_controller.py":2609
 * 
 *                     # Mark as creating to prevent concurrent duplicates
 *                     self._creating_intervals.add(interval_key)             # <<<<<<<<<<<<<<
 * 
 *                     try:
*/
          __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_creating_intervals); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2609, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_33);
          __pyx_t_34 = __pyx_t_33;
          __Pyx_INCREF(__pyx_t_34);
          __pyx_t_7 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_34, __pyx_cur_scope->__pyx_v_interval_key};
            __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_add, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
            __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2609, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_5);
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":2611
 *                     self._creating_intervals.add(interval_key)
 * 
 *                     try:             # <<<<<<<<<<<<<<
 *                         # CRITICAL FIX: Check if break interval already exists in DB before saving
 *                         # This prevents duplicates when Python restarts during break initiation.
*/
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":2616
 *                         # Use exact=True so the pre-break interval (whose end_time may have
 *                         # microseconds just above start_date) is not falsely matched.
 *                         existing_interval_in_db = await self.activity_service.check_existing_interval(start_date, end_date, exact=True)             # <<<<<<<<<<<<<<
 *                         if existing_interval_in_db:
 *                             logger.info("Skipping duplicate break interval - interval already exists in DB for %s to %s", start_date, end_date)
*/
            __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2616, __pyx_L506_error)
            __Pyx_GOTREF(__pyx_t_34);
            __pyx_t_33 = __pyx_t_34;
            __Pyx_INCREF(__pyx_t_33);
            __pyx_t_7 = 0;
            {
              PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_33, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
              __pyx_t_6 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2616, __pyx_L506_error)
              __Pyx_GOTREF(__pyx_t_6);
              if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exact, Py_True, __pyx_t_6, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 2616, __pyx_L506_error)
              __pyx_t_5 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_check_existing_interval, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_6);
              __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
              if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2616, __pyx_L506_error)
              __Pyx_GOTREF(__pyx_t_5);
            }
            __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (likely(__pyx_t_26 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_11);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
              __Pyx_XGIVEREF(__pyx_t_12);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
              __Pyx_XGIVEREF(__pyx_t_13);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 36;
              return __pyx_r;
              __pyx_L508_resume_from_await:;
              __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_11);
              __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_12);
              __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_13);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2616, __pyx_L506_error)
              __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
            } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __pyx_t_5 = __pyx_r; __pyx_r = NULL;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 2616, __pyx_L506_error)
            }
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_existing_interval_in_db);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_existing_interval_in_db, __pyx_t_5);
            __Pyx_GIVEREF(__pyx_t_5);
            __pyx_t_5 = 0;

            /* "ws_package/controllers/activity_controller.py":2617
 *                         # microseconds just above start_date) is not falsely matched.
 *                         existing_interval_in_db = await self.activity_service.check_existing_interval(start_date, end_date, exact=True)
 *                         if existing_interval_in_db:             # <<<<<<<<<<<<<<
 *                             logger.info("Skipping duplicate break interval - interval already exists in DB for %s to %s", start_date, end_date)
 *                             self._creating_intervals.discard(interval_key)
*/
            __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_existing_interval_in_db); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2617, __pyx_L506_error)
            if (__pyx_t_8) {

              /* "ws_package/controllers/activity_controller.py":2618
 *                         existing_interval_in_db = await self.activity_service.check_existing_interval(start_date, end_date, exact=True)
 *                         if existing_interval_in_db:
 *                             logger.info("Skipping duplicate break interval - interval already exists in DB for %s to %s", start_date, end_date)             # <<<<<<<<<<<<<<
 *                             self._creating_intervals.discard(interval_key)
 *                             continue
*/
              __pyx_t_34 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2618, __pyx_L506_error)
              __Pyx_GOTREF(__pyx_t_6);
              __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2618, __pyx_L506_error)
              __Pyx_GOTREF(__pyx_t_33);
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_33))) {
                __pyx_t_34 = PyMethod_GET_SELF(__pyx_t_33);
                assert(__pyx_t_34);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
                __Pyx_INCREF(__pyx_t_34);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[4] = {__pyx_t_34, __pyx_mstate_global->__pyx_kp_u_Skipping_duplicate_break_interva_2, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
                __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2618, __pyx_L506_error)
                __Pyx_GOTREF(__pyx_t_5);
              }
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

              /* "ws_package/controllers/activity_controller.py":2619
 *                         if existing_interval_in_db:
 *                             logger.info("Skipping duplicate break interval - interval already exists in DB for %s to %s", start_date, end_date)
 *                             self._creating_intervals.discard(interval_key)             # <<<<<<<<<<<<<<
 *                             continue
 * 
*/
              __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_creating_intervals); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2619, __pyx_L506_error)
              __Pyx_GOTREF(__pyx_t_34);
              __pyx_t_33 = __pyx_t_34;
              __Pyx_INCREF(__pyx_t_33);
              __pyx_t_7 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_33, __pyx_cur_scope->__pyx_v_interval_key};
                __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_discard, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2619, __pyx_L506_error)
                __Pyx_GOTREF(__pyx_t_5);
              }
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

              /* "ws_package/controllers/activity_controller.py":2620
 *                             logger.info("Skipping duplicate break interval - interval already exists in DB for %s to %s", start_date, end_date)
 *                             self._creating_intervals.discard(interval_key)
 *                             continue             # <<<<<<<<<<<<<<
 * 
 *                         # This is a break interval - must use save_activity_log to set is_uploaded=False
*/
              goto __pyx_L503_continue;

              /* "ws_package/controllers/activity_controller.py":2617
 *                         # microseconds just above start_date) is not falsely matched.
 *                         existing_interval_in_db = await self.activity_service.check_existing_interval(start_date, end_date, exact=True)
 *                         if existing_interval_in_db:             # <<<<<<<<<<<<<<
 *                             logger.info("Skipping duplicate break interval - interval already exists in DB for %s to %s", start_date, end_date)
 *                             self._creating_intervals.discard(interval_key)
*/
            }

            /* "ws_package/controllers/activity_controller.py":2624
 *                         # This is a break interval - must use save_activity_log to set is_uploaded=False
 *                         # Set is_idle: True if popup is active AND interval has zero activity (both activityLevel and activity_percentage)
 *                         popup_is_active = self._idle_popup_active and self._idle_popup_triggered_at is not None             # <<<<<<<<<<<<<<
 *                         has_zero_activity = await self._has_zero_activity_for_interval(start_date, end_date)
 *                         is_idle = popup_is_active and has_zero_activity
*/
            __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_active); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2624, __pyx_L506_error)
            __Pyx_GOTREF(__pyx_t_34);
            __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_34); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2624, __pyx_L506_error)
            if (__pyx_t_8) {
              __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
            } else {
              __Pyx_INCREF(__pyx_t_34);
              __pyx_t_5 = __pyx_t_34;
              __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
              goto __pyx_L510_bool_binop_done;
            }
            __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_triggered_at); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2624, __pyx_L506_error)
            __Pyx_GOTREF(__pyx_t_34);
            __pyx_t_8 = (__pyx_t_34 != Py_None);
            __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
            __pyx_t_34 = __Pyx_PyBool_FromLong(__pyx_t_8); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2624, __pyx_L506_error)
            __Pyx_GOTREF(__pyx_t_34);
            __pyx_t_5 = __pyx_t_34;
            __pyx_t_34 = 0;
            __pyx_L510_bool_binop_done:;
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_popup_is_active);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_popup_is_active, __pyx_t_5);
            __Pyx_GIVEREF(__pyx_t_5);
            __pyx_t_5 = 0;

            /* "ws_package/controllers/activity_controller.py":2625
 *                         # Set is_idle: True if popup is active AND interval has zero activity (both activityLevel and activity_percentage)
 *                         popup_is_active = self._idle_popup_active and self._idle_popup_triggered_at is not None
 *                         has_zero_activity = await self._has_zero_activity_for_interval(start_date, end_date)             # <<<<<<<<<<<<<<
 *                         is_idle = popup_is_active and has_zero_activity
 *                         logger.info("[DEBUG][Break State] Break interval - break_id=%s, is_break=%s, status=%s, will save as is_break=%s", current_break_id, getattr(self, 'is_break', 0), self.status, current_break_id)
*/
            __pyx_t_34 = __pyx_cur_scope->__pyx_v_self;
            __Pyx_INCREF(__pyx_t_34);
            __pyx_t_7 = 0;
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_34, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
              __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_has_zero_activity_for_interval, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
              if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2625, __pyx_L506_error)
              __Pyx_GOTREF(__pyx_t_5);
            }
            __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (likely(__pyx_t_26 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_11);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
              __Pyx_XGIVEREF(__pyx_t_12);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
              __Pyx_XGIVEREF(__pyx_t_13);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 37;
              return __pyx_r;
              __pyx_L512_resume_from_await:;
              __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_11);
              __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_12);
              __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_13);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2625, __pyx_L506_error)
              __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
            } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __pyx_t_5 = __pyx_r; __pyx_r = NULL;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 2625, __pyx_L506_error)
            }
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_has_zero_activity);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_has_zero_activity, __pyx_t_5);
            __Pyx_GIVEREF(__pyx_t_5);
            __pyx_t_5 = 0;

            /* "ws_package/controllers/activity_controller.py":2626
 *                         popup_is_active = self._idle_popup_active and self._idle_popup_triggered_at is not None
 *                         has_zero_activity = await self._has_zero_activity_for_interval(start_date, end_date)
 *                         is_idle = popup_is_active and has_zero_activity             # <<<<<<<<<<<<<<
 *                         logger.info("[DEBUG][Break State] Break interval - break_id=%s, is_break=%s, status=%s, will save as is_break=%s", current_break_id, getattr(self, 'is_break', 0), self.status, current_break_id)
 *                         logger.info("Break interval (break_id=%s) - saving with is_uploaded=False (will be uploaded later) >> status %s, is_idle=%s (popup_is_active=%s, has_zero_activity=%s)", current_break_id, self.status, is_idle, popup_is_active, has_zero_activity)
*/
            __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_popup_is_active); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2626, __pyx_L506_error)
            if (__pyx_t_8) {
            } else {
              __Pyx_INCREF(__pyx_cur_scope->__pyx_v_popup_is_active);
              __pyx_t_5 = __pyx_cur_scope->__pyx_v_popup_is_active;
              goto __pyx_L513_bool_binop_done;
            }
            __Pyx_INCREF(__pyx_cur_scope->__pyx_v_has_zero_activity);
            __pyx_t_5 = __pyx_cur_scope->__pyx_v_has_zero_activity;
            __pyx_L513_bool_binop_done:;
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_is_idle);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_is_idle, __pyx_t_5);
            __Pyx_GIVEREF(__pyx_t_5);
            __pyx_t_5 = 0;

            /* "ws_package/controllers/activity_controller.py":2627
 *                         has_zero_activity = await self._has_zero_activity_for_interval(start_date, end_date)
 *                         is_idle = popup_is_active and has_zero_activity
 *                         logger.info("[DEBUG][Break State] Break interval - break_id=%s, is_break=%s, status=%s, will save as is_break=%s", current_break_id, getattr(self, 'is_break', 0), self.status, current_break_id)             # <<<<<<<<<<<<<<
 *                         logger.info("Break interval (break_id=%s) - saving with is_uploaded=False (will be uploaded later) >> status %s, is_idle=%s (popup_is_active=%s, has_zero_activity=%s)", current_break_id, self.status, is_idle, popup_is_active, has_zero_activity)
 *                         # CRITICAL: Verify break_id is not 0 before saving break interval
*/
            __pyx_t_34 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2627, __pyx_L506_error)
            __Pyx_GOTREF(__pyx_t_33);
            __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2627, __pyx_L506_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
            __pyx_t_33 = __pyx_cur_scope->__pyx_v_self;
            __Pyx_INCREF(__pyx_t_33);
            __pyx_t_1 = __Pyx_GetAttr3(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_is_break, __pyx_mstate_global->__pyx_int_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2627, __pyx_L506_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
            __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2627, __pyx_L506_error)
            __Pyx_GOTREF(__pyx_t_33);
            __pyx_t_7 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_6))) {
              __pyx_t_34 = PyMethod_GET_SELF(__pyx_t_6);
              assert(__pyx_t_34);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
              __Pyx_INCREF(__pyx_t_34);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
              __pyx_t_7 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[6] = {__pyx_t_34, __pyx_mstate_global->__pyx_kp_u_DEBUG_Break_State_Break_interva, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_t_1, __pyx_t_33, __pyx_cur_scope->__pyx_v_current_break_id};
              __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (6-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2627, __pyx_L506_error)
              __Pyx_GOTREF(__pyx_t_5);
            }
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

            /* "ws_package/controllers/activity_controller.py":2628
 *                         is_idle = popup_is_active and has_zero_activity
 *                         logger.info("[DEBUG][Break State] Break interval - break_id=%s, is_break=%s, status=%s, will save as is_break=%s", current_break_id, getattr(self, 'is_break', 0), self.status, current_break_id)
 *                         logger.info("Break interval (break_id=%s) - saving with is_uploaded=False (will be uploaded later) >> status %s, is_idle=%s (popup_is_active=%s, has_zero_activity=%s)", current_break_id, self.status, is_idle, popup_is_active, has_zero_activity)             # <<<<<<<<<<<<<<
 *                         # CRITICAL: Verify break_id is not 0 before saving break interval
 *                         if current_break_id == 0:
*/
            __pyx_t_6 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2628, __pyx_L506_error)
            __Pyx_GOTREF(__pyx_t_33);
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2628, __pyx_L506_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
            __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2628, __pyx_L506_error)
            __Pyx_GOTREF(__pyx_t_33);
            __pyx_t_7 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_1))) {
              __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
              assert(__pyx_t_6);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
              __Pyx_INCREF(__pyx_t_6);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
              __pyx_t_7 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[7] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Break_interval_break_id_s_saving, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_t_33, __pyx_cur_scope->__pyx_v_is_idle, __pyx_cur_scope->__pyx_v_popup_is_active, __pyx_cur_scope->__pyx_v_has_zero_activity};
              __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_7, (7-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2628, __pyx_L506_error)
              __Pyx_GOTREF(__pyx_t_5);
            }
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

            /* "ws_package/controllers/activity_controller.py":2630
 *                         logger.info("Break interval (break_id=%s) - saving with is_uploaded=False (will be uploaded later) >> status %s, is_idle=%s (popup_is_active=%s, has_zero_activity=%s)", current_break_id, self.status, is_idle, popup_is_active, has_zero_activity)
 *                         # CRITICAL: Verify break_id is not 0 before saving break interval
 *                         if current_break_id == 0:             # <<<<<<<<<<<<<<
 *                             logger.warning("[WARNING] Break interval being saved with break_id=0! This should not happen during a break. self.break_id=%s, self.is_break=%s", getattr(self, 'break_id', 'NOT_SET'), getattr(self, 'is_break', 'NOT_SET'))
 *                         await self.activity_service.save_activity_log(activityLevel, start_date, end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)
*/
            __pyx_t_8 = (__Pyx_PyLong_BoolEqObjC(__pyx_cur_scope->__pyx_v_current_break_id, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2630, __pyx_L506_error)
            if (__pyx_t_8) {

              /* "ws_package/controllers/activity_controller.py":2631
 *                         # CRITICAL: Verify break_id is not 0 before saving break interval
 *                         if current_break_id == 0:
 *                             logger.warning("[WARNING] Break interval being saved with break_id=0! This should not happen during a break. self.break_id=%s, self.is_break=%s", getattr(self, 'break_id', 'NOT_SET'), getattr(self, 'is_break', 'NOT_SET'))             # <<<<<<<<<<<<<<
 *                         await self.activity_service.save_activity_log(activityLevel, start_date, end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)
 *                         self.has_on_demand = False
*/
              __pyx_t_1 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2631, __pyx_L506_error)
              __Pyx_GOTREF(__pyx_t_33);
              __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2631, __pyx_L506_error)
              __Pyx_GOTREF(__pyx_t_6);
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              __pyx_t_33 = __pyx_cur_scope->__pyx_v_self;
              __Pyx_INCREF(__pyx_t_33);
              __pyx_t_34 = __Pyx_GetAttr3(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_break_id, __pyx_mstate_global->__pyx_n_u_NOT_SET); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2631, __pyx_L506_error)
              __Pyx_GOTREF(__pyx_t_34);
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              __pyx_t_33 = __pyx_cur_scope->__pyx_v_self;
              __Pyx_INCREF(__pyx_t_33);
              __pyx_t_15 = __Pyx_GetAttr3(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_is_break, __pyx_mstate_global->__pyx_n_u_NOT_SET); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2631, __pyx_L506_error)
              __Pyx_GOTREF(__pyx_t_15);
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_6))) {
                __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
                assert(__pyx_t_1);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                __Pyx_INCREF(__pyx_t_1);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[4] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_WARNING_Break_interval_being_sa, __pyx_t_34, __pyx_t_15};
                __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2631, __pyx_L506_error)
                __Pyx_GOTREF(__pyx_t_5);
              }
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

              /* "ws_package/controllers/activity_controller.py":2630
 *                         logger.info("Break interval (break_id=%s) - saving with is_uploaded=False (will be uploaded later) >> status %s, is_idle=%s (popup_is_active=%s, has_zero_activity=%s)", current_break_id, self.status, is_idle, popup_is_active, has_zero_activity)
 *                         # CRITICAL: Verify break_id is not 0 before saving break interval
 *                         if current_break_id == 0:             # <<<<<<<<<<<<<<
 *                             logger.warning("[WARNING] Break interval being saved with break_id=0! This should not happen during a break. self.break_id=%s, self.is_break=%s", getattr(self, 'break_id', 'NOT_SET'), getattr(self, 'is_break', 'NOT_SET'))
 *                         await self.activity_service.save_activity_log(activityLevel, start_date, end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)
*/
            }

            /* "ws_package/controllers/activity_controller.py":2632
 *                         if current_break_id == 0:
 *                             logger.warning("[WARNING] Break interval being saved with break_id=0! This should not happen during a break. self.break_id=%s, self.is_break=%s", getattr(self, 'break_id', 'NOT_SET'), getattr(self, 'is_break', 'NOT_SET'))
 *                         await self.activity_service.save_activity_log(activityLevel, start_date, end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)             # <<<<<<<<<<<<<<
 *                         self.has_on_demand = False
 *                         # CRITICAL: Immediately flush the queue to ensure break interval is written to database
*/
            __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2632, __pyx_L506_error)
            __Pyx_GOTREF(__pyx_t_15);
            __pyx_t_6 = __pyx_t_15;
            __Pyx_INCREF(__pyx_t_6);
            __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2632, __pyx_L506_error)
            __Pyx_GOTREF(__pyx_t_34);
            __pyx_t_1 = __Pyx_PyLong_AddObjC(__pyx_t_34, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2632, __pyx_L506_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
            __pyx_t_33 = __pyx_cur_scope->__pyx_v_self;
            __Pyx_INCREF(__pyx_t_33);
            __pyx_t_7 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_33, NULL};
              __pyx_t_34 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_today_weekday, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
              if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2632, __pyx_L506_error)
              __Pyx_GOTREF(__pyx_t_34);
            }
            __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_has_on_demand); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2632, __pyx_L506_error)
            __Pyx_GOTREF(__pyx_t_33);
            __pyx_t_7 = 0;
            {
              PyObject *__pyx_callargs[6 + ((CYTHON_VECTORCALL) ? 3 : 0)] = {__pyx_t_6, __pyx_cur_scope->__pyx_v_activityLevel, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date, __pyx_t_1, __pyx_t_34};
              __pyx_t_3 = __Pyx_MakeVectorcallBuilderKwds(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2632, __pyx_L506_error)
              __Pyx_GOTREF(__pyx_t_3);
              if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_break_id, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_t_3, __pyx_callargs+6, 0) < (0)) __PYX_ERR(0, 2632, __pyx_L506_error)
              if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_is_idle, __pyx_cur_scope->__pyx_v_is_idle, __pyx_t_3, __pyx_callargs+6, 1) < (0)) __PYX_ERR(0, 2632, __pyx_L506_error)
              if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_has_on_demand_screenshot, __pyx_t_33, __pyx_t_3, __pyx_callargs+6, 2) < (0)) __PYX_ERR(0, 2632, __pyx_L506_error)
              __pyx_t_5 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_save_activity_log, __pyx_callargs+__pyx_t_7, (6-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_3);
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2632, __pyx_L506_error)
              __Pyx_GOTREF(__pyx_t_5);
            }
            __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (likely(__pyx_t_26 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_11);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
              __Pyx_XGIVEREF(__pyx_t_12);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
              __Pyx_XGIVEREF(__pyx_t_13);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 38;
              return __pyx_r;
              __pyx_L516_resume_from_await:;
              __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_11);
              __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_12);
              __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_13);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2632, __pyx_L506_error)
            } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_DECREF(__pyx_r); __pyx_r = 0;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 2632, __pyx_L506_error)
            }

            /* "ws_package/controllers/activity_controller.py":2633
 *                             logger.warning("[WARNING] Break interval being saved with break_id=0! This should not happen during a break. self.break_id=%s, self.is_break=%s", getattr(self, 'break_id', 'NOT_SET'), getattr(self, 'is_break', 'NOT_SET'))
 *                         await self.activity_service.save_activity_log(activityLevel, start_date, end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)
 *                         self.has_on_demand = False             # <<<<<<<<<<<<<<
 *                         # CRITICAL: Immediately flush the queue to ensure break interval is written to database
 *                         # This ensures the interval is visible in database queries right away
*/
            if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_has_on_demand, Py_False) < (0)) __PYX_ERR(0, 2633, __pyx_L506_error)

            /* "ws_package/controllers/activity_controller.py":2636
 *                         # CRITICAL: Immediately flush the queue to ensure break interval is written to database
 *                         # This ensures the interval is visible in database queries right away
 *                         try:             # <<<<<<<<<<<<<<
 *                             logger.debug("Flushing queue immediately after creating break interval (break_id=%s)", current_break_id)
 *                             await db_writer_service.process_immediately()
*/
            {
              __Pyx_ExceptionSave(&__pyx_t_31, &__pyx_t_23, &__pyx_t_39);
              __Pyx_XGOTREF(__pyx_t_31);
              __Pyx_XGOTREF(__pyx_t_23);
              __Pyx_XGOTREF(__pyx_t_39);
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":2637
 *                         # This ensures the interval is visible in database queries right away
 *                         try:
 *                             logger.debug("Flushing queue immediately after creating break interval (break_id=%s)", current_break_id)             # <<<<<<<<<<<<<<
 *                             await db_writer_service.process_immediately()
 *                         except Exception as flush_error:
*/
                __pyx_t_15 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2637, __pyx_L517_error)
                __Pyx_GOTREF(__pyx_t_3);
                __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2637, __pyx_L517_error)
                __Pyx_GOTREF(__pyx_t_33);
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_33))) {
                  __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_33);
                  assert(__pyx_t_15);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
                  __Pyx_INCREF(__pyx_t_15);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Flushing_queue_immediately_after, __pyx_cur_scope->__pyx_v_current_break_id};
                  __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2637, __pyx_L517_error)
                  __Pyx_GOTREF(__pyx_t_5);
                }
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                /* "ws_package/controllers/activity_controller.py":2638
 *                         try:
 *                             logger.debug("Flushing queue immediately after creating break interval (break_id=%s)", current_break_id)
 *                             await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 *                         except Exception as flush_error:
 *                             logger.error("Error flushing queue after break interval creation: %s", flush_error, exc_info=True)
*/
                __pyx_t_33 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2638, __pyx_L517_error)
                __Pyx_GOTREF(__pyx_t_15);
                __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2638, __pyx_L517_error)
                __Pyx_GOTREF(__pyx_t_3);
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_3))) {
                  __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_3);
                  assert(__pyx_t_33);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
                  __Pyx_INCREF(__pyx_t_33);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_33, NULL};
                  __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2638, __pyx_L517_error)
                  __Pyx_GOTREF(__pyx_t_5);
                }
                __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_11);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_t_23);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_23;
                  __Pyx_XGIVEREF(__pyx_t_31);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_31;
                  __Pyx_XGIVEREF(__pyx_t_39);
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_39;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 39;
                  return __pyx_r;
                  __pyx_L525_resume_from_await:;
                  __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_11);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  __pyx_t_23 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_23);
                  __pyx_t_31 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_31);
                  __pyx_t_39 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = 0;
                  __Pyx_XGOTREF(__pyx_t_39);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2638, __pyx_L517_error)
                } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 2638, __pyx_L517_error)
                }

                /* "ws_package/controllers/activity_controller.py":2636
 *                         # CRITICAL: Immediately flush the queue to ensure break interval is written to database
 *                         # This ensures the interval is visible in database queries right away
 *                         try:             # <<<<<<<<<<<<<<
 *                             logger.debug("Flushing queue immediately after creating break interval (break_id=%s)", current_break_id)
 *                             await db_writer_service.process_immediately()
*/
              }
              __Pyx_XDECREF(__pyx_t_31); __pyx_t_31 = 0;
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
              goto __pyx_L524_try_end;
              __pyx_L517_error:;
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
              __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
              __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
              __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
              __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
              __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

              /* "ws_package/controllers/activity_controller.py":2639
 *                             logger.debug("Flushing queue immediately after creating break interval (break_id=%s)", current_break_id)
 *                             await db_writer_service.process_immediately()
 *                         except Exception as flush_error:             # <<<<<<<<<<<<<<
 *                             logger.error("Error flushing queue after break interval creation: %s", flush_error, exc_info=True)
 * 
*/
              __pyx_t_16 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
              if (__pyx_t_16) {
                __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
                if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_3, &__pyx_t_33) < 0) __PYX_ERR(0, 2639, __pyx_L519_except_error)
                __Pyx_XGOTREF(__pyx_t_5);
                __Pyx_XGOTREF(__pyx_t_3);
                __Pyx_XGOTREF(__pyx_t_33);
                __Pyx_INCREF(__pyx_t_3);
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_flush_error);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_flush_error, __pyx_t_3);
                __Pyx_GIVEREF(__pyx_t_3);
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":2640
 *                             await db_writer_service.process_immediately()
 *                         except Exception as flush_error:
 *                             logger.error("Error flushing queue after break interval creation: %s", flush_error, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *                         # Check for idle detection after break interval is saved
*/
                  __pyx_t_34 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2640, __pyx_L531_error)
                  __Pyx_GOTREF(__pyx_t_1);
                  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2640, __pyx_L531_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_6))) {
                    __pyx_t_34 = PyMethod_GET_SELF(__pyx_t_6);
                    assert(__pyx_t_34);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                    __Pyx_INCREF(__pyx_t_34);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_34, __pyx_mstate_global->__pyx_kp_u_Error_flushing_queue_after_break, __pyx_cur_scope->__pyx_v_flush_error};
                    __pyx_t_1 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2640, __pyx_L531_error)
                    __Pyx_GOTREF(__pyx_t_1);
                    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_1, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 2640, __pyx_L531_error)
                    __pyx_t_15 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_1);
                    __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2640, __pyx_L531_error)
                    __Pyx_GOTREF(__pyx_t_15);
                  }
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                }

                /* "ws_package/controllers/activity_controller.py":2639
 *                             logger.debug("Flushing queue immediately after creating break interval (break_id=%s)", current_break_id)
 *                             await db_writer_service.process_immediately()
 *                         except Exception as flush_error:             # <<<<<<<<<<<<<<
 *                             logger.error("Error flushing queue after break interval creation: %s", flush_error, exc_info=True)
 * 
*/
                /*finally:*/ {
                  /*normal exit:*/{
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_flush_error);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_flush_error); __pyx_cur_scope->__pyx_v_flush_error = 0;
                    goto __pyx_L532;
                  }
                  __pyx_L531_error:;
                  /*exception exit:*/{
                    __Pyx_PyThreadState_assign
                    __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_18 = 0; __pyx_t_48 = 0; __pyx_t_47 = 0; __pyx_t_46 = 0;
                    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                    __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                    __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                    __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                    __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                     __Pyx_ExceptionSwap(&__pyx_t_48, &__pyx_t_47, &__pyx_t_46);
                    if ( unlikely(__Pyx_GetException(&__pyx_t_20, &__pyx_t_21, &__pyx_t_18) < 0)) __Pyx_ErrFetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_18);
                    __Pyx_XGOTREF(__pyx_t_20);
                    __Pyx_XGOTREF(__pyx_t_21);
                    __Pyx_XGOTREF(__pyx_t_18);
                    __Pyx_XGOTREF(__pyx_t_48);
                    __Pyx_XGOTREF(__pyx_t_47);
                    __Pyx_XGOTREF(__pyx_t_46);
                    __pyx_t_16 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_57 = __pyx_filename;
                    {
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_flush_error);
                      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_flush_error); __pyx_cur_scope->__pyx_v_flush_error = 0;
                    }
                    __Pyx_XGIVEREF(__pyx_t_48);
                    __Pyx_XGIVEREF(__pyx_t_47);
                    __Pyx_XGIVEREF(__pyx_t_46);
                    __Pyx_ExceptionReset(__pyx_t_48, __pyx_t_47, __pyx_t_46);
                    __Pyx_XGIVEREF(__pyx_t_20);
                    __Pyx_XGIVEREF(__pyx_t_21);
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __Pyx_ErrRestore(__pyx_t_20, __pyx_t_21, __pyx_t_18);
                    __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_18 = 0; __pyx_t_48 = 0; __pyx_t_47 = 0; __pyx_t_46 = 0;
                    __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_57;
                    goto __pyx_L519_except_error;
                  }
                  __pyx_L532:;
                }
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                goto __pyx_L518_exception_handled;
              }
              goto __pyx_L519_except_error;

              /* "ws_package/controllers/activity_controller.py":2636
 *                         # CRITICAL: Immediately flush the queue to ensure break interval is written to database
 *                         # This ensures the interval is visible in database queries right away
 *                         try:             # <<<<<<<<<<<<<<
 *                             logger.debug("Flushing queue immediately after creating break interval (break_id=%s)", current_break_id)
 *                             await db_writer_service.process_immediately()
*/
              __pyx_L519_except_error:;
              __Pyx_XGIVEREF(__pyx_t_31);
              __Pyx_XGIVEREF(__pyx_t_23);
              __Pyx_XGIVEREF(__pyx_t_39);
              __Pyx_ExceptionReset(__pyx_t_31, __pyx_t_23, __pyx_t_39);
              goto __pyx_L506_error;
              __pyx_L518_exception_handled:;
              __Pyx_XGIVEREF(__pyx_t_31);
              __Pyx_XGIVEREF(__pyx_t_23);
              __Pyx_XGIVEREF(__pyx_t_39);
              __Pyx_ExceptionReset(__pyx_t_31, __pyx_t_23, __pyx_t_39);
              __pyx_L524_try_end:;
            }

            /* "ws_package/controllers/activity_controller.py":2644
 *                         # Check for idle detection after break interval is saved
 *                         # NEW REQUIREMENT: Check for 2 consecutive idle intervals and trigger popup
 *                         async def check_idle_after_delay():             # <<<<<<<<<<<<<<
 *                             await asyncio.sleep(1)  # Wait for DB write to complete
 *                             logger.info("[IdleDetection] Checking for idle after break interval save")
*/
            __pyx_t_33 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_16check_idle_after_delay, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController___start_devic_5, ((PyObject*)__pyx_cur_scope), __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[27])); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2644, __pyx_L506_error)
            __Pyx_GOTREF(__pyx_t_33);
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_check_idle_after_delay);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_check_idle_after_delay, __pyx_t_33);
            __Pyx_GIVEREF(__pyx_t_33);
            __pyx_t_33 = 0;

            /* "ws_package/controllers/activity_controller.py":2652
 *                             else:
 *                                 logger.debug("[IdleDetection] No idle detected after break interval save")
 *                         asyncio.create_task(check_idle_after_delay())             # <<<<<<<<<<<<<<
 *                     finally:
 *                         # Remove from set after a delay to allow database write to complete
*/
            __pyx_t_3 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2652, __pyx_L506_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_create_task); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2652, __pyx_L506_error)
            __Pyx_GOTREF(__pyx_t_15);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_cur_scope->__pyx_v_check_idle_after_delay); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2652, __pyx_L506_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_7 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_15))) {
              __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_15);
              assert(__pyx_t_3);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
              __pyx_t_7 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_5};
              __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2652, __pyx_L506_error)
              __Pyx_GOTREF(__pyx_t_33);
            }
            __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
          }

          /* "ws_package/controllers/activity_controller.py":2655
 *                     finally:
 *                         # Remove from set after a delay to allow database write to complete
 *                         async def remove_after_delay():             # <<<<<<<<<<<<<<
 *                             await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                             self._creating_intervals.discard(interval_key)
*/
          /*finally:*/ {
            /*normal exit:*/{
              __pyx_t_33 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_22remove_after_delay, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController___start_devic_4, ((PyObject*)__pyx_cur_scope), __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[28])); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2655, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_33);
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_remove_after_delay);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_remove_after_delay, __pyx_t_33);
              __Pyx_GIVEREF(__pyx_t_33);
              __pyx_t_33 = 0;

              /* "ws_package/controllers/activity_controller.py":2658
 *                             await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                             self._creating_intervals.discard(interval_key)
 *                         asyncio.create_task(remove_after_delay())             # <<<<<<<<<<<<<<
 *                 elif in_range and self.status == True:
 *                     # CRITICAL FIX: Check if interval already exists before saving to prevent duplicates
*/
              __pyx_t_15 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2658, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_5);
              __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_create_task); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2658, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_cur_scope->__pyx_v_remove_after_delay); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2658, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_5);
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_3))) {
                __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_3);
                assert(__pyx_t_15);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
                __Pyx_INCREF(__pyx_t_15);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_t_5};
                __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2658, __pyx_L263_error)
                __Pyx_GOTREF(__pyx_t_33);
              }
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              goto __pyx_L507;
            }
            __pyx_L506_error:;
            /*exception exit:*/{
              __Pyx_PyThreadState_assign
              __pyx_t_39 = 0; __pyx_t_23 = 0; __pyx_t_31 = 0; __pyx_t_46 = 0; __pyx_t_47 = 0; __pyx_t_48 = 0;
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
              __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
              __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
              __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
              __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
              __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
               __Pyx_ExceptionSwap(&__pyx_t_46, &__pyx_t_47, &__pyx_t_48);
              if ( unlikely(__Pyx_GetException(&__pyx_t_39, &__pyx_t_23, &__pyx_t_31) < 0)) __Pyx_ErrFetch(&__pyx_t_39, &__pyx_t_23, &__pyx_t_31);
              __Pyx_XGOTREF(__pyx_t_39);
              __Pyx_XGOTREF(__pyx_t_23);
              __Pyx_XGOTREF(__pyx_t_31);
              __Pyx_XGOTREF(__pyx_t_46);
              __Pyx_XGOTREF(__pyx_t_47);
              __Pyx_XGOTREF(__pyx_t_48);
              __pyx_t_14 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_58 = __pyx_filename;
              {

                /* "ws_package/controllers/activity_controller.py":2655
 *                     finally:
 *                         # Remove from set after a delay to allow database write to complete
 *                         async def remove_after_delay():             # <<<<<<<<<<<<<<
 *                             await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                             self._creating_intervals.discard(interval_key)
*/
                __pyx_t_33 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_19remove_after_delay, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController___start_devic_4, ((PyObject*)__pyx_cur_scope), __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[29])); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2655, __pyx_L540_error)
                __Pyx_GOTREF(__pyx_t_33);
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_remove_after_delay);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_remove_after_delay, __pyx_t_33);
                __Pyx_GIVEREF(__pyx_t_33);
                __pyx_t_33 = 0;

                /* "ws_package/controllers/activity_controller.py":2658
 *                             await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                             self._creating_intervals.discard(interval_key)
 *                         asyncio.create_task(remove_after_delay())             # <<<<<<<<<<<<<<
 *                 elif in_range and self.status == True:
 *                     # CRITICAL FIX: Check if interval already exists before saving to prevent duplicates
*/
                __pyx_t_3 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2658, __pyx_L540_error)
                __Pyx_GOTREF(__pyx_t_5);
                __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_create_task); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2658, __pyx_L540_error)
                __Pyx_GOTREF(__pyx_t_15);
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_cur_scope->__pyx_v_remove_after_delay); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2658, __pyx_L540_error)
                __Pyx_GOTREF(__pyx_t_5);
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_15))) {
                  __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_15);
                  assert(__pyx_t_3);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                  __Pyx_INCREF(__pyx_t_3);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_5};
                  __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2658, __pyx_L540_error)
                  __Pyx_GOTREF(__pyx_t_33);
                }
                __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              }
              __Pyx_XGIVEREF(__pyx_t_46);
              __Pyx_XGIVEREF(__pyx_t_47);
              __Pyx_XGIVEREF(__pyx_t_48);
              __Pyx_ExceptionReset(__pyx_t_46, __pyx_t_47, __pyx_t_48);
              __Pyx_XGIVEREF(__pyx_t_39);
              __Pyx_XGIVEREF(__pyx_t_23);
              __Pyx_XGIVEREF(__pyx_t_31);
              __Pyx_ErrRestore(__pyx_t_39, __pyx_t_23, __pyx_t_31);
              __pyx_t_39 = 0; __pyx_t_23 = 0; __pyx_t_31 = 0; __pyx_t_46 = 0; __pyx_t_47 = 0; __pyx_t_48 = 0;
              __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_58;
              goto __pyx_L263_error;
              __pyx_L540_error:;
              __Pyx_XGIVEREF(__pyx_t_46);
              __Pyx_XGIVEREF(__pyx_t_47);
              __Pyx_XGIVEREF(__pyx_t_48);
              __Pyx_ExceptionReset(__pyx_t_46, __pyx_t_47, __pyx_t_48);
              __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_XDECREF(__pyx_t_31); __pyx_t_31 = 0;
              __pyx_t_46 = 0; __pyx_t_47 = 0; __pyx_t_48 = 0;
              goto __pyx_L263_error;
            }
            __pyx_L503_continue: {

              /* "ws_package/controllers/activity_controller.py":2655
 *                     finally:
 *                         # Remove from set after a delay to allow database write to complete
 *                         async def remove_after_delay():             # <<<<<<<<<<<<<<
 *                             await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                             self._creating_intervals.discard(interval_key)
*/
              __pyx_t_33 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_22remove_after_delay, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController___start_devic_4, ((PyObject*)__pyx_cur_scope), __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[28])); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2655, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_33);
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_remove_after_delay);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_remove_after_delay, __pyx_t_33);
              __Pyx_GIVEREF(__pyx_t_33);
              __pyx_t_33 = 0;

              /* "ws_package/controllers/activity_controller.py":2658
 *                             await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                             self._creating_intervals.discard(interval_key)
 *                         asyncio.create_task(remove_after_delay())             # <<<<<<<<<<<<<<
 *                 elif in_range and self.status == True:
 *                     # CRITICAL FIX: Check if interval already exists before saving to prevent duplicates
*/
              __pyx_t_15 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2658, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_5);
              __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_create_task); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2658, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_cur_scope->__pyx_v_remove_after_delay); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2658, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_5);
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_3))) {
                __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_3);
                assert(__pyx_t_15);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
                __Pyx_INCREF(__pyx_t_15);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_t_5};
                __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2658, __pyx_L263_error)
                __Pyx_GOTREF(__pyx_t_33);
              }
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              goto __pyx_L269_try_continue;
            }
            __pyx_L507:;
          }

          /* "ws_package/controllers/activity_controller.py":2596
 *                 # CRITICAL: Break intervals must always use save_activity_log (is_uploaded=False) so they can be uploaded
 *                 # Only use save_first_activity_log (is_uploaded=True) for non-break intervals that are out of range
 *                 if is_break_interval and current_break_id != 0:             # <<<<<<<<<<<<<<
 *                     # Round timestamps to seconds for consistent duplicate detection
 *                     # This prevents microsecond differences from creating duplicate intervals
*/
          goto __pyx_L499;
        }

        /* "ws_package/controllers/activity_controller.py":2659
 *                             self._creating_intervals.discard(interval_key)
 *                         asyncio.create_task(remove_after_delay())
 *                 elif in_range and self.status == True:             # <<<<<<<<<<<<<<
 *                     # CRITICAL FIX: Check if interval already exists before saving to prevent duplicates
 *                     # This prevents the same interval from being created multiple times when the loop runs
*/
        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_in_range); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2659, __pyx_L263_error)
        if (__pyx_t_9) {
        } else {
          __pyx_t_8 = __pyx_t_9;
          goto __pyx_L541_bool_binop_done;
        }
        __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2659, __pyx_L263_error)
        __Pyx_GOTREF(__pyx_t_33);
        __pyx_t_3 = PyObject_RichCompare(__pyx_t_33, Py_True, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2659, __pyx_L263_error)
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2659, __pyx_L263_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_8 = __pyx_t_9;
        __pyx_L541_bool_binop_done:;
        if (__pyx_t_8) {

          /* "ws_package/controllers/activity_controller.py":2667
 *                     # Round timestamps to seconds for consistent duplicate detection
 *                     # This prevents microsecond differences from creating duplicate intervals
 *                     start_date_seconds = start_date.replace(microsecond=0)             # <<<<<<<<<<<<<<
 *                     end_date_seconds = end_date.replace(microsecond=0)
 *                     interval_key = (self.last_count + 1, start_date_seconds, end_date_seconds)
*/
          __pyx_t_33 = __pyx_cur_scope->__pyx_v_start_date;
          __Pyx_INCREF(__pyx_t_33);
          __pyx_t_7 = 0;
          {
            PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_33, NULL};
            __pyx_t_5 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2667, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_5);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_5, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 2667, __pyx_L263_error)
            __pyx_t_3 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_5);
            __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2667, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_3);
          }
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_start_date_seconds);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_start_date_seconds, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_3);
          __pyx_t_3 = 0;

          /* "ws_package/controllers/activity_controller.py":2668
 *                     # This prevents microsecond differences from creating duplicate intervals
 *                     start_date_seconds = start_date.replace(microsecond=0)
 *                     end_date_seconds = end_date.replace(microsecond=0)             # <<<<<<<<<<<<<<
 *                     interval_key = (self.last_count + 1, start_date_seconds, end_date_seconds)
 * 
*/
          __pyx_t_5 = __pyx_cur_scope->__pyx_v_end_date;
          __Pyx_INCREF(__pyx_t_5);
          __pyx_t_7 = 0;
          {
            PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_5, NULL};
            __pyx_t_33 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2668, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_33);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_33, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 2668, __pyx_L263_error)
            __pyx_t_3 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_33);
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2668, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_3);
          }
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_end_date_seconds);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_end_date_seconds, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_3);
          __pyx_t_3 = 0;

          /* "ws_package/controllers/activity_controller.py":2669
 *                     start_date_seconds = start_date.replace(microsecond=0)
 *                     end_date_seconds = end_date.replace(microsecond=0)
 *                     interval_key = (self.last_count + 1, start_date_seconds, end_date_seconds)             # <<<<<<<<<<<<<<
 * 
 *                     # Check in-memory set first (fast check, prevents DB queries and race conditions)
*/
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2669, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_33 = __Pyx_PyLong_AddObjC(__pyx_t_3, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2669, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_33);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2669, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_33);
          if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_33) != (0)) __PYX_ERR(0, 2669, __pyx_L263_error);
          __Pyx_INCREF(__pyx_cur_scope->__pyx_v_start_date_seconds);
          __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_start_date_seconds);
          if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_cur_scope->__pyx_v_start_date_seconds) != (0)) __PYX_ERR(0, 2669, __pyx_L263_error);
          __Pyx_INCREF(__pyx_cur_scope->__pyx_v_end_date_seconds);
          __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_end_date_seconds);
          if (__Pyx_PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_cur_scope->__pyx_v_end_date_seconds) != (0)) __PYX_ERR(0, 2669, __pyx_L263_error);
          __pyx_t_33 = 0;
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval_key);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval_key, ((PyObject*)__pyx_t_3));
          __Pyx_GIVEREF(__pyx_t_3);
          __pyx_t_3 = 0;

          /* "ws_package/controllers/activity_controller.py":2672
 * 
 *                     # Check in-memory set first (fast check, prevents DB queries and race conditions)
 *                     if interval_key in self._creating_intervals:             # <<<<<<<<<<<<<<
 *                         logger.info("Skipping duplicate interval - already creating %s to %s (counter=%s)", start_date_seconds, end_date_seconds, self.last_count + 1)
 *                         continue
*/
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_creating_intervals); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2672, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_8 = (__Pyx_PySequence_ContainsTF(__pyx_cur_scope->__pyx_v_interval_key, __pyx_t_3, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2672, __pyx_L263_error)
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (__pyx_t_8) {

            /* "ws_package/controllers/activity_controller.py":2673
 *                     # Check in-memory set first (fast check, prevents DB queries and race conditions)
 *                     if interval_key in self._creating_intervals:
 *                         logger.info("Skipping duplicate interval - already creating %s to %s (counter=%s)", start_date_seconds, end_date_seconds, self.last_count + 1)             # <<<<<<<<<<<<<<
 *                         continue
 * 
*/
            __pyx_t_33 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2673, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2673, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_15);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2673, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_6 = __Pyx_PyLong_AddObjC(__pyx_t_5, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2673, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_t_7 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_15))) {
              __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_15);
              assert(__pyx_t_33);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
              __Pyx_INCREF(__pyx_t_33);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
              __pyx_t_7 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[5] = {__pyx_t_33, __pyx_mstate_global->__pyx_kp_u_Skipping_duplicate_interval_alre, __pyx_cur_scope->__pyx_v_start_date_seconds, __pyx_cur_scope->__pyx_v_end_date_seconds, __pyx_t_6};
              __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (5-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2673, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_3);
            }
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

            /* "ws_package/controllers/activity_controller.py":2674
 *                     if interval_key in self._creating_intervals:
 *                         logger.info("Skipping duplicate interval - already creating %s to %s (counter=%s)", start_date_seconds, end_date_seconds, self.last_count + 1)
 *                         continue             # <<<<<<<<<<<<<<
 * 
 *                     # Mark as creating to prevent concurrent duplicates
*/
            goto __pyx_L269_try_continue;

            /* "ws_package/controllers/activity_controller.py":2672
 * 
 *                     # Check in-memory set first (fast check, prevents DB queries and race conditions)
 *                     if interval_key in self._creating_intervals:             # <<<<<<<<<<<<<<
 *                         logger.info("Skipping duplicate interval - already creating %s to %s (counter=%s)", start_date_seconds, end_date_seconds, self.last_count + 1)
 *                         continue
*/
          }

          /* "ws_package/controllers/activity_controller.py":2677
 * 
 *                     # Mark as creating to prevent concurrent duplicates
 *                     self._creating_intervals.add(interval_key)             # <<<<<<<<<<<<<<
 * 
 *                     interval_exists = False
*/
          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_creating_intervals); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2677, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_15 = __pyx_t_6;
          __Pyx_INCREF(__pyx_t_15);
          __pyx_t_7 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_cur_scope->__pyx_v_interval_key};
            __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_add, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2677, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_3);
          }
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

          /* "ws_package/controllers/activity_controller.py":2679
 *                     self._creating_intervals.add(interval_key)
 * 
 *                     interval_exists = False             # <<<<<<<<<<<<<<
 *                     break_interval_overlaps = False
 *                     regular_interval_overlaps = False
*/
          __pyx_cur_scope->__pyx_v_interval_exists = 0;

          /* "ws_package/controllers/activity_controller.py":2680
 * 
 *                     interval_exists = False
 *                     break_interval_overlaps = False             # <<<<<<<<<<<<<<
 *                     regular_interval_overlaps = False
 *                     try:
*/
          __pyx_cur_scope->__pyx_v_break_interval_overlaps = 0;

          /* "ws_package/controllers/activity_controller.py":2681
 *                     interval_exists = False
 *                     break_interval_overlaps = False
 *                     regular_interval_overlaps = False             # <<<<<<<<<<<<<<
 *                     try:
 *                         # Check pending write queue for break intervals that overlap this slot.
*/
          __pyx_cur_scope->__pyx_v_regular_interval_overlaps = 0;

          /* "ws_package/controllers/activity_controller.py":2682
 *                     break_interval_overlaps = False
 *                     regular_interval_overlaps = False
 *                     try:             # <<<<<<<<<<<<<<
 *                         # Check pending write queue for break intervals that overlap this slot.
 *                         # This is non-blocking (no DB flush needed) and prevents event-loop stalls.
*/
          {
            __Pyx_ExceptionSave(&__pyx_t_48, &__pyx_t_47, &__pyx_t_46);
            __Pyx_XGOTREF(__pyx_t_48);
            __Pyx_XGOTREF(__pyx_t_47);
            __Pyx_XGOTREF(__pyx_t_46);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":2685
 *                         # Check pending write queue for break intervals that overlap this slot.
 *                         # This is non-blocking (no DB flush needed) and prevents event-loop stalls.
 *                         from ws_package.utils.db_write_queue import db_write_queue as _dwq, WriteOperationType as _WOT             # <<<<<<<<<<<<<<
 *                         for _pi in _dwq.get_pending_items(_WOT.ACTIVITY_INTERVAL):
 *                             _d = _pi.data
*/
              {
                PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_db_write_queue,__pyx_mstate_global->__pyx_n_u_WriteOperationType};
                __pyx_t_31 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_utils_db_write_queue, __pyx_imported_names, 2, NULL, 0); if (unlikely(!__pyx_t_31)) __PYX_ERR(0, 2685, __pyx_L544_error)
              }
              __pyx_t_3 = __pyx_t_31;
              __Pyx_GOTREF(__pyx_t_3);
              {
                PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_db_write_queue,__pyx_mstate_global->__pyx_n_u_WriteOperationType};
                for (__pyx_t_29=0; __pyx_t_29 < 2; __pyx_t_29++) {
                  __pyx_t_6 = __Pyx_ImportFrom(__pyx_t_3, __pyx_imported_names[__pyx_t_29]); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2685, __pyx_L544_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  switch (__pyx_t_29) {
                    case 0:
                    __Pyx_INCREF(__pyx_t_6);
                    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v__dwq);
                    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v__dwq, __pyx_t_6);
                    __Pyx_GIVEREF(__pyx_t_6);
                    break;
                    case 1:
                    __Pyx_INCREF(__pyx_t_6);
                    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v__WOT);
                    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v__WOT, __pyx_t_6);
                    __Pyx_GIVEREF(__pyx_t_6);
                    break;
                    default:;
                  }
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                }
              }
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

              /* "ws_package/controllers/activity_controller.py":2686
 *                         # This is non-blocking (no DB flush needed) and prevents event-loop stalls.
 *                         from ws_package.utils.db_write_queue import db_write_queue as _dwq, WriteOperationType as _WOT
 *                         for _pi in _dwq.get_pending_items(_WOT.ACTIVITY_INTERVAL):             # <<<<<<<<<<<<<<
 *                             _d = _pi.data
 *                             if (_d.get('is_break', 0) != 0 and
*/
              __pyx_t_6 = __pyx_cur_scope->__pyx_v__dwq;
              __Pyx_INCREF(__pyx_t_6);
              __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v__WOT, __pyx_mstate_global->__pyx_n_u_ACTIVITY_INTERVAL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2686, __pyx_L544_error)
              __Pyx_GOTREF(__pyx_t_15);
              __pyx_t_7 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_15};
                __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_pending_items, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2686, __pyx_L544_error)
                __Pyx_GOTREF(__pyx_t_3);
              }
              if (likely(PyList_CheckExact(__pyx_t_3)) || PyTuple_CheckExact(__pyx_t_3)) {
                __pyx_t_15 = __pyx_t_3; __Pyx_INCREF(__pyx_t_15);
                __pyx_t_29 = 0;
                __pyx_t_54 = NULL;
              } else {
                __pyx_t_29 = -1; __pyx_t_15 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2686, __pyx_L544_error)
                __Pyx_GOTREF(__pyx_t_15);
                __pyx_t_54 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_15); if (unlikely(!__pyx_t_54)) __PYX_ERR(0, 2686, __pyx_L544_error)
              }
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              for (;;) {
                if (likely(!__pyx_t_54)) {
                  if (likely(PyList_CheckExact(__pyx_t_15))) {
                    {
                      Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_15);
                      #if !CYTHON_ASSUME_SAFE_SIZE
                      if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2686, __pyx_L544_error)
                      #endif
                      if (__pyx_t_29 >= __pyx_temp) break;
                    }
                    __pyx_t_3 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_15, __pyx_t_29, __Pyx_ReferenceSharing_OwnStrongReference);
                    ++__pyx_t_29;
                  } else {
                    {
                      Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_15);
                      #if !CYTHON_ASSUME_SAFE_SIZE
                      if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2686, __pyx_L544_error)
                      #endif
                      if (__pyx_t_29 >= __pyx_temp) break;
                    }
                    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                    __pyx_t_3 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_15, __pyx_t_29));
                    #else
                    __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_15, __pyx_t_29);
                    #endif
                    ++__pyx_t_29;
                  }
                  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2686, __pyx_L544_error)
                } else {
                  __pyx_t_3 = __pyx_t_54(__pyx_t_15);
                  if (unlikely(!__pyx_t_3)) {
                    PyObject* exc_type = PyErr_Occurred();
                    if (exc_type) {
                      if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 2686, __pyx_L544_error)
                      PyErr_Clear();
                    }
                    break;
                  }
                }
                __Pyx_GOTREF(__pyx_t_3);
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v__pi);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v__pi, __pyx_t_3);
                __Pyx_GIVEREF(__pyx_t_3);
                __pyx_t_3 = 0;

                /* "ws_package/controllers/activity_controller.py":2687
 *                         from ws_package.utils.db_write_queue import db_write_queue as _dwq, WriteOperationType as _WOT
 *                         for _pi in _dwq.get_pending_items(_WOT.ACTIVITY_INTERVAL):
 *                             _d = _pi.data             # <<<<<<<<<<<<<<
 *                             if (_d.get('is_break', 0) != 0 and
 *                                     _d.get('counter') == self.last_count + 1):
*/
                __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v__pi, __pyx_mstate_global->__pyx_n_u_data); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2687, __pyx_L544_error)
                __Pyx_GOTREF(__pyx_t_3);
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v__d);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v__d, __pyx_t_3);
                __Pyx_GIVEREF(__pyx_t_3);
                __pyx_t_3 = 0;

                /* "ws_package/controllers/activity_controller.py":2688
 *                         for _pi in _dwq.get_pending_items(_WOT.ACTIVITY_INTERVAL):
 *                             _d = _pi.data
 *                             if (_d.get('is_break', 0) != 0 and             # <<<<<<<<<<<<<<
 *                                     _d.get('counter') == self.last_count + 1):
 *                                 _ps = _d.get('start_time')
*/
                __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v__d, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2688, __pyx_L544_error)
                __Pyx_GOTREF(__pyx_t_3);
                __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_mstate_global->__pyx_tuple[23], NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2688, __pyx_L544_error)
                __Pyx_GOTREF(__pyx_t_6);
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                __pyx_t_9 = (__Pyx_PyLong_BoolNeObjC(__pyx_t_6, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2688, __pyx_L544_error)
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                if (__pyx_t_9) {
                } else {
                  __pyx_t_8 = __pyx_t_9;
                  goto __pyx_L555_bool_binop_done;
                }

                /* "ws_package/controllers/activity_controller.py":2689
 *                             _d = _pi.data
 *                             if (_d.get('is_break', 0) != 0 and
 *                                     _d.get('counter') == self.last_count + 1):             # <<<<<<<<<<<<<<
 *                                 _ps = _d.get('start_time')
 *                                 _pe = _d.get('end_time')
*/
                __pyx_t_3 = __pyx_cur_scope->__pyx_v__d;
                __Pyx_INCREF(__pyx_t_3);
                __pyx_t_7 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_n_u_counter};
                  __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2689, __pyx_L544_error)
                  __Pyx_GOTREF(__pyx_t_6);
                }
                __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2689, __pyx_L544_error)
                __Pyx_GOTREF(__pyx_t_3);
                __pyx_t_33 = __Pyx_PyLong_AddObjC(__pyx_t_3, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2689, __pyx_L544_error)
                __Pyx_GOTREF(__pyx_t_33);
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                __pyx_t_3 = PyObject_RichCompare(__pyx_t_6, __pyx_t_33, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2689, __pyx_L544_error)
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2689, __pyx_L544_error)
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                __pyx_t_8 = __pyx_t_9;
                __pyx_L555_bool_binop_done:;

                /* "ws_package/controllers/activity_controller.py":2688
 *                         for _pi in _dwq.get_pending_items(_WOT.ACTIVITY_INTERVAL):
 *                             _d = _pi.data
 *                             if (_d.get('is_break', 0) != 0 and             # <<<<<<<<<<<<<<
 *                                     _d.get('counter') == self.last_count + 1):
 *                                 _ps = _d.get('start_time')
*/
                if (__pyx_t_8) {

                  /* "ws_package/controllers/activity_controller.py":2690
 *                             if (_d.get('is_break', 0) != 0 and
 *                                     _d.get('counter') == self.last_count + 1):
 *                                 _ps = _d.get('start_time')             # <<<<<<<<<<<<<<
 *                                 _pe = _d.get('end_time')
 *                                 if _ps is not None and _pe is not None and _ps < end_date and _pe > start_date:
*/
                  __pyx_t_33 = __pyx_cur_scope->__pyx_v__d;
                  __Pyx_INCREF(__pyx_t_33);
                  __pyx_t_7 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_33, __pyx_mstate_global->__pyx_n_u_start_time};
                    __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2690, __pyx_L544_error)
                    __Pyx_GOTREF(__pyx_t_3);
                  }
                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v__ps);
                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v__ps, __pyx_t_3);
                  __Pyx_GIVEREF(__pyx_t_3);
                  __pyx_t_3 = 0;

                  /* "ws_package/controllers/activity_controller.py":2691
 *                                     _d.get('counter') == self.last_count + 1):
 *                                 _ps = _d.get('start_time')
 *                                 _pe = _d.get('end_time')             # <<<<<<<<<<<<<<
 *                                 if _ps is not None and _pe is not None and _ps < end_date and _pe > start_date:
 *                                     break_interval_overlaps = True
*/
                  __pyx_t_33 = __pyx_cur_scope->__pyx_v__d;
                  __Pyx_INCREF(__pyx_t_33);
                  __pyx_t_7 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_33, __pyx_mstate_global->__pyx_n_u_end_time};
                    __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2691, __pyx_L544_error)
                    __Pyx_GOTREF(__pyx_t_3);
                  }
                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v__pe);
                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v__pe, __pyx_t_3);
                  __Pyx_GIVEREF(__pyx_t_3);
                  __pyx_t_3 = 0;

                  /* "ws_package/controllers/activity_controller.py":2692
 *                                 _ps = _d.get('start_time')
 *                                 _pe = _d.get('end_time')
 *                                 if _ps is not None and _pe is not None and _ps < end_date and _pe > start_date:             # <<<<<<<<<<<<<<
 *                                     break_interval_overlaps = True
 *                                     logger.info(
*/
                  __pyx_t_9 = (__pyx_cur_scope->__pyx_v__ps != Py_None);
                  if (__pyx_t_9) {
                  } else {
                    __pyx_t_8 = __pyx_t_9;
                    goto __pyx_L558_bool_binop_done;
                  }
                  __pyx_t_9 = (__pyx_cur_scope->__pyx_v__pe != Py_None);
                  if (__pyx_t_9) {
                  } else {
                    __pyx_t_8 = __pyx_t_9;
                    goto __pyx_L558_bool_binop_done;
                  }
                  __pyx_t_3 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v__ps, __pyx_cur_scope->__pyx_v_end_date, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2692, __pyx_L544_error)
                  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2692, __pyx_L544_error)
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  if (__pyx_t_9) {
                  } else {
                    __pyx_t_8 = __pyx_t_9;
                    goto __pyx_L558_bool_binop_done;
                  }
                  __pyx_t_3 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v__pe, __pyx_cur_scope->__pyx_v_start_date, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2692, __pyx_L544_error)
                  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2692, __pyx_L544_error)
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __pyx_t_8 = __pyx_t_9;
                  __pyx_L558_bool_binop_done:;
                  if (__pyx_t_8) {

                    /* "ws_package/controllers/activity_controller.py":2693
 *                                 _pe = _d.get('end_time')
 *                                 if _ps is not None and _pe is not None and _ps < end_date and _pe > start_date:
 *                                     break_interval_overlaps = True             # <<<<<<<<<<<<<<
 *                                     logger.info(
 *                                         "Pending break interval in write queue overlaps %s to %s  skipping regular interval",
*/
                    __pyx_cur_scope->__pyx_v_break_interval_overlaps = 1;

                    /* "ws_package/controllers/activity_controller.py":2694
 *                                 if _ps is not None and _pe is not None and _ps < end_date and _pe > start_date:
 *                                     break_interval_overlaps = True
 *                                     logger.info(             # <<<<<<<<<<<<<<
 *                                         "Pending break interval in write queue overlaps %s to %s  skipping regular interval",
 *                                         start_date, end_date
*/
                    __pyx_t_33 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2694, __pyx_L544_error)
                    __Pyx_GOTREF(__pyx_t_6);
                    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2694, __pyx_L544_error)
                    __Pyx_GOTREF(__pyx_t_5);
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

                    /* "ws_package/controllers/activity_controller.py":2696
 *                                     logger.info(
 *                                         "Pending break interval in write queue overlaps %s to %s  skipping regular interval",
 *                                         start_date, end_date             # <<<<<<<<<<<<<<
 *                                     )
 *                                     break
*/
                    __pyx_t_7 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_5))) {
                      __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_5);
                      assert(__pyx_t_33);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                      __Pyx_INCREF(__pyx_t_33);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                      __pyx_t_7 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[4] = {__pyx_t_33, __pyx_mstate_global->__pyx_kp_u_Pending_break_interval_in_write, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
                      __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2694, __pyx_L544_error)
                      __Pyx_GOTREF(__pyx_t_3);
                    }
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                    /* "ws_package/controllers/activity_controller.py":2698
 *                                         start_date, end_date
 *                                     )
 *                                     break             # <<<<<<<<<<<<<<
 * 
 *                         if not break_interval_overlaps:
*/
                    goto __pyx_L553_break;

                    /* "ws_package/controllers/activity_controller.py":2692
 *                                 _ps = _d.get('start_time')
 *                                 _pe = _d.get('end_time')
 *                                 if _ps is not None and _pe is not None and _ps < end_date and _pe > start_date:             # <<<<<<<<<<<<<<
 *                                     break_interval_overlaps = True
 *                                     logger.info(
*/
                  }

                  /* "ws_package/controllers/activity_controller.py":2688
 *                         for _pi in _dwq.get_pending_items(_WOT.ACTIVITY_INTERVAL):
 *                             _d = _pi.data
 *                             if (_d.get('is_break', 0) != 0 and             # <<<<<<<<<<<<<<
 *                                     _d.get('counter') == self.last_count + 1):
 *                                 _ps = _d.get('start_time')
*/
                }

                /* "ws_package/controllers/activity_controller.py":2686
 *                         # This is non-blocking (no DB flush needed) and prevents event-loop stalls.
 *                         from ws_package.utils.db_write_queue import db_write_queue as _dwq, WriteOperationType as _WOT
 *                         for _pi in _dwq.get_pending_items(_WOT.ACTIVITY_INTERVAL):             # <<<<<<<<<<<<<<
 *                             _d = _pi.data
 *                             if (_d.get('is_break', 0) != 0 and
*/
              }
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              goto __pyx_L562_for_end;
              __pyx_L553_break:;
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              goto __pyx_L562_for_end;
              __pyx_L562_for_end:;

              /* "ws_package/controllers/activity_controller.py":2700
 *                                     break
 * 
 *                         if not break_interval_overlaps:             # <<<<<<<<<<<<<<
 *                             with db_lock_manager.read_lock():
 *                                 async with async_session() as session:
*/
              __pyx_t_8 = (!__pyx_cur_scope->__pyx_v_break_interval_overlaps);
              if (__pyx_t_8) {

                /* "ws_package/controllers/activity_controller.py":2701
 * 
 *                         if not break_interval_overlaps:
 *                             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                                 async with async_session() as session:
 *                                     # Check if interval with same start_time, end_time, and counter already exists
*/
                /*with:*/ {
                  __pyx_t_3 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2701, __pyx_L544_error)
                  __Pyx_GOTREF(__pyx_t_5);
                  __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2701, __pyx_L544_error)
                  __Pyx_GOTREF(__pyx_t_33);
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_33))) {
                    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_33);
                    assert(__pyx_t_3);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
                    __Pyx_INCREF(__pyx_t_3);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
                    __pyx_t_15 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                    if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2701, __pyx_L544_error)
                    __Pyx_GOTREF(__pyx_t_15);
                  }
                  __pyx_t_31 = __Pyx_PyObject_LookupSpecial(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_31)) __PYX_ERR(0, 2701, __pyx_L544_error)
                  __Pyx_GOTREF(__pyx_t_31);
                  __pyx_t_3 = NULL;
                  __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2701, __pyx_L564_error)
                  __Pyx_GOTREF(__pyx_t_5);
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (likely(PyMethod_Check(__pyx_t_5))) {
                    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
                    assert(__pyx_t_3);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                    __Pyx_INCREF(__pyx_t_3);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
                    __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                    if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2701, __pyx_L564_error)
                    __Pyx_GOTREF(__pyx_t_33);
                  }
                  __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  /*try:*/ {
                    {
                      __Pyx_ExceptionSave(&__pyx_t_23, &__pyx_t_39, &__pyx_t_18);
                      __Pyx_XGOTREF(__pyx_t_23);
                      __Pyx_XGOTREF(__pyx_t_39);
                      __Pyx_XGOTREF(__pyx_t_18);
                      /*try:*/ {

                        /* "ws_package/controllers/activity_controller.py":2702
 *                         if not break_interval_overlaps:
 *                             with db_lock_manager.read_lock():
 *                                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                                     # Check if interval with same start_time, end_time, and counter already exists
 *                                     check_query = select(ActivityInterval).where(
*/
                        /*with:*/ {
                          __pyx_t_33 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2702, __pyx_L570_error)
                          __Pyx_GOTREF(__pyx_t_5);
                          __pyx_t_7 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_5))) {
                            __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_5);
                            assert(__pyx_t_33);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                            __Pyx_INCREF(__pyx_t_33);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                            __pyx_t_7 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_33, NULL};
                            __pyx_t_15 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                            if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2702, __pyx_L570_error)
                            __Pyx_GOTREF(__pyx_t_15);
                          }
                          __pyx_t_21 = __Pyx_PyObject_LookupSpecial(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 2702, __pyx_L570_error)
                          __Pyx_GOTREF(__pyx_t_21);
                          __pyx_t_33 = NULL;
                          __pyx_t_3 = __Pyx_PyObject_LookupSpecial(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2702, __pyx_L578_error)
                          __Pyx_GOTREF(__pyx_t_3);
                          __pyx_t_7 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (likely(PyMethod_Check(__pyx_t_3))) {
                            __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_3);
                            assert(__pyx_t_33);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
                            __Pyx_INCREF(__pyx_t_33);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
                            __pyx_t_7 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_33, NULL};
                            __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2702, __pyx_L578_error)
                            __Pyx_GOTREF(__pyx_t_5);
                          }
                          __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
                          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                          if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_XGIVEREF(__pyx_t_11);
                            __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                            __Pyx_XGIVEREF(__pyx_t_12);
                            __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                            __Pyx_XGIVEREF(__pyx_t_13);
                            __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                            __Pyx_XGIVEREF(__pyx_t_15);
                            __pyx_cur_scope->__pyx_t_3 = __pyx_t_15;
                            __Pyx_XGIVEREF(__pyx_t_18);
                            __pyx_cur_scope->__pyx_t_4 = __pyx_t_18;
                            __Pyx_XGIVEREF(__pyx_t_21);
                            __pyx_cur_scope->__pyx_t_5 = __pyx_t_21;
                            __Pyx_XGIVEREF(__pyx_t_23);
                            __pyx_cur_scope->__pyx_t_6 = __pyx_t_23;
                            __Pyx_XGIVEREF(__pyx_t_31);
                            __pyx_cur_scope->__pyx_t_7 = __pyx_t_31;
                            __Pyx_XGIVEREF(__pyx_t_39);
                            __pyx_cur_scope->__pyx_t_8 = __pyx_t_39;
                            __Pyx_XGIVEREF(__pyx_t_46);
                            __pyx_cur_scope->__pyx_t_9 = __pyx_t_46;
                            __Pyx_XGIVEREF(__pyx_t_47);
                            __pyx_cur_scope->__pyx_t_10 = __pyx_t_47;
                            __Pyx_XGIVEREF(__pyx_t_48);
                            __pyx_cur_scope->__pyx_t_11 = __pyx_t_48;
                            __Pyx_XGIVEREF(__pyx_r);
                            __Pyx_RefNannyFinishContext();
                            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                            /* return from generator, awaiting value */
                            __pyx_generator->resume_label = 40;
                            return __pyx_r;
                            __pyx_L579_resume_from_await:;
                            __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                            __pyx_cur_scope->__pyx_t_0 = 0;
                            __Pyx_XGOTREF(__pyx_t_11);
                            __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                            __pyx_cur_scope->__pyx_t_1 = 0;
                            __Pyx_XGOTREF(__pyx_t_12);
                            __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                            __pyx_cur_scope->__pyx_t_2 = 0;
                            __Pyx_XGOTREF(__pyx_t_13);
                            __pyx_t_15 = __pyx_cur_scope->__pyx_t_3;
                            __pyx_cur_scope->__pyx_t_3 = 0;
                            __Pyx_XGOTREF(__pyx_t_15);
                            __pyx_t_18 = __pyx_cur_scope->__pyx_t_4;
                            __pyx_cur_scope->__pyx_t_4 = 0;
                            __Pyx_XGOTREF(__pyx_t_18);
                            __pyx_t_21 = __pyx_cur_scope->__pyx_t_5;
                            __pyx_cur_scope->__pyx_t_5 = 0;
                            __Pyx_XGOTREF(__pyx_t_21);
                            __pyx_t_23 = __pyx_cur_scope->__pyx_t_6;
                            __pyx_cur_scope->__pyx_t_6 = 0;
                            __Pyx_XGOTREF(__pyx_t_23);
                            __pyx_t_31 = __pyx_cur_scope->__pyx_t_7;
                            __pyx_cur_scope->__pyx_t_7 = 0;
                            __Pyx_XGOTREF(__pyx_t_31);
                            __pyx_t_39 = __pyx_cur_scope->__pyx_t_8;
                            __pyx_cur_scope->__pyx_t_8 = 0;
                            __Pyx_XGOTREF(__pyx_t_39);
                            __pyx_t_46 = __pyx_cur_scope->__pyx_t_9;
                            __pyx_cur_scope->__pyx_t_9 = 0;
                            __Pyx_XGOTREF(__pyx_t_46);
                            __pyx_t_47 = __pyx_cur_scope->__pyx_t_10;
                            __pyx_cur_scope->__pyx_t_10 = 0;
                            __Pyx_XGOTREF(__pyx_t_47);
                            __pyx_t_48 = __pyx_cur_scope->__pyx_t_11;
                            __pyx_cur_scope->__pyx_t_11 = 0;
                            __Pyx_XGOTREF(__pyx_t_48);
                            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2702, __pyx_L578_error)
                            __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
                          } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                            __Pyx_GOTREF(__pyx_r);
                            __pyx_t_5 = __pyx_r; __pyx_r = NULL;
                          } else {
                            __Pyx_XGOTREF(__pyx_r);
                            __PYX_ERR(0, 2702, __pyx_L578_error)
                          }
                          __pyx_t_3 = __pyx_t_5;
                          __pyx_t_5 = 0;
                          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                          /*try:*/ {
                            {
                              __Pyx_ExceptionSave(&__pyx_t_20, &__pyx_t_19, &__pyx_t_22);
                              __Pyx_XGOTREF(__pyx_t_20);
                              __Pyx_XGOTREF(__pyx_t_19);
                              __Pyx_XGOTREF(__pyx_t_22);
                              /*try:*/ {
                                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_session);
                                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_session, __pyx_t_3);
                                __Pyx_GIVEREF(__pyx_t_3);
                                __pyx_t_3 = 0;

                                /* "ws_package/controllers/activity_controller.py":2704
 *                                 async with async_session() as session:
 *                                     # Check if interval with same start_time, end_time, and counter already exists
 *                                     check_query = select(ActivityInterval).where(             # <<<<<<<<<<<<<<
 *                                         and_(
 *                                             ActivityInterval.start_time == start_date,
*/
                                __pyx_t_33 = NULL;
                                __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2704, __pyx_L585_error)
                                __Pyx_GOTREF(__pyx_t_6);
                                __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2704, __pyx_L585_error)
                                __Pyx_GOTREF(__pyx_t_1);
                                __pyx_t_7 = 1;
                                #if CYTHON_UNPACK_METHODS
                                if (unlikely(PyMethod_Check(__pyx_t_6))) {
                                  __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_6);
                                  assert(__pyx_t_33);
                                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                                  __Pyx_INCREF(__pyx_t_33);
                                  __Pyx_INCREF(__pyx__function);
                                  __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                                  __pyx_t_7 = 0;
                                }
                                #endif
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_33, __pyx_t_1};
                                  __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                                  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                                  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2704, __pyx_L585_error)
                                  __Pyx_GOTREF(__pyx_t_5);
                                }
                                __pyx_t_15 = __pyx_t_5;
                                __Pyx_INCREF(__pyx_t_15);

                                /* "ws_package/controllers/activity_controller.py":2705
 *                                     # Check if interval with same start_time, end_time, and counter already exists
 *                                     check_query = select(ActivityInterval).where(
 *                                         and_(             # <<<<<<<<<<<<<<
 *                                             ActivityInterval.start_time == start_date,
 *                                             ActivityInterval.end_time == end_date,
*/
                                __pyx_t_1 = NULL;
                                __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_and); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2705, __pyx_L585_error)
                                __Pyx_GOTREF(__pyx_t_33);

                                /* "ws_package/controllers/activity_controller.py":2706
 *                                     check_query = select(ActivityInterval).where(
 *                                         and_(
 *                                             ActivityInterval.start_time == start_date,             # <<<<<<<<<<<<<<
 *                                             ActivityInterval.end_time == end_date,
 *                                             ActivityInterval.counter == self.last_count + 1
*/
                                __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2706, __pyx_L585_error)
                                __Pyx_GOTREF(__pyx_t_34);
                                __pyx_t_37 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2706, __pyx_L585_error)
                                __Pyx_GOTREF(__pyx_t_37);
                                __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                                __pyx_t_34 = PyObject_RichCompare(__pyx_t_37, __pyx_cur_scope->__pyx_v_start_date, Py_EQ); __Pyx_XGOTREF(__pyx_t_34); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2706, __pyx_L585_error)
                                __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;

                                /* "ws_package/controllers/activity_controller.py":2707
 *                                         and_(
 *                                             ActivityInterval.start_time == start_date,
 *                                             ActivityInterval.end_time == end_date,             # <<<<<<<<<<<<<<
 *                                             ActivityInterval.counter == self.last_count + 1
 *                                         )
*/
                                __Pyx_GetModuleGlobalName(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2707, __pyx_L585_error)
                                __Pyx_GOTREF(__pyx_t_37);
                                __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2707, __pyx_L585_error)
                                __Pyx_GOTREF(__pyx_t_4);
                                __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                                __pyx_t_37 = PyObject_RichCompare(__pyx_t_4, __pyx_cur_scope->__pyx_v_end_date, Py_EQ); __Pyx_XGOTREF(__pyx_t_37); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2707, __pyx_L585_error)
                                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                                /* "ws_package/controllers/activity_controller.py":2708
 *                                             ActivityInterval.start_time == start_date,
 *                                             ActivityInterval.end_time == end_date,
 *                                             ActivityInterval.counter == self.last_count + 1             # <<<<<<<<<<<<<<
 *                                         )
 *                                     )
*/
                                __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2708, __pyx_L585_error)
                                __Pyx_GOTREF(__pyx_t_4);
                                __pyx_t_36 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_36)) __PYX_ERR(0, 2708, __pyx_L585_error)
                                __Pyx_GOTREF(__pyx_t_36);
                                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2708, __pyx_L585_error)
                                __Pyx_GOTREF(__pyx_t_4);
                                __pyx_t_2 = __Pyx_PyLong_AddObjC(__pyx_t_4, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2708, __pyx_L585_error)
                                __Pyx_GOTREF(__pyx_t_2);
                                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                __pyx_t_4 = PyObject_RichCompare(__pyx_t_36, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2708, __pyx_L585_error)
                                __Pyx_DECREF(__pyx_t_36); __pyx_t_36 = 0;
                                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                                __pyx_t_7 = 1;
                                #if CYTHON_UNPACK_METHODS
                                if (unlikely(PyMethod_Check(__pyx_t_33))) {
                                  __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_33);
                                  assert(__pyx_t_1);
                                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
                                  __Pyx_INCREF(__pyx_t_1);
                                  __Pyx_INCREF(__pyx__function);
                                  __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
                                  __pyx_t_7 = 0;
                                }
                                #endif
                                {
                                  PyObject *__pyx_callargs[4] = {__pyx_t_1, __pyx_t_34, __pyx_t_37, __pyx_t_4};
                                  __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                                  __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                                  __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                  __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                                  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2705, __pyx_L585_error)
                                  __Pyx_GOTREF(__pyx_t_6);
                                }
                                __pyx_t_7 = 0;
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_t_6};
                                  __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                                  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2704, __pyx_L585_error)
                                  __Pyx_GOTREF(__pyx_t_3);
                                }
                                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_check_query);
                                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_check_query, __pyx_t_3);
                                __Pyx_GIVEREF(__pyx_t_3);
                                __pyx_t_3 = 0;

                                /* "ws_package/controllers/activity_controller.py":2711
 *                                         )
 *                                     )
 *                                     result = await session.execute(check_query)             # <<<<<<<<<<<<<<
 *                                     existing = result.scalars().first()
 *                                     if existing:
*/
                                __pyx_t_5 = __pyx_cur_scope->__pyx_v_session;
                                __Pyx_INCREF(__pyx_t_5);
                                __pyx_t_7 = 0;
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_check_query};
                                  __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                                  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2711, __pyx_L585_error)
                                  __Pyx_GOTREF(__pyx_t_3);
                                }
                                __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_3, &__pyx_r);
                                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                                if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __Pyx_XGIVEREF(__pyx_t_11);
                                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                                  __Pyx_XGIVEREF(__pyx_t_12);
                                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                                  __Pyx_XGIVEREF(__pyx_t_13);
                                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                                  __Pyx_XGIVEREF(__pyx_t_18);
                                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_18;
                                  __Pyx_XGIVEREF(__pyx_t_19);
                                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_19;
                                  __Pyx_XGIVEREF(__pyx_t_20);
                                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_20;
                                  __Pyx_XGIVEREF(__pyx_t_21);
                                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_21;
                                  __Pyx_XGIVEREF(__pyx_t_22);
                                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_22;
                                  __Pyx_XGIVEREF(__pyx_t_23);
                                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_23;
                                  __Pyx_XGIVEREF(__pyx_t_31);
                                  __pyx_cur_scope->__pyx_t_9 = __pyx_t_31;
                                  __Pyx_XGIVEREF(__pyx_t_39);
                                  __pyx_cur_scope->__pyx_t_10 = __pyx_t_39;
                                  __Pyx_XGIVEREF(__pyx_t_46);
                                  __pyx_cur_scope->__pyx_t_11 = __pyx_t_46;
                                  __Pyx_XGIVEREF(__pyx_t_47);
                                  __pyx_cur_scope->__pyx_t_12 = __pyx_t_47;
                                  __Pyx_XGIVEREF(__pyx_t_48);
                                  __pyx_cur_scope->__pyx_t_13 = __pyx_t_48;
                                  __Pyx_XGIVEREF(__pyx_r);
                                  __Pyx_RefNannyFinishContext();
                                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                                  /* return from generator, awaiting value */
                                  __pyx_generator->resume_label = 41;
                                  return __pyx_r;
                                  __pyx_L593_resume_from_await:;
                                  __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                                  __pyx_cur_scope->__pyx_t_0 = 0;
                                  __Pyx_XGOTREF(__pyx_t_11);
                                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                                  __pyx_cur_scope->__pyx_t_1 = 0;
                                  __Pyx_XGOTREF(__pyx_t_12);
                                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                                  __pyx_cur_scope->__pyx_t_2 = 0;
                                  __Pyx_XGOTREF(__pyx_t_13);
                                  __pyx_t_18 = __pyx_cur_scope->__pyx_t_3;
                                  __pyx_cur_scope->__pyx_t_3 = 0;
                                  __Pyx_XGOTREF(__pyx_t_18);
                                  __pyx_t_19 = __pyx_cur_scope->__pyx_t_4;
                                  __pyx_cur_scope->__pyx_t_4 = 0;
                                  __Pyx_XGOTREF(__pyx_t_19);
                                  __pyx_t_20 = __pyx_cur_scope->__pyx_t_5;
                                  __pyx_cur_scope->__pyx_t_5 = 0;
                                  __Pyx_XGOTREF(__pyx_t_20);
                                  __pyx_t_21 = __pyx_cur_scope->__pyx_t_6;
                                  __pyx_cur_scope->__pyx_t_6 = 0;
                                  __Pyx_XGOTREF(__pyx_t_21);
                                  __pyx_t_22 = __pyx_cur_scope->__pyx_t_7;
                                  __pyx_cur_scope->__pyx_t_7 = 0;
                                  __Pyx_XGOTREF(__pyx_t_22);
                                  __pyx_t_23 = __pyx_cur_scope->__pyx_t_8;
                                  __pyx_cur_scope->__pyx_t_8 = 0;
                                  __Pyx_XGOTREF(__pyx_t_23);
                                  __pyx_t_31 = __pyx_cur_scope->__pyx_t_9;
                                  __pyx_cur_scope->__pyx_t_9 = 0;
                                  __Pyx_XGOTREF(__pyx_t_31);
                                  __pyx_t_39 = __pyx_cur_scope->__pyx_t_10;
                                  __pyx_cur_scope->__pyx_t_10 = 0;
                                  __Pyx_XGOTREF(__pyx_t_39);
                                  __pyx_t_46 = __pyx_cur_scope->__pyx_t_11;
                                  __pyx_cur_scope->__pyx_t_11 = 0;
                                  __Pyx_XGOTREF(__pyx_t_46);
                                  __pyx_t_47 = __pyx_cur_scope->__pyx_t_12;
                                  __pyx_cur_scope->__pyx_t_12 = 0;
                                  __Pyx_XGOTREF(__pyx_t_47);
                                  __pyx_t_48 = __pyx_cur_scope->__pyx_t_13;
                                  __pyx_cur_scope->__pyx_t_13 = 0;
                                  __Pyx_XGOTREF(__pyx_t_48);
                                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2711, __pyx_L585_error)
                                  __pyx_t_3 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_3);
                                } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __pyx_t_3 = __pyx_r; __pyx_r = NULL;
                                } else {
                                  __Pyx_XGOTREF(__pyx_r);
                                  __PYX_ERR(0, 2711, __pyx_L585_error)
                                }
                                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_result);
                                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_result, __pyx_t_3);
                                __Pyx_GIVEREF(__pyx_t_3);
                                __pyx_t_3 = 0;

                                /* "ws_package/controllers/activity_controller.py":2712
 *                                     )
 *                                     result = await session.execute(check_query)
 *                                     existing = result.scalars().first()             # <<<<<<<<<<<<<<
 *                                     if existing:
 *                                         interval_exists = True
*/
                                __pyx_t_15 = __pyx_cur_scope->__pyx_v_result;
                                __Pyx_INCREF(__pyx_t_15);
                                __pyx_t_7 = 0;
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL};
                                  __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalars, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                                  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2712, __pyx_L585_error)
                                  __Pyx_GOTREF(__pyx_t_6);
                                }
                                __pyx_t_5 = __pyx_t_6;
                                __Pyx_INCREF(__pyx_t_5);
                                __pyx_t_7 = 0;
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                                  __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_first, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                                  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2712, __pyx_L585_error)
                                  __Pyx_GOTREF(__pyx_t_3);
                                }
                                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_existing);
                                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_existing, __pyx_t_3);
                                __Pyx_GIVEREF(__pyx_t_3);
                                __pyx_t_3 = 0;

                                /* "ws_package/controllers/activity_controller.py":2713
 *                                     result = await session.execute(check_query)
 *                                     existing = result.scalars().first()
 *                                     if existing:             # <<<<<<<<<<<<<<
 *                                         interval_exists = True
 *                                         logger.info("Interval already exists for %s to %s (counter=%s) - skipping duplicate creation", start_date, end_date, self.last_count + 1)
*/
                                __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_existing); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2713, __pyx_L585_error)
                                if (__pyx_t_8) {

                                  /* "ws_package/controllers/activity_controller.py":2714
 *                                     existing = result.scalars().first()
 *                                     if existing:
 *                                         interval_exists = True             # <<<<<<<<<<<<<<
 *                                         logger.info("Interval already exists for %s to %s (counter=%s) - skipping duplicate creation", start_date, end_date, self.last_count + 1)
 * 
*/
                                  __pyx_cur_scope->__pyx_v_interval_exists = 1;

                                  /* "ws_package/controllers/activity_controller.py":2715
 *                                     if existing:
 *                                         interval_exists = True
 *                                         logger.info("Interval already exists for %s to %s (counter=%s) - skipping duplicate creation", start_date, end_date, self.last_count + 1)             # <<<<<<<<<<<<<<
 * 
 *                                     # Check for ANY overlapping interval (break or regular) with this time range
*/
                                  __pyx_t_6 = NULL;
                                  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2715, __pyx_L585_error)
                                  __Pyx_GOTREF(__pyx_t_5);
                                  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2715, __pyx_L585_error)
                                  __Pyx_GOTREF(__pyx_t_15);
                                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                                  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2715, __pyx_L585_error)
                                  __Pyx_GOTREF(__pyx_t_5);
                                  __pyx_t_33 = __Pyx_PyLong_AddObjC(__pyx_t_5, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2715, __pyx_L585_error)
                                  __Pyx_GOTREF(__pyx_t_33);
                                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                                  __pyx_t_7 = 1;
                                  #if CYTHON_UNPACK_METHODS
                                  if (unlikely(PyMethod_Check(__pyx_t_15))) {
                                    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_15);
                                    assert(__pyx_t_6);
                                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                                    __Pyx_INCREF(__pyx_t_6);
                                    __Pyx_INCREF(__pyx__function);
                                    __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                                    __pyx_t_7 = 0;
                                  }
                                  #endif
                                  {
                                    PyObject *__pyx_callargs[5] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Interval_already_exists_for_s_to, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date, __pyx_t_33};
                                    __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (5-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                                    __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                                    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                                    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2715, __pyx_L585_error)
                                    __Pyx_GOTREF(__pyx_t_3);
                                  }
                                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                                  /* "ws_package/controllers/activity_controller.py":2713
 *                                     result = await session.execute(check_query)
 *                                     existing = result.scalars().first()
 *                                     if existing:             # <<<<<<<<<<<<<<
 *                                         interval_exists = True
 *                                         logger.info("Interval already exists for %s to %s (counter=%s) - skipping duplicate creation", start_date, end_date, self.last_count + 1)
*/
                                }

                                /* "ws_package/controllers/activity_controller.py":2718
 * 
 *                                     # Check for ANY overlapping interval (break or regular) with this time range
 *                                     overlap_query = select(ActivityInterval).where(             # <<<<<<<<<<<<<<
 *                                         and_(
 *                                             ActivityInterval.start_time < end_date,
*/
                                __pyx_t_6 = NULL;
                                __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2718, __pyx_L585_error)
                                __Pyx_GOTREF(__pyx_t_5);
                                __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2718, __pyx_L585_error)
                                __Pyx_GOTREF(__pyx_t_4);
                                __pyx_t_7 = 1;
                                #if CYTHON_UNPACK_METHODS
                                if (unlikely(PyMethod_Check(__pyx_t_5))) {
                                  __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
                                  assert(__pyx_t_6);
                                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                                  __Pyx_INCREF(__pyx_t_6);
                                  __Pyx_INCREF(__pyx__function);
                                  __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                                  __pyx_t_7 = 0;
                                }
                                #endif
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_4};
                                  __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                                  if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2718, __pyx_L585_error)
                                  __Pyx_GOTREF(__pyx_t_33);
                                }
                                __pyx_t_15 = __pyx_t_33;
                                __Pyx_INCREF(__pyx_t_15);

                                /* "ws_package/controllers/activity_controller.py":2719
 *                                     # Check for ANY overlapping interval (break or regular) with this time range
 *                                     overlap_query = select(ActivityInterval).where(
 *                                         and_(             # <<<<<<<<<<<<<<
 *                                             ActivityInterval.start_time < end_date,
 *                                             ActivityInterval.end_time > start_date,
*/
                                __pyx_t_4 = NULL;
                                __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_and); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2719, __pyx_L585_error)
                                __Pyx_GOTREF(__pyx_t_6);

                                /* "ws_package/controllers/activity_controller.py":2720
 *                                     overlap_query = select(ActivityInterval).where(
 *                                         and_(
 *                                             ActivityInterval.start_time < end_date,             # <<<<<<<<<<<<<<
 *                                             ActivityInterval.end_time > start_date,
 *                                             ActivityInterval.counter == self.last_count + 1
*/
                                __Pyx_GetModuleGlobalName(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2720, __pyx_L585_error)
                                __Pyx_GOTREF(__pyx_t_37);
                                __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2720, __pyx_L585_error)
                                __Pyx_GOTREF(__pyx_t_34);
                                __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                                __pyx_t_37 = PyObject_RichCompare(__pyx_t_34, __pyx_cur_scope->__pyx_v_end_date, Py_LT); __Pyx_XGOTREF(__pyx_t_37); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2720, __pyx_L585_error)
                                __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;

                                /* "ws_package/controllers/activity_controller.py":2721
 *                                         and_(
 *                                             ActivityInterval.start_time < end_date,
 *                                             ActivityInterval.end_time > start_date,             # <<<<<<<<<<<<<<
 *                                             ActivityInterval.counter == self.last_count + 1
 *                                         )
*/
                                __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2721, __pyx_L585_error)
                                __Pyx_GOTREF(__pyx_t_34);
                                __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2721, __pyx_L585_error)
                                __Pyx_GOTREF(__pyx_t_1);
                                __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                                __pyx_t_34 = PyObject_RichCompare(__pyx_t_1, __pyx_cur_scope->__pyx_v_start_date, Py_GT); __Pyx_XGOTREF(__pyx_t_34); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2721, __pyx_L585_error)
                                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

                                /* "ws_package/controllers/activity_controller.py":2722
 *                                             ActivityInterval.start_time < end_date,
 *                                             ActivityInterval.end_time > start_date,
 *                                             ActivityInterval.counter == self.last_count + 1             # <<<<<<<<<<<<<<
 *                                         )
 *                                     )
*/
                                __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2722, __pyx_L585_error)
                                __Pyx_GOTREF(__pyx_t_1);
                                __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2722, __pyx_L585_error)
                                __Pyx_GOTREF(__pyx_t_2);
                                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                                __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2722, __pyx_L585_error)
                                __Pyx_GOTREF(__pyx_t_1);
                                __pyx_t_36 = __Pyx_PyLong_AddObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_36)) __PYX_ERR(0, 2722, __pyx_L585_error)
                                __Pyx_GOTREF(__pyx_t_36);
                                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                                __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_t_36, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2722, __pyx_L585_error)
                                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                                __Pyx_DECREF(__pyx_t_36); __pyx_t_36 = 0;
                                __pyx_t_7 = 1;
                                #if CYTHON_UNPACK_METHODS
                                if (unlikely(PyMethod_Check(__pyx_t_6))) {
                                  __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
                                  assert(__pyx_t_4);
                                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                                  __Pyx_INCREF(__pyx_t_4);
                                  __Pyx_INCREF(__pyx__function);
                                  __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                                  __pyx_t_7 = 0;
                                }
                                #endif
                                {
                                  PyObject *__pyx_callargs[4] = {__pyx_t_4, __pyx_t_37, __pyx_t_34, __pyx_t_1};
                                  __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                                  __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                                  __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                                  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                                  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2719, __pyx_L585_error)
                                  __Pyx_GOTREF(__pyx_t_5);
                                }
                                __pyx_t_7 = 0;
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_t_5};
                                  __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                                  __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                                  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2718, __pyx_L585_error)
                                  __Pyx_GOTREF(__pyx_t_3);
                                }
                                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_overlap_query);
                                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_overlap_query, __pyx_t_3);
                                __Pyx_GIVEREF(__pyx_t_3);
                                __pyx_t_3 = 0;

                                /* "ws_package/controllers/activity_controller.py":2725
 *                                         )
 *                                     )
 *                                     overlap_result = await session.execute(overlap_query)             # <<<<<<<<<<<<<<
 *                                     overlapping_intervals = overlap_result.scalars().all()
 * 
*/
                                __pyx_t_33 = __pyx_cur_scope->__pyx_v_session;
                                __Pyx_INCREF(__pyx_t_33);
                                __pyx_t_7 = 0;
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_33, __pyx_cur_scope->__pyx_v_overlap_query};
                                  __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                                  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2725, __pyx_L585_error)
                                  __Pyx_GOTREF(__pyx_t_3);
                                }
                                __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_3, &__pyx_r);
                                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                                if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __Pyx_XGIVEREF(__pyx_t_11);
                                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                                  __Pyx_XGIVEREF(__pyx_t_12);
                                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                                  __Pyx_XGIVEREF(__pyx_t_13);
                                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                                  __Pyx_XGIVEREF(__pyx_t_18);
                                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_18;
                                  __Pyx_XGIVEREF(__pyx_t_19);
                                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_19;
                                  __Pyx_XGIVEREF(__pyx_t_20);
                                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_20;
                                  __Pyx_XGIVEREF(__pyx_t_21);
                                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_21;
                                  __Pyx_XGIVEREF(__pyx_t_22);
                                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_22;
                                  __Pyx_XGIVEREF(__pyx_t_23);
                                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_23;
                                  __Pyx_XGIVEREF(__pyx_t_31);
                                  __pyx_cur_scope->__pyx_t_9 = __pyx_t_31;
                                  __Pyx_XGIVEREF(__pyx_t_39);
                                  __pyx_cur_scope->__pyx_t_10 = __pyx_t_39;
                                  __Pyx_XGIVEREF(__pyx_t_46);
                                  __pyx_cur_scope->__pyx_t_11 = __pyx_t_46;
                                  __Pyx_XGIVEREF(__pyx_t_47);
                                  __pyx_cur_scope->__pyx_t_12 = __pyx_t_47;
                                  __Pyx_XGIVEREF(__pyx_t_48);
                                  __pyx_cur_scope->__pyx_t_13 = __pyx_t_48;
                                  __Pyx_XGIVEREF(__pyx_r);
                                  __Pyx_RefNannyFinishContext();
                                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                                  /* return from generator, awaiting value */
                                  __pyx_generator->resume_label = 42;
                                  return __pyx_r;
                                  __pyx_L595_resume_from_await:;
                                  __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                                  __pyx_cur_scope->__pyx_t_0 = 0;
                                  __Pyx_XGOTREF(__pyx_t_11);
                                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                                  __pyx_cur_scope->__pyx_t_1 = 0;
                                  __Pyx_XGOTREF(__pyx_t_12);
                                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                                  __pyx_cur_scope->__pyx_t_2 = 0;
                                  __Pyx_XGOTREF(__pyx_t_13);
                                  __pyx_t_18 = __pyx_cur_scope->__pyx_t_3;
                                  __pyx_cur_scope->__pyx_t_3 = 0;
                                  __Pyx_XGOTREF(__pyx_t_18);
                                  __pyx_t_19 = __pyx_cur_scope->__pyx_t_4;
                                  __pyx_cur_scope->__pyx_t_4 = 0;
                                  __Pyx_XGOTREF(__pyx_t_19);
                                  __pyx_t_20 = __pyx_cur_scope->__pyx_t_5;
                                  __pyx_cur_scope->__pyx_t_5 = 0;
                                  __Pyx_XGOTREF(__pyx_t_20);
                                  __pyx_t_21 = __pyx_cur_scope->__pyx_t_6;
                                  __pyx_cur_scope->__pyx_t_6 = 0;
                                  __Pyx_XGOTREF(__pyx_t_21);
                                  __pyx_t_22 = __pyx_cur_scope->__pyx_t_7;
                                  __pyx_cur_scope->__pyx_t_7 = 0;
                                  __Pyx_XGOTREF(__pyx_t_22);
                                  __pyx_t_23 = __pyx_cur_scope->__pyx_t_8;
                                  __pyx_cur_scope->__pyx_t_8 = 0;
                                  __Pyx_XGOTREF(__pyx_t_23);
                                  __pyx_t_31 = __pyx_cur_scope->__pyx_t_9;
                                  __pyx_cur_scope->__pyx_t_9 = 0;
                                  __Pyx_XGOTREF(__pyx_t_31);
                                  __pyx_t_39 = __pyx_cur_scope->__pyx_t_10;
                                  __pyx_cur_scope->__pyx_t_10 = 0;
                                  __Pyx_XGOTREF(__pyx_t_39);
                                  __pyx_t_46 = __pyx_cur_scope->__pyx_t_11;
                                  __pyx_cur_scope->__pyx_t_11 = 0;
                                  __Pyx_XGOTREF(__pyx_t_46);
                                  __pyx_t_47 = __pyx_cur_scope->__pyx_t_12;
                                  __pyx_cur_scope->__pyx_t_12 = 0;
                                  __Pyx_XGOTREF(__pyx_t_47);
                                  __pyx_t_48 = __pyx_cur_scope->__pyx_t_13;
                                  __pyx_cur_scope->__pyx_t_13 = 0;
                                  __Pyx_XGOTREF(__pyx_t_48);
                                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2725, __pyx_L585_error)
                                  __pyx_t_3 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_3);
                                } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __pyx_t_3 = __pyx_r; __pyx_r = NULL;
                                } else {
                                  __Pyx_XGOTREF(__pyx_r);
                                  __PYX_ERR(0, 2725, __pyx_L585_error)
                                }
                                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_overlap_result);
                                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_overlap_result, __pyx_t_3);
                                __Pyx_GIVEREF(__pyx_t_3);
                                __pyx_t_3 = 0;

                                /* "ws_package/controllers/activity_controller.py":2726
 *                                     )
 *                                     overlap_result = await session.execute(overlap_query)
 *                                     overlapping_intervals = overlap_result.scalars().all()             # <<<<<<<<<<<<<<
 * 
 *                                     if overlapping_intervals:
*/
                                __pyx_t_15 = __pyx_cur_scope->__pyx_v_overlap_result;
                                __Pyx_INCREF(__pyx_t_15);
                                __pyx_t_7 = 0;
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL};
                                  __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalars, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                                  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2726, __pyx_L585_error)
                                  __Pyx_GOTREF(__pyx_t_5);
                                }
                                __pyx_t_33 = __pyx_t_5;
                                __Pyx_INCREF(__pyx_t_33);
                                __pyx_t_7 = 0;
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_33, NULL};
                                  __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_all, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                                  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2726, __pyx_L585_error)
                                  __Pyx_GOTREF(__pyx_t_3);
                                }
                                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_overlapping_intervals);
                                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_overlapping_intervals, __pyx_t_3);
                                __Pyx_GIVEREF(__pyx_t_3);
                                __pyx_t_3 = 0;

                                /* "ws_package/controllers/activity_controller.py":2728
 *                                     overlapping_intervals = overlap_result.scalars().all()
 * 
 *                                     if overlapping_intervals:             # <<<<<<<<<<<<<<
 *                                         break_intervals = [iv for iv in overlapping_intervals if iv.is_break != 0]
 *                                         regular_intervals = [iv for iv in overlapping_intervals if iv.is_break == 0]
*/
                                __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_overlapping_intervals); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2728, __pyx_L585_error)
                                if (__pyx_t_8) {

                                  /* "ws_package/controllers/activity_controller.py":2729
 * 
 *                                     if overlapping_intervals:
 *                                         break_intervals = [iv for iv in overlapping_intervals if iv.is_break != 0]             # <<<<<<<<<<<<<<
 *                                         regular_intervals = [iv for iv in overlapping_intervals if iv.is_break == 0]
 * 
*/
                                  { /* enter inner scope */
                                    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2729, __pyx_L585_error)
                                    __Pyx_GOTREF(__pyx_t_3);
                                    if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_overlapping_intervals)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_overlapping_intervals)) {
                                      __pyx_t_5 = __pyx_cur_scope->__pyx_v_overlapping_intervals; __Pyx_INCREF(__pyx_t_5);
                                      __pyx_t_29 = 0;
                                      __pyx_t_54 = NULL;
                                    } else {
                                      __pyx_t_29 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_overlapping_intervals); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2729, __pyx_L585_error)
                                      __Pyx_GOTREF(__pyx_t_5);
                                      __pyx_t_54 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); if (unlikely(!__pyx_t_54)) __PYX_ERR(0, 2729, __pyx_L585_error)
                                    }
                                    for (;;) {
                                      if (likely(!__pyx_t_54)) {
                                        if (likely(PyList_CheckExact(__pyx_t_5))) {
                                          {
                                            Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_5);
                                            #if !CYTHON_ASSUME_SAFE_SIZE
                                            if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2729, __pyx_L585_error)
                                            #endif
                                            if (__pyx_t_29 >= __pyx_temp) break;
                                          }
                                          __pyx_t_33 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_5, __pyx_t_29, __Pyx_ReferenceSharing_OwnStrongReference);
                                          ++__pyx_t_29;
                                        } else {
                                          {
                                            Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_5);
                                            #if !CYTHON_ASSUME_SAFE_SIZE
                                            if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2729, __pyx_L585_error)
                                            #endif
                                            if (__pyx_t_29 >= __pyx_temp) break;
                                          }
                                          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                                          __pyx_t_33 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_29));
                                          #else
                                          __pyx_t_33 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_29);
                                          #endif
                                          ++__pyx_t_29;
                                        }
                                        if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2729, __pyx_L585_error)
                                      } else {
                                        __pyx_t_33 = __pyx_t_54(__pyx_t_5);
                                        if (unlikely(!__pyx_t_33)) {
                                          PyObject* exc_type = PyErr_Occurred();
                                          if (exc_type) {
                                            if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 2729, __pyx_L585_error)
                                            PyErr_Clear();
                                          }
                                          break;
                                        }
                                      }
                                      __Pyx_GOTREF(__pyx_t_33);
                                      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_8genexpr2__pyx_v_iv);
                                      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_8genexpr2__pyx_v_iv, __pyx_t_33);
                                      __Pyx_GIVEREF(__pyx_t_33);
                                      __pyx_t_33 = 0;
                                      __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_8genexpr2__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_is_break); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2729, __pyx_L585_error)
                                      __Pyx_GOTREF(__pyx_t_33);
                                      __pyx_t_8 = (__Pyx_PyLong_BoolNeObjC(__pyx_t_33, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2729, __pyx_L585_error)
                                      __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                                      if (__pyx_t_8) {
                                        if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_cur_scope->__pyx_8genexpr2__pyx_v_iv))) __PYX_ERR(0, 2729, __pyx_L585_error)
                                      }
                                    }
                                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                                  } /* exit inner scope */
                                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_break_intervals);
                                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_break_intervals, ((PyObject*)__pyx_t_3));
                                  __Pyx_GIVEREF(__pyx_t_3);
                                  __pyx_t_3 = 0;

                                  /* "ws_package/controllers/activity_controller.py":2730
 *                                     if overlapping_intervals:
 *                                         break_intervals = [iv for iv in overlapping_intervals if iv.is_break != 0]
 *                                         regular_intervals = [iv for iv in overlapping_intervals if iv.is_break == 0]             # <<<<<<<<<<<<<<
 * 
 *                                         if break_intervals:
*/
                                  { /* enter inner scope */
                                    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2730, __pyx_L585_error)
                                    __Pyx_GOTREF(__pyx_t_3);
                                    if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_overlapping_intervals)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_overlapping_intervals)) {
                                      __pyx_t_5 = __pyx_cur_scope->__pyx_v_overlapping_intervals; __Pyx_INCREF(__pyx_t_5);
                                      __pyx_t_29 = 0;
                                      __pyx_t_54 = NULL;
                                    } else {
                                      __pyx_t_29 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_overlapping_intervals); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2730, __pyx_L585_error)
                                      __Pyx_GOTREF(__pyx_t_5);
                                      __pyx_t_54 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); if (unlikely(!__pyx_t_54)) __PYX_ERR(0, 2730, __pyx_L585_error)
                                    }
                                    for (;;) {
                                      if (likely(!__pyx_t_54)) {
                                        if (likely(PyList_CheckExact(__pyx_t_5))) {
                                          {
                                            Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_5);
                                            #if !CYTHON_ASSUME_SAFE_SIZE
                                            if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2730, __pyx_L585_error)
                                            #endif
                                            if (__pyx_t_29 >= __pyx_temp) break;
                                          }
                                          __pyx_t_33 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_5, __pyx_t_29, __Pyx_ReferenceSharing_OwnStrongReference);
                                          ++__pyx_t_29;
                                        } else {
                                          {
                                            Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_5);
                                            #if !CYTHON_ASSUME_SAFE_SIZE
                                            if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2730, __pyx_L585_error)
                                            #endif
                                            if (__pyx_t_29 >= __pyx_temp) break;
                                          }
                                          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                                          __pyx_t_33 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_29));
                                          #else
                                          __pyx_t_33 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_29);
                                          #endif
                                          ++__pyx_t_29;
                                        }
                                        if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2730, __pyx_L585_error)
                                      } else {
                                        __pyx_t_33 = __pyx_t_54(__pyx_t_5);
                                        if (unlikely(!__pyx_t_33)) {
                                          PyObject* exc_type = PyErr_Occurred();
                                          if (exc_type) {
                                            if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 2730, __pyx_L585_error)
                                            PyErr_Clear();
                                          }
                                          break;
                                        }
                                      }
                                      __Pyx_GOTREF(__pyx_t_33);
                                      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_8genexpr3__pyx_v_iv);
                                      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_8genexpr3__pyx_v_iv, __pyx_t_33);
                                      __Pyx_GIVEREF(__pyx_t_33);
                                      __pyx_t_33 = 0;
                                      __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_8genexpr3__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_is_break); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2730, __pyx_L585_error)
                                      __Pyx_GOTREF(__pyx_t_33);
                                      __pyx_t_8 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_33, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2730, __pyx_L585_error)
                                      __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                                      if (__pyx_t_8) {
                                        if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_cur_scope->__pyx_8genexpr3__pyx_v_iv))) __PYX_ERR(0, 2730, __pyx_L585_error)
                                      }
                                    }
                                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                                  } /* exit inner scope */
                                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_regular_intervals);
                                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_regular_intervals, ((PyObject*)__pyx_t_3));
                                  __Pyx_GIVEREF(__pyx_t_3);
                                  __pyx_t_3 = 0;

                                  /* "ws_package/controllers/activity_controller.py":2732
 *                                         regular_intervals = [iv for iv in overlapping_intervals if iv.is_break == 0]
 * 
 *                                         if break_intervals:             # <<<<<<<<<<<<<<
 *                                             break_interval_overlaps = True
 *                                             logger.info("Break interval overlaps with time range %s to %s (break intervals: %s) - skipping regular interval creation", start_date, end_date, [(iv.start_time, iv.end_time, iv.is_break) for iv in break_intervals])
*/
                                  {
                                    Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_break_intervals);
                                    if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 2732, __pyx_L585_error)
                                    __pyx_t_8 = (__pyx_temp != 0);
                                  }

                                  if (__pyx_t_8) {

                                    /* "ws_package/controllers/activity_controller.py":2733
 * 
 *                                         if break_intervals:
 *                                             break_interval_overlaps = True             # <<<<<<<<<<<<<<
 *                                             logger.info("Break interval overlaps with time range %s to %s (break intervals: %s) - skipping regular interval creation", start_date, end_date, [(iv.start_time, iv.end_time, iv.is_break) for iv in break_intervals])
 *                                         elif regular_intervals:
*/
                                    __pyx_cur_scope->__pyx_v_break_interval_overlaps = 1;

                                    /* "ws_package/controllers/activity_controller.py":2734
 *                                         if break_intervals:
 *                                             break_interval_overlaps = True
 *                                             logger.info("Break interval overlaps with time range %s to %s (break intervals: %s) - skipping regular interval creation", start_date, end_date, [(iv.start_time, iv.end_time, iv.is_break) for iv in break_intervals])             # <<<<<<<<<<<<<<
 *                                         elif regular_intervals:
 *                                             regular_interval_overlaps = True
*/
                                    __pyx_t_5 = NULL;
                                    __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2734, __pyx_L585_error)
                                    __Pyx_GOTREF(__pyx_t_33);
                                    __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2734, __pyx_L585_error)
                                    __Pyx_GOTREF(__pyx_t_15);
                                    __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                                    { /* enter inner scope */
                                      __pyx_t_33 = PyList_New(0); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2734, __pyx_L585_error)
                                      __Pyx_GOTREF(__pyx_t_33);
                                      __pyx_t_6 = __pyx_cur_scope->__pyx_v_break_intervals; __Pyx_INCREF(__pyx_t_6);
                                      __pyx_t_29 = 0;
                                      for (;;) {
                                        {
                                          Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
                                          #if !CYTHON_ASSUME_SAFE_SIZE
                                          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2734, __pyx_L585_error)
                                          #endif
                                          if (__pyx_t_29 >= __pyx_temp) break;
                                        }
                                        __pyx_t_1 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_6, __pyx_t_29, __Pyx_ReferenceSharing_OwnStrongReference);
                                        ++__pyx_t_29;
                                        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2734, __pyx_L585_error)
                                        __Pyx_GOTREF(__pyx_t_1);
                                        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_8genexpr4__pyx_v_iv);
                                        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_8genexpr4__pyx_v_iv, __pyx_t_1);
                                        __Pyx_GIVEREF(__pyx_t_1);
                                        __pyx_t_1 = 0;
                                        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_8genexpr4__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2734, __pyx_L585_error)
                                        __Pyx_GOTREF(__pyx_t_1);
                                        __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_8genexpr4__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2734, __pyx_L585_error)
                                        __Pyx_GOTREF(__pyx_t_34);
                                        __pyx_t_37 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_8genexpr4__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_is_break); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2734, __pyx_L585_error)
                                        __Pyx_GOTREF(__pyx_t_37);
                                        __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2734, __pyx_L585_error)
                                        __Pyx_GOTREF(__pyx_t_4);
                                        __Pyx_GIVEREF(__pyx_t_1);
                                        if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 2734, __pyx_L585_error);
                                        __Pyx_GIVEREF(__pyx_t_34);
                                        if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_34) != (0)) __PYX_ERR(0, 2734, __pyx_L585_error);
                                        __Pyx_GIVEREF(__pyx_t_37);
                                        if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_37) != (0)) __PYX_ERR(0, 2734, __pyx_L585_error);
                                        __pyx_t_1 = 0;
                                        __pyx_t_34 = 0;
                                        __pyx_t_37 = 0;
                                        if (unlikely(__Pyx_ListComp_Append(__pyx_t_33, (PyObject*)__pyx_t_4))) __PYX_ERR(0, 2734, __pyx_L585_error)
                                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                      }
                                      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                                    } /* exit inner scope */
                                    __pyx_t_7 = 1;
                                    #if CYTHON_UNPACK_METHODS
                                    if (unlikely(PyMethod_Check(__pyx_t_15))) {
                                      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_15);
                                      assert(__pyx_t_5);
                                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                                      __Pyx_INCREF(__pyx_t_5);
                                      __Pyx_INCREF(__pyx__function);
                                      __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                                      __pyx_t_7 = 0;
                                    }
                                    #endif
                                    {
                                      PyObject *__pyx_callargs[5] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Break_interval_overlaps_with_tim, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date, __pyx_t_33};
                                      __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (5-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                                      __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                                      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                                      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2734, __pyx_L585_error)
                                      __Pyx_GOTREF(__pyx_t_3);
                                    }
                                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                                    /* "ws_package/controllers/activity_controller.py":2732
 *                                         regular_intervals = [iv for iv in overlapping_intervals if iv.is_break == 0]
 * 
 *                                         if break_intervals:             # <<<<<<<<<<<<<<
 *                                             break_interval_overlaps = True
 *                                             logger.info("Break interval overlaps with time range %s to %s (break intervals: %s) - skipping regular interval creation", start_date, end_date, [(iv.start_time, iv.end_time, iv.is_break) for iv in break_intervals])
*/
                                    goto __pyx_L605;
                                  }

                                  /* "ws_package/controllers/activity_controller.py":2735
 *                                             break_interval_overlaps = True
 *                                             logger.info("Break interval overlaps with time range %s to %s (break intervals: %s) - skipping regular interval creation", start_date, end_date, [(iv.start_time, iv.end_time, iv.is_break) for iv in break_intervals])
 *                                         elif regular_intervals:             # <<<<<<<<<<<<<<
 *                                             regular_interval_overlaps = True
 *                                             overlapping_details = [(iv.start_time, iv.end_time, iv.is_break) for iv in regular_intervals]
*/
                                  {
                                    Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_regular_intervals);
                                    if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 2735, __pyx_L585_error)
                                    __pyx_t_8 = (__pyx_temp != 0);
                                  }

                                  if (__pyx_t_8) {

                                    /* "ws_package/controllers/activity_controller.py":2736
 *                                             logger.info("Break interval overlaps with time range %s to %s (break intervals: %s) - skipping regular interval creation", start_date, end_date, [(iv.start_time, iv.end_time, iv.is_break) for iv in break_intervals])
 *                                         elif regular_intervals:
 *                                             regular_interval_overlaps = True             # <<<<<<<<<<<<<<
 *                                             overlapping_details = [(iv.start_time, iv.end_time, iv.is_break) for iv in regular_intervals]
 *                                             logger.info("Regular interval overlaps with time range %s to %s (overlapping intervals: %s) - skipping duplicate creation to prevent overlap", start_date, end_date, overlapping_details)
*/
                                    __pyx_cur_scope->__pyx_v_regular_interval_overlaps = 1;

                                    /* "ws_package/controllers/activity_controller.py":2737
 *                                         elif regular_intervals:
 *                                             regular_interval_overlaps = True
 *                                             overlapping_details = [(iv.start_time, iv.end_time, iv.is_break) for iv in regular_intervals]             # <<<<<<<<<<<<<<
 *                                             logger.info("Regular interval overlaps with time range %s to %s (overlapping intervals: %s) - skipping duplicate creation to prevent overlap", start_date, end_date, overlapping_details)
 *                     except Exception as e:
*/
                                    { /* enter inner scope */
                                      __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2737, __pyx_L585_error)
                                      __Pyx_GOTREF(__pyx_t_3);
                                      __pyx_t_15 = __pyx_cur_scope->__pyx_v_regular_intervals; __Pyx_INCREF(__pyx_t_15);
                                      __pyx_t_29 = 0;
                                      for (;;) {
                                        {
                                          Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_15);
                                          #if !CYTHON_ASSUME_SAFE_SIZE
                                          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2737, __pyx_L585_error)
                                          #endif
                                          if (__pyx_t_29 >= __pyx_temp) break;
                                        }
                                        __pyx_t_33 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_15, __pyx_t_29, __Pyx_ReferenceSharing_OwnStrongReference);
                                        ++__pyx_t_29;
                                        if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2737, __pyx_L585_error)
                                        __Pyx_GOTREF(__pyx_t_33);
                                        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_8genexpr5__pyx_v_iv);
                                        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_8genexpr5__pyx_v_iv, __pyx_t_33);
                                        __Pyx_GIVEREF(__pyx_t_33);
                                        __pyx_t_33 = 0;
                                        __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_8genexpr5__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2737, __pyx_L585_error)
                                        __Pyx_GOTREF(__pyx_t_33);
                                        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_8genexpr5__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2737, __pyx_L585_error)
                                        __Pyx_GOTREF(__pyx_t_5);
                                        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_8genexpr5__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_is_break); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2737, __pyx_L585_error)
                                        __Pyx_GOTREF(__pyx_t_6);
                                        __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2737, __pyx_L585_error)
                                        __Pyx_GOTREF(__pyx_t_4);
                                        __Pyx_GIVEREF(__pyx_t_33);
                                        if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_33) != (0)) __PYX_ERR(0, 2737, __pyx_L585_error);
                                        __Pyx_GIVEREF(__pyx_t_5);
                                        if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5) != (0)) __PYX_ERR(0, 2737, __pyx_L585_error);
                                        __Pyx_GIVEREF(__pyx_t_6);
                                        if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_t_6) != (0)) __PYX_ERR(0, 2737, __pyx_L585_error);
                                        __pyx_t_33 = 0;
                                        __pyx_t_5 = 0;
                                        __pyx_t_6 = 0;
                                        if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_4))) __PYX_ERR(0, 2737, __pyx_L585_error)
                                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                      }
                                      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                                    } /* exit inner scope */
                                    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_overlapping_details);
                                    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_overlapping_details, ((PyObject*)__pyx_t_3));
                                    __Pyx_GIVEREF(__pyx_t_3);
                                    __pyx_t_3 = 0;

                                    /* "ws_package/controllers/activity_controller.py":2738
 *                                             regular_interval_overlaps = True
 *                                             overlapping_details = [(iv.start_time, iv.end_time, iv.is_break) for iv in regular_intervals]
 *                                             logger.info("Regular interval overlaps with time range %s to %s (overlapping intervals: %s) - skipping duplicate creation to prevent overlap", start_date, end_date, overlapping_details)             # <<<<<<<<<<<<<<
 *                     except Exception as e:
 *                         logger.warning("Error checking for existing interval: %s - will proceed with creation (non-critical)", e)
*/
                                    __pyx_t_15 = NULL;
                                    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2738, __pyx_L585_error)
                                    __Pyx_GOTREF(__pyx_t_4);
                                    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2738, __pyx_L585_error)
                                    __Pyx_GOTREF(__pyx_t_6);
                                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                    __pyx_t_7 = 1;
                                    #if CYTHON_UNPACK_METHODS
                                    if (unlikely(PyMethod_Check(__pyx_t_6))) {
                                      __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_6);
                                      assert(__pyx_t_15);
                                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                                      __Pyx_INCREF(__pyx_t_15);
                                      __Pyx_INCREF(__pyx__function);
                                      __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                                      __pyx_t_7 = 0;
                                    }
                                    #endif
                                    {
                                      PyObject *__pyx_callargs[5] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Regular_interval_overlaps_with_t, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date, __pyx_cur_scope->__pyx_v_overlapping_details};
                                      __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (5-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                                      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                                      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2738, __pyx_L585_error)
                                      __Pyx_GOTREF(__pyx_t_3);
                                    }
                                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                                    /* "ws_package/controllers/activity_controller.py":2735
 *                                             break_interval_overlaps = True
 *                                             logger.info("Break interval overlaps with time range %s to %s (break intervals: %s) - skipping regular interval creation", start_date, end_date, [(iv.start_time, iv.end_time, iv.is_break) for iv in break_intervals])
 *                                         elif regular_intervals:             # <<<<<<<<<<<<<<
 *                                             regular_interval_overlaps = True
 *                                             overlapping_details = [(iv.start_time, iv.end_time, iv.is_break) for iv in regular_intervals]
*/
                                  }
                                  __pyx_L605:;

                                  /* "ws_package/controllers/activity_controller.py":2728
 *                                     overlapping_intervals = overlap_result.scalars().all()
 * 
 *                                     if overlapping_intervals:             # <<<<<<<<<<<<<<
 *                                         break_intervals = [iv for iv in overlapping_intervals if iv.is_break != 0]
 *                                         regular_intervals = [iv for iv in overlapping_intervals if iv.is_break == 0]
*/
                                }

                                /* "ws_package/controllers/activity_controller.py":2702
 *                         if not break_interval_overlaps:
 *                             with db_lock_manager.read_lock():
 *                                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                                     # Check if interval with same start_time, end_time, and counter already exists
 *                                     check_query = select(ActivityInterval).where(
*/
                              }
                              __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                              __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                              __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                              goto __pyx_L592_try_end;
                              __pyx_L585_error:;
                              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                              __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                              __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                              __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                              __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                              __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                              __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                              __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                              /*except:*/ {
                                __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
                                if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_6, &__pyx_t_15) < 0) __PYX_ERR(0, 2702, __pyx_L587_except_error)
                                __Pyx_XGOTREF(__pyx_t_3);
                                __Pyx_XGOTREF(__pyx_t_6);
                                __Pyx_XGOTREF(__pyx_t_15);
                                __pyx_t_4 = PyTuple_Pack(3, __pyx_t_3, __pyx_t_6, __pyx_t_15); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2702, __pyx_L587_except_error)
                                __Pyx_GOTREF(__pyx_t_4);
                                __pyx_t_32 = __Pyx_PyObject_Call(__pyx_t_21, __pyx_t_4, NULL);
                                __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 2702, __pyx_L587_except_error)
                                __Pyx_GOTREF(__pyx_t_32);
                                __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_32, &__pyx_r);
                                __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0;
                                if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __Pyx_XGIVEREF(__pyx_t_3);
                                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
                                  __Pyx_XGIVEREF(__pyx_t_6);
                                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
                                  __Pyx_XGIVEREF(__pyx_t_11);
                                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_11;
                                  __Pyx_XGIVEREF(__pyx_t_12);
                                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                                  __Pyx_XGIVEREF(__pyx_t_13);
                                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                                  __Pyx_XGIVEREF(__pyx_t_15);
                                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_15;
                                  __Pyx_XGIVEREF(__pyx_t_18);
                                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_18;
                                  __Pyx_XGIVEREF(__pyx_t_19);
                                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_19;
                                  __Pyx_XGIVEREF(__pyx_t_20);
                                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_20;
                                  __Pyx_XGIVEREF(__pyx_t_21);
                                  __pyx_cur_scope->__pyx_t_9 = __pyx_t_21;
                                  __Pyx_XGIVEREF(__pyx_t_22);
                                  __pyx_cur_scope->__pyx_t_10 = __pyx_t_22;
                                  __Pyx_XGIVEREF(__pyx_t_23);
                                  __pyx_cur_scope->__pyx_t_11 = __pyx_t_23;
                                  __Pyx_XGIVEREF(__pyx_t_31);
                                  __pyx_cur_scope->__pyx_t_12 = __pyx_t_31;
                                  __Pyx_XGIVEREF(__pyx_t_32);
                                  __pyx_cur_scope->__pyx_t_13 = __pyx_t_32;
                                  __Pyx_XGIVEREF(__pyx_t_39);
                                  __pyx_cur_scope->__pyx_t_14 = __pyx_t_39;
                                  __Pyx_XGIVEREF(__pyx_t_46);
                                  __pyx_cur_scope->__pyx_t_16 = __pyx_t_46;
                                  __Pyx_XGIVEREF(__pyx_t_47);
                                  __pyx_cur_scope->__pyx_t_17 = __pyx_t_47;
                                  __Pyx_XGIVEREF(__pyx_t_48);
                                  __pyx_cur_scope->__pyx_t_18 = __pyx_t_48;
                                  __Pyx_XGIVEREF(__pyx_r);
                                  __Pyx_RefNannyFinishContext();
                                  __Pyx_Coroutine_SwapException(__pyx_generator);
                                  /* return from generator, awaiting value */
                                  __pyx_generator->resume_label = 43;
                                  return __pyx_r;
                                  __pyx_L615_resume_from_await:;
                                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
                                  __pyx_cur_scope->__pyx_t_0 = 0;
                                  __Pyx_XGOTREF(__pyx_t_3);
                                  __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
                                  __pyx_cur_scope->__pyx_t_1 = 0;
                                  __Pyx_XGOTREF(__pyx_t_6);
                                  __pyx_t_11 = __pyx_cur_scope->__pyx_t_2;
                                  __pyx_cur_scope->__pyx_t_2 = 0;
                                  __Pyx_XGOTREF(__pyx_t_11);
                                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                                  __pyx_cur_scope->__pyx_t_3 = 0;
                                  __Pyx_XGOTREF(__pyx_t_12);
                                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                                  __pyx_cur_scope->__pyx_t_4 = 0;
                                  __Pyx_XGOTREF(__pyx_t_13);
                                  __pyx_t_15 = __pyx_cur_scope->__pyx_t_5;
                                  __pyx_cur_scope->__pyx_t_5 = 0;
                                  __Pyx_XGOTREF(__pyx_t_15);
                                  __pyx_t_18 = __pyx_cur_scope->__pyx_t_6;
                                  __pyx_cur_scope->__pyx_t_6 = 0;
                                  __Pyx_XGOTREF(__pyx_t_18);
                                  __pyx_t_19 = __pyx_cur_scope->__pyx_t_7;
                                  __pyx_cur_scope->__pyx_t_7 = 0;
                                  __Pyx_XGOTREF(__pyx_t_19);
                                  __pyx_t_20 = __pyx_cur_scope->__pyx_t_8;
                                  __pyx_cur_scope->__pyx_t_8 = 0;
                                  __Pyx_XGOTREF(__pyx_t_20);
                                  __pyx_t_21 = __pyx_cur_scope->__pyx_t_9;
                                  __pyx_cur_scope->__pyx_t_9 = 0;
                                  __Pyx_XGOTREF(__pyx_t_21);
                                  __pyx_t_22 = __pyx_cur_scope->__pyx_t_10;
                                  __pyx_cur_scope->__pyx_t_10 = 0;
                                  __Pyx_XGOTREF(__pyx_t_22);
                                  __pyx_t_23 = __pyx_cur_scope->__pyx_t_11;
                                  __pyx_cur_scope->__pyx_t_11 = 0;
                                  __Pyx_XGOTREF(__pyx_t_23);
                                  __pyx_t_31 = __pyx_cur_scope->__pyx_t_12;
                                  __pyx_cur_scope->__pyx_t_12 = 0;
                                  __Pyx_XGOTREF(__pyx_t_31);
                                  __pyx_t_32 = __pyx_cur_scope->__pyx_t_13;
                                  __pyx_cur_scope->__pyx_t_13 = 0;
                                  __Pyx_XGOTREF(__pyx_t_32);
                                  __pyx_t_39 = __pyx_cur_scope->__pyx_t_14;
                                  __pyx_cur_scope->__pyx_t_14 = 0;
                                  __Pyx_XGOTREF(__pyx_t_39);
                                  __pyx_t_46 = __pyx_cur_scope->__pyx_t_16;
                                  __pyx_cur_scope->__pyx_t_16 = 0;
                                  __Pyx_XGOTREF(__pyx_t_46);
                                  __pyx_t_47 = __pyx_cur_scope->__pyx_t_17;
                                  __pyx_cur_scope->__pyx_t_17 = 0;
                                  __Pyx_XGOTREF(__pyx_t_47);
                                  __pyx_t_48 = __pyx_cur_scope->__pyx_t_18;
                                  __pyx_cur_scope->__pyx_t_18 = 0;
                                  __Pyx_XGOTREF(__pyx_t_48);
                                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2702, __pyx_L587_except_error)
                                  __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                                } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                                } else {
                                  __Pyx_XGOTREF(__pyx_r);
                                  __PYX_ERR(0, 2702, __pyx_L587_except_error)
                                }
                                __pyx_t_32 = __pyx_t_4;
                                __pyx_t_4 = 0;
                                __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_32);
                                __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0;
                                if (__pyx_t_8 < (0)) __PYX_ERR(0, 2702, __pyx_L587_except_error)
                                __pyx_t_9 = (!__pyx_t_8);
                                if (unlikely(__pyx_t_9)) {
                                  __Pyx_GIVEREF(__pyx_t_3);
                                  __Pyx_GIVEREF(__pyx_t_6);
                                  __Pyx_XGIVEREF(__pyx_t_15);
                                  __Pyx_ErrRestoreWithState(__pyx_t_3, __pyx_t_6, __pyx_t_15);
                                  __pyx_t_3 = 0;  __pyx_t_6 = 0;  __pyx_t_15 = 0; 
                                  __PYX_ERR(0, 2702, __pyx_L587_except_error)
                                }
                                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                                goto __pyx_L586_exception_handled;
                              }
                              __pyx_L587_except_error:;
                              __Pyx_XGIVEREF(__pyx_t_20);
                              __Pyx_XGIVEREF(__pyx_t_19);
                              __Pyx_XGIVEREF(__pyx_t_22);
                              __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_19, __pyx_t_22);
                              goto __pyx_L570_error;
                              __pyx_L586_exception_handled:;
                              __Pyx_XGIVEREF(__pyx_t_20);
                              __Pyx_XGIVEREF(__pyx_t_19);
                              __Pyx_XGIVEREF(__pyx_t_22);
                              __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_19, __pyx_t_22);
                              __pyx_L592_try_end:;
                            }
                          }
                          /*finally:*/ {
                            /*normal exit:*/{
                              if (__pyx_t_21) {
                                __pyx_t_22 = __Pyx_PyObject_Call(__pyx_t_21, __pyx_mstate_global->__pyx_tuple[7], NULL);
                                __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                                if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 2702, __pyx_L570_error)
                                __Pyx_GOTREF(__pyx_t_22);
                                __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_22, &__pyx_r);
                                __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                                if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __Pyx_XGIVEREF(__pyx_t_11);
                                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                                  __Pyx_XGIVEREF(__pyx_t_12);
                                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                                  __Pyx_XGIVEREF(__pyx_t_13);
                                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                                  __Pyx_XGIVEREF(__pyx_t_18);
                                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_18;
                                  __Pyx_XGIVEREF(__pyx_t_21);
                                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_21;
                                  __Pyx_XGIVEREF(__pyx_t_22);
                                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_22;
                                  __Pyx_XGIVEREF(__pyx_t_23);
                                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_23;
                                  __Pyx_XGIVEREF(__pyx_t_31);
                                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_31;
                                  __Pyx_XGIVEREF(__pyx_t_39);
                                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_39;
                                  __Pyx_XGIVEREF(__pyx_t_46);
                                  __pyx_cur_scope->__pyx_t_9 = __pyx_t_46;
                                  __Pyx_XGIVEREF(__pyx_t_47);
                                  __pyx_cur_scope->__pyx_t_10 = __pyx_t_47;
                                  __Pyx_XGIVEREF(__pyx_t_48);
                                  __pyx_cur_scope->__pyx_t_11 = __pyx_t_48;
                                  __Pyx_XGIVEREF(__pyx_r);
                                  __Pyx_RefNannyFinishContext();
                                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                                  /* return from generator, awaiting value */
                                  __pyx_generator->resume_label = 44;
                                  return __pyx_r;
                                  __pyx_L616_resume_from_await:;
                                  __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                                  __pyx_cur_scope->__pyx_t_0 = 0;
                                  __Pyx_XGOTREF(__pyx_t_11);
                                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                                  __pyx_cur_scope->__pyx_t_1 = 0;
                                  __Pyx_XGOTREF(__pyx_t_12);
                                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                                  __pyx_cur_scope->__pyx_t_2 = 0;
                                  __Pyx_XGOTREF(__pyx_t_13);
                                  __pyx_t_18 = __pyx_cur_scope->__pyx_t_3;
                                  __pyx_cur_scope->__pyx_t_3 = 0;
                                  __Pyx_XGOTREF(__pyx_t_18);
                                  __pyx_t_21 = __pyx_cur_scope->__pyx_t_4;
                                  __pyx_cur_scope->__pyx_t_4 = 0;
                                  __Pyx_XGOTREF(__pyx_t_21);
                                  __pyx_t_22 = __pyx_cur_scope->__pyx_t_5;
                                  __pyx_cur_scope->__pyx_t_5 = 0;
                                  __Pyx_XGOTREF(__pyx_t_22);
                                  __pyx_t_23 = __pyx_cur_scope->__pyx_t_6;
                                  __pyx_cur_scope->__pyx_t_6 = 0;
                                  __Pyx_XGOTREF(__pyx_t_23);
                                  __pyx_t_31 = __pyx_cur_scope->__pyx_t_7;
                                  __pyx_cur_scope->__pyx_t_7 = 0;
                                  __Pyx_XGOTREF(__pyx_t_31);
                                  __pyx_t_39 = __pyx_cur_scope->__pyx_t_8;
                                  __pyx_cur_scope->__pyx_t_8 = 0;
                                  __Pyx_XGOTREF(__pyx_t_39);
                                  __pyx_t_46 = __pyx_cur_scope->__pyx_t_9;
                                  __pyx_cur_scope->__pyx_t_9 = 0;
                                  __Pyx_XGOTREF(__pyx_t_46);
                                  __pyx_t_47 = __pyx_cur_scope->__pyx_t_10;
                                  __pyx_cur_scope->__pyx_t_10 = 0;
                                  __Pyx_XGOTREF(__pyx_t_47);
                                  __pyx_t_48 = __pyx_cur_scope->__pyx_t_11;
                                  __pyx_cur_scope->__pyx_t_11 = 0;
                                  __Pyx_XGOTREF(__pyx_t_48);
                                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2702, __pyx_L570_error)
                                  __pyx_t_15 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_15);
                                } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __pyx_t_15 = __pyx_r; __pyx_r = NULL;
                                } else {
                                  __Pyx_XGOTREF(__pyx_r);
                                  __PYX_ERR(0, 2702, __pyx_L570_error)
                                }
                                __pyx_t_22 = __pyx_t_15;
                                __pyx_t_15 = 0;
                                __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                              }
                              goto __pyx_L584;
                            }
                            __pyx_L584:;
                          }
                          goto __pyx_L617;
                          __pyx_L578_error:;
                          __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                          goto __pyx_L570_error;
                          __pyx_L617:;
                        }

                        /* "ws_package/controllers/activity_controller.py":2701
 * 
 *                         if not break_interval_overlaps:
 *                             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                                 async with async_session() as session:
 *                                     # Check if interval with same start_time, end_time, and counter already exists
*/
                      }
                      __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                      __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                      __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                      goto __pyx_L577_try_end;
                      __pyx_L570_error:;
                      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                      __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                      __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                      __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                      __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                      __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                      __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                      /*except:*/ {
                        __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
                        if (__Pyx_GetException(&__pyx_t_15, &__pyx_t_6, &__pyx_t_3) < 0) __PYX_ERR(0, 2701, __pyx_L572_except_error)
                        __Pyx_XGOTREF(__pyx_t_15);
                        __Pyx_XGOTREF(__pyx_t_6);
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_4 = PyTuple_Pack(3, __pyx_t_15, __pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2701, __pyx_L572_except_error)
                        __Pyx_GOTREF(__pyx_t_4);
                        __pyx_t_21 = __Pyx_PyObject_Call(__pyx_t_31, __pyx_t_4, NULL);
                        __Pyx_DECREF(__pyx_t_31); __pyx_t_31 = 0;
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 2701, __pyx_L572_except_error)
                        __Pyx_GOTREF(__pyx_t_21);
                        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_21);
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        if (__pyx_t_9 < (0)) __PYX_ERR(0, 2701, __pyx_L572_except_error)
                        __pyx_t_8 = (!__pyx_t_9);
                        if (unlikely(__pyx_t_8)) {
                          __Pyx_GIVEREF(__pyx_t_15);
                          __Pyx_GIVEREF(__pyx_t_6);
                          __Pyx_XGIVEREF(__pyx_t_3);
                          __Pyx_ErrRestoreWithState(__pyx_t_15, __pyx_t_6, __pyx_t_3);
                          __pyx_t_15 = 0;  __pyx_t_6 = 0;  __pyx_t_3 = 0; 
                          __PYX_ERR(0, 2701, __pyx_L572_except_error)
                        }
                        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                        goto __pyx_L571_exception_handled;
                      }
                      __pyx_L572_except_error:;
                      __Pyx_XGIVEREF(__pyx_t_23);
                      __Pyx_XGIVEREF(__pyx_t_39);
                      __Pyx_XGIVEREF(__pyx_t_18);
                      __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_39, __pyx_t_18);
                      goto __pyx_L544_error;
                      __pyx_L571_exception_handled:;
                      __Pyx_XGIVEREF(__pyx_t_23);
                      __Pyx_XGIVEREF(__pyx_t_39);
                      __Pyx_XGIVEREF(__pyx_t_18);
                      __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_39, __pyx_t_18);
                      __pyx_L577_try_end:;
                    }
                  }
                  /*finally:*/ {
                    /*normal exit:*/{
                      if (__pyx_t_31) {
                        __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_31, __pyx_mstate_global->__pyx_tuple[7], NULL);
                        __Pyx_DECREF(__pyx_t_31); __pyx_t_31 = 0;
                        if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 2701, __pyx_L544_error)
                        __Pyx_GOTREF(__pyx_t_18);
                        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                      }
                      goto __pyx_L569;
                    }
                    __pyx_L569:;
                  }
                  goto __pyx_L621;
                  __pyx_L564_error:;
                  __Pyx_DECREF(__pyx_t_31); __pyx_t_31 = 0;
                  goto __pyx_L544_error;
                  __pyx_L621:;
                }

                /* "ws_package/controllers/activity_controller.py":2700
 *                                     break
 * 
 *                         if not break_interval_overlaps:             # <<<<<<<<<<<<<<
 *                             with db_lock_manager.read_lock():
 *                                 async with async_session() as session:
*/
              }

              /* "ws_package/controllers/activity_controller.py":2682
 *                     break_interval_overlaps = False
 *                     regular_interval_overlaps = False
 *                     try:             # <<<<<<<<<<<<<<
 *                         # Check pending write queue for break intervals that overlap this slot.
 *                         # This is non-blocking (no DB flush needed) and prevents event-loop stalls.
*/
            }
            __Pyx_XDECREF(__pyx_t_48); __pyx_t_48 = 0;
            __Pyx_XDECREF(__pyx_t_47); __pyx_t_47 = 0;
            __Pyx_XDECREF(__pyx_t_46); __pyx_t_46 = 0;
            goto __pyx_L551_try_end;
            __pyx_L544_error:;
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
            __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
            __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
            __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
            __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
            __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

            /* "ws_package/controllers/activity_controller.py":2739
 *                                             overlapping_details = [(iv.start_time, iv.end_time, iv.is_break) for iv in regular_intervals]
 *                                             logger.info("Regular interval overlaps with time range %s to %s (overlapping intervals: %s) - skipping duplicate creation to prevent overlap", start_date, end_date, overlapping_details)
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.warning("Error checking for existing interval: %s - will proceed with creation (non-critical)", e)
 *                         # If check fails, proceed with creation (better to have duplicate than miss interval)
*/
            __pyx_t_16 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
            if (__pyx_t_16) {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_6, &__pyx_t_15) < 0) __PYX_ERR(0, 2739, __pyx_L546_except_error)
              __Pyx_XGOTREF(__pyx_t_3);
              __Pyx_XGOTREF(__pyx_t_6);
              __Pyx_XGOTREF(__pyx_t_15);
              __Pyx_INCREF(__pyx_t_6);
              __Pyx_GIVEREF(__pyx_t_6);
              __pyx_cur_scope->__pyx_v_e = __pyx_t_6;
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":2740
 *                                             logger.info("Regular interval overlaps with time range %s to %s (overlapping intervals: %s) - skipping duplicate creation to prevent overlap", start_date, end_date, overlapping_details)
 *                     except Exception as e:
 *                         logger.warning("Error checking for existing interval: %s - will proceed with creation (non-critical)", e)             # <<<<<<<<<<<<<<
 *                         # If check fails, proceed with creation (better to have duplicate than miss interval)
 * 
*/
                __pyx_t_5 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2740, __pyx_L627_error)
                __Pyx_GOTREF(__pyx_t_33);
                __pyx_t_37 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2740, __pyx_L627_error)
                __Pyx_GOTREF(__pyx_t_37);
                __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_37))) {
                  __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_37);
                  assert(__pyx_t_5);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_37);
                  __Pyx_INCREF(__pyx_t_5);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_37, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Error_checking_for_existing_inte, __pyx_cur_scope->__pyx_v_e};
                  __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_37, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2740, __pyx_L627_error)
                  __Pyx_GOTREF(__pyx_t_4);
                }
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              }

              /* "ws_package/controllers/activity_controller.py":2739
 *                                             overlapping_details = [(iv.start_time, iv.end_time, iv.is_break) for iv in regular_intervals]
 *                                             logger.info("Regular interval overlaps with time range %s to %s (overlapping intervals: %s) - skipping duplicate creation to prevent overlap", start_date, end_date, overlapping_details)
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.warning("Error checking for existing interval: %s - will proceed with creation (non-critical)", e)
 *                         # If check fails, proceed with creation (better to have duplicate than miss interval)
*/
              /*finally:*/ {
                /*normal exit:*/{
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  goto __pyx_L628;
                }
                __pyx_L627_error:;
                /*exception exit:*/{
                  __Pyx_PyThreadState_assign
                  __pyx_t_31 = 0; __pyx_t_18 = 0; __pyx_t_39 = 0; __pyx_t_23 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0;
                  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                  __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                  __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                  __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                  __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                  __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                  __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                   __Pyx_ExceptionSwap(&__pyx_t_23, &__pyx_t_21, &__pyx_t_22);
                  if ( unlikely(__Pyx_GetException(&__pyx_t_31, &__pyx_t_18, &__pyx_t_39) < 0)) __Pyx_ErrFetch(&__pyx_t_31, &__pyx_t_18, &__pyx_t_39);
                  __Pyx_XGOTREF(__pyx_t_31);
                  __Pyx_XGOTREF(__pyx_t_18);
                  __Pyx_XGOTREF(__pyx_t_39);
                  __Pyx_XGOTREF(__pyx_t_23);
                  __Pyx_XGOTREF(__pyx_t_21);
                  __Pyx_XGOTREF(__pyx_t_22);
                  __pyx_t_16 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_59 = __pyx_filename;
                  {
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  }
                  __Pyx_XGIVEREF(__pyx_t_23);
                  __Pyx_XGIVEREF(__pyx_t_21);
                  __Pyx_XGIVEREF(__pyx_t_22);
                  __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_21, __pyx_t_22);
                  __Pyx_XGIVEREF(__pyx_t_31);
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __Pyx_XGIVEREF(__pyx_t_39);
                  __Pyx_ErrRestore(__pyx_t_31, __pyx_t_18, __pyx_t_39);
                  __pyx_t_31 = 0; __pyx_t_18 = 0; __pyx_t_39 = 0; __pyx_t_23 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0;
                  __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_59;
                  goto __pyx_L546_except_error;
                }
                __pyx_L628:;
              }
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
              goto __pyx_L545_exception_handled;
            }
            goto __pyx_L546_except_error;

            /* "ws_package/controllers/activity_controller.py":2682
 *                     break_interval_overlaps = False
 *                     regular_interval_overlaps = False
 *                     try:             # <<<<<<<<<<<<<<
 *                         # Check pending write queue for break intervals that overlap this slot.
 *                         # This is non-blocking (no DB flush needed) and prevents event-loop stalls.
*/
            __pyx_L546_except_error:;
            __Pyx_XGIVEREF(__pyx_t_48);
            __Pyx_XGIVEREF(__pyx_t_47);
            __Pyx_XGIVEREF(__pyx_t_46);
            __Pyx_ExceptionReset(__pyx_t_48, __pyx_t_47, __pyx_t_46);
            goto __pyx_L263_error;
            __pyx_L545_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_48);
            __Pyx_XGIVEREF(__pyx_t_47);
            __Pyx_XGIVEREF(__pyx_t_46);
            __Pyx_ExceptionReset(__pyx_t_48, __pyx_t_47, __pyx_t_46);
            __pyx_L551_try_end:;
          }

          /* "ws_package/controllers/activity_controller.py":2743
 *                         # If check fails, proceed with creation (better to have duplicate than miss interval)
 * 
 *                     if not interval_exists and not break_interval_overlaps and not regular_interval_overlaps:             # <<<<<<<<<<<<<<
 *                         try:
 *                             # Trim interval start to break stop / last interval end right before save when not on break.
*/
          __pyx_t_9 = (!__pyx_cur_scope->__pyx_v_interval_exists);
          if (__pyx_t_9) {
          } else {
            __pyx_t_8 = __pyx_t_9;
            goto __pyx_L634_bool_binop_done;
          }
          __pyx_t_9 = (!__pyx_cur_scope->__pyx_v_break_interval_overlaps);
          if (__pyx_t_9) {
          } else {
            __pyx_t_8 = __pyx_t_9;
            goto __pyx_L634_bool_binop_done;
          }
          __pyx_t_9 = (!__pyx_cur_scope->__pyx_v_regular_interval_overlaps);
          __pyx_t_8 = __pyx_t_9;
          __pyx_L634_bool_binop_done:;
          if (__pyx_t_8) {

            /* "ws_package/controllers/activity_controller.py":2744
 * 
 *                     if not interval_exists and not break_interval_overlaps and not regular_interval_overlaps:
 *                         try:             # <<<<<<<<<<<<<<
 *                             # Trim interval start to break stop / last interval end right before save when not on break.
 *                             # This handles the case where the slot was set at loop top while still on break (e.g. 17:45-17:50)
*/
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":2748
 *                             # This handles the case where the slot was set at loop top while still on break (e.g. 17:45-17:50)
 *                             # and the user stopped the break at 17:47 during the sleep - we now trim to 17:47-17:50.
 *                             if current_break_id == 0:             # <<<<<<<<<<<<<<
 *                                 trim_to = start_date
 *                                 last_end = await self.activity_service.get_last_activity_interval()
*/
              __pyx_t_8 = (__Pyx_PyLong_BoolEqObjC(__pyx_cur_scope->__pyx_v_current_break_id, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2748, __pyx_L640_error)
              if (__pyx_t_8) {

                /* "ws_package/controllers/activity_controller.py":2749
 *                             # and the user stopped the break at 17:47 during the sleep - we now trim to 17:47-17:50.
 *                             if current_break_id == 0:
 *                                 trim_to = start_date             # <<<<<<<<<<<<<<
 *                                 last_end = await self.activity_service.get_last_activity_interval()
 *                                 if last_end is not None and start_date < last_end < end_date:
*/
                __Pyx_INCREF(__pyx_cur_scope->__pyx_v_start_date);
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_trim_to);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_trim_to, __pyx_cur_scope->__pyx_v_start_date);
                __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_start_date);

                /* "ws_package/controllers/activity_controller.py":2750
 *                             if current_break_id == 0:
 *                                 trim_to = start_date
 *                                 last_end = await self.activity_service.get_last_activity_interval()             # <<<<<<<<<<<<<<
 *                                 if last_end is not None and start_date < last_end < end_date:
 *                                     trim_to = max(trim_to, last_end)
*/
                __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2750, __pyx_L640_error)
                __Pyx_GOTREF(__pyx_t_3);
                __pyx_t_6 = __pyx_t_3;
                __Pyx_INCREF(__pyx_t_6);
                __pyx_t_7 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
                  __pyx_t_15 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_last_activity_interval, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2750, __pyx_L640_error)
                  __Pyx_GOTREF(__pyx_t_15);
                }
                __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_15, &__pyx_r);
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_11);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 45;
                  return __pyx_r;
                  __pyx_L643_resume_from_await:;
                  __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_11);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2750, __pyx_L640_error)
                  __pyx_t_15 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_15);
                } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __pyx_t_15 = __pyx_r; __pyx_r = NULL;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 2750, __pyx_L640_error)
                }
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_last_end);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_last_end, __pyx_t_15);
                __Pyx_GIVEREF(__pyx_t_15);
                __pyx_t_15 = 0;

                /* "ws_package/controllers/activity_controller.py":2751
 *                                 trim_to = start_date
 *                                 last_end = await self.activity_service.get_last_activity_interval()
 *                                 if last_end is not None and start_date < last_end < end_date:             # <<<<<<<<<<<<<<
 *                                     trim_to = max(trim_to, last_end)
 *                                 session_start = self.current_session_start_time
*/
                __pyx_t_9 = (__pyx_cur_scope->__pyx_v_last_end != Py_None);
                if (__pyx_t_9) {
                } else {
                  __pyx_t_8 = __pyx_t_9;
                  goto __pyx_L645_bool_binop_done;
                }
                __pyx_t_15 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_last_end, Py_LT); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2751, __pyx_L640_error)
                if (__Pyx_PyObject_IsTrue(__pyx_t_15)) {
                  __Pyx_DECREF(__pyx_t_15);
                  __pyx_t_15 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_last_end, __pyx_cur_scope->__pyx_v_end_date, Py_LT); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2751, __pyx_L640_error)
                }
                __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2751, __pyx_L640_error)
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                __pyx_t_8 = __pyx_t_9;
                __pyx_L645_bool_binop_done:;
                if (__pyx_t_8) {

                  /* "ws_package/controllers/activity_controller.py":2752
 *                                 last_end = await self.activity_service.get_last_activity_interval()
 *                                 if last_end is not None and start_date < last_end < end_date:
 *                                     trim_to = max(trim_to, last_end)             # <<<<<<<<<<<<<<
 *                                 session_start = self.current_session_start_time
 *                                 if (
*/
                  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_last_end);
                  __pyx_t_15 = __pyx_cur_scope->__pyx_v_last_end;
                  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_trim_to);
                  __pyx_t_3 = __pyx_cur_scope->__pyx_v_trim_to;
                  __pyx_t_4 = PyObject_RichCompare(__pyx_t_15, __pyx_t_3, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2752, __pyx_L640_error)
                  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2752, __pyx_L640_error)
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  if (__pyx_t_8) {
                    __Pyx_INCREF(__pyx_t_15);
                    __pyx_t_6 = __pyx_t_15;
                  } else {
                    __Pyx_INCREF(__pyx_t_3);
                    __pyx_t_6 = __pyx_t_3;
                  }
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __pyx_t_15 = __pyx_t_6;
                  __Pyx_INCREF(__pyx_t_15);
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_trim_to);
                  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_trim_to, __pyx_t_15);
                  __Pyx_GIVEREF(__pyx_t_15);
                  __pyx_t_15 = 0;

                  /* "ws_package/controllers/activity_controller.py":2751
 *                                 trim_to = start_date
 *                                 last_end = await self.activity_service.get_last_activity_interval()
 *                                 if last_end is not None and start_date < last_end < end_date:             # <<<<<<<<<<<<<<
 *                                     trim_to = max(trim_to, last_end)
 *                                 session_start = self.current_session_start_time
*/
                }

                /* "ws_package/controllers/activity_controller.py":2753
 *                                 if last_end is not None and start_date < last_end < end_date:
 *                                     trim_to = max(trim_to, last_end)
 *                                 session_start = self.current_session_start_time             # <<<<<<<<<<<<<<
 *                                 if (
 *                                     session_start is not None
*/
                __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_session_start_time); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2753, __pyx_L640_error)
                __Pyx_GOTREF(__pyx_t_15);
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_session_start);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_session_start, __pyx_t_15);
                __Pyx_GIVEREF(__pyx_t_15);
                __pyx_t_15 = 0;

                /* "ws_package/controllers/activity_controller.py":2755
 *                                 session_start = self.current_session_start_time
 *                                 if (
 *                                     session_start is not None             # <<<<<<<<<<<<<<
 *                                     and start_date < session_start < end_date
 *                                 ):
*/
                __pyx_t_9 = (__pyx_cur_scope->__pyx_v_session_start != Py_None);
                if (__pyx_t_9) {
                } else {
                  __pyx_t_8 = __pyx_t_9;
                  goto __pyx_L648_bool_binop_done;
                }

                /* "ws_package/controllers/activity_controller.py":2756
 *                                 if (
 *                                     session_start is not None
 *                                     and start_date < session_start < end_date             # <<<<<<<<<<<<<<
 *                                 ):
 *                                     trim_to = max(
*/
                __pyx_t_15 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_session_start, Py_LT); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2756, __pyx_L640_error)
                if (__Pyx_PyObject_IsTrue(__pyx_t_15)) {
                  __Pyx_DECREF(__pyx_t_15);
                  __pyx_t_15 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_session_start, __pyx_cur_scope->__pyx_v_end_date, Py_LT); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2756, __pyx_L640_error)
                }
                __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2756, __pyx_L640_error)
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                __pyx_t_8 = __pyx_t_9;
                __pyx_L648_bool_binop_done:;

                /* "ws_package/controllers/activity_controller.py":2754
 *                                     trim_to = max(trim_to, last_end)
 *                                 session_start = self.current_session_start_time
 *                                 if (             # <<<<<<<<<<<<<<
 *                                     session_start is not None
 *                                     and start_date < session_start < end_date
*/
                if (__pyx_t_8) {

                  /* "ws_package/controllers/activity_controller.py":2759
 *                                 ):
 *                                     trim_to = max(
 *                                         trim_to, session_start.replace(microsecond=0)             # <<<<<<<<<<<<<<
 *                                     )
 *                                 break_stop_attr = getattr(self, '_break_stop_time', None)
*/
                  __pyx_t_6 = __pyx_cur_scope->__pyx_v_session_start;
                  __Pyx_INCREF(__pyx_t_6);
                  __pyx_t_7 = 0;
                  {
                    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_6, NULL};
                    __pyx_t_3 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2759, __pyx_L640_error)
                    __Pyx_GOTREF(__pyx_t_3);
                    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_3, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 2759, __pyx_L640_error)
                    __pyx_t_15 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_3);
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2759, __pyx_L640_error)
                    __Pyx_GOTREF(__pyx_t_15);
                  }
                  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_trim_to);
                  __pyx_t_3 = __pyx_cur_scope->__pyx_v_trim_to;
                  __pyx_t_4 = PyObject_RichCompare(__pyx_t_15, __pyx_t_3, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2759, __pyx_L640_error)
                  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2759, __pyx_L640_error)
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  if (__pyx_t_8) {
                    __Pyx_INCREF(__pyx_t_15);
                    __pyx_t_6 = __pyx_t_15;
                  } else {
                    __Pyx_INCREF(__pyx_t_3);
                    __pyx_t_6 = __pyx_t_3;
                  }
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __pyx_t_15 = __pyx_t_6;
                  __Pyx_INCREF(__pyx_t_15);
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_trim_to);
                  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_trim_to, __pyx_t_15);
                  __Pyx_GIVEREF(__pyx_t_15);
                  __pyx_t_15 = 0;

                  /* "ws_package/controllers/activity_controller.py":2754
 *                                     trim_to = max(trim_to, last_end)
 *                                 session_start = self.current_session_start_time
 *                                 if (             # <<<<<<<<<<<<<<
 *                                     session_start is not None
 *                                     and start_date < session_start < end_date
*/
                }

                /* "ws_package/controllers/activity_controller.py":2761
 *                                         trim_to, session_start.replace(microsecond=0)
 *                                     )
 *                                 break_stop_attr = getattr(self, '_break_stop_time', None)             # <<<<<<<<<<<<<<
 *                                 if break_stop_attr is not None and start_date < break_stop_attr < end_date:
 *                                     trim_to = max(trim_to, break_stop_attr)
*/
                __pyx_t_15 = __pyx_cur_scope->__pyx_v_self;
                __Pyx_INCREF(__pyx_t_15);
                __pyx_t_6 = __Pyx_GetAttr3(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_break_stop_time, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2761, __pyx_L640_error)
                __Pyx_GOTREF(__pyx_t_6);
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_break_stop_attr);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_break_stop_attr, __pyx_t_6);
                __Pyx_GIVEREF(__pyx_t_6);
                __pyx_t_6 = 0;

                /* "ws_package/controllers/activity_controller.py":2762
 *                                     )
 *                                 break_stop_attr = getattr(self, '_break_stop_time', None)
 *                                 if break_stop_attr is not None and start_date < break_stop_attr < end_date:             # <<<<<<<<<<<<<<
 *                                     trim_to = max(trim_to, break_stop_attr)
 *                                     self._break_stop_time = None
*/
                __pyx_t_9 = (__pyx_cur_scope->__pyx_v_break_stop_attr != Py_None);
                if (__pyx_t_9) {
                } else {
                  __pyx_t_8 = __pyx_t_9;
                  goto __pyx_L651_bool_binop_done;
                }
                __pyx_t_6 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_break_stop_attr, Py_LT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2762, __pyx_L640_error)
                if (__Pyx_PyObject_IsTrue(__pyx_t_6)) {
                  __Pyx_DECREF(__pyx_t_6);
                  __pyx_t_6 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_break_stop_attr, __pyx_cur_scope->__pyx_v_end_date, Py_LT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2762, __pyx_L640_error)
                }
                __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2762, __pyx_L640_error)
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                __pyx_t_8 = __pyx_t_9;
                __pyx_L651_bool_binop_done:;
                if (__pyx_t_8) {

                  /* "ws_package/controllers/activity_controller.py":2763
 *                                 break_stop_attr = getattr(self, '_break_stop_time', None)
 *                                 if break_stop_attr is not None and start_date < break_stop_attr < end_date:
 *                                     trim_to = max(trim_to, break_stop_attr)             # <<<<<<<<<<<<<<
 *                                     self._break_stop_time = None
 *                                 if trim_to > start_date:
*/
                  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_break_stop_attr);
                  __pyx_t_6 = __pyx_cur_scope->__pyx_v_break_stop_attr;
                  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_trim_to);
                  __pyx_t_15 = __pyx_cur_scope->__pyx_v_trim_to;
                  __pyx_t_4 = PyObject_RichCompare(__pyx_t_6, __pyx_t_15, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2763, __pyx_L640_error)
                  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2763, __pyx_L640_error)
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  if (__pyx_t_8) {
                    __Pyx_INCREF(__pyx_t_6);
                    __pyx_t_3 = __pyx_t_6;
                  } else {
                    __Pyx_INCREF(__pyx_t_15);
                    __pyx_t_3 = __pyx_t_15;
                  }
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __pyx_t_6 = __pyx_t_3;
                  __Pyx_INCREF(__pyx_t_6);
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_trim_to);
                  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_trim_to, __pyx_t_6);
                  __Pyx_GIVEREF(__pyx_t_6);
                  __pyx_t_6 = 0;

                  /* "ws_package/controllers/activity_controller.py":2764
 *                                 if break_stop_attr is not None and start_date < break_stop_attr < end_date:
 *                                     trim_to = max(trim_to, break_stop_attr)
 *                                     self._break_stop_time = None             # <<<<<<<<<<<<<<
 *                                 if trim_to > start_date:
 *                                     self._creating_intervals.discard(interval_key)
*/
                  if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_break_stop_time, Py_None) < (0)) __PYX_ERR(0, 2764, __pyx_L640_error)

                  /* "ws_package/controllers/activity_controller.py":2762
 *                                     )
 *                                 break_stop_attr = getattr(self, '_break_stop_time', None)
 *                                 if break_stop_attr is not None and start_date < break_stop_attr < end_date:             # <<<<<<<<<<<<<<
 *                                     trim_to = max(trim_to, break_stop_attr)
 *                                     self._break_stop_time = None
*/
                }

                /* "ws_package/controllers/activity_controller.py":2765
 *                                     trim_to = max(trim_to, break_stop_attr)
 *                                     self._break_stop_time = None
 *                                 if trim_to > start_date:             # <<<<<<<<<<<<<<
 *                                     self._creating_intervals.discard(interval_key)
 *                                     start_date = trim_to
*/
                __pyx_t_6 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_trim_to, __pyx_cur_scope->__pyx_v_start_date, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2765, __pyx_L640_error)
                __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2765, __pyx_L640_error)
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                if (__pyx_t_8) {

                  /* "ws_package/controllers/activity_controller.py":2766
 *                                     self._break_stop_time = None
 *                                 if trim_to > start_date:
 *                                     self._creating_intervals.discard(interval_key)             # <<<<<<<<<<<<<<
 *                                     start_date = trim_to
 *                                     start_date_seconds = start_date.replace(microsecond=0)
*/
                  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_creating_intervals); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2766, __pyx_L640_error)
                  __Pyx_GOTREF(__pyx_t_15);
                  __pyx_t_3 = __pyx_t_15;
                  __Pyx_INCREF(__pyx_t_3);
                  __pyx_t_7 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_interval_key};
                    __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_discard, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2766, __pyx_L640_error)
                    __Pyx_GOTREF(__pyx_t_6);
                  }
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

                  /* "ws_package/controllers/activity_controller.py":2767
 *                                 if trim_to > start_date:
 *                                     self._creating_intervals.discard(interval_key)
 *                                     start_date = trim_to             # <<<<<<<<<<<<<<
 *                                     start_date_seconds = start_date.replace(microsecond=0)
 *                                     end_date_seconds = end_date.replace(microsecond=0)
*/
                  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_trim_to);
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_start_date);
                  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_trim_to);
                  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_trim_to);

                  /* "ws_package/controllers/activity_controller.py":2768
 *                                     self._creating_intervals.discard(interval_key)
 *                                     start_date = trim_to
 *                                     start_date_seconds = start_date.replace(microsecond=0)             # <<<<<<<<<<<<<<
 *                                     end_date_seconds = end_date.replace(microsecond=0)
 *                                     interval_key = (self.last_count + 1, start_date_seconds, end_date_seconds)
*/
                  __pyx_t_15 = __pyx_cur_scope->__pyx_v_start_date;
                  __Pyx_INCREF(__pyx_t_15);
                  __pyx_t_7 = 0;
                  {
                    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_15, NULL};
                    __pyx_t_3 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2768, __pyx_L640_error)
                    __Pyx_GOTREF(__pyx_t_3);
                    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_3, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 2768, __pyx_L640_error)
                    __pyx_t_6 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_3);
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2768, __pyx_L640_error)
                    __Pyx_GOTREF(__pyx_t_6);
                  }
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_start_date_seconds);
                  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_start_date_seconds, __pyx_t_6);
                  __Pyx_GIVEREF(__pyx_t_6);
                  __pyx_t_6 = 0;

                  /* "ws_package/controllers/activity_controller.py":2769
 *                                     start_date = trim_to
 *                                     start_date_seconds = start_date.replace(microsecond=0)
 *                                     end_date_seconds = end_date.replace(microsecond=0)             # <<<<<<<<<<<<<<
 *                                     interval_key = (self.last_count + 1, start_date_seconds, end_date_seconds)
 *                                     self._creating_intervals.add(interval_key)
*/
                  __pyx_t_3 = __pyx_cur_scope->__pyx_v_end_date;
                  __Pyx_INCREF(__pyx_t_3);
                  __pyx_t_7 = 0;
                  {
                    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_3, NULL};
                    __pyx_t_15 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2769, __pyx_L640_error)
                    __Pyx_GOTREF(__pyx_t_15);
                    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_15, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 2769, __pyx_L640_error)
                    __pyx_t_6 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_15);
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2769, __pyx_L640_error)
                    __Pyx_GOTREF(__pyx_t_6);
                  }
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_end_date_seconds);
                  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_end_date_seconds, __pyx_t_6);
                  __Pyx_GIVEREF(__pyx_t_6);
                  __pyx_t_6 = 0;

                  /* "ws_package/controllers/activity_controller.py":2770
 *                                     start_date_seconds = start_date.replace(microsecond=0)
 *                                     end_date_seconds = end_date.replace(microsecond=0)
 *                                     interval_key = (self.last_count + 1, start_date_seconds, end_date_seconds)             # <<<<<<<<<<<<<<
 *                                     self._creating_intervals.add(interval_key)
 *                                     try:
*/
                  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2770, __pyx_L640_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  __pyx_t_15 = __Pyx_PyLong_AddObjC(__pyx_t_6, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2770, __pyx_L640_error)
                  __Pyx_GOTREF(__pyx_t_15);
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2770, __pyx_L640_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  __Pyx_GIVEREF(__pyx_t_15);
                  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_15) != (0)) __PYX_ERR(0, 2770, __pyx_L640_error);
                  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_start_date_seconds);
                  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_start_date_seconds);
                  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_cur_scope->__pyx_v_start_date_seconds) != (0)) __PYX_ERR(0, 2770, __pyx_L640_error);
                  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_end_date_seconds);
                  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_end_date_seconds);
                  if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_cur_scope->__pyx_v_end_date_seconds) != (0)) __PYX_ERR(0, 2770, __pyx_L640_error);
                  __pyx_t_15 = 0;
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_interval_key);
                  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_interval_key, ((PyObject*)__pyx_t_6));
                  __Pyx_GIVEREF(__pyx_t_6);
                  __pyx_t_6 = 0;

                  /* "ws_package/controllers/activity_controller.py":2771
 *                                     end_date_seconds = end_date.replace(microsecond=0)
 *                                     interval_key = (self.last_count + 1, start_date_seconds, end_date_seconds)
 *                                     self._creating_intervals.add(interval_key)             # <<<<<<<<<<<<<<
 *                                     try:
 *                                         activityLevel = await self.get_activity_level_from_db(start_date, end_date)
*/
                  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_creating_intervals); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2771, __pyx_L640_error)
                  __Pyx_GOTREF(__pyx_t_3);
                  __pyx_t_15 = __pyx_t_3;
                  __Pyx_INCREF(__pyx_t_15);
                  __pyx_t_7 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_cur_scope->__pyx_v_interval_key};
                    __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_add, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2771, __pyx_L640_error)
                    __Pyx_GOTREF(__pyx_t_6);
                  }
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

                  /* "ws_package/controllers/activity_controller.py":2772
 *                                     interval_key = (self.last_count + 1, start_date_seconds, end_date_seconds)
 *                                     self._creating_intervals.add(interval_key)
 *                                     try:             # <<<<<<<<<<<<<<
 *                                         activityLevel = await self.get_activity_level_from_db(start_date, end_date)
 *                                     except Exception as e:
*/
                  {
                    __Pyx_ExceptionSave(&__pyx_t_46, &__pyx_t_47, &__pyx_t_48);
                    __Pyx_XGOTREF(__pyx_t_46);
                    __Pyx_XGOTREF(__pyx_t_47);
                    __Pyx_XGOTREF(__pyx_t_48);
                    /*try:*/ {

                      /* "ws_package/controllers/activity_controller.py":2773
 *                                     self._creating_intervals.add(interval_key)
 *                                     try:
 *                                         activityLevel = await self.get_activity_level_from_db(start_date, end_date)             # <<<<<<<<<<<<<<
 *                                     except Exception as e:
 *                                         logger.warning("Error getting activity for trimmed interval: %s", e)
*/
                      __pyx_t_3 = __pyx_cur_scope->__pyx_v_self;
                      __Pyx_INCREF(__pyx_t_3);
                      __pyx_t_7 = 0;
                      {
                        PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
                        __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_activity_level_from_db, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2773, __pyx_L654_error)
                        __Pyx_GOTREF(__pyx_t_6);
                      }
                      __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_6, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                      if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_46);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_46;
                        __Pyx_XGIVEREF(__pyx_t_47);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_47;
                        __Pyx_XGIVEREF(__pyx_t_48);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_48;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 46;
                        return __pyx_r;
                        __pyx_L662_resume_from_await:;
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_46 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_46);
                        __pyx_t_47 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_47);
                        __pyx_t_48 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_48);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2773, __pyx_L654_error)
                        __pyx_t_6 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_6);
                      } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_6 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 2773, __pyx_L654_error)
                      }
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_activityLevel);
                      __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_activityLevel, __pyx_t_6);
                      __Pyx_GIVEREF(__pyx_t_6);
                      __pyx_t_6 = 0;

                      /* "ws_package/controllers/activity_controller.py":2772
 *                                     interval_key = (self.last_count + 1, start_date_seconds, end_date_seconds)
 *                                     self._creating_intervals.add(interval_key)
 *                                     try:             # <<<<<<<<<<<<<<
 *                                         activityLevel = await self.get_activity_level_from_db(start_date, end_date)
 *                                     except Exception as e:
*/
                    }
                    __Pyx_XDECREF(__pyx_t_46); __pyx_t_46 = 0;
                    __Pyx_XDECREF(__pyx_t_47); __pyx_t_47 = 0;
                    __Pyx_XDECREF(__pyx_t_48); __pyx_t_48 = 0;
                    goto __pyx_L661_try_end;
                    __pyx_L654_error:;
                    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                    __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                    __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                    __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                    __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                    __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

                    /* "ws_package/controllers/activity_controller.py":2774
 *                                     try:
 *                                         activityLevel = await self.get_activity_level_from_db(start_date, end_date)
 *                                     except Exception as e:             # <<<<<<<<<<<<<<
 *                                         logger.warning("Error getting activity for trimmed interval: %s", e)
 *                                         activityLevel = {'mouse': '0.0', 'average': '0.0', 'keyboard': '0.0'}
*/
                    __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                    if (__pyx_t_14) {
                      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_3, &__pyx_t_15) < 0) __PYX_ERR(0, 2774, __pyx_L656_except_error)
                      __Pyx_XGOTREF(__pyx_t_6);
                      __Pyx_XGOTREF(__pyx_t_3);
                      __Pyx_XGOTREF(__pyx_t_15);
                      __Pyx_INCREF(__pyx_t_3);
                      __Pyx_GIVEREF(__pyx_t_3);
                      __pyx_cur_scope->__pyx_v_e = __pyx_t_3;
                      /*try:*/ {

                        /* "ws_package/controllers/activity_controller.py":2775
 *                                         activityLevel = await self.get_activity_level_from_db(start_date, end_date)
 *                                     except Exception as e:
 *                                         logger.warning("Error getting activity for trimmed interval: %s", e)             # <<<<<<<<<<<<<<
 *                                         activityLevel = {'mouse': '0.0', 'average': '0.0', 'keyboard': '0.0'}
 *                                     logger.info("Trimmed interval start before save (e.g. break stopped during slot): %s to %s", start_date, end_date)
*/
                        __pyx_t_37 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2775, __pyx_L668_error)
                        __Pyx_GOTREF(__pyx_t_5);
                        __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2775, __pyx_L668_error)
                        __Pyx_GOTREF(__pyx_t_33);
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                        __pyx_t_7 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_33))) {
                          __pyx_t_37 = PyMethod_GET_SELF(__pyx_t_33);
                          assert(__pyx_t_37);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
                          __Pyx_INCREF(__pyx_t_37);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
                          __pyx_t_7 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[3] = {__pyx_t_37, __pyx_mstate_global->__pyx_kp_u_Error_getting_activity_for_trimm, __pyx_cur_scope->__pyx_v_e};
                          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2775, __pyx_L668_error)
                          __Pyx_GOTREF(__pyx_t_4);
                        }
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                        /* "ws_package/controllers/activity_controller.py":2776
 *                                     except Exception as e:
 *                                         logger.warning("Error getting activity for trimmed interval: %s", e)
 *                                         activityLevel = {'mouse': '0.0', 'average': '0.0', 'keyboard': '0.0'}             # <<<<<<<<<<<<<<
 *                                     logger.info("Trimmed interval start before save (e.g. break stopped during slot): %s to %s", start_date, end_date)
 * 
*/
                        __pyx_t_4 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2776, __pyx_L668_error)
                        __Pyx_GOTREF(__pyx_t_4);
                        if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_mouse, __pyx_mstate_global->__pyx_kp_u_0_0) < (0)) __PYX_ERR(0, 2776, __pyx_L668_error)
                        if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_average, __pyx_mstate_global->__pyx_kp_u_0_0) < (0)) __PYX_ERR(0, 2776, __pyx_L668_error)
                        if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_keyboard, __pyx_mstate_global->__pyx_kp_u_0_0) < (0)) __PYX_ERR(0, 2776, __pyx_L668_error)
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_activityLevel);
                        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_activityLevel, __pyx_t_4);
                        __Pyx_GIVEREF(__pyx_t_4);
                        __pyx_t_4 = 0;
                      }

                      /* "ws_package/controllers/activity_controller.py":2774
 *                                     try:
 *                                         activityLevel = await self.get_activity_level_from_db(start_date, end_date)
 *                                     except Exception as e:             # <<<<<<<<<<<<<<
 *                                         logger.warning("Error getting activity for trimmed interval: %s", e)
 *                                         activityLevel = {'mouse': '0.0', 'average': '0.0', 'keyboard': '0.0'}
*/
                      /*finally:*/ {
                        /*normal exit:*/{
                          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                          goto __pyx_L669;
                        }
                        __pyx_L668_error:;
                        /*exception exit:*/{
                          __Pyx_PyThreadState_assign
                          __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_23 = 0; __pyx_t_39 = 0; __pyx_t_18 = 0; __pyx_t_31 = 0;
                          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                          __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                          __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                          __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                          __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                          __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                          __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                           __Pyx_ExceptionSwap(&__pyx_t_39, &__pyx_t_18, &__pyx_t_31);
                          if ( unlikely(__Pyx_GetException(&__pyx_t_22, &__pyx_t_21, &__pyx_t_23) < 0)) __Pyx_ErrFetch(&__pyx_t_22, &__pyx_t_21, &__pyx_t_23);
                          __Pyx_XGOTREF(__pyx_t_22);
                          __Pyx_XGOTREF(__pyx_t_21);
                          __Pyx_XGOTREF(__pyx_t_23);
                          __Pyx_XGOTREF(__pyx_t_39);
                          __Pyx_XGOTREF(__pyx_t_18);
                          __Pyx_XGOTREF(__pyx_t_31);
                          __pyx_t_14 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_60 = __pyx_filename;
                          {
                            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                          }
                          __Pyx_XGIVEREF(__pyx_t_39);
                          __Pyx_XGIVEREF(__pyx_t_18);
                          __Pyx_XGIVEREF(__pyx_t_31);
                          __Pyx_ExceptionReset(__pyx_t_39, __pyx_t_18, __pyx_t_31);
                          __Pyx_XGIVEREF(__pyx_t_22);
                          __Pyx_XGIVEREF(__pyx_t_21);
                          __Pyx_XGIVEREF(__pyx_t_23);
                          __Pyx_ErrRestore(__pyx_t_22, __pyx_t_21, __pyx_t_23);
                          __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_23 = 0; __pyx_t_39 = 0; __pyx_t_18 = 0; __pyx_t_31 = 0;
                          __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_60;
                          goto __pyx_L656_except_error;
                        }
                        __pyx_L669:;
                      }
                      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                      goto __pyx_L655_exception_handled;
                    }
                    goto __pyx_L656_except_error;

                    /* "ws_package/controllers/activity_controller.py":2772
 *                                     interval_key = (self.last_count + 1, start_date_seconds, end_date_seconds)
 *                                     self._creating_intervals.add(interval_key)
 *                                     try:             # <<<<<<<<<<<<<<
 *                                         activityLevel = await self.get_activity_level_from_db(start_date, end_date)
 *                                     except Exception as e:
*/
                    __pyx_L656_except_error:;
                    __Pyx_XGIVEREF(__pyx_t_46);
                    __Pyx_XGIVEREF(__pyx_t_47);
                    __Pyx_XGIVEREF(__pyx_t_48);
                    __Pyx_ExceptionReset(__pyx_t_46, __pyx_t_47, __pyx_t_48);
                    goto __pyx_L640_error;
                    __pyx_L655_exception_handled:;
                    __Pyx_XGIVEREF(__pyx_t_46);
                    __Pyx_XGIVEREF(__pyx_t_47);
                    __Pyx_XGIVEREF(__pyx_t_48);
                    __Pyx_ExceptionReset(__pyx_t_46, __pyx_t_47, __pyx_t_48);
                    __pyx_L661_try_end:;
                  }

                  /* "ws_package/controllers/activity_controller.py":2777
 *                                         logger.warning("Error getting activity for trimmed interval: %s", e)
 *                                         activityLevel = {'mouse': '0.0', 'average': '0.0', 'keyboard': '0.0'}
 *                                     logger.info("Trimmed interval start before save (e.g. break stopped during slot): %s to %s", start_date, end_date)             # <<<<<<<<<<<<<<
 * 
 *                                     # Re-check for overlaps after trimming (non-blocking: queue check + async lock)
*/
                  __pyx_t_3 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2777, __pyx_L640_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2777, __pyx_L640_error)
                  __Pyx_GOTREF(__pyx_t_4);
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_4))) {
                    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
                    assert(__pyx_t_3);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                    __Pyx_INCREF(__pyx_t_3);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[4] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Trimmed_interval_start_before_sa, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
                    __pyx_t_15 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2777, __pyx_L640_error)
                    __Pyx_GOTREF(__pyx_t_15);
                  }
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

                  /* "ws_package/controllers/activity_controller.py":2780
 * 
 *                                     # Re-check for overlaps after trimming (non-blocking: queue check + async lock)
 *                                     try:             # <<<<<<<<<<<<<<
 *                                         from ws_package.utils.db_write_queue import db_write_queue as _dwq2, WriteOperationType as _WOT2
 *                                         for _pi2 in _dwq2.get_pending_items(_WOT2.ACTIVITY_INTERVAL):
*/
                  {
                    __Pyx_ExceptionSave(&__pyx_t_48, &__pyx_t_47, &__pyx_t_46);
                    __Pyx_XGOTREF(__pyx_t_48);
                    __Pyx_XGOTREF(__pyx_t_47);
                    __Pyx_XGOTREF(__pyx_t_46);
                    /*try:*/ {

                      /* "ws_package/controllers/activity_controller.py":2781
 *                                     # Re-check for overlaps after trimming (non-blocking: queue check + async lock)
 *                                     try:
 *                                         from ws_package.utils.db_write_queue import db_write_queue as _dwq2, WriteOperationType as _WOT2             # <<<<<<<<<<<<<<
 *                                         for _pi2 in _dwq2.get_pending_items(_WOT2.ACTIVITY_INTERVAL):
 *                                             _d2 = _pi2.data
*/
                      {
                        PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_db_write_queue,__pyx_mstate_global->__pyx_n_u_WriteOperationType};
                        __pyx_t_31 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_utils_db_write_queue, __pyx_imported_names, 2, NULL, 0); if (unlikely(!__pyx_t_31)) __PYX_ERR(0, 2781, __pyx_L674_error)
                      }
                      __pyx_t_15 = __pyx_t_31;
                      __Pyx_GOTREF(__pyx_t_15);
                      {
                        PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_db_write_queue,__pyx_mstate_global->__pyx_n_u_WriteOperationType};
                        for (__pyx_t_29=0; __pyx_t_29 < 2; __pyx_t_29++) {
                          __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_15, __pyx_imported_names[__pyx_t_29]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2781, __pyx_L674_error)
                          __Pyx_GOTREF(__pyx_t_4);
                          switch (__pyx_t_29) {
                            case 0:
                            __Pyx_INCREF(__pyx_t_4);
                            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v__dwq2);
                            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v__dwq2, __pyx_t_4);
                            __Pyx_GIVEREF(__pyx_t_4);
                            break;
                            case 1:
                            __Pyx_INCREF(__pyx_t_4);
                            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v__WOT2);
                            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v__WOT2, __pyx_t_4);
                            __Pyx_GIVEREF(__pyx_t_4);
                            break;
                            default:;
                          }
                          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        }
                      }
                      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

                      /* "ws_package/controllers/activity_controller.py":2782
 *                                     try:
 *                                         from ws_package.utils.db_write_queue import db_write_queue as _dwq2, WriteOperationType as _WOT2
 *                                         for _pi2 in _dwq2.get_pending_items(_WOT2.ACTIVITY_INTERVAL):             # <<<<<<<<<<<<<<
 *                                             _d2 = _pi2.data
 *                                             if (_d2.get('is_break', 0) != 0 and
*/
                      __pyx_t_4 = __pyx_cur_scope->__pyx_v__dwq2;
                      __Pyx_INCREF(__pyx_t_4);
                      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v__WOT2, __pyx_mstate_global->__pyx_n_u_ACTIVITY_INTERVAL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2782, __pyx_L674_error)
                      __Pyx_GOTREF(__pyx_t_3);
                      __pyx_t_7 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_3};
                        __pyx_t_15 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_pending_items, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                        if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2782, __pyx_L674_error)
                        __Pyx_GOTREF(__pyx_t_15);
                      }
                      if (likely(PyList_CheckExact(__pyx_t_15)) || PyTuple_CheckExact(__pyx_t_15)) {
                        __pyx_t_3 = __pyx_t_15; __Pyx_INCREF(__pyx_t_3);
                        __pyx_t_29 = 0;
                        __pyx_t_54 = NULL;
                      } else {
                        __pyx_t_29 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_15); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2782, __pyx_L674_error)
                        __Pyx_GOTREF(__pyx_t_3);
                        __pyx_t_54 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_54)) __PYX_ERR(0, 2782, __pyx_L674_error)
                      }
                      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                      for (;;) {
                        if (likely(!__pyx_t_54)) {
                          if (likely(PyList_CheckExact(__pyx_t_3))) {
                            {
                              Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3);
                              #if !CYTHON_ASSUME_SAFE_SIZE
                              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2782, __pyx_L674_error)
                              #endif
                              if (__pyx_t_29 >= __pyx_temp) break;
                            }
                            __pyx_t_15 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_3, __pyx_t_29, __Pyx_ReferenceSharing_OwnStrongReference);
                            ++__pyx_t_29;
                          } else {
                            {
                              Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3);
                              #if !CYTHON_ASSUME_SAFE_SIZE
                              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2782, __pyx_L674_error)
                              #endif
                              if (__pyx_t_29 >= __pyx_temp) break;
                            }
                            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                            __pyx_t_15 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_29));
                            #else
                            __pyx_t_15 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_29);
                            #endif
                            ++__pyx_t_29;
                          }
                          if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2782, __pyx_L674_error)
                        } else {
                          __pyx_t_15 = __pyx_t_54(__pyx_t_3);
                          if (unlikely(!__pyx_t_15)) {
                            PyObject* exc_type = PyErr_Occurred();
                            if (exc_type) {
                              if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 2782, __pyx_L674_error)
                              PyErr_Clear();
                            }
                            break;
                          }
                        }
                        __Pyx_GOTREF(__pyx_t_15);
                        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v__pi2);
                        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v__pi2, __pyx_t_15);
                        __Pyx_GIVEREF(__pyx_t_15);
                        __pyx_t_15 = 0;

                        /* "ws_package/controllers/activity_controller.py":2783
 *                                         from ws_package.utils.db_write_queue import db_write_queue as _dwq2, WriteOperationType as _WOT2
 *                                         for _pi2 in _dwq2.get_pending_items(_WOT2.ACTIVITY_INTERVAL):
 *                                             _d2 = _pi2.data             # <<<<<<<<<<<<<<
 *                                             if (_d2.get('is_break', 0) != 0 and
 *                                                     _d2.get('counter') == self.last_count + 1):
*/
                        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v__pi2, __pyx_mstate_global->__pyx_n_u_data); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2783, __pyx_L674_error)
                        __Pyx_GOTREF(__pyx_t_15);
                        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v__d2);
                        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v__d2, __pyx_t_15);
                        __Pyx_GIVEREF(__pyx_t_15);
                        __pyx_t_15 = 0;

                        /* "ws_package/controllers/activity_controller.py":2784
 *                                         for _pi2 in _dwq2.get_pending_items(_WOT2.ACTIVITY_INTERVAL):
 *                                             _d2 = _pi2.data
 *                                             if (_d2.get('is_break', 0) != 0 and             # <<<<<<<<<<<<<<
 *                                                     _d2.get('counter') == self.last_count + 1):
 *                                                 _ps2 = _d2.get('start_time')
*/
                        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v__d2, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2784, __pyx_L674_error)
                        __Pyx_GOTREF(__pyx_t_15);
                        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_mstate_global->__pyx_tuple[23], NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2784, __pyx_L674_error)
                        __Pyx_GOTREF(__pyx_t_4);
                        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                        __pyx_t_9 = (__Pyx_PyLong_BoolNeObjC(__pyx_t_4, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2784, __pyx_L674_error)
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        if (__pyx_t_9) {
                        } else {
                          __pyx_t_8 = __pyx_t_9;
                          goto __pyx_L685_bool_binop_done;
                        }

                        /* "ws_package/controllers/activity_controller.py":2785
 *                                             _d2 = _pi2.data
 *                                             if (_d2.get('is_break', 0) != 0 and
 *                                                     _d2.get('counter') == self.last_count + 1):             # <<<<<<<<<<<<<<
 *                                                 _ps2 = _d2.get('start_time')
 *                                                 _pe2 = _d2.get('end_time')
*/
                        __pyx_t_15 = __pyx_cur_scope->__pyx_v__d2;
                        __Pyx_INCREF(__pyx_t_15);
                        __pyx_t_7 = 0;
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_mstate_global->__pyx_n_u_counter};
                          __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2785, __pyx_L674_error)
                          __Pyx_GOTREF(__pyx_t_4);
                        }
                        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2785, __pyx_L674_error)
                        __Pyx_GOTREF(__pyx_t_15);
                        __pyx_t_6 = __Pyx_PyLong_AddObjC(__pyx_t_15, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2785, __pyx_L674_error)
                        __Pyx_GOTREF(__pyx_t_6);
                        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                        __pyx_t_15 = PyObject_RichCompare(__pyx_t_4, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2785, __pyx_L674_error)
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2785, __pyx_L674_error)
                        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                        __pyx_t_8 = __pyx_t_9;
                        __pyx_L685_bool_binop_done:;

                        /* "ws_package/controllers/activity_controller.py":2784
 *                                         for _pi2 in _dwq2.get_pending_items(_WOT2.ACTIVITY_INTERVAL):
 *                                             _d2 = _pi2.data
 *                                             if (_d2.get('is_break', 0) != 0 and             # <<<<<<<<<<<<<<
 *                                                     _d2.get('counter') == self.last_count + 1):
 *                                                 _ps2 = _d2.get('start_time')
*/
                        if (__pyx_t_8) {

                          /* "ws_package/controllers/activity_controller.py":2786
 *                                             if (_d2.get('is_break', 0) != 0 and
 *                                                     _d2.get('counter') == self.last_count + 1):
 *                                                 _ps2 = _d2.get('start_time')             # <<<<<<<<<<<<<<
 *                                                 _pe2 = _d2.get('end_time')
 *                                                 if _ps2 is not None and _pe2 is not None and _ps2 < end_date and _pe2 > start_date:
*/
                          __pyx_t_6 = __pyx_cur_scope->__pyx_v__d2;
                          __Pyx_INCREF(__pyx_t_6);
                          __pyx_t_7 = 0;
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_n_u_start_time};
                            __pyx_t_15 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                            if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2786, __pyx_L674_error)
                            __Pyx_GOTREF(__pyx_t_15);
                          }
                          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v__ps2);
                          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v__ps2, __pyx_t_15);
                          __Pyx_GIVEREF(__pyx_t_15);
                          __pyx_t_15 = 0;

                          /* "ws_package/controllers/activity_controller.py":2787
 *                                                     _d2.get('counter') == self.last_count + 1):
 *                                                 _ps2 = _d2.get('start_time')
 *                                                 _pe2 = _d2.get('end_time')             # <<<<<<<<<<<<<<
 *                                                 if _ps2 is not None and _pe2 is not None and _ps2 < end_date and _pe2 > start_date:
 *                                                     break_interval_overlaps = True
*/
                          __pyx_t_6 = __pyx_cur_scope->__pyx_v__d2;
                          __Pyx_INCREF(__pyx_t_6);
                          __pyx_t_7 = 0;
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_n_u_end_time};
                            __pyx_t_15 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                            if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2787, __pyx_L674_error)
                            __Pyx_GOTREF(__pyx_t_15);
                          }
                          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v__pe2);
                          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v__pe2, __pyx_t_15);
                          __Pyx_GIVEREF(__pyx_t_15);
                          __pyx_t_15 = 0;

                          /* "ws_package/controllers/activity_controller.py":2788
 *                                                 _ps2 = _d2.get('start_time')
 *                                                 _pe2 = _d2.get('end_time')
 *                                                 if _ps2 is not None and _pe2 is not None and _ps2 < end_date and _pe2 > start_date:             # <<<<<<<<<<<<<<
 *                                                     break_interval_overlaps = True
 *                                                     logger.info(
*/
                          __pyx_t_9 = (__pyx_cur_scope->__pyx_v__ps2 != Py_None);
                          if (__pyx_t_9) {
                          } else {
                            __pyx_t_8 = __pyx_t_9;
                            goto __pyx_L688_bool_binop_done;
                          }
                          __pyx_t_9 = (__pyx_cur_scope->__pyx_v__pe2 != Py_None);
                          if (__pyx_t_9) {
                          } else {
                            __pyx_t_8 = __pyx_t_9;
                            goto __pyx_L688_bool_binop_done;
                          }
                          __pyx_t_15 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v__ps2, __pyx_cur_scope->__pyx_v_end_date, Py_LT); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2788, __pyx_L674_error)
                          __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2788, __pyx_L674_error)
                          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                          if (__pyx_t_9) {
                          } else {
                            __pyx_t_8 = __pyx_t_9;
                            goto __pyx_L688_bool_binop_done;
                          }
                          __pyx_t_15 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v__pe2, __pyx_cur_scope->__pyx_v_start_date, Py_GT); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2788, __pyx_L674_error)
                          __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2788, __pyx_L674_error)
                          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                          __pyx_t_8 = __pyx_t_9;
                          __pyx_L688_bool_binop_done:;
                          if (__pyx_t_8) {

                            /* "ws_package/controllers/activity_controller.py":2789
 *                                                 _pe2 = _d2.get('end_time')
 *                                                 if _ps2 is not None and _pe2 is not None and _ps2 < end_date and _pe2 > start_date:
 *                                                     break_interval_overlaps = True             # <<<<<<<<<<<<<<
 *                                                     logger.info(
 *                                                         "After trim: pending break interval overlaps %s to %s  skipping",
*/
                            __pyx_cur_scope->__pyx_v_break_interval_overlaps = 1;

                            /* "ws_package/controllers/activity_controller.py":2790
 *                                                 if _ps2 is not None and _pe2 is not None and _ps2 < end_date and _pe2 > start_date:
 *                                                     break_interval_overlaps = True
 *                                                     logger.info(             # <<<<<<<<<<<<<<
 *                                                         "After trim: pending break interval overlaps %s to %s  skipping",
 *                                                         start_date, end_date
*/
                            __pyx_t_6 = NULL;
                            __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2790, __pyx_L674_error)
                            __Pyx_GOTREF(__pyx_t_4);
                            __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2790, __pyx_L674_error)
                            __Pyx_GOTREF(__pyx_t_33);
                            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                            /* "ws_package/controllers/activity_controller.py":2792
 *                                                     logger.info(
 *                                                         "After trim: pending break interval overlaps %s to %s  skipping",
 *                                                         start_date, end_date             # <<<<<<<<<<<<<<
 *                                                     )
 *                                                     break
*/
                            __pyx_t_7 = 1;
                            #if CYTHON_UNPACK_METHODS
                            if (unlikely(PyMethod_Check(__pyx_t_33))) {
                              __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_33);
                              assert(__pyx_t_6);
                              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
                              __Pyx_INCREF(__pyx_t_6);
                              __Pyx_INCREF(__pyx__function);
                              __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
                              __pyx_t_7 = 0;
                            }
                            #endif
                            {
                              PyObject *__pyx_callargs[4] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_After_trim_pending_break_interva, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
                              __pyx_t_15 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                              if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2790, __pyx_L674_error)
                              __Pyx_GOTREF(__pyx_t_15);
                            }
                            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

                            /* "ws_package/controllers/activity_controller.py":2794
 *                                                         start_date, end_date
 *                                                     )
 *                                                     break             # <<<<<<<<<<<<<<
 * 
 *                                         if not break_interval_overlaps:
*/
                            goto __pyx_L683_break;

                            /* "ws_package/controllers/activity_controller.py":2788
 *                                                 _ps2 = _d2.get('start_time')
 *                                                 _pe2 = _d2.get('end_time')
 *                                                 if _ps2 is not None and _pe2 is not None and _ps2 < end_date and _pe2 > start_date:             # <<<<<<<<<<<<<<
 *                                                     break_interval_overlaps = True
 *                                                     logger.info(
*/
                          }

                          /* "ws_package/controllers/activity_controller.py":2784
 *                                         for _pi2 in _dwq2.get_pending_items(_WOT2.ACTIVITY_INTERVAL):
 *                                             _d2 = _pi2.data
 *                                             if (_d2.get('is_break', 0) != 0 and             # <<<<<<<<<<<<<<
 *                                                     _d2.get('counter') == self.last_count + 1):
 *                                                 _ps2 = _d2.get('start_time')
*/
                        }

                        /* "ws_package/controllers/activity_controller.py":2782
 *                                     try:
 *                                         from ws_package.utils.db_write_queue import db_write_queue as _dwq2, WriteOperationType as _WOT2
 *                                         for _pi2 in _dwq2.get_pending_items(_WOT2.ACTIVITY_INTERVAL):             # <<<<<<<<<<<<<<
 *                                             _d2 = _pi2.data
 *                                             if (_d2.get('is_break', 0) != 0 and
*/
                      }
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                      goto __pyx_L692_for_end;
                      __pyx_L683_break:;
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                      goto __pyx_L692_for_end;
                      __pyx_L692_for_end:;

                      /* "ws_package/controllers/activity_controller.py":2796
 *                                                     break
 * 
 *                                         if not break_interval_overlaps:             # <<<<<<<<<<<<<<
 *                                             with db_lock_manager.read_lock():
 *                                                 async with async_session() as session:
*/
                      __pyx_t_8 = (!__pyx_cur_scope->__pyx_v_break_interval_overlaps);
                      if (__pyx_t_8) {

                        /* "ws_package/controllers/activity_controller.py":2797
 * 
 *                                         if not break_interval_overlaps:
 *                                             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                                                 async with async_session() as session:
 *                                                     overlap_query_after_trim = select(ActivityInterval).where(
*/
                        /*with:*/ {
                          __pyx_t_15 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2797, __pyx_L674_error)
                          __Pyx_GOTREF(__pyx_t_33);
                          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2797, __pyx_L674_error)
                          __Pyx_GOTREF(__pyx_t_6);
                          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                          __pyx_t_7 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_6))) {
                            __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_6);
                            assert(__pyx_t_15);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                            __Pyx_INCREF(__pyx_t_15);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                            __pyx_t_7 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL};
                            __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2797, __pyx_L674_error)
                            __Pyx_GOTREF(__pyx_t_3);
                          }
                          __pyx_t_31 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_31)) __PYX_ERR(0, 2797, __pyx_L674_error)
                          __Pyx_GOTREF(__pyx_t_31);
                          __pyx_t_15 = NULL;
                          __pyx_t_33 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2797, __pyx_L694_error)
                          __Pyx_GOTREF(__pyx_t_33);
                          __pyx_t_7 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (likely(PyMethod_Check(__pyx_t_33))) {
                            __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_33);
                            assert(__pyx_t_15);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
                            __Pyx_INCREF(__pyx_t_15);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
                            __pyx_t_7 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL};
                            __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                            __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                            if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2797, __pyx_L694_error)
                            __Pyx_GOTREF(__pyx_t_6);
                          }
                          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                          /*try:*/ {
                            {
                              __Pyx_ExceptionSave(&__pyx_t_18, &__pyx_t_39, &__pyx_t_23);
                              __Pyx_XGOTREF(__pyx_t_18);
                              __Pyx_XGOTREF(__pyx_t_39);
                              __Pyx_XGOTREF(__pyx_t_23);
                              /*try:*/ {

                                /* "ws_package/controllers/activity_controller.py":2798
 *                                         if not break_interval_overlaps:
 *                                             with db_lock_manager.read_lock():
 *                                                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                                                     overlap_query_after_trim = select(ActivityInterval).where(
 *                                                         and_(
*/
                                /*with:*/ {
                                  __pyx_t_6 = NULL;
                                  __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2798, __pyx_L700_error)
                                  __Pyx_GOTREF(__pyx_t_33);
                                  __pyx_t_7 = 1;
                                  #if CYTHON_UNPACK_METHODS
                                  if (unlikely(PyMethod_Check(__pyx_t_33))) {
                                    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_33);
                                    assert(__pyx_t_6);
                                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
                                    __Pyx_INCREF(__pyx_t_6);
                                    __Pyx_INCREF(__pyx__function);
                                    __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
                                    __pyx_t_7 = 0;
                                  }
                                  #endif
                                  {
                                    PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
                                    __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                                    __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                                    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2798, __pyx_L700_error)
                                    __Pyx_GOTREF(__pyx_t_3);
                                  }
                                  __pyx_t_21 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 2798, __pyx_L700_error)
                                  __Pyx_GOTREF(__pyx_t_21);
                                  __pyx_t_6 = NULL;
                                  __pyx_t_15 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2798, __pyx_L708_error)
                                  __Pyx_GOTREF(__pyx_t_15);
                                  __pyx_t_7 = 1;
                                  #if CYTHON_UNPACK_METHODS
                                  if (likely(PyMethod_Check(__pyx_t_15))) {
                                    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_15);
                                    assert(__pyx_t_6);
                                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                                    __Pyx_INCREF(__pyx_t_6);
                                    __Pyx_INCREF(__pyx__function);
                                    __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                                    __pyx_t_7 = 0;
                                  }
                                  #endif
                                  {
                                    PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
                                    __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                                    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                                    if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2798, __pyx_L708_error)
                                    __Pyx_GOTREF(__pyx_t_33);
                                  }
                                  __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_33, &__pyx_r);
                                  __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                                  if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                                    __Pyx_GOTREF(__pyx_r);
                                    __Pyx_XGIVEREF(__pyx_t_3);
                                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
                                    __Pyx_XGIVEREF(__pyx_t_11);
                                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_11;
                                    __Pyx_XGIVEREF(__pyx_t_12);
                                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_12;
                                    __Pyx_XGIVEREF(__pyx_t_13);
                                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_13;
                                    __Pyx_XGIVEREF(__pyx_t_18);
                                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_18;
                                    __Pyx_XGIVEREF(__pyx_t_21);
                                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_21;
                                    __Pyx_XGIVEREF(__pyx_t_23);
                                    __pyx_cur_scope->__pyx_t_6 = __pyx_t_23;
                                    __Pyx_XGIVEREF(__pyx_t_31);
                                    __pyx_cur_scope->__pyx_t_7 = __pyx_t_31;
                                    __Pyx_XGIVEREF(__pyx_t_39);
                                    __pyx_cur_scope->__pyx_t_8 = __pyx_t_39;
                                    __Pyx_XGIVEREF(__pyx_t_46);
                                    __pyx_cur_scope->__pyx_t_9 = __pyx_t_46;
                                    __Pyx_XGIVEREF(__pyx_t_47);
                                    __pyx_cur_scope->__pyx_t_10 = __pyx_t_47;
                                    __Pyx_XGIVEREF(__pyx_t_48);
                                    __pyx_cur_scope->__pyx_t_11 = __pyx_t_48;
                                    __Pyx_XGIVEREF(__pyx_r);
                                    __Pyx_RefNannyFinishContext();
                                    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                                    /* return from generator, awaiting value */
                                    __pyx_generator->resume_label = 47;
                                    return __pyx_r;
                                    __pyx_L709_resume_from_await:;
                                    __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
                                    __pyx_cur_scope->__pyx_t_0 = 0;
                                    __Pyx_XGOTREF(__pyx_t_3);
                                    __pyx_t_11 = __pyx_cur_scope->__pyx_t_1;
                                    __pyx_cur_scope->__pyx_t_1 = 0;
                                    __Pyx_XGOTREF(__pyx_t_11);
                                    __pyx_t_12 = __pyx_cur_scope->__pyx_t_2;
                                    __pyx_cur_scope->__pyx_t_2 = 0;
                                    __Pyx_XGOTREF(__pyx_t_12);
                                    __pyx_t_13 = __pyx_cur_scope->__pyx_t_3;
                                    __pyx_cur_scope->__pyx_t_3 = 0;
                                    __Pyx_XGOTREF(__pyx_t_13);
                                    __pyx_t_18 = __pyx_cur_scope->__pyx_t_4;
                                    __pyx_cur_scope->__pyx_t_4 = 0;
                                    __Pyx_XGOTREF(__pyx_t_18);
                                    __pyx_t_21 = __pyx_cur_scope->__pyx_t_5;
                                    __pyx_cur_scope->__pyx_t_5 = 0;
                                    __Pyx_XGOTREF(__pyx_t_21);
                                    __pyx_t_23 = __pyx_cur_scope->__pyx_t_6;
                                    __pyx_cur_scope->__pyx_t_6 = 0;
                                    __Pyx_XGOTREF(__pyx_t_23);
                                    __pyx_t_31 = __pyx_cur_scope->__pyx_t_7;
                                    __pyx_cur_scope->__pyx_t_7 = 0;
                                    __Pyx_XGOTREF(__pyx_t_31);
                                    __pyx_t_39 = __pyx_cur_scope->__pyx_t_8;
                                    __pyx_cur_scope->__pyx_t_8 = 0;
                                    __Pyx_XGOTREF(__pyx_t_39);
                                    __pyx_t_46 = __pyx_cur_scope->__pyx_t_9;
                                    __pyx_cur_scope->__pyx_t_9 = 0;
                                    __Pyx_XGOTREF(__pyx_t_46);
                                    __pyx_t_47 = __pyx_cur_scope->__pyx_t_10;
                                    __pyx_cur_scope->__pyx_t_10 = 0;
                                    __Pyx_XGOTREF(__pyx_t_47);
                                    __pyx_t_48 = __pyx_cur_scope->__pyx_t_11;
                                    __pyx_cur_scope->__pyx_t_11 = 0;
                                    __Pyx_XGOTREF(__pyx_t_48);
                                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2798, __pyx_L708_error)
                                    __pyx_t_33 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_33);
                                  } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                                    __Pyx_GOTREF(__pyx_r);
                                    __pyx_t_33 = __pyx_r; __pyx_r = NULL;
                                  } else {
                                    __Pyx_XGOTREF(__pyx_r);
                                    __PYX_ERR(0, 2798, __pyx_L708_error)
                                  }
                                  __pyx_t_15 = __pyx_t_33;
                                  __pyx_t_33 = 0;
                                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                                  /*try:*/ {
                                    {
                                      __Pyx_ExceptionSave(&__pyx_t_22, &__pyx_t_19, &__pyx_t_20);
                                      __Pyx_XGOTREF(__pyx_t_22);
                                      __Pyx_XGOTREF(__pyx_t_19);
                                      __Pyx_XGOTREF(__pyx_t_20);
                                      /*try:*/ {
                                        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_session);
                                        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_session, __pyx_t_15);
                                        __Pyx_GIVEREF(__pyx_t_15);
                                        __pyx_t_15 = 0;

                                        /* "ws_package/controllers/activity_controller.py":2799
 *                                             with db_lock_manager.read_lock():
 *                                                 async with async_session() as session:
 *                                                     overlap_query_after_trim = select(ActivityInterval).where(             # <<<<<<<<<<<<<<
 *                                                         and_(
 *                                                             ActivityInterval.start_time < end_date,
*/
                                        __pyx_t_6 = NULL;
                                        __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2799, __pyx_L715_error)
                                        __Pyx_GOTREF(__pyx_t_4);
                                        __Pyx_GetModuleGlobalName(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2799, __pyx_L715_error)
                                        __Pyx_GOTREF(__pyx_t_37);
                                        __pyx_t_7 = 1;
                                        #if CYTHON_UNPACK_METHODS
                                        if (unlikely(PyMethod_Check(__pyx_t_4))) {
                                          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
                                          assert(__pyx_t_6);
                                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                                          __Pyx_INCREF(__pyx_t_6);
                                          __Pyx_INCREF(__pyx__function);
                                          __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                                          __pyx_t_7 = 0;
                                        }
                                        #endif
                                        {
                                          PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_37};
                                          __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                                          __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                                          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                          if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2799, __pyx_L715_error)
                                          __Pyx_GOTREF(__pyx_t_33);
                                        }
                                        __pyx_t_3 = __pyx_t_33;
                                        __Pyx_INCREF(__pyx_t_3);

                                        /* "ws_package/controllers/activity_controller.py":2800
 *                                                 async with async_session() as session:
 *                                                     overlap_query_after_trim = select(ActivityInterval).where(
 *                                                         and_(             # <<<<<<<<<<<<<<
 *                                                             ActivityInterval.start_time < end_date,
 *                                                             ActivityInterval.end_time > start_date,
*/
                                        __pyx_t_37 = NULL;
                                        __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_and); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2800, __pyx_L715_error)
                                        __Pyx_GOTREF(__pyx_t_6);

                                        /* "ws_package/controllers/activity_controller.py":2801
 *                                                     overlap_query_after_trim = select(ActivityInterval).where(
 *                                                         and_(
 *                                                             ActivityInterval.start_time < end_date,             # <<<<<<<<<<<<<<
 *                                                             ActivityInterval.end_time > start_date,
 *                                                             ActivityInterval.counter == self.last_count + 1
*/
                                        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2801, __pyx_L715_error)
                                        __Pyx_GOTREF(__pyx_t_5);
                                        __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2801, __pyx_L715_error)
                                        __Pyx_GOTREF(__pyx_t_34);
                                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                                        __pyx_t_5 = PyObject_RichCompare(__pyx_t_34, __pyx_cur_scope->__pyx_v_end_date, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2801, __pyx_L715_error)
                                        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;

                                        /* "ws_package/controllers/activity_controller.py":2802
 *                                                         and_(
 *                                                             ActivityInterval.start_time < end_date,
 *                                                             ActivityInterval.end_time > start_date,             # <<<<<<<<<<<<<<
 *                                                             ActivityInterval.counter == self.last_count + 1
 *                                                         )
*/
                                        __Pyx_GetModuleGlobalName(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2802, __pyx_L715_error)
                                        __Pyx_GOTREF(__pyx_t_34);
                                        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_34, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2802, __pyx_L715_error)
                                        __Pyx_GOTREF(__pyx_t_1);
                                        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                                        __pyx_t_34 = PyObject_RichCompare(__pyx_t_1, __pyx_cur_scope->__pyx_v_start_date, Py_GT); __Pyx_XGOTREF(__pyx_t_34); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2802, __pyx_L715_error)
                                        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

                                        /* "ws_package/controllers/activity_controller.py":2803
 *                                                             ActivityInterval.start_time < end_date,
 *                                                             ActivityInterval.end_time > start_date,
 *                                                             ActivityInterval.counter == self.last_count + 1             # <<<<<<<<<<<<<<
 *                                                         )
 *                                                     )
*/
                                        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2803, __pyx_L715_error)
                                        __Pyx_GOTREF(__pyx_t_1);
                                        __pyx_t_36 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_36)) __PYX_ERR(0, 2803, __pyx_L715_error)
                                        __Pyx_GOTREF(__pyx_t_36);
                                        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                                        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2803, __pyx_L715_error)
                                        __Pyx_GOTREF(__pyx_t_1);
                                        __pyx_t_2 = __Pyx_PyLong_AddObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2803, __pyx_L715_error)
                                        __Pyx_GOTREF(__pyx_t_2);
                                        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                                        __pyx_t_1 = PyObject_RichCompare(__pyx_t_36, __pyx_t_2, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2803, __pyx_L715_error)
                                        __Pyx_DECREF(__pyx_t_36); __pyx_t_36 = 0;
                                        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                                        __pyx_t_7 = 1;
                                        #if CYTHON_UNPACK_METHODS
                                        if (unlikely(PyMethod_Check(__pyx_t_6))) {
                                          __pyx_t_37 = PyMethod_GET_SELF(__pyx_t_6);
                                          assert(__pyx_t_37);
                                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                                          __Pyx_INCREF(__pyx_t_37);
                                          __Pyx_INCREF(__pyx__function);
                                          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                                          __pyx_t_7 = 0;
                                        }
                                        #endif
                                        {
                                          PyObject *__pyx_callargs[4] = {__pyx_t_37, __pyx_t_5, __pyx_t_34, __pyx_t_1};
                                          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                          __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                                          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                                          __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                                          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                                          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                                          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2800, __pyx_L715_error)
                                          __Pyx_GOTREF(__pyx_t_4);
                                        }
                                        __pyx_t_7 = 0;
                                        {
                                          PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_4};
                                          __pyx_t_15 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                                          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                                          if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2799, __pyx_L715_error)
                                          __Pyx_GOTREF(__pyx_t_15);
                                        }
                                        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_overlap_query_after_trim);
                                        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_overlap_query_after_trim, __pyx_t_15);
                                        __Pyx_GIVEREF(__pyx_t_15);
                                        __pyx_t_15 = 0;

                                        /* "ws_package/controllers/activity_controller.py":2806
 *                                                         )
 *                                                     )
 *                                                     overlap_result_after_trim = await session.execute(overlap_query_after_trim)             # <<<<<<<<<<<<<<
 *                                                     overlapping_intervals_after_trim = overlap_result_after_trim.scalars().all()
 * 
*/
                                        __pyx_t_33 = __pyx_cur_scope->__pyx_v_session;
                                        __Pyx_INCREF(__pyx_t_33);
                                        __pyx_t_7 = 0;
                                        {
                                          PyObject *__pyx_callargs[2] = {__pyx_t_33, __pyx_cur_scope->__pyx_v_overlap_query_after_trim};
                                          __pyx_t_15 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                          __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                                          if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2806, __pyx_L715_error)
                                          __Pyx_GOTREF(__pyx_t_15);
                                        }
                                        __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_15, &__pyx_r);
                                        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                                        if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                                          __Pyx_GOTREF(__pyx_r);
                                          __Pyx_XGIVEREF(__pyx_t_11);
                                          __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                                          __Pyx_XGIVEREF(__pyx_t_12);
                                          __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                                          __Pyx_XGIVEREF(__pyx_t_13);
                                          __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                                          __Pyx_XGIVEREF(__pyx_t_18);
                                          __pyx_cur_scope->__pyx_t_3 = __pyx_t_18;
                                          __Pyx_XGIVEREF(__pyx_t_19);
                                          __pyx_cur_scope->__pyx_t_4 = __pyx_t_19;
                                          __Pyx_XGIVEREF(__pyx_t_20);
                                          __pyx_cur_scope->__pyx_t_5 = __pyx_t_20;
                                          __Pyx_XGIVEREF(__pyx_t_21);
                                          __pyx_cur_scope->__pyx_t_6 = __pyx_t_21;
                                          __Pyx_XGIVEREF(__pyx_t_22);
                                          __pyx_cur_scope->__pyx_t_7 = __pyx_t_22;
                                          __Pyx_XGIVEREF(__pyx_t_23);
                                          __pyx_cur_scope->__pyx_t_8 = __pyx_t_23;
                                          __Pyx_XGIVEREF(__pyx_t_31);
                                          __pyx_cur_scope->__pyx_t_9 = __pyx_t_31;
                                          __Pyx_XGIVEREF(__pyx_t_39);
                                          __pyx_cur_scope->__pyx_t_10 = __pyx_t_39;
                                          __Pyx_XGIVEREF(__pyx_t_46);
                                          __pyx_cur_scope->__pyx_t_11 = __pyx_t_46;
                                          __Pyx_XGIVEREF(__pyx_t_47);
                                          __pyx_cur_scope->__pyx_t_12 = __pyx_t_47;
                                          __Pyx_XGIVEREF(__pyx_t_48);
                                          __pyx_cur_scope->__pyx_t_13 = __pyx_t_48;
                                          __Pyx_XGIVEREF(__pyx_r);
                                          __Pyx_RefNannyFinishContext();
                                          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                                          /* return from generator, awaiting value */
                                          __pyx_generator->resume_label = 48;
                                          return __pyx_r;
                                          __pyx_L723_resume_from_await:;
                                          __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                                          __pyx_cur_scope->__pyx_t_0 = 0;
                                          __Pyx_XGOTREF(__pyx_t_11);
                                          __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                                          __pyx_cur_scope->__pyx_t_1 = 0;
                                          __Pyx_XGOTREF(__pyx_t_12);
                                          __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                                          __pyx_cur_scope->__pyx_t_2 = 0;
                                          __Pyx_XGOTREF(__pyx_t_13);
                                          __pyx_t_18 = __pyx_cur_scope->__pyx_t_3;
                                          __pyx_cur_scope->__pyx_t_3 = 0;
                                          __Pyx_XGOTREF(__pyx_t_18);
                                          __pyx_t_19 = __pyx_cur_scope->__pyx_t_4;
                                          __pyx_cur_scope->__pyx_t_4 = 0;
                                          __Pyx_XGOTREF(__pyx_t_19);
                                          __pyx_t_20 = __pyx_cur_scope->__pyx_t_5;
                                          __pyx_cur_scope->__pyx_t_5 = 0;
                                          __Pyx_XGOTREF(__pyx_t_20);
                                          __pyx_t_21 = __pyx_cur_scope->__pyx_t_6;
                                          __pyx_cur_scope->__pyx_t_6 = 0;
                                          __Pyx_XGOTREF(__pyx_t_21);
                                          __pyx_t_22 = __pyx_cur_scope->__pyx_t_7;
                                          __pyx_cur_scope->__pyx_t_7 = 0;
                                          __Pyx_XGOTREF(__pyx_t_22);
                                          __pyx_t_23 = __pyx_cur_scope->__pyx_t_8;
                                          __pyx_cur_scope->__pyx_t_8 = 0;
                                          __Pyx_XGOTREF(__pyx_t_23);
                                          __pyx_t_31 = __pyx_cur_scope->__pyx_t_9;
                                          __pyx_cur_scope->__pyx_t_9 = 0;
                                          __Pyx_XGOTREF(__pyx_t_31);
                                          __pyx_t_39 = __pyx_cur_scope->__pyx_t_10;
                                          __pyx_cur_scope->__pyx_t_10 = 0;
                                          __Pyx_XGOTREF(__pyx_t_39);
                                          __pyx_t_46 = __pyx_cur_scope->__pyx_t_11;
                                          __pyx_cur_scope->__pyx_t_11 = 0;
                                          __Pyx_XGOTREF(__pyx_t_46);
                                          __pyx_t_47 = __pyx_cur_scope->__pyx_t_12;
                                          __pyx_cur_scope->__pyx_t_12 = 0;
                                          __Pyx_XGOTREF(__pyx_t_47);
                                          __pyx_t_48 = __pyx_cur_scope->__pyx_t_13;
                                          __pyx_cur_scope->__pyx_t_13 = 0;
                                          __Pyx_XGOTREF(__pyx_t_48);
                                          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2806, __pyx_L715_error)
                                          __pyx_t_15 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_15);
                                        } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                                          __Pyx_GOTREF(__pyx_r);
                                          __pyx_t_15 = __pyx_r; __pyx_r = NULL;
                                        } else {
                                          __Pyx_XGOTREF(__pyx_r);
                                          __PYX_ERR(0, 2806, __pyx_L715_error)
                                        }
                                        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_overlap_result_after_trim);
                                        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_overlap_result_after_trim, __pyx_t_15);
                                        __Pyx_GIVEREF(__pyx_t_15);
                                        __pyx_t_15 = 0;

                                        /* "ws_package/controllers/activity_controller.py":2807
 *                                                     )
 *                                                     overlap_result_after_trim = await session.execute(overlap_query_after_trim)
 *                                                     overlapping_intervals_after_trim = overlap_result_after_trim.scalars().all()             # <<<<<<<<<<<<<<
 * 
 *                                                     if overlapping_intervals_after_trim:
*/
                                        __pyx_t_3 = __pyx_cur_scope->__pyx_v_overlap_result_after_trim;
                                        __Pyx_INCREF(__pyx_t_3);
                                        __pyx_t_7 = 0;
                                        {
                                          PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
                                          __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalars, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                                          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2807, __pyx_L715_error)
                                          __Pyx_GOTREF(__pyx_t_4);
                                        }
                                        __pyx_t_33 = __pyx_t_4;
                                        __Pyx_INCREF(__pyx_t_33);
                                        __pyx_t_7 = 0;
                                        {
                                          PyObject *__pyx_callargs[2] = {__pyx_t_33, NULL};
                                          __pyx_t_15 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_all, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                          __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                                          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                          if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2807, __pyx_L715_error)
                                          __Pyx_GOTREF(__pyx_t_15);
                                        }
                                        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_overlapping_intervals_after_trim);
                                        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_overlapping_intervals_after_trim, __pyx_t_15);
                                        __Pyx_GIVEREF(__pyx_t_15);
                                        __pyx_t_15 = 0;

                                        /* "ws_package/controllers/activity_controller.py":2809
 *                                                     overlapping_intervals_after_trim = overlap_result_after_trim.scalars().all()
 * 
 *                                                     if overlapping_intervals_after_trim:             # <<<<<<<<<<<<<<
 *                                                         break_intervals_after_trim = [iv for iv in overlapping_intervals_after_trim if iv.is_break != 0]
 *                                                         regular_intervals_after_trim = [iv for iv in overlapping_intervals_after_trim if iv.is_break == 0]
*/
                                        __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_overlapping_intervals_after_trim); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2809, __pyx_L715_error)
                                        if (__pyx_t_8) {

                                          /* "ws_package/controllers/activity_controller.py":2810
 * 
 *                                                     if overlapping_intervals_after_trim:
 *                                                         break_intervals_after_trim = [iv for iv in overlapping_intervals_after_trim if iv.is_break != 0]             # <<<<<<<<<<<<<<
 *                                                         regular_intervals_after_trim = [iv for iv in overlapping_intervals_after_trim if iv.is_break == 0]
 * 
*/
                                          { /* enter inner scope */
                                            __pyx_t_15 = PyList_New(0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2810, __pyx_L715_error)
                                            __Pyx_GOTREF(__pyx_t_15);
                                            if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_overlapping_intervals_after_trim)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_overlapping_intervals_after_trim)) {
                                              __pyx_t_4 = __pyx_cur_scope->__pyx_v_overlapping_intervals_after_trim; __Pyx_INCREF(__pyx_t_4);
                                              __pyx_t_29 = 0;
                                              __pyx_t_54 = NULL;
                                            } else {
                                              __pyx_t_29 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_overlapping_intervals_after_trim); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2810, __pyx_L715_error)
                                              __Pyx_GOTREF(__pyx_t_4);
                                              __pyx_t_54 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); if (unlikely(!__pyx_t_54)) __PYX_ERR(0, 2810, __pyx_L715_error)
                                            }
                                            for (;;) {
                                              if (likely(!__pyx_t_54)) {
                                                if (likely(PyList_CheckExact(__pyx_t_4))) {
                                                  {
                                                    Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4);
                                                    #if !CYTHON_ASSUME_SAFE_SIZE
                                                    if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2810, __pyx_L715_error)
                                                    #endif
                                                    if (__pyx_t_29 >= __pyx_temp) break;
                                                  }
                                                  __pyx_t_33 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_4, __pyx_t_29, __Pyx_ReferenceSharing_OwnStrongReference);
                                                  ++__pyx_t_29;
                                                } else {
                                                  {
                                                    Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4);
                                                    #if !CYTHON_ASSUME_SAFE_SIZE
                                                    if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2810, __pyx_L715_error)
                                                    #endif
                                                    if (__pyx_t_29 >= __pyx_temp) break;
                                                  }
                                                  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                                                  __pyx_t_33 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_29));
                                                  #else
                                                  __pyx_t_33 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_29);
                                                  #endif
                                                  ++__pyx_t_29;
                                                }
                                                if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2810, __pyx_L715_error)
                                              } else {
                                                __pyx_t_33 = __pyx_t_54(__pyx_t_4);
                                                if (unlikely(!__pyx_t_33)) {
                                                  PyObject* exc_type = PyErr_Occurred();
                                                  if (exc_type) {
                                                    if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 2810, __pyx_L715_error)
                                                    PyErr_Clear();
                                                  }
                                                  break;
                                                }
                                              }
                                              __Pyx_GOTREF(__pyx_t_33);
                                              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_8genexpr6__pyx_v_iv);
                                              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_8genexpr6__pyx_v_iv, __pyx_t_33);
                                              __Pyx_GIVEREF(__pyx_t_33);
                                              __pyx_t_33 = 0;
                                              __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_8genexpr6__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_is_break); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2810, __pyx_L715_error)
                                              __Pyx_GOTREF(__pyx_t_33);
                                              __pyx_t_8 = (__Pyx_PyLong_BoolNeObjC(__pyx_t_33, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2810, __pyx_L715_error)
                                              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                                              if (__pyx_t_8) {
                                                if (unlikely(__Pyx_ListComp_Append(__pyx_t_15, (PyObject*)__pyx_cur_scope->__pyx_8genexpr6__pyx_v_iv))) __PYX_ERR(0, 2810, __pyx_L715_error)
                                              }
                                            }
                                            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                          } /* exit inner scope */
                                          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_break_intervals_after_trim);
                                          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_break_intervals_after_trim, ((PyObject*)__pyx_t_15));
                                          __Pyx_GIVEREF(__pyx_t_15);
                                          __pyx_t_15 = 0;

                                          /* "ws_package/controllers/activity_controller.py":2811
 *                                                     if overlapping_intervals_after_trim:
 *                                                         break_intervals_after_trim = [iv for iv in overlapping_intervals_after_trim if iv.is_break != 0]
 *                                                         regular_intervals_after_trim = [iv for iv in overlapping_intervals_after_trim if iv.is_break == 0]             # <<<<<<<<<<<<<<
 * 
 *                                                         if break_intervals_after_trim:
*/
                                          { /* enter inner scope */
                                            __pyx_t_15 = PyList_New(0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2811, __pyx_L715_error)
                                            __Pyx_GOTREF(__pyx_t_15);
                                            if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_overlapping_intervals_after_trim)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_overlapping_intervals_after_trim)) {
                                              __pyx_t_4 = __pyx_cur_scope->__pyx_v_overlapping_intervals_after_trim; __Pyx_INCREF(__pyx_t_4);
                                              __pyx_t_29 = 0;
                                              __pyx_t_54 = NULL;
                                            } else {
                                              __pyx_t_29 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_overlapping_intervals_after_trim); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2811, __pyx_L715_error)
                                              __Pyx_GOTREF(__pyx_t_4);
                                              __pyx_t_54 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); if (unlikely(!__pyx_t_54)) __PYX_ERR(0, 2811, __pyx_L715_error)
                                            }
                                            for (;;) {
                                              if (likely(!__pyx_t_54)) {
                                                if (likely(PyList_CheckExact(__pyx_t_4))) {
                                                  {
                                                    Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4);
                                                    #if !CYTHON_ASSUME_SAFE_SIZE
                                                    if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2811, __pyx_L715_error)
                                                    #endif
                                                    if (__pyx_t_29 >= __pyx_temp) break;
                                                  }
                                                  __pyx_t_33 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_4, __pyx_t_29, __Pyx_ReferenceSharing_OwnStrongReference);
                                                  ++__pyx_t_29;
                                                } else {
                                                  {
                                                    Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4);
                                                    #if !CYTHON_ASSUME_SAFE_SIZE
                                                    if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2811, __pyx_L715_error)
                                                    #endif
                                                    if (__pyx_t_29 >= __pyx_temp) break;
                                                  }
                                                  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                                                  __pyx_t_33 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_29));
                                                  #else
                                                  __pyx_t_33 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_29);
                                                  #endif
                                                  ++__pyx_t_29;
                                                }
                                                if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2811, __pyx_L715_error)
                                              } else {
                                                __pyx_t_33 = __pyx_t_54(__pyx_t_4);
                                                if (unlikely(!__pyx_t_33)) {
                                                  PyObject* exc_type = PyErr_Occurred();
                                                  if (exc_type) {
                                                    if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 2811, __pyx_L715_error)
                                                    PyErr_Clear();
                                                  }
                                                  break;
                                                }
                                              }
                                              __Pyx_GOTREF(__pyx_t_33);
                                              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_8genexpr7__pyx_v_iv);
                                              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_8genexpr7__pyx_v_iv, __pyx_t_33);
                                              __Pyx_GIVEREF(__pyx_t_33);
                                              __pyx_t_33 = 0;
                                              __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_8genexpr7__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_is_break); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2811, __pyx_L715_error)
                                              __Pyx_GOTREF(__pyx_t_33);
                                              __pyx_t_8 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_33, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2811, __pyx_L715_error)
                                              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                                              if (__pyx_t_8) {
                                                if (unlikely(__Pyx_ListComp_Append(__pyx_t_15, (PyObject*)__pyx_cur_scope->__pyx_8genexpr7__pyx_v_iv))) __PYX_ERR(0, 2811, __pyx_L715_error)
                                              }
                                            }
                                            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                          } /* exit inner scope */
                                          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_regular_intervals_after_trim);
                                          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_regular_intervals_after_trim, ((PyObject*)__pyx_t_15));
                                          __Pyx_GIVEREF(__pyx_t_15);
                                          __pyx_t_15 = 0;

                                          /* "ws_package/controllers/activity_controller.py":2813
 *                                                         regular_intervals_after_trim = [iv for iv in overlapping_intervals_after_trim if iv.is_break == 0]
 * 
 *                                                         if break_intervals_after_trim:             # <<<<<<<<<<<<<<
 *                                                             break_interval_overlaps = True
 *                                                             logger.info("After trimming: Break interval overlaps with trimmed time range %s to %s (break intervals: %s) - skipping regular interval creation", start_date, end_date, [(iv.start_time, iv.end_time, iv.is_break) for iv in break_intervals_after_trim])
*/
                                          {
                                            Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_break_intervals_after_trim);
                                            if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 2813, __pyx_L715_error)
                                            __pyx_t_8 = (__pyx_temp != 0);
                                          }

                                          if (__pyx_t_8) {

                                            /* "ws_package/controllers/activity_controller.py":2814
 * 
 *                                                         if break_intervals_after_trim:
 *                                                             break_interval_overlaps = True             # <<<<<<<<<<<<<<
 *                                                             logger.info("After trimming: Break interval overlaps with trimmed time range %s to %s (break intervals: %s) - skipping regular interval creation", start_date, end_date, [(iv.start_time, iv.end_time, iv.is_break) for iv in break_intervals_after_trim])
 *                                                         elif regular_intervals_after_trim:
*/
                                            __pyx_cur_scope->__pyx_v_break_interval_overlaps = 1;

                                            /* "ws_package/controllers/activity_controller.py":2815
 *                                                         if break_intervals_after_trim:
 *                                                             break_interval_overlaps = True
 *                                                             logger.info("After trimming: Break interval overlaps with trimmed time range %s to %s (break intervals: %s) - skipping regular interval creation", start_date, end_date, [(iv.start_time, iv.end_time, iv.is_break) for iv in break_intervals_after_trim])             # <<<<<<<<<<<<<<
 *                                                         elif regular_intervals_after_trim:
 *                                                             regular_interval_overlaps = True
*/
                                            __pyx_t_4 = NULL;
                                            __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2815, __pyx_L715_error)
                                            __Pyx_GOTREF(__pyx_t_33);
                                            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2815, __pyx_L715_error)
                                            __Pyx_GOTREF(__pyx_t_3);
                                            __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                                            { /* enter inner scope */
                                              __pyx_t_33 = PyList_New(0); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2815, __pyx_L715_error)
                                              __Pyx_GOTREF(__pyx_t_33);
                                              __pyx_t_6 = __pyx_cur_scope->__pyx_v_break_intervals_after_trim; __Pyx_INCREF(__pyx_t_6);
                                              __pyx_t_29 = 0;
                                              for (;;) {
                                                {
                                                  Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
                                                  #if !CYTHON_ASSUME_SAFE_SIZE
                                                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2815, __pyx_L715_error)
                                                  #endif
                                                  if (__pyx_t_29 >= __pyx_temp) break;
                                                }
                                                __pyx_t_1 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_6, __pyx_t_29, __Pyx_ReferenceSharing_OwnStrongReference);
                                                ++__pyx_t_29;
                                                if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2815, __pyx_L715_error)
                                                __Pyx_GOTREF(__pyx_t_1);
                                                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_8genexpr8__pyx_v_iv);
                                                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_8genexpr8__pyx_v_iv, __pyx_t_1);
                                                __Pyx_GIVEREF(__pyx_t_1);
                                                __pyx_t_1 = 0;
                                                __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_8genexpr8__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2815, __pyx_L715_error)
                                                __Pyx_GOTREF(__pyx_t_1);
                                                __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_8genexpr8__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2815, __pyx_L715_error)
                                                __Pyx_GOTREF(__pyx_t_34);
                                                __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_8genexpr8__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_is_break); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2815, __pyx_L715_error)
                                                __Pyx_GOTREF(__pyx_t_5);
                                                __pyx_t_37 = PyTuple_New(3); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2815, __pyx_L715_error)
                                                __Pyx_GOTREF(__pyx_t_37);
                                                __Pyx_GIVEREF(__pyx_t_1);
                                                if (__Pyx_PyTuple_SET_ITEM(__pyx_t_37, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 2815, __pyx_L715_error);
                                                __Pyx_GIVEREF(__pyx_t_34);
                                                if (__Pyx_PyTuple_SET_ITEM(__pyx_t_37, 1, __pyx_t_34) != (0)) __PYX_ERR(0, 2815, __pyx_L715_error);
                                                __Pyx_GIVEREF(__pyx_t_5);
                                                if (__Pyx_PyTuple_SET_ITEM(__pyx_t_37, 2, __pyx_t_5) != (0)) __PYX_ERR(0, 2815, __pyx_L715_error);
                                                __pyx_t_1 = 0;
                                                __pyx_t_34 = 0;
                                                __pyx_t_5 = 0;
                                                if (unlikely(__Pyx_ListComp_Append(__pyx_t_33, (PyObject*)__pyx_t_37))) __PYX_ERR(0, 2815, __pyx_L715_error)
                                                __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                                              }
                                              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                                            } /* exit inner scope */
                                            __pyx_t_7 = 1;
                                            #if CYTHON_UNPACK_METHODS
                                            if (unlikely(PyMethod_Check(__pyx_t_3))) {
                                              __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
                                              assert(__pyx_t_4);
                                              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
                                              __Pyx_INCREF(__pyx_t_4);
                                              __Pyx_INCREF(__pyx__function);
                                              __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
                                              __pyx_t_7 = 0;
                                            }
                                            #endif
                                            {
                                              PyObject *__pyx_callargs[5] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_After_trimming_Break_interval_ov, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date, __pyx_t_33};
                                              __pyx_t_15 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (5-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                                              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                                              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                                              if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2815, __pyx_L715_error)
                                              __Pyx_GOTREF(__pyx_t_15);
                                            }
                                            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

                                            /* "ws_package/controllers/activity_controller.py":2813
 *                                                         regular_intervals_after_trim = [iv for iv in overlapping_intervals_after_trim if iv.is_break == 0]
 * 
 *                                                         if break_intervals_after_trim:             # <<<<<<<<<<<<<<
 *                                                             break_interval_overlaps = True
 *                                                             logger.info("After trimming: Break interval overlaps with trimmed time range %s to %s (break intervals: %s) - skipping regular interval creation", start_date, end_date, [(iv.start_time, iv.end_time, iv.is_break) for iv in break_intervals_after_trim])
*/
                                            goto __pyx_L733;
                                          }

                                          /* "ws_package/controllers/activity_controller.py":2816
 *                                                             break_interval_overlaps = True
 *                                                             logger.info("After trimming: Break interval overlaps with trimmed time range %s to %s (break intervals: %s) - skipping regular interval creation", start_date, end_date, [(iv.start_time, iv.end_time, iv.is_break) for iv in break_intervals_after_trim])
 *                                                         elif regular_intervals_after_trim:             # <<<<<<<<<<<<<<
 *                                                             regular_interval_overlaps = True
 *                                                             overlapping_details_after_trim = [(iv.start_time, iv.end_time, iv.is_break) for iv in regular_intervals_after_trim]
*/
                                          {
                                            Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_regular_intervals_after_trim);
                                            if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 2816, __pyx_L715_error)
                                            __pyx_t_8 = (__pyx_temp != 0);
                                          }

                                          if (__pyx_t_8) {

                                            /* "ws_package/controllers/activity_controller.py":2817
 *                                                             logger.info("After trimming: Break interval overlaps with trimmed time range %s to %s (break intervals: %s) - skipping regular interval creation", start_date, end_date, [(iv.start_time, iv.end_time, iv.is_break) for iv in break_intervals_after_trim])
 *                                                         elif regular_intervals_after_trim:
 *                                                             regular_interval_overlaps = True             # <<<<<<<<<<<<<<
 *                                                             overlapping_details_after_trim = [(iv.start_time, iv.end_time, iv.is_break) for iv in regular_intervals_after_trim]
 *                                                             logger.info("After trimming: Regular interval overlaps with trimmed time range %s to %s (overlapping intervals: %s) - skipping duplicate creation to prevent overlap", start_date, end_date, overlapping_details_after_trim)
*/
                                            __pyx_cur_scope->__pyx_v_regular_interval_overlaps = 1;

                                            /* "ws_package/controllers/activity_controller.py":2818
 *                                                         elif regular_intervals_after_trim:
 *                                                             regular_interval_overlaps = True
 *                                                             overlapping_details_after_trim = [(iv.start_time, iv.end_time, iv.is_break) for iv in regular_intervals_after_trim]             # <<<<<<<<<<<<<<
 *                                                             logger.info("After trimming: Regular interval overlaps with trimmed time range %s to %s (overlapping intervals: %s) - skipping duplicate creation to prevent overlap", start_date, end_date, overlapping_details_after_trim)
 *                                     except Exception as e:
*/
                                            { /* enter inner scope */
                                              __pyx_t_15 = PyList_New(0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2818, __pyx_L715_error)
                                              __Pyx_GOTREF(__pyx_t_15);
                                              __pyx_t_3 = __pyx_cur_scope->__pyx_v_regular_intervals_after_trim; __Pyx_INCREF(__pyx_t_3);
                                              __pyx_t_29 = 0;
                                              for (;;) {
                                                {
                                                  Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3);
                                                  #if !CYTHON_ASSUME_SAFE_SIZE
                                                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2818, __pyx_L715_error)
                                                  #endif
                                                  if (__pyx_t_29 >= __pyx_temp) break;
                                                }
                                                __pyx_t_33 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_3, __pyx_t_29, __Pyx_ReferenceSharing_OwnStrongReference);
                                                ++__pyx_t_29;
                                                if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2818, __pyx_L715_error)
                                                __Pyx_GOTREF(__pyx_t_33);
                                                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_8genexpr9__pyx_v_iv);
                                                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_8genexpr9__pyx_v_iv, __pyx_t_33);
                                                __Pyx_GIVEREF(__pyx_t_33);
                                                __pyx_t_33 = 0;
                                                __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_8genexpr9__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2818, __pyx_L715_error)
                                                __Pyx_GOTREF(__pyx_t_33);
                                                __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_8genexpr9__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2818, __pyx_L715_error)
                                                __Pyx_GOTREF(__pyx_t_4);
                                                __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_8genexpr9__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_is_break); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2818, __pyx_L715_error)
                                                __Pyx_GOTREF(__pyx_t_6);
                                                __pyx_t_37 = PyTuple_New(3); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2818, __pyx_L715_error)
                                                __Pyx_GOTREF(__pyx_t_37);
                                                __Pyx_GIVEREF(__pyx_t_33);
                                                if (__Pyx_PyTuple_SET_ITEM(__pyx_t_37, 0, __pyx_t_33) != (0)) __PYX_ERR(0, 2818, __pyx_L715_error);
                                                __Pyx_GIVEREF(__pyx_t_4);
                                                if (__Pyx_PyTuple_SET_ITEM(__pyx_t_37, 1, __pyx_t_4) != (0)) __PYX_ERR(0, 2818, __pyx_L715_error);
                                                __Pyx_GIVEREF(__pyx_t_6);
                                                if (__Pyx_PyTuple_SET_ITEM(__pyx_t_37, 2, __pyx_t_6) != (0)) __PYX_ERR(0, 2818, __pyx_L715_error);
                                                __pyx_t_33 = 0;
                                                __pyx_t_4 = 0;
                                                __pyx_t_6 = 0;
                                                if (unlikely(__Pyx_ListComp_Append(__pyx_t_15, (PyObject*)__pyx_t_37))) __PYX_ERR(0, 2818, __pyx_L715_error)
                                                __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                                              }
                                              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                                            } /* exit inner scope */
                                            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_overlapping_details_after_trim);
                                            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_overlapping_details_after_trim, ((PyObject*)__pyx_t_15));
                                            __Pyx_GIVEREF(__pyx_t_15);
                                            __pyx_t_15 = 0;

                                            /* "ws_package/controllers/activity_controller.py":2819
 *                                                             regular_interval_overlaps = True
 *                                                             overlapping_details_after_trim = [(iv.start_time, iv.end_time, iv.is_break) for iv in regular_intervals_after_trim]
 *                                                             logger.info("After trimming: Regular interval overlaps with trimmed time range %s to %s (overlapping intervals: %s) - skipping duplicate creation to prevent overlap", start_date, end_date, overlapping_details_after_trim)             # <<<<<<<<<<<<<<
 *                                     except Exception as e:
 *                                         logger.warning("Error checking for overlaps after trimming: %s - will proceed with creation (non-critical)", e)
*/
                                            __pyx_t_3 = NULL;
                                            __Pyx_GetModuleGlobalName(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2819, __pyx_L715_error)
                                            __Pyx_GOTREF(__pyx_t_37);
                                            __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2819, __pyx_L715_error)
                                            __Pyx_GOTREF(__pyx_t_6);
                                            __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                                            __pyx_t_7 = 1;
                                            #if CYTHON_UNPACK_METHODS
                                            if (unlikely(PyMethod_Check(__pyx_t_6))) {
                                              __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_6);
                                              assert(__pyx_t_3);
                                              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                                              __Pyx_INCREF(__pyx_t_3);
                                              __Pyx_INCREF(__pyx__function);
                                              __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                                              __pyx_t_7 = 0;
                                            }
                                            #endif
                                            {
                                              PyObject *__pyx_callargs[5] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_After_trimming_Regular_interval, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date, __pyx_cur_scope->__pyx_v_overlapping_details_after_trim};
                                              __pyx_t_15 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (5-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                                              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                                              if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2819, __pyx_L715_error)
                                              __Pyx_GOTREF(__pyx_t_15);
                                            }
                                            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

                                            /* "ws_package/controllers/activity_controller.py":2816
 *                                                             break_interval_overlaps = True
 *                                                             logger.info("After trimming: Break interval overlaps with trimmed time range %s to %s (break intervals: %s) - skipping regular interval creation", start_date, end_date, [(iv.start_time, iv.end_time, iv.is_break) for iv in break_intervals_after_trim])
 *                                                         elif regular_intervals_after_trim:             # <<<<<<<<<<<<<<
 *                                                             regular_interval_overlaps = True
 *                                                             overlapping_details_after_trim = [(iv.start_time, iv.end_time, iv.is_break) for iv in regular_intervals_after_trim]
*/
                                          }
                                          __pyx_L733:;

                                          /* "ws_package/controllers/activity_controller.py":2809
 *                                                     overlapping_intervals_after_trim = overlap_result_after_trim.scalars().all()
 * 
 *                                                     if overlapping_intervals_after_trim:             # <<<<<<<<<<<<<<
 *                                                         break_intervals_after_trim = [iv for iv in overlapping_intervals_after_trim if iv.is_break != 0]
 *                                                         regular_intervals_after_trim = [iv for iv in overlapping_intervals_after_trim if iv.is_break == 0]
*/
                                        }

                                        /* "ws_package/controllers/activity_controller.py":2798
 *                                         if not break_interval_overlaps:
 *                                             with db_lock_manager.read_lock():
 *                                                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                                                     overlap_query_after_trim = select(ActivityInterval).where(
 *                                                         and_(
*/
                                      }
                                      __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                                      __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                                      __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                                      goto __pyx_L722_try_end;
                                      __pyx_L715_error:;
                                      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                                      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                                      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                                      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                                      __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                                      __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                                      __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                                      __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                                      __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                                      __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                                      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                                      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                                      /*except:*/ {
                                        __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
                                        if (__Pyx_GetException(&__pyx_t_15, &__pyx_t_6, &__pyx_t_3) < 0) __PYX_ERR(0, 2798, __pyx_L717_except_error)
                                        __Pyx_XGOTREF(__pyx_t_15);
                                        __Pyx_XGOTREF(__pyx_t_6);
                                        __Pyx_XGOTREF(__pyx_t_3);
                                        __pyx_t_37 = PyTuple_Pack(3, __pyx_t_15, __pyx_t_6, __pyx_t_3); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2798, __pyx_L717_except_error)
                                        __Pyx_GOTREF(__pyx_t_37);
                                        __pyx_t_32 = __Pyx_PyObject_Call(__pyx_t_21, __pyx_t_37, NULL);
                                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                                        __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                                        if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 2798, __pyx_L717_except_error)
                                        __Pyx_GOTREF(__pyx_t_32);
                                        __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_32, &__pyx_r);
                                        __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0;
                                        if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                                          __Pyx_GOTREF(__pyx_r);
                                          __Pyx_XGIVEREF(__pyx_t_3);
                                          __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
                                          __Pyx_XGIVEREF(__pyx_t_6);
                                          __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
                                          __Pyx_XGIVEREF(__pyx_t_11);
                                          __pyx_cur_scope->__pyx_t_2 = __pyx_t_11;
                                          __Pyx_XGIVEREF(__pyx_t_12);
                                          __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                                          __Pyx_XGIVEREF(__pyx_t_13);
                                          __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                                          __Pyx_XGIVEREF(__pyx_t_15);
                                          __pyx_cur_scope->__pyx_t_5 = __pyx_t_15;
                                          __Pyx_XGIVEREF(__pyx_t_18);
                                          __pyx_cur_scope->__pyx_t_6 = __pyx_t_18;
                                          __Pyx_XGIVEREF(__pyx_t_19);
                                          __pyx_cur_scope->__pyx_t_7 = __pyx_t_19;
                                          __Pyx_XGIVEREF(__pyx_t_20);
                                          __pyx_cur_scope->__pyx_t_8 = __pyx_t_20;
                                          __Pyx_XGIVEREF(__pyx_t_21);
                                          __pyx_cur_scope->__pyx_t_9 = __pyx_t_21;
                                          __Pyx_XGIVEREF(__pyx_t_22);
                                          __pyx_cur_scope->__pyx_t_10 = __pyx_t_22;
                                          __Pyx_XGIVEREF(__pyx_t_23);
                                          __pyx_cur_scope->__pyx_t_11 = __pyx_t_23;
                                          __Pyx_XGIVEREF(__pyx_t_31);
                                          __pyx_cur_scope->__pyx_t_12 = __pyx_t_31;
                                          __Pyx_XGIVEREF(__pyx_t_32);
                                          __pyx_cur_scope->__pyx_t_13 = __pyx_t_32;
                                          __Pyx_XGIVEREF(__pyx_t_39);
                                          __pyx_cur_scope->__pyx_t_14 = __pyx_t_39;
                                          __Pyx_XGIVEREF(__pyx_t_46);
                                          __pyx_cur_scope->__pyx_t_16 = __pyx_t_46;
                                          __Pyx_XGIVEREF(__pyx_t_47);
                                          __pyx_cur_scope->__pyx_t_17 = __pyx_t_47;
                                          __Pyx_XGIVEREF(__pyx_t_48);
                                          __pyx_cur_scope->__pyx_t_18 = __pyx_t_48;
                                          __Pyx_XGIVEREF(__pyx_r);
                                          __Pyx_RefNannyFinishContext();
                                          __Pyx_Coroutine_SwapException(__pyx_generator);
                                          /* return from generator, awaiting value */
                                          __pyx_generator->resume_label = 49;
                                          return __pyx_r;
                                          __pyx_L743_resume_from_await:;
                                          __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
                                          __pyx_cur_scope->__pyx_t_0 = 0;
                                          __Pyx_XGOTREF(__pyx_t_3);
                                          __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
                                          __pyx_cur_scope->__pyx_t_1 = 0;
                                          __Pyx_XGOTREF(__pyx_t_6);
                                          __pyx_t_11 = __pyx_cur_scope->__pyx_t_2;
                                          __pyx_cur_scope->__pyx_t_2 = 0;
                                          __Pyx_XGOTREF(__pyx_t_11);
                                          __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                                          __pyx_cur_scope->__pyx_t_3 = 0;
                                          __Pyx_XGOTREF(__pyx_t_12);
                                          __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                                          __pyx_cur_scope->__pyx_t_4 = 0;
                                          __Pyx_XGOTREF(__pyx_t_13);
                                          __pyx_t_15 = __pyx_cur_scope->__pyx_t_5;
                                          __pyx_cur_scope->__pyx_t_5 = 0;
                                          __Pyx_XGOTREF(__pyx_t_15);
                                          __pyx_t_18 = __pyx_cur_scope->__pyx_t_6;
                                          __pyx_cur_scope->__pyx_t_6 = 0;
                                          __Pyx_XGOTREF(__pyx_t_18);
                                          __pyx_t_19 = __pyx_cur_scope->__pyx_t_7;
                                          __pyx_cur_scope->__pyx_t_7 = 0;
                                          __Pyx_XGOTREF(__pyx_t_19);
                                          __pyx_t_20 = __pyx_cur_scope->__pyx_t_8;
                                          __pyx_cur_scope->__pyx_t_8 = 0;
                                          __Pyx_XGOTREF(__pyx_t_20);
                                          __pyx_t_21 = __pyx_cur_scope->__pyx_t_9;
                                          __pyx_cur_scope->__pyx_t_9 = 0;
                                          __Pyx_XGOTREF(__pyx_t_21);
                                          __pyx_t_22 = __pyx_cur_scope->__pyx_t_10;
                                          __pyx_cur_scope->__pyx_t_10 = 0;
                                          __Pyx_XGOTREF(__pyx_t_22);
                                          __pyx_t_23 = __pyx_cur_scope->__pyx_t_11;
                                          __pyx_cur_scope->__pyx_t_11 = 0;
                                          __Pyx_XGOTREF(__pyx_t_23);
                                          __pyx_t_31 = __pyx_cur_scope->__pyx_t_12;
                                          __pyx_cur_scope->__pyx_t_12 = 0;
                                          __Pyx_XGOTREF(__pyx_t_31);
                                          __pyx_t_32 = __pyx_cur_scope->__pyx_t_13;
                                          __pyx_cur_scope->__pyx_t_13 = 0;
                                          __Pyx_XGOTREF(__pyx_t_32);
                                          __pyx_t_39 = __pyx_cur_scope->__pyx_t_14;
                                          __pyx_cur_scope->__pyx_t_14 = 0;
                                          __Pyx_XGOTREF(__pyx_t_39);
                                          __pyx_t_46 = __pyx_cur_scope->__pyx_t_16;
                                          __pyx_cur_scope->__pyx_t_16 = 0;
                                          __Pyx_XGOTREF(__pyx_t_46);
                                          __pyx_t_47 = __pyx_cur_scope->__pyx_t_17;
                                          __pyx_cur_scope->__pyx_t_17 = 0;
                                          __Pyx_XGOTREF(__pyx_t_47);
                                          __pyx_t_48 = __pyx_cur_scope->__pyx_t_18;
                                          __pyx_cur_scope->__pyx_t_18 = 0;
                                          __Pyx_XGOTREF(__pyx_t_48);
                                          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2798, __pyx_L717_except_error)
                                          __pyx_t_37 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_37);
                                        } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                                          __Pyx_GOTREF(__pyx_r);
                                          __pyx_t_37 = __pyx_r; __pyx_r = NULL;
                                        } else {
                                          __Pyx_XGOTREF(__pyx_r);
                                          __PYX_ERR(0, 2798, __pyx_L717_except_error)
                                        }
                                        __pyx_t_32 = __pyx_t_37;
                                        __pyx_t_37 = 0;
                                        __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_32);
                                        __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0;
                                        if (__pyx_t_8 < (0)) __PYX_ERR(0, 2798, __pyx_L717_except_error)
                                        __pyx_t_9 = (!__pyx_t_8);
                                        if (unlikely(__pyx_t_9)) {
                                          __Pyx_GIVEREF(__pyx_t_15);
                                          __Pyx_GIVEREF(__pyx_t_6);
                                          __Pyx_XGIVEREF(__pyx_t_3);
                                          __Pyx_ErrRestoreWithState(__pyx_t_15, __pyx_t_6, __pyx_t_3);
                                          __pyx_t_15 = 0;  __pyx_t_6 = 0;  __pyx_t_3 = 0; 
                                          __PYX_ERR(0, 2798, __pyx_L717_except_error)
                                        }
                                        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                                        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                                        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                                        goto __pyx_L716_exception_handled;
                                      }
                                      __pyx_L717_except_error:;
                                      __Pyx_XGIVEREF(__pyx_t_22);
                                      __Pyx_XGIVEREF(__pyx_t_19);
                                      __Pyx_XGIVEREF(__pyx_t_20);
                                      __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_19, __pyx_t_20);
                                      goto __pyx_L700_error;
                                      __pyx_L716_exception_handled:;
                                      __Pyx_XGIVEREF(__pyx_t_22);
                                      __Pyx_XGIVEREF(__pyx_t_19);
                                      __Pyx_XGIVEREF(__pyx_t_20);
                                      __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_19, __pyx_t_20);
                                      __pyx_L722_try_end:;
                                    }
                                  }
                                  /*finally:*/ {
                                    /*normal exit:*/{
                                      if (__pyx_t_21) {
                                        __pyx_t_20 = __Pyx_PyObject_Call(__pyx_t_21, __pyx_mstate_global->__pyx_tuple[7], NULL);
                                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                                        if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 2798, __pyx_L700_error)
                                        __Pyx_GOTREF(__pyx_t_20);
                                        __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_20, &__pyx_r);
                                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                                        if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                                          __Pyx_GOTREF(__pyx_r);
                                          __Pyx_XGIVEREF(__pyx_t_11);
                                          __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                                          __Pyx_XGIVEREF(__pyx_t_12);
                                          __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                                          __Pyx_XGIVEREF(__pyx_t_13);
                                          __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                                          __Pyx_XGIVEREF(__pyx_t_18);
                                          __pyx_cur_scope->__pyx_t_3 = __pyx_t_18;
                                          __Pyx_XGIVEREF(__pyx_t_20);
                                          __pyx_cur_scope->__pyx_t_4 = __pyx_t_20;
                                          __Pyx_XGIVEREF(__pyx_t_21);
                                          __pyx_cur_scope->__pyx_t_5 = __pyx_t_21;
                                          __Pyx_XGIVEREF(__pyx_t_23);
                                          __pyx_cur_scope->__pyx_t_6 = __pyx_t_23;
                                          __Pyx_XGIVEREF(__pyx_t_31);
                                          __pyx_cur_scope->__pyx_t_7 = __pyx_t_31;
                                          __Pyx_XGIVEREF(__pyx_t_39);
                                          __pyx_cur_scope->__pyx_t_8 = __pyx_t_39;
                                          __Pyx_XGIVEREF(__pyx_t_46);
                                          __pyx_cur_scope->__pyx_t_9 = __pyx_t_46;
                                          __Pyx_XGIVEREF(__pyx_t_47);
                                          __pyx_cur_scope->__pyx_t_10 = __pyx_t_47;
                                          __Pyx_XGIVEREF(__pyx_t_48);
                                          __pyx_cur_scope->__pyx_t_11 = __pyx_t_48;
                                          __Pyx_XGIVEREF(__pyx_r);
                                          __Pyx_RefNannyFinishContext();
                                          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                                          /* return from generator, awaiting value */
                                          __pyx_generator->resume_label = 50;
                                          return __pyx_r;
                                          __pyx_L744_resume_from_await:;
                                          __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                                          __pyx_cur_scope->__pyx_t_0 = 0;
                                          __Pyx_XGOTREF(__pyx_t_11);
                                          __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                                          __pyx_cur_scope->__pyx_t_1 = 0;
                                          __Pyx_XGOTREF(__pyx_t_12);
                                          __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                                          __pyx_cur_scope->__pyx_t_2 = 0;
                                          __Pyx_XGOTREF(__pyx_t_13);
                                          __pyx_t_18 = __pyx_cur_scope->__pyx_t_3;
                                          __pyx_cur_scope->__pyx_t_3 = 0;
                                          __Pyx_XGOTREF(__pyx_t_18);
                                          __pyx_t_20 = __pyx_cur_scope->__pyx_t_4;
                                          __pyx_cur_scope->__pyx_t_4 = 0;
                                          __Pyx_XGOTREF(__pyx_t_20);
                                          __pyx_t_21 = __pyx_cur_scope->__pyx_t_5;
                                          __pyx_cur_scope->__pyx_t_5 = 0;
                                          __Pyx_XGOTREF(__pyx_t_21);
                                          __pyx_t_23 = __pyx_cur_scope->__pyx_t_6;
                                          __pyx_cur_scope->__pyx_t_6 = 0;
                                          __Pyx_XGOTREF(__pyx_t_23);
                                          __pyx_t_31 = __pyx_cur_scope->__pyx_t_7;
                                          __pyx_cur_scope->__pyx_t_7 = 0;
                                          __Pyx_XGOTREF(__pyx_t_31);
                                          __pyx_t_39 = __pyx_cur_scope->__pyx_t_8;
                                          __pyx_cur_scope->__pyx_t_8 = 0;
                                          __Pyx_XGOTREF(__pyx_t_39);
                                          __pyx_t_46 = __pyx_cur_scope->__pyx_t_9;
                                          __pyx_cur_scope->__pyx_t_9 = 0;
                                          __Pyx_XGOTREF(__pyx_t_46);
                                          __pyx_t_47 = __pyx_cur_scope->__pyx_t_10;
                                          __pyx_cur_scope->__pyx_t_10 = 0;
                                          __Pyx_XGOTREF(__pyx_t_47);
                                          __pyx_t_48 = __pyx_cur_scope->__pyx_t_11;
                                          __pyx_cur_scope->__pyx_t_11 = 0;
                                          __Pyx_XGOTREF(__pyx_t_48);
                                          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2798, __pyx_L700_error)
                                          __pyx_t_3 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_3);
                                        } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                                          __Pyx_GOTREF(__pyx_r);
                                          __pyx_t_3 = __pyx_r; __pyx_r = NULL;
                                        } else {
                                          __Pyx_XGOTREF(__pyx_r);
                                          __PYX_ERR(0, 2798, __pyx_L700_error)
                                        }
                                        __pyx_t_20 = __pyx_t_3;
                                        __pyx_t_3 = 0;
                                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                                      }
                                      goto __pyx_L714;
                                    }
                                    __pyx_L714:;
                                  }
                                  goto __pyx_L745;
                                  __pyx_L708_error:;
                                  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                                  goto __pyx_L700_error;
                                  __pyx_L745:;
                                }

                                /* "ws_package/controllers/activity_controller.py":2797
 * 
 *                                         if not break_interval_overlaps:
 *                                             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                                                 async with async_session() as session:
 *                                                     overlap_query_after_trim = select(ActivityInterval).where(
*/
                              }
                              __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                              __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                              goto __pyx_L707_try_end;
                              __pyx_L700_error:;
                              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                              __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                              __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                              __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                              __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                              __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                              __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                              __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                              /*except:*/ {
                                __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
                                if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_6, &__pyx_t_15) < 0) __PYX_ERR(0, 2797, __pyx_L702_except_error)
                                __Pyx_XGOTREF(__pyx_t_3);
                                __Pyx_XGOTREF(__pyx_t_6);
                                __Pyx_XGOTREF(__pyx_t_15);
                                __pyx_t_37 = PyTuple_Pack(3, __pyx_t_3, __pyx_t_6, __pyx_t_15); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2797, __pyx_L702_except_error)
                                __Pyx_GOTREF(__pyx_t_37);
                                __pyx_t_21 = __Pyx_PyObject_Call(__pyx_t_31, __pyx_t_37, NULL);
                                __Pyx_DECREF(__pyx_t_31); __pyx_t_31 = 0;
                                __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                                if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 2797, __pyx_L702_except_error)
                                __Pyx_GOTREF(__pyx_t_21);
                                __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_21);
                                __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                                if (__pyx_t_9 < (0)) __PYX_ERR(0, 2797, __pyx_L702_except_error)
                                __pyx_t_8 = (!__pyx_t_9);
                                if (unlikely(__pyx_t_8)) {
                                  __Pyx_GIVEREF(__pyx_t_3);
                                  __Pyx_GIVEREF(__pyx_t_6);
                                  __Pyx_XGIVEREF(__pyx_t_15);
                                  __Pyx_ErrRestoreWithState(__pyx_t_3, __pyx_t_6, __pyx_t_15);
                                  __pyx_t_3 = 0;  __pyx_t_6 = 0;  __pyx_t_15 = 0; 
                                  __PYX_ERR(0, 2797, __pyx_L702_except_error)
                                }
                                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                                goto __pyx_L701_exception_handled;
                              }
                              __pyx_L702_except_error:;
                              __Pyx_XGIVEREF(__pyx_t_18);
                              __Pyx_XGIVEREF(__pyx_t_39);
                              __Pyx_XGIVEREF(__pyx_t_23);
                              __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_39, __pyx_t_23);
                              goto __pyx_L674_error;
                              __pyx_L701_exception_handled:;
                              __Pyx_XGIVEREF(__pyx_t_18);
                              __Pyx_XGIVEREF(__pyx_t_39);
                              __Pyx_XGIVEREF(__pyx_t_23);
                              __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_39, __pyx_t_23);
                              __pyx_L707_try_end:;
                            }
                          }
                          /*finally:*/ {
                            /*normal exit:*/{
                              if (__pyx_t_31) {
                                __pyx_t_23 = __Pyx_PyObject_Call(__pyx_t_31, __pyx_mstate_global->__pyx_tuple[7], NULL);
                                __Pyx_DECREF(__pyx_t_31); __pyx_t_31 = 0;
                                if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 2797, __pyx_L674_error)
                                __Pyx_GOTREF(__pyx_t_23);
                                __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                              }
                              goto __pyx_L699;
                            }
                            __pyx_L699:;
                          }
                          goto __pyx_L749;
                          __pyx_L694_error:;
                          __Pyx_DECREF(__pyx_t_31); __pyx_t_31 = 0;
                          goto __pyx_L674_error;
                          __pyx_L749:;
                        }

                        /* "ws_package/controllers/activity_controller.py":2796
 *                                                     break
 * 
 *                                         if not break_interval_overlaps:             # <<<<<<<<<<<<<<
 *                                             with db_lock_manager.read_lock():
 *                                                 async with async_session() as session:
*/
                      }

                      /* "ws_package/controllers/activity_controller.py":2780
 * 
 *                                     # Re-check for overlaps after trimming (non-blocking: queue check + async lock)
 *                                     try:             # <<<<<<<<<<<<<<
 *                                         from ws_package.utils.db_write_queue import db_write_queue as _dwq2, WriteOperationType as _WOT2
 *                                         for _pi2 in _dwq2.get_pending_items(_WOT2.ACTIVITY_INTERVAL):
*/
                    }
                    __Pyx_XDECREF(__pyx_t_48); __pyx_t_48 = 0;
                    __Pyx_XDECREF(__pyx_t_47); __pyx_t_47 = 0;
                    __Pyx_XDECREF(__pyx_t_46); __pyx_t_46 = 0;
                    goto __pyx_L681_try_end;
                    __pyx_L674_error:;
                    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                    __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                    __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                    __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                    __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                    __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

                    /* "ws_package/controllers/activity_controller.py":2820
 *                                                             overlapping_details_after_trim = [(iv.start_time, iv.end_time, iv.is_break) for iv in regular_intervals_after_trim]
 *                                                             logger.info("After trimming: Regular interval overlaps with trimmed time range %s to %s (overlapping intervals: %s) - skipping duplicate creation to prevent overlap", start_date, end_date, overlapping_details_after_trim)
 *                                     except Exception as e:             # <<<<<<<<<<<<<<
 *                                         logger.warning("Error checking for overlaps after trimming: %s - will proceed with creation (non-critical)", e)
 * 
*/
                    __pyx_t_16 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                    if (__pyx_t_16) {
                      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_15, &__pyx_t_6, &__pyx_t_3) < 0) __PYX_ERR(0, 2820, __pyx_L676_except_error)
                      __Pyx_XGOTREF(__pyx_t_15);
                      __Pyx_XGOTREF(__pyx_t_6);
                      __Pyx_XGOTREF(__pyx_t_3);
                      __Pyx_INCREF(__pyx_t_6);
                      __Pyx_GIVEREF(__pyx_t_6);
                      __pyx_cur_scope->__pyx_v_e = __pyx_t_6;
                      /*try:*/ {

                        /* "ws_package/controllers/activity_controller.py":2821
 *                                                             logger.info("After trimming: Regular interval overlaps with trimmed time range %s to %s (overlapping intervals: %s) - skipping duplicate creation to prevent overlap", start_date, end_date, overlapping_details_after_trim)
 *                                     except Exception as e:
 *                                         logger.warning("Error checking for overlaps after trimming: %s - will proceed with creation (non-critical)", e)             # <<<<<<<<<<<<<<
 * 
 *                                     # If overlap found after trimming, skip creation
*/
                        __pyx_t_4 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2821, __pyx_L755_error)
                        __Pyx_GOTREF(__pyx_t_33);
                        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2821, __pyx_L755_error)
                        __Pyx_GOTREF(__pyx_t_5);
                        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                        __pyx_t_7 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_5))) {
                          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
                          assert(__pyx_t_4);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                          __Pyx_INCREF(__pyx_t_4);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                          __pyx_t_7 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Error_checking_for_overlaps_afte, __pyx_cur_scope->__pyx_v_e};
                          __pyx_t_37 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                          if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2821, __pyx_L755_error)
                          __Pyx_GOTREF(__pyx_t_37);
                        }
                        __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                      }

                      /* "ws_package/controllers/activity_controller.py":2820
 *                                                             overlapping_details_after_trim = [(iv.start_time, iv.end_time, iv.is_break) for iv in regular_intervals_after_trim]
 *                                                             logger.info("After trimming: Regular interval overlaps with trimmed time range %s to %s (overlapping intervals: %s) - skipping duplicate creation to prevent overlap", start_date, end_date, overlapping_details_after_trim)
 *                                     except Exception as e:             # <<<<<<<<<<<<<<
 *                                         logger.warning("Error checking for overlaps after trimming: %s - will proceed with creation (non-critical)", e)
 * 
*/
                      /*finally:*/ {
                        /*normal exit:*/{
                          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                          goto __pyx_L756;
                        }
                        __pyx_L755_error:;
                        /*exception exit:*/{
                          __Pyx_PyThreadState_assign
                          __pyx_t_31 = 0; __pyx_t_23 = 0; __pyx_t_39 = 0; __pyx_t_18 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0;
                          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                          __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                          __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                          __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                          __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                          __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                          __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                           __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_21, &__pyx_t_20);
                          if ( unlikely(__Pyx_GetException(&__pyx_t_31, &__pyx_t_23, &__pyx_t_39) < 0)) __Pyx_ErrFetch(&__pyx_t_31, &__pyx_t_23, &__pyx_t_39);
                          __Pyx_XGOTREF(__pyx_t_31);
                          __Pyx_XGOTREF(__pyx_t_23);
                          __Pyx_XGOTREF(__pyx_t_39);
                          __Pyx_XGOTREF(__pyx_t_18);
                          __Pyx_XGOTREF(__pyx_t_21);
                          __Pyx_XGOTREF(__pyx_t_20);
                          __pyx_t_16 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_61 = __pyx_filename;
                          {
                            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                          }
                          __Pyx_XGIVEREF(__pyx_t_18);
                          __Pyx_XGIVEREF(__pyx_t_21);
                          __Pyx_XGIVEREF(__pyx_t_20);
                          __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_21, __pyx_t_20);
                          __Pyx_XGIVEREF(__pyx_t_31);
                          __Pyx_XGIVEREF(__pyx_t_23);
                          __Pyx_XGIVEREF(__pyx_t_39);
                          __Pyx_ErrRestore(__pyx_t_31, __pyx_t_23, __pyx_t_39);
                          __pyx_t_31 = 0; __pyx_t_23 = 0; __pyx_t_39 = 0; __pyx_t_18 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0;
                          __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_61;
                          goto __pyx_L676_except_error;
                        }
                        __pyx_L756:;
                      }
                      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                      goto __pyx_L675_exception_handled;
                    }
                    goto __pyx_L676_except_error;

                    /* "ws_package/controllers/activity_controller.py":2780
 * 
 *                                     # Re-check for overlaps after trimming (non-blocking: queue check + async lock)
 *                                     try:             # <<<<<<<<<<<<<<
 *                                         from ws_package.utils.db_write_queue import db_write_queue as _dwq2, WriteOperationType as _WOT2
 *                                         for _pi2 in _dwq2.get_pending_items(_WOT2.ACTIVITY_INTERVAL):
*/
                    __pyx_L676_except_error:;
                    __Pyx_XGIVEREF(__pyx_t_48);
                    __Pyx_XGIVEREF(__pyx_t_47);
                    __Pyx_XGIVEREF(__pyx_t_46);
                    __Pyx_ExceptionReset(__pyx_t_48, __pyx_t_47, __pyx_t_46);
                    goto __pyx_L640_error;
                    __pyx_L675_exception_handled:;
                    __Pyx_XGIVEREF(__pyx_t_48);
                    __Pyx_XGIVEREF(__pyx_t_47);
                    __Pyx_XGIVEREF(__pyx_t_46);
                    __Pyx_ExceptionReset(__pyx_t_48, __pyx_t_47, __pyx_t_46);
                    __pyx_L681_try_end:;
                  }

                  /* "ws_package/controllers/activity_controller.py":2824
 * 
 *                                     # If overlap found after trimming, skip creation
 *                                     if break_interval_overlaps or regular_interval_overlaps:             # <<<<<<<<<<<<<<
 *                                         self._creating_intervals.discard(interval_key)
 *                                         if break_interval_overlaps:
*/
                  if (!__pyx_cur_scope->__pyx_v_break_interval_overlaps) {
                  } else {
                    __pyx_t_8 = __pyx_cur_scope->__pyx_v_break_interval_overlaps;
                    goto __pyx_L762_bool_binop_done;
                  }
                  __pyx_t_8 = __pyx_cur_scope->__pyx_v_regular_interval_overlaps;
                  __pyx_L762_bool_binop_done:;
                  if (__pyx_t_8) {

                    /* "ws_package/controllers/activity_controller.py":2825
 *                                     # If overlap found after trimming, skip creation
 *                                     if break_interval_overlaps or regular_interval_overlaps:
 *                                         self._creating_intervals.discard(interval_key)             # <<<<<<<<<<<<<<
 *                                         if break_interval_overlaps:
 *                                             logger.info("Skipping interval creation after trim - break interval overlaps with trimmed time range %s to %s", start_date, end_date)
*/
                    __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_creating_intervals); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2825, __pyx_L640_error)
                    __Pyx_GOTREF(__pyx_t_15);
                    __pyx_t_6 = __pyx_t_15;
                    __Pyx_INCREF(__pyx_t_6);
                    __pyx_t_7 = 0;
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_cur_scope->__pyx_v_interval_key};
                      __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_discard, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2825, __pyx_L640_error)
                      __Pyx_GOTREF(__pyx_t_3);
                    }
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                    /* "ws_package/controllers/activity_controller.py":2826
 *                                     if break_interval_overlaps or regular_interval_overlaps:
 *                                         self._creating_intervals.discard(interval_key)
 *                                         if break_interval_overlaps:             # <<<<<<<<<<<<<<
 *                                             logger.info("Skipping interval creation after trim - break interval overlaps with trimmed time range %s to %s", start_date, end_date)
 *                                         if regular_interval_overlaps:
*/
                    if (__pyx_cur_scope->__pyx_v_break_interval_overlaps) {

                      /* "ws_package/controllers/activity_controller.py":2827
 *                                         self._creating_intervals.discard(interval_key)
 *                                         if break_interval_overlaps:
 *                                             logger.info("Skipping interval creation after trim - break interval overlaps with trimmed time range %s to %s", start_date, end_date)             # <<<<<<<<<<<<<<
 *                                         if regular_interval_overlaps:
 *                                             logger.info("Skipping interval creation after trim - regular interval overlaps with trimmed time range %s to %s", start_date, end_date)
*/
                      __pyx_t_15 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2827, __pyx_L640_error)
                      __Pyx_GOTREF(__pyx_t_6);
                      __pyx_t_37 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2827, __pyx_L640_error)
                      __Pyx_GOTREF(__pyx_t_37);
                      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                      __pyx_t_7 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_37))) {
                        __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_37);
                        assert(__pyx_t_15);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_37);
                        __Pyx_INCREF(__pyx_t_15);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_37, __pyx__function);
                        __pyx_t_7 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[4] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Skipping_interval_creation_after, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
                        __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_37, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                        __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2827, __pyx_L640_error)
                        __Pyx_GOTREF(__pyx_t_3);
                      }
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                      /* "ws_package/controllers/activity_controller.py":2826
 *                                     if break_interval_overlaps or regular_interval_overlaps:
 *                                         self._creating_intervals.discard(interval_key)
 *                                         if break_interval_overlaps:             # <<<<<<<<<<<<<<
 *                                             logger.info("Skipping interval creation after trim - break interval overlaps with trimmed time range %s to %s", start_date, end_date)
 *                                         if regular_interval_overlaps:
*/
                    }

                    /* "ws_package/controllers/activity_controller.py":2828
 *                                         if break_interval_overlaps:
 *                                             logger.info("Skipping interval creation after trim - break interval overlaps with trimmed time range %s to %s", start_date, end_date)
 *                                         if regular_interval_overlaps:             # <<<<<<<<<<<<<<
 *                                             logger.info("Skipping interval creation after trim - regular interval overlaps with trimmed time range %s to %s", start_date, end_date)
 *                                         continue
*/
                    if (__pyx_cur_scope->__pyx_v_regular_interval_overlaps) {

                      /* "ws_package/controllers/activity_controller.py":2829
 *                                             logger.info("Skipping interval creation after trim - break interval overlaps with trimmed time range %s to %s", start_date, end_date)
 *                                         if regular_interval_overlaps:
 *                                             logger.info("Skipping interval creation after trim - regular interval overlaps with trimmed time range %s to %s", start_date, end_date)             # <<<<<<<<<<<<<<
 *                                         continue
 *                             resolving_policy = self._apply_resolving_slot_save_policy(
*/
                      __pyx_t_37 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2829, __pyx_L640_error)
                      __Pyx_GOTREF(__pyx_t_15);
                      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2829, __pyx_L640_error)
                      __Pyx_GOTREF(__pyx_t_6);
                      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                      __pyx_t_7 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_6))) {
                        __pyx_t_37 = PyMethod_GET_SELF(__pyx_t_6);
                        assert(__pyx_t_37);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                        __Pyx_INCREF(__pyx_t_37);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                        __pyx_t_7 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[4] = {__pyx_t_37, __pyx_mstate_global->__pyx_kp_u_Skipping_interval_creation_after_2, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
                        __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2829, __pyx_L640_error)
                        __Pyx_GOTREF(__pyx_t_3);
                      }
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                      /* "ws_package/controllers/activity_controller.py":2828
 *                                         if break_interval_overlaps:
 *                                             logger.info("Skipping interval creation after trim - break interval overlaps with trimmed time range %s to %s", start_date, end_date)
 *                                         if regular_interval_overlaps:             # <<<<<<<<<<<<<<
 *                                             logger.info("Skipping interval creation after trim - regular interval overlaps with trimmed time range %s to %s", start_date, end_date)
 *                                         continue
*/
                    }

                    /* "ws_package/controllers/activity_controller.py":2830
 *                                         if regular_interval_overlaps:
 *                                             logger.info("Skipping interval creation after trim - regular interval overlaps with trimmed time range %s to %s", start_date, end_date)
 *                                         continue             # <<<<<<<<<<<<<<
 *                             resolving_policy = self._apply_resolving_slot_save_policy(
 *                                 start_date, end_date, activityLevel
*/
                    goto __pyx_L637_continue;

                    /* "ws_package/controllers/activity_controller.py":2824
 * 
 *                                     # If overlap found after trimming, skip creation
 *                                     if break_interval_overlaps or regular_interval_overlaps:             # <<<<<<<<<<<<<<
 *                                         self._creating_intervals.discard(interval_key)
 *                                         if break_interval_overlaps:
*/
                  }

                  /* "ws_package/controllers/activity_controller.py":2765
 *                                     trim_to = max(trim_to, break_stop_attr)
 *                                     self._break_stop_time = None
 *                                 if trim_to > start_date:             # <<<<<<<<<<<<<<
 *                                     self._creating_intervals.discard(interval_key)
 *                                     start_date = trim_to
*/
                }

                /* "ws_package/controllers/activity_controller.py":2748
 *                             # This handles the case where the slot was set at loop top while still on break (e.g. 17:45-17:50)
 *                             # and the user stopped the break at 17:47 during the sleep - we now trim to 17:47-17:50.
 *                             if current_break_id == 0:             # <<<<<<<<<<<<<<
 *                                 trim_to = start_date
 *                                 last_end = await self.activity_service.get_last_activity_interval()
*/
              }

              /* "ws_package/controllers/activity_controller.py":2831
 *                                             logger.info("Skipping interval creation after trim - regular interval overlaps with trimmed time range %s to %s", start_date, end_date)
 *                                         continue
 *                             resolving_policy = self._apply_resolving_slot_save_policy(             # <<<<<<<<<<<<<<
 *                                 start_date, end_date, activityLevel
 *                             )
*/
              __pyx_t_6 = __pyx_cur_scope->__pyx_v_self;
              __Pyx_INCREF(__pyx_t_6);

              /* "ws_package/controllers/activity_controller.py":2832
 *                                         continue
 *                             resolving_policy = self._apply_resolving_slot_save_policy(
 *                                 start_date, end_date, activityLevel             # <<<<<<<<<<<<<<
 *                             )
 *                             if resolving_policy is not None:
*/
              __pyx_t_7 = 0;
              {
                PyObject *__pyx_callargs[4] = {__pyx_t_6, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date, __pyx_cur_scope->__pyx_v_activityLevel};
                __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_apply_resolving_slot_save_polic, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2831, __pyx_L640_error)
                __Pyx_GOTREF(__pyx_t_3);
              }
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_resolving_policy);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_resolving_policy, __pyx_t_3);
              __Pyx_GIVEREF(__pyx_t_3);
              __pyx_t_3 = 0;

              /* "ws_package/controllers/activity_controller.py":2834
 *                                 start_date, end_date, activityLevel
 *                             )
 *                             if resolving_policy is not None:             # <<<<<<<<<<<<<<
 *                                 activityLevel, is_idle = resolving_policy
 *                             else:
*/
              __pyx_t_8 = (__pyx_cur_scope->__pyx_v_resolving_policy != Py_None);
              if (__pyx_t_8) {

                /* "ws_package/controllers/activity_controller.py":2835
 *                             )
 *                             if resolving_policy is not None:
 *                                 activityLevel, is_idle = resolving_policy             # <<<<<<<<<<<<<<
 *                             else:
 *                                 popup_is_active = self._idle_popup_active and self._idle_popup_triggered_at is not None
*/
                if ((likely(PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_resolving_policy))) || (PyList_CheckExact(__pyx_cur_scope->__pyx_v_resolving_policy))) {
                  PyObject* sequence = __pyx_cur_scope->__pyx_v_resolving_policy;
                  Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
                  if (unlikely(size != 2)) {
                    if (size > 2) __Pyx_RaiseTooManyValuesError(2);
                    else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
                    __PYX_ERR(0, 2835, __pyx_L640_error)
                  }
                  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                  if (likely(PyTuple_CheckExact(sequence))) {
                    __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
                    __Pyx_INCREF(__pyx_t_3);
                    __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1);
                    __Pyx_INCREF(__pyx_t_6);
                  } else {
                    __pyx_t_3 = __Pyx_PyList_GET_ITEM_REF(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
                    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2835, __pyx_L640_error)
                    __Pyx_XGOTREF(__pyx_t_3);
                    __pyx_t_6 = __Pyx_PyList_GET_ITEM_REF(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
                    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2835, __pyx_L640_error)
                    __Pyx_XGOTREF(__pyx_t_6);
                  }
                  #else
                  __pyx_t_3 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2835, __pyx_L640_error)
                  __Pyx_GOTREF(__pyx_t_3);
                  __pyx_t_6 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2835, __pyx_L640_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  #endif
                } else {
                  Py_ssize_t index = -1;
                  __pyx_t_37 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_resolving_policy); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2835, __pyx_L640_error)
                  __Pyx_GOTREF(__pyx_t_37);
                  __pyx_t_44 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_37);
                  index = 0; __pyx_t_3 = __pyx_t_44(__pyx_t_37); if (unlikely(!__pyx_t_3)) goto __pyx_L767_unpacking_failed;
                  __Pyx_GOTREF(__pyx_t_3);
                  index = 1; __pyx_t_6 = __pyx_t_44(__pyx_t_37); if (unlikely(!__pyx_t_6)) goto __pyx_L767_unpacking_failed;
                  __Pyx_GOTREF(__pyx_t_6);
                  if (__Pyx_IternextUnpackEndCheck(__pyx_t_44(__pyx_t_37), 2) < (0)) __PYX_ERR(0, 2835, __pyx_L640_error)
                  __pyx_t_44 = NULL;
                  __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                  goto __pyx_L768_unpacking_done;
                  __pyx_L767_unpacking_failed:;
                  __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                  __pyx_t_44 = NULL;
                  if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
                  __PYX_ERR(0, 2835, __pyx_L640_error)
                  __pyx_L768_unpacking_done:;
                }
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_activityLevel);
                __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_activityLevel, __pyx_t_3);
                __Pyx_GIVEREF(__pyx_t_3);
                __pyx_t_3 = 0;
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_is_idle);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_is_idle, __pyx_t_6);
                __Pyx_GIVEREF(__pyx_t_6);
                __pyx_t_6 = 0;

                /* "ws_package/controllers/activity_controller.py":2834
 *                                 start_date, end_date, activityLevel
 *                             )
 *                             if resolving_policy is not None:             # <<<<<<<<<<<<<<
 *                                 activityLevel, is_idle = resolving_policy
 *                             else:
*/
                goto __pyx_L766;
              }

              /* "ws_package/controllers/activity_controller.py":2837
 *                                 activityLevel, is_idle = resolving_policy
 *                             else:
 *                                 popup_is_active = self._idle_popup_active and self._idle_popup_triggered_at is not None             # <<<<<<<<<<<<<<
 *                                 has_zero_activity = await self._has_zero_activity_for_interval(start_date, end_date)
 *                                 is_idle = popup_is_active and has_zero_activity
*/
              /*else*/ {
                __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_active); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2837, __pyx_L640_error)
                __Pyx_GOTREF(__pyx_t_3);
                __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2837, __pyx_L640_error)
                if (__pyx_t_8) {
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                } else {
                  __Pyx_INCREF(__pyx_t_3);
                  __pyx_t_6 = __pyx_t_3;
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  goto __pyx_L769_bool_binop_done;
                }
                __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_triggered_at); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2837, __pyx_L640_error)
                __Pyx_GOTREF(__pyx_t_3);
                __pyx_t_8 = (__pyx_t_3 != Py_None);
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                __pyx_t_3 = __Pyx_PyBool_FromLong(__pyx_t_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2837, __pyx_L640_error)
                __Pyx_GOTREF(__pyx_t_3);
                __pyx_t_6 = __pyx_t_3;
                __pyx_t_3 = 0;
                __pyx_L769_bool_binop_done:;
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_popup_is_active);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_popup_is_active, __pyx_t_6);
                __Pyx_GIVEREF(__pyx_t_6);
                __pyx_t_6 = 0;

                /* "ws_package/controllers/activity_controller.py":2838
 *                             else:
 *                                 popup_is_active = self._idle_popup_active and self._idle_popup_triggered_at is not None
 *                                 has_zero_activity = await self._has_zero_activity_for_interval(start_date, end_date)             # <<<<<<<<<<<<<<
 *                                 is_idle = popup_is_active and has_zero_activity
 *                             logger.info("[IdleInterval] Regular interval (in range) - break_id=%s, is_break=%s, status=%s, will save as is_break=%s", current_break_id, getattr(self, 'is_break', 0), self.status, current_break_id if current_break_id else 0)
*/
                __pyx_t_3 = __pyx_cur_scope->__pyx_v_self;
                __Pyx_INCREF(__pyx_t_3);
                __pyx_t_7 = 0;
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
                  __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_has_zero_activity_for_interval, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2838, __pyx_L640_error)
                  __Pyx_GOTREF(__pyx_t_6);
                }
                __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_6, &__pyx_r);
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_11);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 51;
                  return __pyx_r;
                  __pyx_L771_resume_from_await:;
                  __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_11);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2838, __pyx_L640_error)
                  __pyx_t_6 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_6);
                } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __pyx_t_6 = __pyx_r; __pyx_r = NULL;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 2838, __pyx_L640_error)
                }
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_has_zero_activity);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_has_zero_activity, __pyx_t_6);
                __Pyx_GIVEREF(__pyx_t_6);
                __pyx_t_6 = 0;

                /* "ws_package/controllers/activity_controller.py":2839
 *                                 popup_is_active = self._idle_popup_active and self._idle_popup_triggered_at is not None
 *                                 has_zero_activity = await self._has_zero_activity_for_interval(start_date, end_date)
 *                                 is_idle = popup_is_active and has_zero_activity             # <<<<<<<<<<<<<<
 *                             logger.info("[IdleInterval] Regular interval (in range) - break_id=%s, is_break=%s, status=%s, will save as is_break=%s", current_break_id, getattr(self, 'is_break', 0), self.status, current_break_id if current_break_id else 0)
 *                             logger.info("[IdleInterval] Saving: break_id=%s, is_idle=%s", current_break_id, is_idle)
*/
                __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_popup_is_active); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2839, __pyx_L640_error)
                if (__pyx_t_8) {
                } else {
                  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_popup_is_active);
                  __pyx_t_6 = __pyx_cur_scope->__pyx_v_popup_is_active;
                  goto __pyx_L772_bool_binop_done;
                }
                __Pyx_INCREF(__pyx_cur_scope->__pyx_v_has_zero_activity);
                __pyx_t_6 = __pyx_cur_scope->__pyx_v_has_zero_activity;
                __pyx_L772_bool_binop_done:;
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_is_idle);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_is_idle, __pyx_t_6);
                __Pyx_GIVEREF(__pyx_t_6);
                __pyx_t_6 = 0;
              }
              __pyx_L766:;

              /* "ws_package/controllers/activity_controller.py":2840
 *                                 has_zero_activity = await self._has_zero_activity_for_interval(start_date, end_date)
 *                                 is_idle = popup_is_active and has_zero_activity
 *                             logger.info("[IdleInterval] Regular interval (in range) - break_id=%s, is_break=%s, status=%s, will save as is_break=%s", current_break_id, getattr(self, 'is_break', 0), self.status, current_break_id if current_break_id else 0)             # <<<<<<<<<<<<<<
 *                             logger.info("[IdleInterval] Saving: break_id=%s, is_idle=%s", current_break_id, is_idle)
 *                             logger.info("[IdleInterval] ActivityLevel: Keyboard=%s%%, Mouse=%s%%, Average=%s%%", activityLevel.get('keyboard', '0.0'), activityLevel.get('mouse', '0.0'), activityLevel.get('average', '0.0'))
*/
              __pyx_t_3 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2840, __pyx_L640_error)
              __Pyx_GOTREF(__pyx_t_37);
              __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2840, __pyx_L640_error)
              __Pyx_GOTREF(__pyx_t_15);
              __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
              __pyx_t_37 = __pyx_cur_scope->__pyx_v_self;
              __Pyx_INCREF(__pyx_t_37);
              __pyx_t_5 = __Pyx_GetAttr3(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_is_break, __pyx_mstate_global->__pyx_int_0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2840, __pyx_L640_error)
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
              __pyx_t_37 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2840, __pyx_L640_error)
              __Pyx_GOTREF(__pyx_t_37);
              __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_current_break_id); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2840, __pyx_L640_error)
              if (__pyx_t_8) {
                __Pyx_INCREF(__pyx_cur_scope->__pyx_v_current_break_id);
                __pyx_t_4 = __pyx_cur_scope->__pyx_v_current_break_id;
              } else {
                __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
                __pyx_t_4 = __pyx_mstate_global->__pyx_int_0;
              }
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_15))) {
                __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_15);
                assert(__pyx_t_3);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                __Pyx_INCREF(__pyx_t_3);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[6] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_IdleInterval_Regular_interval_i, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_t_5, __pyx_t_37, __pyx_t_4};
                __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (6-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2840, __pyx_L640_error)
                __Pyx_GOTREF(__pyx_t_6);
              }
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

              /* "ws_package/controllers/activity_controller.py":2841
 *                                 is_idle = popup_is_active and has_zero_activity
 *                             logger.info("[IdleInterval] Regular interval (in range) - break_id=%s, is_break=%s, status=%s, will save as is_break=%s", current_break_id, getattr(self, 'is_break', 0), self.status, current_break_id if current_break_id else 0)
 *                             logger.info("[IdleInterval] Saving: break_id=%s, is_idle=%s", current_break_id, is_idle)             # <<<<<<<<<<<<<<
 *                             logger.info("[IdleInterval] ActivityLevel: Keyboard=%s%%, Mouse=%s%%, Average=%s%%", activityLevel.get('keyboard', '0.0'), activityLevel.get('mouse', '0.0'), activityLevel.get('average', '0.0'))
 *                             if is_idle:
*/
              __pyx_t_15 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2841, __pyx_L640_error)
              __Pyx_GOTREF(__pyx_t_4);
              __pyx_t_37 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2841, __pyx_L640_error)
              __Pyx_GOTREF(__pyx_t_37);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_37))) {
                __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_37);
                assert(__pyx_t_15);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_37);
                __Pyx_INCREF(__pyx_t_15);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_37, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[4] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_IdleInterval_Saving_break_id_s, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_cur_scope->__pyx_v_is_idle};
                __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_37, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2841, __pyx_L640_error)
                __Pyx_GOTREF(__pyx_t_6);
              }
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

              /* "ws_package/controllers/activity_controller.py":2842
 *                             logger.info("[IdleInterval] Regular interval (in range) - break_id=%s, is_break=%s, status=%s, will save as is_break=%s", current_break_id, getattr(self, 'is_break', 0), self.status, current_break_id if current_break_id else 0)
 *                             logger.info("[IdleInterval] Saving: break_id=%s, is_idle=%s", current_break_id, is_idle)
 *                             logger.info("[IdleInterval] ActivityLevel: Keyboard=%s%%, Mouse=%s%%, Average=%s%%", activityLevel.get('keyboard', '0.0'), activityLevel.get('mouse', '0.0'), activityLevel.get('average', '0.0'))             # <<<<<<<<<<<<<<
 *                             if is_idle:
 *                                 logger.info("[IdleInterval]  Interval marked as IDLE - will NOT be sent to server until popup handled")
*/
              __pyx_t_37 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2842, __pyx_L640_error)
              __Pyx_GOTREF(__pyx_t_15);
              __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2842, __pyx_L640_error)
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activityLevel, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2842, __pyx_L640_error)
              __Pyx_GOTREF(__pyx_t_15);
              __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_mstate_global->__pyx_tuple[24], NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2842, __pyx_L640_error)
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activityLevel, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2842, __pyx_L640_error)
              __Pyx_GOTREF(__pyx_t_15);
              __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_mstate_global->__pyx_tuple[25], NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2842, __pyx_L640_error)
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activityLevel, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2842, __pyx_L640_error)
              __Pyx_GOTREF(__pyx_t_15);
              __pyx_t_33 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_mstate_global->__pyx_tuple[26], NULL); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2842, __pyx_L640_error)
              __Pyx_GOTREF(__pyx_t_33);
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_4))) {
                __pyx_t_37 = PyMethod_GET_SELF(__pyx_t_4);
                assert(__pyx_t_37);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                __Pyx_INCREF(__pyx_t_37);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[5] = {__pyx_t_37, __pyx_mstate_global->__pyx_kp_u_IdleInterval_ActivityLevel_Keyb, __pyx_t_5, __pyx_t_3, __pyx_t_33};
                __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (5-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2842, __pyx_L640_error)
                __Pyx_GOTREF(__pyx_t_6);
              }
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

              /* "ws_package/controllers/activity_controller.py":2843
 *                             logger.info("[IdleInterval] Saving: break_id=%s, is_idle=%s", current_break_id, is_idle)
 *                             logger.info("[IdleInterval] ActivityLevel: Keyboard=%s%%, Mouse=%s%%, Average=%s%%", activityLevel.get('keyboard', '0.0'), activityLevel.get('mouse', '0.0'), activityLevel.get('average', '0.0'))
 *                             if is_idle:             # <<<<<<<<<<<<<<
 *                                 logger.info("[IdleInterval]  Interval marked as IDLE - will NOT be sent to server until popup handled")
 *                             await self.activity_service.save_activity_log(activityLevel, start_date, end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)
*/
              __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_is_idle); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2843, __pyx_L640_error)
              if (__pyx_t_8) {

                /* "ws_package/controllers/activity_controller.py":2844
 *                             logger.info("[IdleInterval] ActivityLevel: Keyboard=%s%%, Mouse=%s%%, Average=%s%%", activityLevel.get('keyboard', '0.0'), activityLevel.get('mouse', '0.0'), activityLevel.get('average', '0.0'))
 *                             if is_idle:
 *                                 logger.info("[IdleInterval]  Interval marked as IDLE - will NOT be sent to server until popup handled")             # <<<<<<<<<<<<<<
 *                             await self.activity_service.save_activity_log(activityLevel, start_date, end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)
 *                             self.has_on_demand = False
*/
                __pyx_t_4 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2844, __pyx_L640_error)
                __Pyx_GOTREF(__pyx_t_33);
                __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2844, __pyx_L640_error)
                __Pyx_GOTREF(__pyx_t_3);
                __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_3))) {
                  __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
                  assert(__pyx_t_4);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
                  __Pyx_INCREF(__pyx_t_4);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_IdleInterval_Interval_marked_as};
                  __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2844, __pyx_L640_error)
                  __Pyx_GOTREF(__pyx_t_6);
                }
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

                /* "ws_package/controllers/activity_controller.py":2843
 *                             logger.info("[IdleInterval] Saving: break_id=%s, is_idle=%s", current_break_id, is_idle)
 *                             logger.info("[IdleInterval] ActivityLevel: Keyboard=%s%%, Mouse=%s%%, Average=%s%%", activityLevel.get('keyboard', '0.0'), activityLevel.get('mouse', '0.0'), activityLevel.get('average', '0.0'))
 *                             if is_idle:             # <<<<<<<<<<<<<<
 *                                 logger.info("[IdleInterval]  Interval marked as IDLE - will NOT be sent to server until popup handled")
 *                             await self.activity_service.save_activity_log(activityLevel, start_date, end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)
*/
              }

              /* "ws_package/controllers/activity_controller.py":2845
 *                             if is_idle:
 *                                 logger.info("[IdleInterval]  Interval marked as IDLE - will NOT be sent to server until popup handled")
 *                             await self.activity_service.save_activity_log(activityLevel, start_date, end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)             # <<<<<<<<<<<<<<
 *                             self.has_on_demand = False
 *                         finally:
*/
              __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2845, __pyx_L640_error)
              __Pyx_GOTREF(__pyx_t_4);
              __pyx_t_3 = __pyx_t_4;
              __Pyx_INCREF(__pyx_t_3);
              __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2845, __pyx_L640_error)
              __Pyx_GOTREF(__pyx_t_33);
              __pyx_t_5 = __Pyx_PyLong_AddObjC(__pyx_t_33, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2845, __pyx_L640_error)
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              __pyx_t_37 = __pyx_cur_scope->__pyx_v_self;
              __Pyx_INCREF(__pyx_t_37);
              __pyx_t_7 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_37, NULL};
                __pyx_t_33 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_today_weekday, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2845, __pyx_L640_error)
                __Pyx_GOTREF(__pyx_t_33);
              }
              __pyx_t_37 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_has_on_demand); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2845, __pyx_L640_error)
              __Pyx_GOTREF(__pyx_t_37);
              __pyx_t_7 = 0;
              {
                PyObject *__pyx_callargs[6 + ((CYTHON_VECTORCALL) ? 3 : 0)] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_activityLevel, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date, __pyx_t_5, __pyx_t_33};
                __pyx_t_15 = __Pyx_MakeVectorcallBuilderKwds(3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2845, __pyx_L640_error)
                __Pyx_GOTREF(__pyx_t_15);
                if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_break_id, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_t_15, __pyx_callargs+6, 0) < (0)) __PYX_ERR(0, 2845, __pyx_L640_error)
                if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_is_idle, __pyx_cur_scope->__pyx_v_is_idle, __pyx_t_15, __pyx_callargs+6, 1) < (0)) __PYX_ERR(0, 2845, __pyx_L640_error)
                if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_has_on_demand_screenshot, __pyx_t_37, __pyx_t_15, __pyx_callargs+6, 2) < (0)) __PYX_ERR(0, 2845, __pyx_L640_error)
                __pyx_t_6 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_save_activity_log, __pyx_callargs+__pyx_t_7, (6-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_15);
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2845, __pyx_L640_error)
                __Pyx_GOTREF(__pyx_t_6);
              }
              __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_6, &__pyx_r);
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_XGIVEREF(__pyx_t_11);
                __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                __Pyx_XGIVEREF(__pyx_t_12);
                __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                __Pyx_XGIVEREF(__pyx_t_13);
                __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                __Pyx_XGIVEREF(__pyx_r);
                __Pyx_RefNannyFinishContext();
                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                /* return from generator, awaiting value */
                __pyx_generator->resume_label = 52;
                return __pyx_r;
                __pyx_L775_resume_from_await:;
                __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                __pyx_cur_scope->__pyx_t_0 = 0;
                __Pyx_XGOTREF(__pyx_t_11);
                __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                __pyx_cur_scope->__pyx_t_1 = 0;
                __Pyx_XGOTREF(__pyx_t_12);
                __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                __pyx_cur_scope->__pyx_t_2 = 0;
                __Pyx_XGOTREF(__pyx_t_13);
                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2845, __pyx_L640_error)
              } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_DECREF(__pyx_r); __pyx_r = 0;
              } else {
                __Pyx_XGOTREF(__pyx_r);
                __PYX_ERR(0, 2845, __pyx_L640_error)
              }

              /* "ws_package/controllers/activity_controller.py":2846
 *                                 logger.info("[IdleInterval]  Interval marked as IDLE - will NOT be sent to server until popup handled")
 *                             await self.activity_service.save_activity_log(activityLevel, start_date, end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)
 *                             self.has_on_demand = False             # <<<<<<<<<<<<<<
 *                         finally:
 *                             # Remove from set after a delay to allow database write to complete
*/
              if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_has_on_demand, Py_False) < (0)) __PYX_ERR(0, 2846, __pyx_L640_error)
            }

            /* "ws_package/controllers/activity_controller.py":2849
 *                         finally:
 *                             # Remove from set after a delay to allow database write to complete
 *                             async def remove_after_delay():             # <<<<<<<<<<<<<<
 *                                 await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                                 self._creating_intervals.discard(interval_key)
*/
            /*finally:*/ {
              /*normal exit:*/{
                __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_28remove_after_delay, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController___start_devic_4, ((PyObject*)__pyx_cur_scope), __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[30])); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2849, __pyx_L263_error)
                __Pyx_GOTREF(__pyx_t_6);
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_remove_after_delay);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_remove_after_delay, __pyx_t_6);
                __Pyx_GIVEREF(__pyx_t_6);
                __pyx_t_6 = 0;

                /* "ws_package/controllers/activity_controller.py":2861
 *                                 else:
 *                                     logger.debug("[IdleDetection] No idle detected after interval save")
 *                             asyncio.create_task(remove_after_delay())             # <<<<<<<<<<<<<<
 *                     else:
 *                         # Remove from set immediately if we're not creating the interval
*/
                __pyx_t_4 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2861, __pyx_L263_error)
                __Pyx_GOTREF(__pyx_t_15);
                __pyx_t_37 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_create_task); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2861, __pyx_L263_error)
                __Pyx_GOTREF(__pyx_t_37);
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                __pyx_t_15 = __Pyx_PyObject_CallNoArg(__pyx_cur_scope->__pyx_v_remove_after_delay); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2861, __pyx_L263_error)
                __Pyx_GOTREF(__pyx_t_15);
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_37))) {
                  __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_37);
                  assert(__pyx_t_4);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_37);
                  __Pyx_INCREF(__pyx_t_4);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_37, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_15};
                  __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_37, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2861, __pyx_L263_error)
                  __Pyx_GOTREF(__pyx_t_6);
                }
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                goto __pyx_L641;
              }
              __pyx_L640_error:;
              /*exception exit:*/{
                __Pyx_PyThreadState_assign
                __pyx_t_46 = 0; __pyx_t_47 = 0; __pyx_t_48 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_18 = 0;
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                 __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_21, &__pyx_t_18);
                if ( unlikely(__Pyx_GetException(&__pyx_t_46, &__pyx_t_47, &__pyx_t_48) < 0)) __Pyx_ErrFetch(&__pyx_t_46, &__pyx_t_47, &__pyx_t_48);
                __Pyx_XGOTREF(__pyx_t_46);
                __Pyx_XGOTREF(__pyx_t_47);
                __Pyx_XGOTREF(__pyx_t_48);
                __Pyx_XGOTREF(__pyx_t_20);
                __Pyx_XGOTREF(__pyx_t_21);
                __Pyx_XGOTREF(__pyx_t_18);
                __pyx_t_14 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_62 = __pyx_filename;
                {

                  /* "ws_package/controllers/activity_controller.py":2849
 *                         finally:
 *                             # Remove from set after a delay to allow database write to complete
 *                             async def remove_after_delay():             # <<<<<<<<<<<<<<
 *                                 await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                                 self._creating_intervals.discard(interval_key)
*/
                  __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_25remove_after_delay, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController___start_devic_4, ((PyObject*)__pyx_cur_scope), __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[31])); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2849, __pyx_L779_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_remove_after_delay);
                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_remove_after_delay, __pyx_t_6);
                  __Pyx_GIVEREF(__pyx_t_6);
                  __pyx_t_6 = 0;

                  /* "ws_package/controllers/activity_controller.py":2861
 *                                 else:
 *                                     logger.debug("[IdleDetection] No idle detected after interval save")
 *                             asyncio.create_task(remove_after_delay())             # <<<<<<<<<<<<<<
 *                     else:
 *                         # Remove from set immediately if we're not creating the interval
*/
                  __pyx_t_37 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2861, __pyx_L779_error)
                  __Pyx_GOTREF(__pyx_t_15);
                  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_create_task); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2861, __pyx_L779_error)
                  __Pyx_GOTREF(__pyx_t_4);
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __pyx_t_15 = __Pyx_PyObject_CallNoArg(__pyx_cur_scope->__pyx_v_remove_after_delay); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2861, __pyx_L779_error)
                  __Pyx_GOTREF(__pyx_t_15);
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_4))) {
                    __pyx_t_37 = PyMethod_GET_SELF(__pyx_t_4);
                    assert(__pyx_t_37);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                    __Pyx_INCREF(__pyx_t_37);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_37, __pyx_t_15};
                    __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2861, __pyx_L779_error)
                    __Pyx_GOTREF(__pyx_t_6);
                  }
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                }
                __Pyx_XGIVEREF(__pyx_t_20);
                __Pyx_XGIVEREF(__pyx_t_21);
                __Pyx_XGIVEREF(__pyx_t_18);
                __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_18);
                __Pyx_XGIVEREF(__pyx_t_46);
                __Pyx_XGIVEREF(__pyx_t_47);
                __Pyx_XGIVEREF(__pyx_t_48);
                __Pyx_ErrRestore(__pyx_t_46, __pyx_t_47, __pyx_t_48);
                __pyx_t_46 = 0; __pyx_t_47 = 0; __pyx_t_48 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_18 = 0;
                __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_62;
                goto __pyx_L263_error;
                __pyx_L779_error:;
                __Pyx_XGIVEREF(__pyx_t_20);
                __Pyx_XGIVEREF(__pyx_t_21);
                __Pyx_XGIVEREF(__pyx_t_18);
                __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_18);
                __Pyx_XDECREF(__pyx_t_46); __pyx_t_46 = 0;
                __Pyx_XDECREF(__pyx_t_47); __pyx_t_47 = 0;
                __Pyx_XDECREF(__pyx_t_48); __pyx_t_48 = 0;
                __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_18 = 0;
                goto __pyx_L263_error;
              }
              __pyx_L637_continue: {

                /* "ws_package/controllers/activity_controller.py":2849
 *                         finally:
 *                             # Remove from set after a delay to allow database write to complete
 *                             async def remove_after_delay():             # <<<<<<<<<<<<<<
 *                                 await asyncio.sleep(2)  # Wait 2 seconds for DB write
 *                                 self._creating_intervals.discard(interval_key)
*/
                __pyx_t_6 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_28remove_after_delay, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController___start_devic_4, ((PyObject*)__pyx_cur_scope), __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[30])); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2849, __pyx_L263_error)
                __Pyx_GOTREF(__pyx_t_6);
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_remove_after_delay);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_remove_after_delay, __pyx_t_6);
                __Pyx_GIVEREF(__pyx_t_6);
                __pyx_t_6 = 0;

                /* "ws_package/controllers/activity_controller.py":2861
 *                                 else:
 *                                     logger.debug("[IdleDetection] No idle detected after interval save")
 *                             asyncio.create_task(remove_after_delay())             # <<<<<<<<<<<<<<
 *                     else:
 *                         # Remove from set immediately if we're not creating the interval
*/
                __pyx_t_4 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2861, __pyx_L263_error)
                __Pyx_GOTREF(__pyx_t_15);
                __pyx_t_37 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_create_task); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2861, __pyx_L263_error)
                __Pyx_GOTREF(__pyx_t_37);
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                __pyx_t_15 = __Pyx_PyObject_CallNoArg(__pyx_cur_scope->__pyx_v_remove_after_delay); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2861, __pyx_L263_error)
                __Pyx_GOTREF(__pyx_t_15);
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_37))) {
                  __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_37);
                  assert(__pyx_t_4);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_37);
                  __Pyx_INCREF(__pyx_t_4);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_37, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_15};
                  __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_37, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2861, __pyx_L263_error)
                  __Pyx_GOTREF(__pyx_t_6);
                }
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                goto __pyx_L269_try_continue;
              }
              __pyx_L641:;
            }

            /* "ws_package/controllers/activity_controller.py":2743
 *                         # If check fails, proceed with creation (better to have duplicate than miss interval)
 * 
 *                     if not interval_exists and not break_interval_overlaps and not regular_interval_overlaps:             # <<<<<<<<<<<<<<
 *                         try:
 *                             # Trim interval start to break stop / last interval end right before save when not on break.
*/
            goto __pyx_L633;
          }

          /* "ws_package/controllers/activity_controller.py":2864
 *                     else:
 *                         # Remove from set immediately if we're not creating the interval
 *                         self._creating_intervals.discard(interval_key)             # <<<<<<<<<<<<<<
 *                         if interval_exists:
 *                             if await self._refresh_resolving_slot_if_exists(start_date, end_date):
*/
          /*else*/ {
            __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_creating_intervals); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2864, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_15);
            __pyx_t_37 = __pyx_t_15;
            __Pyx_INCREF(__pyx_t_37);
            __pyx_t_7 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_37, __pyx_cur_scope->__pyx_v_interval_key};
              __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_discard, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2864, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_6);
            }
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

            /* "ws_package/controllers/activity_controller.py":2865
 *                         # Remove from set immediately if we're not creating the interval
 *                         self._creating_intervals.discard(interval_key)
 *                         if interval_exists:             # <<<<<<<<<<<<<<
 *                             if await self._refresh_resolving_slot_if_exists(start_date, end_date):
 *                                 logger.info(
*/
            if (__pyx_cur_scope->__pyx_v_interval_exists) {

              /* "ws_package/controllers/activity_controller.py":2866
 *                         self._creating_intervals.discard(interval_key)
 *                         if interval_exists:
 *                             if await self._refresh_resolving_slot_if_exists(start_date, end_date):             # <<<<<<<<<<<<<<
 *                                 logger.info(
 *                                     "Resolving slot %s to %s already exists  refreshed activity (not idle)",
*/
              __pyx_t_15 = __pyx_cur_scope->__pyx_v_self;
              __Pyx_INCREF(__pyx_t_15);
              __pyx_t_7 = 0;
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_15, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
                __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_refresh_resolving_slot_if_exist, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2866, __pyx_L263_error)
                __Pyx_GOTREF(__pyx_t_6);
              }
              __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_6, &__pyx_r);
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_XGIVEREF(__pyx_t_11);
                __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                __Pyx_XGIVEREF(__pyx_t_12);
                __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                __Pyx_XGIVEREF(__pyx_t_13);
                __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                __Pyx_XGIVEREF(__pyx_r);
                __Pyx_RefNannyFinishContext();
                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                /* return from generator, awaiting value */
                __pyx_generator->resume_label = 53;
                return __pyx_r;
                __pyx_L782_resume_from_await:;
                __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                __pyx_cur_scope->__pyx_t_0 = 0;
                __Pyx_XGOTREF(__pyx_t_11);
                __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                __pyx_cur_scope->__pyx_t_1 = 0;
                __Pyx_XGOTREF(__pyx_t_12);
                __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                __pyx_cur_scope->__pyx_t_2 = 0;
                __Pyx_XGOTREF(__pyx_t_13);
                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2866, __pyx_L263_error)
                __pyx_t_6 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_6);
              } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                __Pyx_GOTREF(__pyx_r);
                __pyx_t_6 = __pyx_r; __pyx_r = NULL;
              } else {
                __Pyx_XGOTREF(__pyx_r);
                __PYX_ERR(0, 2866, __pyx_L263_error)
              }
              __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2866, __pyx_L263_error)
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              if (__pyx_t_8) {

                /* "ws_package/controllers/activity_controller.py":2867
 *                         if interval_exists:
 *                             if await self._refresh_resolving_slot_if_exists(start_date, end_date):
 *                                 logger.info(             # <<<<<<<<<<<<<<
 *                                     "Resolving slot %s to %s already exists  refreshed activity (not idle)",
 *                                     start_date,
*/
                __pyx_t_15 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2867, __pyx_L263_error)
                __Pyx_GOTREF(__pyx_t_37);
                __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2867, __pyx_L263_error)
                __Pyx_GOTREF(__pyx_t_4);
                __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;

                /* "ws_package/controllers/activity_controller.py":2870
 *                                     "Resolving slot %s to %s already exists  refreshed activity (not idle)",
 *                                     start_date,
 *                                     end_date,             # <<<<<<<<<<<<<<
 *                                 )
 *                             else:
*/
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_4))) {
                  __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_4);
                  assert(__pyx_t_15);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                  __Pyx_INCREF(__pyx_t_15);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[4] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Resolving_slot_s_to_s_already_ex, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
                  __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2867, __pyx_L263_error)
                  __Pyx_GOTREF(__pyx_t_6);
                }
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

                /* "ws_package/controllers/activity_controller.py":2866
 *                         self._creating_intervals.discard(interval_key)
 *                         if interval_exists:
 *                             if await self._refresh_resolving_slot_if_exists(start_date, end_date):             # <<<<<<<<<<<<<<
 *                                 logger.info(
 *                                     "Resolving slot %s to %s already exists  refreshed activity (not idle)",
*/
                goto __pyx_L781;
              }

              /* "ws_package/controllers/activity_controller.py":2873
 *                                 )
 *                             else:
 *                                 logger.info("Skipping duplicate interval creation for %s to %s (counter=%s)", start_date, end_date, self.last_count + 1)             # <<<<<<<<<<<<<<
 *                         if break_interval_overlaps:
 *                             logger.info("Skipping regular interval creation - break interval exists for time range %s to %s", start_date, end_date)
*/
              /*else*/ {
                __pyx_t_4 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2873, __pyx_L263_error)
                __Pyx_GOTREF(__pyx_t_15);
                __pyx_t_37 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2873, __pyx_L263_error)
                __Pyx_GOTREF(__pyx_t_37);
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2873, __pyx_L263_error)
                __Pyx_GOTREF(__pyx_t_15);
                __pyx_t_33 = __Pyx_PyLong_AddObjC(__pyx_t_15, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2873, __pyx_L263_error)
                __Pyx_GOTREF(__pyx_t_33);
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_37))) {
                  __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_37);
                  assert(__pyx_t_4);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_37);
                  __Pyx_INCREF(__pyx_t_4);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_37, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[5] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Skipping_duplicate_interval_crea, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date, __pyx_t_33};
                  __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_37, __pyx_callargs+__pyx_t_7, (5-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                  __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2873, __pyx_L263_error)
                  __Pyx_GOTREF(__pyx_t_6);
                }
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              }
              __pyx_L781:;

              /* "ws_package/controllers/activity_controller.py":2865
 *                         # Remove from set immediately if we're not creating the interval
 *                         self._creating_intervals.discard(interval_key)
 *                         if interval_exists:             # <<<<<<<<<<<<<<
 *                             if await self._refresh_resolving_slot_if_exists(start_date, end_date):
 *                                 logger.info(
*/
            }

            /* "ws_package/controllers/activity_controller.py":2874
 *                             else:
 *                                 logger.info("Skipping duplicate interval creation for %s to %s (counter=%s)", start_date, end_date, self.last_count + 1)
 *                         if break_interval_overlaps:             # <<<<<<<<<<<<<<
 *                             logger.info("Skipping regular interval creation - break interval exists for time range %s to %s", start_date, end_date)
 *                         if regular_interval_overlaps:
*/
            if (__pyx_cur_scope->__pyx_v_break_interval_overlaps) {

              /* "ws_package/controllers/activity_controller.py":2875
 *                                 logger.info("Skipping duplicate interval creation for %s to %s (counter=%s)", start_date, end_date, self.last_count + 1)
 *                         if break_interval_overlaps:
 *                             logger.info("Skipping regular interval creation - break interval exists for time range %s to %s", start_date, end_date)             # <<<<<<<<<<<<<<
 *                         if regular_interval_overlaps:
 *                             logger.info("Skipping regular interval creation - overlapping regular interval exists for time range %s to %s", start_date, end_date)
*/
              __pyx_t_37 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2875, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_33);
              __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2875, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_4))) {
                __pyx_t_37 = PyMethod_GET_SELF(__pyx_t_4);
                assert(__pyx_t_37);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                __Pyx_INCREF(__pyx_t_37);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[4] = {__pyx_t_37, __pyx_mstate_global->__pyx_kp_u_Skipping_regular_interval_creati, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
                __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2875, __pyx_L263_error)
                __Pyx_GOTREF(__pyx_t_6);
              }
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

              /* "ws_package/controllers/activity_controller.py":2874
 *                             else:
 *                                 logger.info("Skipping duplicate interval creation for %s to %s (counter=%s)", start_date, end_date, self.last_count + 1)
 *                         if break_interval_overlaps:             # <<<<<<<<<<<<<<
 *                             logger.info("Skipping regular interval creation - break interval exists for time range %s to %s", start_date, end_date)
 *                         if regular_interval_overlaps:
*/
            }

            /* "ws_package/controllers/activity_controller.py":2876
 *                         if break_interval_overlaps:
 *                             logger.info("Skipping regular interval creation - break interval exists for time range %s to %s", start_date, end_date)
 *                         if regular_interval_overlaps:             # <<<<<<<<<<<<<<
 *                             logger.info("Skipping regular interval creation - overlapping regular interval exists for time range %s to %s", start_date, end_date)
 *                 else:
*/
            if (__pyx_cur_scope->__pyx_v_regular_interval_overlaps) {

              /* "ws_package/controllers/activity_controller.py":2877
 *                             logger.info("Skipping regular interval creation - break interval exists for time range %s to %s", start_date, end_date)
 *                         if regular_interval_overlaps:
 *                             logger.info("Skipping regular interval creation - overlapping regular interval exists for time range %s to %s", start_date, end_date)             # <<<<<<<<<<<<<<
 *                 else:
 *                     resolving_policy = self._apply_resolving_slot_save_policy(
*/
              __pyx_t_4 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2877, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_37);
              __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2877, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_33);
              __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_33))) {
                __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_33);
                assert(__pyx_t_4);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
                __Pyx_INCREF(__pyx_t_4);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[4] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Skipping_regular_interval_creati_2, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
                __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2877, __pyx_L263_error)
                __Pyx_GOTREF(__pyx_t_6);
              }
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

              /* "ws_package/controllers/activity_controller.py":2876
 *                         if break_interval_overlaps:
 *                             logger.info("Skipping regular interval creation - break interval exists for time range %s to %s", start_date, end_date)
 *                         if regular_interval_overlaps:             # <<<<<<<<<<<<<<
 *                             logger.info("Skipping regular interval creation - overlapping regular interval exists for time range %s to %s", start_date, end_date)
 *                 else:
*/
            }
          }
          __pyx_L633:;

          /* "ws_package/controllers/activity_controller.py":2659
 *                             self._creating_intervals.discard(interval_key)
 *                         asyncio.create_task(remove_after_delay())
 *                 elif in_range and self.status == True:             # <<<<<<<<<<<<<<
 *                     # CRITICAL FIX: Check if interval already exists before saving to prevent duplicates
 *                     # This prevents the same interval from being created multiple times when the loop runs
*/
          goto __pyx_L499;
        }

        /* "ws_package/controllers/activity_controller.py":2879
 *                             logger.info("Skipping regular interval creation - overlapping regular interval exists for time range %s to %s", start_date, end_date)
 *                 else:
 *                     resolving_policy = self._apply_resolving_slot_save_policy(             # <<<<<<<<<<<<<<
 *                         start_date, end_date, activityLevel
 *                     )
*/
        /*else*/ {
          __pyx_t_33 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_33);

          /* "ws_package/controllers/activity_controller.py":2880
 *                 else:
 *                     resolving_policy = self._apply_resolving_slot_save_policy(
 *                         start_date, end_date, activityLevel             # <<<<<<<<<<<<<<
 *                     )
 *                     if resolving_policy is not None:
*/
          __pyx_t_7 = 0;
          {
            PyObject *__pyx_callargs[4] = {__pyx_t_33, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date, __pyx_cur_scope->__pyx_v_activityLevel};
            __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_apply_resolving_slot_save_polic, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
            if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2879, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_6);
          }
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_resolving_policy);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_resolving_policy, __pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_6);
          __pyx_t_6 = 0;

          /* "ws_package/controllers/activity_controller.py":2882
 *                         start_date, end_date, activityLevel
 *                     )
 *                     if resolving_policy is not None:             # <<<<<<<<<<<<<<
 *                         activityLevel, is_idle = resolving_policy
 *                     else:
*/
          __pyx_t_8 = (__pyx_cur_scope->__pyx_v_resolving_policy != Py_None);
          if (__pyx_t_8) {

            /* "ws_package/controllers/activity_controller.py":2883
 *                     )
 *                     if resolving_policy is not None:
 *                         activityLevel, is_idle = resolving_policy             # <<<<<<<<<<<<<<
 *                     else:
 *                         popup_is_active = self._idle_popup_active and self._idle_popup_triggered_at is not None
*/
            if ((likely(PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_resolving_policy))) || (PyList_CheckExact(__pyx_cur_scope->__pyx_v_resolving_policy))) {
              PyObject* sequence = __pyx_cur_scope->__pyx_v_resolving_policy;
              Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
              if (unlikely(size != 2)) {
                if (size > 2) __Pyx_RaiseTooManyValuesError(2);
                else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
                __PYX_ERR(0, 2883, __pyx_L263_error)
              }
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              if (likely(PyTuple_CheckExact(sequence))) {
                __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0);
                __Pyx_INCREF(__pyx_t_6);
                __pyx_t_33 = PyTuple_GET_ITEM(sequence, 1);
                __Pyx_INCREF(__pyx_t_33);
              } else {
                __pyx_t_6 = __Pyx_PyList_GET_ITEM_REF(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
                if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2883, __pyx_L263_error)
                __Pyx_XGOTREF(__pyx_t_6);
                __pyx_t_33 = __Pyx_PyList_GET_ITEM_REF(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
                if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2883, __pyx_L263_error)
                __Pyx_XGOTREF(__pyx_t_33);
              }
              #else
              __pyx_t_6 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2883, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_6);
              __pyx_t_33 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2883, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_33);
              #endif
            } else {
              Py_ssize_t index = -1;
              __pyx_t_4 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_resolving_policy); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2883, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_4);
              __pyx_t_44 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_4);
              index = 0; __pyx_t_6 = __pyx_t_44(__pyx_t_4); if (unlikely(!__pyx_t_6)) goto __pyx_L786_unpacking_failed;
              __Pyx_GOTREF(__pyx_t_6);
              index = 1; __pyx_t_33 = __pyx_t_44(__pyx_t_4); if (unlikely(!__pyx_t_33)) goto __pyx_L786_unpacking_failed;
              __Pyx_GOTREF(__pyx_t_33);
              if (__Pyx_IternextUnpackEndCheck(__pyx_t_44(__pyx_t_4), 2) < (0)) __PYX_ERR(0, 2883, __pyx_L263_error)
              __pyx_t_44 = NULL;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              goto __pyx_L787_unpacking_done;
              __pyx_L786_unpacking_failed:;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __pyx_t_44 = NULL;
              if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
              __PYX_ERR(0, 2883, __pyx_L263_error)
              __pyx_L787_unpacking_done:;
            }
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_activityLevel);
            __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_activityLevel, __pyx_t_6);
            __Pyx_GIVEREF(__pyx_t_6);
            __pyx_t_6 = 0;
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_is_idle);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_is_idle, __pyx_t_33);
            __Pyx_GIVEREF(__pyx_t_33);
            __pyx_t_33 = 0;

            /* "ws_package/controllers/activity_controller.py":2882
 *                         start_date, end_date, activityLevel
 *                     )
 *                     if resolving_policy is not None:             # <<<<<<<<<<<<<<
 *                         activityLevel, is_idle = resolving_policy
 *                     else:
*/
            goto __pyx_L785;
          }

          /* "ws_package/controllers/activity_controller.py":2885
 *                         activityLevel, is_idle = resolving_policy
 *                     else:
 *                         popup_is_active = self._idle_popup_active and self._idle_popup_triggered_at is not None             # <<<<<<<<<<<<<<
 *                         has_zero_activity = await self._has_zero_activity_for_interval(start_date, end_date)
 *                         is_idle = popup_is_active and has_zero_activity
*/
          /*else*/ {
            __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_active); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2885, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2885, __pyx_L263_error)
            if (__pyx_t_8) {
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            } else {
              __Pyx_INCREF(__pyx_t_6);
              __pyx_t_33 = __pyx_t_6;
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              goto __pyx_L788_bool_binop_done;
            }
            __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_triggered_at); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2885, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_8 = (__pyx_t_6 != Py_None);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2885, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_33 = __pyx_t_6;
            __pyx_t_6 = 0;
            __pyx_L788_bool_binop_done:;
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_popup_is_active);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_popup_is_active, __pyx_t_33);
            __Pyx_GIVEREF(__pyx_t_33);
            __pyx_t_33 = 0;

            /* "ws_package/controllers/activity_controller.py":2886
 *                     else:
 *                         popup_is_active = self._idle_popup_active and self._idle_popup_triggered_at is not None
 *                         has_zero_activity = await self._has_zero_activity_for_interval(start_date, end_date)             # <<<<<<<<<<<<<<
 *                         is_idle = popup_is_active and has_zero_activity
 *                     logger.info("[IdleInterval] Regular interval (out of range) - break_id=%s, is_break=%s, status=%s, will save as is_break=%s", current_break_id, getattr(self, 'is_break', 0), self.status, current_break_id if current_break_id else 0)
*/
            __pyx_t_6 = __pyx_cur_scope->__pyx_v_self;
            __Pyx_INCREF(__pyx_t_6);
            __pyx_t_7 = 0;
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
              __pyx_t_33 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_has_zero_activity_for_interval, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2886, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_33);
            }
            __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_33, &__pyx_r);
            __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
            if (likely(__pyx_t_26 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_11);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
              __Pyx_XGIVEREF(__pyx_t_12);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
              __Pyx_XGIVEREF(__pyx_t_13);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 54;
              return __pyx_r;
              __pyx_L790_resume_from_await:;
              __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_11);
              __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_12);
              __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_13);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2886, __pyx_L263_error)
              __pyx_t_33 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_33);
            } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __pyx_t_33 = __pyx_r; __pyx_r = NULL;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 2886, __pyx_L263_error)
            }
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_has_zero_activity);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_has_zero_activity, __pyx_t_33);
            __Pyx_GIVEREF(__pyx_t_33);
            __pyx_t_33 = 0;

            /* "ws_package/controllers/activity_controller.py":2887
 *                         popup_is_active = self._idle_popup_active and self._idle_popup_triggered_at is not None
 *                         has_zero_activity = await self._has_zero_activity_for_interval(start_date, end_date)
 *                         is_idle = popup_is_active and has_zero_activity             # <<<<<<<<<<<<<<
 *                     logger.info("[IdleInterval] Regular interval (out of range) - break_id=%s, is_break=%s, status=%s, will save as is_break=%s", current_break_id, getattr(self, 'is_break', 0), self.status, current_break_id if current_break_id else 0)
 *                     logger.info("[IdleInterval] Saving: is_uploaded=True, break_id=%s, is_idle=%s", current_break_id, is_idle)
*/
            __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_popup_is_active); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2887, __pyx_L263_error)
            if (__pyx_t_8) {
            } else {
              __Pyx_INCREF(__pyx_cur_scope->__pyx_v_popup_is_active);
              __pyx_t_33 = __pyx_cur_scope->__pyx_v_popup_is_active;
              goto __pyx_L791_bool_binop_done;
            }
            __Pyx_INCREF(__pyx_cur_scope->__pyx_v_has_zero_activity);
            __pyx_t_33 = __pyx_cur_scope->__pyx_v_has_zero_activity;
            __pyx_L791_bool_binop_done:;
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_is_idle);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_is_idle, __pyx_t_33);
            __Pyx_GIVEREF(__pyx_t_33);
            __pyx_t_33 = 0;
          }
          __pyx_L785:;

          /* "ws_package/controllers/activity_controller.py":2888
 *                         has_zero_activity = await self._has_zero_activity_for_interval(start_date, end_date)
 *                         is_idle = popup_is_active and has_zero_activity
 *                     logger.info("[IdleInterval] Regular interval (out of range) - break_id=%s, is_break=%s, status=%s, will save as is_break=%s", current_break_id, getattr(self, 'is_break', 0), self.status, current_break_id if current_break_id else 0)             # <<<<<<<<<<<<<<
 *                     logger.info("[IdleInterval] Saving: is_uploaded=True, break_id=%s, is_idle=%s", current_break_id, is_idle)
 *                     logger.info("[IdleInterval] ActivityLevel: Keyboard=%s%%, Mouse=%s%%, Average=%s%%", activityLevel.get('keyboard', '0.0'), activityLevel.get('mouse', '0.0'), activityLevel.get('average', '0.0'))
*/
          __pyx_t_6 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2888, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_37 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2888, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_37);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_4 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_4);
          __pyx_t_15 = __Pyx_GetAttr3(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_is_break, __pyx_mstate_global->__pyx_int_0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2888, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2888, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_current_break_id); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2888, __pyx_L263_error)
          if (__pyx_t_8) {
            __Pyx_INCREF(__pyx_cur_scope->__pyx_v_current_break_id);
            __pyx_t_5 = __pyx_cur_scope->__pyx_v_current_break_id;
          } else {
            __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
            __pyx_t_5 = __pyx_mstate_global->__pyx_int_0;
          }
          __pyx_t_7 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_37))) {
            __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_37);
            assert(__pyx_t_6);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_37);
            __Pyx_INCREF(__pyx_t_6);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_37, __pyx__function);
            __pyx_t_7 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[6] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_IdleInterval_Regular_interval_o, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_t_15, __pyx_t_4, __pyx_t_5};
            __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_37, __pyx_callargs+__pyx_t_7, (6-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
            if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2888, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_33);
          }
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

          /* "ws_package/controllers/activity_controller.py":2889
 *                         is_idle = popup_is_active and has_zero_activity
 *                     logger.info("[IdleInterval] Regular interval (out of range) - break_id=%s, is_break=%s, status=%s, will save as is_break=%s", current_break_id, getattr(self, 'is_break', 0), self.status, current_break_id if current_break_id else 0)
 *                     logger.info("[IdleInterval] Saving: is_uploaded=True, break_id=%s, is_idle=%s", current_break_id, is_idle)             # <<<<<<<<<<<<<<
 *                     logger.info("[IdleInterval] ActivityLevel: Keyboard=%s%%, Mouse=%s%%, Average=%s%%", activityLevel.get('keyboard', '0.0'), activityLevel.get('mouse', '0.0'), activityLevel.get('average', '0.0'))
 *                     if is_idle:
*/
          __pyx_t_37 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2889, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2889, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_7 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_4))) {
            __pyx_t_37 = PyMethod_GET_SELF(__pyx_t_4);
            assert(__pyx_t_37);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_37);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
            __pyx_t_7 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[4] = {__pyx_t_37, __pyx_mstate_global->__pyx_kp_u_IdleInterval_Saving_is_uploaded, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_cur_scope->__pyx_v_is_idle};
            __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2889, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_33);
          }
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

          /* "ws_package/controllers/activity_controller.py":2890
 *                     logger.info("[IdleInterval] Regular interval (out of range) - break_id=%s, is_break=%s, status=%s, will save as is_break=%s", current_break_id, getattr(self, 'is_break', 0), self.status, current_break_id if current_break_id else 0)
 *                     logger.info("[IdleInterval] Saving: is_uploaded=True, break_id=%s, is_idle=%s", current_break_id, is_idle)
 *                     logger.info("[IdleInterval] ActivityLevel: Keyboard=%s%%, Mouse=%s%%, Average=%s%%", activityLevel.get('keyboard', '0.0'), activityLevel.get('mouse', '0.0'), activityLevel.get('average', '0.0'))             # <<<<<<<<<<<<<<
 *                     if is_idle:
 *                         logger.info("[IdleInterval]  Interval marked as IDLE - will NOT be sent to server until popup handled")
*/
          __pyx_t_4 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2890, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_37);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2890, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
          __pyx_t_37 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activityLevel, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2890, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_37);
          __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_37, __pyx_mstate_global->__pyx_tuple[24], NULL); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2890, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
          __pyx_t_37 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activityLevel, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2890, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_37);
          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_37, __pyx_mstate_global->__pyx_tuple[25], NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2890, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
          __pyx_t_37 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activityLevel, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2890, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_37);
          __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_37, __pyx_mstate_global->__pyx_tuple[26], NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2890, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
          __pyx_t_7 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_5))) {
            __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
            assert(__pyx_t_4);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
            __pyx_t_7 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[5] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_IdleInterval_ActivityLevel_Keyb, __pyx_t_15, __pyx_t_6, __pyx_t_3};
            __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (5-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2890, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_33);
          }
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

          /* "ws_package/controllers/activity_controller.py":2891
 *                     logger.info("[IdleInterval] Saving: is_uploaded=True, break_id=%s, is_idle=%s", current_break_id, is_idle)
 *                     logger.info("[IdleInterval] ActivityLevel: Keyboard=%s%%, Mouse=%s%%, Average=%s%%", activityLevel.get('keyboard', '0.0'), activityLevel.get('mouse', '0.0'), activityLevel.get('average', '0.0'))
 *                     if is_idle:             # <<<<<<<<<<<<<<
 *                         logger.info("[IdleInterval]  Interval marked as IDLE - will NOT be sent to server until popup handled")
 *                     await self.activity_service.save_first_activity_log(activityLevel, start_date, end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)
*/
          __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_is_idle); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2891, __pyx_L263_error)
          if (__pyx_t_8) {

            /* "ws_package/controllers/activity_controller.py":2892
 *                     logger.info("[IdleInterval] ActivityLevel: Keyboard=%s%%, Mouse=%s%%, Average=%s%%", activityLevel.get('keyboard', '0.0'), activityLevel.get('mouse', '0.0'), activityLevel.get('average', '0.0'))
 *                     if is_idle:
 *                         logger.info("[IdleInterval]  Interval marked as IDLE - will NOT be sent to server until popup handled")             # <<<<<<<<<<<<<<
 *                     await self.activity_service.save_first_activity_log(activityLevel, start_date, end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)
 *                     self.has_on_demand = False
*/
            __pyx_t_5 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2892, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2892, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __pyx_t_7 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_6))) {
              __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
              assert(__pyx_t_5);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
              __Pyx_INCREF(__pyx_t_5);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
              __pyx_t_7 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_IdleInterval_Interval_marked_as};
              __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2892, __pyx_L263_error)
              __Pyx_GOTREF(__pyx_t_33);
            }
            __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

            /* "ws_package/controllers/activity_controller.py":2891
 *                     logger.info("[IdleInterval] Saving: is_uploaded=True, break_id=%s, is_idle=%s", current_break_id, is_idle)
 *                     logger.info("[IdleInterval] ActivityLevel: Keyboard=%s%%, Mouse=%s%%, Average=%s%%", activityLevel.get('keyboard', '0.0'), activityLevel.get('mouse', '0.0'), activityLevel.get('average', '0.0'))
 *                     if is_idle:             # <<<<<<<<<<<<<<
 *                         logger.info("[IdleInterval]  Interval marked as IDLE - will NOT be sent to server until popup handled")
 *                     await self.activity_service.save_first_activity_log(activityLevel, start_date, end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)
*/
          }

          /* "ws_package/controllers/activity_controller.py":2893
 *                     if is_idle:
 *                         logger.info("[IdleInterval]  Interval marked as IDLE - will NOT be sent to server until popup handled")
 *                     await self.activity_service.save_first_activity_log(activityLevel, start_date, end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)             # <<<<<<<<<<<<<<
 *                     self.has_on_demand = False
 *                     # Check for idle detection after out-of-range interval is saved
*/
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2893, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_6 = __pyx_t_5;
          __Pyx_INCREF(__pyx_t_6);
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2893, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_15 = __Pyx_PyLong_AddObjC(__pyx_t_3, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2893, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_4 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_4);
          __pyx_t_7 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
            __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_today_weekday, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2893, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_3);
          }
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_has_on_demand); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2893, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_7 = 0;
          {
            PyObject *__pyx_callargs[6 + ((CYTHON_VECTORCALL) ? 3 : 0)] = {__pyx_t_6, __pyx_cur_scope->__pyx_v_activityLevel, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date, __pyx_t_15, __pyx_t_3};
            __pyx_t_37 = __Pyx_MakeVectorcallBuilderKwds(3); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2893, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_37);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_break_id, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_t_37, __pyx_callargs+6, 0) < (0)) __PYX_ERR(0, 2893, __pyx_L263_error)
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_is_idle, __pyx_cur_scope->__pyx_v_is_idle, __pyx_t_37, __pyx_callargs+6, 1) < (0)) __PYX_ERR(0, 2893, __pyx_L263_error)
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_has_on_demand_screenshot, __pyx_t_4, __pyx_t_37, __pyx_callargs+6, 2) < (0)) __PYX_ERR(0, 2893, __pyx_L263_error)
            __pyx_t_33 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_save_first_activity_log, __pyx_callargs+__pyx_t_7, (6-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_37);
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2893, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_33);
          }
          __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_33, &__pyx_r);
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
          if (likely(__pyx_t_26 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_11);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
            __Pyx_XGIVEREF(__pyx_t_12);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
            __Pyx_XGIVEREF(__pyx_t_13);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 55;
            return __pyx_r;
            __pyx_L794_resume_from_await:;
            __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_11);
            __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_12);
            __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_13);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2893, __pyx_L263_error)
          } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_DECREF(__pyx_r); __pyx_r = 0;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 2893, __pyx_L263_error)
          }

          /* "ws_package/controllers/activity_controller.py":2894
 *                         logger.info("[IdleInterval]  Interval marked as IDLE - will NOT be sent to server until popup handled")
 *                     await self.activity_service.save_first_activity_log(activityLevel, start_date, end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)
 *                     self.has_on_demand = False             # <<<<<<<<<<<<<<
 *                     # Check for idle detection after out-of-range interval is saved
 *                     # NEW REQUIREMENT: Check for 2 consecutive idle intervals and trigger popup
*/
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_has_on_demand, Py_False) < (0)) __PYX_ERR(0, 2894, __pyx_L263_error)

          /* "ws_package/controllers/activity_controller.py":2897
 *                     # Check for idle detection after out-of-range interval is saved
 *                     # NEW REQUIREMENT: Check for 2 consecutive idle intervals and trigger popup
 *                     async def check_idle_after_delay():             # <<<<<<<<<<<<<<
 *                         await asyncio.sleep(1)  # Wait for DB write to complete
 *                         logger.info("[IdleDetection] Checking for idle after interval save (out of range)")
*/
          __pyx_t_33 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_23__start_device_activity_31check_idle_after_delay, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController___start_devic_5, ((PyObject*)__pyx_cur_scope), __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[32])); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2897, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_33);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_check_idle_after_delay);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_check_idle_after_delay, __pyx_t_33);
          __Pyx_GIVEREF(__pyx_t_33);
          __pyx_t_33 = 0;

          /* "ws_package/controllers/activity_controller.py":2905
 *                         else:
 *                             logger.debug("[IdleDetection] No idle detected after interval save")
 *                     asyncio.create_task(check_idle_after_delay())             # <<<<<<<<<<<<<<
 * 
 *                 # CRITICAL: Periodically flush queue when on break to ensure intervals are saved to DB
*/
          __pyx_t_5 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2905, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_37);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_create_task); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2905, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
          __pyx_t_37 = __Pyx_PyObject_CallNoArg(__pyx_cur_scope->__pyx_v_check_idle_after_delay); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2905, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_37);
          __pyx_t_7 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_4))) {
            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
            assert(__pyx_t_5);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
            __pyx_t_7 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_37};
            __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2905, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_33);
          }
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
        }
        __pyx_L499:;

        /* "ws_package/controllers/activity_controller.py":2910
 *                 # This ensures break intervals are written without blocking the main loop
 *                 # Check if break_id is set (not 0) to determine if we're on a break
 *                 if current_break_id != 0:             # <<<<<<<<<<<<<<
 *                     now = datetime.datetime.now()
 *                     # Flush queue every 30 seconds when on break (non-blocking, doesn't disturb functionality)
*/
        __pyx_t_8 = (__Pyx_PyLong_BoolNeObjC(__pyx_cur_scope->__pyx_v_current_break_id, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2910, __pyx_L263_error)
        if (__pyx_t_8) {

          /* "ws_package/controllers/activity_controller.py":2911
 *                 # Check if break_id is set (not 0) to determine if we're on a break
 *                 if current_break_id != 0:
 *                     now = datetime.datetime.now()             # <<<<<<<<<<<<<<
 *                     # Flush queue every 30 seconds when on break (non-blocking, doesn't disturb functionality)
 *                     if (self._last_break_queue_flush is None or
*/
          __Pyx_GetModuleGlobalName(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2911, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_37);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2911, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
          __pyx_t_4 = __pyx_t_5;
          __Pyx_INCREF(__pyx_t_4);
          __pyx_t_7 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
            __pyx_t_33 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2911, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_33);
          }
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_now);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_now, __pyx_t_33);
          __Pyx_GIVEREF(__pyx_t_33);
          __pyx_t_33 = 0;

          /* "ws_package/controllers/activity_controller.py":2913
 *                     now = datetime.datetime.now()
 *                     # Flush queue every 30 seconds when on break (non-blocking, doesn't disturb functionality)
 *                     if (self._last_break_queue_flush is None or             # <<<<<<<<<<<<<<
 *                         (now - self._last_break_queue_flush).total_seconds() >= 30):
 *                         try:
*/
          __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_break_queue_flush); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2913, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_33);
          __pyx_t_9 = (__pyx_t_33 == Py_None);
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
          if (!__pyx_t_9) {
          } else {
            __pyx_t_8 = __pyx_t_9;
            goto __pyx_L797_bool_binop_done;
          }

          /* "ws_package/controllers/activity_controller.py":2914
 *                     # Flush queue every 30 seconds when on break (non-blocking, doesn't disturb functionality)
 *                     if (self._last_break_queue_flush is None or
 *                         (now - self._last_break_queue_flush).total_seconds() >= 30):             # <<<<<<<<<<<<<<
 *                         try:
 *                             queue_size = db_write_queue.get_queue_size(WriteOperationType.ACTIVITY_INTERVAL)
*/
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_break_queue_flush); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2914, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_37 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_now, __pyx_t_4); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2914, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_37);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_5 = __pyx_t_37;
          __Pyx_INCREF(__pyx_t_5);
          __pyx_t_7 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
            __pyx_t_33 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_total_seconds, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
            if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2914, __pyx_L263_error)
            __Pyx_GOTREF(__pyx_t_33);
          }
          __pyx_t_37 = PyObject_RichCompare(__pyx_t_33, __pyx_mstate_global->__pyx_int_30, Py_GE); __Pyx_XGOTREF(__pyx_t_37); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2914, __pyx_L263_error)
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
          __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_37); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2914, __pyx_L263_error)
          __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
          __pyx_t_8 = __pyx_t_9;
          __pyx_L797_bool_binop_done:;

          /* "ws_package/controllers/activity_controller.py":2913
 *                     now = datetime.datetime.now()
 *                     # Flush queue every 30 seconds when on break (non-blocking, doesn't disturb functionality)
 *                     if (self._last_break_queue_flush is None or             # <<<<<<<<<<<<<<
 *                         (now - self._last_break_queue_flush).total_seconds() >= 30):
 *                         try:
*/
          if (__pyx_t_8) {

            /* "ws_package/controllers/activity_controller.py":2915
 *                     if (self._last_break_queue_flush is None or
 *                         (now - self._last_break_queue_flush).total_seconds() >= 30):
 *                         try:             # <<<<<<<<<<<<<<
 *                             queue_size = db_write_queue.get_queue_size(WriteOperationType.ACTIVITY_INTERVAL)
 *                             if queue_size > 0:
*/
            {
              __Pyx_ExceptionSave(&__pyx_t_18, &__pyx_t_21, &__pyx_t_20);
              __Pyx_XGOTREF(__pyx_t_18);
              __Pyx_XGOTREF(__pyx_t_21);
              __Pyx_XGOTREF(__pyx_t_20);
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":2916
 *                         (now - self._last_break_queue_flush).total_seconds() >= 30):
 *                         try:
 *                             queue_size = db_write_queue.get_queue_size(WriteOperationType.ACTIVITY_INTERVAL)             # <<<<<<<<<<<<<<
 *                             if queue_size > 0:
 *                                 logger.debug("On break (break_id=%s) - flushing %s queued intervals to DB (periodic flush)", current_break_id, queue_size)
*/
                __pyx_t_33 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_db_write_queue); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2916, __pyx_L799_error)
                __Pyx_GOTREF(__pyx_t_5);
                __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_get_queue_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2916, __pyx_L799_error)
                __Pyx_GOTREF(__pyx_t_4);
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_WriteOperationType); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2916, __pyx_L799_error)
                __Pyx_GOTREF(__pyx_t_5);
                __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_ACTIVITY_INTERVAL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2916, __pyx_L799_error)
                __Pyx_GOTREF(__pyx_t_3);
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_4))) {
                  __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_4);
                  assert(__pyx_t_33);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                  __Pyx_INCREF(__pyx_t_33);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_33, __pyx_t_3};
                  __pyx_t_37 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2916, __pyx_L799_error)
                  __Pyx_GOTREF(__pyx_t_37);
                }
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_queue_size);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_queue_size, __pyx_t_37);
                __Pyx_GIVEREF(__pyx_t_37);
                __pyx_t_37 = 0;

                /* "ws_package/controllers/activity_controller.py":2917
 *                         try:
 *                             queue_size = db_write_queue.get_queue_size(WriteOperationType.ACTIVITY_INTERVAL)
 *                             if queue_size > 0:             # <<<<<<<<<<<<<<
 *                                 logger.debug("On break (break_id=%s) - flushing %s queued intervals to DB (periodic flush)", current_break_id, queue_size)
 *                                 # CRITICAL: Await the flush to ensure it completes before continuing
*/
                __pyx_t_37 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_queue_size, __pyx_mstate_global->__pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_37); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2917, __pyx_L799_error)
                __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_37); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2917, __pyx_L799_error)
                __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                if (__pyx_t_8) {

                  /* "ws_package/controllers/activity_controller.py":2918
 *                             queue_size = db_write_queue.get_queue_size(WriteOperationType.ACTIVITY_INTERVAL)
 *                             if queue_size > 0:
 *                                 logger.debug("On break (break_id=%s) - flushing %s queued intervals to DB (periodic flush)", current_break_id, queue_size)             # <<<<<<<<<<<<<<
 *                                 # CRITICAL: Await the flush to ensure it completes before continuing
 *                                 # This ensures intervals are actually written to database, not just queued
*/
                  __pyx_t_4 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2918, __pyx_L799_error)
                  __Pyx_GOTREF(__pyx_t_3);
                  __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2918, __pyx_L799_error)
                  __Pyx_GOTREF(__pyx_t_33);
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_33))) {
                    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_33);
                    assert(__pyx_t_4);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
                    __Pyx_INCREF(__pyx_t_4);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[4] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_On_break_break_id_s_flushing_s_q, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_cur_scope->__pyx_v_queue_size};
                    __pyx_t_37 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                    if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2918, __pyx_L799_error)
                    __Pyx_GOTREF(__pyx_t_37);
                  }
                  __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;

                  /* "ws_package/controllers/activity_controller.py":2921
 *                                 # CRITICAL: Await the flush to ensure it completes before continuing
 *                                 # This ensures intervals are actually written to database, not just queued
 *                                 await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 *                                 self._last_break_queue_flush = now
 *                         except Exception as e:
*/
                  __pyx_t_33 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2921, __pyx_L799_error)
                  __Pyx_GOTREF(__pyx_t_4);
                  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2921, __pyx_L799_error)
                  __Pyx_GOTREF(__pyx_t_3);
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_3))) {
                    __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_3);
                    assert(__pyx_t_33);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
                    __Pyx_INCREF(__pyx_t_33);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_33, NULL};
                    __pyx_t_37 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 2921, __pyx_L799_error)
                    __Pyx_GOTREF(__pyx_t_37);
                  }
                  __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_37, &__pyx_r);
                  __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                  if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_XGIVEREF(__pyx_t_11);
                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                    __Pyx_XGIVEREF(__pyx_t_12);
                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                    __Pyx_XGIVEREF(__pyx_t_13);
                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_18;
                    __Pyx_XGIVEREF(__pyx_t_20);
                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_20;
                    __Pyx_XGIVEREF(__pyx_t_21);
                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_21;
                    __Pyx_XGIVEREF(__pyx_r);
                    __Pyx_RefNannyFinishContext();
                    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                    /* return from generator, awaiting value */
                    __pyx_generator->resume_label = 56;
                    return __pyx_r;
                    __pyx_L808_resume_from_await:;
                    __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                    __pyx_cur_scope->__pyx_t_0 = 0;
                    __Pyx_XGOTREF(__pyx_t_11);
                    __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                    __pyx_cur_scope->__pyx_t_1 = 0;
                    __Pyx_XGOTREF(__pyx_t_12);
                    __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                    __pyx_cur_scope->__pyx_t_2 = 0;
                    __Pyx_XGOTREF(__pyx_t_13);
                    __pyx_t_18 = __pyx_cur_scope->__pyx_t_3;
                    __pyx_cur_scope->__pyx_t_3 = 0;
                    __Pyx_XGOTREF(__pyx_t_18);
                    __pyx_t_20 = __pyx_cur_scope->__pyx_t_4;
                    __pyx_cur_scope->__pyx_t_4 = 0;
                    __Pyx_XGOTREF(__pyx_t_20);
                    __pyx_t_21 = __pyx_cur_scope->__pyx_t_5;
                    __pyx_cur_scope->__pyx_t_5 = 0;
                    __Pyx_XGOTREF(__pyx_t_21);
                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2921, __pyx_L799_error)
                  } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                  } else {
                    __Pyx_XGOTREF(__pyx_r);
                    __PYX_ERR(0, 2921, __pyx_L799_error)
                  }

                  /* "ws_package/controllers/activity_controller.py":2922
 *                                 # This ensures intervals are actually written to database, not just queued
 *                                 await db_writer_service.process_immediately()
 *                                 self._last_break_queue_flush = now             # <<<<<<<<<<<<<<
 *                         except Exception as e:
 *                             logger.debug("Error in periodic break queue flush: %s", e)
*/
                  if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_break_queue_flush, __pyx_cur_scope->__pyx_v_now) < (0)) __PYX_ERR(0, 2922, __pyx_L799_error)

                  /* "ws_package/controllers/activity_controller.py":2917
 *                         try:
 *                             queue_size = db_write_queue.get_queue_size(WriteOperationType.ACTIVITY_INTERVAL)
 *                             if queue_size > 0:             # <<<<<<<<<<<<<<
 *                                 logger.debug("On break (break_id=%s) - flushing %s queued intervals to DB (periodic flush)", current_break_id, queue_size)
 *                                 # CRITICAL: Await the flush to ensure it completes before continuing
*/
                }

                /* "ws_package/controllers/activity_controller.py":2915
 *                     if (self._last_break_queue_flush is None or
 *                         (now - self._last_break_queue_flush).total_seconds() >= 30):
 *                         try:             # <<<<<<<<<<<<<<
 *                             queue_size = db_write_queue.get_queue_size(WriteOperationType.ACTIVITY_INTERVAL)
 *                             if queue_size > 0:
*/
              }
              __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
              __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
              __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
              goto __pyx_L806_try_end;
              __pyx_L799_error:;
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
              __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
              __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
              __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
              __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
              __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

              /* "ws_package/controllers/activity_controller.py":2923
 *                                 await db_writer_service.process_immediately()
 *                                 self._last_break_queue_flush = now
 *                         except Exception as e:             # <<<<<<<<<<<<<<
 *                             logger.debug("Error in periodic break queue flush: %s", e)
 *                             # Don't log as error - this is non-critical background operation
*/
              __pyx_t_16 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
              if (__pyx_t_16) {
                __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
                if (__Pyx_GetException(&__pyx_t_37, &__pyx_t_3, &__pyx_t_33) < 0) __PYX_ERR(0, 2923, __pyx_L801_except_error)
                __Pyx_XGOTREF(__pyx_t_37);
                __Pyx_XGOTREF(__pyx_t_3);
                __Pyx_XGOTREF(__pyx_t_33);
                __Pyx_INCREF(__pyx_t_3);
                __Pyx_GIVEREF(__pyx_t_3);
                __pyx_cur_scope->__pyx_v_e = __pyx_t_3;
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":2924
 *                                 self._last_break_queue_flush = now
 *                         except Exception as e:
 *                             logger.debug("Error in periodic break queue flush: %s", e)             # <<<<<<<<<<<<<<
 *                             # Don't log as error - this is non-critical background operation
 * 
*/
                  __pyx_t_5 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2924, __pyx_L814_error)
                  __Pyx_GOTREF(__pyx_t_15);
                  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2924, __pyx_L814_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_6))) {
                    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
                    assert(__pyx_t_5);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                    __Pyx_INCREF(__pyx_t_5);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Error_in_periodic_break_queue_fl, __pyx_cur_scope->__pyx_v_e};
                    __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2924, __pyx_L814_error)
                    __Pyx_GOTREF(__pyx_t_4);
                  }
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                }

                /* "ws_package/controllers/activity_controller.py":2923
 *                                 await db_writer_service.process_immediately()
 *                                 self._last_break_queue_flush = now
 *                         except Exception as e:             # <<<<<<<<<<<<<<
 *                             logger.debug("Error in periodic break queue flush: %s", e)
 *                             # Don't log as error - this is non-critical background operation
*/
                /*finally:*/ {
                  /*normal exit:*/{
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    goto __pyx_L815;
                  }
                  __pyx_L814_error:;
                  /*exception exit:*/{
                    __Pyx_PyThreadState_assign
                    __pyx_t_48 = 0; __pyx_t_47 = 0; __pyx_t_46 = 0; __pyx_t_39 = 0; __pyx_t_23 = 0; __pyx_t_31 = 0;
                    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                    __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                    __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                    __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                     __Pyx_ExceptionSwap(&__pyx_t_39, &__pyx_t_23, &__pyx_t_31);
                    if ( unlikely(__Pyx_GetException(&__pyx_t_48, &__pyx_t_47, &__pyx_t_46) < 0)) __Pyx_ErrFetch(&__pyx_t_48, &__pyx_t_47, &__pyx_t_46);
                    __Pyx_XGOTREF(__pyx_t_48);
                    __Pyx_XGOTREF(__pyx_t_47);
                    __Pyx_XGOTREF(__pyx_t_46);
                    __Pyx_XGOTREF(__pyx_t_39);
                    __Pyx_XGOTREF(__pyx_t_23);
                    __Pyx_XGOTREF(__pyx_t_31);
                    __pyx_t_16 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_63 = __pyx_filename;
                    {
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    }
                    __Pyx_XGIVEREF(__pyx_t_39);
                    __Pyx_XGIVEREF(__pyx_t_23);
                    __Pyx_XGIVEREF(__pyx_t_31);
                    __Pyx_ExceptionReset(__pyx_t_39, __pyx_t_23, __pyx_t_31);
                    __Pyx_XGIVEREF(__pyx_t_48);
                    __Pyx_XGIVEREF(__pyx_t_47);
                    __Pyx_XGIVEREF(__pyx_t_46);
                    __Pyx_ErrRestore(__pyx_t_48, __pyx_t_47, __pyx_t_46);
                    __pyx_t_48 = 0; __pyx_t_47 = 0; __pyx_t_46 = 0; __pyx_t_39 = 0; __pyx_t_23 = 0; __pyx_t_31 = 0;
                    __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_63;
                    goto __pyx_L801_except_error;
                  }
                  __pyx_L815:;
                }
                __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                goto __pyx_L800_exception_handled;
              }
              goto __pyx_L801_except_error;

              /* "ws_package/controllers/activity_controller.py":2915
 *                     if (self._last_break_queue_flush is None or
 *                         (now - self._last_break_queue_flush).total_seconds() >= 30):
 *                         try:             # <<<<<<<<<<<<<<
 *                             queue_size = db_write_queue.get_queue_size(WriteOperationType.ACTIVITY_INTERVAL)
 *                             if queue_size > 0:
*/
              __pyx_L801_except_error:;
              __Pyx_XGIVEREF(__pyx_t_18);
              __Pyx_XGIVEREF(__pyx_t_21);
              __Pyx_XGIVEREF(__pyx_t_20);
              __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_21, __pyx_t_20);
              goto __pyx_L263_error;
              __pyx_L800_exception_handled:;
              __Pyx_XGIVEREF(__pyx_t_18);
              __Pyx_XGIVEREF(__pyx_t_21);
              __Pyx_XGIVEREF(__pyx_t_20);
              __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_21, __pyx_t_20);
              __pyx_L806_try_end:;
            }

            /* "ws_package/controllers/activity_controller.py":2913
 *                     now = datetime.datetime.now()
 *                     # Flush queue every 30 seconds when on break (non-blocking, doesn't disturb functionality)
 *                     if (self._last_break_queue_flush is None or             # <<<<<<<<<<<<<<
 *                         (now - self._last_break_queue_flush).total_seconds() >= 30):
 *                         try:
*/
          }

          /* "ws_package/controllers/activity_controller.py":2910
 *                 # This ensures break intervals are written without blocking the main loop
 *                 # Check if break_id is set (not 0) to determine if we're on a break
 *                 if current_break_id != 0:             # <<<<<<<<<<<<<<
 *                     now = datetime.datetime.now()
 *                     # Flush queue every 30 seconds when on break (non-blocking, doesn't disturb functionality)
*/
        }

        /* "ws_package/controllers/activity_controller.py":2928
 * 
 *                 # Final check if we should stop
 *                 if stop_event.is_set():             # <<<<<<<<<<<<<<
 *                     break
 * 
*/
        __pyx_t_3 = __pyx_cur_scope->__pyx_v_stop_event;
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_7 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
          __pyx_t_33 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_set, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 2928, __pyx_L263_error)
          __Pyx_GOTREF(__pyx_t_33);
        }
        __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_33); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2928, __pyx_L263_error)
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
        if (__pyx_t_8) {

          /* "ws_package/controllers/activity_controller.py":2929
 *                 # Final check if we should stop
 *                 if stop_event.is_set():
 *                     break             # <<<<<<<<<<<<<<
 * 
 *             except Exception as e:
*/
          goto __pyx_L268_try_break;

          /* "ws_package/controllers/activity_controller.py":2928
 * 
 *                 # Final check if we should stop
 *                 if stop_event.is_set():             # <<<<<<<<<<<<<<
 *                     break
 * 
*/
        }

        /* "ws_package/controllers/activity_controller.py":2181
 *                 self._break_monitoring_logged = False
 * 
 *             try:             # <<<<<<<<<<<<<<
 *                 logger.debug("[Timing][Python] Inside main activity loop")
 *                 logger.info("Current Interval Status: %s Screenshot Interval frequency: %s App and URL Status: %s Blur Intensity: %s", self.interval, self.screenshot_interval, self.appandurlstatus, self.blur_intensity)
*/
      }
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      goto __pyx_L270_try_end;
      __pyx_L263_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
      __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
      __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
      __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
      __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
      __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":2931
 *                     break
 * 
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 logger.exception("Error in device activity loop", exc_info=True)
 * 
*/
      __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
      if (__pyx_t_14) {
        __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_33, &__pyx_t_3, &__pyx_t_37) < 0) __PYX_ERR(0, 2931, __pyx_L265_except_error)
        __Pyx_XGOTREF(__pyx_t_33);
        __Pyx_XGOTREF(__pyx_t_3);
        __Pyx_XGOTREF(__pyx_t_37);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_3);
        __Pyx_GIVEREF(__pyx_t_3);
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":2932
 * 
 *             except Exception as e:
 *                 logger.exception("Error in device activity loop", exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *                 # Attempt to persist the interval even after unexpected errors (only if not already saved)
*/
          __pyx_t_6 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2932, __pyx_L826_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_exception); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2932, __pyx_L826_error)
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_7 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_15))) {
            __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_15);
            assert(__pyx_t_6);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
            __Pyx_INCREF(__pyx_t_6);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
            __pyx_t_7 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Error_in_device_activity_loop};
            __pyx_t_5 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2932, __pyx_L826_error)
            __Pyx_GOTREF(__pyx_t_5);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_5, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 2932, __pyx_L826_error)
            __pyx_t_4 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_5);
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2932, __pyx_L826_error)
            __Pyx_GOTREF(__pyx_t_4);
          }
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

          /* "ws_package/controllers/activity_controller.py":2935
 * 
 *                 # Attempt to persist the interval even after unexpected errors (only if not already saved)
 *                 try:             # <<<<<<<<<<<<<<
 *                     if 'start_date' in locals() and 'end_date' in locals():
 *                         start_sec = start_date.replace(microsecond=0)
*/
          {
            __Pyx_ExceptionSave(&__pyx_t_20, &__pyx_t_21, &__pyx_t_18);
            __Pyx_XGOTREF(__pyx_t_20);
            __Pyx_XGOTREF(__pyx_t_21);
            __Pyx_XGOTREF(__pyx_t_18);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":2936
 *                 # Attempt to persist the interval even after unexpected errors (only if not already saved)
 *                 try:
 *                     if 'start_date' in locals() and 'end_date' in locals():             # <<<<<<<<<<<<<<
 *                         start_sec = start_date.replace(microsecond=0)
 *                         end_sec = end_date.replace(microsecond=0)
*/
              __pyx_t_4 = __Pyx_PyDict_NewPresized(126); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_GOTREF(__pyx_t_4);
              if (__pyx_cur_scope->__pyx_v_ErrorCode) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_ErrorCode, __pyx_cur_scope->__pyx_v_ErrorCode) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u__7, __pyx_cur_scope->__pyx_v__) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__WOT) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_WOT, __pyx_cur_scope->__pyx_v__WOT) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__WOT2) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_WOT2, __pyx_cur_scope->__pyx_v__WOT2) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__d) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_d, __pyx_cur_scope->__pyx_v__d) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__d2) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_d2, __pyx_cur_scope->__pyx_v__d2) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__dwq) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_dwq, __pyx_cur_scope->__pyx_v__dwq) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__dwq2) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_dwq2, __pyx_cur_scope->__pyx_v__dwq2) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__on_time_error) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_on_time_error, __pyx_cur_scope->__pyx_v__on_time_error) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__pe) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_pe, __pyx_cur_scope->__pyx_v__pe) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__pe2) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_pe2, __pyx_cur_scope->__pyx_v__pe2) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__pi) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_pi, __pyx_cur_scope->__pyx_v__pi) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__pi2) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_pi2, __pyx_cur_scope->__pyx_v__pi2) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__ps) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_ps, __pyx_cur_scope->__pyx_v__ps) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__ps2) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_ps2, __pyx_cur_scope->__pyx_v__ps2) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_active_app_ui_task) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_active_app_ui_task, __pyx_cur_scope->__pyx_v_active_app_ui_task) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_active_app_ui_task_done_callback) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_active_app_ui_task_done_callback, __pyx_cur_scope->__pyx_v_active_app_ui_task_done_callback) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_active_app_url) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_active_app_url, __pyx_cur_scope->__pyx_v_active_app_url) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_activityLevel) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_activityLevel, __pyx_cur_scope->__pyx_v_activityLevel) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_activity_error) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_activity_error, __pyx_cur_scope->__pyx_v_activity_error) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_activity_percentage_end) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_activity_percentage_end, __pyx_cur_scope->__pyx_v_activity_percentage_end) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_activity_percentage_end_seconds) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_activity_percentage_end_seconds, __pyx_cur_scope->__pyx_v_activity_percentage_end_seconds) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_activity_percentage_entity) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_activity_percentage_entity, __pyx_cur_scope->__pyx_v_activity_percentage_entity) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_activity_percentage_key) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_activity_percentage_key, __pyx_cur_scope->__pyx_v_activity_percentage_key) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_activity_percentage_start) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_activity_percentage_start, __pyx_cur_scope->__pyx_v_activity_percentage_start) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_activity_percentage_start_seconds) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_activity_percentage_start_second, __pyx_cur_scope->__pyx_v_activity_percentage_start_seconds) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_app_listener) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_app_listener, __pyx_cur_scope->__pyx_v_app_listener) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_apply_desktop_key) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_apply_desktop_key, __pyx_cur_scope->__pyx_v_apply_desktop_key) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __pyx_t_15 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_average_activity); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_GOTREF(__pyx_t_15);
              if (__pyx_t_15) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_average_activity, __pyx_t_15) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              __pyx_t_15 = __Pyx_PyBool_FromLong(__pyx_cur_scope->__pyx_v_break_interval_overlaps); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_GOTREF(__pyx_t_15);
              if (__pyx_t_15) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_break_interval_overlaps, __pyx_t_15) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (__pyx_cur_scope->__pyx_v_break_intervals) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_break_intervals, __pyx_cur_scope->__pyx_v_break_intervals) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_break_intervals_after_trim) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_break_intervals_after_trim, __pyx_cur_scope->__pyx_v_break_intervals_after_trim) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_break_start_time) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_break_start_time, __pyx_cur_scope->__pyx_v_break_start_time) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_break_stop_attr) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_break_stop_attr, __pyx_cur_scope->__pyx_v_break_stop_attr) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_break_stop_time_attr) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_break_stop_time_attr, __pyx_cur_scope->__pyx_v_break_stop_time_attr) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_check_idle_after_delay) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_check_idle_after_delay, __pyx_cur_scope->__pyx_v_check_idle_after_delay) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_check_query) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_check_query, __pyx_cur_scope->__pyx_v_check_query) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_chunk_duration) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_chunk_duration, __pyx_cur_scope->__pyx_v_chunk_duration) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_chunks) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_chunks, __pyx_cur_scope->__pyx_v_chunks) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_current_break_id) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_current_break_id, __pyx_cur_scope->__pyx_v_current_break_id) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_current_break_id_slot) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_current_break_id_slot, __pyx_cur_scope->__pyx_v_current_break_id_slot) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_e) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_e, __pyx_cur_scope->__pyx_v_e) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_effective_end) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_effective_end, __pyx_cur_scope->__pyx_v_effective_end) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_effective_start) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_effective_start, __pyx_cur_scope->__pyx_v_effective_start) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_empty_activity_level) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_empty_activity_level, __pyx_cur_scope->__pyx_v_empty_activity_level) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_enable_hourly_log_upload) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_enable_hourly_log_upload, __pyx_cur_scope->__pyx_v_enable_hourly_log_upload) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_end_date) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_end_date, __pyx_cur_scope->__pyx_v_end_date) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_end_date_seconds) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_end_date_seconds, __pyx_cur_scope->__pyx_v_end_date_seconds) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_end_sec) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_end_sec, __pyx_cur_scope->__pyx_v_end_sec) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_enqueued) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_enqueued, __pyx_cur_scope->__pyx_v_enqueued) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_error_data) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_error_data, __pyx_cur_scope->__pyx_v_error_data) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_existing) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_existing, __pyx_cur_scope->__pyx_v_existing) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_existing_dummy) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_existing_dummy, __pyx_cur_scope->__pyx_v_existing_dummy) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_existing_interval_in_db) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_existing_interval_in_db, __pyx_cur_scope->__pyx_v_existing_interval_in_db) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_existing_record) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_existing_record, __pyx_cur_scope->__pyx_v_existing_record) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_fallback_error) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_fallback_error, __pyx_cur_scope->__pyx_v_fallback_error) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_first_entry) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_first_entry, __pyx_cur_scope->__pyx_v_first_entry) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_first_entry_note) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_first_entry_note, __pyx_cur_scope->__pyx_v_first_entry_note) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_flush_error) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_flush_error, __pyx_cur_scope->__pyx_v_flush_error) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_has_any_activity) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_has_any_activity, __pyx_cur_scope->__pyx_v_has_any_activity) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_has_zero_activity) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_has_zero_activity, __pyx_cur_scope->__pyx_v_has_zero_activity) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_headers) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_headers, __pyx_cur_scope->__pyx_v_headers) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_in_range) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_in_range, __pyx_cur_scope->__pyx_v_in_range) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __pyx_t_15 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_initial_average); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_GOTREF(__pyx_t_15);
              if (__pyx_t_15) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_initial_average, __pyx_t_15) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              __pyx_t_15 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_initial_mouse); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_GOTREF(__pyx_t_15);
              if (__pyx_t_15) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_initial_mouse, __pyx_t_15) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              __pyx_t_15 = __Pyx_PyBool_FromLong(__pyx_cur_scope->__pyx_v_interval_exists); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_GOTREF(__pyx_t_15);
              if (__pyx_t_15) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_interval_exists, __pyx_t_15) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (__pyx_cur_scope->__pyx_v_interval_key) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_interval_key, __pyx_cur_scope->__pyx_v_interval_key) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __pyx_t_15 = __Pyx_PyBool_FromLong(__pyx_cur_scope->__pyx_v_is_break_interval); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_GOTREF(__pyx_t_15);
              if (__pyx_t_15) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_is_break_interval, __pyx_t_15) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              __pyx_t_15 = __Pyx_PyBool_FromLong(__pyx_cur_scope->__pyx_v_is_first_entry); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_GOTREF(__pyx_t_15);
              if (__pyx_t_15) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_is_first_entry, __pyx_t_15) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (__pyx_cur_scope->__pyx_v_is_idle) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_is_idle, __pyx_cur_scope->__pyx_v_is_idle) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_keyboard_active) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_keyboard_active, __pyx_cur_scope->__pyx_v_keyboard_active) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __pyx_t_15 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_keyboard_activity); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_GOTREF(__pyx_t_15);
              if (__pyx_t_15) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_keyboard_activity, __pyx_t_15) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (__pyx_cur_scope->__pyx_v_keyboard_verified) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_keyboard_verified, __pyx_cur_scope->__pyx_v_keyboard_verified) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_last_app_monitor_time) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_last_app_monitor_time, __pyx_cur_scope->__pyx_v_last_app_monitor_time) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_last_end) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_last_end, __pyx_cur_scope->__pyx_v_last_end) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_latest_record) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_latest_record, __pyx_cur_scope->__pyx_v_latest_record) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_minimal_activity) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_minimal_activity, __pyx_cur_scope->__pyx_v_minimal_activity) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_monitor_active_app_for_ui) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_monitor_active_app_for_ui, __pyx_cur_scope->__pyx_v_monitor_active_app_for_ui) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_monitor_active_apps) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_monitor_active_apps, __pyx_cur_scope->__pyx_v_monitor_active_apps) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_monitor_task) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_monitor_task, __pyx_cur_scope->__pyx_v_monitor_task) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_mouse_active) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_mouse_active, __pyx_cur_scope->__pyx_v_mouse_active) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __pyx_t_15 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_mouse_activity); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_GOTREF(__pyx_t_15);
              if (__pyx_t_15) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_mouse_activity, __pyx_t_15) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (__pyx_cur_scope->__pyx_v_mouse_verified) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_mouse_verified, __pyx_cur_scope->__pyx_v_mouse_verified) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_now) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_now, __pyx_cur_scope->__pyx_v_now) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_overlap_query) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_overlap_query, __pyx_cur_scope->__pyx_v_overlap_query) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_overlap_query_after_trim) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_overlap_query_after_trim, __pyx_cur_scope->__pyx_v_overlap_query_after_trim) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_overlap_result) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_overlap_result, __pyx_cur_scope->__pyx_v_overlap_result) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_overlap_result_after_trim) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_overlap_result_after_trim, __pyx_cur_scope->__pyx_v_overlap_result_after_trim) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_overlapping_details) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_overlapping_details, __pyx_cur_scope->__pyx_v_overlapping_details) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_overlapping_details_after_trim) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_overlapping_details_after_trim, __pyx_cur_scope->__pyx_v_overlapping_details_after_trim) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_overlapping_intervals) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_overlapping_intervals, __pyx_cur_scope->__pyx_v_overlapping_intervals) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_overlapping_intervals_after_trim) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_overlapping_intervals_after_trim, __pyx_cur_scope->__pyx_v_overlapping_intervals_after_trim) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_payload) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_payload, __pyx_cur_scope->__pyx_v_payload) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_popup_is_active) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_popup_is_active, __pyx_cur_scope->__pyx_v_popup_is_active) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_processed_count) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_processed_count, __pyx_cur_scope->__pyx_v_processed_count) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_query) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_query, __pyx_cur_scope->__pyx_v_query) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_queue_size) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_queue_size, __pyx_cur_scope->__pyx_v_queue_size) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_recovery_error) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_recovery_error, __pyx_cur_scope->__pyx_v_recovery_error) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __pyx_t_15 = __Pyx_PyBool_FromLong(__pyx_cur_scope->__pyx_v_regular_interval_overlaps); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_GOTREF(__pyx_t_15);
              if (__pyx_t_15) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_regular_interval_overlaps, __pyx_t_15) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (__pyx_cur_scope->__pyx_v_regular_intervals) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_regular_intervals, __pyx_cur_scope->__pyx_v_regular_intervals) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_regular_intervals_after_trim) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_regular_intervals_after_trim, __pyx_cur_scope->__pyx_v_regular_intervals_after_trim) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_remove_after_delay) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_remove_after_delay, __pyx_cur_scope->__pyx_v_remove_after_delay) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_resolving_policy) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_resolving_policy, __pyx_cur_scope->__pyx_v_resolving_policy) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_response) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_response, __pyx_cur_scope->__pyx_v_response) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_result) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_result, __pyx_cur_scope->__pyx_v_result) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_script_path) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_script_path, __pyx_cur_scope->__pyx_v_script_path) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_self) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_self, __pyx_cur_scope->__pyx_v_self) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_session) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_session, __pyx_cur_scope->__pyx_v_session) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_session_start) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_session_start, __pyx_cur_scope->__pyx_v_session_start) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_sleep_seconds) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_sleep_seconds, __pyx_cur_scope->__pyx_v_sleep_seconds) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_slot_end) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_slot_end, __pyx_cur_scope->__pyx_v_slot_end) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_start_date) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_start_date, __pyx_cur_scope->__pyx_v_start_date) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_start_date_seconds) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_start_date_seconds, __pyx_cur_scope->__pyx_v_start_date_seconds) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_start_sec) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_start_sec, __pyx_cur_scope->__pyx_v_start_sec) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_stop_event) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_stop_event, __pyx_cur_scope->__pyx_v_stop_event) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_stop_listeners) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_stop_listeners, __pyx_cur_scope->__pyx_v_stop_listeners) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_target_directory) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_target_directory, __pyx_cur_scope->__pyx_v_target_directory) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_target_directory_stealth) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_target_directory_stealth, __pyx_cur_scope->__pyx_v_target_directory_stealth) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_task_done_callback) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_task_done_callback, __pyx_cur_scope->__pyx_v_task_done_callback) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __pyx_t_15 = __Pyx_PyBool_FromLong(__pyx_cur_scope->__pyx_v_timecheck_failed); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_GOTREF(__pyx_t_15);
              if (__pyx_t_15) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_timecheck_failed, __pyx_t_15) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (__pyx_cur_scope->__pyx_v_today) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_today, __pyx_cur_scope->__pyx_v_today) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_total_sleep) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_total_sleep, __pyx_cur_scope->__pyx_v_total_sleep) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_trim_to) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_trim_to, __pyx_cur_scope->__pyx_v_trim_to) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_url) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_url, __pyx_cur_scope->__pyx_v_url) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_user_entity) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_cur_scope->__pyx_v_user_entity) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_work_session_start) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_work_session_start, __pyx_cur_scope->__pyx_v_work_session_start) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __pyx_t_9 = (__Pyx_PyDict_ContainsTF(__pyx_mstate_global->__pyx_n_u_start_date, __pyx_t_4, Py_EQ)); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              if (__pyx_t_9) {
              } else {
                __pyx_t_8 = __pyx_t_9;
                goto __pyx_L837_bool_binop_done;
              }
              __pyx_t_4 = __Pyx_PyDict_NewPresized(126); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_GOTREF(__pyx_t_4);
              if (__pyx_cur_scope->__pyx_v_ErrorCode) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_ErrorCode, __pyx_cur_scope->__pyx_v_ErrorCode) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u__7, __pyx_cur_scope->__pyx_v__) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__WOT) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_WOT, __pyx_cur_scope->__pyx_v__WOT) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__WOT2) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_WOT2, __pyx_cur_scope->__pyx_v__WOT2) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__d) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_d, __pyx_cur_scope->__pyx_v__d) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__d2) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_d2, __pyx_cur_scope->__pyx_v__d2) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__dwq) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_dwq, __pyx_cur_scope->__pyx_v__dwq) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__dwq2) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_dwq2, __pyx_cur_scope->__pyx_v__dwq2) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__on_time_error) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_on_time_error, __pyx_cur_scope->__pyx_v__on_time_error) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__pe) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_pe, __pyx_cur_scope->__pyx_v__pe) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__pe2) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_pe2, __pyx_cur_scope->__pyx_v__pe2) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__pi) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_pi, __pyx_cur_scope->__pyx_v__pi) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__pi2) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_pi2, __pyx_cur_scope->__pyx_v__pi2) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__ps) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_ps, __pyx_cur_scope->__pyx_v__ps) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v__ps2) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_ps2, __pyx_cur_scope->__pyx_v__ps2) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_active_app_ui_task) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_active_app_ui_task, __pyx_cur_scope->__pyx_v_active_app_ui_task) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_active_app_ui_task_done_callback) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_active_app_ui_task_done_callback, __pyx_cur_scope->__pyx_v_active_app_ui_task_done_callback) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_active_app_url) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_active_app_url, __pyx_cur_scope->__pyx_v_active_app_url) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_activityLevel) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_activityLevel, __pyx_cur_scope->__pyx_v_activityLevel) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_activity_error) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_activity_error, __pyx_cur_scope->__pyx_v_activity_error) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_activity_percentage_end) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_activity_percentage_end, __pyx_cur_scope->__pyx_v_activity_percentage_end) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_activity_percentage_end_seconds) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_activity_percentage_end_seconds, __pyx_cur_scope->__pyx_v_activity_percentage_end_seconds) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_activity_percentage_entity) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_activity_percentage_entity, __pyx_cur_scope->__pyx_v_activity_percentage_entity) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_activity_percentage_key) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_activity_percentage_key, __pyx_cur_scope->__pyx_v_activity_percentage_key) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_activity_percentage_start) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_activity_percentage_start, __pyx_cur_scope->__pyx_v_activity_percentage_start) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_activity_percentage_start_seconds) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_activity_percentage_start_second, __pyx_cur_scope->__pyx_v_activity_percentage_start_seconds) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_app_listener) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_app_listener, __pyx_cur_scope->__pyx_v_app_listener) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_apply_desktop_key) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_apply_desktop_key, __pyx_cur_scope->__pyx_v_apply_desktop_key) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __pyx_t_15 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_average_activity); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_GOTREF(__pyx_t_15);
              if (__pyx_t_15) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_average_activity, __pyx_t_15) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              __pyx_t_15 = __Pyx_PyBool_FromLong(__pyx_cur_scope->__pyx_v_break_interval_overlaps); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_GOTREF(__pyx_t_15);
              if (__pyx_t_15) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_break_interval_overlaps, __pyx_t_15) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (__pyx_cur_scope->__pyx_v_break_intervals) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_break_intervals, __pyx_cur_scope->__pyx_v_break_intervals) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_break_intervals_after_trim) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_break_intervals_after_trim, __pyx_cur_scope->__pyx_v_break_intervals_after_trim) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_break_start_time) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_break_start_time, __pyx_cur_scope->__pyx_v_break_start_time) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_break_stop_attr) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_break_stop_attr, __pyx_cur_scope->__pyx_v_break_stop_attr) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_break_stop_time_attr) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_break_stop_time_attr, __pyx_cur_scope->__pyx_v_break_stop_time_attr) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_check_idle_after_delay) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_check_idle_after_delay, __pyx_cur_scope->__pyx_v_check_idle_after_delay) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_check_query) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_check_query, __pyx_cur_scope->__pyx_v_check_query) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_chunk_duration) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_chunk_duration, __pyx_cur_scope->__pyx_v_chunk_duration) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_chunks) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_chunks, __pyx_cur_scope->__pyx_v_chunks) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_current_break_id) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_current_break_id, __pyx_cur_scope->__pyx_v_current_break_id) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_current_break_id_slot) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_current_break_id_slot, __pyx_cur_scope->__pyx_v_current_break_id_slot) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_e) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_e, __pyx_cur_scope->__pyx_v_e) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_effective_end) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_effective_end, __pyx_cur_scope->__pyx_v_effective_end) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_effective_start) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_effective_start, __pyx_cur_scope->__pyx_v_effective_start) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_empty_activity_level) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_empty_activity_level, __pyx_cur_scope->__pyx_v_empty_activity_level) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_enable_hourly_log_upload) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_enable_hourly_log_upload, __pyx_cur_scope->__pyx_v_enable_hourly_log_upload) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_end_date) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_end_date, __pyx_cur_scope->__pyx_v_end_date) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_end_date_seconds) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_end_date_seconds, __pyx_cur_scope->__pyx_v_end_date_seconds) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_end_sec) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_end_sec, __pyx_cur_scope->__pyx_v_end_sec) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_enqueued) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_enqueued, __pyx_cur_scope->__pyx_v_enqueued) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_error_data) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_error_data, __pyx_cur_scope->__pyx_v_error_data) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_existing) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_existing, __pyx_cur_scope->__pyx_v_existing) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_existing_dummy) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_existing_dummy, __pyx_cur_scope->__pyx_v_existing_dummy) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_existing_interval_in_db) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_existing_interval_in_db, __pyx_cur_scope->__pyx_v_existing_interval_in_db) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_existing_record) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_existing_record, __pyx_cur_scope->__pyx_v_existing_record) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_fallback_error) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_fallback_error, __pyx_cur_scope->__pyx_v_fallback_error) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_first_entry) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_first_entry, __pyx_cur_scope->__pyx_v_first_entry) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_first_entry_note) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_first_entry_note, __pyx_cur_scope->__pyx_v_first_entry_note) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_flush_error) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_flush_error, __pyx_cur_scope->__pyx_v_flush_error) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_has_any_activity) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_has_any_activity, __pyx_cur_scope->__pyx_v_has_any_activity) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_has_zero_activity) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_has_zero_activity, __pyx_cur_scope->__pyx_v_has_zero_activity) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_headers) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_headers, __pyx_cur_scope->__pyx_v_headers) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_in_range) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_in_range, __pyx_cur_scope->__pyx_v_in_range) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __pyx_t_15 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_initial_average); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_GOTREF(__pyx_t_15);
              if (__pyx_t_15) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_initial_average, __pyx_t_15) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              __pyx_t_15 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_initial_mouse); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_GOTREF(__pyx_t_15);
              if (__pyx_t_15) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_initial_mouse, __pyx_t_15) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              __pyx_t_15 = __Pyx_PyBool_FromLong(__pyx_cur_scope->__pyx_v_interval_exists); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_GOTREF(__pyx_t_15);
              if (__pyx_t_15) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_interval_exists, __pyx_t_15) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (__pyx_cur_scope->__pyx_v_interval_key) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_interval_key, __pyx_cur_scope->__pyx_v_interval_key) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __pyx_t_15 = __Pyx_PyBool_FromLong(__pyx_cur_scope->__pyx_v_is_break_interval); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_GOTREF(__pyx_t_15);
              if (__pyx_t_15) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_is_break_interval, __pyx_t_15) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              __pyx_t_15 = __Pyx_PyBool_FromLong(__pyx_cur_scope->__pyx_v_is_first_entry); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_GOTREF(__pyx_t_15);
              if (__pyx_t_15) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_is_first_entry, __pyx_t_15) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (__pyx_cur_scope->__pyx_v_is_idle) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_is_idle, __pyx_cur_scope->__pyx_v_is_idle) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_keyboard_active) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_keyboard_active, __pyx_cur_scope->__pyx_v_keyboard_active) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __pyx_t_15 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_keyboard_activity); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_GOTREF(__pyx_t_15);
              if (__pyx_t_15) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_keyboard_activity, __pyx_t_15) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (__pyx_cur_scope->__pyx_v_keyboard_verified) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_keyboard_verified, __pyx_cur_scope->__pyx_v_keyboard_verified) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_last_app_monitor_time) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_last_app_monitor_time, __pyx_cur_scope->__pyx_v_last_app_monitor_time) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_last_end) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_last_end, __pyx_cur_scope->__pyx_v_last_end) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_latest_record) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_latest_record, __pyx_cur_scope->__pyx_v_latest_record) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_minimal_activity) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_minimal_activity, __pyx_cur_scope->__pyx_v_minimal_activity) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_monitor_active_app_for_ui) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_monitor_active_app_for_ui, __pyx_cur_scope->__pyx_v_monitor_active_app_for_ui) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_monitor_active_apps) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_monitor_active_apps, __pyx_cur_scope->__pyx_v_monitor_active_apps) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_monitor_task) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_monitor_task, __pyx_cur_scope->__pyx_v_monitor_task) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_mouse_active) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_mouse_active, __pyx_cur_scope->__pyx_v_mouse_active) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __pyx_t_15 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_mouse_activity); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_GOTREF(__pyx_t_15);
              if (__pyx_t_15) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_mouse_activity, __pyx_t_15) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (__pyx_cur_scope->__pyx_v_mouse_verified) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_mouse_verified, __pyx_cur_scope->__pyx_v_mouse_verified) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_now) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_now, __pyx_cur_scope->__pyx_v_now) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_overlap_query) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_overlap_query, __pyx_cur_scope->__pyx_v_overlap_query) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_overlap_query_after_trim) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_overlap_query_after_trim, __pyx_cur_scope->__pyx_v_overlap_query_after_trim) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_overlap_result) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_overlap_result, __pyx_cur_scope->__pyx_v_overlap_result) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_overlap_result_after_trim) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_overlap_result_after_trim, __pyx_cur_scope->__pyx_v_overlap_result_after_trim) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_overlapping_details) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_overlapping_details, __pyx_cur_scope->__pyx_v_overlapping_details) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_overlapping_details_after_trim) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_overlapping_details_after_trim, __pyx_cur_scope->__pyx_v_overlapping_details_after_trim) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_overlapping_intervals) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_overlapping_intervals, __pyx_cur_scope->__pyx_v_overlapping_intervals) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_overlapping_intervals_after_trim) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_overlapping_intervals_after_trim, __pyx_cur_scope->__pyx_v_overlapping_intervals_after_trim) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_payload) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_payload, __pyx_cur_scope->__pyx_v_payload) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_popup_is_active) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_popup_is_active, __pyx_cur_scope->__pyx_v_popup_is_active) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_processed_count) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_processed_count, __pyx_cur_scope->__pyx_v_processed_count) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_query) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_query, __pyx_cur_scope->__pyx_v_query) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_queue_size) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_queue_size, __pyx_cur_scope->__pyx_v_queue_size) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_recovery_error) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_recovery_error, __pyx_cur_scope->__pyx_v_recovery_error) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __pyx_t_15 = __Pyx_PyBool_FromLong(__pyx_cur_scope->__pyx_v_regular_interval_overlaps); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_GOTREF(__pyx_t_15);
              if (__pyx_t_15) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_regular_interval_overlaps, __pyx_t_15) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (__pyx_cur_scope->__pyx_v_regular_intervals) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_regular_intervals, __pyx_cur_scope->__pyx_v_regular_intervals) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_regular_intervals_after_trim) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_regular_intervals_after_trim, __pyx_cur_scope->__pyx_v_regular_intervals_after_trim) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_remove_after_delay) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_remove_after_delay, __pyx_cur_scope->__pyx_v_remove_after_delay) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_resolving_policy) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_resolving_policy, __pyx_cur_scope->__pyx_v_resolving_policy) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_response) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_response, __pyx_cur_scope->__pyx_v_response) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_result) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_result, __pyx_cur_scope->__pyx_v_result) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_script_path) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_script_path, __pyx_cur_scope->__pyx_v_script_path) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_self) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_self, __pyx_cur_scope->__pyx_v_self) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_session) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_session, __pyx_cur_scope->__pyx_v_session) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_session_start) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_session_start, __pyx_cur_scope->__pyx_v_session_start) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_sleep_seconds) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_sleep_seconds, __pyx_cur_scope->__pyx_v_sleep_seconds) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_slot_end) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_slot_end, __pyx_cur_scope->__pyx_v_slot_end) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_start_date) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_start_date, __pyx_cur_scope->__pyx_v_start_date) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_start_date_seconds) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_start_date_seconds, __pyx_cur_scope->__pyx_v_start_date_seconds) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_start_sec) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_start_sec, __pyx_cur_scope->__pyx_v_start_sec) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_stop_event) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_stop_event, __pyx_cur_scope->__pyx_v_stop_event) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_stop_listeners) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_stop_listeners, __pyx_cur_scope->__pyx_v_stop_listeners) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_target_directory) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_target_directory, __pyx_cur_scope->__pyx_v_target_directory) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_target_directory_stealth) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_target_directory_stealth, __pyx_cur_scope->__pyx_v_target_directory_stealth) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_task_done_callback) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_task_done_callback, __pyx_cur_scope->__pyx_v_task_done_callback) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __pyx_t_15 = __Pyx_PyBool_FromLong(__pyx_cur_scope->__pyx_v_timecheck_failed); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_GOTREF(__pyx_t_15);
              if (__pyx_t_15) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_timecheck_failed, __pyx_t_15) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (__pyx_cur_scope->__pyx_v_today) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_today, __pyx_cur_scope->__pyx_v_today) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_total_sleep) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_total_sleep, __pyx_cur_scope->__pyx_v_total_sleep) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_trim_to) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_trim_to, __pyx_cur_scope->__pyx_v_trim_to) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_url) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_url, __pyx_cur_scope->__pyx_v_url) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_user_entity) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_cur_scope->__pyx_v_user_entity) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              if (__pyx_cur_scope->__pyx_v_work_session_start) {
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_work_session_start, __pyx_cur_scope->__pyx_v_work_session_start) < (0)) __PYX_ERR(0, 2936, __pyx_L828_error)
              }
              __pyx_t_9 = (__Pyx_PyDict_ContainsTF(__pyx_mstate_global->__pyx_n_u_end_date, __pyx_t_4, Py_EQ)); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2936, __pyx_L828_error)
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __pyx_t_8 = __pyx_t_9;
              __pyx_L837_bool_binop_done:;
              if (__pyx_t_8) {

                /* "ws_package/controllers/activity_controller.py":2937
 *                 try:
 *                     if 'start_date' in locals() and 'end_date' in locals():
 *                         start_sec = start_date.replace(microsecond=0)             # <<<<<<<<<<<<<<
 *                         end_sec = end_date.replace(microsecond=0)
 *                         interval_key = (self.last_count + 1, start_sec, end_sec)
*/
                if (unlikely(!__pyx_cur_scope->__pyx_v_start_date)) { __Pyx_RaiseUnboundLocalError("start_date"); __PYX_ERR(0, 2937, __pyx_L828_error) }
                __pyx_t_15 = __pyx_cur_scope->__pyx_v_start_date;
                __Pyx_INCREF(__pyx_t_15);
                __pyx_t_7 = 0;
                {
                  PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_15, NULL};
                  __pyx_t_5 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2937, __pyx_L828_error)
                  __Pyx_GOTREF(__pyx_t_5);
                  if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_5, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 2937, __pyx_L828_error)
                  __pyx_t_4 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_5);
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2937, __pyx_L828_error)
                  __Pyx_GOTREF(__pyx_t_4);
                }
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_start_sec);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_start_sec, __pyx_t_4);
                __Pyx_GIVEREF(__pyx_t_4);
                __pyx_t_4 = 0;

                /* "ws_package/controllers/activity_controller.py":2938
 *                     if 'start_date' in locals() and 'end_date' in locals():
 *                         start_sec = start_date.replace(microsecond=0)
 *                         end_sec = end_date.replace(microsecond=0)             # <<<<<<<<<<<<<<
 *                         interval_key = (self.last_count + 1, start_sec, end_sec)
 *                         # Skip if we were already creating this interval (save was likely enqueued before the exception)
*/
                if (unlikely(!__pyx_cur_scope->__pyx_v_end_date)) { __Pyx_RaiseUnboundLocalError("end_date"); __PYX_ERR(0, 2938, __pyx_L828_error) }
                __pyx_t_5 = __pyx_cur_scope->__pyx_v_end_date;
                __Pyx_INCREF(__pyx_t_5);
                __pyx_t_7 = 0;
                {
                  PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_5, NULL};
                  __pyx_t_15 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2938, __pyx_L828_error)
                  __Pyx_GOTREF(__pyx_t_15);
                  if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_15, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 2938, __pyx_L828_error)
                  __pyx_t_4 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_15);
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2938, __pyx_L828_error)
                  __Pyx_GOTREF(__pyx_t_4);
                }
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_end_sec);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_end_sec, __pyx_t_4);
                __Pyx_GIVEREF(__pyx_t_4);
                __pyx_t_4 = 0;

                /* "ws_package/controllers/activity_controller.py":2939
 *                         start_sec = start_date.replace(microsecond=0)
 *                         end_sec = end_date.replace(microsecond=0)
 *                         interval_key = (self.last_count + 1, start_sec, end_sec)             # <<<<<<<<<<<<<<
 *                         # Skip if we were already creating this interval (save was likely enqueued before the exception)
 *                         if interval_key in self._creating_intervals:
*/
                __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2939, __pyx_L828_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_t_15 = __Pyx_PyLong_AddObjC(__pyx_t_4, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2939, __pyx_L828_error)
                __Pyx_GOTREF(__pyx_t_15);
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2939, __pyx_L828_error)
                __Pyx_GOTREF(__pyx_t_4);
                __Pyx_GIVEREF(__pyx_t_15);
                if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_15) != (0)) __PYX_ERR(0, 2939, __pyx_L828_error);
                __Pyx_INCREF(__pyx_cur_scope->__pyx_v_start_sec);
                __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_start_sec);
                if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_cur_scope->__pyx_v_start_sec) != (0)) __PYX_ERR(0, 2939, __pyx_L828_error);
                __Pyx_INCREF(__pyx_cur_scope->__pyx_v_end_sec);
                __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_end_sec);
                if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_cur_scope->__pyx_v_end_sec) != (0)) __PYX_ERR(0, 2939, __pyx_L828_error);
                __pyx_t_15 = 0;
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval_key);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval_key, ((PyObject*)__pyx_t_4));
                __Pyx_GIVEREF(__pyx_t_4);
                __pyx_t_4 = 0;

                /* "ws_package/controllers/activity_controller.py":2941
 *                         interval_key = (self.last_count + 1, start_sec, end_sec)
 *                         # Skip if we were already creating this interval (save was likely enqueued before the exception)
 *                         if interval_key in self._creating_intervals:             # <<<<<<<<<<<<<<
 *                             logger.info("Skipping exception recovery save - interval %s to %s already in progress (avoid duplicate)", start_date, end_date)
 *                             await asyncio.sleep(5)
*/
                __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_creating_intervals); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2941, __pyx_L828_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_t_8 = (__Pyx_PySequence_ContainsTF(__pyx_cur_scope->__pyx_v_interval_key, __pyx_t_4, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2941, __pyx_L828_error)
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                if (__pyx_t_8) {

                  /* "ws_package/controllers/activity_controller.py":2942
 *                         # Skip if we were already creating this interval (save was likely enqueued before the exception)
 *                         if interval_key in self._creating_intervals:
 *                             logger.info("Skipping exception recovery save - interval %s to %s already in progress (avoid duplicate)", start_date, end_date)             # <<<<<<<<<<<<<<
 *                             await asyncio.sleep(5)
 *                             continue
*/
                  __pyx_t_15 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2942, __pyx_L828_error)
                  __Pyx_GOTREF(__pyx_t_5);
                  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2942, __pyx_L828_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  if (unlikely(!__pyx_cur_scope->__pyx_v_start_date)) { __Pyx_RaiseUnboundLocalError("start_date"); __PYX_ERR(0, 2942, __pyx_L828_error) }
                  if (unlikely(!__pyx_cur_scope->__pyx_v_end_date)) { __Pyx_RaiseUnboundLocalError("end_date"); __PYX_ERR(0, 2942, __pyx_L828_error) }
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_6))) {
                    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_6);
                    assert(__pyx_t_15);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                    __Pyx_INCREF(__pyx_t_15);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[4] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Skipping_exception_recovery_save, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
                    __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2942, __pyx_L828_error)
                    __Pyx_GOTREF(__pyx_t_4);
                  }
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                  /* "ws_package/controllers/activity_controller.py":2943
 *                         if interval_key in self._creating_intervals:
 *                             logger.info("Skipping exception recovery save - interval %s to %s already in progress (avoid duplicate)", start_date, end_date)
 *                             await asyncio.sleep(5)             # <<<<<<<<<<<<<<
 *                             continue
 *                         # Flush queue so any pending write for this interval is committed, then check DB
*/
                  __pyx_t_6 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2943, __pyx_L828_error)
                  __Pyx_GOTREF(__pyx_t_15);
                  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2943, __pyx_L828_error)
                  __Pyx_GOTREF(__pyx_t_5);
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_5))) {
                    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
                    assert(__pyx_t_6);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                    __Pyx_INCREF(__pyx_t_6);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_int_5};
                    __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2943, __pyx_L828_error)
                    __Pyx_GOTREF(__pyx_t_4);
                  }
                  __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_XGIVEREF(__pyx_t_3);
                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
                    __Pyx_XGIVEREF(__pyx_t_11);
                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_11;
                    __Pyx_XGIVEREF(__pyx_t_12);
                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_12;
                    __Pyx_XGIVEREF(__pyx_t_13);
                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_13;
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_18;
                    __Pyx_XGIVEREF(__pyx_t_20);
                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_20;
                    __Pyx_XGIVEREF(__pyx_t_21);
                    __pyx_cur_scope->__pyx_t_6 = __pyx_t_21;
                    __Pyx_XGIVEREF(__pyx_t_33);
                    __pyx_cur_scope->__pyx_t_7 = __pyx_t_33;
                    __Pyx_XGIVEREF(__pyx_t_37);
                    __pyx_cur_scope->__pyx_t_8 = __pyx_t_37;
                    __Pyx_XGIVEREF(__pyx_r);
                    __Pyx_RefNannyFinishContext();
                    __Pyx_Coroutine_SwapException(__pyx_generator);
                    /* return from generator, awaiting value */
                    __pyx_generator->resume_label = 57;
                    return __pyx_r;
                    __pyx_L840_resume_from_await:;
                    __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
                    __pyx_cur_scope->__pyx_t_0 = 0;
                    __Pyx_XGOTREF(__pyx_t_3);
                    __pyx_t_11 = __pyx_cur_scope->__pyx_t_1;
                    __pyx_cur_scope->__pyx_t_1 = 0;
                    __Pyx_XGOTREF(__pyx_t_11);
                    __pyx_t_12 = __pyx_cur_scope->__pyx_t_2;
                    __pyx_cur_scope->__pyx_t_2 = 0;
                    __Pyx_XGOTREF(__pyx_t_12);
                    __pyx_t_13 = __pyx_cur_scope->__pyx_t_3;
                    __pyx_cur_scope->__pyx_t_3 = 0;
                    __Pyx_XGOTREF(__pyx_t_13);
                    __pyx_t_18 = __pyx_cur_scope->__pyx_t_4;
                    __pyx_cur_scope->__pyx_t_4 = 0;
                    __Pyx_XGOTREF(__pyx_t_18);
                    __pyx_t_20 = __pyx_cur_scope->__pyx_t_5;
                    __pyx_cur_scope->__pyx_t_5 = 0;
                    __Pyx_XGOTREF(__pyx_t_20);
                    __pyx_t_21 = __pyx_cur_scope->__pyx_t_6;
                    __pyx_cur_scope->__pyx_t_6 = 0;
                    __Pyx_XGOTREF(__pyx_t_21);
                    __pyx_t_33 = __pyx_cur_scope->__pyx_t_7;
                    __pyx_cur_scope->__pyx_t_7 = 0;
                    __Pyx_XGOTREF(__pyx_t_33);
                    __pyx_t_37 = __pyx_cur_scope->__pyx_t_8;
                    __pyx_cur_scope->__pyx_t_8 = 0;
                    __Pyx_XGOTREF(__pyx_t_37);
                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2943, __pyx_L828_error)
                  } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                  } else {
                    __Pyx_XGOTREF(__pyx_r);
                    __PYX_ERR(0, 2943, __pyx_L828_error)
                  }

                  /* "ws_package/controllers/activity_controller.py":2944
 *                             logger.info("Skipping exception recovery save - interval %s to %s already in progress (avoid duplicate)", start_date, end_date)
 *                             await asyncio.sleep(5)
 *                             continue             # <<<<<<<<<<<<<<
 *                         # Flush queue so any pending write for this interval is committed, then check DB
 *                         try:
*/
                  goto __pyx_L834_try_continue;

                  /* "ws_package/controllers/activity_controller.py":2941
 *                         interval_key = (self.last_count + 1, start_sec, end_sec)
 *                         # Skip if we were already creating this interval (save was likely enqueued before the exception)
 *                         if interval_key in self._creating_intervals:             # <<<<<<<<<<<<<<
 *                             logger.info("Skipping exception recovery save - interval %s to %s already in progress (avoid duplicate)", start_date, end_date)
 *                             await asyncio.sleep(5)
*/
                }

                /* "ws_package/controllers/activity_controller.py":2946
 *                             continue
 *                         # Flush queue so any pending write for this interval is committed, then check DB
 *                         try:             # <<<<<<<<<<<<<<
 *                             await db_writer_service.process_immediately()
 *                         except Exception:
*/
                {
                  __Pyx_ExceptionSave(&__pyx_t_31, &__pyx_t_23, &__pyx_t_39);
                  __Pyx_XGOTREF(__pyx_t_31);
                  __Pyx_XGOTREF(__pyx_t_23);
                  __Pyx_XGOTREF(__pyx_t_39);
                  /*try:*/ {

                    /* "ws_package/controllers/activity_controller.py":2947
 *                         # Flush queue so any pending write for this interval is committed, then check DB
 *                         try:
 *                             await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 *                         except Exception:
 *                             pass
*/
                    __pyx_t_5 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2947, __pyx_L841_error)
                    __Pyx_GOTREF(__pyx_t_6);
                    __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2947, __pyx_L841_error)
                    __Pyx_GOTREF(__pyx_t_15);
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __pyx_t_7 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_15))) {
                      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_15);
                      assert(__pyx_t_5);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                      __Pyx_INCREF(__pyx_t_5);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                      __pyx_t_7 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                      __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2947, __pyx_L841_error)
                      __Pyx_GOTREF(__pyx_t_4);
                    }
                    __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                      __Pyx_GOTREF(__pyx_r);
                      __Pyx_XGIVEREF(__pyx_t_3);
                      __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
                      __Pyx_XGIVEREF(__pyx_t_11);
                      __pyx_cur_scope->__pyx_t_1 = __pyx_t_11;
                      __Pyx_XGIVEREF(__pyx_t_12);
                      __pyx_cur_scope->__pyx_t_2 = __pyx_t_12;
                      __Pyx_XGIVEREF(__pyx_t_13);
                      __pyx_cur_scope->__pyx_t_3 = __pyx_t_13;
                      __Pyx_XGIVEREF(__pyx_t_18);
                      __pyx_cur_scope->__pyx_t_4 = __pyx_t_18;
                      __Pyx_XGIVEREF(__pyx_t_20);
                      __pyx_cur_scope->__pyx_t_5 = __pyx_t_20;
                      __Pyx_XGIVEREF(__pyx_t_21);
                      __pyx_cur_scope->__pyx_t_6 = __pyx_t_21;
                      __Pyx_XGIVEREF(__pyx_t_23);
                      __pyx_cur_scope->__pyx_t_7 = __pyx_t_23;
                      __Pyx_XGIVEREF(__pyx_t_31);
                      __pyx_cur_scope->__pyx_t_8 = __pyx_t_31;
                      __Pyx_XGIVEREF(__pyx_t_33);
                      __pyx_cur_scope->__pyx_t_9 = __pyx_t_33;
                      __Pyx_XGIVEREF(__pyx_t_37);
                      __pyx_cur_scope->__pyx_t_10 = __pyx_t_37;
                      __Pyx_XGIVEREF(__pyx_t_39);
                      __pyx_cur_scope->__pyx_t_11 = __pyx_t_39;
                      __Pyx_XGIVEREF(__pyx_r);
                      __Pyx_RefNannyFinishContext();
                      __Pyx_Coroutine_SwapException(__pyx_generator);
                      /* return from generator, awaiting value */
                      __pyx_generator->resume_label = 58;
                      return __pyx_r;
                      __pyx_L849_resume_from_await:;
                      __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
                      __pyx_cur_scope->__pyx_t_0 = 0;
                      __Pyx_XGOTREF(__pyx_t_3);
                      __pyx_t_11 = __pyx_cur_scope->__pyx_t_1;
                      __pyx_cur_scope->__pyx_t_1 = 0;
                      __Pyx_XGOTREF(__pyx_t_11);
                      __pyx_t_12 = __pyx_cur_scope->__pyx_t_2;
                      __pyx_cur_scope->__pyx_t_2 = 0;
                      __Pyx_XGOTREF(__pyx_t_12);
                      __pyx_t_13 = __pyx_cur_scope->__pyx_t_3;
                      __pyx_cur_scope->__pyx_t_3 = 0;
                      __Pyx_XGOTREF(__pyx_t_13);
                      __pyx_t_18 = __pyx_cur_scope->__pyx_t_4;
                      __pyx_cur_scope->__pyx_t_4 = 0;
                      __Pyx_XGOTREF(__pyx_t_18);
                      __pyx_t_20 = __pyx_cur_scope->__pyx_t_5;
                      __pyx_cur_scope->__pyx_t_5 = 0;
                      __Pyx_XGOTREF(__pyx_t_20);
                      __pyx_t_21 = __pyx_cur_scope->__pyx_t_6;
                      __pyx_cur_scope->__pyx_t_6 = 0;
                      __Pyx_XGOTREF(__pyx_t_21);
                      __pyx_t_23 = __pyx_cur_scope->__pyx_t_7;
                      __pyx_cur_scope->__pyx_t_7 = 0;
                      __Pyx_XGOTREF(__pyx_t_23);
                      __pyx_t_31 = __pyx_cur_scope->__pyx_t_8;
                      __pyx_cur_scope->__pyx_t_8 = 0;
                      __Pyx_XGOTREF(__pyx_t_31);
                      __pyx_t_33 = __pyx_cur_scope->__pyx_t_9;
                      __pyx_cur_scope->__pyx_t_9 = 0;
                      __Pyx_XGOTREF(__pyx_t_33);
                      __pyx_t_37 = __pyx_cur_scope->__pyx_t_10;
                      __pyx_cur_scope->__pyx_t_10 = 0;
                      __Pyx_XGOTREF(__pyx_t_37);
                      __pyx_t_39 = __pyx_cur_scope->__pyx_t_11;
                      __pyx_cur_scope->__pyx_t_11 = 0;
                      __Pyx_XGOTREF(__pyx_t_39);
                      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2947, __pyx_L841_error)
                    } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                      __Pyx_GOTREF(__pyx_r);
                      __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                    } else {
                      __Pyx_XGOTREF(__pyx_r);
                      __PYX_ERR(0, 2947, __pyx_L841_error)
                    }

                    /* "ws_package/controllers/activity_controller.py":2946
 *                             continue
 *                         # Flush queue so any pending write for this interval is committed, then check DB
 *                         try:             # <<<<<<<<<<<<<<
 *                             await db_writer_service.process_immediately()
 *                         except Exception:
*/
                  }
                  __Pyx_XDECREF(__pyx_t_31); __pyx_t_31 = 0;
                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                  __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                  goto __pyx_L848_try_end;
                  __pyx_L841_error:;
                  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                  __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                  __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                  __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                  __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

                  /* "ws_package/controllers/activity_controller.py":2948
 *                         try:
 *                             await db_writer_service.process_immediately()
 *                         except Exception:             # <<<<<<<<<<<<<<
 *                             pass
 *                         if await self.activity_service.check_existing_interval(start_date, end_date, exact=True):
*/
                  __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                  if (__pyx_t_14) {
                    __Pyx_ErrRestore(0,0,0);
                    goto __pyx_L842_exception_handled;
                  }
                  goto __pyx_L843_except_error;

                  /* "ws_package/controllers/activity_controller.py":2946
 *                             continue
 *                         # Flush queue so any pending write for this interval is committed, then check DB
 *                         try:             # <<<<<<<<<<<<<<
 *                             await db_writer_service.process_immediately()
 *                         except Exception:
*/
                  __pyx_L843_except_error:;
                  __Pyx_XGIVEREF(__pyx_t_31);
                  __Pyx_XGIVEREF(__pyx_t_23);
                  __Pyx_XGIVEREF(__pyx_t_39);
                  __Pyx_ExceptionReset(__pyx_t_31, __pyx_t_23, __pyx_t_39);
                  goto __pyx_L828_error;
                  __pyx_L842_exception_handled:;
                  __Pyx_XGIVEREF(__pyx_t_31);
                  __Pyx_XGIVEREF(__pyx_t_23);
                  __Pyx_XGIVEREF(__pyx_t_39);
                  __Pyx_ExceptionReset(__pyx_t_31, __pyx_t_23, __pyx_t_39);
                  __pyx_L848_try_end:;
                }

                /* "ws_package/controllers/activity_controller.py":2950
 *                         except Exception:
 *                             pass
 *                         if await self.activity_service.check_existing_interval(start_date, end_date, exact=True):             # <<<<<<<<<<<<<<
 *                             logger.info("Skipping exception recovery save - interval %s to %s already exists in DB (avoid duplicate)", start_date, end_date)
 *                             await asyncio.sleep(5)
*/
                __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2950, __pyx_L828_error)
                __Pyx_GOTREF(__pyx_t_5);
                __pyx_t_15 = __pyx_t_5;
                __Pyx_INCREF(__pyx_t_15);
                if (unlikely(!__pyx_cur_scope->__pyx_v_start_date)) { __Pyx_RaiseUnboundLocalError("start_date"); __PYX_ERR(0, 2950, __pyx_L828_error) }
                if (unlikely(!__pyx_cur_scope->__pyx_v_end_date)) { __Pyx_RaiseUnboundLocalError("end_date"); __PYX_ERR(0, 2950, __pyx_L828_error) }
                __pyx_t_7 = 0;
                {
                  PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_15, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
                  __pyx_t_6 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2950, __pyx_L828_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exact, Py_True, __pyx_t_6, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 2950, __pyx_L828_error)
                  __pyx_t_4 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_check_existing_interval, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_6);
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2950, __pyx_L828_error)
                  __Pyx_GOTREF(__pyx_t_4);
                }
                __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_3);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
                  __Pyx_XGIVEREF(__pyx_t_11);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_11;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_18;
                  __Pyx_XGIVEREF(__pyx_t_20);
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_20;
                  __Pyx_XGIVEREF(__pyx_t_21);
                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_21;
                  __Pyx_XGIVEREF(__pyx_t_33);
                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_33;
                  __Pyx_XGIVEREF(__pyx_t_37);
                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_37;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_SwapException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 59;
                  return __pyx_r;
                  __pyx_L853_resume_from_await:;
                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_3);
                  __pyx_t_11 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_11);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  __pyx_t_18 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_18);
                  __pyx_t_20 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = 0;
                  __Pyx_XGOTREF(__pyx_t_20);
                  __pyx_t_21 = __pyx_cur_scope->__pyx_t_6;
                  __pyx_cur_scope->__pyx_t_6 = 0;
                  __Pyx_XGOTREF(__pyx_t_21);
                  __pyx_t_33 = __pyx_cur_scope->__pyx_t_7;
                  __pyx_cur_scope->__pyx_t_7 = 0;
                  __Pyx_XGOTREF(__pyx_t_33);
                  __pyx_t_37 = __pyx_cur_scope->__pyx_t_8;
                  __pyx_cur_scope->__pyx_t_8 = 0;
                  __Pyx_XGOTREF(__pyx_t_37);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2950, __pyx_L828_error)
                  __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 2950, __pyx_L828_error)
                }
                __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2950, __pyx_L828_error)
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                if (__pyx_t_8) {

                  /* "ws_package/controllers/activity_controller.py":2951
 *                             pass
 *                         if await self.activity_service.check_existing_interval(start_date, end_date, exact=True):
 *                             logger.info("Skipping exception recovery save - interval %s to %s already exists in DB (avoid duplicate)", start_date, end_date)             # <<<<<<<<<<<<<<
 *                             await asyncio.sleep(5)
 *                             continue
*/
                  __pyx_t_5 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2951, __pyx_L828_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2951, __pyx_L828_error)
                  __Pyx_GOTREF(__pyx_t_15);
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  if (unlikely(!__pyx_cur_scope->__pyx_v_start_date)) { __Pyx_RaiseUnboundLocalError("start_date"); __PYX_ERR(0, 2951, __pyx_L828_error) }
                  if (unlikely(!__pyx_cur_scope->__pyx_v_end_date)) { __Pyx_RaiseUnboundLocalError("end_date"); __PYX_ERR(0, 2951, __pyx_L828_error) }
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_15))) {
                    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_15);
                    assert(__pyx_t_5);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                    __Pyx_INCREF(__pyx_t_5);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[4] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Skipping_exception_recovery_save_2, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
                    __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2951, __pyx_L828_error)
                    __Pyx_GOTREF(__pyx_t_4);
                  }
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                  /* "ws_package/controllers/activity_controller.py":2952
 *                         if await self.activity_service.check_existing_interval(start_date, end_date, exact=True):
 *                             logger.info("Skipping exception recovery save - interval %s to %s already exists in DB (avoid duplicate)", start_date, end_date)
 *                             await asyncio.sleep(5)             # <<<<<<<<<<<<<<
 *                             continue
 *                         logger.warning("Attempting to save interval %s to %s after exception", start_date, end_date)
*/
                  __pyx_t_15 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2952, __pyx_L828_error)
                  __Pyx_GOTREF(__pyx_t_5);
                  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2952, __pyx_L828_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __pyx_t_7 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_6))) {
                    __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_6);
                    assert(__pyx_t_15);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                    __Pyx_INCREF(__pyx_t_15);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                    __pyx_t_7 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_mstate_global->__pyx_int_5};
                    __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2952, __pyx_L828_error)
                    __Pyx_GOTREF(__pyx_t_4);
                  }
                  __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_XGIVEREF(__pyx_t_3);
                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
                    __Pyx_XGIVEREF(__pyx_t_11);
                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_11;
                    __Pyx_XGIVEREF(__pyx_t_12);
                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_12;
                    __Pyx_XGIVEREF(__pyx_t_13);
                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_13;
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_18;
                    __Pyx_XGIVEREF(__pyx_t_20);
                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_20;
                    __Pyx_XGIVEREF(__pyx_t_21);
                    __pyx_cur_scope->__pyx_t_6 = __pyx_t_21;
                    __Pyx_XGIVEREF(__pyx_t_33);
                    __pyx_cur_scope->__pyx_t_7 = __pyx_t_33;
                    __Pyx_XGIVEREF(__pyx_t_37);
                    __pyx_cur_scope->__pyx_t_8 = __pyx_t_37;
                    __Pyx_XGIVEREF(__pyx_r);
                    __Pyx_RefNannyFinishContext();
                    __Pyx_Coroutine_SwapException(__pyx_generator);
                    /* return from generator, awaiting value */
                    __pyx_generator->resume_label = 60;
                    return __pyx_r;
                    __pyx_L854_resume_from_await:;
                    __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
                    __pyx_cur_scope->__pyx_t_0 = 0;
                    __Pyx_XGOTREF(__pyx_t_3);
                    __pyx_t_11 = __pyx_cur_scope->__pyx_t_1;
                    __pyx_cur_scope->__pyx_t_1 = 0;
                    __Pyx_XGOTREF(__pyx_t_11);
                    __pyx_t_12 = __pyx_cur_scope->__pyx_t_2;
                    __pyx_cur_scope->__pyx_t_2 = 0;
                    __Pyx_XGOTREF(__pyx_t_12);
                    __pyx_t_13 = __pyx_cur_scope->__pyx_t_3;
                    __pyx_cur_scope->__pyx_t_3 = 0;
                    __Pyx_XGOTREF(__pyx_t_13);
                    __pyx_t_18 = __pyx_cur_scope->__pyx_t_4;
                    __pyx_cur_scope->__pyx_t_4 = 0;
                    __Pyx_XGOTREF(__pyx_t_18);
                    __pyx_t_20 = __pyx_cur_scope->__pyx_t_5;
                    __pyx_cur_scope->__pyx_t_5 = 0;
                    __Pyx_XGOTREF(__pyx_t_20);
                    __pyx_t_21 = __pyx_cur_scope->__pyx_t_6;
                    __pyx_cur_scope->__pyx_t_6 = 0;
                    __Pyx_XGOTREF(__pyx_t_21);
                    __pyx_t_33 = __pyx_cur_scope->__pyx_t_7;
                    __pyx_cur_scope->__pyx_t_7 = 0;
                    __Pyx_XGOTREF(__pyx_t_33);
                    __pyx_t_37 = __pyx_cur_scope->__pyx_t_8;
                    __pyx_cur_scope->__pyx_t_8 = 0;
                    __Pyx_XGOTREF(__pyx_t_37);
                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2952, __pyx_L828_error)
                  } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                  } else {
                    __Pyx_XGOTREF(__pyx_r);
                    __PYX_ERR(0, 2952, __pyx_L828_error)
                  }

                  /* "ws_package/controllers/activity_controller.py":2953
 *                             logger.info("Skipping exception recovery save - interval %s to %s already exists in DB (avoid duplicate)", start_date, end_date)
 *                             await asyncio.sleep(5)
 *                             continue             # <<<<<<<<<<<<<<
 *                         logger.warning("Attempting to save interval %s to %s after exception", start_date, end_date)
 *                         minimal_activity = {'mouse': '0.0', 'average': '0.0', 'keyboard': '0.0'}
*/
                  goto __pyx_L834_try_continue;

                  /* "ws_package/controllers/activity_controller.py":2950
 *                         except Exception:
 *                             pass
 *                         if await self.activity_service.check_existing_interval(start_date, end_date, exact=True):             # <<<<<<<<<<<<<<
 *                             logger.info("Skipping exception recovery save - interval %s to %s already exists in DB (avoid duplicate)", start_date, end_date)
 *                             await asyncio.sleep(5)
*/
                }

                /* "ws_package/controllers/activity_controller.py":2954
 *                             await asyncio.sleep(5)
 *                             continue
 *                         logger.warning("Attempting to save interval %s to %s after exception", start_date, end_date)             # <<<<<<<<<<<<<<
 *                         minimal_activity = {'mouse': '0.0', 'average': '0.0', 'keyboard': '0.0'}
 *                         if await self.inrange(start_date, end_date) and self.status == True:
*/
                __pyx_t_6 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2954, __pyx_L828_error)
                __Pyx_GOTREF(__pyx_t_15);
                __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2954, __pyx_L828_error)
                __Pyx_GOTREF(__pyx_t_5);
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                if (unlikely(!__pyx_cur_scope->__pyx_v_start_date)) { __Pyx_RaiseUnboundLocalError("start_date"); __PYX_ERR(0, 2954, __pyx_L828_error) }
                if (unlikely(!__pyx_cur_scope->__pyx_v_end_date)) { __Pyx_RaiseUnboundLocalError("end_date"); __PYX_ERR(0, 2954, __pyx_L828_error) }
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_5))) {
                  __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
                  assert(__pyx_t_6);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                  __Pyx_INCREF(__pyx_t_6);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[4] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Attempting_to_save_interval_s_to, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
                  __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2954, __pyx_L828_error)
                  __Pyx_GOTREF(__pyx_t_4);
                }
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                /* "ws_package/controllers/activity_controller.py":2955
 *                             continue
 *                         logger.warning("Attempting to save interval %s to %s after exception", start_date, end_date)
 *                         minimal_activity = {'mouse': '0.0', 'average': '0.0', 'keyboard': '0.0'}             # <<<<<<<<<<<<<<
 *                         if await self.inrange(start_date, end_date) and self.status == True:
 *                             await self.activity_service.save_activity_log(minimal_activity, start_date, end_date, self.last_count+1, self.get_today_weekday(), has_on_demand_screenshot=self.has_on_demand)
*/
                __pyx_t_4 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2955, __pyx_L828_error)
                __Pyx_GOTREF(__pyx_t_4);
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_mouse, __pyx_mstate_global->__pyx_kp_u_0_0) < (0)) __PYX_ERR(0, 2955, __pyx_L828_error)
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_average, __pyx_mstate_global->__pyx_kp_u_0_0) < (0)) __PYX_ERR(0, 2955, __pyx_L828_error)
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_keyboard, __pyx_mstate_global->__pyx_kp_u_0_0) < (0)) __PYX_ERR(0, 2955, __pyx_L828_error)
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_minimal_activity);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_minimal_activity, ((PyObject*)__pyx_t_4));
                __Pyx_GIVEREF(__pyx_t_4);
                __pyx_t_4 = 0;

                /* "ws_package/controllers/activity_controller.py":2956
 *                         logger.warning("Attempting to save interval %s to %s after exception", start_date, end_date)
 *                         minimal_activity = {'mouse': '0.0', 'average': '0.0', 'keyboard': '0.0'}
 *                         if await self.inrange(start_date, end_date) and self.status == True:             # <<<<<<<<<<<<<<
 *                             await self.activity_service.save_activity_log(minimal_activity, start_date, end_date, self.last_count+1, self.get_today_weekday(), has_on_demand_screenshot=self.has_on_demand)
 *                         else:
*/
                __pyx_t_5 = __pyx_cur_scope->__pyx_v_self;
                __Pyx_INCREF(__pyx_t_5);
                if (unlikely(!__pyx_cur_scope->__pyx_v_start_date)) { __Pyx_RaiseUnboundLocalError("start_date"); __PYX_ERR(0, 2956, __pyx_L828_error) }
                if (unlikely(!__pyx_cur_scope->__pyx_v_end_date)) { __Pyx_RaiseUnboundLocalError("end_date"); __PYX_ERR(0, 2956, __pyx_L828_error) }
                __pyx_t_7 = 0;
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
                  __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_inrange, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2956, __pyx_L828_error)
                  __Pyx_GOTREF(__pyx_t_4);
                }
                __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_3);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
                  __pyx_cur_scope->__pyx_t_19 = __pyx_t_8;
                  __Pyx_XGIVEREF(__pyx_t_11);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_11;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_18;
                  __Pyx_XGIVEREF(__pyx_t_20);
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_20;
                  __Pyx_XGIVEREF(__pyx_t_21);
                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_21;
                  __Pyx_XGIVEREF(__pyx_t_33);
                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_33;
                  __Pyx_XGIVEREF(__pyx_t_37);
                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_37;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_SwapException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 61;
                  return __pyx_r;
                  __pyx_L858_resume_from_await:;
                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_3);
                  __pyx_t_8 = __pyx_cur_scope->__pyx_t_19;
                  __pyx_t_11 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_11);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  __pyx_t_18 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_18);
                  __pyx_t_20 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = 0;
                  __Pyx_XGOTREF(__pyx_t_20);
                  __pyx_t_21 = __pyx_cur_scope->__pyx_t_6;
                  __pyx_cur_scope->__pyx_t_6 = 0;
                  __Pyx_XGOTREF(__pyx_t_21);
                  __pyx_t_33 = __pyx_cur_scope->__pyx_t_7;
                  __pyx_cur_scope->__pyx_t_7 = 0;
                  __Pyx_XGOTREF(__pyx_t_33);
                  __pyx_t_37 = __pyx_cur_scope->__pyx_t_8;
                  __pyx_cur_scope->__pyx_t_8 = 0;
                  __Pyx_XGOTREF(__pyx_t_37);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2956, __pyx_L828_error)
                  __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 2956, __pyx_L828_error)
                }
                __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2956, __pyx_L828_error)
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                if (__pyx_t_9) {
                } else {
                  __pyx_t_8 = __pyx_t_9;
                  goto __pyx_L856_bool_binop_done;
                }
                __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2956, __pyx_L828_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_t_5 = PyObject_RichCompare(__pyx_t_4, Py_True, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2956, __pyx_L828_error)
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 2956, __pyx_L828_error)
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __pyx_t_8 = __pyx_t_9;
                __pyx_L856_bool_binop_done:;
                if (__pyx_t_8) {

                  /* "ws_package/controllers/activity_controller.py":2957
 *                         minimal_activity = {'mouse': '0.0', 'average': '0.0', 'keyboard': '0.0'}
 *                         if await self.inrange(start_date, end_date) and self.status == True:
 *                             await self.activity_service.save_activity_log(minimal_activity, start_date, end_date, self.last_count+1, self.get_today_weekday(), has_on_demand_screenshot=self.has_on_demand)             # <<<<<<<<<<<<<<
 *                         else:
 *                             await self.activity_service.save_first_activity_log(minimal_activity, start_date, end_date, self.last_count+1, self.get_today_weekday(), has_on_demand_screenshot=self.has_on_demand)
*/
                  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2957, __pyx_L828_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  __pyx_t_4 = __pyx_t_6;
                  __Pyx_INCREF(__pyx_t_4);
                  if (unlikely(!__pyx_cur_scope->__pyx_v_start_date)) { __Pyx_RaiseUnboundLocalError("start_date"); __PYX_ERR(0, 2957, __pyx_L828_error) }
                  if (unlikely(!__pyx_cur_scope->__pyx_v_end_date)) { __Pyx_RaiseUnboundLocalError("end_date"); __PYX_ERR(0, 2957, __pyx_L828_error) }
                  __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2957, __pyx_L828_error)
                  __Pyx_GOTREF(__pyx_t_15);
                  __pyx_t_34 = __Pyx_PyLong_AddObjC(__pyx_t_15, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2957, __pyx_L828_error)
                  __Pyx_GOTREF(__pyx_t_34);
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self;
                  __Pyx_INCREF(__pyx_t_1);
                  __pyx_t_7 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
                    __pyx_t_15 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_today_weekday, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                    if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2957, __pyx_L828_error)
                    __Pyx_GOTREF(__pyx_t_15);
                  }
                  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_has_on_demand); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2957, __pyx_L828_error)
                  __Pyx_GOTREF(__pyx_t_1);
                  __pyx_t_7 = 0;
                  {
                    PyObject *__pyx_callargs[6 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_minimal_activity, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date, __pyx_t_34, __pyx_t_15};
                    __pyx_t_2 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2957, __pyx_L828_error)
                    __Pyx_GOTREF(__pyx_t_2);
                    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_has_on_demand_screenshot, __pyx_t_1, __pyx_t_2, __pyx_callargs+6, 0) < (0)) __PYX_ERR(0, 2957, __pyx_L828_error)
                    __pyx_t_5 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_save_activity_log, __pyx_callargs+__pyx_t_7, (6-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_2);
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2957, __pyx_L828_error)
                    __Pyx_GOTREF(__pyx_t_5);
                  }
                  __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_XGIVEREF(__pyx_t_3);
                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
                    __Pyx_XGIVEREF(__pyx_t_11);
                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_11;
                    __Pyx_XGIVEREF(__pyx_t_12);
                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_12;
                    __Pyx_XGIVEREF(__pyx_t_13);
                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_13;
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_18;
                    __Pyx_XGIVEREF(__pyx_t_20);
                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_20;
                    __Pyx_XGIVEREF(__pyx_t_21);
                    __pyx_cur_scope->__pyx_t_6 = __pyx_t_21;
                    __Pyx_XGIVEREF(__pyx_t_33);
                    __pyx_cur_scope->__pyx_t_7 = __pyx_t_33;
                    __Pyx_XGIVEREF(__pyx_t_37);
                    __pyx_cur_scope->__pyx_t_8 = __pyx_t_37;
                    __Pyx_XGIVEREF(__pyx_r);
                    __Pyx_RefNannyFinishContext();
                    __Pyx_Coroutine_SwapException(__pyx_generator);
                    /* return from generator, awaiting value */
                    __pyx_generator->resume_label = 62;
                    return __pyx_r;
                    __pyx_L859_resume_from_await:;
                    __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
                    __pyx_cur_scope->__pyx_t_0 = 0;
                    __Pyx_XGOTREF(__pyx_t_3);
                    __pyx_t_11 = __pyx_cur_scope->__pyx_t_1;
                    __pyx_cur_scope->__pyx_t_1 = 0;
                    __Pyx_XGOTREF(__pyx_t_11);
                    __pyx_t_12 = __pyx_cur_scope->__pyx_t_2;
                    __pyx_cur_scope->__pyx_t_2 = 0;
                    __Pyx_XGOTREF(__pyx_t_12);
                    __pyx_t_13 = __pyx_cur_scope->__pyx_t_3;
                    __pyx_cur_scope->__pyx_t_3 = 0;
                    __Pyx_XGOTREF(__pyx_t_13);
                    __pyx_t_18 = __pyx_cur_scope->__pyx_t_4;
                    __pyx_cur_scope->__pyx_t_4 = 0;
                    __Pyx_XGOTREF(__pyx_t_18);
                    __pyx_t_20 = __pyx_cur_scope->__pyx_t_5;
                    __pyx_cur_scope->__pyx_t_5 = 0;
                    __Pyx_XGOTREF(__pyx_t_20);
                    __pyx_t_21 = __pyx_cur_scope->__pyx_t_6;
                    __pyx_cur_scope->__pyx_t_6 = 0;
                    __Pyx_XGOTREF(__pyx_t_21);
                    __pyx_t_33 = __pyx_cur_scope->__pyx_t_7;
                    __pyx_cur_scope->__pyx_t_7 = 0;
                    __Pyx_XGOTREF(__pyx_t_33);
                    __pyx_t_37 = __pyx_cur_scope->__pyx_t_8;
                    __pyx_cur_scope->__pyx_t_8 = 0;
                    __Pyx_XGOTREF(__pyx_t_37);
                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2957, __pyx_L828_error)
                  } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                  } else {
                    __Pyx_XGOTREF(__pyx_r);
                    __PYX_ERR(0, 2957, __pyx_L828_error)
                  }

                  /* "ws_package/controllers/activity_controller.py":2956
 *                         logger.warning("Attempting to save interval %s to %s after exception", start_date, end_date)
 *                         minimal_activity = {'mouse': '0.0', 'average': '0.0', 'keyboard': '0.0'}
 *                         if await self.inrange(start_date, end_date) and self.status == True:             # <<<<<<<<<<<<<<
 *                             await self.activity_service.save_activity_log(minimal_activity, start_date, end_date, self.last_count+1, self.get_today_weekday(), has_on_demand_screenshot=self.has_on_demand)
 *                         else:
*/
                  goto __pyx_L855;
                }

                /* "ws_package/controllers/activity_controller.py":2959
 *                             await self.activity_service.save_activity_log(minimal_activity, start_date, end_date, self.last_count+1, self.get_today_weekday(), has_on_demand_screenshot=self.has_on_demand)
 *                         else:
 *                             await self.activity_service.save_first_activity_log(minimal_activity, start_date, end_date, self.last_count+1, self.get_today_weekday(), has_on_demand_screenshot=self.has_on_demand)             # <<<<<<<<<<<<<<
 *                         logger.info("Successfully saved interval after exception recovery")
 *                         self.has_on_demand = False
*/
                /*else*/ {
                  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2959, __pyx_L828_error)
                  __Pyx_GOTREF(__pyx_t_2);
                  __pyx_t_6 = __pyx_t_2;
                  __Pyx_INCREF(__pyx_t_6);
                  if (unlikely(!__pyx_cur_scope->__pyx_v_start_date)) { __Pyx_RaiseUnboundLocalError("start_date"); __PYX_ERR(0, 2959, __pyx_L828_error) }
                  if (unlikely(!__pyx_cur_scope->__pyx_v_end_date)) { __Pyx_RaiseUnboundLocalError("end_date"); __PYX_ERR(0, 2959, __pyx_L828_error) }
                  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2959, __pyx_L828_error)
                  __Pyx_GOTREF(__pyx_t_1);
                  __pyx_t_15 = __Pyx_PyLong_AddObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2959, __pyx_L828_error)
                  __Pyx_GOTREF(__pyx_t_15);
                  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                  __pyx_t_34 = __pyx_cur_scope->__pyx_v_self;
                  __Pyx_INCREF(__pyx_t_34);
                  __pyx_t_7 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_34, NULL};
                    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_today_weekday, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2959, __pyx_L828_error)
                    __Pyx_GOTREF(__pyx_t_1);
                  }
                  __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_has_on_demand); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2959, __pyx_L828_error)
                  __Pyx_GOTREF(__pyx_t_34);
                  __pyx_t_7 = 0;
                  {
                    PyObject *__pyx_callargs[6 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_6, __pyx_cur_scope->__pyx_v_minimal_activity, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date, __pyx_t_15, __pyx_t_1};
                    __pyx_t_4 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2959, __pyx_L828_error)
                    __Pyx_GOTREF(__pyx_t_4);
                    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_has_on_demand_screenshot, __pyx_t_34, __pyx_t_4, __pyx_callargs+6, 0) < (0)) __PYX_ERR(0, 2959, __pyx_L828_error)
                    __pyx_t_5 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_save_first_activity_log, __pyx_callargs+__pyx_t_7, (6-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_4);
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2959, __pyx_L828_error)
                    __Pyx_GOTREF(__pyx_t_5);
                  }
                  __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_XGIVEREF(__pyx_t_3);
                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
                    __Pyx_XGIVEREF(__pyx_t_11);
                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_11;
                    __Pyx_XGIVEREF(__pyx_t_12);
                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_12;
                    __Pyx_XGIVEREF(__pyx_t_13);
                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_13;
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_18;
                    __Pyx_XGIVEREF(__pyx_t_20);
                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_20;
                    __Pyx_XGIVEREF(__pyx_t_21);
                    __pyx_cur_scope->__pyx_t_6 = __pyx_t_21;
                    __Pyx_XGIVEREF(__pyx_t_33);
                    __pyx_cur_scope->__pyx_t_7 = __pyx_t_33;
                    __Pyx_XGIVEREF(__pyx_t_37);
                    __pyx_cur_scope->__pyx_t_8 = __pyx_t_37;
                    __Pyx_XGIVEREF(__pyx_r);
                    __Pyx_RefNannyFinishContext();
                    __Pyx_Coroutine_SwapException(__pyx_generator);
                    /* return from generator, awaiting value */
                    __pyx_generator->resume_label = 63;
                    return __pyx_r;
                    __pyx_L860_resume_from_await:;
                    __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
                    __pyx_cur_scope->__pyx_t_0 = 0;
                    __Pyx_XGOTREF(__pyx_t_3);
                    __pyx_t_11 = __pyx_cur_scope->__pyx_t_1;
                    __pyx_cur_scope->__pyx_t_1 = 0;
                    __Pyx_XGOTREF(__pyx_t_11);
                    __pyx_t_12 = __pyx_cur_scope->__pyx_t_2;
                    __pyx_cur_scope->__pyx_t_2 = 0;
                    __Pyx_XGOTREF(__pyx_t_12);
                    __pyx_t_13 = __pyx_cur_scope->__pyx_t_3;
                    __pyx_cur_scope->__pyx_t_3 = 0;
                    __Pyx_XGOTREF(__pyx_t_13);
                    __pyx_t_18 = __pyx_cur_scope->__pyx_t_4;
                    __pyx_cur_scope->__pyx_t_4 = 0;
                    __Pyx_XGOTREF(__pyx_t_18);
                    __pyx_t_20 = __pyx_cur_scope->__pyx_t_5;
                    __pyx_cur_scope->__pyx_t_5 = 0;
                    __Pyx_XGOTREF(__pyx_t_20);
                    __pyx_t_21 = __pyx_cur_scope->__pyx_t_6;
                    __pyx_cur_scope->__pyx_t_6 = 0;
                    __Pyx_XGOTREF(__pyx_t_21);
                    __pyx_t_33 = __pyx_cur_scope->__pyx_t_7;
                    __pyx_cur_scope->__pyx_t_7 = 0;
                    __Pyx_XGOTREF(__pyx_t_33);
                    __pyx_t_37 = __pyx_cur_scope->__pyx_t_8;
                    __pyx_cur_scope->__pyx_t_8 = 0;
                    __Pyx_XGOTREF(__pyx_t_37);
                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2959, __pyx_L828_error)
                  } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                  } else {
                    __Pyx_XGOTREF(__pyx_r);
                    __PYX_ERR(0, 2959, __pyx_L828_error)
                  }
                }
                __pyx_L855:;

                /* "ws_package/controllers/activity_controller.py":2960
 *                         else:
 *                             await self.activity_service.save_first_activity_log(minimal_activity, start_date, end_date, self.last_count+1, self.get_today_weekday(), has_on_demand_screenshot=self.has_on_demand)
 *                         logger.info("Successfully saved interval after exception recovery")             # <<<<<<<<<<<<<<
 *                         self.has_on_demand = False
 *                 except Exception as recovery_error:
*/
                __pyx_t_2 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2960, __pyx_L828_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 2960, __pyx_L828_error)
                __Pyx_GOTREF(__pyx_t_34);
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_34))) {
                  __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_34);
                  assert(__pyx_t_2);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_34);
                  __Pyx_INCREF(__pyx_t_2);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_34, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Successfully_saved_interval_afte};
                  __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_34, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                  __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2960, __pyx_L828_error)
                  __Pyx_GOTREF(__pyx_t_5);
                }
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                /* "ws_package/controllers/activity_controller.py":2961
 *                             await self.activity_service.save_first_activity_log(minimal_activity, start_date, end_date, self.last_count+1, self.get_today_weekday(), has_on_demand_screenshot=self.has_on_demand)
 *                         logger.info("Successfully saved interval after exception recovery")
 *                         self.has_on_demand = False             # <<<<<<<<<<<<<<
 *                 except Exception as recovery_error:
 *                     logger.error("Failed to save interval during exception recovery: %s", recovery_error, exc_info=True)
*/
                if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_has_on_demand, Py_False) < (0)) __PYX_ERR(0, 2961, __pyx_L828_error)

                /* "ws_package/controllers/activity_controller.py":2936
 *                 # Attempt to persist the interval even after unexpected errors (only if not already saved)
 *                 try:
 *                     if 'start_date' in locals() and 'end_date' in locals():             # <<<<<<<<<<<<<<
 *                         start_sec = start_date.replace(microsecond=0)
 *                         end_sec = end_date.replace(microsecond=0)
*/
              }

              /* "ws_package/controllers/activity_controller.py":2935
 * 
 *                 # Attempt to persist the interval even after unexpected errors (only if not already saved)
 *                 try:             # <<<<<<<<<<<<<<
 *                     if 'start_date' in locals() and 'end_date' in locals():
 *                         start_sec = start_date.replace(microsecond=0)
*/
            }
            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
            __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            goto __pyx_L835_try_end;
            __pyx_L828_error:;
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
            __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
            __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
            __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

            /* "ws_package/controllers/activity_controller.py":2962
 *                         logger.info("Successfully saved interval after exception recovery")
 *                         self.has_on_demand = False
 *                 except Exception as recovery_error:             # <<<<<<<<<<<<<<
 *                     logger.error("Failed to save interval during exception recovery: %s", recovery_error, exc_info=True)
 * 
*/
            __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
            if (__pyx_t_14) {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_34, &__pyx_t_2) < 0) __PYX_ERR(0, 2962, __pyx_L830_except_error)
              __Pyx_XGOTREF(__pyx_t_5);
              __Pyx_XGOTREF(__pyx_t_34);
              __Pyx_XGOTREF(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_34);
              __Pyx_GIVEREF(__pyx_t_34);
              __pyx_cur_scope->__pyx_v_recovery_error = __pyx_t_34;
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":2963
 *                         self.has_on_demand = False
 *                 except Exception as recovery_error:
 *                     logger.error("Failed to save interval during exception recovery: %s", recovery_error, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *                 # Continue the loop even if there's an error
*/
                __pyx_t_1 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2963, __pyx_L866_error)
                __Pyx_GOTREF(__pyx_t_15);
                __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2963, __pyx_L866_error)
                __Pyx_GOTREF(__pyx_t_6);
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_6))) {
                  __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_6);
                  assert(__pyx_t_1);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                  __Pyx_INCREF(__pyx_t_1);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Failed_to_save_interval_during_e, __pyx_cur_scope->__pyx_v_recovery_error};
                  __pyx_t_15 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2963, __pyx_L866_error)
                  __Pyx_GOTREF(__pyx_t_15);
                  if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_15, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 2963, __pyx_L866_error)
                  __pyx_t_4 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_15);
                  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2963, __pyx_L866_error)
                  __Pyx_GOTREF(__pyx_t_4);
                }
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              }

              /* "ws_package/controllers/activity_controller.py":2962
 *                         logger.info("Successfully saved interval after exception recovery")
 *                         self.has_on_demand = False
 *                 except Exception as recovery_error:             # <<<<<<<<<<<<<<
 *                     logger.error("Failed to save interval during exception recovery: %s", recovery_error, exc_info=True)
 * 
*/
              /*finally:*/ {
                /*normal exit:*/{
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_recovery_error);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_recovery_error); __pyx_cur_scope->__pyx_v_recovery_error = 0;
                  goto __pyx_L867;
                }
                __pyx_L866_error:;
                /*exception exit:*/{
                  __Pyx_PyThreadState_assign
                  __pyx_t_39 = 0; __pyx_t_23 = 0; __pyx_t_31 = 0; __pyx_t_46 = 0; __pyx_t_47 = 0; __pyx_t_48 = 0;
                  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                  __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                  __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                   __Pyx_ExceptionSwap(&__pyx_t_46, &__pyx_t_47, &__pyx_t_48);
                  if ( unlikely(__Pyx_GetException(&__pyx_t_39, &__pyx_t_23, &__pyx_t_31) < 0)) __Pyx_ErrFetch(&__pyx_t_39, &__pyx_t_23, &__pyx_t_31);
                  __Pyx_XGOTREF(__pyx_t_39);
                  __Pyx_XGOTREF(__pyx_t_23);
                  __Pyx_XGOTREF(__pyx_t_31);
                  __Pyx_XGOTREF(__pyx_t_46);
                  __Pyx_XGOTREF(__pyx_t_47);
                  __Pyx_XGOTREF(__pyx_t_48);
                  __pyx_t_14 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_64 = __pyx_filename;
                  {
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_recovery_error);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_recovery_error); __pyx_cur_scope->__pyx_v_recovery_error = 0;
                  }
                  __Pyx_XGIVEREF(__pyx_t_46);
                  __Pyx_XGIVEREF(__pyx_t_47);
                  __Pyx_XGIVEREF(__pyx_t_48);
                  __Pyx_ExceptionReset(__pyx_t_46, __pyx_t_47, __pyx_t_48);
                  __Pyx_XGIVEREF(__pyx_t_39);
                  __Pyx_XGIVEREF(__pyx_t_23);
                  __Pyx_XGIVEREF(__pyx_t_31);
                  __Pyx_ErrRestore(__pyx_t_39, __pyx_t_23, __pyx_t_31);
                  __pyx_t_39 = 0; __pyx_t_23 = 0; __pyx_t_31 = 0; __pyx_t_46 = 0; __pyx_t_47 = 0; __pyx_t_48 = 0;
                  __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_64;
                  goto __pyx_L830_except_error;
                }
                __pyx_L867:;
              }
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              goto __pyx_L829_exception_handled;
            }
            goto __pyx_L830_except_error;

            /* "ws_package/controllers/activity_controller.py":2935
 * 
 *                 # Attempt to persist the interval even after unexpected errors (only if not already saved)
 *                 try:             # <<<<<<<<<<<<<<
 *                     if 'start_date' in locals() and 'end_date' in locals():
 *                         start_sec = start_date.replace(microsecond=0)
*/
            __pyx_L830_except_error:;
            __Pyx_XGIVEREF(__pyx_t_20);
            __Pyx_XGIVEREF(__pyx_t_21);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_18);
            goto __pyx_L826_error;
            __pyx_L834_try_continue:;
            __Pyx_XGIVEREF(__pyx_t_20);
            __Pyx_XGIVEREF(__pyx_t_21);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_18);
            goto __pyx_L823_continue;
            __pyx_L829_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_20);
            __Pyx_XGIVEREF(__pyx_t_21);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_18);
            __pyx_L835_try_end:;
          }

          /* "ws_package/controllers/activity_controller.py":2966
 * 
 *                 # Continue the loop even if there's an error
 *                 await asyncio.sleep(5)  # Brief pause before retrying             # <<<<<<<<<<<<<<
 *                 continue
 * 
*/
          __pyx_t_34 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2966, __pyx_L826_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2966, __pyx_L826_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_7 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_4))) {
            __pyx_t_34 = PyMethod_GET_SELF(__pyx_t_4);
            assert(__pyx_t_34);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_34);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
            __pyx_t_7 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_34, __pyx_mstate_global->__pyx_int_5};
            __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2966, __pyx_L826_error)
            __Pyx_GOTREF(__pyx_t_2);
          }
          __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_2, &__pyx_r);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (likely(__pyx_t_26 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_3);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
            __Pyx_XGIVEREF(__pyx_t_11);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_11;
            __Pyx_XGIVEREF(__pyx_t_12);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_12;
            __Pyx_XGIVEREF(__pyx_t_13);
            __pyx_cur_scope->__pyx_t_3 = __pyx_t_13;
            __Pyx_XGIVEREF(__pyx_t_33);
            __pyx_cur_scope->__pyx_t_4 = __pyx_t_33;
            __Pyx_XGIVEREF(__pyx_t_37);
            __pyx_cur_scope->__pyx_t_5 = __pyx_t_37;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_SwapException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 64;
            return __pyx_r;
            __pyx_L872_resume_from_await:;
            __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_3);
            __pyx_t_11 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_11);
            __pyx_t_12 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_12);
            __pyx_t_13 = __pyx_cur_scope->__pyx_t_3;
            __pyx_cur_scope->__pyx_t_3 = 0;
            __Pyx_XGOTREF(__pyx_t_13);
            __pyx_t_33 = __pyx_cur_scope->__pyx_t_4;
            __pyx_cur_scope->__pyx_t_4 = 0;
            __Pyx_XGOTREF(__pyx_t_33);
            __pyx_t_37 = __pyx_cur_scope->__pyx_t_5;
            __pyx_cur_scope->__pyx_t_5 = 0;
            __Pyx_XGOTREF(__pyx_t_37);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2966, __pyx_L826_error)
          } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_DECREF(__pyx_r); __pyx_r = 0;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 2966, __pyx_L826_error)
          }

          /* "ws_package/controllers/activity_controller.py":2967
 *                 # Continue the loop even if there's an error
 *                 await asyncio.sleep(5)  # Brief pause before retrying
 *                 continue             # <<<<<<<<<<<<<<
 * 
 *     async def empty_interval(self, user_entity: UserEntity):
*/
          goto __pyx_L823_continue;
        }

        /* "ws_package/controllers/activity_controller.py":2931
 *                     break
 * 
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 logger.exception("Error in device activity loop", exc_info=True)
 * 
*/
        /*finally:*/ {
          __pyx_L826_error:;
          /*exception exit:*/{
            __Pyx_PyThreadState_assign
            __pyx_t_18 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_48 = 0; __pyx_t_47 = 0; __pyx_t_46 = 0;
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
            __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
            __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
            __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
             __Pyx_ExceptionSwap(&__pyx_t_48, &__pyx_t_47, &__pyx_t_46);
            if ( unlikely(__Pyx_GetException(&__pyx_t_18, &__pyx_t_21, &__pyx_t_20) < 0)) __Pyx_ErrFetch(&__pyx_t_18, &__pyx_t_21, &__pyx_t_20);
            __Pyx_XGOTREF(__pyx_t_18);
            __Pyx_XGOTREF(__pyx_t_21);
            __Pyx_XGOTREF(__pyx_t_20);
            __Pyx_XGOTREF(__pyx_t_48);
            __Pyx_XGOTREF(__pyx_t_47);
            __Pyx_XGOTREF(__pyx_t_46);
            __pyx_t_16 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_65 = __pyx_filename;
            {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
            }
            __Pyx_XGIVEREF(__pyx_t_48);
            __Pyx_XGIVEREF(__pyx_t_47);
            __Pyx_XGIVEREF(__pyx_t_46);
            __Pyx_ExceptionReset(__pyx_t_48, __pyx_t_47, __pyx_t_46);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_XGIVEREF(__pyx_t_21);
            __Pyx_XGIVEREF(__pyx_t_20);
            __Pyx_ErrRestore(__pyx_t_18, __pyx_t_21, __pyx_t_20);
            __pyx_t_18 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_48 = 0; __pyx_t_47 = 0; __pyx_t_46 = 0;
            __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_65;
            goto __pyx_L265_except_error;
          }
          __pyx_L823_continue: {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
            goto __pyx_L821_except_continue;
          }
        }
        __pyx_L821_except_continue:;
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
        goto __pyx_L269_try_continue;
      }
      goto __pyx_L265_except_error;

      /* "ws_package/controllers/activity_controller.py":2181
 *                 self._break_monitoring_logged = False
 * 
 *             try:             # <<<<<<<<<<<<<<
 *                 logger.debug("[Timing][Python] Inside main activity loop")
 *                 logger.info("Current Interval Status: %s Screenshot Interval frequency: %s App and URL Status: %s Blur Intensity: %s", self.interval, self.screenshot_interval, self.appandurlstatus, self.blur_intensity)
*/
      __pyx_L265_except_error:;
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_12, __pyx_t_11);
      goto __pyx_L1_error;
      __pyx_L268_try_break:;
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_12, __pyx_t_11);
      goto __pyx_L204_break;
      __pyx_L269_try_continue:;
      __Pyx_XGIVEREF(__pyx_t_13);
      __Pyx_XGIVEREF(__pyx_t_12);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_12, __pyx_t_11);
      goto __pyx_L203_continue;
      __pyx_L270_try_end:;
    }
    __pyx_L203_continue:;
  }
  __pyx_L204_break:;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":1686
 *         logger.info("Minute activity timer stopped")
 * 
 *     async def __start_device_activity(self, user_entity:UserEntity, stop_event):             # <<<<<<<<<<<<<<
 * 
 *         # Update start_date to actual timer start time (when user clicks Start)
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_33);
  __Pyx_XDECREF(__pyx_t_34);
  __Pyx_XDECREF(__pyx_t_35);
  __Pyx_XDECREF(__pyx_t_36);
  __Pyx_XDECREF(__pyx_t_37);
  __Pyx_XDECREF(__pyx_t_38);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("__start_device_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_105generator21(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":2969
 *                 continue
 * 
 *     async def empty_interval(self, user_entity: UserEntity):             # <<<<<<<<<<<<<<
 *         logger.info("Running push empty intervals")
 *         current = self.last_count + 1
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_104empty_interval(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_104empty_interval = {"empty_interval", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_104empty_interval, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_104empty_interval(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  CYTHON_UNUSED PyObject *__pyx_v_user_entity = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("empty_interval (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_user_entity,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 2969, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 2969, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 2969, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "empty_interval", 0) < (0)) __PYX_ERR(0, 2969, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("empty_interval", 1, 2, 2, i); __PYX_ERR(0, 2969, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 2969, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 2969, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_user_entity = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("empty_interval", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 2969, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.empty_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_103empty_interval(__pyx_self, __pyx_v_self, __pyx_v_user_entity);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_14empty_interval_2generator62(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":2997
 *             # slot intervals and uploaded like regular activity  no session stop/open.
 *             if gap_seconds > 3600 and not is_silent_build():
 *                 total_fill_seconds = sum((e - s).total_seconds() for s, e in sub_segments)             # <<<<<<<<<<<<<<
 *                 logger.info(
 *                     "Sleep gap > 1 hour (gap_seconds=%.0f, fill_seconds=%.0f) - "
*/

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_14empty_interval_genexpr(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 2997, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_14empty_interval_2generator62, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[36]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_genexpr, __pyx_mstate_global->__pyx_n_u_ActivityController_empty_interva, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 2997, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.empty_interval.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_14empty_interval_2generator62(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *(*__pyx_t_8)(PyObject *);
  size_t __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L8_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started generator");
    __PYX_ERR(0, 2997, __pyx_L1_error)
  }
  if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 2997, __pyx_L1_error) }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1);
    __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_genexpr_arg_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2997, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2997, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2997, __pyx_L1_error)
          #endif
          if (__pyx_t_2 >= __pyx_temp) break;
        }
        __pyx_t_4 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_1, __pyx_t_2, __Pyx_ReferenceSharing_OwnStrongReference);
        ++__pyx_t_2;
      } else {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2997, __pyx_L1_error)
          #endif
          if (__pyx_t_2 >= __pyx_temp) break;
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2));
        #else
        __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2);
        #endif
        ++__pyx_t_2;
      }
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2997, __pyx_L1_error)
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 2997, __pyx_L1_error)
          PyErr_Clear();
        }
        break;
      }
    }
    __Pyx_GOTREF(__pyx_t_4);
    if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
      PyObject* sequence = __pyx_t_4;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 2997, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0);
        __Pyx_INCREF(__pyx_t_5);
        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1);
        __Pyx_INCREF(__pyx_t_6);
      } else {
        __pyx_t_5 = __Pyx_PyList_GET_ITEM_REF(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2997, __pyx_L1_error)
        __Pyx_XGOTREF(__pyx_t_5);
        __pyx_t_6 = __Pyx_PyList_GET_ITEM_REF(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2997, __pyx_L1_error)
        __Pyx_XGOTREF(__pyx_t_6);
      }
      #else
      __pyx_t_5 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2997, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 2997, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      #endif
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 2997, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_8 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_7);
      index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_5);
      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_6);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < (0)) __PYX_ERR(0, 2997, __pyx_L1_error)
      __pyx_t_8 = NULL;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L7_unpacking_done;
      __pyx_L6_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 2997, __pyx_L1_error)
      __pyx_L7_unpacking_done:;
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_s);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_s, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_6);
    __pyx_t_6 = 0;
    __pyx_t_5 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_e, __pyx_cur_scope->__pyx_v_s); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 2997, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __pyx_t_5;
    __Pyx_INCREF(__pyx_t_6);
    __pyx_t_9 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
      __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_total_seconds, __pyx_callargs+__pyx_t_9, (1-__pyx_t_9) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2997, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    }
    __pyx_r = __pyx_t_4;
    __pyx_t_4 = 0;
    __Pyx_XGIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L8_resume_from_yield:;
    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
    __pyx_cur_scope->__pyx_t_0 = 0;
    __Pyx_XGOTREF(__pyx_t_1);
    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2997, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":2969
 *                 continue
 * 
 *     async def empty_interval(self, user_entity: UserEntity):             # <<<<<<<<<<<<<<
 *         logger.info("Running push empty intervals")
 *         current = self.last_count + 1
*/

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_103empty_interval(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_user_entity) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval *__pyx_cur_scope;
  PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_14empty_interval_2generator62 = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("empty_interval", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 2969, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_user_entity = __pyx_v_user_entity;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_user_entity);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_user_entity);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_105generator21, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[37]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_empty_interval, __pyx_mstate_global->__pyx_n_u_ActivityController_empty_interva_2, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 2969, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.empty_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XDECREF(__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_14empty_interval_2generator62);
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_105generator21(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  __Pyx_PySendResult __pyx_t_6;
  Py_ssize_t __pyx_t_7;
  int __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  PyObject *__pyx_t_10 = NULL;
  PyObject *(*__pyx_t_11)(PyObject *);
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14[5];
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16[6];
  PyObject *__pyx_t_17 = NULL;
  int __pyx_t_18;
  Py_ssize_t __pyx_t_19;
  PyObject *(*__pyx_t_20)(PyObject *);
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  int __pyx_t_24;
  int __pyx_t_25;
  char const *__pyx_t_26;
  PyObject *__pyx_t_27 = NULL;
  PyObject *__pyx_t_28 = NULL;
  PyObject *__pyx_t_29 = NULL;
  PyObject *__pyx_t_30 = NULL;
  PyObject *__pyx_t_31 = NULL;
  PyObject *__pyx_t_32 = NULL;
  PyObject *__pyx_t_33[4];
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("empty_interval", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L4_resume_from_await;
    case 2: goto __pyx_L10_resume_from_await;
    case 3: goto __pyx_L20_resume_from_await;
    case 4: goto __pyx_L21_resume_from_await;
    case 5: goto __pyx_L52_resume_from_await;
    case 6: goto __pyx_L53_resume_from_await;
    case 7: goto __pyx_L57_resume_from_await;
    case 8: goto __pyx_L58_resume_from_await;
    case 9: goto __pyx_L59_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 2969, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":2970
 * 
 *     async def empty_interval(self, user_entity: UserEntity):
 *         logger.info("Running push empty intervals")             # <<<<<<<<<<<<<<
 *         current = self.last_count + 1
 *         missing_intervals = await self.find_missing_timestamps(current)
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2970, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2970, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Running_push_empty_intervals};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2970, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":2971
 *     async def empty_interval(self, user_entity: UserEntity):
 *         logger.info("Running push empty intervals")
 *         current = self.last_count + 1             # <<<<<<<<<<<<<<
 *         missing_intervals = await self.find_missing_timestamps(current)
 *         missing_intervals = self._filter_gaps_before_session(missing_intervals)
*/
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2971, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyLong_AddObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2971, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_cur_scope->__pyx_v_current = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":2972
 *         logger.info("Running push empty intervals")
 *         current = self.last_count + 1
 *         missing_intervals = await self.find_missing_timestamps(current)             # <<<<<<<<<<<<<<
 *         missing_intervals = self._filter_gaps_before_session(missing_intervals)
 * 
*/
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_cur_scope->__pyx_v_current};
    __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_find_missing_timestamps, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2972, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  }
  __pyx_t_6 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (likely(__pyx_t_6 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L4_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2972, __pyx_L1_error)
    __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
  } else if (likely(__pyx_t_6 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __pyx_t_4 = __pyx_r; __pyx_r = NULL;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 2972, __pyx_L1_error)
  }
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_cur_scope->__pyx_v_missing_intervals = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":2973
 *         current = self.last_count + 1
 *         missing_intervals = await self.find_missing_timestamps(current)
 *         missing_intervals = self._filter_gaps_before_session(missing_intervals)             # <<<<<<<<<<<<<<
 * 
 *         if len(missing_intervals) == 0:
*/
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_cur_scope->__pyx_v_missing_intervals};
    __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_filter_gaps_before_session, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2973, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  }
  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_missing_intervals);
  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_missing_intervals, __pyx_t_4);
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":2975
 *         missing_intervals = self._filter_gaps_before_session(missing_intervals)
 * 
 *         if len(missing_intervals) == 0:             # <<<<<<<<<<<<<<
 *             logger.info("No missing intervals")
 *             return
*/
  __pyx_t_7 = PyObject_Length(__pyx_cur_scope->__pyx_v_missing_intervals); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 2975, __pyx_L1_error)
  __pyx_t_8 = (__pyx_t_7 == 0);
  if (__pyx_t_8) {

    /* "ws_package/controllers/activity_controller.py":2976
 * 
 *         if len(missing_intervals) == 0:
 *             logger.info("No missing intervals")             # <<<<<<<<<<<<<<
 *             return
 *         logger.info("System is in sleep: %s", missing_intervals)
*/
    __pyx_t_1 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2976, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2976, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_3))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
      assert(__pyx_t_1);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_No_missing_intervals};
      __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2976, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "ws_package/controllers/activity_controller.py":2977
 *         if len(missing_intervals) == 0:
 *             logger.info("No missing intervals")
 *             return             # <<<<<<<<<<<<<<
 *         logger.info("System is in sleep: %s", missing_intervals)
 * 
*/
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":2975
 *         missing_intervals = self._filter_gaps_before_session(missing_intervals)
 * 
 *         if len(missing_intervals) == 0:             # <<<<<<<<<<<<<<
 *             logger.info("No missing intervals")
 *             return
*/
  }

  /* "ws_package/controllers/activity_controller.py":2978
 *             logger.info("No missing intervals")
 *             return
 *         logger.info("System is in sleep: %s", missing_intervals)             # <<<<<<<<<<<<<<
 * 
 *         for gap_start, gap_end in missing_intervals:
*/
  __pyx_t_3 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2978, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2978, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_2))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
    assert(__pyx_t_3);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_System_is_in_sleep_s, __pyx_cur_scope->__pyx_v_missing_intervals};
    __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2978, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":2980
 *         logger.info("System is in sleep: %s", missing_intervals)
 * 
 *         for gap_start, gap_end in missing_intervals:             # <<<<<<<<<<<<<<
 *             overlapping = await self.get_intervals_overlapping_range(gap_start, gap_end)
 *             sub_segments = self._subtract_overlapping_intervals(gap_start, gap_end, overlapping)
*/
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_missing_intervals)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_missing_intervals)) {
    __pyx_t_4 = __pyx_cur_scope->__pyx_v_missing_intervals; __Pyx_INCREF(__pyx_t_4);
    __pyx_t_7 = 0;
    __pyx_t_9 = NULL;
  } else {
    __pyx_t_7 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_missing_intervals); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 2980, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_9 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 2980, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_9)) {
      if (likely(PyList_CheckExact(__pyx_t_4))) {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2980, __pyx_L1_error)
          #endif
          if (__pyx_t_7 >= __pyx_temp) break;
        }
        __pyx_t_2 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_4, __pyx_t_7, __Pyx_ReferenceSharing_OwnStrongReference);
        ++__pyx_t_7;
      } else {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 2980, __pyx_L1_error)
          #endif
          if (__pyx_t_7 >= __pyx_temp) break;
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_2 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_7));
        #else
        __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_7);
        #endif
        ++__pyx_t_7;
      }
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2980, __pyx_L1_error)
    } else {
      __pyx_t_2 = __pyx_t_9(__pyx_t_4);
      if (unlikely(!__pyx_t_2)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 2980, __pyx_L1_error)
          PyErr_Clear();
        }
        break;
      }
    }
    __Pyx_GOTREF(__pyx_t_2);
    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
      PyObject* sequence = __pyx_t_2;
      Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
      if (unlikely(size != 2)) {
        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
        __PYX_ERR(0, 2980, __pyx_L1_error)
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      if (likely(PyTuple_CheckExact(sequence))) {
        __pyx_t_3 = PyTuple_GET_ITEM(sequence, 0);
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1);
        __Pyx_INCREF(__pyx_t_1);
      } else {
        __pyx_t_3 = __Pyx_PyList_GET_ITEM_REF(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2980, __pyx_L1_error)
        __Pyx_XGOTREF(__pyx_t_3);
        __pyx_t_1 = __Pyx_PyList_GET_ITEM_REF(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2980, __pyx_L1_error)
        __Pyx_XGOTREF(__pyx_t_1);
      }
      #else
      __pyx_t_3 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2980, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_1 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2980, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      #endif
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    } else {
      Py_ssize_t index = -1;
      __pyx_t_10 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2980, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_11 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_10);
      index = 0; __pyx_t_3 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_3)) goto __pyx_L8_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_3);
      index = 1; __pyx_t_1 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_1)) goto __pyx_L8_unpacking_failed;
      __Pyx_GOTREF(__pyx_t_1);
      if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 2) < (0)) __PYX_ERR(0, 2980, __pyx_L1_error)
      __pyx_t_11 = NULL;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L9_unpacking_done;
      __pyx_L8_unpacking_failed:;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_11 = NULL;
      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
      __PYX_ERR(0, 2980, __pyx_L1_error)
      __pyx_L9_unpacking_done:;
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_gap_start);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_gap_start, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_gap_end);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_gap_end, __pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_t_1 = 0;

    /* "ws_package/controllers/activity_controller.py":2981
 * 
 *         for gap_start, gap_end in missing_intervals:
 *             overlapping = await self.get_intervals_overlapping_range(gap_start, gap_end)             # <<<<<<<<<<<<<<
 *             sub_segments = self._subtract_overlapping_intervals(gap_start, gap_end, overlapping)
 *             if not sub_segments:
*/
    __pyx_t_1 = __pyx_cur_scope->__pyx_v_self;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_5 = 0;
    {
      PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_cur_scope->__pyx_v_gap_start, __pyx_cur_scope->__pyx_v_gap_end};
      __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_intervals_overlapping_range, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2981, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    }
    __pyx_t_6 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_2, &__pyx_r);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (likely(__pyx_t_6 == PYGEN_NEXT)) {
      __Pyx_GOTREF(__pyx_r);
      __Pyx_XGIVEREF(__pyx_t_4);
      __pyx_cur_scope->__pyx_t_0 = __pyx_t_4;
      __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
      __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
      __Pyx_XGIVEREF(__pyx_r);
      __Pyx_RefNannyFinishContext();
      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
      /* return from generator, awaiting value */
      __pyx_generator->resume_label = 2;
      return __pyx_r;
      __pyx_L10_resume_from_await:;
      __pyx_t_4 = __pyx_cur_scope->__pyx_t_0;
      __pyx_cur_scope->__pyx_t_0 = 0;
      __Pyx_XGOTREF(__pyx_t_4);
      __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
      __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 2981, __pyx_L1_error)
      __pyx_t_2 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_2);
    } else if (likely(__pyx_t_6 == PYGEN_RETURN)) {
      __Pyx_GOTREF(__pyx_r);
      __pyx_t_2 = __pyx_r; __pyx_r = NULL;
    } else {
      __Pyx_XGOTREF(__pyx_r);
      __PYX_ERR(0, 2981, __pyx_L1_error)
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_overlapping);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_overlapping, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;

    /* "ws_package/controllers/activity_controller.py":2982
 *         for gap_start, gap_end in missing_intervals:
 *             overlapping = await self.get_intervals_overlapping_range(gap_start, gap_end)
 *             sub_segments = self._subtract_overlapping_intervals(gap_start, gap_end, overlapping)             # <<<<<<<<<<<<<<
 *             if not sub_segments:
 *                 logger.info(
*/
    __pyx_t_1 = __pyx_cur_scope->__pyx_v_self;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_5 = 0;
    {
      PyObject *__pyx_callargs[4] = {__pyx_t_1, __pyx_cur_scope->__pyx_v_gap_start, __pyx_cur_scope->__pyx_v_gap_end, __pyx_cur_scope->__pyx_v_overlapping};
      __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_subtract_overlapping_intervals, __pyx_callargs+__pyx_t_5, (4-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2982, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_sub_segments);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_sub_segments, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;

    /* "ws_package/controllers/activity_controller.py":2983
 *             overlapping = await self.get_intervals_overlapping_range(gap_start, gap_end)
 *             sub_segments = self._subtract_overlapping_intervals(gap_start, gap_end, overlapping)
 *             if not sub_segments:             # <<<<<<<<<<<<<<
 *                 logger.info(
 *                     f"Skip empty interval for {gap_start} - {gap_end}: fully covered by existing intervals (e.g. break)"
*/
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_sub_segments); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2983, __pyx_L1_error)
    __pyx_t_12 = (!__pyx_t_8);
    if (__pyx_t_12) {

      /* "ws_package/controllers/activity_controller.py":2984
 *             sub_segments = self._subtract_overlapping_intervals(gap_start, gap_end, overlapping)
 *             if not sub_segments:
 *                 logger.info(             # <<<<<<<<<<<<<<
 *                     f"Skip empty interval for {gap_start} - {gap_end}: fully covered by existing intervals (e.g. break)"
 *                 )
*/
      __pyx_t_1 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2984, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2984, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

      /* "ws_package/controllers/activity_controller.py":2985
 *             if not sub_segments:
 *                 logger.info(
 *                     f"Skip empty interval for {gap_start} - {gap_end}: fully covered by existing intervals (e.g. break)"             # <<<<<<<<<<<<<<
 *                 )
 *                 continue
*/
      __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_gap_start, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2985, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_13 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_gap_end, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2985, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_14[0] = __pyx_mstate_global->__pyx_kp_u_Skip_empty_interval_for;
      __pyx_t_14[1] = __pyx_t_3;
      __pyx_t_14[2] = __pyx_mstate_global->__pyx_kp_u__8;
      __pyx_t_14[3] = __pyx_t_13;
      __pyx_t_14[4] = __pyx_mstate_global->__pyx_kp_u_fully_covered_by_existing_inter;
      __pyx_t_15 = __Pyx_PyUnicode_Join(__pyx_t_14, 5, 24 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3) + 3 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_13) + 50, 127 | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13));
      if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2985, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_5 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_10);
        assert(__pyx_t_1);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
        __pyx_t_5 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_t_15};
        __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2984, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "ws_package/controllers/activity_controller.py":2987
 *                     f"Skip empty interval for {gap_start} - {gap_end}: fully covered by existing intervals (e.g. break)"
 *                 )
 *                 continue             # <<<<<<<<<<<<<<
 *             if overlapping:
 *                 logger.info(
*/
      goto __pyx_L6_continue;

      /* "ws_package/controllers/activity_controller.py":2983
 *             overlapping = await self.get_intervals_overlapping_range(gap_start, gap_end)
 *             sub_segments = self._subtract_overlapping_intervals(gap_start, gap_end, overlapping)
 *             if not sub_segments:             # <<<<<<<<<<<<<<
 *                 logger.info(
 *                     f"Skip empty interval for {gap_start} - {gap_end}: fully covered by existing intervals (e.g. break)"
*/
    }

    /* "ws_package/controllers/activity_controller.py":2988
 *                 )
 *                 continue
 *             if overlapping:             # <<<<<<<<<<<<<<
 *                 logger.info(
 *                     f"Sleep gap {gap_start} - {gap_end} overlaps existing intervals; filling only non-overlapping parts: {sub_segments}"
*/
    __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_overlapping); if (unlikely((__pyx_t_12 < 0))) __PYX_ERR(0, 2988, __pyx_L1_error)
    if (__pyx_t_12) {

      /* "ws_package/controllers/activity_controller.py":2989
 *                 continue
 *             if overlapping:
 *                 logger.info(             # <<<<<<<<<<<<<<
 *                     f"Sleep gap {gap_start} - {gap_end} overlaps existing intervals; filling only non-overlapping parts: {sub_segments}"
 *                 )
*/
      __pyx_t_10 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2989, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2989, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

      /* "ws_package/controllers/activity_controller.py":2990
 *             if overlapping:
 *                 logger.info(
 *                     f"Sleep gap {gap_start} - {gap_end} overlaps existing intervals; filling only non-overlapping parts: {sub_segments}"             # <<<<<<<<<<<<<<
 *                 )
 * 
*/
      __pyx_t_15 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_gap_start, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2990, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_13 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_gap_end, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 2990, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_sub_segments, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 2990, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_16[0] = __pyx_mstate_global->__pyx_kp_u_Sleep_gap;
      __pyx_t_16[1] = __pyx_t_15;
      __pyx_t_16[2] = __pyx_mstate_global->__pyx_kp_u__8;
      __pyx_t_16[3] = __pyx_t_13;
      __pyx_t_16[4] = __pyx_mstate_global->__pyx_kp_u_overlaps_existing_intervals_fil;
      __pyx_t_16[5] = __pyx_t_3;
      __pyx_t_17 = __Pyx_PyUnicode_Join(__pyx_t_16, 6, 10 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_15) + 3 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_13) + 66 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3), 127 | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_15) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3));
      if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 2990, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_5 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_1))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1);
        assert(__pyx_t_10);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
        __pyx_t_5 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_t_17};
        __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2989, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "ws_package/controllers/activity_controller.py":2988
 *                 )
 *                 continue
 *             if overlapping:             # <<<<<<<<<<<<<<
 *                 logger.info(
 *                     f"Sleep gap {gap_start} - {gap_end} overlaps existing intervals; filling only non-overlapping parts: {sub_segments}"
*/
    }

    /* "ws_package/controllers/activity_controller.py":2993
 *                 )
 * 
 *             gap_seconds = (gap_end - gap_start).total_seconds()             # <<<<<<<<<<<<<<
 *             # Silent mode: any gap (including >1 hour) is filled as normal idle/empty
 *             # slot intervals and uploaded like regular activity  no session stop/open.
*/
    __pyx_t_17 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_gap_end, __pyx_cur_scope->__pyx_v_gap_start); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 2993, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_17);
    __pyx_t_1 = __pyx_t_17;
    __Pyx_INCREF(__pyx_t_1);
    __pyx_t_5 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
      __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_total_seconds, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2993, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_gap_seconds);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_gap_seconds, __pyx_t_2);
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_t_2 = 0;

    /* "ws_package/controllers/activity_controller.py":2996
 *             # Silent mode: any gap (including >1 hour) is filled as normal idle/empty
 *             # slot intervals and uploaded like regular activity  no session stop/open.
 *             if gap_seconds > 3600 and not is_silent_build():             # <<<<<<<<<<<<<<
 *                 total_fill_seconds = sum((e - s).total_seconds() for s, e in sub_segments)
 *                 logger.info(
*/
    __pyx_t_2 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_gap_seconds, __pyx_mstate_global->__pyx_int_3600, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2996, __pyx_L1_error)
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2996, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_8) {
    } else {
      __pyx_t_12 = __pyx_t_8;
      goto __pyx_L14_bool_binop_done;
    }
    __pyx_t_17 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_is_silent_build); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2996, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_1))) {
      __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_1);
      assert(__pyx_t_17);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
      __Pyx_INCREF(__pyx_t_17);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_17, NULL};
      __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2996, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    }
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 2996, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_18 = (!__pyx_t_8);
    __pyx_t_12 = __pyx_t_18;
    __pyx_L14_bool_binop_done:;
    if (__pyx_t_12) {

      /* "ws_package/controllers/activity_controller.py":2997
 *             # slot intervals and uploaded like regular activity  no session stop/open.
 *             if gap_seconds > 3600 and not is_silent_build():
 *                 total_fill_seconds = sum((e - s).total_seconds() for s, e in sub_segments)             # <<<<<<<<<<<<<<
 *                 logger.info(
 *                     "Sleep gap > 1 hour (gap_seconds=%.0f, fill_seconds=%.0f) - "
*/
      __pyx_t_1 = NULL;
      __pyx_t_17 = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_14empty_interval_genexpr(NULL, __pyx_cur_scope->__pyx_v_sub_segments); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 2997, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_5 = 1;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_t_17};
        __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_builtin_sum, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2997, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_total_fill_seconds);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_total_fill_seconds, __pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_t_2 = 0;

      /* "ws_package/controllers/activity_controller.py":2998
 *             if gap_seconds > 3600 and not is_silent_build():
 *                 total_fill_seconds = sum((e - s).total_seconds() for s, e in sub_segments)
 *                 logger.info(             # <<<<<<<<<<<<<<
 *                     "Sleep gap > 1 hour (gap_seconds=%.0f, fill_seconds=%.0f) - "
 *                     "saving empty interval(s) for non-overlapping parts only (visible mode)",
*/
      __pyx_t_17 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 2998, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 2998, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":3002
 *                     "saving empty interval(s) for non-overlapping parts only (visible mode)",
 *                     gap_seconds,
 *                     total_fill_seconds,             # <<<<<<<<<<<<<<
 *                 )
 *                 for seg_start, seg_end in sub_segments:
*/
      __pyx_t_5 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_10);
        assert(__pyx_t_17);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_17);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
        __pyx_t_5 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[4] = {__pyx_t_17, __pyx_mstate_global->__pyx_kp_u_Sleep_gap_1_hour_gap_seconds_0f, __pyx_cur_scope->__pyx_v_gap_seconds, __pyx_cur_scope->__pyx_v_total_fill_seconds};
        __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_5, (4-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 2998, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "ws_package/controllers/activity_controller.py":3004
 *                     total_fill_seconds,
 *                 )
 *                 for seg_start, seg_end in sub_segments:             # <<<<<<<<<<<<<<
 *                     break_id = self._empty_interval_break_id(seg_start)
 *                     gap_level = await self._activity_level_for_gap_fill(seg_start, seg_end)
*/
      if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_sub_segments)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_sub_segments)) {
        __pyx_t_2 = __pyx_cur_scope->__pyx_v_sub_segments; __Pyx_INCREF(__pyx_t_2);
        __pyx_t_19 = 0;
        __pyx_t_20 = NULL;
      } else {
        __pyx_t_19 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_sub_segments); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3004, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_20 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3004, __pyx_L1_error)
      }
      for (;;) {
        if (likely(!__pyx_t_20)) {
          if (likely(PyList_CheckExact(__pyx_t_2))) {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2);
              #if !CYTHON_ASSUME_SAFE_SIZE
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3004, __pyx_L1_error)
              #endif
              if (__pyx_t_19 >= __pyx_temp) break;
            }
            __pyx_t_10 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_2, __pyx_t_19, __Pyx_ReferenceSharing_OwnStrongReference);
            ++__pyx_t_19;
          } else {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2);
              #if !CYTHON_ASSUME_SAFE_SIZE
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3004, __pyx_L1_error)
              #endif
              if (__pyx_t_19 >= __pyx_temp) break;
            }
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_10 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_19));
            #else
            __pyx_t_10 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_19);
            #endif
            ++__pyx_t_19;
          }
          if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3004, __pyx_L1_error)
        } else {
          __pyx_t_10 = __pyx_t_20(__pyx_t_2);
          if (unlikely(!__pyx_t_10)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 3004, __pyx_L1_error)
              PyErr_Clear();
            }
            break;
          }
        }
        __Pyx_GOTREF(__pyx_t_10);
        if ((likely(PyTuple_CheckExact(__pyx_t_10))) || (PyList_CheckExact(__pyx_t_10))) {
          PyObject* sequence = __pyx_t_10;
          Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
          if (unlikely(size != 2)) {
            if (size > 2) __Pyx_RaiseTooManyValuesError(2);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            __PYX_ERR(0, 3004, __pyx_L1_error)
          }
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_17 = PyTuple_GET_ITEM(sequence, 0);
            __Pyx_INCREF(__pyx_t_17);
            __pyx_t_1 = PyTuple_GET_ITEM(sequence, 1);
            __Pyx_INCREF(__pyx_t_1);
          } else {
            __pyx_t_17 = __Pyx_PyList_GET_ITEM_REF(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
            if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3004, __pyx_L1_error)
            __Pyx_XGOTREF(__pyx_t_17);
            __pyx_t_1 = __Pyx_PyList_GET_ITEM_REF(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3004, __pyx_L1_error)
            __Pyx_XGOTREF(__pyx_t_1);
          }
          #else
          __pyx_t_17 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3004, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_1 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3004, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          #endif
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        } else {
          Py_ssize_t index = -1;
          __pyx_t_3 = PyObject_GetIter(__pyx_t_10); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3004, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_11 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_3);
          index = 0; __pyx_t_17 = __pyx_t_11(__pyx_t_3); if (unlikely(!__pyx_t_17)) goto __pyx_L18_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_17);
          index = 1; __pyx_t_1 = __pyx_t_11(__pyx_t_3); if (unlikely(!__pyx_t_1)) goto __pyx_L18_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_1);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_3), 2) < (0)) __PYX_ERR(0, 3004, __pyx_L1_error)
          __pyx_t_11 = NULL;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          goto __pyx_L19_unpacking_done;
          __pyx_L18_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_11 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          __PYX_ERR(0, 3004, __pyx_L1_error)
          __pyx_L19_unpacking_done:;
        }
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_seg_start);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_seg_start, __pyx_t_17);
        __Pyx_GIVEREF(__pyx_t_17);
        __pyx_t_17 = 0;
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_seg_end);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_seg_end, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":3005
 *                 )
 *                 for seg_start, seg_end in sub_segments:
 *                     break_id = self._empty_interval_break_id(seg_start)             # <<<<<<<<<<<<<<
 *                     gap_level = await self._activity_level_for_gap_fill(seg_start, seg_end)
 *                     await self.activity_service.save_first_activity_log(
*/
        __pyx_t_1 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_5 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_cur_scope->__pyx_v_seg_start};
          __pyx_t_10 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_empty_interval_break_id, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3005, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
        }
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_break_id);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_break_id, __pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_10);
        __pyx_t_10 = 0;

        /* "ws_package/controllers/activity_controller.py":3006
 *                 for seg_start, seg_end in sub_segments:
 *                     break_id = self._empty_interval_break_id(seg_start)
 *                     gap_level = await self._activity_level_for_gap_fill(seg_start, seg_end)             # <<<<<<<<<<<<<<
 *                     await self.activity_service.save_first_activity_log(
 *                         gap_level,
*/
        __pyx_t_1 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_5 = 0;
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_cur_scope->__pyx_v_seg_start, __pyx_cur_scope->__pyx_v_seg_end};
          __pyx_t_10 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_activity_level_for_gap_fill, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3006, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
        }
        __pyx_t_6 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_10, &__pyx_r);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (likely(__pyx_t_6 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_2);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
          __Pyx_XGIVEREF(__pyx_t_4);
          __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
          __pyx_cur_scope->__pyx_t_4 = __pyx_t_19;
          __pyx_cur_scope->__pyx_t_5 = __pyx_t_20;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 3;
          return __pyx_r;
          __pyx_L20_resume_from_await:;
          __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_2);
          __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
          __pyx_cur_scope->__pyx_t_3 = 0;
          __Pyx_XGOTREF(__pyx_t_4);
          __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
          __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
          __pyx_t_19 = __pyx_cur_scope->__pyx_t_4;
          __pyx_t_20 = __pyx_cur_scope->__pyx_t_5;
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3006, __pyx_L1_error)
          __pyx_t_10 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_10);
        } else if (likely(__pyx_t_6 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __pyx_t_10 = __pyx_r; __pyx_r = NULL;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 3006, __pyx_L1_error)
        }
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_gap_level);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_gap_level, __pyx_t_10);
        __Pyx_GIVEREF(__pyx_t_10);
        __pyx_t_10 = 0;

        /* "ws_package/controllers/activity_controller.py":3007
 *                     break_id = self._empty_interval_break_id(seg_start)
 *                     gap_level = await self._activity_level_for_gap_fill(seg_start, seg_end)
 *                     await self.activity_service.save_first_activity_log(             # <<<<<<<<<<<<<<
 *                         gap_level,
 *                         seg_start,
*/
        __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3007, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_1 = __pyx_t_17;
        __Pyx_INCREF(__pyx_t_1);

        /* "ws_package/controllers/activity_controller.py":3011
 *                         seg_start,
 *                         seg_end,
 *                         self.last_count + 1,             # <<<<<<<<<<<<<<
 *                         self.get_today_weekday(),
 *                         break_id=break_id,
*/
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3011, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_13 = __Pyx_PyLong_AddObjC(__pyx_t_3, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3011, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "ws_package/controllers/activity_controller.py":3012
 *                         seg_end,
 *                         self.last_count + 1,
 *                         self.get_today_weekday(),             # <<<<<<<<<<<<<<
 *                         break_id=break_id,
 *                     )
*/
        __pyx_t_15 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_15);
        __pyx_t_5 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL};
          __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_today_weekday, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3012, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
        }

        /* "ws_package/controllers/activity_controller.py":3013
 *                         self.last_count + 1,
 *                         self.get_today_weekday(),
 *                         break_id=break_id,             # <<<<<<<<<<<<<<
 *                     )
 *                 if total_fill_seconds > 3600:
*/
        __pyx_t_5 = 0;
        {
          PyObject *__pyx_callargs[6 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_1, __pyx_cur_scope->__pyx_v_gap_level, __pyx_cur_scope->__pyx_v_seg_start, __pyx_cur_scope->__pyx_v_seg_end, __pyx_t_13, __pyx_t_3};
          __pyx_t_15 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3007, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_15);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_break_id, __pyx_cur_scope->__pyx_v_break_id, __pyx_t_15, __pyx_callargs+6, 0) < (0)) __PYX_ERR(0, 3007, __pyx_L1_error)
          __pyx_t_10 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_save_first_activity_log, __pyx_callargs+__pyx_t_5, (6-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_15);
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3007, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
        }
        __pyx_t_6 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_10, &__pyx_r);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (likely(__pyx_t_6 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_2);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
          __Pyx_XGIVEREF(__pyx_t_4);
          __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
          __pyx_cur_scope->__pyx_t_4 = __pyx_t_19;
          __pyx_cur_scope->__pyx_t_5 = __pyx_t_20;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 4;
          return __pyx_r;
          __pyx_L21_resume_from_await:;
          __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_2);
          __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
          __pyx_cur_scope->__pyx_t_3 = 0;
          __Pyx_XGOTREF(__pyx_t_4);
          __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
          __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
          __pyx_t_19 = __pyx_cur_scope->__pyx_t_4;
          __pyx_t_20 = __pyx_cur_scope->__pyx_t_5;
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3007, __pyx_L1_error)
        } else if (likely(__pyx_t_6 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_DECREF(__pyx_r); __pyx_r = 0;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 3007, __pyx_L1_error)
        }

        /* "ws_package/controllers/activity_controller.py":3004
 *                     total_fill_seconds,
 *                 )
 *                 for seg_start, seg_end in sub_segments:             # <<<<<<<<<<<<<<
 *                     break_id = self._empty_interval_break_id(seg_start)
 *                     gap_level = await self._activity_level_for_gap_fill(seg_start, seg_end)
*/
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "ws_package/controllers/activity_controller.py":3015
 *                         break_id=break_id,
 *                     )
 *                 if total_fill_seconds > 3600:             # <<<<<<<<<<<<<<
 *                     try:
 *                         sleep_minutes = int(total_fill_seconds / 60)
*/
      __pyx_t_2 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_total_fill_seconds, __pyx_mstate_global->__pyx_int_3600, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3015, __pyx_L1_error)
      __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_12 < 0))) __PYX_ERR(0, 3015, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__pyx_t_12) {

        /* "ws_package/controllers/activity_controller.py":3016
 *                     )
 *                 if total_fill_seconds > 3600:
 *                     try:             # <<<<<<<<<<<<<<
 *                         sleep_minutes = int(total_fill_seconds / 60)
 *                         sent = self._send_to_electron_if_connected("sleep_auto_stop", {
*/
        {
          __Pyx_ExceptionSave(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_23);
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":3017
 *                 if total_fill_seconds > 3600:
 *                     try:
 *                         sleep_minutes = int(total_fill_seconds / 60)             # <<<<<<<<<<<<<<
 *                         sent = self._send_to_electron_if_connected("sleep_auto_stop", {
 *                             "message": f"Your system was in sleep for more than 1 hour. Timer has been stopped automatically & time log for the sleep period has been saved. Kindly restart the timer to continue working!!",
*/
            __pyx_t_2 = __Pyx_PyLong_TrueDivideObjC(__pyx_cur_scope->__pyx_v_total_fill_seconds, __pyx_mstate_global->__pyx_int_60, 60, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3017, __pyx_L24_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_10 = __Pyx_PyNumber_Int(__pyx_t_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3017, __pyx_L24_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_GIVEREF(__pyx_t_10);
            __pyx_cur_scope->__pyx_v_sleep_minutes = ((PyObject*)__pyx_t_10);
            __pyx_t_10 = 0;

            /* "ws_package/controllers/activity_controller.py":3018
 *                     try:
 *                         sleep_minutes = int(total_fill_seconds / 60)
 *                         sent = self._send_to_electron_if_connected("sleep_auto_stop", {             # <<<<<<<<<<<<<<
 *                             "message": f"Your system was in sleep for more than 1 hour. Timer has been stopped automatically & time log for the sleep period has been saved. Kindly restart the timer to continue working!!",
 *                             "sleep_minutes": sleep_minutes,
*/
            __pyx_t_2 = __pyx_cur_scope->__pyx_v_self;
            __Pyx_INCREF(__pyx_t_2);

            /* "ws_package/controllers/activity_controller.py":3019
 *                         sleep_minutes = int(total_fill_seconds / 60)
 *                         sent = self._send_to_electron_if_connected("sleep_auto_stop", {
 *                             "message": f"Your system was in sleep for more than 1 hour. Timer has been stopped automatically & time log for the sleep period has been saved. Kindly restart the timer to continue working!!",             # <<<<<<<<<<<<<<
 *                             "sleep_minutes": sleep_minutes,
 *                         })
*/
            __pyx_t_17 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3019, __pyx_L24_error)
            __Pyx_GOTREF(__pyx_t_17);
            if (PyDict_SetItem(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_message, __pyx_mstate_global->__pyx_kp_u_Your_system_was_in_sleep_for_mor) < (0)) __PYX_ERR(0, 3019, __pyx_L24_error)

            /* "ws_package/controllers/activity_controller.py":3020
 *                         sent = self._send_to_electron_if_connected("sleep_auto_stop", {
 *                             "message": f"Your system was in sleep for more than 1 hour. Timer has been stopped automatically & time log for the sleep period has been saved. Kindly restart the timer to continue working!!",
 *                             "sleep_minutes": sleep_minutes,             # <<<<<<<<<<<<<<
 *                         })
 *                         if sent:
*/
            if (PyDict_SetItem(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_sleep_minutes, __pyx_cur_scope->__pyx_v_sleep_minutes) < (0)) __PYX_ERR(0, 3019, __pyx_L24_error)
            __pyx_t_5 = 0;
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_mstate_global->__pyx_n_u_sleep_auto_stop, __pyx_t_17};
              __pyx_t_10 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_send_to_electron_if_connected, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
              if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3018, __pyx_L24_error)
              __Pyx_GOTREF(__pyx_t_10);
            }
            __Pyx_GIVEREF(__pyx_t_10);
            __pyx_cur_scope->__pyx_v_sent = __pyx_t_10;
            __pyx_t_10 = 0;

            /* "ws_package/controllers/activity_controller.py":3022
 *                             "sleep_minutes": sleep_minutes,
 *                         })
 *                         if sent:             # <<<<<<<<<<<<<<
 *                             logger.info("Sleep auto-stop signal sent to Electron (sleep gap: %s minutes)", sleep_minutes)
 *                         else:
*/
            __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_sent); if (unlikely((__pyx_t_12 < 0))) __PYX_ERR(0, 3022, __pyx_L24_error)
            if (__pyx_t_12) {

              /* "ws_package/controllers/activity_controller.py":3023
 *                         })
 *                         if sent:
 *                             logger.info("Sleep auto-stop signal sent to Electron (sleep gap: %s minutes)", sleep_minutes)             # <<<<<<<<<<<<<<
 *                         else:
 *                             logger.warning("Failed to send sleep_auto_stop to Electron (not connected?)")
*/
              __pyx_t_17 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3023, __pyx_L24_error)
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3023, __pyx_L24_error)
              __Pyx_GOTREF(__pyx_t_15);
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              __pyx_t_5 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_15))) {
                __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_15);
                assert(__pyx_t_17);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                __Pyx_INCREF(__pyx_t_17);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                __pyx_t_5 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_17, __pyx_mstate_global->__pyx_kp_u_Sleep_auto_stop_signal_sent_to_E, __pyx_cur_scope->__pyx_v_sleep_minutes};
                __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3023, __pyx_L24_error)
                __Pyx_GOTREF(__pyx_t_10);
              }
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

              /* "ws_package/controllers/activity_controller.py":3022
 *                             "sleep_minutes": sleep_minutes,
 *                         })
 *                         if sent:             # <<<<<<<<<<<<<<
 *                             logger.info("Sleep auto-stop signal sent to Electron (sleep gap: %s minutes)", sleep_minutes)
 *                         else:
*/
              goto __pyx_L32;
            }

            /* "ws_package/controllers/activity_controller.py":3025
 *                             logger.info("Sleep auto-stop signal sent to Electron (sleep gap: %s minutes)", sleep_minutes)
 *                         else:
 *                             logger.warning("Failed to send sleep_auto_stop to Electron (not connected?)")             # <<<<<<<<<<<<<<
 *                     except Exception as e:
 *                         logger.error("Error sending sleep_auto_stop to Electron: %s", e, exc_info=True)
*/
            /*else*/ {
              __pyx_t_15 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3025, __pyx_L24_error)
              __Pyx_GOTREF(__pyx_t_17);
              __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3025, __pyx_L24_error)
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
              __pyx_t_5 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_2))) {
                __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_2);
                assert(__pyx_t_15);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
                __Pyx_INCREF(__pyx_t_15);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
                __pyx_t_5 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Failed_to_send_sleep_auto_stop_t};
                __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3025, __pyx_L24_error)
                __Pyx_GOTREF(__pyx_t_10);
              }
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            }
            __pyx_L32:;

            /* "ws_package/controllers/activity_controller.py":3016
 *                     )
 *                 if total_fill_seconds > 3600:
 *                     try:             # <<<<<<<<<<<<<<
 *                         sleep_minutes = int(total_fill_seconds / 60)
 *                         sent = self._send_to_electron_if_connected("sleep_auto_stop", {
*/
          }
          __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
          __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          goto __pyx_L31_try_end;
          __pyx_L24_error:;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

          /* "ws_package/controllers/activity_controller.py":3026
 *                         else:
 *                             logger.warning("Failed to send sleep_auto_stop to Electron (not connected?)")
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error sending sleep_auto_stop to Electron: %s", e, exc_info=True)
 *                     return
*/
          __pyx_t_24 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
          if (__pyx_t_24) {
            __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.empty_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_10, &__pyx_t_2, &__pyx_t_15) < 0) __PYX_ERR(0, 3026, __pyx_L26_except_error)
            __Pyx_XGOTREF(__pyx_t_10);
            __Pyx_XGOTREF(__pyx_t_2);
            __Pyx_XGOTREF(__pyx_t_15);
            __Pyx_INCREF(__pyx_t_2);
            __Pyx_GIVEREF(__pyx_t_2);
            __pyx_cur_scope->__pyx_v_e = __pyx_t_2;
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":3027
 *                             logger.warning("Failed to send sleep_auto_stop to Electron (not connected?)")
 *                     except Exception as e:
 *                         logger.error("Error sending sleep_auto_stop to Electron: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 *                     return
 *             else:
*/
              __pyx_t_3 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3027, __pyx_L38_error)
              __Pyx_GOTREF(__pyx_t_13);
              __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3027, __pyx_L38_error)
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              __pyx_t_5 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_1))) {
                __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
                assert(__pyx_t_3);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
                __Pyx_INCREF(__pyx_t_3);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
                __pyx_t_5 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Error_sending_sleep_auto_stop_to, __pyx_cur_scope->__pyx_v_e};
                __pyx_t_13 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3027, __pyx_L38_error)
                __Pyx_GOTREF(__pyx_t_13);
                if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_13, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 3027, __pyx_L38_error)
                __pyx_t_17 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_13);
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3027, __pyx_L38_error)
                __Pyx_GOTREF(__pyx_t_17);
              }
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            }

            /* "ws_package/controllers/activity_controller.py":3026
 *                         else:
 *                             logger.warning("Failed to send sleep_auto_stop to Electron (not connected?)")
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error sending sleep_auto_stop to Electron: %s", e, exc_info=True)
 *                     return
*/
            /*finally:*/ {
              /*normal exit:*/{
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                goto __pyx_L39;
              }
              __pyx_L38_error:;
              /*exception exit:*/{
                __Pyx_PyThreadState_assign
                __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0;
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                 __Pyx_ExceptionSwap(&__pyx_t_30, &__pyx_t_31, &__pyx_t_32);
                if ( unlikely(__Pyx_GetException(&__pyx_t_27, &__pyx_t_28, &__pyx_t_29) < 0)) __Pyx_ErrFetch(&__pyx_t_27, &__pyx_t_28, &__pyx_t_29);
                __Pyx_XGOTREF(__pyx_t_27);
                __Pyx_XGOTREF(__pyx_t_28);
                __Pyx_XGOTREF(__pyx_t_29);
                __Pyx_XGOTREF(__pyx_t_30);
                __Pyx_XGOTREF(__pyx_t_31);
                __Pyx_XGOTREF(__pyx_t_32);
                __pyx_t_24 = __pyx_lineno; __pyx_t_25 = __pyx_clineno; __pyx_t_26 = __pyx_filename;
                {
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                }
                __Pyx_XGIVEREF(__pyx_t_30);
                __Pyx_XGIVEREF(__pyx_t_31);
                __Pyx_XGIVEREF(__pyx_t_32);
                __Pyx_ExceptionReset(__pyx_t_30, __pyx_t_31, __pyx_t_32);
                __Pyx_XGIVEREF(__pyx_t_27);
                __Pyx_XGIVEREF(__pyx_t_28);
                __Pyx_XGIVEREF(__pyx_t_29);
                __Pyx_ErrRestore(__pyx_t_27, __pyx_t_28, __pyx_t_29);
                __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0;
                __pyx_lineno = __pyx_t_24; __pyx_clineno = __pyx_t_25; __pyx_filename = __pyx_t_26;
                goto __pyx_L26_except_error;
              }
              __pyx_L39:;
            }
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            goto __pyx_L25_exception_handled;
          }
          goto __pyx_L26_except_error;

          /* "ws_package/controllers/activity_controller.py":3016
 *                     )
 *                 if total_fill_seconds > 3600:
 *                     try:             # <<<<<<<<<<<<<<
 *                         sleep_minutes = int(total_fill_seconds / 60)
 *                         sent = self._send_to_electron_if_connected("sleep_auto_stop", {
*/
          __pyx_L26_except_error:;
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_23);
          goto __pyx_L1_error;
          __pyx_L25_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_23);
          __pyx_L31_try_end:;
        }

        /* "ws_package/controllers/activity_controller.py":3028
 *                     except Exception as e:
 *                         logger.error("Error sending sleep_auto_stop to Electron: %s", e, exc_info=True)
 *                     return             # <<<<<<<<<<<<<<
 *             else:
 *                 if gap_seconds > 3600:
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        goto __pyx_L0;

        /* "ws_package/controllers/activity_controller.py":3015
 *                         break_id=break_id,
 *                     )
 *                 if total_fill_seconds > 3600:             # <<<<<<<<<<<<<<
 *                     try:
 *                         sleep_minutes = int(total_fill_seconds / 60)
*/
      }

      /* "ws_package/controllers/activity_controller.py":2996
 *             # Silent mode: any gap (including >1 hour) is filled as normal idle/empty
 *             # slot intervals and uploaded like regular activity  no session stop/open.
 *             if gap_seconds > 3600 and not is_silent_build():             # <<<<<<<<<<<<<<
 *                 total_fill_seconds = sum((e - s).total_seconds() for s, e in sub_segments)
 *                 logger.info(
*/
      goto __pyx_L13;
    }

    /* "ws_package/controllers/activity_controller.py":3030
 *                     return
 *             else:
 *                 if gap_seconds > 3600:             # <<<<<<<<<<<<<<
 *                     logger.info(
 *                         "[Silent] Sleep gap > 1 hour (%.0fs)  filling idle intervals normally",
*/
    /*else*/ {
      __pyx_t_15 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_gap_seconds, __pyx_mstate_global->__pyx_int_3600, Py_GT); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3030, __pyx_L1_error)
      __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely((__pyx_t_12 < 0))) __PYX_ERR(0, 3030, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      if (__pyx_t_12) {

        /* "ws_package/controllers/activity_controller.py":3031
 *             else:
 *                 if gap_seconds > 3600:
 *                     logger.info(             # <<<<<<<<<<<<<<
 *                         "[Silent] Sleep gap > 1 hour (%.0fs)  filling idle intervals normally",
 *                         gap_seconds,
*/
        __pyx_t_2 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3031, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3031, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_17);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

        /* "ws_package/controllers/activity_controller.py":3033
 *                     logger.info(
 *                         "[Silent] Sleep gap > 1 hour (%.0fs)  filling idle intervals normally",
 *                         gap_seconds,             # <<<<<<<<<<<<<<
 *                     )
 *                 else:
*/
        __pyx_t_5 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_17))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_17);
          assert(__pyx_t_2);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
          __pyx_t_5 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Silent_Sleep_gap_1_hour_0fs_fil, __pyx_cur_scope->__pyx_v_gap_seconds};
          __pyx_t_15 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3031, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_15);
        }
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

        /* "ws_package/controllers/activity_controller.py":3030
 *                     return
 *             else:
 *                 if gap_seconds > 3600:             # <<<<<<<<<<<<<<
 *                     logger.info(
 *                         "[Silent] Sleep gap > 1 hour (%.0fs)  filling idle intervals normally",
*/
        goto __pyx_L44;
      }

      /* "ws_package/controllers/activity_controller.py":3036
 *                     )
 *                 else:
 *                     logger.info("Sleep is less than 1 hour adding up intervals")             # <<<<<<<<<<<<<<
 *                 for seg_start, seg_end in sub_segments:
 *                     start_time = seg_start
*/
      /*else*/ {
        __pyx_t_17 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3036, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3036, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_5 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_10);
          assert(__pyx_t_17);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_17);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
          __pyx_t_5 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_17, __pyx_mstate_global->__pyx_kp_u_Sleep_is_less_than_1_hour_adding};
          __pyx_t_15 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3036, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_15);
        }
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      }
      __pyx_L44:;

      /* "ws_package/controllers/activity_controller.py":3037
 *                 else:
 *                     logger.info("Sleep is less than 1 hour adding up intervals")
 *                 for seg_start, seg_end in sub_segments:             # <<<<<<<<<<<<<<
 *                     start_time = seg_start
 *                     while start_time < seg_end:
*/
      if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_sub_segments)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_sub_segments)) {
        __pyx_t_15 = __pyx_cur_scope->__pyx_v_sub_segments; __Pyx_INCREF(__pyx_t_15);
        __pyx_t_19 = 0;
        __pyx_t_20 = NULL;
      } else {
        __pyx_t_19 = -1; __pyx_t_15 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_sub_segments); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3037, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_20 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_15); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3037, __pyx_L1_error)
      }
      for (;;) {
        if (likely(!__pyx_t_20)) {
          if (likely(PyList_CheckExact(__pyx_t_15))) {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_15);
              #if !CYTHON_ASSUME_SAFE_SIZE
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3037, __pyx_L1_error)
              #endif
              if (__pyx_t_19 >= __pyx_temp) break;
            }
            __pyx_t_10 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_15, __pyx_t_19, __Pyx_ReferenceSharing_OwnStrongReference);
            ++__pyx_t_19;
          } else {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_15);
              #if !CYTHON_ASSUME_SAFE_SIZE
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3037, __pyx_L1_error)
              #endif
              if (__pyx_t_19 >= __pyx_temp) break;
            }
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_10 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_15, __pyx_t_19));
            #else
            __pyx_t_10 = __Pyx_PySequence_ITEM(__pyx_t_15, __pyx_t_19);
            #endif
            ++__pyx_t_19;
          }
          if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3037, __pyx_L1_error)
        } else {
          __pyx_t_10 = __pyx_t_20(__pyx_t_15);
          if (unlikely(!__pyx_t_10)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 3037, __pyx_L1_error)
              PyErr_Clear();
            }
            break;
          }
        }
        __Pyx_GOTREF(__pyx_t_10);
        if ((likely(PyTuple_CheckExact(__pyx_t_10))) || (PyList_CheckExact(__pyx_t_10))) {
          PyObject* sequence = __pyx_t_10;
          Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
          if (unlikely(size != 2)) {
            if (size > 2) __Pyx_RaiseTooManyValuesError(2);
            else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
            __PYX_ERR(0, 3037, __pyx_L1_error)
          }
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          if (likely(PyTuple_CheckExact(sequence))) {
            __pyx_t_17 = PyTuple_GET_ITEM(sequence, 0);
            __Pyx_INCREF(__pyx_t_17);
            __pyx_t_2 = PyTuple_GET_ITEM(sequence, 1);
            __Pyx_INCREF(__pyx_t_2);
          } else {
            __pyx_t_17 = __Pyx_PyList_GET_ITEM_REF(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
            if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3037, __pyx_L1_error)
            __Pyx_XGOTREF(__pyx_t_17);
            __pyx_t_2 = __Pyx_PyList_GET_ITEM_REF(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3037, __pyx_L1_error)
            __Pyx_XGOTREF(__pyx_t_2);
          }
          #else
          __pyx_t_17 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3037, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_2 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3037, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_2);
          #endif
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        } else {
          Py_ssize_t index = -1;
          __pyx_t_1 = PyObject_GetIter(__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3037, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_11 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_1);
          index = 0; __pyx_t_17 = __pyx_t_11(__pyx_t_1); if (unlikely(!__pyx_t_17)) goto __pyx_L47_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_17);
          index = 1; __pyx_t_2 = __pyx_t_11(__pyx_t_1); if (unlikely(!__pyx_t_2)) goto __pyx_L47_unpacking_failed;
          __Pyx_GOTREF(__pyx_t_2);
          if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_1), 2) < (0)) __PYX_ERR(0, 3037, __pyx_L1_error)
          __pyx_t_11 = NULL;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          goto __pyx_L48_unpacking_done;
          __pyx_L47_unpacking_failed:;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_11 = NULL;
          if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
          __PYX_ERR(0, 3037, __pyx_L1_error)
          __pyx_L48_unpacking_done:;
        }
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_seg_start);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_seg_start, __pyx_t_17);
        __Pyx_GIVEREF(__pyx_t_17);
        __pyx_t_17 = 0;
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_seg_end);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_seg_end, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        __pyx_t_2 = 0;

        /* "ws_package/controllers/activity_controller.py":3038
 *                     logger.info("Sleep is less than 1 hour adding up intervals")
 *                 for seg_start, seg_end in sub_segments:
 *                     start_time = seg_start             # <<<<<<<<<<<<<<
 *                     while start_time < seg_end:
 *                         interval_end_time = min(
*/
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_seg_start);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_start_time);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_start_time, __pyx_cur_scope->__pyx_v_seg_start);
        __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_seg_start);

        /* "ws_package/controllers/activity_controller.py":3039
 *                 for seg_start, seg_end in sub_segments:
 *                     start_time = seg_start
 *                     while start_time < seg_end:             # <<<<<<<<<<<<<<
 *                         interval_end_time = min(
 *                             start_time + datetime.timedelta(minutes=self.interval / 60), seg_end
*/
        while (1) {
          __pyx_t_10 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_start_time, __pyx_cur_scope->__pyx_v_seg_end, Py_LT); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3039, __pyx_L1_error)
          __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_12 < 0))) __PYX_ERR(0, 3039, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (!__pyx_t_12) break;

          /* "ws_package/controllers/activity_controller.py":3041
 *                     while start_time < seg_end:
 *                         interval_end_time = min(
 *                             start_time + datetime.timedelta(minutes=self.interval / 60), seg_end             # <<<<<<<<<<<<<<
 *                         )
 *                         break_id = self._empty_interval_break_id(start_time)
*/
          __Pyx_INCREF(__pyx_cur_scope->__pyx_v_seg_end);
          __pyx_t_10 = __pyx_cur_scope->__pyx_v_seg_end;
          __pyx_t_17 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3041, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_timedelta); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3041, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3041, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_3 = __Pyx_PyLong_TrueDivideObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_60, 60, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3041, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_5 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_13))) {
            __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_13);
            assert(__pyx_t_17);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
            __Pyx_INCREF(__pyx_t_17);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
            __pyx_t_5 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_17, NULL};
            __pyx_t_1 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3041, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_1);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_minutes, __pyx_t_3, __pyx_t_1, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 3041, __pyx_L1_error)
            __pyx_t_2 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_1);
            __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3041, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
          }
          __pyx_t_13 = PyNumber_Add(__pyx_cur_scope->__pyx_v_start_time, __pyx_t_2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3041, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_1 = PyObject_RichCompare(__pyx_t_10, __pyx_t_13, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3041, __pyx_L1_error)
          __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_12 < 0))) __PYX_ERR(0, 3041, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (__pyx_t_12) {
            __Pyx_INCREF(__pyx_t_10);
            __pyx_t_2 = __pyx_t_10;
          } else {
            __Pyx_INCREF(__pyx_t_13);
            __pyx_t_2 = __pyx_t_13;
          }
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_10 = __pyx_t_2;
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval_end_time);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval_end_time, __pyx_t_10);
          __Pyx_GIVEREF(__pyx_t_10);
          __pyx_t_10 = 0;

          /* "ws_package/controllers/activity_controller.py":3043
 *                             start_time + datetime.timedelta(minutes=self.interval / 60), seg_end
 *                         )
 *                         break_id = self._empty_interval_break_id(start_time)             # <<<<<<<<<<<<<<
 *                         if await self.activity_service.check_existing_interval(
 *                             start_time, interval_end_time, exact=True
*/
          __pyx_t_2 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_2);
          __pyx_t_5 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_start_time};
            __pyx_t_10 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_empty_interval_break_id, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3043, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
          }
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_break_id);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_break_id, __pyx_t_10);
          __Pyx_GIVEREF(__pyx_t_10);
          __pyx_t_10 = 0;

          /* "ws_package/controllers/activity_controller.py":3044
 *                         )
 *                         break_id = self._empty_interval_break_id(start_time)
 *                         if await self.activity_service.check_existing_interval(             # <<<<<<<<<<<<<<
 *                             start_time, interval_end_time, exact=True
 *                         ):
*/
          __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3044, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_2 = __pyx_t_13;
          __Pyx_INCREF(__pyx_t_2);

          /* "ws_package/controllers/activity_controller.py":3045
 *                         break_id = self._empty_interval_break_id(start_time)
 *                         if await self.activity_service.check_existing_interval(
 *                             start_time, interval_end_time, exact=True             # <<<<<<<<<<<<<<
 *                         ):
 *                             logger.info(
*/
          __pyx_t_5 = 0;
          {
            PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_start_time, __pyx_cur_scope->__pyx_v_interval_end_time};
            __pyx_t_1 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3044, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_1);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exact, Py_True, __pyx_t_1, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 3044, __pyx_L1_error)
            __pyx_t_10 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_check_existing_interval, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_1);
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3044, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
          }
          __pyx_t_6 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_10, &__pyx_r);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (likely(__pyx_t_6 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_4);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_4;
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
            __Pyx_XGIVEREF(__pyx_t_15);
            __pyx_cur_scope->__pyx_t_3 = __pyx_t_15;
            __pyx_cur_scope->__pyx_t_4 = __pyx_t_19;
            __pyx_cur_scope->__pyx_t_5 = __pyx_t_20;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 5;
            return __pyx_r;
            __pyx_L52_resume_from_await:;
            __pyx_t_4 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_4);
            __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
            __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
            __pyx_t_15 = __pyx_cur_scope->__pyx_t_3;
            __pyx_cur_scope->__pyx_t_3 = 0;
            __Pyx_XGOTREF(__pyx_t_15);
            __pyx_t_19 = __pyx_cur_scope->__pyx_t_4;
            __pyx_t_20 = __pyx_cur_scope->__pyx_t_5;
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3044, __pyx_L1_error)
            __pyx_t_10 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_10);
          } else if (likely(__pyx_t_6 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __pyx_t_10 = __pyx_r; __pyx_r = NULL;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 3044, __pyx_L1_error)
          }

          /* "ws_package/controllers/activity_controller.py":3044
 *                         )
 *                         break_id = self._empty_interval_break_id(start_time)
 *                         if await self.activity_service.check_existing_interval(             # <<<<<<<<<<<<<<
 *                             start_time, interval_end_time, exact=True
 *                         ):
*/
          __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_12 < 0))) __PYX_ERR(0, 3044, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (__pyx_t_12) {

            /* "ws_package/controllers/activity_controller.py":3047
 *                             start_time, interval_end_time, exact=True
 *                         ):
 *                             logger.info(             # <<<<<<<<<<<<<<
 *                                 "Skip sleep gap fill  interval already exists for %s to %s",
 *                                 start_time,
*/
            __pyx_t_13 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3047, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3047, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

            /* "ws_package/controllers/activity_controller.py":3050
 *                                 "Skip sleep gap fill  interval already exists for %s to %s",
 *                                 start_time,
 *                                 interval_end_time,             # <<<<<<<<<<<<<<
 *                             )
 *                             start_time = interval_end_time
*/
            __pyx_t_5 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_2))) {
              __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_2);
              assert(__pyx_t_13);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_13);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
              __pyx_t_5 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[4] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Skip_sleep_gap_fill_interval_alr, __pyx_cur_scope->__pyx_v_start_time, __pyx_cur_scope->__pyx_v_interval_end_time};
              __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_5, (4-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3047, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_10);
            }
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

            /* "ws_package/controllers/activity_controller.py":3052
 *                                 interval_end_time,
 *                             )
 *                             start_time = interval_end_time             # <<<<<<<<<<<<<<
 *                             continue
 *                         gap_level = await self._activity_level_for_gap_fill(
*/
            __Pyx_INCREF(__pyx_cur_scope->__pyx_v_interval_end_time);
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_start_time);
            __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_start_time, __pyx_cur_scope->__pyx_v_interval_end_time);
            __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_interval_end_time);

            /* "ws_package/controllers/activity_controller.py":3053
 *                             )
 *                             start_time = interval_end_time
 *                             continue             # <<<<<<<<<<<<<<
 *                         gap_level = await self._activity_level_for_gap_fill(
 *                             start_time, interval_end_time
*/
            goto __pyx_L49_continue;

            /* "ws_package/controllers/activity_controller.py":3044
 *                         )
 *                         break_id = self._empty_interval_break_id(start_time)
 *                         if await self.activity_service.check_existing_interval(             # <<<<<<<<<<<<<<
 *                             start_time, interval_end_time, exact=True
 *                         ):
*/
          }

          /* "ws_package/controllers/activity_controller.py":3054
 *                             start_time = interval_end_time
 *                             continue
 *                         gap_level = await self._activity_level_for_gap_fill(             # <<<<<<<<<<<<<<
 *                             start_time, interval_end_time
 *                         )
*/
          __pyx_t_2 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_2);

          /* "ws_package/controllers/activity_controller.py":3055
 *                             continue
 *                         gap_level = await self._activity_level_for_gap_fill(
 *                             start_time, interval_end_time             # <<<<<<<<<<<<<<
 *                         )
 *                         if await self.inrange(start_time, interval_end_time) and self.status is True:
*/
          __pyx_t_5 = 0;
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_start_time, __pyx_cur_scope->__pyx_v_interval_end_time};
            __pyx_t_10 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_activity_level_for_gap_fill, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3054, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
          }
          __pyx_t_6 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_10, &__pyx_r);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (likely(__pyx_t_6 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_4);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_4;
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
            __Pyx_XGIVEREF(__pyx_t_15);
            __pyx_cur_scope->__pyx_t_3 = __pyx_t_15;
            __pyx_cur_scope->__pyx_t_4 = __pyx_t_19;
            __pyx_cur_scope->__pyx_t_5 = __pyx_t_20;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 6;
            return __pyx_r;
            __pyx_L53_resume_from_await:;
            __pyx_t_4 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_4);
            __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
            __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
            __pyx_t_15 = __pyx_cur_scope->__pyx_t_3;
            __pyx_cur_scope->__pyx_t_3 = 0;
            __Pyx_XGOTREF(__pyx_t_15);
            __pyx_t_19 = __pyx_cur_scope->__pyx_t_4;
            __pyx_t_20 = __pyx_cur_scope->__pyx_t_5;
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3054, __pyx_L1_error)
            __pyx_t_10 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_10);
          } else if (likely(__pyx_t_6 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __pyx_t_10 = __pyx_r; __pyx_r = NULL;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 3054, __pyx_L1_error)
          }
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_gap_level);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_gap_level, __pyx_t_10);
          __Pyx_GIVEREF(__pyx_t_10);
          __pyx_t_10 = 0;

          /* "ws_package/controllers/activity_controller.py":3057
 *                             start_time, interval_end_time
 *                         )
 *                         if await self.inrange(start_time, interval_end_time) and self.status is True:             # <<<<<<<<<<<<<<
 *                             logger.info(
 *                                 f"Add Empty Interval in range of tracking mode: {start_time} - {interval_end_time}"
*/
          __pyx_t_2 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_2);
          __pyx_t_5 = 0;
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_start_time, __pyx_cur_scope->__pyx_v_interval_end_time};
            __pyx_t_10 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_inrange, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3057, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_10);
          }
          __pyx_t_6 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_10, &__pyx_r);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (likely(__pyx_t_6 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_4);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_4;
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
            __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
            __Pyx_XGIVEREF(__pyx_t_15);
            __pyx_cur_scope->__pyx_t_3 = __pyx_t_15;
            __pyx_cur_scope->__pyx_t_4 = __pyx_t_19;
            __pyx_cur_scope->__pyx_t_5 = __pyx_t_20;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 7;
            return __pyx_r;
            __pyx_L57_resume_from_await:;
            __pyx_t_4 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_4);
            __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
            __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
            __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
            __pyx_t_15 = __pyx_cur_scope->__pyx_t_3;
            __pyx_cur_scope->__pyx_t_3 = 0;
            __Pyx_XGOTREF(__pyx_t_15);
            __pyx_t_19 = __pyx_cur_scope->__pyx_t_4;
            __pyx_t_20 = __pyx_cur_scope->__pyx_t_5;
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3057, __pyx_L1_error)
            __pyx_t_10 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_10);
          } else if (likely(__pyx_t_6 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __pyx_t_10 = __pyx_r; __pyx_r = NULL;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 3057, __pyx_L1_error)
          }
          __pyx_t_18 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_18 < 0))) __PYX_ERR(0, 3057, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (__pyx_t_18) {
          } else {
            __pyx_t_12 = __pyx_t_18;
            goto __pyx_L55_bool_binop_done;
          }
          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3057, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_18 = (__pyx_t_10 == Py_True);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_12 = __pyx_t_18;
          __pyx_L55_bool_binop_done:;
          if (__pyx_t_12) {

            /* "ws_package/controllers/activity_controller.py":3058
 *                         )
 *                         if await self.inrange(start_time, interval_end_time) and self.status is True:
 *                             logger.info(             # <<<<<<<<<<<<<<
 *                                 f"Add Empty Interval in range of tracking mode: {start_time} - {interval_end_time}"
 *                             )
*/
            __pyx_t_2 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3058, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_13);
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3058, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

            /* "ws_package/controllers/activity_controller.py":3059
 *                         if await self.inrange(start_time, interval_end_time) and self.status is True:
 *                             logger.info(
 *                                 f"Add Empty Interval in range of tracking mode: {start_time} - {interval_end_time}"             # <<<<<<<<<<<<<<
 *                             )
 *                             logger.info("user main status activity saved  >>  %s", self.status)
*/
            __pyx_t_13 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_start_time, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3059, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_13);
            __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_interval_end_time, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3059, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_33[0] = __pyx_mstate_global->__pyx_kp_u_Add_Empty_Interval_in_range_of_t;
            __pyx_t_33[1] = __pyx_t_13;
            __pyx_t_33[2] = __pyx_mstate_global->__pyx_kp_u__8;
            __pyx_t_33[3] = __pyx_t_3;
            __pyx_t_17 = __Pyx_PyUnicode_Join(__pyx_t_33, 4, 46 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_13) + 3 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3), 127 | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3));
            if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3059, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_17);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __pyx_t_5 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_1))) {
              __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
              assert(__pyx_t_2);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
              __Pyx_INCREF(__pyx_t_2);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
              __pyx_t_5 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_17};
              __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3058, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_10);
            }
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

            /* "ws_package/controllers/activity_controller.py":3061
 *                                 f"Add Empty Interval in range of tracking mode: {start_time} - {interval_end_time}"
 *                             )
 *                             logger.info("user main status activity saved  >>  %s", self.status)             # <<<<<<<<<<<<<<
 *                             await self.activity_service.save_activity_log(
 *                                 gap_level,
*/
            __pyx_t_1 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3061, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_17);
            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3061, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3061, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_17);
            __pyx_t_5 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_2))) {
              __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
              assert(__pyx_t_1);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_1);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
              __pyx_t_5 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_user_main_status_activity_saved, __pyx_t_17};
              __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3061, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_10);
            }
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

            /* "ws_package/controllers/activity_controller.py":3062
 *                             )
 *                             logger.info("user main status activity saved  >>  %s", self.status)
 *                             await self.activity_service.save_activity_log(             # <<<<<<<<<<<<<<
 *                                 gap_level,
 *                                 start_time,
*/
            __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3062, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_17);
            __pyx_t_2 = __pyx_t_17;
            __Pyx_INCREF(__pyx_t_2);

            /* "ws_package/controllers/activity_controller.py":3066
 *                                 start_time,
 *                                 interval_end_time,
 *                                 self.last_count + 1,             # <<<<<<<<<<<<<<
 *                                 self.get_today_weekday(),
 *                                 break_id=break_id,
*/
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3066, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_3 = __Pyx_PyLong_AddObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3066, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

            /* "ws_package/controllers/activity_controller.py":3067
 *                                 interval_end_time,
 *                                 self.last_count + 1,
 *                                 self.get_today_weekday(),             # <<<<<<<<<<<<<<
 *                                 break_id=break_id,
 *                             )
*/
            __pyx_t_13 = __pyx_cur_scope->__pyx_v_self;
            __Pyx_INCREF(__pyx_t_13);
            __pyx_t_5 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_13, NULL};
              __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_today_weekday, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3067, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_1);
            }

            /* "ws_package/controllers/activity_controller.py":3068
 *                                 self.last_count + 1,
 *                                 self.get_today_weekday(),
 *                                 break_id=break_id,             # <<<<<<<<<<<<<<
 *                             )
 *                         else:
*/
            __pyx_t_5 = 0;
            {
              PyObject *__pyx_callargs[6 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_gap_level, __pyx_cur_scope->__pyx_v_start_time, __pyx_cur_scope->__pyx_v_interval_end_time, __pyx_t_3, __pyx_t_1};
              __pyx_t_13 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3062, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_13);
              if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_break_id, __pyx_cur_scope->__pyx_v_break_id, __pyx_t_13, __pyx_callargs+6, 0) < (0)) __PYX_ERR(0, 3062, __pyx_L1_error)
              __pyx_t_10 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_save_activity_log, __pyx_callargs+__pyx_t_5, (6-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_13);
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
              if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3062, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_10);
            }
            __pyx_t_6 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_10, &__pyx_r);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            if (likely(__pyx_t_6 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_4);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_4;
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
              __Pyx_XGIVEREF(__pyx_t_15);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_15;
              __pyx_cur_scope->__pyx_t_4 = __pyx_t_19;
              __pyx_cur_scope->__pyx_t_5 = __pyx_t_20;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 8;
              return __pyx_r;
              __pyx_L58_resume_from_await:;
              __pyx_t_4 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_4);
              __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
              __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
              __pyx_t_15 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_15);
              __pyx_t_19 = __pyx_cur_scope->__pyx_t_4;
              __pyx_t_20 = __pyx_cur_scope->__pyx_t_5;
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3062, __pyx_L1_error)
            } else if (likely(__pyx_t_6 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_DECREF(__pyx_r); __pyx_r = 0;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 3062, __pyx_L1_error)
            }

            /* "ws_package/controllers/activity_controller.py":3057
 *                             start_time, interval_end_time
 *                         )
 *                         if await self.inrange(start_time, interval_end_time) and self.status is True:             # <<<<<<<<<<<<<<
 *                             logger.info(
 *                                 f"Add Empty Interval in range of tracking mode: {start_time} - {interval_end_time}"
*/
            goto __pyx_L54;
          }

          /* "ws_package/controllers/activity_controller.py":3071
 *                             )
 *                         else:
 *                             logger.info(             # <<<<<<<<<<<<<<
 *                                 f"Exclude Empty Interval becasue it is out of range of tracking mode: {start_time} - {interval_end_time}"
 *                             )
*/
          /*else*/ {
            __pyx_t_17 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3071, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_13);
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3071, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

            /* "ws_package/controllers/activity_controller.py":3072
 *                         else:
 *                             logger.info(
 *                                 f"Exclude Empty Interval becasue it is out of range of tracking mode: {start_time} - {interval_end_time}"             # <<<<<<<<<<<<<<
 *                             )
 *                             logger.info("user main status activity saved  >>  %s", self.status)
*/
            __pyx_t_13 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_start_time, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3072, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_13);
            __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_interval_end_time, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3072, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_33[0] = __pyx_mstate_global->__pyx_kp_u_Exclude_Empty_Interval_becasue_i;
            __pyx_t_33[1] = __pyx_t_13;
            __pyx_t_33[2] = __pyx_mstate_global->__pyx_kp_u__8;
            __pyx_t_33[3] = __pyx_t_3;
            __pyx_t_2 = __Pyx_PyUnicode_Join(__pyx_t_33, 4, 68 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_13) + 3 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3), 127 | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3));
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3072, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __pyx_t_5 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_1))) {
              __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_1);
              assert(__pyx_t_17);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
              __Pyx_INCREF(__pyx_t_17);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
              __pyx_t_5 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_17, __pyx_t_2};
              __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3071, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_10);
            }
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

            /* "ws_package/controllers/activity_controller.py":3074
 *                                 f"Exclude Empty Interval becasue it is out of range of tracking mode: {start_time} - {interval_end_time}"
 *                             )
 *                             logger.info("user main status activity saved  >>  %s", self.status)             # <<<<<<<<<<<<<<
 *                             await self.activity_service.save_first_activity_log(
 *                                 gap_level,
*/
            __pyx_t_1 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3074, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3074, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_17);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3074, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_5 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_17))) {
              __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_17);
              assert(__pyx_t_1);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
              __Pyx_INCREF(__pyx_t_1);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
              __pyx_t_5 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_user_main_status_activity_saved, __pyx_t_2};
              __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
              if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3074, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_10);
            }
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

            /* "ws_package/controllers/activity_controller.py":3075
 *                             )
 *                             logger.info("user main status activity saved  >>  %s", self.status)
 *                             await self.activity_service.save_first_activity_log(             # <<<<<<<<<<<<<<
 *                                 gap_level,
 *                                 start_time,
*/
            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3075, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_17 = __pyx_t_2;
            __Pyx_INCREF(__pyx_t_17);

            /* "ws_package/controllers/activity_controller.py":3079
 *                                 start_time,
 *                                 interval_end_time,
 *                                 self.last_count + 1,             # <<<<<<<<<<<<<<
 *                                 self.get_today_weekday(),
 *                                 break_id=break_id,
*/
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3079, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_3 = __Pyx_PyLong_AddObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3079, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

            /* "ws_package/controllers/activity_controller.py":3080
 *                                 interval_end_time,
 *                                 self.last_count + 1,
 *                                 self.get_today_weekday(),             # <<<<<<<<<<<<<<
 *                                 break_id=break_id,
 *                             )
*/
            __pyx_t_13 = __pyx_cur_scope->__pyx_v_self;
            __Pyx_INCREF(__pyx_t_13);
            __pyx_t_5 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_13, NULL};
              __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_today_weekday, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3080, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_1);
            }

            /* "ws_package/controllers/activity_controller.py":3081
 *                                 self.last_count + 1,
 *                                 self.get_today_weekday(),
 *                                 break_id=break_id,             # <<<<<<<<<<<<<<
 *                             )
 *                         start_time = interval_end_time
*/
            __pyx_t_5 = 0;
            {
              PyObject *__pyx_callargs[6 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_17, __pyx_cur_scope->__pyx_v_gap_level, __pyx_cur_scope->__pyx_v_start_time, __pyx_cur_scope->__pyx_v_interval_end_time, __pyx_t_3, __pyx_t_1};
              __pyx_t_13 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3075, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_13);
              if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_break_id, __pyx_cur_scope->__pyx_v_break_id, __pyx_t_13, __pyx_callargs+6, 0) < (0)) __PYX_ERR(0, 3075, __pyx_L1_error)
              __pyx_t_10 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_save_first_activity_log, __pyx_callargs+__pyx_t_5, (6-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_13);
              __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3075, __pyx_L1_error)
              __Pyx_GOTREF(__pyx_t_10);
            }
            __pyx_t_6 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_10, &__pyx_r);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            if (likely(__pyx_t_6 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_4);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_4;
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
              __Pyx_XGIVEREF(__pyx_t_15);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_15;
              __pyx_cur_scope->__pyx_t_4 = __pyx_t_19;
              __pyx_cur_scope->__pyx_t_5 = __pyx_t_20;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 9;
              return __pyx_r;
              __pyx_L59_resume_from_await:;
              __pyx_t_4 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_4);
              __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
              __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
              __pyx_t_15 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_15);
              __pyx_t_19 = __pyx_cur_scope->__pyx_t_4;
              __pyx_t_20 = __pyx_cur_scope->__pyx_t_5;
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3075, __pyx_L1_error)
            } else if (likely(__pyx_t_6 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_DECREF(__pyx_r); __pyx_r = 0;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 3075, __pyx_L1_error)
            }
          }
          __pyx_L54:;

          /* "ws_package/controllers/activity_controller.py":3083
 *                                 break_id=break_id,
 *                             )
 *                         start_time = interval_end_time             # <<<<<<<<<<<<<<
 * 
 * 
*/
          __Pyx_INCREF(__pyx_cur_scope->__pyx_v_interval_end_time);
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_start_time);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_start_time, __pyx_cur_scope->__pyx_v_interval_end_time);
          __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_interval_end_time);
          __pyx_L49_continue:;
        }

        /* "ws_package/controllers/activity_controller.py":3037
 *                 else:
 *                     logger.info("Sleep is less than 1 hour adding up intervals")
 *                 for seg_start, seg_end in sub_segments:             # <<<<<<<<<<<<<<
 *                     start_time = seg_start
 *                     while start_time < seg_end:
*/
      }
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
    }
    __pyx_L13:;

    /* "ws_package/controllers/activity_controller.py":2980
 *         logger.info("System is in sleep: %s", missing_intervals)
 * 
 *         for gap_start, gap_end in missing_intervals:             # <<<<<<<<<<<<<<
 *             overlapping = await self.get_intervals_overlapping_range(gap_start, gap_end)
 *             sub_segments = self._subtract_overlapping_intervals(gap_start, gap_end, overlapping)
*/
    __pyx_L6_continue:;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":2969
 *                 continue
 * 
 *     async def empty_interval(self, user_entity: UserEntity):             # <<<<<<<<<<<<<<
 *         logger.info("Running push empty intervals")
 *         current = self.last_count + 1
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_17);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("empty_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_108generator22(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":3086
 * 
 * 
 *     async def _push_activity_log(self, user_entity: UserEntity, stop_event=None):             # <<<<<<<<<<<<<<
 *         while not stop_event.is_set():
 *             try:
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_107_push_activity_log(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_107_push_activity_log = {"_push_activity_log", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_107_push_activity_log, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_107_push_activity_log(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_user_entity = 0;
  PyObject *__pyx_v_stop_event = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_push_activity_log (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_user_entity,&__pyx_mstate_global->__pyx_n_u_stop_event,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 3086, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 3086, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3086, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3086, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_push_activity_log", 0) < (0)) __PYX_ERR(0, 3086, __pyx_L3_error)
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject *)Py_None));
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_push_activity_log", 0, 2, 3, i); __PYX_ERR(0, 3086, __pyx_L3_error) }
      }
    } else {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 3086, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3086, __pyx_L3_error)
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3086, __pyx_L3_error)
        break;
        default: goto __pyx_L5_argtuple_error;
      }
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject *)Py_None));
    }
    __pyx_v_self = values[0];
    __pyx_v_user_entity = values[1];
    __pyx_v_stop_event = values[2];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_push_activity_log", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 3086, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._push_activity_log", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_106_push_activity_log(__pyx_self, __pyx_v_self, __pyx_v_user_entity, __pyx_v_stop_event);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_106_push_activity_log(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity, PyObject *__pyx_v_stop_event) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_push_activity_log", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 3086, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_user_entity = __pyx_v_user_entity;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_user_entity);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_user_entity);
  __pyx_cur_scope->__pyx_v_stop_event = __pyx_v_stop_event;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_stop_event);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_stop_event);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_108generator22, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[38]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_push_activity_log, __pyx_mstate_global->__pyx_n_u_ActivityController__push_activit, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 3086, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._push_activity_log", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_108generator22(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  size_t __pyx_t_3;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  __Pyx_PySendResult __pyx_t_15;
  int __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  Py_ssize_t __pyx_t_19;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  int __pyx_t_22;
  char const *__pyx_t_23;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  PyObject *__pyx_t_26 = NULL;
  PyObject *__pyx_t_27 = NULL;
  PyObject *__pyx_t_28 = NULL;
  PyObject *__pyx_t_29 = NULL;
  char const *__pyx_t_30;
  int __pyx_t_31;
  PyObject *(*__pyx_t_32)(PyObject *);
  int __pyx_t_33;
  Py_ssize_t __pyx_t_34;
  char const *__pyx_t_35;
  PyObject *(*__pyx_t_36)(PyObject *);
  char const *__pyx_t_37;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_push_activity_log", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L24_resume_from_await;
    case 2: goto __pyx_L30_resume_from_await;
    case 3: goto __pyx_L62_resume_from_await;
    case 4: goto __pyx_L74_resume_from_await;
    case 5: goto __pyx_L77_resume_from_await;
    case 6: goto __pyx_L78_resume_from_await;
    case 7: goto __pyx_L82_resume_from_await;
    case 8: goto __pyx_L84_resume_from_await;
    case 9: goto __pyx_L85_resume_from_await;
    case 10: goto __pyx_L86_resume_from_await;
    case 11: goto __pyx_L88_resume_from_await;
    case 12: goto __pyx_L90_resume_from_await;
    case 13: goto __pyx_L92_resume_from_await;
    case 14: goto __pyx_L101_resume_from_await;
    case 15: goto __pyx_L115_resume_from_await;
    case 16: goto __pyx_L136_resume_from_await;
    case 17: goto __pyx_L174_resume_from_await;
    case 18: goto __pyx_L179_resume_from_await;
    case 19: goto __pyx_L184_resume_from_await;
    case 20: goto __pyx_L188_resume_from_await;
    case 21: goto __pyx_L191_resume_from_await;
    case 22: goto __pyx_L195_resume_from_await;
    case 23: goto __pyx_L204_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 3086, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":3087
 * 
 *     async def _push_activity_log(self, user_entity: UserEntity, stop_event=None):
 *         while not stop_event.is_set():             # <<<<<<<<<<<<<<
 *             try:
 *                 current_break_id = getattr(self, 'break_id', 0) or 0
*/
  while (1) {
    __pyx_t_2 = __pyx_cur_scope->__pyx_v_stop_event;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_3 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
      __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_set, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3087, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 3087, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __pyx_t_5 = (!__pyx_t_4);
    if (!__pyx_t_5) break;

    /* "ws_package/controllers/activity_controller.py":3088
 *     async def _push_activity_log(self, user_entity: UserEntity, stop_event=None):
 *         while not stop_event.is_set():
 *             try:             # <<<<<<<<<<<<<<
 *                 current_break_id = getattr(self, 'break_id', 0) or 0
 *                 try:
*/
    {
      __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":3089
 *         while not stop_event.is_set():
 *             try:
 *                 current_break_id = getattr(self, 'break_id', 0) or 0             # <<<<<<<<<<<<<<
 *                 try:
 *                     await asyncio.wait_for(
*/
        __pyx_t_2 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_break_id, __pyx_mstate_global->__pyx_int_0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3089, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 3089, __pyx_L6_error)
        if (!__pyx_t_5) {
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        } else {
          __Pyx_INCREF(__pyx_t_2);
          __pyx_t_1 = __pyx_t_2;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          goto __pyx_L14_bool_binop_done;
        }
        __pyx_t_2 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3089, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = __pyx_t_2;
        __pyx_t_2 = 0;
        __pyx_L14_bool_binop_done:;
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_current_break_id);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_current_break_id, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":3090
 *             try:
 *                 current_break_id = getattr(self, 'break_id', 0) or 0
 *                 try:             # <<<<<<<<<<<<<<
 *                     await asyncio.wait_for(
 *                         self.update_tracking_duration(user_entity),
*/
        {
          __Pyx_ExceptionSave(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_9);
          __Pyx_XGOTREF(__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_11);
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":3091
 *                 current_break_id = getattr(self, 'break_id', 0) or 0
 *                 try:
 *                     await asyncio.wait_for(             # <<<<<<<<<<<<<<
 *                         self.update_tracking_duration(user_entity),
 *                         timeout=10.0,
*/
            __pyx_t_2 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3091, __pyx_L16_error)
            __Pyx_GOTREF(__pyx_t_12);
            __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_wait_for); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3091, __pyx_L16_error)
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

            /* "ws_package/controllers/activity_controller.py":3092
 *                 try:
 *                     await asyncio.wait_for(
 *                         self.update_tracking_duration(user_entity),             # <<<<<<<<<<<<<<
 *                         timeout=10.0,
 *                     )
*/
            __pyx_t_14 = __pyx_cur_scope->__pyx_v_self;
            __Pyx_INCREF(__pyx_t_14);
            __pyx_t_3 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_14, __pyx_cur_scope->__pyx_v_user_entity};
              __pyx_t_12 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_update_tracking_duration, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
              if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3092, __pyx_L16_error)
              __Pyx_GOTREF(__pyx_t_12);
            }
            __pyx_t_3 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_13))) {
              __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_13);
              assert(__pyx_t_2);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
              __Pyx_INCREF(__pyx_t_2);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
              __pyx_t_3 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_2, __pyx_t_12};
              __pyx_t_14 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3091, __pyx_L16_error)
              __Pyx_GOTREF(__pyx_t_14);
              if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_timeout, __pyx_mstate_global->__pyx_float_10_0, __pyx_t_14, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 3091, __pyx_L16_error)
              __pyx_t_1 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_14);
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3091, __pyx_L16_error)
              __Pyx_GOTREF(__pyx_t_1);
            }
            __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (likely(__pyx_t_15 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_6);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
              __Pyx_XGIVEREF(__pyx_t_7);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
              __Pyx_XGIVEREF(__pyx_t_8);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
              __Pyx_XGIVEREF(__pyx_t_9);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
              __Pyx_XGIVEREF(__pyx_t_10);
              __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
              __Pyx_XGIVEREF(__pyx_t_11);
              __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 1;
              return __pyx_r;
              __pyx_L24_resume_from_await:;
              __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_6);
              __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_7);
              __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_8);
              __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_9);
              __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
              __pyx_cur_scope->__pyx_t_4 = 0;
              __Pyx_XGOTREF(__pyx_t_10);
              __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
              __pyx_cur_scope->__pyx_t_5 = 0;
              __Pyx_XGOTREF(__pyx_t_11);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3091, __pyx_L16_error)
            } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_DECREF(__pyx_r); __pyx_r = 0;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 3091, __pyx_L16_error)
            }

            /* "ws_package/controllers/activity_controller.py":3090
 *             try:
 *                 current_break_id = getattr(self, 'break_id', 0) or 0
 *                 try:             # <<<<<<<<<<<<<<
 *                     await asyncio.wait_for(
 *                         self.update_tracking_duration(user_entity),
*/
          }
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          goto __pyx_L23_try_end;
          __pyx_L16_error:;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":3095
 *                         timeout=10.0,
 *                     )
 *                 except asyncio.TimeoutError:             # <<<<<<<<<<<<<<
 *                     logger.warning(
 *                         "[push] update_tracking_duration timed out after 10s  "
*/
          __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_13, &__pyx_t_14);
          __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3095, __pyx_L18_except_error)
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_TimeoutError); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3095, __pyx_L18_except_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_t_16 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_2);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_ErrRestore(__pyx_t_1, __pyx_t_13, __pyx_t_14);
          __pyx_t_1 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0;
          if (__pyx_t_16) {
            __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._push_activity_log", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_14, &__pyx_t_13, &__pyx_t_1) < 0) __PYX_ERR(0, 3095, __pyx_L18_except_error)
            __Pyx_XGOTREF(__pyx_t_14);
            __Pyx_XGOTREF(__pyx_t_13);
            __Pyx_XGOTREF(__pyx_t_1);

            /* "ws_package/controllers/activity_controller.py":3096
 *                     )
 *                 except asyncio.TimeoutError:
 *                     logger.warning(             # <<<<<<<<<<<<<<
 *                         "[push] update_tracking_duration timed out after 10s  "
 *                         "continuing with cached stealth-mode data"
*/
            __pyx_t_12 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3096, __pyx_L18_except_error)
            __Pyx_GOTREF(__pyx_t_17);
            __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3096, __pyx_L18_except_error)
            __Pyx_GOTREF(__pyx_t_18);
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            __pyx_t_3 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_18))) {
              __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_18);
              assert(__pyx_t_12);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_18);
              __Pyx_INCREF(__pyx_t_12);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_18, __pyx__function);
              __pyx_t_3 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_12, __pyx_mstate_global->__pyx_kp_u_push_update_tracking_duration_t};
              __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_18, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
              if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3096, __pyx_L18_except_error)
              __Pyx_GOTREF(__pyx_t_2);
            }
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            goto __pyx_L17_exception_handled;
          }
          goto __pyx_L18_except_error;

          /* "ws_package/controllers/activity_controller.py":3090
 *             try:
 *                 current_break_id = getattr(self, 'break_id', 0) or 0
 *                 try:             # <<<<<<<<<<<<<<
 *                     await asyncio.wait_for(
 *                         self.update_tracking_duration(user_entity),
*/
          __pyx_L18_except_error:;
          __Pyx_XGIVEREF(__pyx_t_9);
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
          goto __pyx_L6_error;
          __pyx_L17_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_9);
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
          __pyx_L23_try_end:;
        }

        /* "ws_package/controllers/activity_controller.py":3100
 *                         "continuing with cached stealth-mode data"
 *                     )
 *                 logger.info(             # <<<<<<<<<<<<<<
 *                     "Running push loop force_stop=%s, timezone_mismatch=%s, datetime_mismatch=%s, time_error_type=%s",
 *                     self.force_stop,
*/
        __pyx_t_13 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3100, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3100, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

        /* "ws_package/controllers/activity_controller.py":3102
 *                 logger.info(
 *                     "Running push loop force_stop=%s, timezone_mismatch=%s, datetime_mismatch=%s, time_error_type=%s",
 *                     self.force_stop,             # <<<<<<<<<<<<<<
 *                     self._timezone_mismatch,
 *                     self._datetime_mismatch,
*/
        __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_force_stop); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3102, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_14);

        /* "ws_package/controllers/activity_controller.py":3103
 *                     "Running push loop force_stop=%s, timezone_mismatch=%s, datetime_mismatch=%s, time_error_type=%s",
 *                     self.force_stop,
 *                     self._timezone_mismatch,             # <<<<<<<<<<<<<<
 *                     self._datetime_mismatch,
 *                     self._time_error_type,
*/
        __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_timezone_mismatch); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3103, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_18);

        /* "ws_package/controllers/activity_controller.py":3104
 *                     self.force_stop,
 *                     self._timezone_mismatch,
 *                     self._datetime_mismatch,             # <<<<<<<<<<<<<<
 *                     self._time_error_type,
 *                 )
*/
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_datetime_mismatch); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3104, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_12);

        /* "ws_package/controllers/activity_controller.py":3105
 *                     self._timezone_mismatch,
 *                     self._datetime_mismatch,
 *                     self._time_error_type,             # <<<<<<<<<<<<<<
 *                 )
 *                 if (
*/
        __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_time_error_type); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3105, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_3 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_2);
          assert(__pyx_t_13);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
          __pyx_t_3 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[6] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Running_push_loop_force_stop_s_t, __pyx_t_14, __pyx_t_18, __pyx_t_12, __pyx_t_17};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_3, (6-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3100, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":3108
 *                 )
 *                 if (
 *                     self._timezone_mismatch is True             # <<<<<<<<<<<<<<
 *                     and self._timezone_checks_enabled(user_entity)
 *                 ):
*/
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_timezone_mismatch); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3108, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_4 = (__pyx_t_1 == Py_True);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (__pyx_t_4) {
        } else {
          __pyx_t_5 = __pyx_t_4;
          goto __pyx_L28_bool_binop_done;
        }

        /* "ws_package/controllers/activity_controller.py":3109
 *                 if (
 *                     self._timezone_mismatch is True
 *                     and self._timezone_checks_enabled(user_entity)             # <<<<<<<<<<<<<<
 *                 ):
 *                     # Real timezone mismatch from timecheck or monitor  stop sync.
*/
        __pyx_t_2 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_2);
        __pyx_t_3 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_user_entity};
          __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_timezone_checks_enabled, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3109, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 3109, __pyx_L6_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_5 = __pyx_t_4;
        __pyx_L28_bool_binop_done:;

        /* "ws_package/controllers/activity_controller.py":3107
 *                     self._time_error_type,
 *                 )
 *                 if (             # <<<<<<<<<<<<<<
 *                     self._timezone_mismatch is True
 *                     and self._timezone_checks_enabled(user_entity)
*/
        if (__pyx_t_5) {

          /* "ws_package/controllers/activity_controller.py":3112
 *                 ):
 *                     # Real timezone mismatch from timecheck or monitor  stop sync.
 *                     logger.info("Timezone mismatch under Push loop")             # <<<<<<<<<<<<<<
 *                     active_app_url = [{
 *                         "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),
*/
          __pyx_t_2 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3112, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3112, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __pyx_t_3 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_12))) {
            __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_12);
            assert(__pyx_t_2);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
            __Pyx_INCREF(__pyx_t_2);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
            __pyx_t_3 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Timezone_mismatch_under_Push_loo};
            __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3112, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_1);
          }
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":3114
 *                     logger.info("Timezone mismatch under Push loop")
 *                     active_app_url = [{
 *                         "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),             # <<<<<<<<<<<<<<
 *                         "module": "Wrong Timestamp",
 *                         "active_app": "Wrong Timestamp",
*/
          __pyx_t_1 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3114, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_2 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_time); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3114, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_strftime); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3114, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_18);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __pyx_t_3 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_18))) {
            __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_18);
            assert(__pyx_t_2);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_18);
            __Pyx_INCREF(__pyx_t_2);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_18, __pyx__function);
            __pyx_t_3 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Y_m_d_H_M_S};
            __pyx_t_12 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_18, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
            if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3114, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_12);
          }
          __pyx_t_18 = __Pyx_PyObject_Unicode(__pyx_t_12); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3114, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_18);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_timestamp, __pyx_t_18) < (0)) __PYX_ERR(0, 3114, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
          if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_module, __pyx_mstate_global->__pyx_kp_u_Wrong_Timestamp) < (0)) __PYX_ERR(0, 3114, __pyx_L6_error)
          if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_active_app, __pyx_mstate_global->__pyx_kp_u_Wrong_Timestamp) < (0)) __PYX_ERR(0, 3114, __pyx_L6_error)
          if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_url, __pyx_mstate_global->__pyx_kp_u_Wrong_Timestamp) < (0)) __PYX_ERR(0, 3114, __pyx_L6_error)

          /* "ws_package/controllers/activity_controller.py":3113
 *                     # Real timezone mismatch from timecheck or monitor  stop sync.
 *                     logger.info("Timezone mismatch under Push loop")
 *                     active_app_url = [{             # <<<<<<<<<<<<<<
 *                         "timestamp": str(time.strftime('%Y-%m-%d %H:%M:%S')),
 *                         "module": "Wrong Timestamp",
*/
          __pyx_t_18 = PyList_New(1); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3113, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_18);
          __Pyx_GIVEREF(__pyx_t_1);
          if (__Pyx_PyList_SET_ITEM(__pyx_t_18, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 3113, __pyx_L6_error);
          __pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_active_app_url);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_active_app_url, ((PyObject*)__pyx_t_18));
          __Pyx_GIVEREF(__pyx_t_18);
          __pyx_t_18 = 0;

          /* "ws_package/controllers/activity_controller.py":3120
 *                     }]
 * 
 *                     await self.activity_service.save_app_monitors(active_app_url, self.last_count+1, True),             # <<<<<<<<<<<<<<
 * 
 *                     logger.info("save last active app as true because of wrong timezone deteceted so next last min save can't be wrong from activity")
*/
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3120, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_1 = __pyx_t_12;
          __Pyx_INCREF(__pyx_t_1);
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3120, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_17 = __Pyx_PyLong_AddObjC(__pyx_t_2, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3120, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_17);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_3 = 0;
          {
            PyObject *__pyx_callargs[4] = {__pyx_t_1, __pyx_cur_scope->__pyx_v_active_app_url, __pyx_t_17, Py_True};
            __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_save_app_monitors, __pyx_callargs+__pyx_t_3, (4-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3120, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_18);
          }
          __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_18, &__pyx_r);
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
          if (likely(__pyx_t_15 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_6);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
            __Pyx_XGIVEREF(__pyx_t_7);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
            __Pyx_XGIVEREF(__pyx_t_8);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 2;
            return __pyx_r;
            __pyx_L30_resume_from_await:;
            __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_6);
            __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_7);
            __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_8);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3120, __pyx_L6_error)
            __pyx_t_18 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_18);
          } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __pyx_t_18 = __pyx_r; __pyx_r = NULL;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 3120, __pyx_L6_error)
          }
          __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3120, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_GIVEREF(__pyx_t_18);
          if (__Pyx_PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_18) != (0)) __PYX_ERR(0, 3120, __pyx_L6_error);
          __pyx_t_18 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

          /* "ws_package/controllers/activity_controller.py":3122
 *                     await self.activity_service.save_app_monitors(active_app_url, self.last_count+1, True),
 * 
 *                     logger.info("save last active app as true because of wrong timezone deteceted so next last min save can't be wrong from activity")             # <<<<<<<<<<<<<<
 *                     url = config('timezone_mismatch', 'Application')
 *                     headers = {
*/
          __pyx_t_18 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3122, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3122, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __pyx_t_3 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_1))) {
            __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_1);
            assert(__pyx_t_18);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_18);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
            __pyx_t_3 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_18, __pyx_mstate_global->__pyx_kp_u_save_last_active_app_as_true_bec};
            __pyx_t_12 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3122, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_12);
          }
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

          /* "ws_package/controllers/activity_controller.py":3123
 * 
 *                     logger.info("save last active app as true because of wrong timezone deteceted so next last min save can't be wrong from activity")
 *                     url = config('timezone_mismatch', 'Application')             # <<<<<<<<<<<<<<
 *                     headers = {
 *                         "Content-Type": "application/json",
*/
          __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_config); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3123, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_mstate_global->__pyx_tuple[22], NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3123, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_url);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_url, __pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_1);
          __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":3125
 *                     url = config('timezone_mismatch', 'Application')
 *                     headers = {
 *                         "Content-Type": "application/json",             # <<<<<<<<<<<<<<
 *                         "Authorization": f"Bearer {user_entity.sd_token}",
 *                         "OrgID": f"{user_entity.org_id}",
*/
          __pyx_t_1 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3125, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
          if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Content_Type, __pyx_mstate_global->__pyx_kp_u_application_json) < (0)) __PYX_ERR(0, 3125, __pyx_L6_error)

          /* "ws_package/controllers/activity_controller.py":3126
 *                     headers = {
 *                         "Content-Type": "application/json",
 *                         "Authorization": f"Bearer {user_entity.sd_token}",             # <<<<<<<<<<<<<<
 *                         "OrgID": f"{user_entity.org_id}",
 *                         "SDToken": f"{user_entity.sd_token}",
*/
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_sd_token); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3126, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_18 = __Pyx_PyObject_FormatSimple(__pyx_t_12, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3126, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_18);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_t_12 = __Pyx_PyUnicode_Concat(__pyx_mstate_global->__pyx_kp_u_Bearer, __pyx_t_18); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3126, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
          if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_Authorization, __pyx_t_12) < (0)) __PYX_ERR(0, 3125, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

          /* "ws_package/controllers/activity_controller.py":3127
 *                         "Content-Type": "application/json",
 *                         "Authorization": f"Bearer {user_entity.sd_token}",
 *                         "OrgID": f"{user_entity.org_id}",             # <<<<<<<<<<<<<<
 *                         "SDToken": f"{user_entity.sd_token}",
 *                         "UserID": f"{user_entity.user_id}"
*/
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_org_id); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3127, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_18 = __Pyx_PyObject_FormatSimple(__pyx_t_12, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3127, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_18);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_OrgID, __pyx_t_18) < (0)) __PYX_ERR(0, 3125, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

          /* "ws_package/controllers/activity_controller.py":3128
 *                         "Authorization": f"Bearer {user_entity.sd_token}",
 *                         "OrgID": f"{user_entity.org_id}",
 *                         "SDToken": f"{user_entity.sd_token}",             # <<<<<<<<<<<<<<
 *                         "UserID": f"{user_entity.user_id}"
 *                     }
*/
          __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_sd_token); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3128, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_18);
          __pyx_t_12 = __Pyx_PyObject_FormatSimple(__pyx_t_18, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3128, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
          if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_SDToken, __pyx_t_12) < (0)) __PYX_ERR(0, 3125, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

          /* "ws_package/controllers/activity_controller.py":3129
 *                         "OrgID": f"{user_entity.org_id}",
 *                         "SDToken": f"{user_entity.sd_token}",
 *                         "UserID": f"{user_entity.user_id}"             # <<<<<<<<<<<<<<
 *                     }
 *                     from ws_package.utils.desktop_key import apply_desktop_key
*/
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_user_id); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3129, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_18 = __Pyx_PyObject_FormatSimple(__pyx_t_12, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3129, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_18);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_UserID, __pyx_t_18) < (0)) __PYX_ERR(0, 3125, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_headers);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_headers, __pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_1);
          __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":3131
 *                         "UserID": f"{user_entity.user_id}"
 *                     }
 *                     from ws_package.utils.desktop_key import apply_desktop_key             # <<<<<<<<<<<<<<
 *                     headers = apply_desktop_key(headers)
 *                     payload = {
*/
          {
            PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_apply_desktop_key};
            __pyx_t_11 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_utils_desktop_key, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3131, __pyx_L6_error)
          }
          __pyx_t_1 = __pyx_t_11;
          __Pyx_GOTREF(__pyx_t_1);
          {
            PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_apply_desktop_key};
            __pyx_t_19 = 0; {
              __pyx_t_18 = __Pyx_ImportFrom(__pyx_t_1, __pyx_imported_names[__pyx_t_19]); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3131, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_18);
              switch (__pyx_t_19) {
                case 0:
                __Pyx_INCREF(__pyx_t_18);
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_apply_desktop_key);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_apply_desktop_key, __pyx_t_18);
                __Pyx_GIVEREF(__pyx_t_18);
                break;
                default:;
              }
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
            }
          }
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":3132
 *                     }
 *                     from ws_package.utils.desktop_key import apply_desktop_key
 *                     headers = apply_desktop_key(headers)             # <<<<<<<<<<<<<<
 *                     payload = {
 *                         "device_type": self.get_os_type_caps(),
*/
          __pyx_t_18 = NULL;
          __Pyx_INCREF(__pyx_cur_scope->__pyx_v_apply_desktop_key);
          __pyx_t_12 = __pyx_cur_scope->__pyx_v_apply_desktop_key; 
          __pyx_t_3 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_12))) {
            __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_12);
            assert(__pyx_t_18);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
            __Pyx_INCREF(__pyx_t_18);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
            __pyx_t_3 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_18, __pyx_cur_scope->__pyx_v_headers};
            __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3132, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_1);
          }
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_headers);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_headers, __pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_1);
          __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":3134
 *                     headers = apply_desktop_key(headers)
 *                     payload = {
 *                         "device_type": self.get_os_type_caps(),             # <<<<<<<<<<<<<<
 *                         "os_name": self.get_os_type_caps(),
 *                         "os_version": get_os_version(),
*/
          __pyx_t_1 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3134, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_18 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_18);
          __pyx_t_3 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_18, NULL};
            __pyx_t_12 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type_caps, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3134, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_12);
          }
          if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_device_type, __pyx_t_12) < (0)) __PYX_ERR(0, 3134, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

          /* "ws_package/controllers/activity_controller.py":3135
 *                     payload = {
 *                         "device_type": self.get_os_type_caps(),
 *                         "os_name": self.get_os_type_caps(),             # <<<<<<<<<<<<<<
 *                         "os_version": get_os_version(),
 *                         "device_id":self.system_unique_id,
*/
          __pyx_t_18 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_18);
          __pyx_t_3 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_18, NULL};
            __pyx_t_12 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type_caps, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3135, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_12);
          }
          if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_os_name, __pyx_t_12) < (0)) __PYX_ERR(0, 3134, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

          /* "ws_package/controllers/activity_controller.py":3136
 *                         "device_type": self.get_os_type_caps(),
 *                         "os_name": self.get_os_type_caps(),
 *                         "os_version": get_os_version(),             # <<<<<<<<<<<<<<
 *                         "device_id":self.system_unique_id,
 *                         "status": 1
*/
          __pyx_t_18 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_get_os_version); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3136, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_3 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_17))) {
            __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_17);
            assert(__pyx_t_18);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
            __Pyx_INCREF(__pyx_t_18);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
            __pyx_t_3 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_18, NULL};
            __pyx_t_12 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3136, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_12);
          }
          if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_os_version, __pyx_t_12) < (0)) __PYX_ERR(0, 3134, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

          /* "ws_package/controllers/activity_controller.py":3137
 *                         "os_name": self.get_os_type_caps(),
 *                         "os_version": get_os_version(),
 *                         "device_id":self.system_unique_id,             # <<<<<<<<<<<<<<
 *                         "status": 1
 *                     }
*/
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_system_unique_id); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3137, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_12);
          if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_device_id, __pyx_t_12) < (0)) __PYX_ERR(0, 3134, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_status, __pyx_mstate_global->__pyx_int_1) < (0)) __PYX_ERR(0, 3134, __pyx_L6_error)
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_payload);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_payload, ((PyObject*)__pyx_t_1));
          __Pyx_GIVEREF(__pyx_t_1);
          __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":3140
 *                         "status": 1
 *                     }
 *                     try:             # <<<<<<<<<<<<<<
 *                         log_testing_request_headers(logger, "POST", url, headers, payload)
 *                         response = requests.post(url, headers=headers, json=payload, timeout=10)
*/
          {
            __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_10, &__pyx_t_9);
            __Pyx_XGOTREF(__pyx_t_11);
            __Pyx_XGOTREF(__pyx_t_10);
            __Pyx_XGOTREF(__pyx_t_9);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":3141
 *                     }
 *                     try:
 *                         log_testing_request_headers(logger, "POST", url, headers, payload)             # <<<<<<<<<<<<<<
 *                         response = requests.post(url, headers=headers, json=payload, timeout=10)
 *                         log_api_response_summary(
*/
              __pyx_t_12 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_log_testing_request_headers); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3141, __pyx_L31_error)
              __Pyx_GOTREF(__pyx_t_17);
              __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3141, __pyx_L31_error)
              __Pyx_GOTREF(__pyx_t_18);
              __pyx_t_3 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_17))) {
                __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_17);
                assert(__pyx_t_12);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
                __Pyx_INCREF(__pyx_t_12);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
                __pyx_t_3 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[6] = {__pyx_t_12, __pyx_t_18, __pyx_mstate_global->__pyx_n_u_POST, __pyx_cur_scope->__pyx_v_url, __pyx_cur_scope->__pyx_v_headers, __pyx_cur_scope->__pyx_v_payload};
                __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_3, (6-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3141, __pyx_L31_error)
                __Pyx_GOTREF(__pyx_t_1);
              }
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

              /* "ws_package/controllers/activity_controller.py":3142
 *                     try:
 *                         log_testing_request_headers(logger, "POST", url, headers, payload)
 *                         response = requests.post(url, headers=headers, json=payload, timeout=10)             # <<<<<<<<<<<<<<
 *                         log_api_response_summary(
 *                             logger,
*/
              __pyx_t_17 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_requests); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3142, __pyx_L31_error)
              __Pyx_GOTREF(__pyx_t_18);
              __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_post); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3142, __pyx_L31_error)
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
              __pyx_t_3 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_12))) {
                __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_12);
                assert(__pyx_t_17);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
                __Pyx_INCREF(__pyx_t_17);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
                __pyx_t_3 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 3 : 0)] = {__pyx_t_17, __pyx_cur_scope->__pyx_v_url};
                __pyx_t_18 = __Pyx_MakeVectorcallBuilderKwds(3); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3142, __pyx_L31_error)
                __Pyx_GOTREF(__pyx_t_18);
                if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_headers, __pyx_cur_scope->__pyx_v_headers, __pyx_t_18, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 3142, __pyx_L31_error)
                if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_json, __pyx_cur_scope->__pyx_v_payload, __pyx_t_18, __pyx_callargs+2, 1) < (0)) __PYX_ERR(0, 3142, __pyx_L31_error)
                if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_timeout, __pyx_mstate_global->__pyx_int_10, __pyx_t_18, __pyx_callargs+2, 2) < (0)) __PYX_ERR(0, 3142, __pyx_L31_error)
                __pyx_t_1 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_18);
                __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3142, __pyx_L31_error)
                __Pyx_GOTREF(__pyx_t_1);
              }
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_response);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_response, __pyx_t_1);
              __Pyx_GIVEREF(__pyx_t_1);
              __pyx_t_1 = 0;

              /* "ws_package/controllers/activity_controller.py":3143
 *                         log_testing_request_headers(logger, "POST", url, headers, payload)
 *                         response = requests.post(url, headers=headers, json=payload, timeout=10)
 *                         log_api_response_summary(             # <<<<<<<<<<<<<<
 *                             logger,
 *                             api_name_from_url(url),
*/
              __pyx_t_12 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_log_api_response_summary); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3143, __pyx_L31_error)
              __Pyx_GOTREF(__pyx_t_18);

              /* "ws_package/controllers/activity_controller.py":3144
 *                         response = requests.post(url, headers=headers, json=payload, timeout=10)
 *                         log_api_response_summary(
 *                             logger,             # <<<<<<<<<<<<<<
 *                             api_name_from_url(url),
 *                             response.status_code,
*/
              __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3144, __pyx_L31_error)
              __Pyx_GOTREF(__pyx_t_17);

              /* "ws_package/controllers/activity_controller.py":3145
 *                         log_api_response_summary(
 *                             logger,
 *                             api_name_from_url(url),             # <<<<<<<<<<<<<<
 *                             response.status_code,
 *                             response.text,
*/
              __pyx_t_14 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_api_name_from_url); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3145, __pyx_L31_error)
              __Pyx_GOTREF(__pyx_t_13);
              __pyx_t_3 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_13))) {
                __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
                assert(__pyx_t_14);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
                __Pyx_INCREF(__pyx_t_14);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
                __pyx_t_3 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_14, __pyx_cur_scope->__pyx_v_url};
                __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3145, __pyx_L31_error)
                __Pyx_GOTREF(__pyx_t_2);
              }

              /* "ws_package/controllers/activity_controller.py":3146
 *                             logger,
 *                             api_name_from_url(url),
 *                             response.status_code,             # <<<<<<<<<<<<<<
 *                             response.text,
 *                         )
*/
              __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_response, __pyx_mstate_global->__pyx_n_u_status_code); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3146, __pyx_L31_error)
              __Pyx_GOTREF(__pyx_t_13);

              /* "ws_package/controllers/activity_controller.py":3147
 *                             api_name_from_url(url),
 *                             response.status_code,
 *                             response.text,             # <<<<<<<<<<<<<<
 *                         )
 *                     except requests.exceptions.Timeout:
*/
              __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_response, __pyx_mstate_global->__pyx_n_u_text); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3147, __pyx_L31_error)
              __Pyx_GOTREF(__pyx_t_14);
              __pyx_t_3 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_18))) {
                __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_18);
                assert(__pyx_t_12);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_18);
                __Pyx_INCREF(__pyx_t_12);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_18, __pyx__function);
                __pyx_t_3 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[5] = {__pyx_t_12, __pyx_t_17, __pyx_t_2, __pyx_t_13, __pyx_t_14};
                __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_18, __pyx_callargs+__pyx_t_3, (5-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3143, __pyx_L31_error)
                __Pyx_GOTREF(__pyx_t_1);
              }
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

              /* "ws_package/controllers/activity_controller.py":3140
 *                         "status": 1
 *                     }
 *                     try:             # <<<<<<<<<<<<<<
 *                         log_testing_request_headers(logger, "POST", url, headers, payload)
 *                         response = requests.post(url, headers=headers, json=payload, timeout=10)
*/
            }
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
            goto __pyx_L38_try_end;
            __pyx_L31_error:;
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;

            /* "ws_package/controllers/activity_controller.py":3149
 *                             response.text,
 *                         )
 *                     except requests.exceptions.Timeout:             # <<<<<<<<<<<<<<
 *                         logger.error("[API] %s | timeout", api_name_from_url(url))
 *                     except requests.exceptions.RequestException as e:
*/
            __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_18, &__pyx_t_14);
            __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_requests); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3149, __pyx_L33_except_error)
            __Pyx_GOTREF(__pyx_t_13);
            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_exceptions); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3149, __pyx_L33_except_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_Timeout); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3149, __pyx_L33_except_error)
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_16 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_13);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_ErrRestore(__pyx_t_1, __pyx_t_18, __pyx_t_14);
            __pyx_t_1 = 0; __pyx_t_18 = 0; __pyx_t_14 = 0;
            if (__pyx_t_16) {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._push_activity_log", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_14, &__pyx_t_18, &__pyx_t_1) < 0) __PYX_ERR(0, 3149, __pyx_L33_except_error)
              __Pyx_XGOTREF(__pyx_t_14);
              __Pyx_XGOTREF(__pyx_t_18);
              __Pyx_XGOTREF(__pyx_t_1);

              /* "ws_package/controllers/activity_controller.py":3150
 *                         )
 *                     except requests.exceptions.Timeout:
 *                         logger.error("[API] %s | timeout", api_name_from_url(url))             # <<<<<<<<<<<<<<
 *                     except requests.exceptions.RequestException as e:
 *                         logger.error("[API] %s | request failed: %s", api_name_from_url(url), e)
*/
              __pyx_t_2 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3150, __pyx_L33_except_error)
              __Pyx_GOTREF(__pyx_t_17);
              __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3150, __pyx_L33_except_error)
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
              __pyx_t_20 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_api_name_from_url); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3150, __pyx_L33_except_error)
              __Pyx_GOTREF(__pyx_t_21);
              __pyx_t_3 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_21))) {
                __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_21);
                assert(__pyx_t_20);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_21);
                __Pyx_INCREF(__pyx_t_20);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_21, __pyx__function);
                __pyx_t_3 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_20, __pyx_cur_scope->__pyx_v_url};
                __pyx_t_17 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_21, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3150, __pyx_L33_except_error)
                __Pyx_GOTREF(__pyx_t_17);
              }
              __pyx_t_3 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_12))) {
                __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_12);
                assert(__pyx_t_2);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
                __Pyx_INCREF(__pyx_t_2);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
                __pyx_t_3 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_API_s_timeout, __pyx_t_17};
                __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3150, __pyx_L33_except_error)
                __Pyx_GOTREF(__pyx_t_13);
              }
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              goto __pyx_L32_exception_handled;
            }

            /* "ws_package/controllers/activity_controller.py":3151
 *                     except requests.exceptions.Timeout:
 *                         logger.error("[API] %s | timeout", api_name_from_url(url))
 *                     except requests.exceptions.RequestException as e:             # <<<<<<<<<<<<<<
 *                         logger.error("[API] %s | request failed: %s", api_name_from_url(url), e)
 * 
*/
            __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_18, &__pyx_t_14);
            __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_requests); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3151, __pyx_L33_except_error)
            __Pyx_GOTREF(__pyx_t_13);
            __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_exceptions); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3151, __pyx_L33_except_error)
            __Pyx_GOTREF(__pyx_t_12);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_RequestException); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3151, __pyx_L33_except_error)
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            __pyx_t_16 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_13);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_ErrRestore(__pyx_t_1, __pyx_t_18, __pyx_t_14);
            __pyx_t_1 = 0; __pyx_t_18 = 0; __pyx_t_14 = 0;
            if (__pyx_t_16) {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._push_activity_log", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_14, &__pyx_t_18, &__pyx_t_1) < 0) __PYX_ERR(0, 3151, __pyx_L33_except_error)
              __Pyx_XGOTREF(__pyx_t_14);
              __Pyx_XGOTREF(__pyx_t_18);
              __Pyx_XGOTREF(__pyx_t_1);
              __Pyx_INCREF(__pyx_t_18);
              __Pyx_GIVEREF(__pyx_t_18);
              __pyx_cur_scope->__pyx_v_e = __pyx_t_18;
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":3152
 *                         logger.error("[API] %s | timeout", api_name_from_url(url))
 *                     except requests.exceptions.RequestException as e:
 *                         logger.error("[API] %s | request failed: %s", api_name_from_url(url), e)             # <<<<<<<<<<<<<<
 * 
 *                     # Send timezone popup only for true timezone mismatch. datetime_error is emitted by time monitor.
*/
                __pyx_t_12 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3152, __pyx_L46_error)
                __Pyx_GOTREF(__pyx_t_17);
                __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3152, __pyx_L46_error)
                __Pyx_GOTREF(__pyx_t_2);
                __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                __pyx_t_21 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_api_name_from_url); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3152, __pyx_L46_error)
                __Pyx_GOTREF(__pyx_t_20);
                __pyx_t_3 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_20))) {
                  __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_20);
                  assert(__pyx_t_21);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_20);
                  __Pyx_INCREF(__pyx_t_21);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_20, __pyx__function);
                  __pyx_t_3 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_21, __pyx_cur_scope->__pyx_v_url};
                  __pyx_t_17 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_20, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                  if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3152, __pyx_L46_error)
                  __Pyx_GOTREF(__pyx_t_17);
                }
                __pyx_t_3 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_2))) {
                  __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_2);
                  assert(__pyx_t_12);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
                  __Pyx_INCREF(__pyx_t_12);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
                  __pyx_t_3 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[4] = {__pyx_t_12, __pyx_mstate_global->__pyx_kp_u_API_s_request_failed_s, __pyx_t_17, __pyx_cur_scope->__pyx_v_e};
                  __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_3, (4-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                  if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3152, __pyx_L46_error)
                  __Pyx_GOTREF(__pyx_t_13);
                }
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              }

              /* "ws_package/controllers/activity_controller.py":3151
 *                     except requests.exceptions.Timeout:
 *                         logger.error("[API] %s | timeout", api_name_from_url(url))
 *                     except requests.exceptions.RequestException as e:             # <<<<<<<<<<<<<<
 *                         logger.error("[API] %s | request failed: %s", api_name_from_url(url), e)
 * 
*/
              /*finally:*/ {
                /*normal exit:*/{
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  goto __pyx_L47;
                }
                __pyx_L46_error:;
                /*exception exit:*/{
                  __Pyx_PyThreadState_assign
                  __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0;
                  __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                  __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                  __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                  __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                  __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                   __Pyx_ExceptionSwap(&__pyx_t_27, &__pyx_t_28, &__pyx_t_29);
                  if ( unlikely(__Pyx_GetException(&__pyx_t_24, &__pyx_t_25, &__pyx_t_26) < 0)) __Pyx_ErrFetch(&__pyx_t_24, &__pyx_t_25, &__pyx_t_26);
                  __Pyx_XGOTREF(__pyx_t_24);
                  __Pyx_XGOTREF(__pyx_t_25);
                  __Pyx_XGOTREF(__pyx_t_26);
                  __Pyx_XGOTREF(__pyx_t_27);
                  __Pyx_XGOTREF(__pyx_t_28);
                  __Pyx_XGOTREF(__pyx_t_29);
                  __pyx_t_16 = __pyx_lineno; __pyx_t_22 = __pyx_clineno; __pyx_t_23 = __pyx_filename;
                  {
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  }
                  __Pyx_XGIVEREF(__pyx_t_27);
                  __Pyx_XGIVEREF(__pyx_t_28);
                  __Pyx_XGIVEREF(__pyx_t_29);
                  __Pyx_ExceptionReset(__pyx_t_27, __pyx_t_28, __pyx_t_29);
                  __Pyx_XGIVEREF(__pyx_t_24);
                  __Pyx_XGIVEREF(__pyx_t_25);
                  __Pyx_XGIVEREF(__pyx_t_26);
                  __Pyx_ErrRestore(__pyx_t_24, __pyx_t_25, __pyx_t_26);
                  __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0;
                  __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_22; __pyx_filename = __pyx_t_23;
                  goto __pyx_L33_except_error;
                }
                __pyx_L47:;
              }
              __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              goto __pyx_L32_exception_handled;
            }
            goto __pyx_L33_except_error;

            /* "ws_package/controllers/activity_controller.py":3140
 *                         "status": 1
 *                     }
 *                     try:             # <<<<<<<<<<<<<<
 *                         log_testing_request_headers(logger, "POST", url, headers, payload)
 *                         response = requests.post(url, headers=headers, json=payload, timeout=10)
*/
            __pyx_L33_except_error:;
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_10);
            __Pyx_XGIVEREF(__pyx_t_9);
            __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_10, __pyx_t_9);
            goto __pyx_L6_error;
            __pyx_L32_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_10);
            __Pyx_XGIVEREF(__pyx_t_9);
            __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_10, __pyx_t_9);
            __pyx_L38_try_end:;
          }

          /* "ws_package/controllers/activity_controller.py":3155
 * 
 *                     # Send timezone popup only for true timezone mismatch. datetime_error is emitted by time monitor.
 *                     try:             # <<<<<<<<<<<<<<
 *                         if self._timezone_mismatch:
 *                             error_data = {
*/
          {
            __Pyx_ExceptionSave(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
            __Pyx_XGOTREF(__pyx_t_9);
            __Pyx_XGOTREF(__pyx_t_10);
            __Pyx_XGOTREF(__pyx_t_11);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":3156
 *                     # Send timezone popup only for true timezone mismatch. datetime_error is emitted by time monitor.
 *                     try:
 *                         if self._timezone_mismatch:             # <<<<<<<<<<<<<<
 *                             error_data = {
 *                                 'title': 'Timezone Error',
*/
              __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_timezone_mismatch); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3156, __pyx_L52_error)
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 3156, __pyx_L52_error)
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (__pyx_t_5) {

                /* "ws_package/controllers/activity_controller.py":3158
 *                         if self._timezone_mismatch:
 *                             error_data = {
 *                                 'title': 'Timezone Error',             # <<<<<<<<<<<<<<
 *                                 'message': 'Your system timezone must match with Workstatus account timezone to start the tracker',
 *                                 'timestamp': datetime.datetime.now().isoformat()
*/
                __pyx_t_1 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3158, __pyx_L52_error)
                __Pyx_GOTREF(__pyx_t_1);
                if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_title, __pyx_mstate_global->__pyx_kp_u_Timezone_Error) < (0)) __PYX_ERR(0, 3158, __pyx_L52_error)
                if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_message, __pyx_mstate_global->__pyx_kp_u_Your_system_timezone_must_match) < (0)) __PYX_ERR(0, 3158, __pyx_L52_error)

                /* "ws_package/controllers/activity_controller.py":3160
 *                                 'title': 'Timezone Error',
 *                                 'message': 'Your system timezone must match with Workstatus account timezone to start the tracker',
 *                                 'timestamp': datetime.datetime.now().isoformat()             # <<<<<<<<<<<<<<
 *                             }
 *                             if self._send_to_electron_if_connected('timezone_error', error_data):
*/
                __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3160, __pyx_L52_error)
                __Pyx_GOTREF(__pyx_t_17);
                __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3160, __pyx_L52_error)
                __Pyx_GOTREF(__pyx_t_12);
                __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                __pyx_t_2 = __pyx_t_12;
                __Pyx_INCREF(__pyx_t_2);
                __pyx_t_3 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
                  __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                  if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3160, __pyx_L52_error)
                  __Pyx_GOTREF(__pyx_t_13);
                }
                __pyx_t_14 = __pyx_t_13;
                __Pyx_INCREF(__pyx_t_14);
                __pyx_t_3 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_14, NULL};
                  __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_isoformat, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                  if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3160, __pyx_L52_error)
                  __Pyx_GOTREF(__pyx_t_18);
                }
                if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_timestamp, __pyx_t_18) < (0)) __PYX_ERR(0, 3158, __pyx_L52_error)
                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_error_data);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_error_data, ((PyObject*)__pyx_t_1));
                __Pyx_GIVEREF(__pyx_t_1);
                __pyx_t_1 = 0;

                /* "ws_package/controllers/activity_controller.py":3162
 *                                 'timestamp': datetime.datetime.now().isoformat()
 *                             }
 *                             if self._send_to_electron_if_connected('timezone_error', error_data):             # <<<<<<<<<<<<<<
 *                                 logger.info("Sent timezone mismatch error to Electron: %s", error_data)
 *                                 await precise_sleep(5, stop_event)
*/
                __pyx_t_18 = __pyx_cur_scope->__pyx_v_self;
                __Pyx_INCREF(__pyx_t_18);
                __pyx_t_3 = 0;
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_18, __pyx_mstate_global->__pyx_n_u_timezone_error, __pyx_cur_scope->__pyx_v_error_data};
                  __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_send_to_electron_if_connected, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                  if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3162, __pyx_L52_error)
                  __Pyx_GOTREF(__pyx_t_1);
                }
                __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 3162, __pyx_L52_error)
                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                if (__pyx_t_5) {

                  /* "ws_package/controllers/activity_controller.py":3163
 *                             }
 *                             if self._send_to_electron_if_connected('timezone_error', error_data):
 *                                 logger.info("Sent timezone mismatch error to Electron: %s", error_data)             # <<<<<<<<<<<<<<
 *                                 await precise_sleep(5, stop_event)
 *                                 # CRITICAL: Don't call os._exit(1) - keep Python process alive for error recovery
*/
                  __pyx_t_18 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3163, __pyx_L52_error)
                  __Pyx_GOTREF(__pyx_t_13);
                  __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3163, __pyx_L52_error)
                  __Pyx_GOTREF(__pyx_t_14);
                  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                  __pyx_t_3 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_14))) {
                    __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_14);
                    assert(__pyx_t_18);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
                    __Pyx_INCREF(__pyx_t_18);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
                    __pyx_t_3 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[3] = {__pyx_t_18, __pyx_mstate_global->__pyx_kp_u_Sent_timezone_mismatch_error_to_2, __pyx_cur_scope->__pyx_v_error_data};
                    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3163, __pyx_L52_error)
                    __Pyx_GOTREF(__pyx_t_1);
                  }
                  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

                  /* "ws_package/controllers/activity_controller.py":3164
 *                             if self._send_to_electron_if_connected('timezone_error', error_data):
 *                                 logger.info("Sent timezone mismatch error to Electron: %s", error_data)
 *                                 await precise_sleep(5, stop_event)             # <<<<<<<<<<<<<<
 *                                 # CRITICAL: Don't call os._exit(1) - keep Python process alive for error recovery
 *                                 # Electron will handle stopping the timer, but Python should remain running
*/
                  __pyx_t_14 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_precise_sleep); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3164, __pyx_L52_error)
                  __Pyx_GOTREF(__pyx_t_18);
                  __pyx_t_3 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_18))) {
                    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_18);
                    assert(__pyx_t_14);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_18);
                    __Pyx_INCREF(__pyx_t_14);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_18, __pyx__function);
                    __pyx_t_3 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[3] = {__pyx_t_14, __pyx_mstate_global->__pyx_int_5, __pyx_cur_scope->__pyx_v_stop_event};
                    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_18, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3164, __pyx_L52_error)
                    __Pyx_GOTREF(__pyx_t_1);
                  }
                  __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
                  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                  if (likely(__pyx_t_15 == PYGEN_NEXT)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_XGIVEREF(__pyx_t_6);
                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
                    __Pyx_XGIVEREF(__pyx_t_7);
                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
                    __Pyx_XGIVEREF(__pyx_t_8);
                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
                    __Pyx_XGIVEREF(__pyx_t_9);
                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
                    __Pyx_XGIVEREF(__pyx_t_10);
                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                    __Pyx_XGIVEREF(__pyx_t_11);
                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
                    __Pyx_XGIVEREF(__pyx_r);
                    __Pyx_RefNannyFinishContext();
                    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                    /* return from generator, awaiting value */
                    __pyx_generator->resume_label = 3;
                    return __pyx_r;
                    __pyx_L62_resume_from_await:;
                    __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
                    __pyx_cur_scope->__pyx_t_0 = 0;
                    __Pyx_XGOTREF(__pyx_t_6);
                    __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
                    __pyx_cur_scope->__pyx_t_1 = 0;
                    __Pyx_XGOTREF(__pyx_t_7);
                    __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
                    __pyx_cur_scope->__pyx_t_2 = 0;
                    __Pyx_XGOTREF(__pyx_t_8);
                    __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
                    __pyx_cur_scope->__pyx_t_3 = 0;
                    __Pyx_XGOTREF(__pyx_t_9);
                    __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                    __pyx_cur_scope->__pyx_t_4 = 0;
                    __Pyx_XGOTREF(__pyx_t_10);
                    __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
                    __pyx_cur_scope->__pyx_t_5 = 0;
                    __Pyx_XGOTREF(__pyx_t_11);
                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3164, __pyx_L52_error)
                  } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                  } else {
                    __Pyx_XGOTREF(__pyx_r);
                    __PYX_ERR(0, 3164, __pyx_L52_error)
                  }

                  /* "ws_package/controllers/activity_controller.py":3167
 *                                 # CRITICAL: Don't call os._exit(1) - keep Python process alive for error recovery
 *                                 # Electron will handle stopping the timer, but Python should remain running
 *                                 logger.info("Timezone error sent to Electron - Python process will remain alive (not exiting)")             # <<<<<<<<<<<<<<
 *                     except Exception as e:
 *                         logger.error("Failed to send time integrity error to Electron: %s", e)
*/
                  __pyx_t_18 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3167, __pyx_L52_error)
                  __Pyx_GOTREF(__pyx_t_14);
                  __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3167, __pyx_L52_error)
                  __Pyx_GOTREF(__pyx_t_13);
                  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                  __pyx_t_3 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_13))) {
                    __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_13);
                    assert(__pyx_t_18);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
                    __Pyx_INCREF(__pyx_t_18);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
                    __pyx_t_3 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_18, __pyx_mstate_global->__pyx_kp_u_Timezone_error_sent_to_Electron};
                    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3167, __pyx_L52_error)
                    __Pyx_GOTREF(__pyx_t_1);
                  }
                  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

                  /* "ws_package/controllers/activity_controller.py":3162
 *                                 'timestamp': datetime.datetime.now().isoformat()
 *                             }
 *                             if self._send_to_electron_if_connected('timezone_error', error_data):             # <<<<<<<<<<<<<<
 *                                 logger.info("Sent timezone mismatch error to Electron: %s", error_data)
 *                                 await precise_sleep(5, stop_event)
*/
                }

                /* "ws_package/controllers/activity_controller.py":3156
 *                     # Send timezone popup only for true timezone mismatch. datetime_error is emitted by time monitor.
 *                     try:
 *                         if self._timezone_mismatch:             # <<<<<<<<<<<<<<
 *                             error_data = {
 *                                 'title': 'Timezone Error',
*/
              }

              /* "ws_package/controllers/activity_controller.py":3155
 * 
 *                     # Send timezone popup only for true timezone mismatch. datetime_error is emitted by time monitor.
 *                     try:             # <<<<<<<<<<<<<<
 *                         if self._timezone_mismatch:
 *                             error_data = {
*/
            }
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            goto __pyx_L59_try_end;
            __pyx_L52_error:;
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
            __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;

            /* "ws_package/controllers/activity_controller.py":3168
 *                                 # Electron will handle stopping the timer, but Python should remain running
 *                                 logger.info("Timezone error sent to Electron - Python process will remain alive (not exiting)")
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Failed to send time integrity error to Electron: %s", e)
 * 
*/
            __pyx_t_22 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
            if (__pyx_t_22) {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._push_activity_log", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_13, &__pyx_t_18) < 0) __PYX_ERR(0, 3168, __pyx_L54_except_error)
              __Pyx_XGOTREF(__pyx_t_1);
              __Pyx_XGOTREF(__pyx_t_13);
              __Pyx_XGOTREF(__pyx_t_18);
              __Pyx_INCREF(__pyx_t_13);
              __Pyx_GIVEREF(__pyx_t_13);
              __pyx_cur_scope->__pyx_v_e = __pyx_t_13;
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":3169
 *                                 logger.info("Timezone error sent to Electron - Python process will remain alive (not exiting)")
 *                     except Exception as e:
 *                         logger.error("Failed to send time integrity error to Electron: %s", e)             # <<<<<<<<<<<<<<
 * 
 *                     logger.error(
*/
                __pyx_t_12 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3169, __pyx_L68_error)
                __Pyx_GOTREF(__pyx_t_2);
                __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3169, __pyx_L68_error)
                __Pyx_GOTREF(__pyx_t_17);
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                __pyx_t_3 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_17))) {
                  __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_17);
                  assert(__pyx_t_12);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
                  __Pyx_INCREF(__pyx_t_12);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
                  __pyx_t_3 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_12, __pyx_mstate_global->__pyx_kp_u_Failed_to_send_time_integrity_er, __pyx_cur_scope->__pyx_v_e};
                  __pyx_t_14 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                  if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3169, __pyx_L68_error)
                  __Pyx_GOTREF(__pyx_t_14);
                }
                __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              }

              /* "ws_package/controllers/activity_controller.py":3168
 *                                 # Electron will handle stopping the timer, but Python should remain running
 *                                 logger.info("Timezone error sent to Electron - Python process will remain alive (not exiting)")
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Failed to send time integrity error to Electron: %s", e)
 * 
*/
              /*finally:*/ {
                /*normal exit:*/{
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  goto __pyx_L69;
                }
                __pyx_L68_error:;
                /*exception exit:*/{
                  __Pyx_PyThreadState_assign
                  __pyx_t_29 = 0; __pyx_t_28 = 0; __pyx_t_27 = 0; __pyx_t_26 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0;
                  __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                  __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                  __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                  __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                   __Pyx_ExceptionSwap(&__pyx_t_26, &__pyx_t_25, &__pyx_t_24);
                  if ( unlikely(__Pyx_GetException(&__pyx_t_29, &__pyx_t_28, &__pyx_t_27) < 0)) __Pyx_ErrFetch(&__pyx_t_29, &__pyx_t_28, &__pyx_t_27);
                  __Pyx_XGOTREF(__pyx_t_29);
                  __Pyx_XGOTREF(__pyx_t_28);
                  __Pyx_XGOTREF(__pyx_t_27);
                  __Pyx_XGOTREF(__pyx_t_26);
                  __Pyx_XGOTREF(__pyx_t_25);
                  __Pyx_XGOTREF(__pyx_t_24);
                  __pyx_t_22 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_30 = __pyx_filename;
                  {
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  }
                  __Pyx_XGIVEREF(__pyx_t_26);
                  __Pyx_XGIVEREF(__pyx_t_25);
                  __Pyx_XGIVEREF(__pyx_t_24);
                  __Pyx_ExceptionReset(__pyx_t_26, __pyx_t_25, __pyx_t_24);
                  __Pyx_XGIVEREF(__pyx_t_29);
                  __Pyx_XGIVEREF(__pyx_t_28);
                  __Pyx_XGIVEREF(__pyx_t_27);
                  __Pyx_ErrRestore(__pyx_t_29, __pyx_t_28, __pyx_t_27);
                  __pyx_t_29 = 0; __pyx_t_28 = 0; __pyx_t_27 = 0; __pyx_t_26 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0;
                  __pyx_lineno = __pyx_t_22; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_30;
                  goto __pyx_L54_except_error;
                }
                __pyx_L69:;
              }
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
              goto __pyx_L53_exception_handled;
            }
            goto __pyx_L54_except_error;

            /* "ws_package/controllers/activity_controller.py":3155
 * 
 *                     # Send timezone popup only for true timezone mismatch. datetime_error is emitted by time monitor.
 *                     try:             # <<<<<<<<<<<<<<
 *                         if self._timezone_mismatch:
 *                             error_data = {
*/
            __pyx_L54_except_error:;
            __Pyx_XGIVEREF(__pyx_t_9);
            __Pyx_XGIVEREF(__pyx_t_10);
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
            goto __pyx_L6_error;
            __pyx_L53_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_9);
            __Pyx_XGIVEREF(__pyx_t_10);
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
            __pyx_L59_try_end:;
          }

          /* "ws_package/controllers/activity_controller.py":3171
 *                         logger.error("Failed to send time integrity error to Electron: %s", e)
 * 
 *                     logger.error(             # <<<<<<<<<<<<<<
 *                         "Time integrity error detected (%s) - stopping tracker IMMEDIATELY - NO DATA SYNC",
 *                         self._time_error_type,
*/
          __pyx_t_13 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3171, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3171, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":3173
 *                     logger.error(
 *                         "Time integrity error detected (%s) - stopping tracker IMMEDIATELY - NO DATA SYNC",
 *                         self._time_error_type,             # <<<<<<<<<<<<<<
 *                     )
 *                     self.force_stop = True
*/
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_time_error_type); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3173, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_3 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_14))) {
            __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_14);
            assert(__pyx_t_13);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
            __pyx_t_3 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Time_integrity_error_detected_s, __pyx_t_1};
            __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3171, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_18);
          }
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

          /* "ws_package/controllers/activity_controller.py":3175
 *                         self._time_error_type,
 *                     )
 *                     self.force_stop = True             # <<<<<<<<<<<<<<
 *                     # CRITICAL: Skip all data sync operations when timezone error is detected
 *                     # Don't sync intervals, don't sync unsent data, just stop
*/
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_force_stop, Py_True) < (0)) __PYX_ERR(0, 3175, __pyx_L6_error)

          /* "ws_package/controllers/activity_controller.py":3178
 *                     # CRITICAL: Skip all data sync operations when timezone error is detected
 *                     # Don't sync intervals, don't sync unsent data, just stop
 *                     logger.error("Skipping all data sync operations (empty_interval, unsent intervals, current intervals)")             # <<<<<<<<<<<<<<
 *                     # CRITICAL: Don't call os._exit(1) - keep Python process alive for error recovery
 *                     # The monitoring loop will stop gracefully due to force_stop=True, but process remains alive
*/
          __pyx_t_14 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3178, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3178, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_3 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_13))) {
            __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
            assert(__pyx_t_14);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
            __Pyx_INCREF(__pyx_t_14);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
            __pyx_t_3 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_14, __pyx_mstate_global->__pyx_kp_u_Skipping_all_data_sync_operation};
            __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3178, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_18);
          }
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

          /* "ws_package/controllers/activity_controller.py":3181
 *                     # CRITICAL: Don't call os._exit(1) - keep Python process alive for error recovery
 *                     # The monitoring loop will stop gracefully due to force_stop=True, but process remains alive
 *                     logger.info("Python process will remain alive - monitoring stopped but process continues running")             # <<<<<<<<<<<<<<
 *                     # Wait a bit to allow error message to be sent; skip empty_interval and interval send (no last 10-15 sec to DB/API)
 *                     await precise_sleep(5, stop_event)
*/
          __pyx_t_13 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3181, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_14);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3181, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __pyx_t_3 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_1))) {
            __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_1);
            assert(__pyx_t_13);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
            __pyx_t_3 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Python_process_will_remain_alive};
            __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3181, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_18);
          }
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

          /* "ws_package/controllers/activity_controller.py":3183
 *                     logger.info("Python process will remain alive - monitoring stopped but process continues running")
 *                     # Wait a bit to allow error message to be sent; skip empty_interval and interval send (no last 10-15 sec to DB/API)
 *                     await precise_sleep(5, stop_event)             # <<<<<<<<<<<<<<
 *                     continue
 *                 elif self.force_stop == True and self.status == False:
*/
          __pyx_t_1 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_precise_sleep); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3183, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_3 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_13))) {
            __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_13);
            assert(__pyx_t_1);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
            __pyx_t_3 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_mstate_global->__pyx_int_5, __pyx_cur_scope->__pyx_v_stop_event};
            __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3183, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_18);
          }
          __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_18, &__pyx_r);
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
          if (likely(__pyx_t_15 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_6);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
            __Pyx_XGIVEREF(__pyx_t_7);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
            __Pyx_XGIVEREF(__pyx_t_8);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 4;
            return __pyx_r;
            __pyx_L74_resume_from_await:;
            __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_6);
            __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_7);
            __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_8);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3183, __pyx_L6_error)
          } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_DECREF(__pyx_r); __pyx_r = 0;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 3183, __pyx_L6_error)
          }

          /* "ws_package/controllers/activity_controller.py":3184
 *                     # Wait a bit to allow error message to be sent; skip empty_interval and interval send (no last 10-15 sec to DB/API)
 *                     await precise_sleep(5, stop_event)
 *                     continue             # <<<<<<<<<<<<<<
 *                 elif self.force_stop == True and self.status == False:
 *                     # This is a WebSocket stop command, not a timezone mismatch
*/
          goto __pyx_L12_try_continue;

          /* "ws_package/controllers/activity_controller.py":3107
 *                     self._time_error_type,
 *                 )
 *                 if (             # <<<<<<<<<<<<<<
 *                     self._timezone_mismatch is True
 *                     and self._timezone_checks_enabled(user_entity)
*/
        }

        /* "ws_package/controllers/activity_controller.py":3185
 *                     await precise_sleep(5, stop_event)
 *                     continue
 *                 elif self.force_stop == True and self.status == False:             # <<<<<<<<<<<<<<
 *                     # This is a WebSocket stop command, not a timezone mismatch
 *                     # Don't exit - just skip the push activity and wait
*/
        __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_force_stop); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3185, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_18);
        __pyx_t_13 = PyObject_RichCompare(__pyx_t_18, Py_True, Py_EQ); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3185, __pyx_L6_error)
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 3185, __pyx_L6_error)
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        if (__pyx_t_4) {
        } else {
          __pyx_t_5 = __pyx_t_4;
          goto __pyx_L75_bool_binop_done;
        }
        __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3185, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_18 = PyObject_RichCompare(__pyx_t_13, Py_False, Py_EQ); __Pyx_XGOTREF(__pyx_t_18); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3185, __pyx_L6_error)
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_18); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 3185, __pyx_L6_error)
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        __pyx_t_5 = __pyx_t_4;
        __pyx_L75_bool_binop_done:;
        if (__pyx_t_5) {

          /* "ws_package/controllers/activity_controller.py":3188
 *                     # This is a WebSocket stop command, not a timezone mismatch
 *                     # Don't exit - just skip the push activity and wait
 *                     logger.info("[Tracker] Tracking stopped via WebSocket - skipping push activity")             # <<<<<<<<<<<<<<
 *                     await precise_sleep(self.interval, stop_event)
 *                     continue
*/
          __pyx_t_13 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3188, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3188, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_3 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_14))) {
            __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_14);
            assert(__pyx_t_13);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
            __pyx_t_3 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Tracker_Tracking_stopped_via_We};
            __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3188, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_18);
          }
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

          /* "ws_package/controllers/activity_controller.py":3189
 *                     # Don't exit - just skip the push activity and wait
 *                     logger.info("[Tracker] Tracking stopped via WebSocket - skipping push activity")
 *                     await precise_sleep(self.interval, stop_event)             # <<<<<<<<<<<<<<
 *                     continue
 *                 else:
*/
          __pyx_t_14 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_precise_sleep); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3189, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3189, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_3 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_13))) {
            __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
            assert(__pyx_t_14);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
            __Pyx_INCREF(__pyx_t_14);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
            __pyx_t_3 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_14, __pyx_t_1, __pyx_cur_scope->__pyx_v_stop_event};
            __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3189, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_18);
          }
          __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_18, &__pyx_r);
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
          if (likely(__pyx_t_15 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_6);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
            __Pyx_XGIVEREF(__pyx_t_7);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
            __Pyx_XGIVEREF(__pyx_t_8);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 5;
            return __pyx_r;
            __pyx_L77_resume_from_await:;
            __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_6);
            __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_7);
            __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_8);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3189, __pyx_L6_error)
          } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_DECREF(__pyx_r); __pyx_r = 0;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 3189, __pyx_L6_error)
          }

          /* "ws_package/controllers/activity_controller.py":3190
 *                     logger.info("[Tracker] Tracking stopped via WebSocket - skipping push activity")
 *                     await precise_sleep(self.interval, stop_event)
 *                     continue             # <<<<<<<<<<<<<<
 *                 else:
 *                     logger.info("Force Stop Status False under Push")
*/
          goto __pyx_L12_try_continue;

          /* "ws_package/controllers/activity_controller.py":3185
 *                     await precise_sleep(5, stop_event)
 *                     continue
 *                 elif self.force_stop == True and self.status == False:             # <<<<<<<<<<<<<<
 *                     # This is a WebSocket stop command, not a timezone mismatch
 *                     # Don't exit - just skip the push activity and wait
*/
        }

        /* "ws_package/controllers/activity_controller.py":3192
 *                     continue
 *                 else:
 *                     logger.info("Force Stop Status False under Push")             # <<<<<<<<<<<<<<
 * 
 * 
*/
        /*else*/ {
          __pyx_t_13 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3192, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3192, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_3 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_14))) {
            __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_14);
            assert(__pyx_t_13);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
            __pyx_t_3 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Force_Stop_Status_False_under_Pu};
            __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3192, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_18);
          }
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        }

        /* "ws_package/controllers/activity_controller.py":3195
 * 
 * 
 *                 await self.empty_interval(user_entity)             # <<<<<<<<<<<<<<
 * 
 *                 logger.info("Today is %s and tracking days are %s", self.get_today_weekday(), self.no_of_days)
*/
        __pyx_t_14 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_14);
        __pyx_t_3 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_14, __pyx_cur_scope->__pyx_v_user_entity};
          __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_empty_interval, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3195, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_18);
        }
        __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_18, &__pyx_r);
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        if (likely(__pyx_t_15 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_6);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
          __Pyx_XGIVEREF(__pyx_t_7);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
          __Pyx_XGIVEREF(__pyx_t_8);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 6;
          return __pyx_r;
          __pyx_L78_resume_from_await:;
          __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_6);
          __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_7);
          __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_8);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3195, __pyx_L6_error)
        } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_DECREF(__pyx_r); __pyx_r = 0;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 3195, __pyx_L6_error)
        }

        /* "ws_package/controllers/activity_controller.py":3197
 *                 await self.empty_interval(user_entity)
 * 
 *                 logger.info("Today is %s and tracking days are %s", self.get_today_weekday(), self.no_of_days)             # <<<<<<<<<<<<<<
 *                 if self.no_of_days is not None and self.get_today_weekday() in self.no_of_days:
 * 
*/
        __pyx_t_14 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3197, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3197, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_17 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_17);
        __pyx_t_3 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_17, NULL};
          __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_today_weekday, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3197, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_13);
        }
        __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_no_of_days); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3197, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_3 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_1);
          assert(__pyx_t_14);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_14);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
          __pyx_t_3 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[4] = {__pyx_t_14, __pyx_mstate_global->__pyx_kp_u_Today_is_s_and_tracking_days_are, __pyx_t_13, __pyx_t_17};
          __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_3, (4-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3197, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_18);
        }
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

        /* "ws_package/controllers/activity_controller.py":3198
 * 
 *                 logger.info("Today is %s and tracking days are %s", self.get_today_weekday(), self.no_of_days)
 *                 if self.no_of_days is not None and self.get_today_weekday() in self.no_of_days:             # <<<<<<<<<<<<<<
 * 
 *                     self.activity_service.application_activity_log_url = config('application_activity_log_url', 'Application')
*/
        __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_no_of_days); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3198, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_18);
        __pyx_t_4 = (__pyx_t_18 != Py_None);
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        if (__pyx_t_4) {
        } else {
          __pyx_t_5 = __pyx_t_4;
          goto __pyx_L80_bool_binop_done;
        }
        __pyx_t_1 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_3 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
          __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_today_weekday, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3198, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_18);
        }
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_no_of_days); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3198, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_4 = (__Pyx_PySequence_ContainsTF(__pyx_t_18, __pyx_t_1, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 3198, __pyx_L6_error)
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_5 = __pyx_t_4;
        __pyx_L80_bool_binop_done:;
        if (__pyx_t_5) {

          /* "ws_package/controllers/activity_controller.py":3200
 *                 if self.no_of_days is not None and self.get_today_weekday() in self.no_of_days:
 * 
 *                     self.activity_service.application_activity_log_url = config('application_activity_log_url', 'Application')             # <<<<<<<<<<<<<<
 *                     prev_day_unsent = await self.getting_unsent_interval(user_entity)
 *                     logger.info("Previous day unsent intervals %s", prev_day_unsent)
*/
          __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_config); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3200, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_mstate_global->__pyx_tuple[27], NULL); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3200, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_18);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3200, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
          if (__Pyx_PyObject_SetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_application_activity_log_url, __pyx_t_18) < (0)) __PYX_ERR(0, 3200, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":3201
 * 
 *                     self.activity_service.application_activity_log_url = config('application_activity_log_url', 'Application')
 *                     prev_day_unsent = await self.getting_unsent_interval(user_entity)             # <<<<<<<<<<<<<<
 *                     logger.info("Previous day unsent intervals %s", prev_day_unsent)
 *                     if prev_day_unsent:
*/
          __pyx_t_18 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_18);
          __pyx_t_3 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_18, __pyx_cur_scope->__pyx_v_user_entity};
            __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_getting_unsent_interval, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3201, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_1);
          }
          __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (likely(__pyx_t_15 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_6);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
            __Pyx_XGIVEREF(__pyx_t_7);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
            __Pyx_XGIVEREF(__pyx_t_8);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 7;
            return __pyx_r;
            __pyx_L82_resume_from_await:;
            __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_6);
            __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_7);
            __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_8);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3201, __pyx_L6_error)
            __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
          } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __pyx_t_1 = __pyx_r; __pyx_r = NULL;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 3201, __pyx_L6_error)
          }
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_prev_day_unsent);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_prev_day_unsent, __pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_1);
          __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":3202
 *                     self.activity_service.application_activity_log_url = config('application_activity_log_url', 'Application')
 *                     prev_day_unsent = await self.getting_unsent_interval(user_entity)
 *                     logger.info("Previous day unsent intervals %s", prev_day_unsent)             # <<<<<<<<<<<<<<
 *                     if prev_day_unsent:
 *                         start = prev_day_unsent[0].start_time
*/
          __pyx_t_18 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3202, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3202, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __pyx_t_3 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_13))) {
            __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_13);
            assert(__pyx_t_18);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
            __Pyx_INCREF(__pyx_t_18);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
            __pyx_t_3 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_18, __pyx_mstate_global->__pyx_kp_u_Previous_day_unsent_intervals_s, __pyx_cur_scope->__pyx_v_prev_day_unsent};
            __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3202, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_1);
          }
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":3203
 *                     prev_day_unsent = await self.getting_unsent_interval(user_entity)
 *                     logger.info("Previous day unsent intervals %s", prev_day_unsent)
 *                     if prev_day_unsent:             # <<<<<<<<<<<<<<
 *                         start = prev_day_unsent[0].start_time
 *                         await self.sending_unsent_intervals(start, prev_day_unsent, user_entity)
*/
          __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_prev_day_unsent); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 3203, __pyx_L6_error)
          if (__pyx_t_5) {

            /* "ws_package/controllers/activity_controller.py":3204
 *                     logger.info("Previous day unsent intervals %s", prev_day_unsent)
 *                     if prev_day_unsent:
 *                         start = prev_day_unsent[0].start_time             # <<<<<<<<<<<<<<
 *                         await self.sending_unsent_intervals(start, prev_day_unsent, user_entity)
 * 
*/
            __pyx_t_1 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_prev_day_unsent, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_SharedReference); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3204, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3204, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_start);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_start, __pyx_t_13);
            __Pyx_GIVEREF(__pyx_t_13);
            __pyx_t_13 = 0;

            /* "ws_package/controllers/activity_controller.py":3205
 *                     if prev_day_unsent:
 *                         start = prev_day_unsent[0].start_time
 *                         await self.sending_unsent_intervals(start, prev_day_unsent, user_entity)             # <<<<<<<<<<<<<<
 * 
 *                     # Headers for the activity log api
*/
            __pyx_t_1 = __pyx_cur_scope->__pyx_v_self;
            __Pyx_INCREF(__pyx_t_1);
            __pyx_t_3 = 0;
            {
              PyObject *__pyx_callargs[4] = {__pyx_t_1, __pyx_cur_scope->__pyx_v_start, __pyx_cur_scope->__pyx_v_prev_day_unsent, __pyx_cur_scope->__pyx_v_user_entity};
              __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_sending_unsent_intervals, __pyx_callargs+__pyx_t_3, (4-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3205, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_13);
            }
            __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_13, &__pyx_r);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            if (likely(__pyx_t_15 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_6);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
              __Pyx_XGIVEREF(__pyx_t_7);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
              __Pyx_XGIVEREF(__pyx_t_8);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 8;
              return __pyx_r;
              __pyx_L84_resume_from_await:;
              __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_6);
              __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_7);
              __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_8);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3205, __pyx_L6_error)
            } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_DECREF(__pyx_r); __pyx_r = 0;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 3205, __pyx_L6_error)
            }

            /* "ws_package/controllers/activity_controller.py":3203
 *                     prev_day_unsent = await self.getting_unsent_interval(user_entity)
 *                     logger.info("Previous day unsent intervals %s", prev_day_unsent)
 *                     if prev_day_unsent:             # <<<<<<<<<<<<<<
 *                         start = prev_day_unsent[0].start_time
 *                         await self.sending_unsent_intervals(start, prev_day_unsent, user_entity)
*/
          }

          /* "ws_package/controllers/activity_controller.py":3208
 * 
 *                     # Headers for the activity log api
 *                     sd_token = user_entity.sd_token             # <<<<<<<<<<<<<<
 *                     org_id = user_entity.org_id
 *                     user_id = user_entity.user_id
*/
          __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_sd_token); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3208, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_sd_token);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_sd_token, __pyx_t_13);
          __Pyx_GIVEREF(__pyx_t_13);
          __pyx_t_13 = 0;

          /* "ws_package/controllers/activity_controller.py":3209
 *                     # Headers for the activity log api
 *                     sd_token = user_entity.sd_token
 *                     org_id = user_entity.org_id             # <<<<<<<<<<<<<<
 *                     user_id = user_entity.user_id
 *                     appVersion =  self.appVersion
*/
          __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_org_id); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3209, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_org_id);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_org_id, __pyx_t_13);
          __Pyx_GIVEREF(__pyx_t_13);
          __pyx_t_13 = 0;

          /* "ws_package/controllers/activity_controller.py":3210
 *                     sd_token = user_entity.sd_token
 *                     org_id = user_entity.org_id
 *                     user_id = user_entity.user_id             # <<<<<<<<<<<<<<
 *                     appVersion =  self.appVersion
 * 
*/
          __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_user_id); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3210, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_user_id);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_user_id, __pyx_t_13);
          __Pyx_GIVEREF(__pyx_t_13);
          __pyx_t_13 = 0;

          /* "ws_package/controllers/activity_controller.py":3211
 *                     org_id = user_entity.org_id
 *                     user_id = user_entity.user_id
 *                     appVersion =  self.appVersion             # <<<<<<<<<<<<<<
 * 
 *                     # CRITICAL: Filter by current session counter to prevent picking intervals from previous sessions
*/
          __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appVersion); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3211, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_appVersion);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_appVersion, __pyx_t_13);
          __Pyx_GIVEREF(__pyx_t_13);
          __pyx_t_13 = 0;

          /* "ws_package/controllers/activity_controller.py":3214
 * 
 *                     # CRITICAL: Filter by current session counter to prevent picking intervals from previous sessions
 *                     current_session_counter = self.last_count + 1             # <<<<<<<<<<<<<<
 *                     intervals = await self.activity_service.get_activity_intervals(self.main_start_date, self.main_end_date, counter=current_session_counter)
 * 
*/
          __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3214, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_1 = __Pyx_PyLong_AddObjC(__pyx_t_13, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3214, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_current_session_counter);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_current_session_counter, __pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_1);
          __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":3215
 *                     # CRITICAL: Filter by current session counter to prevent picking intervals from previous sessions
 *                     current_session_counter = self.last_count + 1
 *                     intervals = await self.activity_service.get_activity_intervals(self.main_start_date, self.main_end_date, counter=current_session_counter)             # <<<<<<<<<<<<<<
 * 
 *                     # Safety valve: auto-reset stale break if Electron crashed mid-break
*/
          __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3215, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_18);
          __pyx_t_13 = __pyx_t_18;
          __Pyx_INCREF(__pyx_t_13);
          __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_main_start_date); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3215, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_main_end_date); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3215, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_14);
          __pyx_t_3 = 0;
          {
            PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_13, __pyx_t_17, __pyx_t_14};
            __pyx_t_12 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3215, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_12);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_counter, __pyx_cur_scope->__pyx_v_current_session_counter, __pyx_t_12, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 3215, __pyx_L6_error)
            __pyx_t_1 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_get_activity_intervals, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_12);
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3215, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_1);
          }
          __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (likely(__pyx_t_15 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_6);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
            __Pyx_XGIVEREF(__pyx_t_7);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
            __Pyx_XGIVEREF(__pyx_t_8);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 9;
            return __pyx_r;
            __pyx_L85_resume_from_await:;
            __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_6);
            __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_7);
            __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_8);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3215, __pyx_L6_error)
            __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
          } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __pyx_t_1 = __pyx_r; __pyx_r = NULL;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 3215, __pyx_L6_error)
          }
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_intervals);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_intervals, __pyx_t_1);
          __Pyx_GIVEREF(__pyx_t_1);
          __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":3218
 * 
 *                     # Safety valve: auto-reset stale break if Electron crashed mid-break
 *                     await self.check_stale_break()             # <<<<<<<<<<<<<<
 * 
 *                     if not is_silent_build():
*/
          __pyx_t_18 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_18);
          __pyx_t_3 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_18, NULL};
            __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_check_stale_break, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3218, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_1);
          }
          __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (likely(__pyx_t_15 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_6);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
            __Pyx_XGIVEREF(__pyx_t_7);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
            __Pyx_XGIVEREF(__pyx_t_8);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 10;
            return __pyx_r;
            __pyx_L86_resume_from_await:;
            __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_6);
            __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_7);
            __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_8);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3218, __pyx_L6_error)
          } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_DECREF(__pyx_r); __pyx_r = 0;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 3218, __pyx_L6_error)
          }

          /* "ws_package/controllers/activity_controller.py":3220
 *                     await self.check_stale_break()
 * 
 *                     if not is_silent_build():             # <<<<<<<<<<<<<<
 *                         # NEW REQUIREMENT: Check 60-minute timeout before checking API pause
 *                         timeout_reached = await self.check_idle_popup_timeout()
*/
          __pyx_t_18 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_is_silent_build); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3220, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_3 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_12))) {
            __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_12);
            assert(__pyx_t_18);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
            __Pyx_INCREF(__pyx_t_18);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
            __pyx_t_3 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_18, NULL};
            __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3220, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_1);
          }
          __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 3220, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_4 = (!__pyx_t_5);
          if (__pyx_t_4) {

            /* "ws_package/controllers/activity_controller.py":3222
 *                     if not is_silent_build():
 *                         # NEW REQUIREMENT: Check 60-minute timeout before checking API pause
 *                         timeout_reached = await self.check_idle_popup_timeout()             # <<<<<<<<<<<<<<
 *                         if timeout_reached:
 *                             logger.warning(
*/
            __pyx_t_12 = __pyx_cur_scope->__pyx_v_self;
            __Pyx_INCREF(__pyx_t_12);
            __pyx_t_3 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_12, NULL};
              __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_check_idle_popup_timeout, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3222, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_1);
            }
            __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (likely(__pyx_t_15 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_6);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
              __Pyx_XGIVEREF(__pyx_t_7);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
              __Pyx_XGIVEREF(__pyx_t_8);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 11;
              return __pyx_r;
              __pyx_L88_resume_from_await:;
              __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_6);
              __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_7);
              __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_8);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3222, __pyx_L6_error)
              __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
            } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __pyx_t_1 = __pyx_r; __pyx_r = NULL;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 3222, __pyx_L6_error)
            }
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_timeout_reached);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_timeout_reached, __pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_1);
            __pyx_t_1 = 0;

            /* "ws_package/controllers/activity_controller.py":3223
 *                         # NEW REQUIREMENT: Check 60-minute timeout before checking API pause
 *                         timeout_reached = await self.check_idle_popup_timeout()
 *                         if timeout_reached:             # <<<<<<<<<<<<<<
 *                             logger.warning(
 *                                 "[IdleTimeout] Auto-stop triggered  waiting for Electron stop "
*/
            __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_timeout_reached); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 3223, __pyx_L6_error)
            if (__pyx_t_4) {

              /* "ws_package/controllers/activity_controller.py":3224
 *                         timeout_reached = await self.check_idle_popup_timeout()
 *                         if timeout_reached:
 *                             logger.warning(             # <<<<<<<<<<<<<<
 *                                 "[IdleTimeout] Auto-stop triggered  waiting for Electron stop "
 *                                 "(do not exit push alone; MonitorThread would restart it)"
*/
              __pyx_t_12 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3224, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_18);
              __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3224, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_14);
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
              __pyx_t_3 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_14))) {
                __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_14);
                assert(__pyx_t_12);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
                __Pyx_INCREF(__pyx_t_12);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
                __pyx_t_3 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_12, __pyx_mstate_global->__pyx_kp_u_IdleTimeout_Auto_stop_triggered};
                __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3224, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_1);
              }
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

              /* "ws_package/controllers/activity_controller.py":3228
 *                                 "(do not exit push alone; MonitorThread would restart it)"
 *                             )
 *                             self.status = False             # <<<<<<<<<<<<<<
 *                             # Wait for stop_event from Electron-driven stop path
 *                             await precise_sleep(self.interval, stop_event)
*/
              if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status, Py_False) < (0)) __PYX_ERR(0, 3228, __pyx_L6_error)

              /* "ws_package/controllers/activity_controller.py":3230
 *                             self.status = False
 *                             # Wait for stop_event from Electron-driven stop path
 *                             await precise_sleep(self.interval, stop_event)             # <<<<<<<<<<<<<<
 *                             if stop_event.is_set():
 *                                 break
*/
              __pyx_t_14 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_precise_sleep); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3230, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_12);
              __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3230, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_18);
              __pyx_t_3 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_12))) {
                __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_12);
                assert(__pyx_t_14);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
                __Pyx_INCREF(__pyx_t_14);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
                __pyx_t_3 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_14, __pyx_t_18, __pyx_cur_scope->__pyx_v_stop_event};
                __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3230, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_1);
              }
              __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (likely(__pyx_t_15 == PYGEN_NEXT)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_XGIVEREF(__pyx_t_6);
                __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
                __Pyx_XGIVEREF(__pyx_t_7);
                __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
                __Pyx_XGIVEREF(__pyx_t_8);
                __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
                __Pyx_XGIVEREF(__pyx_r);
                __Pyx_RefNannyFinishContext();
                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                /* return from generator, awaiting value */
                __pyx_generator->resume_label = 12;
                return __pyx_r;
                __pyx_L90_resume_from_await:;
                __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
                __pyx_cur_scope->__pyx_t_0 = 0;
                __Pyx_XGOTREF(__pyx_t_6);
                __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
                __pyx_cur_scope->__pyx_t_1 = 0;
                __Pyx_XGOTREF(__pyx_t_7);
                __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
                __pyx_cur_scope->__pyx_t_2 = 0;
                __Pyx_XGOTREF(__pyx_t_8);
                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3230, __pyx_L6_error)
              } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_DECREF(__pyx_r); __pyx_r = 0;
              } else {
                __Pyx_XGOTREF(__pyx_r);
                __PYX_ERR(0, 3230, __pyx_L6_error)
              }

              /* "ws_package/controllers/activity_controller.py":3231
 *                             # Wait for stop_event from Electron-driven stop path
 *                             await precise_sleep(self.interval, stop_event)
 *                             if stop_event.is_set():             # <<<<<<<<<<<<<<
 *                                 break
 *                             continue
*/
              __pyx_t_12 = __pyx_cur_scope->__pyx_v_stop_event;
              __Pyx_INCREF(__pyx_t_12);
              __pyx_t_3 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_12, NULL};
                __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_set, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3231, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_1);
              }
              __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 3231, __pyx_L6_error)
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (__pyx_t_4) {

                /* "ws_package/controllers/activity_controller.py":3232
 *                             await precise_sleep(self.interval, stop_event)
 *                             if stop_event.is_set():
 *                                 break             # <<<<<<<<<<<<<<
 *                             continue
 * 
*/
                goto __pyx_L11_try_break;

                /* "ws_package/controllers/activity_controller.py":3231
 *                             # Wait for stop_event from Electron-driven stop path
 *                             await precise_sleep(self.interval, stop_event)
 *                             if stop_event.is_set():             # <<<<<<<<<<<<<<
 *                                 break
 *                             continue
*/
              }

              /* "ws_package/controllers/activity_controller.py":3233
 *                             if stop_event.is_set():
 *                                 break
 *                             continue             # <<<<<<<<<<<<<<
 * 
 *                         # Check if API calls should be paused (idle popup active or all-zero activity).
*/
              goto __pyx_L12_try_continue;

              /* "ws_package/controllers/activity_controller.py":3223
 *                         # NEW REQUIREMENT: Check 60-minute timeout before checking API pause
 *                         timeout_reached = await self.check_idle_popup_timeout()
 *                         if timeout_reached:             # <<<<<<<<<<<<<<
 *                             logger.warning(
 *                                 "[IdleTimeout] Auto-stop triggered  waiting for Electron stop "
*/
            }

            /* "ws_package/controllers/activity_controller.py":3240
 *                         # preventing indefinite stall  EXCEPT while the idle popup is active (60+ min idle
 *                         # must never sync until the user responds or auto-stop marks intervals uploaded).
 *                         should_pause_api = await self._should_pause_api_calls(intervals)             # <<<<<<<<<<<<<<
 *                         idle_popup_blocking = (
 *                             self._idle_popup_active and self._idle_popup_triggered_at is not None
*/
            __pyx_t_12 = __pyx_cur_scope->__pyx_v_self;
            __Pyx_INCREF(__pyx_t_12);
            __pyx_t_3 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_12, __pyx_cur_scope->__pyx_v_intervals};
              __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_should_pause_api_calls, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3240, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_1);
            }
            __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (likely(__pyx_t_15 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_6);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
              __Pyx_XGIVEREF(__pyx_t_7);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
              __Pyx_XGIVEREF(__pyx_t_8);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 13;
              return __pyx_r;
              __pyx_L92_resume_from_await:;
              __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_6);
              __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_7);
              __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_8);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3240, __pyx_L6_error)
              __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
            } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __pyx_t_1 = __pyx_r; __pyx_r = NULL;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 3240, __pyx_L6_error)
            }
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_should_pause_api);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_should_pause_api, __pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_1);
            __pyx_t_1 = 0;

            /* "ws_package/controllers/activity_controller.py":3242
 *                         should_pause_api = await self._should_pause_api_calls(intervals)
 *                         idle_popup_blocking = (
 *                             self._idle_popup_active and self._idle_popup_triggered_at is not None             # <<<<<<<<<<<<<<
 *                         )
 *                         force_upload_after_pause_cap = (
*/
            __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_active); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3242, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_12);
            __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 3242, __pyx_L6_error)
            if (__pyx_t_4) {
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            } else {
              __Pyx_INCREF(__pyx_t_12);
              __pyx_t_1 = __pyx_t_12;
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
              goto __pyx_L93_bool_binop_done;
            }
            __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_triggered_at); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3242, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_12);
            __pyx_t_4 = (__pyx_t_12 != Py_None);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            __pyx_t_12 = __Pyx_PyBool_FromLong(__pyx_t_4); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3242, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_12);
            __pyx_t_1 = __pyx_t_12;
            __pyx_t_12 = 0;
            __pyx_L93_bool_binop_done:;
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_idle_popup_blocking);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_idle_popup_blocking, __pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_1);
            __pyx_t_1 = 0;

            /* "ws_package/controllers/activity_controller.py":3245
 *                         )
 *                         force_upload_after_pause_cap = (
 *                             should_pause_api             # <<<<<<<<<<<<<<
 *                             and self._api_pause_cycles >= self._MAX_API_PAUSE_CYCLES
 *                             and not idle_popup_blocking
*/
            __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_should_pause_api); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 3245, __pyx_L6_error)
            if (__pyx_t_4) {
            } else {
              __Pyx_INCREF(__pyx_cur_scope->__pyx_v_should_pause_api);
              __pyx_t_1 = __pyx_cur_scope->__pyx_v_should_pause_api;
              goto __pyx_L95_bool_binop_done;
            }

            /* "ws_package/controllers/activity_controller.py":3246
 *                         force_upload_after_pause_cap = (
 *                             should_pause_api
 *                             and self._api_pause_cycles >= self._MAX_API_PAUSE_CYCLES             # <<<<<<<<<<<<<<
 *                             and not idle_popup_blocking
 *                         )
*/
            __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_api_pause_cycles); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3246, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_12);
            __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_MAX_API_PAUSE_CYCLES); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3246, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_18);
            __pyx_t_14 = PyObject_RichCompare(__pyx_t_12, __pyx_t_18, Py_GE); __Pyx_XGOTREF(__pyx_t_14); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3246, __pyx_L6_error)
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
            __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 3246, __pyx_L6_error)
            if (__pyx_t_4) {
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            } else {
              __Pyx_INCREF(__pyx_t_14);
              __pyx_t_1 = __pyx_t_14;
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              goto __pyx_L95_bool_binop_done;
            }

            /* "ws_package/controllers/activity_controller.py":3247
 *                             should_pause_api
 *                             and self._api_pause_cycles >= self._MAX_API_PAUSE_CYCLES
 *                             and not idle_popup_blocking             # <<<<<<<<<<<<<<
 *                         )
 *                         if should_pause_api and not force_upload_after_pause_cap:
*/
            __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_idle_popup_blocking); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 3247, __pyx_L6_error)
            __pyx_t_5 = (!__pyx_t_4);
            __pyx_t_14 = __Pyx_PyBool_FromLong(__pyx_t_5); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3247, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_14);
            __pyx_t_1 = __pyx_t_14;
            __pyx_t_14 = 0;
            __pyx_L95_bool_binop_done:;
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_force_upload_after_pause_cap);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_force_upload_after_pause_cap, __pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_1);
            __pyx_t_1 = 0;

            /* "ws_package/controllers/activity_controller.py":3249
 *                             and not idle_popup_blocking
 *                         )
 *                         if should_pause_api and not force_upload_after_pause_cap:             # <<<<<<<<<<<<<<
 *                             self._api_pause_cycles += 1
 *                             logger.info(
*/
            __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_should_pause_api); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 3249, __pyx_L6_error)
            if (__pyx_t_4) {
            } else {
              __pyx_t_5 = __pyx_t_4;
              goto __pyx_L99_bool_binop_done;
            }
            __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_force_upload_after_pause_cap); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 3249, __pyx_L6_error)
            __pyx_t_31 = (!__pyx_t_4);
            __pyx_t_5 = __pyx_t_31;
            __pyx_L99_bool_binop_done:;
            if (__pyx_t_5) {

              /* "ws_package/controllers/activity_controller.py":3250
 *                         )
 *                         if should_pause_api and not force_upload_after_pause_cap:
 *                             self._api_pause_cycles += 1             # <<<<<<<<<<<<<<
 *                             logger.info(
 *                                 "[APIBlock] API calls paused  cycle %d/%d "
*/
              __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_api_pause_cycles); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3250, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_t_14 = __Pyx_PyLong_AddObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3250, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_14);
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_api_pause_cycles, __pyx_t_14) < (0)) __PYX_ERR(0, 3250, __pyx_L6_error)
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

              /* "ws_package/controllers/activity_controller.py":3251
 *                         if should_pause_api and not force_upload_after_pause_cap:
 *                             self._api_pause_cycles += 1
 *                             logger.info(             # <<<<<<<<<<<<<<
 *                                 "[APIBlock] API calls paused  cycle %d/%d "
 *                                 "(zero activity or idle popup active); intervals saved to DB",
*/
              __pyx_t_1 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3251, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_18);
              __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3251, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

              /* "ws_package/controllers/activity_controller.py":3254
 *                                 "[APIBlock] API calls paused  cycle %d/%d "
 *                                 "(zero activity or idle popup active); intervals saved to DB",
 *                                 self._api_pause_cycles, self._MAX_API_PAUSE_CYCLES,             # <<<<<<<<<<<<<<
 *                             )
 *                             self._api_pause_active = True
*/
              __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_api_pause_cycles); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3254, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_18);
              __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_MAX_API_PAUSE_CYCLES); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3254, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_17);
              __pyx_t_3 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_12))) {
                __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_12);
                assert(__pyx_t_1);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
                __Pyx_INCREF(__pyx_t_1);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
                __pyx_t_3 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[4] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_APIBlock_API_calls_paused_cycle, __pyx_t_18, __pyx_t_17};
                __pyx_t_14 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_3, (4-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3251, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_14);
              }
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

              /* "ws_package/controllers/activity_controller.py":3256
 *                                 self._api_pause_cycles, self._MAX_API_PAUSE_CYCLES,
 *                             )
 *                             self._api_pause_active = True             # <<<<<<<<<<<<<<
 *                             await precise_sleep(self.interval, stop_event)
 *                             continue
*/
              if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_api_pause_active, Py_True) < (0)) __PYX_ERR(0, 3256, __pyx_L6_error)

              /* "ws_package/controllers/activity_controller.py":3257
 *                             )
 *                             self._api_pause_active = True
 *                             await precise_sleep(self.interval, stop_event)             # <<<<<<<<<<<<<<
 *                             continue
 *                         else:
*/
              __pyx_t_12 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_precise_sleep); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3257, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_17);
              __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3257, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_18);
              __pyx_t_3 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_17))) {
                __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_17);
                assert(__pyx_t_12);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
                __Pyx_INCREF(__pyx_t_12);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
                __pyx_t_3 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_12, __pyx_t_18, __pyx_cur_scope->__pyx_v_stop_event};
                __pyx_t_14 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3257, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_14);
              }
              __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_14, &__pyx_r);
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              if (likely(__pyx_t_15 == PYGEN_NEXT)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_XGIVEREF(__pyx_t_6);
                __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
                __Pyx_XGIVEREF(__pyx_t_7);
                __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
                __Pyx_XGIVEREF(__pyx_t_8);
                __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
                __Pyx_XGIVEREF(__pyx_r);
                __Pyx_RefNannyFinishContext();
                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                /* return from generator, awaiting value */
                __pyx_generator->resume_label = 14;
                return __pyx_r;
                __pyx_L101_resume_from_await:;
                __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
                __pyx_cur_scope->__pyx_t_0 = 0;
                __Pyx_XGOTREF(__pyx_t_6);
                __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
                __pyx_cur_scope->__pyx_t_1 = 0;
                __Pyx_XGOTREF(__pyx_t_7);
                __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
                __pyx_cur_scope->__pyx_t_2 = 0;
                __Pyx_XGOTREF(__pyx_t_8);
                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3257, __pyx_L6_error)
              } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_DECREF(__pyx_r); __pyx_r = 0;
              } else {
                __Pyx_XGOTREF(__pyx_r);
                __PYX_ERR(0, 3257, __pyx_L6_error)
              }

              /* "ws_package/controllers/activity_controller.py":3258
 *                             self._api_pause_active = True
 *                             await precise_sleep(self.interval, stop_event)
 *                             continue             # <<<<<<<<<<<<<<
 *                         else:
 *                             if force_upload_after_pause_cap:
*/
              goto __pyx_L12_try_continue;

              /* "ws_package/controllers/activity_controller.py":3249
 *                             and not idle_popup_blocking
 *                         )
 *                         if should_pause_api and not force_upload_after_pause_cap:             # <<<<<<<<<<<<<<
 *                             self._api_pause_cycles += 1
 *                             logger.info(
*/
            }

            /* "ws_package/controllers/activity_controller.py":3260
 *                             continue
 *                         else:
 *                             if force_upload_after_pause_cap:             # <<<<<<<<<<<<<<
 *                                 logger.warning(
 *                                     "[APIBlock] Max pause cycles (%d) reached  forcing upload "
*/
            /*else*/ {
              __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_force_upload_after_pause_cap); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 3260, __pyx_L6_error)
              if (__pyx_t_5) {

                /* "ws_package/controllers/activity_controller.py":3261
 *                         else:
 *                             if force_upload_after_pause_cap:
 *                                 logger.warning(             # <<<<<<<<<<<<<<
 *                                     "[APIBlock] Max pause cycles (%d) reached  forcing upload "
 *                                     "to prevent indefinite data hold (idle popup not active)",
*/
                __pyx_t_17 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3261, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_18);
                __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3261, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_12);
                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

                /* "ws_package/controllers/activity_controller.py":3264
 *                                     "[APIBlock] Max pause cycles (%d) reached  forcing upload "
 *                                     "to prevent indefinite data hold (idle popup not active)",
 *                                     self._MAX_API_PAUSE_CYCLES,             # <<<<<<<<<<<<<<
 *                                 )
 *                             self._api_pause_active = False
*/
                __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_MAX_API_PAUSE_CYCLES); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3264, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_18);
                __pyx_t_3 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_12))) {
                  __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_12);
                  assert(__pyx_t_17);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
                  __Pyx_INCREF(__pyx_t_17);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
                  __pyx_t_3 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_17, __pyx_mstate_global->__pyx_kp_u_APIBlock_Max_pause_cycles_d_rea, __pyx_t_18};
                  __pyx_t_14 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                  if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3261, __pyx_L6_error)
                  __Pyx_GOTREF(__pyx_t_14);
                }
                __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

                /* "ws_package/controllers/activity_controller.py":3260
 *                             continue
 *                         else:
 *                             if force_upload_after_pause_cap:             # <<<<<<<<<<<<<<
 *                                 logger.warning(
 *                                     "[APIBlock] Max pause cycles (%d) reached  forcing upload "
*/
              }

              /* "ws_package/controllers/activity_controller.py":3266
 *                                     self._MAX_API_PAUSE_CYCLES,
 *                                 )
 *                             self._api_pause_active = False             # <<<<<<<<<<<<<<
 *                             self._api_pause_cycles = 0  # reset on any successful push path
 * 
*/
              if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_api_pause_active, Py_False) < (0)) __PYX_ERR(0, 3266, __pyx_L6_error)

              /* "ws_package/controllers/activity_controller.py":3267
 *                                 )
 *                             self._api_pause_active = False
 *                             self._api_pause_cycles = 0  # reset on any successful push path             # <<<<<<<<<<<<<<
 * 
 *                     # NEW: If we have held idle intervals and non-idle interval found, send held intervals first
*/
              if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_api_pause_cycles, __pyx_mstate_global->__pyx_int_0) < (0)) __PYX_ERR(0, 3267, __pyx_L6_error)
            }

            /* "ws_package/controllers/activity_controller.py":3220
 *                     await self.check_stale_break()
 * 
 *                     if not is_silent_build():             # <<<<<<<<<<<<<<
 *                         # NEW REQUIREMENT: Check 60-minute timeout before checking API pause
 *                         timeout_reached = await self.check_idle_popup_timeout()
*/
          }

          /* "ws_package/controllers/activity_controller.py":3271
 *                     # NEW: If we have held idle intervals and non-idle interval found, send held intervals first
 *                     # CRITICAL: Only send held intervals from current counter (filter out intervals from previous counters)
 *                     current_counter = self.last_count + 1             # <<<<<<<<<<<<<<
 *                     if self._held_idle_intervals:
 *                         # Filter held intervals by current counter
*/
          __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3271, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_14);
          __pyx_t_12 = __Pyx_PyLong_AddObjC(__pyx_t_14, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3271, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_current_counter);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_current_counter, __pyx_t_12);
          __Pyx_GIVEREF(__pyx_t_12);
          __pyx_t_12 = 0;

          /* "ws_package/controllers/activity_controller.py":3272
 *                     # CRITICAL: Only send held intervals from current counter (filter out intervals from previous counters)
 *                     current_counter = self.last_count + 1
 *                     if self._held_idle_intervals:             # <<<<<<<<<<<<<<
 *                         # Filter held intervals by current counter
 *                         current_counter_held = [iv for iv in self._held_idle_intervals if getattr(iv, 'counter', None) == current_counter]
*/
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_held_idle_intervals); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3272, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_12); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 3272, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          if (__pyx_t_5) {

            /* "ws_package/controllers/activity_controller.py":3274
 *                     if self._held_idle_intervals:
 *                         # Filter held intervals by current counter
 *                         current_counter_held = [iv for iv in self._held_idle_intervals if getattr(iv, 'counter', None) == current_counter]             # <<<<<<<<<<<<<<
 *                         if current_counter_held:
 *                             logger.info("[APIBlock] Sending %s held idle interval(s) from current counter (%s) before non-idle interval", len(current_counter_held), current_counter)
*/
            { /* enter inner scope */
              __pyx_t_12 = PyList_New(0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3274, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_12);
              __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_held_idle_intervals); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3274, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_14);
              if (likely(PyList_CheckExact(__pyx_t_14)) || PyTuple_CheckExact(__pyx_t_14)) {
                __pyx_t_18 = __pyx_t_14; __Pyx_INCREF(__pyx_t_18);
                __pyx_t_19 = 0;
                __pyx_t_32 = NULL;
              } else {
                __pyx_t_19 = -1; __pyx_t_18 = PyObject_GetIter(__pyx_t_14); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3274, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_18);
                __pyx_t_32 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_18); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 3274, __pyx_L6_error)
              }
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              for (;;) {
                if (likely(!__pyx_t_32)) {
                  if (likely(PyList_CheckExact(__pyx_t_18))) {
                    {
                      Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_18);
                      #if !CYTHON_ASSUME_SAFE_SIZE
                      if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3274, __pyx_L6_error)
                      #endif
                      if (__pyx_t_19 >= __pyx_temp) break;
                    }
                    __pyx_t_14 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_18, __pyx_t_19, __Pyx_ReferenceSharing_OwnStrongReference);
                    ++__pyx_t_19;
                  } else {
                    {
                      Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_18);
                      #if !CYTHON_ASSUME_SAFE_SIZE
                      if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3274, __pyx_L6_error)
                      #endif
                      if (__pyx_t_19 >= __pyx_temp) break;
                    }
                    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                    __pyx_t_14 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_18, __pyx_t_19));
                    #else
                    __pyx_t_14 = __Pyx_PySequence_ITEM(__pyx_t_18, __pyx_t_19);
                    #endif
                    ++__pyx_t_19;
                  }
                  if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3274, __pyx_L6_error)
                } else {
                  __pyx_t_14 = __pyx_t_32(__pyx_t_18);
                  if (unlikely(!__pyx_t_14)) {
                    PyObject* exc_type = PyErr_Occurred();
                    if (exc_type) {
                      if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 3274, __pyx_L6_error)
                      PyErr_Clear();
                    }
                    break;
                  }
                }
                __Pyx_GOTREF(__pyx_t_14);
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_9genexpr11__pyx_v_iv);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_9genexpr11__pyx_v_iv, __pyx_t_14);
                __Pyx_GIVEREF(__pyx_t_14);
                __pyx_t_14 = 0;
                __pyx_t_14 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_9genexpr11__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_counter, Py_None); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3274, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_14);
                __pyx_t_17 = PyObject_RichCompare(__pyx_t_14, __pyx_cur_scope->__pyx_v_current_counter, Py_EQ); __Pyx_XGOTREF(__pyx_t_17); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3274, __pyx_L6_error)
                __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_17); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 3274, __pyx_L6_error)
                __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                if (__pyx_t_5) {
                  if (unlikely(__Pyx_ListComp_Append(__pyx_t_12, (PyObject*)__pyx_cur_scope->__pyx_9genexpr11__pyx_v_iv))) __PYX_ERR(0, 3274, __pyx_L6_error)
                }
              }
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
            } /* exit inner scope */
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_current_counter_held);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_current_counter_held, ((PyObject*)__pyx_t_12));
            __Pyx_GIVEREF(__pyx_t_12);
            __pyx_t_12 = 0;

            /* "ws_package/controllers/activity_controller.py":3275
 *                         # Filter held intervals by current counter
 *                         current_counter_held = [iv for iv in self._held_idle_intervals if getattr(iv, 'counter', None) == current_counter]
 *                         if current_counter_held:             # <<<<<<<<<<<<<<
 *                             logger.info("[APIBlock] Sending %s held idle interval(s) from current counter (%s) before non-idle interval", len(current_counter_held), current_counter)
 *                             held_intervals = current_counter_held.copy()
*/
            {
              Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_current_counter_held);
              if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 3275, __pyx_L6_error)
              __pyx_t_5 = (__pyx_temp != 0);
            }

            if (__pyx_t_5) {

              /* "ws_package/controllers/activity_controller.py":3276
 *                         current_counter_held = [iv for iv in self._held_idle_intervals if getattr(iv, 'counter', None) == current_counter]
 *                         if current_counter_held:
 *                             logger.info("[APIBlock] Sending %s held idle interval(s) from current counter (%s) before non-idle interval", len(current_counter_held), current_counter)             # <<<<<<<<<<<<<<
 *                             held_intervals = current_counter_held.copy()
 *                             # Remove sent intervals from held list
*/
              __pyx_t_18 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3276, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_17);
              __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3276, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_14);
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
              __pyx_t_19 = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_current_counter_held); if (unlikely(__pyx_t_19 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3276, __pyx_L6_error)
              __pyx_t_17 = PyLong_FromSsize_t(__pyx_t_19); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3276, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_17);
              __pyx_t_3 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_14))) {
                __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_14);
                assert(__pyx_t_18);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
                __Pyx_INCREF(__pyx_t_18);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
                __pyx_t_3 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[4] = {__pyx_t_18, __pyx_mstate_global->__pyx_kp_u_APIBlock_Sending_s_held_idle_in, __pyx_t_17, __pyx_cur_scope->__pyx_v_current_counter};
                __pyx_t_12 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_3, (4-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3276, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_12);
              }
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

              /* "ws_package/controllers/activity_controller.py":3277
 *                         if current_counter_held:
 *                             logger.info("[APIBlock] Sending %s held idle interval(s) from current counter (%s) before non-idle interval", len(current_counter_held), current_counter)
 *                             held_intervals = current_counter_held.copy()             # <<<<<<<<<<<<<<
 *                             # Remove sent intervals from held list
 *                             self._held_idle_intervals = [iv for iv in self._held_idle_intervals if getattr(iv, 'counter', None) != current_counter]
*/
              __pyx_t_12 = __Pyx_CallUnboundCMethod0(&__pyx_mstate_global->__pyx_umethod_PyList_Type__copy, __pyx_cur_scope->__pyx_v_current_counter_held); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3277, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_held_intervals);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_held_intervals, ((PyObject*)__pyx_t_12));
              __Pyx_GIVEREF(__pyx_t_12);
              __pyx_t_12 = 0;

              /* "ws_package/controllers/activity_controller.py":3279
 *                             held_intervals = current_counter_held.copy()
 *                             # Remove sent intervals from held list
 *                             self._held_idle_intervals = [iv for iv in self._held_idle_intervals if getattr(iv, 'counter', None) != current_counter]             # <<<<<<<<<<<<<<
 * 
 *                             # Process and send held idle intervals
*/
              { /* enter inner scope */
                __pyx_t_12 = PyList_New(0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3279, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_12);
                __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_held_idle_intervals); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3279, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_14);
                if (likely(PyList_CheckExact(__pyx_t_14)) || PyTuple_CheckExact(__pyx_t_14)) {
                  __pyx_t_17 = __pyx_t_14; __Pyx_INCREF(__pyx_t_17);
                  __pyx_t_19 = 0;
                  __pyx_t_32 = NULL;
                } else {
                  __pyx_t_19 = -1; __pyx_t_17 = PyObject_GetIter(__pyx_t_14); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3279, __pyx_L6_error)
                  __Pyx_GOTREF(__pyx_t_17);
                  __pyx_t_32 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_17); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 3279, __pyx_L6_error)
                }
                __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                for (;;) {
                  if (likely(!__pyx_t_32)) {
                    if (likely(PyList_CheckExact(__pyx_t_17))) {
                      {
                        Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_17);
                        #if !CYTHON_ASSUME_SAFE_SIZE
                        if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3279, __pyx_L6_error)
                        #endif
                        if (__pyx_t_19 >= __pyx_temp) break;
                      }
                      __pyx_t_14 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_17, __pyx_t_19, __Pyx_ReferenceSharing_OwnStrongReference);
                      ++__pyx_t_19;
                    } else {
                      {
                        Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_17);
                        #if !CYTHON_ASSUME_SAFE_SIZE
                        if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3279, __pyx_L6_error)
                        #endif
                        if (__pyx_t_19 >= __pyx_temp) break;
                      }
                      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                      __pyx_t_14 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_17, __pyx_t_19));
                      #else
                      __pyx_t_14 = __Pyx_PySequence_ITEM(__pyx_t_17, __pyx_t_19);
                      #endif
                      ++__pyx_t_19;
                    }
                    if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3279, __pyx_L6_error)
                  } else {
                    __pyx_t_14 = __pyx_t_32(__pyx_t_17);
                    if (unlikely(!__pyx_t_14)) {
                      PyObject* exc_type = PyErr_Occurred();
                      if (exc_type) {
                        if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 3279, __pyx_L6_error)
                        PyErr_Clear();
                      }
                      break;
                    }
                  }
                  __Pyx_GOTREF(__pyx_t_14);
                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_9genexpr12__pyx_v_iv);
                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_9genexpr12__pyx_v_iv, __pyx_t_14);
                  __Pyx_GIVEREF(__pyx_t_14);
                  __pyx_t_14 = 0;
                  __pyx_t_14 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_9genexpr12__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_counter, Py_None); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3279, __pyx_L6_error)
                  __Pyx_GOTREF(__pyx_t_14);
                  __pyx_t_18 = PyObject_RichCompare(__pyx_t_14, __pyx_cur_scope->__pyx_v_current_counter, Py_NE); __Pyx_XGOTREF(__pyx_t_18); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3279, __pyx_L6_error)
                  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_18); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 3279, __pyx_L6_error)
                  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                  if (__pyx_t_5) {
                    if (unlikely(__Pyx_ListComp_Append(__pyx_t_12, (PyObject*)__pyx_cur_scope->__pyx_9genexpr12__pyx_v_iv))) __PYX_ERR(0, 3279, __pyx_L6_error)
                  }
                }
                __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
              } /* exit inner scope */
              if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_held_idle_intervals, __pyx_t_12) < (0)) __PYX_ERR(0, 3279, __pyx_L6_error)
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

              /* "ws_package/controllers/activity_controller.py":3282
 * 
 *                             # Process and send held idle intervals
 *                             sending_held_intervals = self.process_intervals_bulk(held_intervals, org_id, user_entity)             # <<<<<<<<<<<<<<
 *                             self.activity_service.headers = {
 *                                 'SDToken': str(sd_token),
*/
              __pyx_t_17 = __pyx_cur_scope->__pyx_v_self;
              __Pyx_INCREF(__pyx_t_17);
              __pyx_t_3 = 0;
              {
                PyObject *__pyx_callargs[4] = {__pyx_t_17, __pyx_cur_scope->__pyx_v_held_intervals, __pyx_cur_scope->__pyx_v_org_id, __pyx_cur_scope->__pyx_v_user_entity};
                __pyx_t_12 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_process_intervals_bulk, __pyx_callargs+__pyx_t_3, (4-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3282, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_12);
              }
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_sending_held_intervals);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_sending_held_intervals, __pyx_t_12);
              __Pyx_GIVEREF(__pyx_t_12);
              __pyx_t_12 = 0;

              /* "ws_package/controllers/activity_controller.py":3284
 *                             sending_held_intervals = self.process_intervals_bulk(held_intervals, org_id, user_entity)
 *                             self.activity_service.headers = {
 *                                 'SDToken': str(sd_token),             # <<<<<<<<<<<<<<
 *                                 'OrgID': str(org_id),
 *                                 'UserID': str(user_id),
*/
              __pyx_t_12 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3284, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_12);
              __pyx_t_17 = __Pyx_PyObject_Unicode(__pyx_cur_scope->__pyx_v_sd_token); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3284, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_17);
              if (PyDict_SetItem(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_SDToken, __pyx_t_17) < (0)) __PYX_ERR(0, 3284, __pyx_L6_error)
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

              /* "ws_package/controllers/activity_controller.py":3285
 *                             self.activity_service.headers = {
 *                                 'SDToken': str(sd_token),
 *                                 'OrgID': str(org_id),             # <<<<<<<<<<<<<<
 *                                 'UserID': str(user_id),
 *                                 'appVersion': str(appVersion),
*/
              __pyx_t_17 = __Pyx_PyObject_Unicode(__pyx_cur_scope->__pyx_v_org_id); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3285, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_17);
              if (PyDict_SetItem(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_OrgID, __pyx_t_17) < (0)) __PYX_ERR(0, 3284, __pyx_L6_error)
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

              /* "ws_package/controllers/activity_controller.py":3286
 *                                 'SDToken': str(sd_token),
 *                                 'OrgID': str(org_id),
 *                                 'UserID': str(user_id),             # <<<<<<<<<<<<<<
 *                                 'appVersion': str(appVersion),
 *                                 'Authorization': f'Bearer {sd_token}'
*/
              __pyx_t_17 = __Pyx_PyObject_Unicode(__pyx_cur_scope->__pyx_v_user_id); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3286, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_17);
              if (PyDict_SetItem(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_UserID, __pyx_t_17) < (0)) __PYX_ERR(0, 3284, __pyx_L6_error)
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

              /* "ws_package/controllers/activity_controller.py":3287
 *                                 'OrgID': str(org_id),
 *                                 'UserID': str(user_id),
 *                                 'appVersion': str(appVersion),             # <<<<<<<<<<<<<<
 *                                 'Authorization': f'Bearer {sd_token}'
 *                             }
*/
              __pyx_t_17 = __Pyx_PyObject_Unicode(__pyx_cur_scope->__pyx_v_appVersion); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3287, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_17);
              if (PyDict_SetItem(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_appVersion, __pyx_t_17) < (0)) __PYX_ERR(0, 3284, __pyx_L6_error)
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

              /* "ws_package/controllers/activity_controller.py":3288
 *                                 'UserID': str(user_id),
 *                                 'appVersion': str(appVersion),
 *                                 'Authorization': f'Bearer {sd_token}'             # <<<<<<<<<<<<<<
 *                             }
 * 
*/
              __pyx_t_17 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_sd_token, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3288, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_17);
              __pyx_t_18 = __Pyx_PyUnicode_Concat(__pyx_mstate_global->__pyx_kp_u_Bearer, __pyx_t_17); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3288, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_18);
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
              if (PyDict_SetItem(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_Authorization, __pyx_t_18) < (0)) __PYX_ERR(0, 3284, __pyx_L6_error)
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

              /* "ws_package/controllers/activity_controller.py":3283
 *                             # Process and send held idle intervals
 *                             sending_held_intervals = self.process_intervals_bulk(held_intervals, org_id, user_entity)
 *                             self.activity_service.headers = {             # <<<<<<<<<<<<<<
 *                                 'SDToken': str(sd_token),
 *                                 'OrgID': str(org_id),
*/
              __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3283, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_18);
              if (__Pyx_PyObject_SetAttrStr(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_headers, __pyx_t_12) < (0)) __PYX_ERR(0, 3283, __pyx_L6_error)
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

              /* "ws_package/controllers/activity_controller.py":3291
 *                             }
 * 
 *                             held_sent_count = 0             # <<<<<<<<<<<<<<
 *                             async for response in sending_held_intervals:
 *                                 if not response or not isinstance(response, (list, tuple)):
*/
              __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_held_sent_count);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_held_sent_count, __pyx_mstate_global->__pyx_int_0);
              __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_0);

              /* "ws_package/controllers/activity_controller.py":3292
 * 
 *                             held_sent_count = 0
 *                             async for response in sending_held_intervals:             # <<<<<<<<<<<<<<
 *                                 if not response or not isinstance(response, (list, tuple)):
 *                                     logger.info("No interval found in held intervals %s", response)
*/
              __pyx_t_18 = __Pyx_Coroutine_GetAsyncIter(__pyx_cur_scope->__pyx_v_sending_held_intervals); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3292, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_18);
              for (;;) {
                __pyx_t_12 = __Pyx_Coroutine_AsyncIterNext(__pyx_t_18); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3292, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_12);
                __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_12, &__pyx_r);
                __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                if (likely(__pyx_t_15 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_6);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
                  __Pyx_XGIVEREF(__pyx_t_7);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
                  __Pyx_XGIVEREF(__pyx_t_8);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_18;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 15;
                  return __pyx_r;
                  __pyx_L115_resume_from_await:;
                  __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_6);
                  __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_7);
                  __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_8);
                  __pyx_t_18 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_18);
                  if (unlikely(!__pyx_sent_value)) {
                    PyObject* exc_type = __Pyx_PyErr_CurrentExceptionType();
                    if (unlikely(exc_type && (exc_type == PyExc_StopAsyncIteration || ( exc_type != PyExc_StopIteration && exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopAsyncIteration))))) {
                      PyErr_Clear();
                      break;
                    }
                    __PYX_ERR(0, 3292, __pyx_L6_error)
                  }
                  __pyx_t_12 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_12);
                } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __pyx_t_12 = __pyx_r; __pyx_r = NULL;
                } else {
                  PyObject* exc_type = __Pyx_PyErr_CurrentExceptionType();
                  if (unlikely(exc_type && (exc_type == PyExc_StopAsyncIteration || ( exc_type != PyExc_StopIteration && exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopAsyncIteration))))) {
                    PyErr_Clear();
                    break;
                  }
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 3292, __pyx_L6_error)
                }
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_response);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_response, __pyx_t_12);
                __Pyx_GIVEREF(__pyx_t_12);
                __pyx_t_12 = 0;

                /* "ws_package/controllers/activity_controller.py":3293
 *                             held_sent_count = 0
 *                             async for response in sending_held_intervals:
 *                                 if not response or not isinstance(response, (list, tuple)):             # <<<<<<<<<<<<<<
 *                                     logger.info("No interval found in held intervals %s", response)
 *                                     continue
*/
                __pyx_t_31 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_response); if (unlikely((__pyx_t_31 < 0))) __PYX_ERR(0, 3293, __pyx_L6_error)
                __pyx_t_4 = (!__pyx_t_31);
                if (!__pyx_t_4) {
                } else {
                  __pyx_t_5 = __pyx_t_4;
                  goto __pyx_L117_bool_binop_done;
                }
                __pyx_t_31 = PyList_Check(__pyx_cur_scope->__pyx_v_response); 
                if (!__pyx_t_31) {
                } else {
                  __pyx_t_4 = __pyx_t_31;
                  goto __pyx_L119_bool_binop_done;
                }
                __pyx_t_31 = PyTuple_Check(__pyx_cur_scope->__pyx_v_response); 
                __pyx_t_4 = __pyx_t_31;
                __pyx_L119_bool_binop_done:;
                __pyx_t_31 = (!__pyx_t_4);
                __pyx_t_5 = __pyx_t_31;
                __pyx_L117_bool_binop_done:;
                if (__pyx_t_5) {

                  /* "ws_package/controllers/activity_controller.py":3294
 *                             async for response in sending_held_intervals:
 *                                 if not response or not isinstance(response, (list, tuple)):
 *                                     logger.info("No interval found in held intervals %s", response)             # <<<<<<<<<<<<<<
 *                                     continue
 * 
*/
                  __pyx_t_17 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3294, __pyx_L6_error)
                  __Pyx_GOTREF(__pyx_t_14);
                  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3294, __pyx_L6_error)
                  __Pyx_GOTREF(__pyx_t_1);
                  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                  __pyx_t_3 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_1))) {
                    __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_1);
                    assert(__pyx_t_17);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
                    __Pyx_INCREF(__pyx_t_17);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
                    __pyx_t_3 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[3] = {__pyx_t_17, __pyx_mstate_global->__pyx_kp_u_No_interval_found_in_held_interv, __pyx_cur_scope->__pyx_v_response};
                    __pyx_t_12 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                    if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3294, __pyx_L6_error)
                    __Pyx_GOTREF(__pyx_t_12);
                  }
                  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

                  /* "ws_package/controllers/activity_controller.py":3295
 *                                 if not response or not isinstance(response, (list, tuple)):
 *                                     logger.info("No interval found in held intervals %s", response)
 *                                     continue             # <<<<<<<<<<<<<<
 * 
 *                                 _response = self.activity_service.push_activity_logs(response[0])
*/
                  goto __pyx_L113_continue;

                  /* "ws_package/controllers/activity_controller.py":3293
 *                             held_sent_count = 0
 *                             async for response in sending_held_intervals:
 *                                 if not response or not isinstance(response, (list, tuple)):             # <<<<<<<<<<<<<<
 *                                     logger.info("No interval found in held intervals %s", response)
 *                                     continue
*/
                }

                /* "ws_package/controllers/activity_controller.py":3297
 *                                     continue
 * 
 *                                 _response = self.activity_service.push_activity_logs(response[0])             # <<<<<<<<<<<<<<
 *                                 logger.info("Response for held idle intervals: %s", _response)
 *                                 held_sent_count += 1
*/
                __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3297, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_17);
                __pyx_t_1 = __pyx_t_17;
                __Pyx_INCREF(__pyx_t_1);
                __pyx_t_14 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_response, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_SharedReference); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3297, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_14);
                __pyx_t_3 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_t_14};
                  __pyx_t_12 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_push_activity_logs, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                  if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3297, __pyx_L6_error)
                  __Pyx_GOTREF(__pyx_t_12);
                }
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v__response);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v__response, __pyx_t_12);
                __Pyx_GIVEREF(__pyx_t_12);
                __pyx_t_12 = 0;

                /* "ws_package/controllers/activity_controller.py":3298
 * 
 *                                 _response = self.activity_service.push_activity_logs(response[0])
 *                                 logger.info("Response for held idle intervals: %s", _response)             # <<<<<<<<<<<<<<
 *                                 held_sent_count += 1
 * 
*/
                __pyx_t_17 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3298, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_14);
                __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3298, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_1);
                __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                __pyx_t_3 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_1))) {
                  __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_1);
                  assert(__pyx_t_17);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
                  __Pyx_INCREF(__pyx_t_17);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
                  __pyx_t_3 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_17, __pyx_mstate_global->__pyx_kp_u_Response_for_held_idle_intervals, __pyx_cur_scope->__pyx_v__response};
                  __pyx_t_12 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                  if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3298, __pyx_L6_error)
                  __Pyx_GOTREF(__pyx_t_12);
                }
                __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

                /* "ws_package/controllers/activity_controller.py":3299
 *                                 _response = self.activity_service.push_activity_logs(response[0])
 *                                 logger.info("Response for held idle intervals: %s", _response)
 *                                 held_sent_count += 1             # <<<<<<<<<<<<<<
 * 
 *                             logger.info("[APIBlock] Successfully sent %s held idle interval(s)", held_sent_count)
*/
                __pyx_t_12 = __Pyx_PyLong_AddObjC(__pyx_cur_scope->__pyx_v_held_sent_count, __pyx_mstate_global->__pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3299, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_12);
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_held_sent_count);
                __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_held_sent_count, __pyx_t_12);
                __Pyx_GIVEREF(__pyx_t_12);
                __pyx_t_12 = 0;

                /* "ws_package/controllers/activity_controller.py":3292
 * 
 *                             held_sent_count = 0
 *                             async for response in sending_held_intervals:             # <<<<<<<<<<<<<<
 *                                 if not response or not isinstance(response, (list, tuple)):
 *                                     logger.info("No interval found in held intervals %s", response)
*/
                __pyx_L113_continue:;
              }
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

              /* "ws_package/controllers/activity_controller.py":3301
 *                                 held_sent_count += 1
 * 
 *                             logger.info("[APIBlock] Successfully sent %s held idle interval(s)", held_sent_count)             # <<<<<<<<<<<<<<
 *                         else:
 *                             # All held intervals are from previous counter - clear them
*/
              __pyx_t_12 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3301, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3301, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_17);
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __pyx_t_3 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_17))) {
                __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_17);
                assert(__pyx_t_12);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
                __Pyx_INCREF(__pyx_t_12);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
                __pyx_t_3 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_12, __pyx_mstate_global->__pyx_kp_u_APIBlock_Successfully_sent_s_he, __pyx_cur_scope->__pyx_v_held_sent_count};
                __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3301, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_18);
              }
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

              /* "ws_package/controllers/activity_controller.py":3275
 *                         # Filter held intervals by current counter
 *                         current_counter_held = [iv for iv in self._held_idle_intervals if getattr(iv, 'counter', None) == current_counter]
 *                         if current_counter_held:             # <<<<<<<<<<<<<<
 *                             logger.info("[APIBlock] Sending %s held idle interval(s) from current counter (%s) before non-idle interval", len(current_counter_held), current_counter)
 *                             held_intervals = current_counter_held.copy()
*/
              goto __pyx_L108;
            }

            /* "ws_package/controllers/activity_controller.py":3304
 *                         else:
 *                             # All held intervals are from previous counter - clear them
 *                             logger.info("[APIBlock] Clearing %s held idle interval(s) from previous counter (current counter=%s)", len(self._held_idle_intervals), current_counter)             # <<<<<<<<<<<<<<
 *                             self._held_idle_intervals = []
 * 
*/
            /*else*/ {
              __pyx_t_17 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3304, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_12);
              __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3304, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
              __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_held_idle_intervals); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3304, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_12);
              __pyx_t_19 = PyObject_Length(__pyx_t_12); if (unlikely(__pyx_t_19 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3304, __pyx_L6_error)
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
              __pyx_t_12 = PyLong_FromSsize_t(__pyx_t_19); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3304, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_12);
              __pyx_t_3 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_1))) {
                __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_1);
                assert(__pyx_t_17);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
                __Pyx_INCREF(__pyx_t_17);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
                __pyx_t_3 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[4] = {__pyx_t_17, __pyx_mstate_global->__pyx_kp_u_APIBlock_Clearing_s_held_idle_i, __pyx_t_12, __pyx_cur_scope->__pyx_v_current_counter};
                __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_3, (4-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3304, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_18);
              }
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

              /* "ws_package/controllers/activity_controller.py":3305
 *                             # All held intervals are from previous counter - clear them
 *                             logger.info("[APIBlock] Clearing %s held idle interval(s) from previous counter (current counter=%s)", len(self._held_idle_intervals), current_counter)
 *                             self._held_idle_intervals = []             # <<<<<<<<<<<<<<
 * 
 *                     # CRITICAL: Filter out held idle intervals and unsent is_idle rows before sending
*/
              __pyx_t_18 = PyList_New(0); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3305, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_18);
              if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_held_idle_intervals, __pyx_t_18) < (0)) __PYX_ERR(0, 3305, __pyx_L6_error)
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
            }
            __pyx_L108:;

            /* "ws_package/controllers/activity_controller.py":3272
 *                     # CRITICAL: Only send held intervals from current counter (filter out intervals from previous counters)
 *                     current_counter = self.last_count + 1
 *                     if self._held_idle_intervals:             # <<<<<<<<<<<<<<
 *                         # Filter held intervals by current counter
 *                         current_counter_held = [iv for iv in self._held_idle_intervals if getattr(iv, 'counter', None) == current_counter]
*/
          }

          /* "ws_package/controllers/activity_controller.py":3308
 * 
 *                     # CRITICAL: Filter out held idle intervals and unsent is_idle rows before sending
 *                     held_interval_ids = {getattr(held, 'id', None) for held in self._held_idle_intervals}             # <<<<<<<<<<<<<<
 *                     filtered_intervals = [
 *                         iv for iv in intervals
*/
          { /* enter inner scope */
            __pyx_t_18 = PySet_New(NULL); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3308, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_18);
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_held_idle_intervals); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3308, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_1);
            if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
              __pyx_t_12 = __pyx_t_1; __Pyx_INCREF(__pyx_t_12);
              __pyx_t_19 = 0;
              __pyx_t_32 = NULL;
            } else {
              __pyx_t_19 = -1; __pyx_t_12 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3308, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_12);
              __pyx_t_32 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_12); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 3308, __pyx_L6_error)
            }
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            for (;;) {
              if (likely(!__pyx_t_32)) {
                if (likely(PyList_CheckExact(__pyx_t_12))) {
                  {
                    Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_12);
                    #if !CYTHON_ASSUME_SAFE_SIZE
                    if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3308, __pyx_L6_error)
                    #endif
                    if (__pyx_t_19 >= __pyx_temp) break;
                  }
                  __pyx_t_1 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_12, __pyx_t_19, __Pyx_ReferenceSharing_OwnStrongReference);
                  ++__pyx_t_19;
                } else {
                  {
                    Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_12);
                    #if !CYTHON_ASSUME_SAFE_SIZE
                    if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3308, __pyx_L6_error)
                    #endif
                    if (__pyx_t_19 >= __pyx_temp) break;
                  }
                  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                  __pyx_t_1 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_12, __pyx_t_19));
                  #else
                  __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_12, __pyx_t_19);
                  #endif
                  ++__pyx_t_19;
                }
                if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3308, __pyx_L6_error)
              } else {
                __pyx_t_1 = __pyx_t_32(__pyx_t_12);
                if (unlikely(!__pyx_t_1)) {
                  PyObject* exc_type = PyErr_Occurred();
                  if (exc_type) {
                    if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 3308, __pyx_L6_error)
                    PyErr_Clear();
                  }
                  break;
                }
              }
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_9genexpr13__pyx_v_held);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_9genexpr13__pyx_v_held, __pyx_t_1);
              __Pyx_GIVEREF(__pyx_t_1);
              __pyx_t_1 = 0;
              __pyx_t_1 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_9genexpr13__pyx_v_held, __pyx_mstate_global->__pyx_n_u_id, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3308, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_1);
              if (unlikely(PySet_Add(__pyx_t_18, (PyObject*)__pyx_t_1))) __PYX_ERR(0, 3308, __pyx_L6_error)
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            }
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          } /* exit inner scope */
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_held_interval_ids);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_held_interval_ids, ((PyObject*)__pyx_t_18));
          __Pyx_GIVEREF(__pyx_t_18);
          __pyx_t_18 = 0;

          /* "ws_package/controllers/activity_controller.py":3309
 *                     # CRITICAL: Filter out held idle intervals and unsent is_idle rows before sending
 *                     held_interval_ids = {getattr(held, 'id', None) for held in self._held_idle_intervals}
 *                     filtered_intervals = [             # <<<<<<<<<<<<<<
 *                         iv for iv in intervals
 *                         if getattr(iv, 'id', None) not in held_interval_ids
*/
          { /* enter inner scope */
            __pyx_t_18 = PyList_New(0); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3309, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_18);

            /* "ws_package/controllers/activity_controller.py":3310
 *                     held_interval_ids = {getattr(held, 'id', None) for held in self._held_idle_intervals}
 *                     filtered_intervals = [
 *                         iv for iv in intervals             # <<<<<<<<<<<<<<
 *                         if getattr(iv, 'id', None) not in held_interval_ids
 *                         and not (
*/
            if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_intervals)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_intervals)) {
              __pyx_t_12 = __pyx_cur_scope->__pyx_v_intervals; __Pyx_INCREF(__pyx_t_12);
              __pyx_t_19 = 0;
              __pyx_t_32 = NULL;
            } else {
              __pyx_t_19 = -1; __pyx_t_12 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_intervals); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3310, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_12);
              __pyx_t_32 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_12); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 3310, __pyx_L6_error)
            }
            for (;;) {
              if (likely(!__pyx_t_32)) {
                if (likely(PyList_CheckExact(__pyx_t_12))) {
                  {
                    Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_12);
                    #if !CYTHON_ASSUME_SAFE_SIZE
                    if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3310, __pyx_L6_error)
                    #endif
                    if (__pyx_t_19 >= __pyx_temp) break;
                  }
                  __pyx_t_1 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_12, __pyx_t_19, __Pyx_ReferenceSharing_OwnStrongReference);
                  ++__pyx_t_19;
                } else {
                  {
                    Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_12);
                    #if !CYTHON_ASSUME_SAFE_SIZE
                    if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3310, __pyx_L6_error)
                    #endif
                    if (__pyx_t_19 >= __pyx_temp) break;
                  }
                  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                  __pyx_t_1 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_12, __pyx_t_19));
                  #else
                  __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_12, __pyx_t_19);
                  #endif
                  ++__pyx_t_19;
                }
                if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3310, __pyx_L6_error)
              } else {
                __pyx_t_1 = __pyx_t_32(__pyx_t_12);
                if (unlikely(!__pyx_t_1)) {
                  PyObject* exc_type = PyErr_Occurred();
                  if (exc_type) {
                    if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 3310, __pyx_L6_error)
                    PyErr_Clear();
                  }
                  break;
                }
              }
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_9genexpr14__pyx_v_iv);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_9genexpr14__pyx_v_iv, __pyx_t_1);
              __Pyx_GIVEREF(__pyx_t_1);
              __pyx_t_1 = 0;

              /* "ws_package/controllers/activity_controller.py":3311
 *                     filtered_intervals = [
 *                         iv for iv in intervals
 *                         if getattr(iv, 'id', None) not in held_interval_ids             # <<<<<<<<<<<<<<
 *                         and not (
 *                             getattr(iv, 'is_idle', False)
*/
              __pyx_t_1 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_9genexpr14__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_id, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3311, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_t_31 = (__Pyx_PySet_ContainsTF(__pyx_t_1, __pyx_cur_scope->__pyx_v_held_interval_ids, Py_NE)); if (unlikely((__pyx_t_31 < 0))) __PYX_ERR(0, 3311, __pyx_L6_error)
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (__pyx_t_31) {
              } else {
                __pyx_t_5 = __pyx_t_31;
                goto __pyx_L128_bool_binop_done;
              }

              /* "ws_package/controllers/activity_controller.py":3313
 *                         if getattr(iv, 'id', None) not in held_interval_ids
 *                         and not (
 *                             getattr(iv, 'is_idle', False)             # <<<<<<<<<<<<<<
 *                             and not getattr(iv, 'is_uploaded', False)
 *                         )
*/
              __pyx_t_1 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_9genexpr14__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_is_idle, Py_False); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3313, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 3313, __pyx_L6_error)
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (__pyx_t_4) {
              } else {
                __pyx_t_31 = __pyx_t_4;
                goto __pyx_L130_bool_binop_done;
              }

              /* "ws_package/controllers/activity_controller.py":3314
 *                         and not (
 *                             getattr(iv, 'is_idle', False)
 *                             and not getattr(iv, 'is_uploaded', False)             # <<<<<<<<<<<<<<
 *                         )
 *                     ]
*/
              __pyx_t_1 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_9genexpr14__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_is_uploaded, Py_False); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3314, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 3314, __pyx_L6_error)
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __pyx_t_33 = (!__pyx_t_4);
              __pyx_t_31 = __pyx_t_33;
              __pyx_L130_bool_binop_done:;

              /* "ws_package/controllers/activity_controller.py":3312
 *                         iv for iv in intervals
 *                         if getattr(iv, 'id', None) not in held_interval_ids
 *                         and not (             # <<<<<<<<<<<<<<
 *                             getattr(iv, 'is_idle', False)
 *                             and not getattr(iv, 'is_uploaded', False)
*/
              __pyx_t_33 = (!__pyx_t_31);
              __pyx_t_5 = __pyx_t_33;
              __pyx_L128_bool_binop_done:;

              /* "ws_package/controllers/activity_controller.py":3311
 *                     filtered_intervals = [
 *                         iv for iv in intervals
 *                         if getattr(iv, 'id', None) not in held_interval_ids             # <<<<<<<<<<<<<<
 *                         and not (
 *                             getattr(iv, 'is_idle', False)
*/
              if (__pyx_t_5) {

                /* "ws_package/controllers/activity_controller.py":3310
 *                     held_interval_ids = {getattr(held, 'id', None) for held in self._held_idle_intervals}
 *                     filtered_intervals = [
 *                         iv for iv in intervals             # <<<<<<<<<<<<<<
 *                         if getattr(iv, 'id', None) not in held_interval_ids
 *                         and not (
*/
                if (unlikely(__Pyx_ListComp_Append(__pyx_t_18, (PyObject*)__pyx_cur_scope->__pyx_9genexpr14__pyx_v_iv))) __PYX_ERR(0, 3309, __pyx_L6_error)

                /* "ws_package/controllers/activity_controller.py":3311
 *                     filtered_intervals = [
 *                         iv for iv in intervals
 *                         if getattr(iv, 'id', None) not in held_interval_ids             # <<<<<<<<<<<<<<
 *                         and not (
 *                             getattr(iv, 'is_idle', False)
*/
              }

              /* "ws_package/controllers/activity_controller.py":3310
 *                     held_interval_ids = {getattr(held, 'id', None) for held in self._held_idle_intervals}
 *                     filtered_intervals = [
 *                         iv for iv in intervals             # <<<<<<<<<<<<<<
 *                         if getattr(iv, 'id', None) not in held_interval_ids
 *                         and not (
*/
            }
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          } /* exit inner scope */
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_filtered_intervals);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_filtered_intervals, ((PyObject*)__pyx_t_18));
          __Pyx_GIVEREF(__pyx_t_18);
          __pyx_t_18 = 0;

          /* "ws_package/controllers/activity_controller.py":3318
 *                     ]
 * 
 *                     excluded = len(intervals) - len(filtered_intervals)             # <<<<<<<<<<<<<<
 *                     if excluded:
 *                         logger.info(
*/
          __pyx_t_19 = PyObject_Length(__pyx_cur_scope->__pyx_v_intervals); if (unlikely(__pyx_t_19 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3318, __pyx_L6_error)
          __pyx_t_34 = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_filtered_intervals); if (unlikely(__pyx_t_34 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3318, __pyx_L6_error)
          __pyx_cur_scope->__pyx_v_excluded = (__pyx_t_19 - __pyx_t_34);

          /* "ws_package/controllers/activity_controller.py":3319
 * 
 *                     excluded = len(intervals) - len(filtered_intervals)
 *                     if excluded:             # <<<<<<<<<<<<<<
 *                         logger.info(
 *                             "[APIBlock] Excluded %s interval(s) from upload (held or is_idle pending popup)",
*/
          __pyx_t_5 = (__pyx_cur_scope->__pyx_v_excluded != 0);
          if (__pyx_t_5) {

            /* "ws_package/controllers/activity_controller.py":3320
 *                     excluded = len(intervals) - len(filtered_intervals)
 *                     if excluded:
 *                         logger.info(             # <<<<<<<<<<<<<<
 *                             "[APIBlock] Excluded %s interval(s) from upload (held or is_idle pending popup)",
 *                             excluded,
*/
            __pyx_t_12 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3320, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3320, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_17);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

            /* "ws_package/controllers/activity_controller.py":3322
 *                         logger.info(
 *                             "[APIBlock] Excluded %s interval(s) from upload (held or is_idle pending popup)",
 *                             excluded,             # <<<<<<<<<<<<<<
 *                         )
 * 
*/
            __pyx_t_1 = PyLong_FromSsize_t(__pyx_cur_scope->__pyx_v_excluded); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3322, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_3 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_17))) {
              __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_17);
              assert(__pyx_t_12);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
              __Pyx_INCREF(__pyx_t_12);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
              __pyx_t_3 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_12, __pyx_mstate_global->__pyx_kp_u_APIBlock_Excluded_s_interval_s, __pyx_t_1};
              __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
              if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3320, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_18);
            }
            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

            /* "ws_package/controllers/activity_controller.py":3319
 * 
 *                     excluded = len(intervals) - len(filtered_intervals)
 *                     if excluded:             # <<<<<<<<<<<<<<
 *                         logger.info(
 *                             "[APIBlock] Excluded %s interval(s) from upload (held or is_idle pending popup)",
*/
          }

          /* "ws_package/controllers/activity_controller.py":3326
 * 
 *                     # Only send non-idle intervals (held idle intervals are sent separately above)
 *                     sending_intervals = self.process_intervals_bulk(filtered_intervals, org_id, user_entity)             # <<<<<<<<<<<<<<
 * 
 *                     self.activity_service.headers = {
*/
          __pyx_t_17 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_17);
          __pyx_t_3 = 0;
          {
            PyObject *__pyx_callargs[4] = {__pyx_t_17, __pyx_cur_scope->__pyx_v_filtered_intervals, __pyx_cur_scope->__pyx_v_org_id, __pyx_cur_scope->__pyx_v_user_entity};
            __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_process_intervals_bulk, __pyx_callargs+__pyx_t_3, (4-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
            if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3326, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_18);
          }
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_sending_intervals);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_sending_intervals, __pyx_t_18);
          __Pyx_GIVEREF(__pyx_t_18);
          __pyx_t_18 = 0;

          /* "ws_package/controllers/activity_controller.py":3329
 * 
 *                     self.activity_service.headers = {
 *                         'SDToken': str(sd_token),             # <<<<<<<<<<<<<<
 *                         'OrgID': str(org_id),
 *                         'UserID': str(user_id),
*/
          __pyx_t_18 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3329, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_18);
          __pyx_t_17 = __Pyx_PyObject_Unicode(__pyx_cur_scope->__pyx_v_sd_token); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3329, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_17);
          if (PyDict_SetItem(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_SDToken, __pyx_t_17) < (0)) __PYX_ERR(0, 3329, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

          /* "ws_package/controllers/activity_controller.py":3330
 *                     self.activity_service.headers = {
 *                         'SDToken': str(sd_token),
 *                         'OrgID': str(org_id),             # <<<<<<<<<<<<<<
 *                         'UserID': str(user_id),
 *                         'appVersion': str(appVersion),
*/
          __pyx_t_17 = __Pyx_PyObject_Unicode(__pyx_cur_scope->__pyx_v_org_id); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3330, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_17);
          if (PyDict_SetItem(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_OrgID, __pyx_t_17) < (0)) __PYX_ERR(0, 3329, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

          /* "ws_package/controllers/activity_controller.py":3331
 *                         'SDToken': str(sd_token),
 *                         'OrgID': str(org_id),
 *                         'UserID': str(user_id),             # <<<<<<<<<<<<<<
 *                         'appVersion': str(appVersion),
 *                         'Authorization': f'Bearer {sd_token}'
*/
          __pyx_t_17 = __Pyx_PyObject_Unicode(__pyx_cur_scope->__pyx_v_user_id); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3331, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_17);
          if (PyDict_SetItem(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_UserID, __pyx_t_17) < (0)) __PYX_ERR(0, 3329, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

          /* "ws_package/controllers/activity_controller.py":3332
 *                         'OrgID': str(org_id),
 *                         'UserID': str(user_id),
 *                         'appVersion': str(appVersion),             # <<<<<<<<<<<<<<
 *                         'Authorization': f'Bearer {sd_token}'
 *                     }
*/
          __pyx_t_17 = __Pyx_PyObject_Unicode(__pyx_cur_scope->__pyx_v_appVersion); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3332, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_17);
          if (PyDict_SetItem(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_appVersion, __pyx_t_17) < (0)) __PYX_ERR(0, 3329, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

          /* "ws_package/controllers/activity_controller.py":3333
 *                         'UserID': str(user_id),
 *                         'appVersion': str(appVersion),
 *                         'Authorization': f'Bearer {sd_token}'             # <<<<<<<<<<<<<<
 *                     }
 * 
*/
          __pyx_t_17 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_sd_token, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3333, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_1 = __Pyx_PyUnicode_Concat(__pyx_mstate_global->__pyx_kp_u_Bearer, __pyx_t_17); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3333, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          if (PyDict_SetItem(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_Authorization, __pyx_t_1) < (0)) __PYX_ERR(0, 3329, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":3328
 *                     sending_intervals = self.process_intervals_bulk(filtered_intervals, org_id, user_entity)
 * 
 *                     self.activity_service.headers = {             # <<<<<<<<<<<<<<
 *                         'SDToken': str(sd_token),
 *                         'OrgID': str(org_id),
*/
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3328, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
          if (__Pyx_PyObject_SetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_headers, __pyx_t_18) < (0)) __PYX_ERR(0, 3328, __pyx_L6_error)
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":3336
 *                     }
 * 
 *                     async for response in sending_intervals:             # <<<<<<<<<<<<<<
 *                         if not response or not isinstance(response, (list, tuple)):
 *                             logger.info("No interval found %s", response)
*/
          __pyx_t_1 = __Pyx_Coroutine_GetAsyncIter(__pyx_cur_scope->__pyx_v_sending_intervals); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3336, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
          for (;;) {
            __pyx_t_18 = __Pyx_Coroutine_AsyncIterNext(__pyx_t_1); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3336, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_18);
            __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_18, &__pyx_r);
            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
            if (likely(__pyx_t_15 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_1);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
              __Pyx_XGIVEREF(__pyx_t_6);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
              __Pyx_XGIVEREF(__pyx_t_7);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
              __Pyx_XGIVEREF(__pyx_t_8);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_8;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 16;
              return __pyx_r;
              __pyx_L136_resume_from_await:;
              __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_1);
              __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_6);
              __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_7);
              __pyx_t_8 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_8);
              if (unlikely(!__pyx_sent_value)) {
                PyObject* exc_type = __Pyx_PyErr_CurrentExceptionType();
                if (unlikely(exc_type && (exc_type == PyExc_StopAsyncIteration || ( exc_type != PyExc_StopIteration && exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopAsyncIteration))))) {
                  PyErr_Clear();
                  break;
                }
                __PYX_ERR(0, 3336, __pyx_L6_error)
              }
              __pyx_t_18 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_18);
            } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __pyx_t_18 = __pyx_r; __pyx_r = NULL;
            } else {
              PyObject* exc_type = __Pyx_PyErr_CurrentExceptionType();
              if (unlikely(exc_type && (exc_type == PyExc_StopAsyncIteration || ( exc_type != PyExc_StopIteration && exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopAsyncIteration))))) {
                PyErr_Clear();
                break;
              }
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 3336, __pyx_L6_error)
            }
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_response);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_response, __pyx_t_18);
            __Pyx_GIVEREF(__pyx_t_18);
            __pyx_t_18 = 0;

            /* "ws_package/controllers/activity_controller.py":3337
 * 
 *                     async for response in sending_intervals:
 *                         if not response or not isinstance(response, (list, tuple)):             # <<<<<<<<<<<<<<
 *                             logger.info("No interval found %s", response)
 *                             continue
*/
            __pyx_t_33 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_response); if (unlikely((__pyx_t_33 < 0))) __PYX_ERR(0, 3337, __pyx_L6_error)
            __pyx_t_31 = (!__pyx_t_33);
            if (!__pyx_t_31) {
            } else {
              __pyx_t_5 = __pyx_t_31;
              goto __pyx_L138_bool_binop_done;
            }
            __pyx_t_33 = PyList_Check(__pyx_cur_scope->__pyx_v_response); 
            if (!__pyx_t_33) {
            } else {
              __pyx_t_31 = __pyx_t_33;
              goto __pyx_L140_bool_binop_done;
            }
            __pyx_t_33 = PyTuple_Check(__pyx_cur_scope->__pyx_v_response); 
            __pyx_t_31 = __pyx_t_33;
            __pyx_L140_bool_binop_done:;
            __pyx_t_33 = (!__pyx_t_31);
            __pyx_t_5 = __pyx_t_33;
            __pyx_L138_bool_binop_done:;
            if (__pyx_t_5) {

              /* "ws_package/controllers/activity_controller.py":3338
 *                     async for response in sending_intervals:
 *                         if not response or not isinstance(response, (list, tuple)):
 *                             logger.info("No interval found %s", response)             # <<<<<<<<<<<<<<
 *                             continue
 * 
*/
              __pyx_t_17 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3338, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_12);
              __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3338, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_14);
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
              __pyx_t_3 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_14))) {
                __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_14);
                assert(__pyx_t_17);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
                __Pyx_INCREF(__pyx_t_17);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
                __pyx_t_3 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_17, __pyx_mstate_global->__pyx_kp_u_No_interval_found_s, __pyx_cur_scope->__pyx_v_response};
                __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3338, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_18);
              }
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

              /* "ws_package/controllers/activity_controller.py":3339
 *                         if not response or not isinstance(response, (list, tuple)):
 *                             logger.info("No interval found %s", response)
 *                             continue             # <<<<<<<<<<<<<<
 * 
 *                         _response = self.activity_service.push_activity_logs(response[0])
*/
              goto __pyx_L134_continue;

              /* "ws_package/controllers/activity_controller.py":3337
 * 
 *                     async for response in sending_intervals:
 *                         if not response or not isinstance(response, (list, tuple)):             # <<<<<<<<<<<<<<
 *                             logger.info("No interval found %s", response)
 *                             continue
*/
            }

            /* "ws_package/controllers/activity_controller.py":3341
 *                             continue
 * 
 *                         _response = self.activity_service.push_activity_logs(response[0])             # <<<<<<<<<<<<<<
 *                         logger.info("Response: %s", _response)
 * 
*/
            __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3341, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_17);
            __pyx_t_14 = __pyx_t_17;
            __Pyx_INCREF(__pyx_t_14);
            __pyx_t_12 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_response, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_SharedReference); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3341, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_12);
            __pyx_t_3 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_14, __pyx_t_12};
              __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_push_activity_logs, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
              if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3341, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_18);
            }
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v__response);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v__response, __pyx_t_18);
            __Pyx_GIVEREF(__pyx_t_18);
            __pyx_t_18 = 0;

            /* "ws_package/controllers/activity_controller.py":3342
 * 
 *                         _response = self.activity_service.push_activity_logs(response[0])
 *                         logger.info("Response: %s", _response)             # <<<<<<<<<<<<<<
 * 
 *                         # Check if sync failed after sleep event
*/
            __pyx_t_17 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3342, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_12);
            __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3342, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_14);
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            __pyx_t_3 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_14))) {
              __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_14);
              assert(__pyx_t_17);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
              __Pyx_INCREF(__pyx_t_17);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
              __pyx_t_3 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_17, __pyx_mstate_global->__pyx_kp_u_Response_s, __pyx_cur_scope->__pyx_v__response};
              __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3342, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_18);
            }
            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

            /* "ws_package/controllers/activity_controller.py":3345
 * 
 *                         # Check if sync failed after sleep event
 *                         sync_failed = False             # <<<<<<<<<<<<<<
 *                         if _response is None:
 *                             sync_failed = True
*/
            __pyx_cur_scope->__pyx_v_sync_failed = 0;

            /* "ws_package/controllers/activity_controller.py":3346
 *                         # Check if sync failed after sleep event
 *                         sync_failed = False
 *                         if _response is None:             # <<<<<<<<<<<<<<
 *                             sync_failed = True
 *                         elif isinstance(_response, dict):
*/
            __pyx_t_5 = (__pyx_cur_scope->__pyx_v__response == Py_None);
            if (__pyx_t_5) {

              /* "ws_package/controllers/activity_controller.py":3347
 *                         sync_failed = False
 *                         if _response is None:
 *                             sync_failed = True             # <<<<<<<<<<<<<<
 *                         elif isinstance(_response, dict):
 *                             # Check for error responses (not success)
*/
              __pyx_cur_scope->__pyx_v_sync_failed = 1;

              /* "ws_package/controllers/activity_controller.py":3346
 *                         # Check if sync failed after sleep event
 *                         sync_failed = False
 *                         if _response is None:             # <<<<<<<<<<<<<<
 *                             sync_failed = True
 *                         elif isinstance(_response, dict):
*/
              goto __pyx_L142;
            }

            /* "ws_package/controllers/activity_controller.py":3348
 *                         if _response is None:
 *                             sync_failed = True
 *                         elif isinstance(_response, dict):             # <<<<<<<<<<<<<<
 *                             # Check for error responses (not success)
 *                             if _response.get("message") == "Token is Expired":
*/
            __pyx_t_5 = PyDict_Check(__pyx_cur_scope->__pyx_v__response); 
            if (__pyx_t_5) {

              /* "ws_package/controllers/activity_controller.py":3350
 *                         elif isinstance(_response, dict):
 *                             # Check for error responses (not success)
 *                             if _response.get("message") == "Token is Expired":             # <<<<<<<<<<<<<<
 *                                 sync_failed = True
 *                                 self._send_subscription_expired_popup(_response)
*/
              __pyx_t_14 = __pyx_cur_scope->__pyx_v__response;
              __Pyx_INCREF(__pyx_t_14);
              __pyx_t_3 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_14, __pyx_mstate_global->__pyx_n_u_message};
                __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3350, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_18);
              }
              __pyx_t_5 = (__Pyx_PyUnicode_Equals(__pyx_t_18, __pyx_mstate_global->__pyx_kp_u_Token_is_Expired, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 3350, __pyx_L6_error)
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
              if (__pyx_t_5) {

                /* "ws_package/controllers/activity_controller.py":3351
 *                             # Check for error responses (not success)
 *                             if _response.get("message") == "Token is Expired":
 *                                 sync_failed = True             # <<<<<<<<<<<<<<
 *                                 self._send_subscription_expired_popup(_response)
 *                             elif _response.get("planStatus") != "active" or _response.get("isdeleted") == 1 or _response.get("isdeactivated") == 1:
*/
                __pyx_cur_scope->__pyx_v_sync_failed = 1;

                /* "ws_package/controllers/activity_controller.py":3352
 *                             if _response.get("message") == "Token is Expired":
 *                                 sync_failed = True
 *                                 self._send_subscription_expired_popup(_response)             # <<<<<<<<<<<<<<
 *                             elif _response.get("planStatus") != "active" or _response.get("isdeleted") == 1 or _response.get("isdeactivated") == 1:
 *                                 sync_failed = True
*/
                __pyx_t_14 = __pyx_cur_scope->__pyx_v_self;
                __Pyx_INCREF(__pyx_t_14);
                __pyx_t_3 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_14, __pyx_cur_scope->__pyx_v__response};
                  __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_send_subscription_expired_popup, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                  if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3352, __pyx_L6_error)
                  __Pyx_GOTREF(__pyx_t_18);
                }
                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

                /* "ws_package/controllers/activity_controller.py":3350
 *                         elif isinstance(_response, dict):
 *                             # Check for error responses (not success)
 *                             if _response.get("message") == "Token is Expired":             # <<<<<<<<<<<<<<
 *                                 sync_failed = True
 *                                 self._send_subscription_expired_popup(_response)
*/
                goto __pyx_L143;
              }

              /* "ws_package/controllers/activity_controller.py":3353
 *                                 sync_failed = True
 *                                 self._send_subscription_expired_popup(_response)
 *                             elif _response.get("planStatus") != "active" or _response.get("isdeleted") == 1 or _response.get("isdeactivated") == 1:             # <<<<<<<<<<<<<<
 *                                 sync_failed = True
 *                                 self._send_subscription_expired_popup(_response)
*/
              __pyx_t_14 = __pyx_cur_scope->__pyx_v__response;
              __Pyx_INCREF(__pyx_t_14);
              __pyx_t_3 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_14, __pyx_mstate_global->__pyx_n_u_planStatus};
                __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3353, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_18);
              }
              __pyx_t_33 = (__Pyx_PyUnicode_Equals(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_active, Py_NE)); if (unlikely((__pyx_t_33 < 0))) __PYX_ERR(0, 3353, __pyx_L6_error)
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
              if (!__pyx_t_33) {
              } else {
                __pyx_t_5 = __pyx_t_33;
                goto __pyx_L144_bool_binop_done;
              }
              __pyx_t_14 = __pyx_cur_scope->__pyx_v__response;
              __Pyx_INCREF(__pyx_t_14);
              __pyx_t_3 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_14, __pyx_mstate_global->__pyx_n_u_isdeleted};
                __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3353, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_18);
              }
              __pyx_t_33 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_18, __pyx_mstate_global->__pyx_int_1, 1, 0)); if (unlikely((__pyx_t_33 < 0))) __PYX_ERR(0, 3353, __pyx_L6_error)
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
              if (!__pyx_t_33) {
              } else {
                __pyx_t_5 = __pyx_t_33;
                goto __pyx_L144_bool_binop_done;
              }
              __pyx_t_14 = __pyx_cur_scope->__pyx_v__response;
              __Pyx_INCREF(__pyx_t_14);
              __pyx_t_3 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_14, __pyx_mstate_global->__pyx_n_u_isdeactivated};
                __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3353, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_18);
              }
              __pyx_t_33 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_18, __pyx_mstate_global->__pyx_int_1, 1, 0)); if (unlikely((__pyx_t_33 < 0))) __PYX_ERR(0, 3353, __pyx_L6_error)
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
              __pyx_t_5 = __pyx_t_33;
              __pyx_L144_bool_binop_done:;
              if (__pyx_t_5) {

                /* "ws_package/controllers/activity_controller.py":3354
 *                                 self._send_subscription_expired_popup(_response)
 *                             elif _response.get("planStatus") != "active" or _response.get("isdeleted") == 1 or _response.get("isdeactivated") == 1:
 *                                 sync_failed = True             # <<<<<<<<<<<<<<
 *                                 self._send_subscription_expired_popup(_response)
 * 
*/
                __pyx_cur_scope->__pyx_v_sync_failed = 1;

                /* "ws_package/controllers/activity_controller.py":3355
 *                             elif _response.get("planStatus") != "active" or _response.get("isdeleted") == 1 or _response.get("isdeactivated") == 1:
 *                                 sync_failed = True
 *                                 self._send_subscription_expired_popup(_response)             # <<<<<<<<<<<<<<
 * 
 *                         # If sync failed, check if there was a recent sleep event
*/
                __pyx_t_14 = __pyx_cur_scope->__pyx_v_self;
                __Pyx_INCREF(__pyx_t_14);
                __pyx_t_3 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_14, __pyx_cur_scope->__pyx_v__response};
                  __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_send_subscription_expired_popup, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                  if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3355, __pyx_L6_error)
                  __Pyx_GOTREF(__pyx_t_18);
                }
                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

                /* "ws_package/controllers/activity_controller.py":3353
 *                                 sync_failed = True
 *                                 self._send_subscription_expired_popup(_response)
 *                             elif _response.get("planStatus") != "active" or _response.get("isdeleted") == 1 or _response.get("isdeactivated") == 1:             # <<<<<<<<<<<<<<
 *                                 sync_failed = True
 *                                 self._send_subscription_expired_popup(_response)
*/
              }
              __pyx_L143:;

              /* "ws_package/controllers/activity_controller.py":3348
 *                         if _response is None:
 *                             sync_failed = True
 *                         elif isinstance(_response, dict):             # <<<<<<<<<<<<<<
 *                             # Check for error responses (not success)
 *                             if _response.get("message") == "Token is Expired":
*/
            }
            __pyx_L142:;

            /* "ws_package/controllers/activity_controller.py":3358
 * 
 *                         # If sync failed, check if there was a recent sleep event
 *                         if sync_failed:             # <<<<<<<<<<<<<<
 *                             try:
 *                                 wake_detector = get_system_wake_detector()
*/
            if (__pyx_cur_scope->__pyx_v_sync_failed) {

              /* "ws_package/controllers/activity_controller.py":3359
 *                         # If sync failed, check if there was a recent sleep event
 *                         if sync_failed:
 *                             try:             # <<<<<<<<<<<<<<
 *                                 wake_detector = get_system_wake_detector()
 *                                 wake_stats = wake_detector.get_stats()
*/
              {
                __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_10, &__pyx_t_9);
                __Pyx_XGOTREF(__pyx_t_11);
                __Pyx_XGOTREF(__pyx_t_10);
                __Pyx_XGOTREF(__pyx_t_9);
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":3360
 *                         if sync_failed:
 *                             try:
 *                                 wake_detector = get_system_wake_detector()             # <<<<<<<<<<<<<<
 *                                 wake_stats = wake_detector.get_stats()
 *                                 last_wake_time = wake_stats.get('last_wake_time')
*/
                  __pyx_t_14 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_get_system_wake_detector); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3360, __pyx_L148_error)
                  __Pyx_GOTREF(__pyx_t_17);
                  __pyx_t_3 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_17))) {
                    __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_17);
                    assert(__pyx_t_14);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
                    __Pyx_INCREF(__pyx_t_14);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
                    __pyx_t_3 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_14, NULL};
                    __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                    if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3360, __pyx_L148_error)
                    __Pyx_GOTREF(__pyx_t_18);
                  }
                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_wake_detector);
                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_wake_detector, __pyx_t_18);
                  __Pyx_GIVEREF(__pyx_t_18);
                  __pyx_t_18 = 0;

                  /* "ws_package/controllers/activity_controller.py":3361
 *                             try:
 *                                 wake_detector = get_system_wake_detector()
 *                                 wake_stats = wake_detector.get_stats()             # <<<<<<<<<<<<<<
 *                                 last_wake_time = wake_stats.get('last_wake_time')
 * 
*/
                  __pyx_t_17 = __pyx_cur_scope->__pyx_v_wake_detector;
                  __Pyx_INCREF(__pyx_t_17);
                  __pyx_t_3 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_17, NULL};
                    __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_stats, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                    if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3361, __pyx_L148_error)
                    __Pyx_GOTREF(__pyx_t_18);
                  }
                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_wake_stats);
                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_wake_stats, __pyx_t_18);
                  __Pyx_GIVEREF(__pyx_t_18);
                  __pyx_t_18 = 0;

                  /* "ws_package/controllers/activity_controller.py":3362
 *                                 wake_detector = get_system_wake_detector()
 *                                 wake_stats = wake_detector.get_stats()
 *                                 last_wake_time = wake_stats.get('last_wake_time')             # <<<<<<<<<<<<<<
 * 
 *                                 if last_wake_time and isinstance(last_wake_time, datetime.datetime):
*/
                  __pyx_t_17 = __pyx_cur_scope->__pyx_v_wake_stats;
                  __Pyx_INCREF(__pyx_t_17);
                  __pyx_t_3 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_17, __pyx_mstate_global->__pyx_n_u_last_wake_time};
                    __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                    if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3362, __pyx_L148_error)
                    __Pyx_GOTREF(__pyx_t_18);
                  }
                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_last_wake_time);
                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_last_wake_time, __pyx_t_18);
                  __Pyx_GIVEREF(__pyx_t_18);
                  __pyx_t_18 = 0;

                  /* "ws_package/controllers/activity_controller.py":3364
 *                                 last_wake_time = wake_stats.get('last_wake_time')
 * 
 *                                 if last_wake_time and isinstance(last_wake_time, datetime.datetime):             # <<<<<<<<<<<<<<
 *                                     time_since_wake = (datetime.datetime.now() - last_wake_time).total_seconds()
 *                                     # If wake was recent (within last 30 minutes) and sync failed
*/
                  __pyx_t_33 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_wake_time); if (unlikely((__pyx_t_33 < 0))) __PYX_ERR(0, 3364, __pyx_L148_error)
                  if (__pyx_t_33) {
                  } else {
                    __pyx_t_5 = __pyx_t_33;
                    goto __pyx_L157_bool_binop_done;
                  }
                  __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3364, __pyx_L148_error)
                  __Pyx_GOTREF(__pyx_t_18);
                  __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3364, __pyx_L148_error)
                  __Pyx_GOTREF(__pyx_t_17);
                  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                  __pyx_t_33 = PyObject_IsInstance(__pyx_cur_scope->__pyx_v_last_wake_time, __pyx_t_17); if (unlikely(__pyx_t_33 == ((int)-1))) __PYX_ERR(0, 3364, __pyx_L148_error)
                  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                  __pyx_t_5 = __pyx_t_33;
                  __pyx_L157_bool_binop_done:;
                  if (__pyx_t_5) {

                    /* "ws_package/controllers/activity_controller.py":3365
 * 
 *                                 if last_wake_time and isinstance(last_wake_time, datetime.datetime):
 *                                     time_since_wake = (datetime.datetime.now() - last_wake_time).total_seconds()             # <<<<<<<<<<<<<<
 *                                     # If wake was recent (within last 30 minutes) and sync failed
 *                                     if time_since_wake < 1800:  # 30 minutes
*/
                    __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3365, __pyx_L148_error)
                    __Pyx_GOTREF(__pyx_t_13);
                    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3365, __pyx_L148_error)
                    __Pyx_GOTREF(__pyx_t_2);
                    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                    __pyx_t_12 = __pyx_t_2;
                    __Pyx_INCREF(__pyx_t_12);
                    __pyx_t_3 = 0;
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_12, NULL};
                      __pyx_t_14 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                      if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3365, __pyx_L148_error)
                      __Pyx_GOTREF(__pyx_t_14);
                    }
                    __pyx_t_2 = PyNumber_Subtract(__pyx_t_14, __pyx_cur_scope->__pyx_v_last_wake_time); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3365, __pyx_L148_error)
                    __Pyx_GOTREF(__pyx_t_2);
                    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                    __pyx_t_18 = __pyx_t_2;
                    __Pyx_INCREF(__pyx_t_18);
                    __pyx_t_3 = 0;
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_18, NULL};
                      __pyx_t_17 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_total_seconds, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                      if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3365, __pyx_L148_error)
                      __Pyx_GOTREF(__pyx_t_17);
                    }
                    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_time_since_wake);
                    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_time_since_wake, __pyx_t_17);
                    __Pyx_GIVEREF(__pyx_t_17);
                    __pyx_t_17 = 0;

                    /* "ws_package/controllers/activity_controller.py":3367
 *                                     time_since_wake = (datetime.datetime.now() - last_wake_time).total_seconds()
 *                                     # If wake was recent (within last 30 minutes) and sync failed
 *                                     if time_since_wake < 1800:  # 30 minutes             # <<<<<<<<<<<<<<
 *                                         os_type = platform.system()
 *                                         logger.error("***   DATA SYNC FAILED AFTER SYSTEM SLEEP - PLATFORM: %s - WAKE TIME: %s - TIME SINCE WAKE: %s MINUTES - DATA NOT SYNCED TO WEB - THIS MAY CAUSE DATA LOSS   ***", os_type.upper(), last_wake_time.strftime('%Y-%m-%d %H:%M:%S'), time_since_wake/60)
*/
                    __pyx_t_17 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_time_since_wake, __pyx_mstate_global->__pyx_int_1800, Py_LT); __Pyx_XGOTREF(__pyx_t_17); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3367, __pyx_L148_error)
                    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_17); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 3367, __pyx_L148_error)
                    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                    if (__pyx_t_5) {

                      /* "ws_package/controllers/activity_controller.py":3368
 *                                     # If wake was recent (within last 30 minutes) and sync failed
 *                                     if time_since_wake < 1800:  # 30 minutes
 *                                         os_type = platform.system()             # <<<<<<<<<<<<<<
 *                                         logger.error("***   DATA SYNC FAILED AFTER SYSTEM SLEEP - PLATFORM: %s - WAKE TIME: %s - TIME SINCE WAKE: %s MINUTES - DATA NOT SYNCED TO WEB - THIS MAY CAUSE DATA LOSS   ***", os_type.upper(), last_wake_time.strftime('%Y-%m-%d %H:%M:%S'), time_since_wake/60)
 *                             except Exception as e:
*/
                      __pyx_t_2 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3368, __pyx_L148_error)
                      __Pyx_GOTREF(__pyx_t_18);
                      __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_system); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3368, __pyx_L148_error)
                      __Pyx_GOTREF(__pyx_t_14);
                      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                      __pyx_t_3 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_14))) {
                        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_14);
                        assert(__pyx_t_2);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
                        __Pyx_INCREF(__pyx_t_2);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
                        __pyx_t_3 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
                        __pyx_t_17 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                        if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3368, __pyx_L148_error)
                        __Pyx_GOTREF(__pyx_t_17);
                      }
                      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_os_type);
                      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_os_type, __pyx_t_17);
                      __Pyx_GIVEREF(__pyx_t_17);
                      __pyx_t_17 = 0;

                      /* "ws_package/controllers/activity_controller.py":3369
 *                                     if time_since_wake < 1800:  # 30 minutes
 *                                         os_type = platform.system()
 *                                         logger.error("***   DATA SYNC FAILED AFTER SYSTEM SLEEP - PLATFORM: %s - WAKE TIME: %s - TIME SINCE WAKE: %s MINUTES - DATA NOT SYNCED TO WEB - THIS MAY CAUSE DATA LOSS   ***", os_type.upper(), last_wake_time.strftime('%Y-%m-%d %H:%M:%S'), time_since_wake/60)             # <<<<<<<<<<<<<<
 *                             except Exception as e:
 *                                 logger.debug("Could not check wake time for sync failure: %s", e)
*/
                      __pyx_t_14 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3369, __pyx_L148_error)
                      __Pyx_GOTREF(__pyx_t_2);
                      __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3369, __pyx_L148_error)
                      __Pyx_GOTREF(__pyx_t_18);
                      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                      __pyx_t_12 = __pyx_cur_scope->__pyx_v_os_type;
                      __Pyx_INCREF(__pyx_t_12);
                      __pyx_t_3 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_12, NULL};
                        __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_upper, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3369, __pyx_L148_error)
                        __Pyx_GOTREF(__pyx_t_2);
                      }
                      __pyx_t_13 = __pyx_cur_scope->__pyx_v_last_wake_time;
                      __Pyx_INCREF(__pyx_t_13);
                      __pyx_t_3 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Y_m_d_H_M_S};
                        __pyx_t_12 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strftime, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                        if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3369, __pyx_L148_error)
                        __Pyx_GOTREF(__pyx_t_12);
                      }
                      __pyx_t_13 = __Pyx_PyLong_TrueDivideObjC(__pyx_cur_scope->__pyx_v_time_since_wake, __pyx_mstate_global->__pyx_int_60, 60, 0, 0); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3369, __pyx_L148_error)
                      __Pyx_GOTREF(__pyx_t_13);
                      __pyx_t_3 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_18))) {
                        __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_18);
                        assert(__pyx_t_14);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_18);
                        __Pyx_INCREF(__pyx_t_14);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_18, __pyx__function);
                        __pyx_t_3 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[5] = {__pyx_t_14, __pyx_mstate_global->__pyx_kp_u_DATA_SYNC_FAILED_AFTER_SYSTEM_S, __pyx_t_2, __pyx_t_12, __pyx_t_13};
                        __pyx_t_17 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_18, __pyx_callargs+__pyx_t_3, (5-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                        if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3369, __pyx_L148_error)
                        __Pyx_GOTREF(__pyx_t_17);
                      }
                      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

                      /* "ws_package/controllers/activity_controller.py":3367
 *                                     time_since_wake = (datetime.datetime.now() - last_wake_time).total_seconds()
 *                                     # If wake was recent (within last 30 minutes) and sync failed
 *                                     if time_since_wake < 1800:  # 30 minutes             # <<<<<<<<<<<<<<
 *                                         os_type = platform.system()
 *                                         logger.error("***   DATA SYNC FAILED AFTER SYSTEM SLEEP - PLATFORM: %s - WAKE TIME: %s - TIME SINCE WAKE: %s MINUTES - DATA NOT SYNCED TO WEB - THIS MAY CAUSE DATA LOSS   ***", os_type.upper(), last_wake_time.strftime('%Y-%m-%d %H:%M:%S'), time_since_wake/60)
*/
                    }

                    /* "ws_package/controllers/activity_controller.py":3364
 *                                 last_wake_time = wake_stats.get('last_wake_time')
 * 
 *                                 if last_wake_time and isinstance(last_wake_time, datetime.datetime):             # <<<<<<<<<<<<<<
 *                                     time_since_wake = (datetime.datetime.now() - last_wake_time).total_seconds()
 *                                     # If wake was recent (within last 30 minutes) and sync failed
*/
                  }

                  /* "ws_package/controllers/activity_controller.py":3359
 *                         # If sync failed, check if there was a recent sleep event
 *                         if sync_failed:
 *                             try:             # <<<<<<<<<<<<<<
 *                                 wake_detector = get_system_wake_detector()
 *                                 wake_stats = wake_detector.get_stats()
*/
                }
                __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                goto __pyx_L155_try_end;
                __pyx_L148_error:;
                __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;

                /* "ws_package/controllers/activity_controller.py":3370
 *                                         os_type = platform.system()
 *                                         logger.error("***   DATA SYNC FAILED AFTER SYSTEM SLEEP - PLATFORM: %s - WAKE TIME: %s - TIME SINCE WAKE: %s MINUTES - DATA NOT SYNCED TO WEB - THIS MAY CAUSE DATA LOSS   ***", os_type.upper(), last_wake_time.strftime('%Y-%m-%d %H:%M:%S'), time_since_wake/60)
 *                             except Exception as e:             # <<<<<<<<<<<<<<
 *                                 logger.debug("Could not check wake time for sync failure: %s", e)
 *                         if _response and _response.get("message") == "Token is Expired":
*/
                __pyx_t_16 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                if (__pyx_t_16) {
                  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._push_activity_log", __pyx_clineno, __pyx_lineno, __pyx_filename);
                  if (__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_13) < 0) __PYX_ERR(0, 3370, __pyx_L150_except_error)
                  __Pyx_XGOTREF(__pyx_t_17);
                  __Pyx_XGOTREF(__pyx_t_18);
                  __Pyx_XGOTREF(__pyx_t_13);
                  __Pyx_INCREF(__pyx_t_18);
                  __Pyx_GIVEREF(__pyx_t_18);
                  __pyx_cur_scope->__pyx_v_e = __pyx_t_18;
                  /*try:*/ {

                    /* "ws_package/controllers/activity_controller.py":3371
 *                                         logger.error("***   DATA SYNC FAILED AFTER SYSTEM SLEEP - PLATFORM: %s - WAKE TIME: %s - TIME SINCE WAKE: %s MINUTES - DATA NOT SYNCED TO WEB - THIS MAY CAUSE DATA LOSS   ***", os_type.upper(), last_wake_time.strftime('%Y-%m-%d %H:%M:%S'), time_since_wake/60)
 *                             except Exception as e:
 *                                 logger.debug("Could not check wake time for sync failure: %s", e)             # <<<<<<<<<<<<<<
 *                         if _response and _response.get("message") == "Token is Expired":
 *                             logger.info("Token is Expired")
*/
                    __pyx_t_2 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3371, __pyx_L165_error)
                    __Pyx_GOTREF(__pyx_t_14);
                    __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3371, __pyx_L165_error)
                    __Pyx_GOTREF(__pyx_t_20);
                    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                    __pyx_t_3 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_20))) {
                      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_20);
                      assert(__pyx_t_2);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_20);
                      __Pyx_INCREF(__pyx_t_2);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_20, __pyx__function);
                      __pyx_t_3 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Could_not_check_wake_time_for_sy, __pyx_cur_scope->__pyx_v_e};
                      __pyx_t_12 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_20, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                      if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3371, __pyx_L165_error)
                      __Pyx_GOTREF(__pyx_t_12);
                    }
                    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                  }

                  /* "ws_package/controllers/activity_controller.py":3370
 *                                         os_type = platform.system()
 *                                         logger.error("***   DATA SYNC FAILED AFTER SYSTEM SLEEP - PLATFORM: %s - WAKE TIME: %s - TIME SINCE WAKE: %s MINUTES - DATA NOT SYNCED TO WEB - THIS MAY CAUSE DATA LOSS   ***", os_type.upper(), last_wake_time.strftime('%Y-%m-%d %H:%M:%S'), time_since_wake/60)
 *                             except Exception as e:             # <<<<<<<<<<<<<<
 *                                 logger.debug("Could not check wake time for sync failure: %s", e)
 *                         if _response and _response.get("message") == "Token is Expired":
*/
                  /*finally:*/ {
                    /*normal exit:*/{
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                      goto __pyx_L166;
                    }
                    __pyx_L165_error:;
                    /*exception exit:*/{
                      __Pyx_PyThreadState_assign
                      __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0;
                      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                      __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                      __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                       __Pyx_ExceptionSwap(&__pyx_t_27, &__pyx_t_28, &__pyx_t_29);
                      if ( unlikely(__Pyx_GetException(&__pyx_t_24, &__pyx_t_25, &__pyx_t_26) < 0)) __Pyx_ErrFetch(&__pyx_t_24, &__pyx_t_25, &__pyx_t_26);
                      __Pyx_XGOTREF(__pyx_t_24);
                      __Pyx_XGOTREF(__pyx_t_25);
                      __Pyx_XGOTREF(__pyx_t_26);
                      __Pyx_XGOTREF(__pyx_t_27);
                      __Pyx_XGOTREF(__pyx_t_28);
                      __Pyx_XGOTREF(__pyx_t_29);
                      __pyx_t_16 = __pyx_lineno; __pyx_t_22 = __pyx_clineno; __pyx_t_35 = __pyx_filename;
                      {
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                        __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                      }
                      __Pyx_XGIVEREF(__pyx_t_27);
                      __Pyx_XGIVEREF(__pyx_t_28);
                      __Pyx_XGIVEREF(__pyx_t_29);
                      __Pyx_ExceptionReset(__pyx_t_27, __pyx_t_28, __pyx_t_29);
                      __Pyx_XGIVEREF(__pyx_t_24);
                      __Pyx_XGIVEREF(__pyx_t_25);
                      __Pyx_XGIVEREF(__pyx_t_26);
                      __Pyx_ErrRestore(__pyx_t_24, __pyx_t_25, __pyx_t_26);
                      __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0;
                      __pyx_lineno = __pyx_t_16; __pyx_clineno = __pyx_t_22; __pyx_filename = __pyx_t_35;
                      goto __pyx_L150_except_error;
                    }
                    __pyx_L166:;
                  }
                  __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                  __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                  __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                  goto __pyx_L149_exception_handled;
                }
                goto __pyx_L150_except_error;

                /* "ws_package/controllers/activity_controller.py":3359
 *                         # If sync failed, check if there was a recent sleep event
 *                         if sync_failed:
 *                             try:             # <<<<<<<<<<<<<<
 *                                 wake_detector = get_system_wake_detector()
 *                                 wake_stats = wake_detector.get_stats()
*/
                __pyx_L150_except_error:;
                __Pyx_XGIVEREF(__pyx_t_11);
                __Pyx_XGIVEREF(__pyx_t_10);
                __Pyx_XGIVEREF(__pyx_t_9);
                __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_10, __pyx_t_9);
                goto __pyx_L6_error;
                __pyx_L149_exception_handled:;
                __Pyx_XGIVEREF(__pyx_t_11);
                __Pyx_XGIVEREF(__pyx_t_10);
                __Pyx_XGIVEREF(__pyx_t_9);
                __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_10, __pyx_t_9);
                __pyx_L155_try_end:;
              }

              /* "ws_package/controllers/activity_controller.py":3358
 * 
 *                         # If sync failed, check if there was a recent sleep event
 *                         if sync_failed:             # <<<<<<<<<<<<<<
 *                             try:
 *                                 wake_detector = get_system_wake_detector()
*/
            }

            /* "ws_package/controllers/activity_controller.py":3372
 *                             except Exception as e:
 *                                 logger.debug("Could not check wake time for sync failure: %s", e)
 *                         if _response and _response.get("message") == "Token is Expired":             # <<<<<<<<<<<<<<
 *                             logger.info("Token is Expired")
 *                             self.status = False
*/
            __pyx_t_33 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v__response); if (unlikely((__pyx_t_33 < 0))) __PYX_ERR(0, 3372, __pyx_L6_error)
            if (__pyx_t_33) {
            } else {
              __pyx_t_5 = __pyx_t_33;
              goto __pyx_L172_bool_binop_done;
            }
            __pyx_t_18 = __pyx_cur_scope->__pyx_v__response;
            __Pyx_INCREF(__pyx_t_18);
            __pyx_t_3 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_18, __pyx_mstate_global->__pyx_n_u_message};
              __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
              if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3372, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_13);
            }
            __pyx_t_33 = (__Pyx_PyUnicode_Equals(__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Token_is_Expired, Py_EQ)); if (unlikely((__pyx_t_33 < 0))) __PYX_ERR(0, 3372, __pyx_L6_error)
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __pyx_t_5 = __pyx_t_33;
            __pyx_L172_bool_binop_done:;
            if (__pyx_t_5) {

              /* "ws_package/controllers/activity_controller.py":3373
 *                                 logger.debug("Could not check wake time for sync failure: %s", e)
 *                         if _response and _response.get("message") == "Token is Expired":
 *                             logger.info("Token is Expired")             # <<<<<<<<<<<<<<
 *                             self.status = False
 *                             await precise_sleep(14400, stop_event) # main sleep for thread 3
*/
              __pyx_t_18 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3373, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_17);
              __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3373, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
              __pyx_t_3 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_12))) {
                __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_12);
                assert(__pyx_t_18);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
                __Pyx_INCREF(__pyx_t_18);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
                __pyx_t_3 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_18, __pyx_mstate_global->__pyx_kp_u_Token_is_Expired};
                __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3373, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_13);
              }
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

              /* "ws_package/controllers/activity_controller.py":3374
 *                         if _response and _response.get("message") == "Token is Expired":
 *                             logger.info("Token is Expired")
 *                             self.status = False             # <<<<<<<<<<<<<<
 *                             await precise_sleep(14400, stop_event) # main sleep for thread 3
 * 
*/
              if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status, Py_False) < (0)) __PYX_ERR(0, 3374, __pyx_L6_error)

              /* "ws_package/controllers/activity_controller.py":3375
 *                             logger.info("Token is Expired")
 *                             self.status = False
 *                             await precise_sleep(14400, stop_event) # main sleep for thread 3             # <<<<<<<<<<<<<<
 * 
 *                         elif _response and (_response.get("planStatus") != "active" or _response.get("isdeleted") == 1 or _response.get("isdeactivated") == 1):
*/
              __pyx_t_12 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_precise_sleep); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3375, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_18);
              __pyx_t_3 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_18))) {
                __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_18);
                assert(__pyx_t_12);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_18);
                __Pyx_INCREF(__pyx_t_12);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_18, __pyx__function);
                __pyx_t_3 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_12, __pyx_mstate_global->__pyx_int_14400, __pyx_cur_scope->__pyx_v_stop_event};
                __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_18, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3375, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_13);
              }
              __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_13, &__pyx_r);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              if (likely(__pyx_t_15 == PYGEN_NEXT)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_XGIVEREF(__pyx_t_1);
                __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                __Pyx_XGIVEREF(__pyx_t_6);
                __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
                __Pyx_XGIVEREF(__pyx_t_7);
                __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
                __Pyx_XGIVEREF(__pyx_t_8);
                __pyx_cur_scope->__pyx_t_3 = __pyx_t_8;
                __Pyx_XGIVEREF(__pyx_r);
                __Pyx_RefNannyFinishContext();
                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                /* return from generator, awaiting value */
                __pyx_generator->resume_label = 17;
                return __pyx_r;
                __pyx_L174_resume_from_await:;
                __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                __pyx_cur_scope->__pyx_t_0 = 0;
                __Pyx_XGOTREF(__pyx_t_1);
                __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
                __pyx_cur_scope->__pyx_t_1 = 0;
                __Pyx_XGOTREF(__pyx_t_6);
                __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
                __pyx_cur_scope->__pyx_t_2 = 0;
                __Pyx_XGOTREF(__pyx_t_7);
                __pyx_t_8 = __pyx_cur_scope->__pyx_t_3;
                __pyx_cur_scope->__pyx_t_3 = 0;
                __Pyx_XGOTREF(__pyx_t_8);
                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3375, __pyx_L6_error)
              } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_DECREF(__pyx_r); __pyx_r = 0;
              } else {
                __Pyx_XGOTREF(__pyx_r);
                __PYX_ERR(0, 3375, __pyx_L6_error)
              }

              /* "ws_package/controllers/activity_controller.py":3372
 *                             except Exception as e:
 *                                 logger.debug("Could not check wake time for sync failure: %s", e)
 *                         if _response and _response.get("message") == "Token is Expired":             # <<<<<<<<<<<<<<
 *                             logger.info("Token is Expired")
 *                             self.status = False
*/
              goto __pyx_L171;
            }

            /* "ws_package/controllers/activity_controller.py":3377
 *                             await precise_sleep(14400, stop_event) # main sleep for thread 3
 * 
 *                         elif _response and (_response.get("planStatus") != "active" or _response.get("isdeleted") == 1 or _response.get("isdeactivated") == 1):             # <<<<<<<<<<<<<<
 *                             logger.error("Either plan status Deactivated use deleted or user deactivated")
 *                             self.status = False
*/
            __pyx_t_33 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v__response); if (unlikely((__pyx_t_33 < 0))) __PYX_ERR(0, 3377, __pyx_L6_error)
            if (__pyx_t_33) {
            } else {
              __pyx_t_5 = __pyx_t_33;
              goto __pyx_L175_bool_binop_done;
            }
            __pyx_t_18 = __pyx_cur_scope->__pyx_v__response;
            __Pyx_INCREF(__pyx_t_18);
            __pyx_t_3 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_18, __pyx_mstate_global->__pyx_n_u_planStatus};
              __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
              if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3377, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_13);
            }
            __pyx_t_33 = (__Pyx_PyUnicode_Equals(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_active, Py_NE)); if (unlikely((__pyx_t_33 < 0))) __PYX_ERR(0, 3377, __pyx_L6_error)
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            if (!__pyx_t_33) {
            } else {
              __pyx_t_5 = __pyx_t_33;
              goto __pyx_L175_bool_binop_done;
            }
            __pyx_t_18 = __pyx_cur_scope->__pyx_v__response;
            __Pyx_INCREF(__pyx_t_18);
            __pyx_t_3 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_18, __pyx_mstate_global->__pyx_n_u_isdeleted};
              __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
              if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3377, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_13);
            }
            __pyx_t_33 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_13, __pyx_mstate_global->__pyx_int_1, 1, 0)); if (unlikely((__pyx_t_33 < 0))) __PYX_ERR(0, 3377, __pyx_L6_error)
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            if (!__pyx_t_33) {
            } else {
              __pyx_t_5 = __pyx_t_33;
              goto __pyx_L175_bool_binop_done;
            }
            __pyx_t_18 = __pyx_cur_scope->__pyx_v__response;
            __Pyx_INCREF(__pyx_t_18);
            __pyx_t_3 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_18, __pyx_mstate_global->__pyx_n_u_isdeactivated};
              __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
              if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3377, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_13);
            }
            __pyx_t_33 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_13, __pyx_mstate_global->__pyx_int_1, 1, 0)); if (unlikely((__pyx_t_33 < 0))) __PYX_ERR(0, 3377, __pyx_L6_error)
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __pyx_t_5 = __pyx_t_33;
            __pyx_L175_bool_binop_done:;
            if (__pyx_t_5) {

              /* "ws_package/controllers/activity_controller.py":3378
 * 
 *                         elif _response and (_response.get("planStatus") != "active" or _response.get("isdeleted") == 1 or _response.get("isdeactivated") == 1):
 *                             logger.error("Either plan status Deactivated use deleted or user deactivated")             # <<<<<<<<<<<<<<
 *                             self.status = False
 *                             await precise_sleep(14400, stop_event)  # main sleep for thread 3
*/
              __pyx_t_18 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3378, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_12);
              __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3378, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_17);
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
              __pyx_t_3 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_17))) {
                __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_17);
                assert(__pyx_t_18);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
                __Pyx_INCREF(__pyx_t_18);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
                __pyx_t_3 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_18, __pyx_mstate_global->__pyx_kp_u_Either_plan_status_Deactivated_u};
                __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3378, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_13);
              }
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

              /* "ws_package/controllers/activity_controller.py":3379
 *                         elif _response and (_response.get("planStatus") != "active" or _response.get("isdeleted") == 1 or _response.get("isdeactivated") == 1):
 *                             logger.error("Either plan status Deactivated use deleted or user deactivated")
 *                             self.status = False             # <<<<<<<<<<<<<<
 *                             await precise_sleep(14400, stop_event)  # main sleep for thread 3
 * 
*/
              if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status, Py_False) < (0)) __PYX_ERR(0, 3379, __pyx_L6_error)

              /* "ws_package/controllers/activity_controller.py":3380
 *                             logger.error("Either plan status Deactivated use deleted or user deactivated")
 *                             self.status = False
 *                             await precise_sleep(14400, stop_event)  # main sleep for thread 3             # <<<<<<<<<<<<<<
 * 
 *                         elif _response and _response["planStatus"] == "active":
*/
              __pyx_t_17 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_precise_sleep); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3380, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_18);
              __pyx_t_3 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_18))) {
                __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_18);
                assert(__pyx_t_17);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_18);
                __Pyx_INCREF(__pyx_t_17);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_18, __pyx__function);
                __pyx_t_3 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_17, __pyx_mstate_global->__pyx_int_14400, __pyx_cur_scope->__pyx_v_stop_event};
                __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_18, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3380, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_13);
              }
              __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_13, &__pyx_r);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              if (likely(__pyx_t_15 == PYGEN_NEXT)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_XGIVEREF(__pyx_t_1);
                __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                __Pyx_XGIVEREF(__pyx_t_6);
                __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
                __Pyx_XGIVEREF(__pyx_t_7);
                __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
                __Pyx_XGIVEREF(__pyx_t_8);
                __pyx_cur_scope->__pyx_t_3 = __pyx_t_8;
                __Pyx_XGIVEREF(__pyx_r);
                __Pyx_RefNannyFinishContext();
                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                /* return from generator, awaiting value */
                __pyx_generator->resume_label = 18;
                return __pyx_r;
                __pyx_L179_resume_from_await:;
                __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                __pyx_cur_scope->__pyx_t_0 = 0;
                __Pyx_XGOTREF(__pyx_t_1);
                __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
                __pyx_cur_scope->__pyx_t_1 = 0;
                __Pyx_XGOTREF(__pyx_t_6);
                __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
                __pyx_cur_scope->__pyx_t_2 = 0;
                __Pyx_XGOTREF(__pyx_t_7);
                __pyx_t_8 = __pyx_cur_scope->__pyx_t_3;
                __pyx_cur_scope->__pyx_t_3 = 0;
                __Pyx_XGOTREF(__pyx_t_8);
                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3380, __pyx_L6_error)
              } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_DECREF(__pyx_r); __pyx_r = 0;
              } else {
                __Pyx_XGOTREF(__pyx_r);
                __PYX_ERR(0, 3380, __pyx_L6_error)
              }

              /* "ws_package/controllers/activity_controller.py":3377
 *                             await precise_sleep(14400, stop_event) # main sleep for thread 3
 * 
 *                         elif _response and (_response.get("planStatus") != "active" or _response.get("isdeleted") == 1 or _response.get("isdeactivated") == 1):             # <<<<<<<<<<<<<<
 *                             logger.error("Either plan status Deactivated use deleted or user deactivated")
 *                             self.status = False
*/
              goto __pyx_L171;
            }

            /* "ws_package/controllers/activity_controller.py":3382
 *                             await precise_sleep(14400, stop_event)  # main sleep for thread 3
 * 
 *                         elif _response and _response["planStatus"] == "active":             # <<<<<<<<<<<<<<
 *                             for interval in response[1]:
 *                                 await self.activity_service.update_activity_interval(interval)  # Pass individual interval
*/
            __pyx_t_33 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v__response); if (unlikely((__pyx_t_33 < 0))) __PYX_ERR(0, 3382, __pyx_L6_error)
            if (__pyx_t_33) {
            } else {
              __pyx_t_5 = __pyx_t_33;
              goto __pyx_L180_bool_binop_done;
            }
            __pyx_t_13 = __Pyx_PyObject_Dict_GetItem(__pyx_cur_scope->__pyx_v__response, __pyx_mstate_global->__pyx_n_u_planStatus); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3382, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_13);
            __pyx_t_33 = (__Pyx_PyUnicode_Equals(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_active, Py_EQ)); if (unlikely((__pyx_t_33 < 0))) __PYX_ERR(0, 3382, __pyx_L6_error)
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __pyx_t_5 = __pyx_t_33;
            __pyx_L180_bool_binop_done:;
            if (__pyx_t_5) {

              /* "ws_package/controllers/activity_controller.py":3383
 * 
 *                         elif _response and _response["planStatus"] == "active":
 *                             for interval in response[1]:             # <<<<<<<<<<<<<<
 *                                 await self.activity_service.update_activity_interval(interval)  # Pass individual interval
 *                             for interval_payload in response[0]:
*/
              __pyx_t_13 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_response, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_SharedReference); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3383, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_13);
              if (likely(PyList_CheckExact(__pyx_t_13)) || PyTuple_CheckExact(__pyx_t_13)) {
                __pyx_t_18 = __pyx_t_13; __Pyx_INCREF(__pyx_t_18);
                __pyx_t_34 = 0;
                __pyx_t_32 = NULL;
              } else {
                __pyx_t_34 = -1; __pyx_t_18 = PyObject_GetIter(__pyx_t_13); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3383, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_18);
                __pyx_t_32 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_18); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 3383, __pyx_L6_error)
              }
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              for (;;) {
                if (likely(!__pyx_t_32)) {
                  if (likely(PyList_CheckExact(__pyx_t_18))) {
                    {
                      Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_18);
                      #if !CYTHON_ASSUME_SAFE_SIZE
                      if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3383, __pyx_L6_error)
                      #endif
                      if (__pyx_t_34 >= __pyx_temp) break;
                    }
                    __pyx_t_13 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_18, __pyx_t_34, __Pyx_ReferenceSharing_OwnStrongReference);
                    ++__pyx_t_34;
                  } else {
                    {
                      Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_18);
                      #if !CYTHON_ASSUME_SAFE_SIZE
                      if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3383, __pyx_L6_error)
                      #endif
                      if (__pyx_t_34 >= __pyx_temp) break;
                    }
                    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                    __pyx_t_13 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_18, __pyx_t_34));
                    #else
                    __pyx_t_13 = __Pyx_PySequence_ITEM(__pyx_t_18, __pyx_t_34);
                    #endif
                    ++__pyx_t_34;
                  }
                  if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3383, __pyx_L6_error)
                } else {
                  __pyx_t_13 = __pyx_t_32(__pyx_t_18);
                  if (unlikely(!__pyx_t_13)) {
                    PyObject* exc_type = PyErr_Occurred();
                    if (exc_type) {
                      if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 3383, __pyx_L6_error)
                      PyErr_Clear();
                    }
                    break;
                  }
                }
                __Pyx_GOTREF(__pyx_t_13);
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_13);
                __Pyx_GIVEREF(__pyx_t_13);
                __pyx_t_13 = 0;

                /* "ws_package/controllers/activity_controller.py":3384
 *                         elif _response and _response["planStatus"] == "active":
 *                             for interval in response[1]:
 *                                 await self.activity_service.update_activity_interval(interval)  # Pass individual interval             # <<<<<<<<<<<<<<
 *                             for interval_payload in response[0]:
 *                                 await precise_sleep(2, stop_event)#For updating properly is_uploaded = 1 in db
*/
                __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3384, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_12);
                __pyx_t_17 = __pyx_t_12;
                __Pyx_INCREF(__pyx_t_17);
                __pyx_t_3 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_17, __pyx_cur_scope->__pyx_v_interval};
                  __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_update_activity_interval, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                  if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3384, __pyx_L6_error)
                  __Pyx_GOTREF(__pyx_t_13);
                }
                __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_13, &__pyx_r);
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                if (likely(__pyx_t_15 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_1);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                  __Pyx_XGIVEREF(__pyx_t_6);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
                  __Pyx_XGIVEREF(__pyx_t_7);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
                  __Pyx_XGIVEREF(__pyx_t_8);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_8;
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_18;
                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_32;
                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_34;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 19;
                  return __pyx_r;
                  __pyx_L184_resume_from_await:;
                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_1);
                  __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_6);
                  __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_7);
                  __pyx_t_8 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_8);
                  __pyx_t_18 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_18);
                  __pyx_t_32 = __pyx_cur_scope->__pyx_t_6;
                  __pyx_t_34 = __pyx_cur_scope->__pyx_t_7;
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3384, __pyx_L6_error)
                } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 3384, __pyx_L6_error)
                }

                /* "ws_package/controllers/activity_controller.py":3383
 * 
 *                         elif _response and _response["planStatus"] == "active":
 *                             for interval in response[1]:             # <<<<<<<<<<<<<<
 *                                 await self.activity_service.update_activity_interval(interval)  # Pass individual interval
 *                             for interval_payload in response[0]:
*/
              }
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

              /* "ws_package/controllers/activity_controller.py":3385
 *                             for interval in response[1]:
 *                                 await self.activity_service.update_activity_interval(interval)  # Pass individual interval
 *                             for interval_payload in response[0]:             # <<<<<<<<<<<<<<
 *                                 await precise_sleep(2, stop_event)#For updating properly is_uploaded = 1 in db
 *                                 for interval in interval_payload.get('intervals', []):  # Ensure 'intervals' exists
*/
              __pyx_t_18 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_response, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_SharedReference); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3385, __pyx_L6_error)
              __Pyx_GOTREF(__pyx_t_18);
              if (likely(PyList_CheckExact(__pyx_t_18)) || PyTuple_CheckExact(__pyx_t_18)) {
                __pyx_t_13 = __pyx_t_18; __Pyx_INCREF(__pyx_t_13);
                __pyx_t_34 = 0;
                __pyx_t_32 = NULL;
              } else {
                __pyx_t_34 = -1; __pyx_t_13 = PyObject_GetIter(__pyx_t_18); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3385, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_13);
                __pyx_t_32 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_13); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 3385, __pyx_L6_error)
              }
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
              for (;;) {
                if (likely(!__pyx_t_32)) {
                  if (likely(PyList_CheckExact(__pyx_t_13))) {
                    {
                      Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_13);
                      #if !CYTHON_ASSUME_SAFE_SIZE
                      if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3385, __pyx_L6_error)
                      #endif
                      if (__pyx_t_34 >= __pyx_temp) break;
                    }
                    __pyx_t_18 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_13, __pyx_t_34, __Pyx_ReferenceSharing_OwnStrongReference);
                    ++__pyx_t_34;
                  } else {
                    {
                      Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_13);
                      #if !CYTHON_ASSUME_SAFE_SIZE
                      if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3385, __pyx_L6_error)
                      #endif
                      if (__pyx_t_34 >= __pyx_temp) break;
                    }
                    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                    __pyx_t_18 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_13, __pyx_t_34));
                    #else
                    __pyx_t_18 = __Pyx_PySequence_ITEM(__pyx_t_13, __pyx_t_34);
                    #endif
                    ++__pyx_t_34;
                  }
                  if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3385, __pyx_L6_error)
                } else {
                  __pyx_t_18 = __pyx_t_32(__pyx_t_13);
                  if (unlikely(!__pyx_t_18)) {
                    PyObject* exc_type = PyErr_Occurred();
                    if (exc_type) {
                      if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 3385, __pyx_L6_error)
                      PyErr_Clear();
                    }
                    break;
                  }
                }
                __Pyx_GOTREF(__pyx_t_18);
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval_payload);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval_payload, __pyx_t_18);
                __Pyx_GIVEREF(__pyx_t_18);
                __pyx_t_18 = 0;

                /* "ws_package/controllers/activity_controller.py":3386
 *                                 await self.activity_service.update_activity_interval(interval)  # Pass individual interval
 *                             for interval_payload in response[0]:
 *                                 await precise_sleep(2, stop_event)#For updating properly is_uploaded = 1 in db             # <<<<<<<<<<<<<<
 *                                 for interval in interval_payload.get('intervals', []):  # Ensure 'intervals' exists
 *                                     screen_url = interval.get("screenUrl")  # Access the screenUrl from each interval payload
*/
                __pyx_t_12 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_precise_sleep); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3386, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_17);
                __pyx_t_3 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_17))) {
                  __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_17);
                  assert(__pyx_t_12);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
                  __Pyx_INCREF(__pyx_t_12);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
                  __pyx_t_3 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_12, __pyx_mstate_global->__pyx_int_2, __pyx_cur_scope->__pyx_v_stop_event};
                  __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                  if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3386, __pyx_L6_error)
                  __Pyx_GOTREF(__pyx_t_18);
                }
                __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_18, &__pyx_r);
                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                if (likely(__pyx_t_15 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_1);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                  __Pyx_XGIVEREF(__pyx_t_6);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
                  __Pyx_XGIVEREF(__pyx_t_7);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
                  __Pyx_XGIVEREF(__pyx_t_8);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_8;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_32;
                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_34;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 20;
                  return __pyx_r;
                  __pyx_L188_resume_from_await:;
                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_1);
                  __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_6);
                  __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_7);
                  __pyx_t_8 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_8);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  __pyx_t_32 = __pyx_cur_scope->__pyx_t_6;
                  __pyx_t_34 = __pyx_cur_scope->__pyx_t_7;
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3386, __pyx_L6_error)
                } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 3386, __pyx_L6_error)
                }

                /* "ws_package/controllers/activity_controller.py":3387
 *                             for interval_payload in response[0]:
 *                                 await precise_sleep(2, stop_event)#For updating properly is_uploaded = 1 in db
 *                                 for interval in interval_payload.get('intervals', []):  # Ensure 'intervals' exists             # <<<<<<<<<<<<<<
 *                                     screen_url = interval.get("screenUrl")  # Access the screenUrl from each interval payload
 *                                     await self.screenshot_controller.update_screenshots(screen_url, self.last_count+1)
*/
                __pyx_t_17 = __pyx_cur_scope->__pyx_v_interval_payload;
                __Pyx_INCREF(__pyx_t_17);
                __pyx_t_12 = PyList_New(0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3387, __pyx_L6_error)
                __Pyx_GOTREF(__pyx_t_12);
                __pyx_t_3 = 0;
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_17, __pyx_mstate_global->__pyx_n_u_intervals, __pyx_t_12};
                  __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                  if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3387, __pyx_L6_error)
                  __Pyx_GOTREF(__pyx_t_18);
                }
                if (likely(PyList_CheckExact(__pyx_t_18)) || PyTuple_CheckExact(__pyx_t_18)) {
                  __pyx_t_12 = __pyx_t_18; __Pyx_INCREF(__pyx_t_12);
                  __pyx_t_19 = 0;
                  __pyx_t_36 = NULL;
                } else {
                  __pyx_t_19 = -1; __pyx_t_12 = PyObject_GetIter(__pyx_t_18); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3387, __pyx_L6_error)
                  __Pyx_GOTREF(__pyx_t_12);
                  __pyx_t_36 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_12); if (unlikely(!__pyx_t_36)) __PYX_ERR(0, 3387, __pyx_L6_error)
                }
                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                for (;;) {
                  if (likely(!__pyx_t_36)) {
                    if (likely(PyList_CheckExact(__pyx_t_12))) {
                      {
                        Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_12);
                        #if !CYTHON_ASSUME_SAFE_SIZE
                        if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3387, __pyx_L6_error)
                        #endif
                        if (__pyx_t_19 >= __pyx_temp) break;
                      }
                      __pyx_t_18 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_12, __pyx_t_19, __Pyx_ReferenceSharing_OwnStrongReference);
                      ++__pyx_t_19;
                    } else {
                      {
                        Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_12);
                        #if !CYTHON_ASSUME_SAFE_SIZE
                        if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3387, __pyx_L6_error)
                        #endif
                        if (__pyx_t_19 >= __pyx_temp) break;
                      }
                      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                      __pyx_t_18 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_12, __pyx_t_19));
                      #else
                      __pyx_t_18 = __Pyx_PySequence_ITEM(__pyx_t_12, __pyx_t_19);
                      #endif
                      ++__pyx_t_19;
                    }
                    if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3387, __pyx_L6_error)
                  } else {
                    __pyx_t_18 = __pyx_t_36(__pyx_t_12);
                    if (unlikely(!__pyx_t_18)) {
                      PyObject* exc_type = PyErr_Occurred();
                      if (exc_type) {
                        if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 3387, __pyx_L6_error)
                        PyErr_Clear();
                      }
                      break;
                    }
                  }
                  __Pyx_GOTREF(__pyx_t_18);
                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_18);
                  __Pyx_GIVEREF(__pyx_t_18);
                  __pyx_t_18 = 0;

                  /* "ws_package/controllers/activity_controller.py":3388
 *                                 await precise_sleep(2, stop_event)#For updating properly is_uploaded = 1 in db
 *                                 for interval in interval_payload.get('intervals', []):  # Ensure 'intervals' exists
 *                                     screen_url = interval.get("screenUrl")  # Access the screenUrl from each interval payload             # <<<<<<<<<<<<<<
 *                                     await self.screenshot_controller.update_screenshots(screen_url, self.last_count+1)
 *                 else:
*/
                  __pyx_t_17 = __pyx_cur_scope->__pyx_v_interval;
                  __Pyx_INCREF(__pyx_t_17);
                  __pyx_t_3 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_17, __pyx_mstate_global->__pyx_n_u_screenUrl};
                    __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                    if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3388, __pyx_L6_error)
                    __Pyx_GOTREF(__pyx_t_18);
                  }
                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_screen_url);
                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_screen_url, __pyx_t_18);
                  __Pyx_GIVEREF(__pyx_t_18);
                  __pyx_t_18 = 0;

                  /* "ws_package/controllers/activity_controller.py":3389
 *                                 for interval in interval_payload.get('intervals', []):  # Ensure 'intervals' exists
 *                                     screen_url = interval.get("screenUrl")  # Access the screenUrl from each interval payload
 *                                     await self.screenshot_controller.update_screenshots(screen_url, self.last_count+1)             # <<<<<<<<<<<<<<
 *                 else:
 *                     logger.info("Not in Tracking days")
*/
                  __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3389, __pyx_L6_error)
                  __Pyx_GOTREF(__pyx_t_20);
                  __pyx_t_17 = __pyx_t_20;
                  __Pyx_INCREF(__pyx_t_17);
                  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3389, __pyx_L6_error)
                  __Pyx_GOTREF(__pyx_t_2);
                  __pyx_t_14 = __Pyx_PyLong_AddObjC(__pyx_t_2, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3389, __pyx_L6_error)
                  __Pyx_GOTREF(__pyx_t_14);
                  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                  __pyx_t_3 = 0;
                  {
                    PyObject *__pyx_callargs[3] = {__pyx_t_17, __pyx_cur_scope->__pyx_v_screen_url, __pyx_t_14};
                    __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_update_screenshots, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                    if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3389, __pyx_L6_error)
                    __Pyx_GOTREF(__pyx_t_18);
                  }
                  __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_18, &__pyx_r);
                  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                  if (likely(__pyx_t_15 == PYGEN_NEXT)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_XGIVEREF(__pyx_t_1);
                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                    __Pyx_XGIVEREF(__pyx_t_6);
                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
                    __Pyx_XGIVEREF(__pyx_t_7);
                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
                    __Pyx_XGIVEREF(__pyx_t_8);
                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_8;
                    __Pyx_XGIVEREF(__pyx_t_12);
                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                    __Pyx_XGIVEREF(__pyx_t_13);
                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                    __pyx_cur_scope->__pyx_t_7 = __pyx_t_19;
                    __pyx_cur_scope->__pyx_t_6 = __pyx_t_32;
                    __pyx_cur_scope->__pyx_t_8 = __pyx_t_34;
                    __pyx_cur_scope->__pyx_t_9 = __pyx_t_36;
                    __Pyx_XGIVEREF(__pyx_r);
                    __Pyx_RefNannyFinishContext();
                    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                    /* return from generator, awaiting value */
                    __pyx_generator->resume_label = 21;
                    return __pyx_r;
                    __pyx_L191_resume_from_await:;
                    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                    __pyx_cur_scope->__pyx_t_0 = 0;
                    __Pyx_XGOTREF(__pyx_t_1);
                    __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
                    __pyx_cur_scope->__pyx_t_1 = 0;
                    __Pyx_XGOTREF(__pyx_t_6);
                    __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
                    __pyx_cur_scope->__pyx_t_2 = 0;
                    __Pyx_XGOTREF(__pyx_t_7);
                    __pyx_t_8 = __pyx_cur_scope->__pyx_t_3;
                    __pyx_cur_scope->__pyx_t_3 = 0;
                    __Pyx_XGOTREF(__pyx_t_8);
                    __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                    __pyx_cur_scope->__pyx_t_4 = 0;
                    __Pyx_XGOTREF(__pyx_t_12);
                    __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                    __pyx_cur_scope->__pyx_t_5 = 0;
                    __Pyx_XGOTREF(__pyx_t_13);
                    __pyx_t_19 = __pyx_cur_scope->__pyx_t_7;
                    __pyx_t_32 = __pyx_cur_scope->__pyx_t_6;
                    __pyx_t_34 = __pyx_cur_scope->__pyx_t_8;
                    __pyx_t_36 = __pyx_cur_scope->__pyx_t_9;
                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3389, __pyx_L6_error)
                  } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                  } else {
                    __Pyx_XGOTREF(__pyx_r);
                    __PYX_ERR(0, 3389, __pyx_L6_error)
                  }

                  /* "ws_package/controllers/activity_controller.py":3387
 *                             for interval_payload in response[0]:
 *                                 await precise_sleep(2, stop_event)#For updating properly is_uploaded = 1 in db
 *                                 for interval in interval_payload.get('intervals', []):  # Ensure 'intervals' exists             # <<<<<<<<<<<<<<
 *                                     screen_url = interval.get("screenUrl")  # Access the screenUrl from each interval payload
 *                                     await self.screenshot_controller.update_screenshots(screen_url, self.last_count+1)
*/
                }
                __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

                /* "ws_package/controllers/activity_controller.py":3385
 *                             for interval in response[1]:
 *                                 await self.activity_service.update_activity_interval(interval)  # Pass individual interval
 *                             for interval_payload in response[0]:             # <<<<<<<<<<<<<<
 *                                 await precise_sleep(2, stop_event)#For updating properly is_uploaded = 1 in db
 *                                 for interval in interval_payload.get('intervals', []):  # Ensure 'intervals' exists
*/
              }
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

              /* "ws_package/controllers/activity_controller.py":3382
 *                             await precise_sleep(14400, stop_event)  # main sleep for thread 3
 * 
 *                         elif _response and _response["planStatus"] == "active":             # <<<<<<<<<<<<<<
 *                             for interval in response[1]:
 *                                 await self.activity_service.update_activity_interval(interval)  # Pass individual interval
*/
            }
            __pyx_L171:;

            /* "ws_package/controllers/activity_controller.py":3336
 *                     }
 * 
 *                     async for response in sending_intervals:             # <<<<<<<<<<<<<<
 *                         if not response or not isinstance(response, (list, tuple)):
 *                             logger.info("No interval found %s", response)
*/
            __pyx_L134_continue:;
          }
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

          /* "ws_package/controllers/activity_controller.py":3198
 * 
 *                 logger.info("Today is %s and tracking days are %s", self.get_today_weekday(), self.no_of_days)
 *                 if self.no_of_days is not None and self.get_today_weekday() in self.no_of_days:             # <<<<<<<<<<<<<<
 * 
 *                     self.activity_service.application_activity_log_url = config('application_activity_log_url', 'Application')
*/
          goto __pyx_L79;
        }

        /* "ws_package/controllers/activity_controller.py":3391
 *                                     await self.screenshot_controller.update_screenshots(screen_url, self.last_count+1)
 *                 else:
 *                     logger.info("Not in Tracking days")             # <<<<<<<<<<<<<<
 *                 logger.info("Push thread")
 *                 # self.log_system_resources()
*/
        /*else*/ {
          __pyx_t_13 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3391, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_12);
          __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3391, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_18);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __pyx_t_3 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_18))) {
            __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_18);
            assert(__pyx_t_13);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_18);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_18, __pyx__function);
            __pyx_t_3 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Not_in_Tracking_days};
            __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_18, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3391, __pyx_L6_error)
            __Pyx_GOTREF(__pyx_t_1);
          }
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        }
        __pyx_L79:;

        /* "ws_package/controllers/activity_controller.py":3392
 *                 else:
 *                     logger.info("Not in Tracking days")
 *                 logger.info("Push thread")             # <<<<<<<<<<<<<<
 *                 # self.log_system_resources()
 *                 await precise_sleep(self.interval, stop_event)
*/
        __pyx_t_18 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3392, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3392, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_3 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_12))) {
          __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_12);
          assert(__pyx_t_18);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_18);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
          __pyx_t_3 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_18, __pyx_mstate_global->__pyx_kp_u_Push_thread};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3392, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":3394
 *                 logger.info("Push thread")
 *                 # self.log_system_resources()
 *                 await precise_sleep(self.interval, stop_event)             # <<<<<<<<<<<<<<
 * 
 *                 # Check if we should stop
*/
        __pyx_t_12 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_precise_sleep); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3394, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_18);
        __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3394, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_3 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_18))) {
          __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_18);
          assert(__pyx_t_12);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_18);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_18, __pyx__function);
          __pyx_t_3 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_12, __pyx_t_13, __pyx_cur_scope->__pyx_v_stop_event};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_18, __pyx_callargs+__pyx_t_3, (3-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3394, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (likely(__pyx_t_15 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_6);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
          __Pyx_XGIVEREF(__pyx_t_7);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
          __Pyx_XGIVEREF(__pyx_t_8);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 22;
          return __pyx_r;
          __pyx_L195_resume_from_await:;
          __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_6);
          __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_7);
          __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_8);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3394, __pyx_L6_error)
        } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_DECREF(__pyx_r); __pyx_r = 0;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 3394, __pyx_L6_error)
        }

        /* "ws_package/controllers/activity_controller.py":3397
 * 
 *                 # Check if we should stop
 *                 if stop_event.is_set():             # <<<<<<<<<<<<<<
 *                     break
 * 
*/
        __pyx_t_18 = __pyx_cur_scope->__pyx_v_stop_event;
        __Pyx_INCREF(__pyx_t_18);
        __pyx_t_3 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_18, NULL};
          __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_set, __pyx_callargs+__pyx_t_3, (1-__pyx_t_3) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3397, __pyx_L6_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 3397, __pyx_L6_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (__pyx_t_5) {

          /* "ws_package/controllers/activity_controller.py":3398
 *                 # Check if we should stop
 *                 if stop_event.is_set():
 *                     break             # <<<<<<<<<<<<<<
 * 
 *             except Exception as e:
*/
          goto __pyx_L11_try_break;

          /* "ws_package/controllers/activity_controller.py":3397
 * 
 *                 # Check if we should stop
 *                 if stop_event.is_set():             # <<<<<<<<<<<<<<
 *                     break
 * 
*/
        }

        /* "ws_package/controllers/activity_controller.py":3088
 *     async def _push_activity_log(self, user_entity: UserEntity, stop_event=None):
 *         while not stop_event.is_set():
 *             try:             # <<<<<<<<<<<<<<
 *                 current_break_id = getattr(self, 'break_id', 0) or 0
 *                 try:
*/
      }
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L13_try_end;
      __pyx_L6_error:;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
      __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;

      /* "ws_package/controllers/activity_controller.py":3400
 *                     break
 * 
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 from ws_package.utils.error_codes import ErrorCode
 *                 logger.error("%s: %s", ErrorCode.PUSH_LOOP_FAILED, e, exc_info=True)
*/
      __pyx_t_22 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
      if (__pyx_t_22) {
        __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._push_activity_log", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_18, &__pyx_t_13) < 0) __PYX_ERR(0, 3400, __pyx_L8_except_error)
        __Pyx_XGOTREF(__pyx_t_1);
        __Pyx_XGOTREF(__pyx_t_18);
        __Pyx_XGOTREF(__pyx_t_13);
        __Pyx_INCREF(__pyx_t_18);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_18);
        __Pyx_GIVEREF(__pyx_t_18);
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":3401
 * 
 *             except Exception as e:
 *                 from ws_package.utils.error_codes import ErrorCode             # <<<<<<<<<<<<<<
 *                 logger.error("%s: %s", ErrorCode.PUSH_LOOP_FAILED, e, exc_info=True)
 *                 # Continue the loop even if there's an error
*/
          {
            PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ErrorCode};
            __pyx_t_9 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_utils_error_codes, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3401, __pyx_L202_error)
          }
          __pyx_t_12 = __pyx_t_9;
          __Pyx_GOTREF(__pyx_t_12);
          {
            PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ErrorCode};
            __pyx_t_34 = 0; {
              __pyx_t_20 = __Pyx_ImportFrom(__pyx_t_12, __pyx_imported_names[__pyx_t_34]); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3401, __pyx_L202_error)
              __Pyx_GOTREF(__pyx_t_20);
              switch (__pyx_t_34) {
                case 0:
                __Pyx_INCREF(__pyx_t_20);
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_ErrorCode);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_ErrorCode, __pyx_t_20);
                __Pyx_GIVEREF(__pyx_t_20);
                break;
                default:;
              }
              __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
            }
          }
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

          /* "ws_package/controllers/activity_controller.py":3402
 *             except Exception as e:
 *                 from ws_package.utils.error_codes import ErrorCode
 *                 logger.error("%s: %s", ErrorCode.PUSH_LOOP_FAILED, e, exc_info=True)             # <<<<<<<<<<<<<<
 *                 # Continue the loop even if there's an error
 *                 await asyncio.sleep(5)  # Brief pause before retrying
*/
          __pyx_t_20 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3402, __pyx_L202_error)
          __Pyx_GOTREF(__pyx_t_14);
          __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3402, __pyx_L202_error)
          __Pyx_GOTREF(__pyx_t_17);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_ErrorCode, __pyx_mstate_global->__pyx_n_u_PUSH_LOOP_FAILED); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3402, __pyx_L202_error)
          __Pyx_GOTREF(__pyx_t_14);
          __pyx_t_3 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_17))) {
            __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_17);
            assert(__pyx_t_20);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
            __Pyx_INCREF(__pyx_t_20);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
            __pyx_t_3 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[4 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_20, __pyx_mstate_global->__pyx_kp_u_s_s, __pyx_t_14, __pyx_cur_scope->__pyx_v_e};
            __pyx_t_2 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3402, __pyx_L202_error)
            __Pyx_GOTREF(__pyx_t_2);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_2, __pyx_callargs+4, 0) < (0)) __PYX_ERR(0, 3402, __pyx_L202_error)
            __pyx_t_12 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_3, (4-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_2);
            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3402, __pyx_L202_error)
            __Pyx_GOTREF(__pyx_t_12);
          }
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

          /* "ws_package/controllers/activity_controller.py":3404
 *                 logger.error("%s: %s", ErrorCode.PUSH_LOOP_FAILED, e, exc_info=True)
 *                 # Continue the loop even if there's an error
 *                 await asyncio.sleep(5)  # Brief pause before retrying             # <<<<<<<<<<<<<<
 *                 continue
 * 
*/
          __pyx_t_17 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3404, __pyx_L202_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3404, __pyx_L202_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_3 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_14))) {
            __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_14);
            assert(__pyx_t_17);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
            __Pyx_INCREF(__pyx_t_17);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
            __pyx_t_3 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_17, __pyx_mstate_global->__pyx_int_5};
            __pyx_t_12 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_3, (2-__pyx_t_3) | (__pyx_t_3*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3404, __pyx_L202_error)
            __Pyx_GOTREF(__pyx_t_12);
          }
          __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_12, &__pyx_r);
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          if (likely(__pyx_t_15 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_1);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
            __Pyx_XGIVEREF(__pyx_t_6);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
            __Pyx_XGIVEREF(__pyx_t_7);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
            __Pyx_XGIVEREF(__pyx_t_8);
            __pyx_cur_scope->__pyx_t_3 = __pyx_t_8;
            __Pyx_XGIVEREF(__pyx_t_13);
            __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
            __Pyx_XGIVEREF(__pyx_t_18);
            __pyx_cur_scope->__pyx_t_5 = __pyx_t_18;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_SwapException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 23;
            return __pyx_r;
            __pyx_L204_resume_from_await:;
            __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_1);
            __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_6);
            __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_7);
            __pyx_t_8 = __pyx_cur_scope->__pyx_t_3;
            __pyx_cur_scope->__pyx_t_3 = 0;
            __Pyx_XGOTREF(__pyx_t_8);
            __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
            __pyx_cur_scope->__pyx_t_4 = 0;
            __Pyx_XGOTREF(__pyx_t_13);
            __pyx_t_18 = __pyx_cur_scope->__pyx_t_5;
            __pyx_cur_scope->__pyx_t_5 = 0;
            __Pyx_XGOTREF(__pyx_t_18);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3404, __pyx_L202_error)
          } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_DECREF(__pyx_r); __pyx_r = 0;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 3404, __pyx_L202_error)
          }

          /* "ws_package/controllers/activity_controller.py":3405
 *                 # Continue the loop even if there's an error
 *                 await asyncio.sleep(5)  # Brief pause before retrying
 *                 continue             # <<<<<<<<<<<<<<
 * 
 *     def is_link(self, url):
*/
          goto __pyx_L199_continue;
        }

        /* "ws_package/controllers/activity_controller.py":3400
 *                     break
 * 
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 from ws_package.utils.error_codes import ErrorCode
 *                 logger.error("%s: %s", ErrorCode.PUSH_LOOP_FAILED, e, exc_info=True)
*/
        /*finally:*/ {
          __pyx_L202_error:;
          /*exception exit:*/{
            __Pyx_PyThreadState_assign
            __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_29 = 0; __pyx_t_28 = 0; __pyx_t_27 = 0;
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
            __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
             __Pyx_ExceptionSwap(&__pyx_t_29, &__pyx_t_28, &__pyx_t_27);
            if ( unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
            __Pyx_XGOTREF(__pyx_t_9);
            __Pyx_XGOTREF(__pyx_t_10);
            __Pyx_XGOTREF(__pyx_t_11);
            __Pyx_XGOTREF(__pyx_t_29);
            __Pyx_XGOTREF(__pyx_t_28);
            __Pyx_XGOTREF(__pyx_t_27);
            __pyx_t_22 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_37 = __pyx_filename;
            {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
            }
            __Pyx_XGIVEREF(__pyx_t_29);
            __Pyx_XGIVEREF(__pyx_t_28);
            __Pyx_XGIVEREF(__pyx_t_27);
            __Pyx_ExceptionReset(__pyx_t_29, __pyx_t_28, __pyx_t_27);
            __Pyx_XGIVEREF(__pyx_t_9);
            __Pyx_XGIVEREF(__pyx_t_10);
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_ErrRestore(__pyx_t_9, __pyx_t_10, __pyx_t_11);
            __pyx_t_9 = 0; __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_29 = 0; __pyx_t_28 = 0; __pyx_t_27 = 0;
            __pyx_lineno = __pyx_t_22; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_37;
            goto __pyx_L8_except_error;
          }
          __pyx_L199_continue: {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
            goto __pyx_L197_except_continue;
          }
        }
        __pyx_L197_except_continue:;
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        goto __pyx_L12_try_continue;
      }
      goto __pyx_L8_except_error;

      /* "ws_package/controllers/activity_controller.py":3088
 *     async def _push_activity_log(self, user_entity: UserEntity, stop_event=None):
 *         while not stop_event.is_set():
 *             try:             # <<<<<<<<<<<<<<
 *                 current_break_id = getattr(self, 'break_id', 0) or 0
 *                 try:
*/
      __pyx_L8_except_error:;
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
      goto __pyx_L1_error;
      __pyx_L11_try_break:;
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
      goto __pyx_L5_break;
      __pyx_L12_try_continue:;
      __Pyx_XGIVEREF(__pyx_t_6);
      __Pyx_XGIVEREF(__pyx_t_7);
      __Pyx_XGIVEREF(__pyx_t_8);
      __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
      goto __pyx_L4_continue;
      __pyx_L13_try_end:;
    }
    __pyx_L4_continue:;
  }
  __pyx_L5_break:;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":3086
 * 
 * 
 *     async def _push_activity_log(self, user_entity: UserEntity, stop_event=None):             # <<<<<<<<<<<<<<
 *         while not stop_event.is_set():
 *             try:
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("_push_activity_log", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":3407
 *                 continue
 * 
 *     def is_link(self, url):             # <<<<<<<<<<<<<<
 *         """Check if the given string is a valid HTTP/HTTPS URL."""
 *         return self.screenshot_manager.is_link(url)
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_110is_link(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_109is_link, "Check if the given string is a valid HTTP/HTTPS URL.");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_110is_link = {"is_link", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_110is_link, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_109is_link};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_110is_link(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_url = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_link (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_url,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 3407, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3407, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3407, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "is_link", 0) < (0)) __PYX_ERR(0, 3407, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("is_link", 1, 2, 2, i); __PYX_ERR(0, 3407, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3407, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3407, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_url = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("is_link", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 3407, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.is_link", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_109is_link(__pyx_self, __pyx_v_self, __pyx_v_url);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_109is_link(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_url) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  size_t __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_link", 0);

  /* "ws_package/controllers/activity_controller.py":3409
 *     def is_link(self, url):
 *         """Check if the given string is a valid HTTP/HTTPS URL."""
 *         return self.screenshot_manager.is_link(url)             # <<<<<<<<<<<<<<
 * 
 *     def forward_ss(self, ss):
*/
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_manager); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3409, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __pyx_t_3;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_4 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_url};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_link, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3409, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "ws_package/controllers/activity_controller.py":3407
 *                 continue
 * 
 *     def is_link(self, url):             # <<<<<<<<<<<<<<
 *         """Check if the given string is a valid HTTP/HTTPS URL."""
 *         return self.screenshot_manager.is_link(url)
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.is_link", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":3411
 *         return self.screenshot_manager.is_link(url)
 * 
 *     def forward_ss(self, ss):             # <<<<<<<<<<<<<<
 *         return self.screenshot_manager.forward_ss(ss)
 * 
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_112forward_ss(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_112forward_ss = {"forward_ss", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_112forward_ss, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_112forward_ss(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_ss = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("forward_ss (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_ss,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 3411, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3411, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3411, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "forward_ss", 0) < (0)) __PYX_ERR(0, 3411, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("forward_ss", 1, 2, 2, i); __PYX_ERR(0, 3411, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3411, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3411, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_ss = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("forward_ss", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 3411, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.forward_ss", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_111forward_ss(__pyx_self, __pyx_v_self, __pyx_v_ss);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_111forward_ss(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_ss) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  size_t __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("forward_ss", 0);

  /* "ws_package/controllers/activity_controller.py":3412
 * 
 *     def forward_ss(self, ss):
 *         return self.screenshot_manager.forward_ss(ss)             # <<<<<<<<<<<<<<
 * 
 *     async def ss(self, interval_start_time, interval_end_time, user_entity: UserEntity): # This is a validator chck if screenshot is link or not everytime and renaming before uploading
*/
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_manager); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3412, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __pyx_t_3;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_4 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_ss};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_forward_ss, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3412, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "ws_package/controllers/activity_controller.py":3411
 *         return self.screenshot_manager.is_link(url)
 * 
 *     def forward_ss(self, ss):             # <<<<<<<<<<<<<<
 *         return self.screenshot_manager.forward_ss(ss)
 * 
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.forward_ss", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_115generator23(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":3414
 *         return self.screenshot_manager.forward_ss(ss)
 * 
 *     async def ss(self, interval_start_time, interval_end_time, user_entity: UserEntity): # This is a validator chck if screenshot is link or not everytime and renaming before uploading             # <<<<<<<<<<<<<<
 *         ss_array = await self.activity_service.get_screenshots(interval_start_time, interval_end_time)
 *         ans_array = []
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_114ss(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_114ss = {"ss", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_114ss, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_114ss(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_interval_start_time = 0;
  PyObject *__pyx_v_interval_end_time = 0;
  PyObject *__pyx_v_user_entity = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[4] = {0,0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ss (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_interval_start_time,&__pyx_mstate_global->__pyx_n_u_interval_end_time,&__pyx_mstate_global->__pyx_n_u_user_entity,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 3414, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  4:
        values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 3414, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 3414, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3414, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3414, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "ss", 0) < (0)) __PYX_ERR(0, 3414, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 4; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("ss", 1, 4, 4, i); __PYX_ERR(0, 3414, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 4)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3414, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3414, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 3414, __pyx_L3_error)
      values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 3414, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_interval_start_time = values[1];
    __pyx_v_interval_end_time = values[2];
    __pyx_v_user_entity = values[3];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("ss", 1, 4, 4, __pyx_nargs); __PYX_ERR(0, 3414, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.ss", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_113ss(__pyx_self, __pyx_v_self, __pyx_v_interval_start_time, __pyx_v_interval_end_time, __pyx_v_user_entity);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_113ss(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_interval_start_time, PyObject *__pyx_v_interval_end_time, PyObject *__pyx_v_user_entity) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("ss", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 3414, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_interval_start_time = __pyx_v_interval_start_time;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_interval_start_time);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_interval_start_time);
  __pyx_cur_scope->__pyx_v_interval_end_time = __pyx_v_interval_end_time;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_interval_end_time);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_interval_end_time);
  __pyx_cur_scope->__pyx_v_user_entity = __pyx_v_user_entity;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_user_entity);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_user_entity);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_115generator23, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[39]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_ss, __pyx_mstate_global->__pyx_n_u_ActivityController_ss, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 3414, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.ss", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_115generator23(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  size_t __pyx_t_4;
  __Pyx_PySendResult __pyx_t_5;
  Py_ssize_t __pyx_t_6;
  PyObject *(*__pyx_t_7)(PyObject *);
  int __pyx_t_8;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  PyObject *__pyx_t_26 = NULL;
  PyObject *__pyx_t_27 = NULL;
  PyObject *__pyx_t_28 = NULL;
  PyObject *__pyx_t_29[10];
  PyObject *__pyx_t_30 = NULL;
  PyObject *__pyx_t_31 = NULL;
  PyObject *__pyx_t_32 = NULL;
  int __pyx_t_33;
  int __pyx_t_34;
  char const *__pyx_t_35;
  PyObject *__pyx_t_36 = NULL;
  PyObject *__pyx_t_37 = NULL;
  PyObject *__pyx_t_38 = NULL;
  PyObject *__pyx_t_39 = NULL;
  PyObject *__pyx_t_40 = NULL;
  PyObject *__pyx_t_41 = NULL;
  char const *__pyx_t_42;
  char const *__pyx_t_43;
  char const *__pyx_t_44;
  char const *__pyx_t_45;
  char const *__pyx_t_46;
  char const *__pyx_t_47;
  char const *__pyx_t_48;
  char const *__pyx_t_49;
  char const *__pyx_t_50;
  char const *__pyx_t_51;
  char const *__pyx_t_52;
  char const *__pyx_t_53;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("ss", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L4_resume_from_await;
    case 2: goto __pyx_L26_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 3414, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":3415
 * 
 *     async def ss(self, interval_start_time, interval_end_time, user_entity: UserEntity): # This is a validator chck if screenshot is link or not everytime and renaming before uploading
 *         ss_array = await self.activity_service.get_screenshots(interval_start_time, interval_end_time)             # <<<<<<<<<<<<<<
 *         ans_array = []
 *         for ss in ss_array:
*/
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __pyx_t_3;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_4 = 0;
  {
    PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_interval_start_time, __pyx_cur_scope->__pyx_v_interval_end_time};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_screenshots, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3415, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_5 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_5 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L4_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3415, __pyx_L1_error)
    __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
  } else if (likely(__pyx_t_5 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __pyx_t_1 = __pyx_r; __pyx_r = NULL;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 3415, __pyx_L1_error)
  }
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_ss_array = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":3416
 *     async def ss(self, interval_start_time, interval_end_time, user_entity: UserEntity): # This is a validator chck if screenshot is link or not everytime and renaming before uploading
 *         ss_array = await self.activity_service.get_screenshots(interval_start_time, interval_end_time)
 *         ans_array = []             # <<<<<<<<<<<<<<
 *         for ss in ss_array:
 *             if self.is_link(ss):
*/
  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_ans_array = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":3417
 *         ss_array = await self.activity_service.get_screenshots(interval_start_time, interval_end_time)
 *         ans_array = []
 *         for ss in ss_array:             # <<<<<<<<<<<<<<
 *             if self.is_link(ss):
 *                 ans_array.append(ss)
*/
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_ss_array)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_ss_array)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_v_ss_array; __Pyx_INCREF(__pyx_t_1);
    __pyx_t_6 = 0;
    __pyx_t_7 = NULL;
  } else {
    __pyx_t_6 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_ss_array); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3417, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_7 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3417, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_7)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3417, __pyx_L1_error)
          #endif
          if (__pyx_t_6 >= __pyx_temp) break;
        }
        __pyx_t_3 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_1, __pyx_t_6, __Pyx_ReferenceSharing_OwnStrongReference);
        ++__pyx_t_6;
      } else {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3417, __pyx_L1_error)
          #endif
          if (__pyx_t_6 >= __pyx_temp) break;
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_6));
        #else
        __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_6);
        #endif
        ++__pyx_t_6;
      }
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3417, __pyx_L1_error)
    } else {
      __pyx_t_3 = __pyx_t_7(__pyx_t_1);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 3417, __pyx_L1_error)
          PyErr_Clear();
        }
        break;
      }
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_ss);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_ss, __pyx_t_3);
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_t_3 = 0;

    /* "ws_package/controllers/activity_controller.py":3418
 *         ans_array = []
 *         for ss in ss_array:
 *             if self.is_link(ss):             # <<<<<<<<<<<<<<
 *                 ans_array.append(ss)
 * 
*/
    __pyx_t_2 = __pyx_cur_scope->__pyx_v_self;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_4 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_ss};
      __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_link, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3418, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 3418, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_8) {

      /* "ws_package/controllers/activity_controller.py":3419
 *         for ss in ss_array:
 *             if self.is_link(ss):
 *                 ans_array.append(ss)             # <<<<<<<<<<<<<<
 * 
 *             else:
*/
      __pyx_t_9 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_ans_array, __pyx_cur_scope->__pyx_v_ss); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 3419, __pyx_L1_error)

      /* "ws_package/controllers/activity_controller.py":3418
 *         ans_array = []
 *         for ss in ss_array:
 *             if self.is_link(ss):             # <<<<<<<<<<<<<<
 *                 ans_array.append(ss)
 * 
*/
      goto __pyx_L7;
    }

    /* "ws_package/controllers/activity_controller.py":3422
 * 
 *             else:
 *                 try:             # <<<<<<<<<<<<<<
 *                     # Validate screenshot file exists and is accessible
 *                     if not os.path.exists(ss):
*/
    /*else*/ {
      {
        __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
        __Pyx_XGOTREF(__pyx_t_10);
        __Pyx_XGOTREF(__pyx_t_11);
        __Pyx_XGOTREF(__pyx_t_12);
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":3424
 *                 try:
 *                     # Validate screenshot file exists and is accessible
 *                     if not os.path.exists(ss):             # <<<<<<<<<<<<<<
 *                         logger.warning("Screenshot file not found: %s", ss)
 *                         continue
*/
          __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_os); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3424, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_path); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3424, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __pyx_t_2 = __pyx_t_14;
          __Pyx_INCREF(__pyx_t_2);
          __pyx_t_4 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_ss};
            __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_exists, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3424, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_3);
          }
          __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 3424, __pyx_L8_error)
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_15 = (!__pyx_t_8);
          if (__pyx_t_15) {

            /* "ws_package/controllers/activity_controller.py":3425
 *                     # Validate screenshot file exists and is accessible
 *                     if not os.path.exists(ss):
 *                         logger.warning("Screenshot file not found: %s", ss)             # <<<<<<<<<<<<<<
 *                         continue
 * 
*/
            __pyx_t_14 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3425, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3425, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_13))) {
              __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
              assert(__pyx_t_14);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
              __Pyx_INCREF(__pyx_t_14);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_14, __pyx_mstate_global->__pyx_kp_u_Screenshot_file_not_found_s, __pyx_cur_scope->__pyx_v_ss};
              __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3425, __pyx_L8_error)
              __Pyx_GOTREF(__pyx_t_3);
            }
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

            /* "ws_package/controllers/activity_controller.py":3426
 *                     if not os.path.exists(ss):
 *                         logger.warning("Screenshot file not found: %s", ss)
 *                         continue             # <<<<<<<<<<<<<<
 * 
 *                     if not os.access(ss, os.R_OK):
*/
            goto __pyx_L14_try_continue;

            /* "ws_package/controllers/activity_controller.py":3424
 *                 try:
 *                     # Validate screenshot file exists and is accessible
 *                     if not os.path.exists(ss):             # <<<<<<<<<<<<<<
 *                         logger.warning("Screenshot file not found: %s", ss)
 *                         continue
*/
          }

          /* "ws_package/controllers/activity_controller.py":3428
 *                         continue
 * 
 *                     if not os.access(ss, os.R_OK):             # <<<<<<<<<<<<<<
 *                         logger.warning("Screenshot file not readable: %s", ss)
 *                         continue
*/
          __pyx_t_13 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_os); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3428, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_14);
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_access); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3428, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_os); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3428, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_14);
          __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_R_OK); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3428, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_16);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __pyx_t_4 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_2);
            assert(__pyx_t_13);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
            __pyx_t_4 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_13, __pyx_cur_scope->__pyx_v_ss, __pyx_t_16};
            __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3428, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_3);
          }
          __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_15 < 0))) __PYX_ERR(0, 3428, __pyx_L8_error)
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_8 = (!__pyx_t_15);
          if (__pyx_t_8) {

            /* "ws_package/controllers/activity_controller.py":3429
 * 
 *                     if not os.access(ss, os.R_OK):
 *                         logger.warning("Screenshot file not readable: %s", ss)             # <<<<<<<<<<<<<<
 *                         continue
 * 
*/
            __pyx_t_2 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3429, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_16);
            __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3429, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_13))) {
              __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_13);
              assert(__pyx_t_2);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
              __Pyx_INCREF(__pyx_t_2);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Screenshot_file_not_readable_s, __pyx_cur_scope->__pyx_v_ss};
              __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3429, __pyx_L8_error)
              __Pyx_GOTREF(__pyx_t_3);
            }
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

            /* "ws_package/controllers/activity_controller.py":3430
 *                     if not os.access(ss, os.R_OK):
 *                         logger.warning("Screenshot file not readable: %s", ss)
 *                         continue             # <<<<<<<<<<<<<<
 * 
 *                     try:
*/
            goto __pyx_L14_try_continue;

            /* "ws_package/controllers/activity_controller.py":3428
 *                         continue
 * 
 *                     if not os.access(ss, os.R_OK):             # <<<<<<<<<<<<<<
 *                         logger.warning("Screenshot file not readable: %s", ss)
 *                         continue
*/
          }

          /* "ws_package/controllers/activity_controller.py":3432
 *                         continue
 * 
 *                     try:             # <<<<<<<<<<<<<<
 *                         task = asyncio.create_task(
 *                             self.screenshot_controller.screenshot_service.sync(
*/
          {
            __Pyx_ExceptionSave(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
            __Pyx_XGOTREF(__pyx_t_17);
            __Pyx_XGOTREF(__pyx_t_18);
            __Pyx_XGOTREF(__pyx_t_19);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":3433
 * 
 *                     try:
 *                         task = asyncio.create_task(             # <<<<<<<<<<<<<<
 *                             self.screenshot_controller.screenshot_service.sync(
 *                                 ss,
*/
              __pyx_t_13 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3433, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_create_task); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3433, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_16);
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

              /* "ws_package/controllers/activity_controller.py":3434
 *                     try:
 *                         task = asyncio.create_task(
 *                             self.screenshot_controller.screenshot_service.sync(             # <<<<<<<<<<<<<<
 *                                 ss,
 *                                 f"{user_entity.org_id}/{user_entity.user_id}/"
*/
              __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3434, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_20);
              __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_screenshot_service); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3434, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_21);
              __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
              __pyx_t_14 = __pyx_t_21;
              __Pyx_INCREF(__pyx_t_14);

              /* "ws_package/controllers/activity_controller.py":3436
 *                             self.screenshot_controller.screenshot_service.sync(
 *                                 ss,
 *                                 f"{user_entity.org_id}/{user_entity.user_id}/"             # <<<<<<<<<<<<<<
 *                                 f"{self.s3_screenshot_path}{self.screenshot_controller.format_ss_name(self.forward_ss(ss))}/"
 *                                 f"{self.get_os_type()}/{self.screenshot_controller.unix_format_ss_name(self.forward_ss(ss))}",
*/
              __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_org_id); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3436, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_20);
              __pyx_t_22 = __Pyx_PyObject_FormatSimple(__pyx_t_20, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 3436, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_22);
              __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
              __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_user_id); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3436, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_20);
              __pyx_t_23 = __Pyx_PyObject_FormatSimple(__pyx_t_20, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 3436, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_23);
              __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;

              /* "ws_package/controllers/activity_controller.py":3437
 *                                 ss,
 *                                 f"{user_entity.org_id}/{user_entity.user_id}/"
 *                                 f"{self.s3_screenshot_path}{self.screenshot_controller.format_ss_name(self.forward_ss(ss))}/"             # <<<<<<<<<<<<<<
 *                                 f"{self.get_os_type()}/{self.screenshot_controller.unix_format_ss_name(self.forward_ss(ss))}",
 *                                 user_entity
*/
              __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_s3_screenshot_path); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3437, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_20);
              __pyx_t_24 = __Pyx_PyObject_FormatSimple(__pyx_t_20, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3437, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_24);
              __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
              __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3437, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_20);
              __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_format_ss_name); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3437, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_25);
              __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
              __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_forward_ss); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3437, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_20);
              __pyx_t_26 = __Pyx_PyObject_CallOneArg(__pyx_t_20, __pyx_cur_scope->__pyx_v_ss); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 3437, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_26);
              __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
              __pyx_t_20 = __Pyx_PyObject_CallOneArg(__pyx_t_25, __pyx_t_26); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3437, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_20);
              __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
              __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
              __pyx_t_26 = __Pyx_PyObject_FormatSimple(__pyx_t_20, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 3437, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_26);
              __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;

              /* "ws_package/controllers/activity_controller.py":3438
 *                                 f"{user_entity.org_id}/{user_entity.user_id}/"
 *                                 f"{self.s3_screenshot_path}{self.screenshot_controller.format_ss_name(self.forward_ss(ss))}/"
 *                                 f"{self.get_os_type()}/{self.screenshot_controller.unix_format_ss_name(self.forward_ss(ss))}",             # <<<<<<<<<<<<<<
 *                                 user_entity
 *                             ),
*/
              __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_get_os_type); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3438, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_20);
              __pyx_t_25 = __Pyx_PyObject_CallNoArg(__pyx_t_20); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3438, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_25);
              __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
              __pyx_t_20 = __Pyx_PyObject_FormatSimple(__pyx_t_25, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3438, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_20);
              __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
              __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3438, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_25);
              __pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_unix_format_ss_name); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 3438, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_27);
              __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
              __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_forward_ss); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3438, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_25);
              __pyx_t_28 = __Pyx_PyObject_CallOneArg(__pyx_t_25, __pyx_cur_scope->__pyx_v_ss); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 3438, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_28);
              __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
              __pyx_t_25 = __Pyx_PyObject_CallOneArg(__pyx_t_27, __pyx_t_28); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3438, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_25);
              __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
              __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
              __pyx_t_28 = __Pyx_PyObject_FormatSimple(__pyx_t_25, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 3438, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_28);
              __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
              __pyx_t_29[0] = __pyx_t_22;
              __pyx_t_29[1] = __pyx_mstate_global->__pyx_kp_u__9;
              __pyx_t_29[2] = __pyx_t_23;
              __pyx_t_29[3] = __pyx_mstate_global->__pyx_kp_u__9;
              __pyx_t_29[4] = __pyx_t_24;
              __pyx_t_29[5] = __pyx_t_26;
              __pyx_t_29[6] = __pyx_mstate_global->__pyx_kp_u__9;
              __pyx_t_29[7] = __pyx_t_20;
              __pyx_t_29[8] = __pyx_mstate_global->__pyx_kp_u__9;
              __pyx_t_29[9] = __pyx_t_28;

              /* "ws_package/controllers/activity_controller.py":3436
 *                             self.screenshot_controller.screenshot_service.sync(
 *                                 ss,
 *                                 f"{user_entity.org_id}/{user_entity.user_id}/"             # <<<<<<<<<<<<<<
 *                                 f"{self.s3_screenshot_path}{self.screenshot_controller.format_ss_name(self.forward_ss(ss))}/"
 *                                 f"{self.get_os_type()}/{self.screenshot_controller.unix_format_ss_name(self.forward_ss(ss))}",
*/
              __pyx_t_25 = __Pyx_PyUnicode_Join(__pyx_t_29, 10, __Pyx_PyUnicode_GET_LENGTH(__pyx_t_22) + 1 * 4 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_23) + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_24) + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_26) + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_20) + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_28), 127 | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_22) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_23) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_24) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_26) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_20) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_28));
              if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3436, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_25);
              __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
              __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
              __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
              __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;

              /* "ws_package/controllers/activity_controller.py":3439
 *                                 f"{self.s3_screenshot_path}{self.screenshot_controller.format_ss_name(self.forward_ss(ss))}/"
 *                                 f"{self.get_os_type()}/{self.screenshot_controller.unix_format_ss_name(self.forward_ss(ss))}",
 *                                 user_entity             # <<<<<<<<<<<<<<
 *                             ),
 *                         )
*/
              __pyx_t_4 = 0;
              {
                PyObject *__pyx_callargs[4] = {__pyx_t_14, __pyx_cur_scope->__pyx_v_ss, __pyx_t_25, __pyx_cur_scope->__pyx_v_user_entity};
                __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_sync, __pyx_callargs+__pyx_t_4, (4-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3434, __pyx_L18_error)
                __Pyx_GOTREF(__pyx_t_2);
              }
              __pyx_t_4 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_16))) {
                __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_16);
                assert(__pyx_t_13);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_16);
                __Pyx_INCREF(__pyx_t_13);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_16, __pyx__function);
                __pyx_t_4 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_t_2};
                __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_16, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3433, __pyx_L18_error)
                __Pyx_GOTREF(__pyx_t_3);
              }
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_task);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_task, __pyx_t_3);
              __Pyx_GIVEREF(__pyx_t_3);
              __pyx_t_3 = 0;

              /* "ws_package/controllers/activity_controller.py":3443
 *                         )
 *                         # Track task to prevent silent failures
 *                         self._background_tasks.add(task)             # <<<<<<<<<<<<<<
 *                         task.add_done_callback(self._background_tasks.discard)
 * 
*/
              __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_background_tasks); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3443, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_t_16 = __pyx_t_2;
              __Pyx_INCREF(__pyx_t_16);
              __pyx_t_4 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_16, __pyx_cur_scope->__pyx_v_task};
                __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_add, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3443, __pyx_L18_error)
                __Pyx_GOTREF(__pyx_t_3);
              }
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

              /* "ws_package/controllers/activity_controller.py":3444
 *                         # Track task to prevent silent failures
 *                         self._background_tasks.add(task)
 *                         task.add_done_callback(self._background_tasks.discard)             # <<<<<<<<<<<<<<
 * 
 *                         response = await task
*/
              __pyx_t_2 = __pyx_cur_scope->__pyx_v_task;
              __Pyx_INCREF(__pyx_t_2);
              __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_background_tasks); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3444, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_16);
              __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_discard); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3444, __pyx_L18_error)
              __Pyx_GOTREF(__pyx_t_13);
              __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
              __pyx_t_4 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_13};
                __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_add_done_callback, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3444, __pyx_L18_error)
                __Pyx_GOTREF(__pyx_t_3);
              }
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

              /* "ws_package/controllers/activity_controller.py":3446
 *                         task.add_done_callback(self._background_tasks.discard)
 * 
 *                         response = await task             # <<<<<<<<<<<<<<
 *                         s3_upload_link = response
 *                         ans_array.append(s3_upload_link)
*/
              __pyx_t_5 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_cur_scope->__pyx_v_task, &__pyx_r);
              if (likely(__pyx_t_5 == PYGEN_NEXT)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_XGIVEREF(__pyx_t_1);
                __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
                __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
                __Pyx_XGIVEREF(__pyx_t_10);
                __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                __Pyx_XGIVEREF(__pyx_t_11);
                __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
                __Pyx_XGIVEREF(__pyx_t_12);
                __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                __Pyx_XGIVEREF(__pyx_t_17);
                __pyx_cur_scope->__pyx_t_6 = __pyx_t_17;
                __Pyx_XGIVEREF(__pyx_t_18);
                __pyx_cur_scope->__pyx_t_7 = __pyx_t_18;
                __Pyx_XGIVEREF(__pyx_t_19);
                __pyx_cur_scope->__pyx_t_8 = __pyx_t_19;
                __Pyx_XGIVEREF(__pyx_r);
                __Pyx_RefNannyFinishContext();
                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                /* return from generator, awaiting value */
                __pyx_generator->resume_label = 2;
                return __pyx_r;
                __pyx_L26_resume_from_await:;
                __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                __pyx_cur_scope->__pyx_t_0 = 0;
                __Pyx_XGOTREF(__pyx_t_1);
                __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
                __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
                __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                __pyx_cur_scope->__pyx_t_3 = 0;
                __Pyx_XGOTREF(__pyx_t_10);
                __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
                __pyx_cur_scope->__pyx_t_4 = 0;
                __Pyx_XGOTREF(__pyx_t_11);
                __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                __pyx_cur_scope->__pyx_t_5 = 0;
                __Pyx_XGOTREF(__pyx_t_12);
                __pyx_t_17 = __pyx_cur_scope->__pyx_t_6;
                __pyx_cur_scope->__pyx_t_6 = 0;
                __Pyx_XGOTREF(__pyx_t_17);
                __pyx_t_18 = __pyx_cur_scope->__pyx_t_7;
                __pyx_cur_scope->__pyx_t_7 = 0;
                __Pyx_XGOTREF(__pyx_t_18);
                __pyx_t_19 = __pyx_cur_scope->__pyx_t_8;
                __pyx_cur_scope->__pyx_t_8 = 0;
                __Pyx_XGOTREF(__pyx_t_19);
                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3446, __pyx_L18_error)
                __pyx_t_3 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_3);
              } else if (likely(__pyx_t_5 == PYGEN_RETURN)) {
                __Pyx_GOTREF(__pyx_r);
                __pyx_t_3 = __pyx_r; __pyx_r = NULL;
              } else {
                __Pyx_XGOTREF(__pyx_r);
                __PYX_ERR(0, 3446, __pyx_L18_error)
              }
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_response);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_response, __pyx_t_3);
              __Pyx_GIVEREF(__pyx_t_3);
              __pyx_t_3 = 0;

              /* "ws_package/controllers/activity_controller.py":3447
 * 
 *                         response = await task
 *                         s3_upload_link = response             # <<<<<<<<<<<<<<
 *                         ans_array.append(s3_upload_link)
 *                         # Delete local file once we have AWS link - no need to wait for next interval
*/
              __Pyx_INCREF(__pyx_cur_scope->__pyx_v_response);
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_s3_upload_link);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_s3_upload_link, __pyx_cur_scope->__pyx_v_response);
              __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_response);

              /* "ws_package/controllers/activity_controller.py":3448
 *                         response = await task
 *                         s3_upload_link = response
 *                         ans_array.append(s3_upload_link)             # <<<<<<<<<<<<<<
 *                         # Delete local file once we have AWS link - no need to wait for next interval
 *                         if s3_upload_link and ss:
*/
              __pyx_t_9 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_ans_array, __pyx_cur_scope->__pyx_v_s3_upload_link); if (unlikely(__pyx_t_9 == ((int)-1))) __PYX_ERR(0, 3448, __pyx_L18_error)

              /* "ws_package/controllers/activity_controller.py":3450
 *                         ans_array.append(s3_upload_link)
 *                         # Delete local file once we have AWS link - no need to wait for next interval
 *                         if s3_upload_link and ss:             # <<<<<<<<<<<<<<
 *                             try:
 *                                 screenshot_dir = os.path.dirname(ss)
*/
              __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_s3_upload_link); if (unlikely((__pyx_t_15 < 0))) __PYX_ERR(0, 3450, __pyx_L18_error)
              if (__pyx_t_15) {
              } else {
                __pyx_t_8 = __pyx_t_15;
                goto __pyx_L28_bool_binop_done;
              }
              __pyx_t_15 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_ss); if (unlikely((__pyx_t_15 < 0))) __PYX_ERR(0, 3450, __pyx_L18_error)
              __pyx_t_8 = __pyx_t_15;
              __pyx_L28_bool_binop_done:;
              if (__pyx_t_8) {

                /* "ws_package/controllers/activity_controller.py":3451
 *                         # Delete local file once we have AWS link - no need to wait for next interval
 *                         if s3_upload_link and ss:
 *                             try:             # <<<<<<<<<<<<<<
 *                                 screenshot_dir = os.path.dirname(ss)
 *                                 screenshot_name = os.path.basename(ss)
*/
                {
                  __Pyx_ExceptionSave(&__pyx_t_30, &__pyx_t_31, &__pyx_t_32);
                  __Pyx_XGOTREF(__pyx_t_30);
                  __Pyx_XGOTREF(__pyx_t_31);
                  __Pyx_XGOTREF(__pyx_t_32);
                  /*try:*/ {

                    /* "ws_package/controllers/activity_controller.py":3452
 *                         if s3_upload_link and ss:
 *                             try:
 *                                 screenshot_dir = os.path.dirname(ss)             # <<<<<<<<<<<<<<
 *                                 screenshot_name = os.path.basename(ss)
 *                                 self.screenshot_controller.delete_screenshot(screenshot_name, screenshot_dir)
*/
                    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3452, __pyx_L30_error)
                    __Pyx_GOTREF(__pyx_t_2);
                    __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_path); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3452, __pyx_L30_error)
                    __Pyx_GOTREF(__pyx_t_16);
                    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __pyx_t_13 = __pyx_t_16;
                    __Pyx_INCREF(__pyx_t_13);
                    __pyx_t_4 = 0;
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_cur_scope->__pyx_v_ss};
                      __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_dirname, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3452, __pyx_L30_error)
                      __Pyx_GOTREF(__pyx_t_3);
                    }
                    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_screenshot_dir);
                    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_screenshot_dir, __pyx_t_3);
                    __Pyx_GIVEREF(__pyx_t_3);
                    __pyx_t_3 = 0;

                    /* "ws_package/controllers/activity_controller.py":3453
 *                             try:
 *                                 screenshot_dir = os.path.dirname(ss)
 *                                 screenshot_name = os.path.basename(ss)             # <<<<<<<<<<<<<<
 *                                 self.screenshot_controller.delete_screenshot(screenshot_name, screenshot_dir)
 *                             except Exception as del_e:
*/
                    __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_os); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3453, __pyx_L30_error)
                    __Pyx_GOTREF(__pyx_t_13);
                    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3453, __pyx_L30_error)
                    __Pyx_GOTREF(__pyx_t_2);
                    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                    __pyx_t_16 = __pyx_t_2;
                    __Pyx_INCREF(__pyx_t_16);
                    __pyx_t_4 = 0;
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_16, __pyx_cur_scope->__pyx_v_ss};
                      __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_basename, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3453, __pyx_L30_error)
                      __Pyx_GOTREF(__pyx_t_3);
                    }
                    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_screenshot_name);
                    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_screenshot_name, __pyx_t_3);
                    __Pyx_GIVEREF(__pyx_t_3);
                    __pyx_t_3 = 0;

                    /* "ws_package/controllers/activity_controller.py":3454
 *                                 screenshot_dir = os.path.dirname(ss)
 *                                 screenshot_name = os.path.basename(ss)
 *                                 self.screenshot_controller.delete_screenshot(screenshot_name, screenshot_dir)             # <<<<<<<<<<<<<<
 *                             except Exception as del_e:
 *                                 logger.warning("Failed to delete screenshot file after upload: %s", del_e)
*/
                    __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3454, __pyx_L30_error)
                    __Pyx_GOTREF(__pyx_t_16);
                    __pyx_t_2 = __pyx_t_16;
                    __Pyx_INCREF(__pyx_t_2);
                    __pyx_t_4 = 0;
                    {
                      PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_screenshot_name, __pyx_cur_scope->__pyx_v_screenshot_dir};
                      __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_delete_screenshot, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3454, __pyx_L30_error)
                      __Pyx_GOTREF(__pyx_t_3);
                    }
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                    /* "ws_package/controllers/activity_controller.py":3451
 *                         # Delete local file once we have AWS link - no need to wait for next interval
 *                         if s3_upload_link and ss:
 *                             try:             # <<<<<<<<<<<<<<
 *                                 screenshot_dir = os.path.dirname(ss)
 *                                 screenshot_name = os.path.basename(ss)
*/
                  }
                  __Pyx_XDECREF(__pyx_t_30); __pyx_t_30 = 0;
                  __Pyx_XDECREF(__pyx_t_31); __pyx_t_31 = 0;
                  __Pyx_XDECREF(__pyx_t_32); __pyx_t_32 = 0;
                  goto __pyx_L37_try_end;
                  __pyx_L30_error:;
                  __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                  __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                  __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                  __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                  __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                  __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                  __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                  __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                  __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
                  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

                  /* "ws_package/controllers/activity_controller.py":3455
 *                                 screenshot_name = os.path.basename(ss)
 *                                 self.screenshot_controller.delete_screenshot(screenshot_name, screenshot_dir)
 *                             except Exception as del_e:             # <<<<<<<<<<<<<<
 *                                 logger.warning("Failed to delete screenshot file after upload: %s", del_e)
 *                     except ValidationError as e:
*/
                  __pyx_t_33 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                  if (__pyx_t_33) {
                    __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.ss", __pyx_clineno, __pyx_lineno, __pyx_filename);
                    if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_16, &__pyx_t_2) < 0) __PYX_ERR(0, 3455, __pyx_L32_except_error)
                    __Pyx_XGOTREF(__pyx_t_3);
                    __Pyx_XGOTREF(__pyx_t_16);
                    __Pyx_XGOTREF(__pyx_t_2);
                    __Pyx_INCREF(__pyx_t_16);
                    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_del_e);
                    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_del_e, __pyx_t_16);
                    __Pyx_GIVEREF(__pyx_t_16);
                    /*try:*/ {

                      /* "ws_package/controllers/activity_controller.py":3456
 *                                 self.screenshot_controller.delete_screenshot(screenshot_name, screenshot_dir)
 *                             except Exception as del_e:
 *                                 logger.warning("Failed to delete screenshot file after upload: %s", del_e)             # <<<<<<<<<<<<<<
 *                     except ValidationError as e:
 *                         logger.error("Screenshot sync validation error for screenshot: %s", e)
*/
                      __pyx_t_21 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3456, __pyx_L43_error)
                      __Pyx_GOTREF(__pyx_t_25);
                      __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3456, __pyx_L43_error)
                      __Pyx_GOTREF(__pyx_t_14);
                      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                      __pyx_t_4 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_14))) {
                        __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_14);
                        assert(__pyx_t_21);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
                        __Pyx_INCREF(__pyx_t_21);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
                        __pyx_t_4 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[3] = {__pyx_t_21, __pyx_mstate_global->__pyx_kp_u_Failed_to_delete_screenshot_file, __pyx_cur_scope->__pyx_v_del_e};
                        __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                        if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3456, __pyx_L43_error)
                        __Pyx_GOTREF(__pyx_t_13);
                      }
                      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                    }

                    /* "ws_package/controllers/activity_controller.py":3455
 *                                 screenshot_name = os.path.basename(ss)
 *                                 self.screenshot_controller.delete_screenshot(screenshot_name, screenshot_dir)
 *                             except Exception as del_e:             # <<<<<<<<<<<<<<
 *                                 logger.warning("Failed to delete screenshot file after upload: %s", del_e)
 *                     except ValidationError as e:
*/
                    /*finally:*/ {
                      /*normal exit:*/{
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_del_e);
                        __Pyx_DECREF(__pyx_cur_scope->__pyx_v_del_e); __pyx_cur_scope->__pyx_v_del_e = 0;
                        goto __pyx_L44;
                      }
                      __pyx_L43_error:;
                      /*exception exit:*/{
                        __Pyx_PyThreadState_assign
                        __pyx_t_36 = 0; __pyx_t_37 = 0; __pyx_t_38 = 0; __pyx_t_39 = 0; __pyx_t_40 = 0; __pyx_t_41 = 0;
                        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                        __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                        __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                        __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                        __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                        __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
                         __Pyx_ExceptionSwap(&__pyx_t_39, &__pyx_t_40, &__pyx_t_41);
                        if ( unlikely(__Pyx_GetException(&__pyx_t_36, &__pyx_t_37, &__pyx_t_38) < 0)) __Pyx_ErrFetch(&__pyx_t_36, &__pyx_t_37, &__pyx_t_38);
                        __Pyx_XGOTREF(__pyx_t_36);
                        __Pyx_XGOTREF(__pyx_t_37);
                        __Pyx_XGOTREF(__pyx_t_38);
                        __Pyx_XGOTREF(__pyx_t_39);
                        __Pyx_XGOTREF(__pyx_t_40);
                        __Pyx_XGOTREF(__pyx_t_41);
                        __pyx_t_33 = __pyx_lineno; __pyx_t_34 = __pyx_clineno; __pyx_t_35 = __pyx_filename;
                        {
                          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_del_e);
                          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_del_e); __pyx_cur_scope->__pyx_v_del_e = 0;
                        }
                        __Pyx_XGIVEREF(__pyx_t_39);
                        __Pyx_XGIVEREF(__pyx_t_40);
                        __Pyx_XGIVEREF(__pyx_t_41);
                        __Pyx_ExceptionReset(__pyx_t_39, __pyx_t_40, __pyx_t_41);
                        __Pyx_XGIVEREF(__pyx_t_36);
                        __Pyx_XGIVEREF(__pyx_t_37);
                        __Pyx_XGIVEREF(__pyx_t_38);
                        __Pyx_ErrRestore(__pyx_t_36, __pyx_t_37, __pyx_t_38);
                        __pyx_t_36 = 0; __pyx_t_37 = 0; __pyx_t_38 = 0; __pyx_t_39 = 0; __pyx_t_40 = 0; __pyx_t_41 = 0;
                        __pyx_lineno = __pyx_t_33; __pyx_clineno = __pyx_t_34; __pyx_filename = __pyx_t_35;
                        goto __pyx_L32_except_error;
                      }
                      __pyx_L44:;
                    }
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                    goto __pyx_L31_exception_handled;
                  }
                  goto __pyx_L32_except_error;

                  /* "ws_package/controllers/activity_controller.py":3451
 *                         # Delete local file once we have AWS link - no need to wait for next interval
 *                         if s3_upload_link and ss:
 *                             try:             # <<<<<<<<<<<<<<
 *                                 screenshot_dir = os.path.dirname(ss)
 *                                 screenshot_name = os.path.basename(ss)
*/
                  __pyx_L32_except_error:;
                  __Pyx_XGIVEREF(__pyx_t_30);
                  __Pyx_XGIVEREF(__pyx_t_31);
                  __Pyx_XGIVEREF(__pyx_t_32);
                  __Pyx_ExceptionReset(__pyx_t_30, __pyx_t_31, __pyx_t_32);
                  goto __pyx_L18_error;
                  __pyx_L31_exception_handled:;
                  __Pyx_XGIVEREF(__pyx_t_30);
                  __Pyx_XGIVEREF(__pyx_t_31);
                  __Pyx_XGIVEREF(__pyx_t_32);
                  __Pyx_ExceptionReset(__pyx_t_30, __pyx_t_31, __pyx_t_32);
                  __pyx_L37_try_end:;
                }

                /* "ws_package/controllers/activity_controller.py":3450
 *                         ans_array.append(s3_upload_link)
 *                         # Delete local file once we have AWS link - no need to wait for next interval
 *                         if s3_upload_link and ss:             # <<<<<<<<<<<<<<
 *                             try:
 *                                 screenshot_dir = os.path.dirname(ss)
*/
              }

              /* "ws_package/controllers/activity_controller.py":3432
 *                         continue
 * 
 *                     try:             # <<<<<<<<<<<<<<
 *                         task = asyncio.create_task(
 *                             self.screenshot_controller.screenshot_service.sync(
*/
            }
            __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
            goto __pyx_L25_try_end;
            __pyx_L18_error:;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
            __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
            __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
            __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
            __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
            __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
            __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
            __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

            /* "ws_package/controllers/activity_controller.py":3457
 *                             except Exception as del_e:
 *                                 logger.warning("Failed to delete screenshot file after upload: %s", del_e)
 *                     except ValidationError as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Screenshot sync validation error for screenshot: %s", e)
 *                         logger.error("Context: file=%s, dest=%s%s", ss, self.s3_screenshot_path, self.screenshot_controller.format_ss_name(self.forward_ss(ss)))
*/
            __Pyx_ErrFetch(&__pyx_t_2, &__pyx_t_16, &__pyx_t_3);
            __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_ValidationError); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3457, __pyx_L20_except_error)
            __Pyx_GOTREF(__pyx_t_13);
            __pyx_t_34 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_2, __pyx_t_13);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_ErrRestore(__pyx_t_2, __pyx_t_16, __pyx_t_3);
            __pyx_t_2 = 0; __pyx_t_16 = 0; __pyx_t_3 = 0;
            if (__pyx_t_34) {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.ss", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_16, &__pyx_t_2) < 0) __PYX_ERR(0, 3457, __pyx_L20_except_error)
              __Pyx_XGOTREF(__pyx_t_3);
              __Pyx_XGOTREF(__pyx_t_16);
              __Pyx_XGOTREF(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_16);
              __Pyx_GIVEREF(__pyx_t_16);
              __pyx_cur_scope->__pyx_v_e = __pyx_t_16;
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":3458
 *                                 logger.warning("Failed to delete screenshot file after upload: %s", del_e)
 *                     except ValidationError as e:
 *                         logger.error("Screenshot sync validation error for screenshot: %s", e)             # <<<<<<<<<<<<<<
 *                         logger.error("Context: file=%s, dest=%s%s", ss, self.s3_screenshot_path, self.screenshot_controller.format_ss_name(self.forward_ss(ss)))
 *                         # Skip this screenshot and continue processing
*/
                __pyx_t_14 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3458, __pyx_L54_error)
                __Pyx_GOTREF(__pyx_t_21);
                __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3458, __pyx_L54_error)
                __Pyx_GOTREF(__pyx_t_25);
                __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                __pyx_t_4 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_25))) {
                  __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_25);
                  assert(__pyx_t_14);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_25);
                  __Pyx_INCREF(__pyx_t_14);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_25, __pyx__function);
                  __pyx_t_4 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_14, __pyx_mstate_global->__pyx_kp_u_Screenshot_sync_validation_error, __pyx_cur_scope->__pyx_v_e};
                  __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_25, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                  __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                  if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3458, __pyx_L54_error)
                  __Pyx_GOTREF(__pyx_t_13);
                }
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

                /* "ws_package/controllers/activity_controller.py":3459
 *                     except ValidationError as e:
 *                         logger.error("Screenshot sync validation error for screenshot: %s", e)
 *                         logger.error("Context: file=%s, dest=%s%s", ss, self.s3_screenshot_path, self.screenshot_controller.format_ss_name(self.forward_ss(ss)))             # <<<<<<<<<<<<<<
 *                         # Skip this screenshot and continue processing
 *                         continue
*/
                __pyx_t_25 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3459, __pyx_L54_error)
                __Pyx_GOTREF(__pyx_t_14);
                __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3459, __pyx_L54_error)
                __Pyx_GOTREF(__pyx_t_21);
                __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_s3_screenshot_path); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3459, __pyx_L54_error)
                __Pyx_GOTREF(__pyx_t_14);
                __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 3459, __pyx_L54_error)
                __Pyx_GOTREF(__pyx_t_26);
                __pyx_t_20 = __pyx_t_26;
                __Pyx_INCREF(__pyx_t_20);
                __pyx_t_23 = __pyx_cur_scope->__pyx_v_self;
                __Pyx_INCREF(__pyx_t_23);
                __pyx_t_4 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_23, __pyx_cur_scope->__pyx_v_ss};
                  __pyx_t_24 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_forward_ss, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                  if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3459, __pyx_L54_error)
                  __Pyx_GOTREF(__pyx_t_24);
                }
                __pyx_t_4 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_20, __pyx_t_24};
                  __pyx_t_28 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_format_ss_name, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                  __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                  __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                  if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 3459, __pyx_L54_error)
                  __Pyx_GOTREF(__pyx_t_28);
                }
                __pyx_t_4 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_21))) {
                  __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_21);
                  assert(__pyx_t_25);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_21);
                  __Pyx_INCREF(__pyx_t_25);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_21, __pyx__function);
                  __pyx_t_4 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[5] = {__pyx_t_25, __pyx_mstate_global->__pyx_kp_u_Context_file_s_dest_s_s, __pyx_cur_scope->__pyx_v_ss, __pyx_t_14, __pyx_t_28};
                  __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_21, __pyx_callargs+__pyx_t_4, (5-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                  __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
                  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                  if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3459, __pyx_L54_error)
                  __Pyx_GOTREF(__pyx_t_13);
                }
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

                /* "ws_package/controllers/activity_controller.py":3461
 *                         logger.error("Context: file=%s, dest=%s%s", ss, self.s3_screenshot_path, self.screenshot_controller.format_ss_name(self.forward_ss(ss)))
 *                         # Skip this screenshot and continue processing
 *                         continue             # <<<<<<<<<<<<<<
 *                     except ScreenshotError as e:
 *                         error_message = str(e)
*/
                goto __pyx_L51_continue;
              }

              /* "ws_package/controllers/activity_controller.py":3457
 *                             except Exception as del_e:
 *                                 logger.warning("Failed to delete screenshot file after upload: %s", del_e)
 *                     except ValidationError as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Screenshot sync validation error for screenshot: %s", e)
 *                         logger.error("Context: file=%s, dest=%s%s", ss, self.s3_screenshot_path, self.screenshot_controller.format_ss_name(self.forward_ss(ss)))
*/
              /*finally:*/ {
                __pyx_L54_error:;
                /*exception exit:*/{
                  __Pyx_PyThreadState_assign
                  __pyx_t_32 = 0; __pyx_t_31 = 0; __pyx_t_30 = 0; __pyx_t_41 = 0; __pyx_t_40 = 0; __pyx_t_39 = 0;
                  __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                  __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                  __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                  __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                  __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                  __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                  __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                  __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
                   __Pyx_ExceptionSwap(&__pyx_t_41, &__pyx_t_40, &__pyx_t_39);
                  if ( unlikely(__Pyx_GetException(&__pyx_t_32, &__pyx_t_31, &__pyx_t_30) < 0)) __Pyx_ErrFetch(&__pyx_t_32, &__pyx_t_31, &__pyx_t_30);
                  __Pyx_XGOTREF(__pyx_t_32);
                  __Pyx_XGOTREF(__pyx_t_31);
                  __Pyx_XGOTREF(__pyx_t_30);
                  __Pyx_XGOTREF(__pyx_t_41);
                  __Pyx_XGOTREF(__pyx_t_40);
                  __Pyx_XGOTREF(__pyx_t_39);
                  __pyx_t_34 = __pyx_lineno; __pyx_t_33 = __pyx_clineno; __pyx_t_42 = __pyx_filename;
                  {
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  }
                  __Pyx_XGIVEREF(__pyx_t_41);
                  __Pyx_XGIVEREF(__pyx_t_40);
                  __Pyx_XGIVEREF(__pyx_t_39);
                  __Pyx_ExceptionReset(__pyx_t_41, __pyx_t_40, __pyx_t_39);
                  __Pyx_XGIVEREF(__pyx_t_32);
                  __Pyx_XGIVEREF(__pyx_t_31);
                  __Pyx_XGIVEREF(__pyx_t_30);
                  __Pyx_ErrRestore(__pyx_t_32, __pyx_t_31, __pyx_t_30);
                  __pyx_t_32 = 0; __pyx_t_31 = 0; __pyx_t_30 = 0; __pyx_t_41 = 0; __pyx_t_40 = 0; __pyx_t_39 = 0;
                  __pyx_lineno = __pyx_t_34; __pyx_clineno = __pyx_t_33; __pyx_filename = __pyx_t_42;
                  goto __pyx_L20_except_error;
                }
                __pyx_L51_continue: {
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  goto __pyx_L49_except_continue;
                }
              }
              __pyx_L49_except_continue:;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              goto __pyx_L24_try_continue;
            }

            /* "ws_package/controllers/activity_controller.py":3462
 *                         # Skip this screenshot and continue processing
 *                         continue
 *                     except ScreenshotError as e:             # <<<<<<<<<<<<<<
 *                         error_message = str(e)
 *                         # Check for S3 time tampering error (S3_TIME_TAMPERING or legacy message)
*/
            __Pyx_ErrFetch(&__pyx_t_2, &__pyx_t_16, &__pyx_t_3);
            __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_ScreenshotError); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3462, __pyx_L20_except_error)
            __Pyx_GOTREF(__pyx_t_13);
            __pyx_t_33 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_2, __pyx_t_13);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_ErrRestore(__pyx_t_2, __pyx_t_16, __pyx_t_3);
            __pyx_t_2 = 0; __pyx_t_16 = 0; __pyx_t_3 = 0;
            if (__pyx_t_33) {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.ss", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_16, &__pyx_t_2) < 0) __PYX_ERR(0, 3462, __pyx_L20_except_error)
              __Pyx_XGOTREF(__pyx_t_3);
              __Pyx_XGOTREF(__pyx_t_16);
              __Pyx_XGOTREF(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_16);
              __Pyx_GIVEREF(__pyx_t_16);
              __pyx_cur_scope->__pyx_v_e = __pyx_t_16;
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":3463
 *                         continue
 *                     except ScreenshotError as e:
 *                         error_message = str(e)             # <<<<<<<<<<<<<<
 *                         # Check for S3 time tampering error (S3_TIME_TAMPERING or legacy message)
 *                         if "S3_TIME_TAMPERING" in error_message or "Time tampering detected" in error_message or "RequestTimeTooSkewed" in error_message:
*/
                __pyx_t_13 = __Pyx_PyObject_Unicode(__pyx_cur_scope->__pyx_v_e); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3463, __pyx_L65_error)
                __Pyx_GOTREF(__pyx_t_13);
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_error_message);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_error_message, ((PyObject*)__pyx_t_13));
                __Pyx_GIVEREF(__pyx_t_13);
                __pyx_t_13 = 0;

                /* "ws_package/controllers/activity_controller.py":3465
 *                         error_message = str(e)
 *                         # Check for S3 time tampering error (S3_TIME_TAMPERING or legacy message)
 *                         if "S3_TIME_TAMPERING" in error_message or "Time tampering detected" in error_message or "RequestTimeTooSkewed" in error_message:             # <<<<<<<<<<<<<<
 *                             logger.error("S3 TIME TAMPERING DETECTED during screenshot upload: %s", error_message)
 *                             self.handle_s3_time_error(error_message)
*/
                __pyx_t_15 = (__Pyx_PyUnicode_ContainsTF(__pyx_mstate_global->__pyx_n_u_S3_TIME_TAMPERING, __pyx_cur_scope->__pyx_v_error_message, Py_EQ)); if (unlikely((__pyx_t_15 < 0))) __PYX_ERR(0, 3465, __pyx_L65_error)
                if (!__pyx_t_15) {
                } else {
                  __pyx_t_8 = __pyx_t_15;
                  goto __pyx_L68_bool_binop_done;
                }
                __pyx_t_15 = (__Pyx_PyUnicode_ContainsTF(__pyx_mstate_global->__pyx_kp_u_Time_tampering_detected, __pyx_cur_scope->__pyx_v_error_message, Py_EQ)); if (unlikely((__pyx_t_15 < 0))) __PYX_ERR(0, 3465, __pyx_L65_error)
                if (!__pyx_t_15) {
                } else {
                  __pyx_t_8 = __pyx_t_15;
                  goto __pyx_L68_bool_binop_done;
                }
                __pyx_t_15 = (__Pyx_PyUnicode_ContainsTF(__pyx_mstate_global->__pyx_n_u_RequestTimeTooSkewed, __pyx_cur_scope->__pyx_v_error_message, Py_EQ)); if (unlikely((__pyx_t_15 < 0))) __PYX_ERR(0, 3465, __pyx_L65_error)
                __pyx_t_8 = __pyx_t_15;
                __pyx_L68_bool_binop_done:;
                if (__pyx_t_8) {

                  /* "ws_package/controllers/activity_controller.py":3466
 *                         # Check for S3 time tampering error (S3_TIME_TAMPERING or legacy message)
 *                         if "S3_TIME_TAMPERING" in error_message or "Time tampering detected" in error_message or "RequestTimeTooSkewed" in error_message:
 *                             logger.error("S3 TIME TAMPERING DETECTED during screenshot upload: %s", error_message)             # <<<<<<<<<<<<<<
 *                             self.handle_s3_time_error(error_message)
 *                             # Continue processing other screenshots
*/
                  __pyx_t_21 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_28, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 3466, __pyx_L65_error)
                  __Pyx_GOTREF(__pyx_t_28);
                  __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_28, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3466, __pyx_L65_error)
                  __Pyx_GOTREF(__pyx_t_14);
                  __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
                  __pyx_t_4 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_14))) {
                    __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_14);
                    assert(__pyx_t_21);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
                    __Pyx_INCREF(__pyx_t_21);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
                    __pyx_t_4 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[3] = {__pyx_t_21, __pyx_mstate_global->__pyx_kp_u_S3_TIME_TAMPERING_DETECTED_durin, __pyx_cur_scope->__pyx_v_error_message};
                    __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                    if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3466, __pyx_L65_error)
                    __Pyx_GOTREF(__pyx_t_13);
                  }
                  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

                  /* "ws_package/controllers/activity_controller.py":3467
 *                         if "S3_TIME_TAMPERING" in error_message or "Time tampering detected" in error_message or "RequestTimeTooSkewed" in error_message:
 *                             logger.error("S3 TIME TAMPERING DETECTED during screenshot upload: %s", error_message)
 *                             self.handle_s3_time_error(error_message)             # <<<<<<<<<<<<<<
 *                             # Continue processing other screenshots
 *                             continue
*/
                  __pyx_t_14 = __pyx_cur_scope->__pyx_v_self;
                  __Pyx_INCREF(__pyx_t_14);
                  __pyx_t_4 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_14, __pyx_cur_scope->__pyx_v_error_message};
                    __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_handle_s3_time_error, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                    if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3467, __pyx_L65_error)
                    __Pyx_GOTREF(__pyx_t_13);
                  }
                  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

                  /* "ws_package/controllers/activity_controller.py":3469
 *                             self.handle_s3_time_error(error_message)
 *                             # Continue processing other screenshots
 *                             continue             # <<<<<<<<<<<<<<
 *                         logger.error("Screenshot sync error for screenshot: %s", e)
 *                         logger.error("Context: file=%s, dest=%s%s", ss, self.s3_screenshot_path, self.screenshot_controller.format_ss_name(self.forward_ss(ss)))
*/
                  goto __pyx_L62_continue;

                  /* "ws_package/controllers/activity_controller.py":3465
 *                         error_message = str(e)
 *                         # Check for S3 time tampering error (S3_TIME_TAMPERING or legacy message)
 *                         if "S3_TIME_TAMPERING" in error_message or "Time tampering detected" in error_message or "RequestTimeTooSkewed" in error_message:             # <<<<<<<<<<<<<<
 *                             logger.error("S3 TIME TAMPERING DETECTED during screenshot upload: %s", error_message)
 *                             self.handle_s3_time_error(error_message)
*/
                }

                /* "ws_package/controllers/activity_controller.py":3470
 *                             # Continue processing other screenshots
 *                             continue
 *                         logger.error("Screenshot sync error for screenshot: %s", e)             # <<<<<<<<<<<<<<
 *                         logger.error("Context: file=%s, dest=%s%s", ss, self.s3_screenshot_path, self.screenshot_controller.format_ss_name(self.forward_ss(ss)))
 *                         # Skip this screenshot and continue processing
*/
                __pyx_t_14 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3470, __pyx_L65_error)
                __Pyx_GOTREF(__pyx_t_21);
                __pyx_t_28 = __Pyx_PyObject_GetAttrStr(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 3470, __pyx_L65_error)
                __Pyx_GOTREF(__pyx_t_28);
                __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                __pyx_t_4 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_28))) {
                  __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_28);
                  assert(__pyx_t_14);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_28);
                  __Pyx_INCREF(__pyx_t_14);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_28, __pyx__function);
                  __pyx_t_4 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_14, __pyx_mstate_global->__pyx_kp_u_Screenshot_sync_error_for_screen, __pyx_cur_scope->__pyx_v_e};
                  __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_28, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                  __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
                  if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3470, __pyx_L65_error)
                  __Pyx_GOTREF(__pyx_t_13);
                }
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

                /* "ws_package/controllers/activity_controller.py":3471
 *                             continue
 *                         logger.error("Screenshot sync error for screenshot: %s", e)
 *                         logger.error("Context: file=%s, dest=%s%s", ss, self.s3_screenshot_path, self.screenshot_controller.format_ss_name(self.forward_ss(ss)))             # <<<<<<<<<<<<<<
 *                         # Skip this screenshot and continue processing
 *                         continue
*/
                __pyx_t_28 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3471, __pyx_L65_error)
                __Pyx_GOTREF(__pyx_t_14);
                __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3471, __pyx_L65_error)
                __Pyx_GOTREF(__pyx_t_21);
                __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_s3_screenshot_path); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3471, __pyx_L65_error)
                __Pyx_GOTREF(__pyx_t_14);
                __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3471, __pyx_L65_error)
                __Pyx_GOTREF(__pyx_t_24);
                __pyx_t_26 = __pyx_t_24;
                __Pyx_INCREF(__pyx_t_26);
                __pyx_t_23 = __pyx_cur_scope->__pyx_v_self;
                __Pyx_INCREF(__pyx_t_23);
                __pyx_t_4 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_23, __pyx_cur_scope->__pyx_v_ss};
                  __pyx_t_20 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_forward_ss, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                  if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3471, __pyx_L65_error)
                  __Pyx_GOTREF(__pyx_t_20);
                }
                __pyx_t_4 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_26, __pyx_t_20};
                  __pyx_t_25 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_format_ss_name, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                  __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                  if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3471, __pyx_L65_error)
                  __Pyx_GOTREF(__pyx_t_25);
                }
                __pyx_t_4 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_21))) {
                  __pyx_t_28 = PyMethod_GET_SELF(__pyx_t_21);
                  assert(__pyx_t_28);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_21);
                  __Pyx_INCREF(__pyx_t_28);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_21, __pyx__function);
                  __pyx_t_4 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[5] = {__pyx_t_28, __pyx_mstate_global->__pyx_kp_u_Context_file_s_dest_s_s, __pyx_cur_scope->__pyx_v_ss, __pyx_t_14, __pyx_t_25};
                  __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_21, __pyx_callargs+__pyx_t_4, (5-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
                  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                  __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                  if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3471, __pyx_L65_error)
                  __Pyx_GOTREF(__pyx_t_13);
                }
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

                /* "ws_package/controllers/activity_controller.py":3473
 *                         logger.error("Context: file=%s, dest=%s%s", ss, self.s3_screenshot_path, self.screenshot_controller.format_ss_name(self.forward_ss(ss)))
 *                         # Skip this screenshot and continue processing
 *                         continue             # <<<<<<<<<<<<<<
 *                     except NetworkError as e:
 *                         logger.error("Network error during screenshot sync for screenshot: %s", e)
*/
                goto __pyx_L62_continue;
              }

              /* "ws_package/controllers/activity_controller.py":3462
 *                         # Skip this screenshot and continue processing
 *                         continue
 *                     except ScreenshotError as e:             # <<<<<<<<<<<<<<
 *                         error_message = str(e)
 *                         # Check for S3 time tampering error (S3_TIME_TAMPERING or legacy message)
*/
              /*finally:*/ {
                __pyx_L65_error:;
                /*exception exit:*/{
                  __Pyx_PyThreadState_assign
                  __pyx_t_39 = 0; __pyx_t_40 = 0; __pyx_t_41 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0;
                  __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                  __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                  __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                  __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                  __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                  __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                  __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                  __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
                   __Pyx_ExceptionSwap(&__pyx_t_30, &__pyx_t_31, &__pyx_t_32);
                  if ( unlikely(__Pyx_GetException(&__pyx_t_39, &__pyx_t_40, &__pyx_t_41) < 0)) __Pyx_ErrFetch(&__pyx_t_39, &__pyx_t_40, &__pyx_t_41);
                  __Pyx_XGOTREF(__pyx_t_39);
                  __Pyx_XGOTREF(__pyx_t_40);
                  __Pyx_XGOTREF(__pyx_t_41);
                  __Pyx_XGOTREF(__pyx_t_30);
                  __Pyx_XGOTREF(__pyx_t_31);
                  __Pyx_XGOTREF(__pyx_t_32);
                  __pyx_t_33 = __pyx_lineno; __pyx_t_34 = __pyx_clineno; __pyx_t_43 = __pyx_filename;
                  {
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  }
                  __Pyx_XGIVEREF(__pyx_t_30);
                  __Pyx_XGIVEREF(__pyx_t_31);
                  __Pyx_XGIVEREF(__pyx_t_32);
                  __Pyx_ExceptionReset(__pyx_t_30, __pyx_t_31, __pyx_t_32);
                  __Pyx_XGIVEREF(__pyx_t_39);
                  __Pyx_XGIVEREF(__pyx_t_40);
                  __Pyx_XGIVEREF(__pyx_t_41);
                  __Pyx_ErrRestore(__pyx_t_39, __pyx_t_40, __pyx_t_41);
                  __pyx_t_39 = 0; __pyx_t_40 = 0; __pyx_t_41 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0;
                  __pyx_lineno = __pyx_t_33; __pyx_clineno = __pyx_t_34; __pyx_filename = __pyx_t_43;
                  goto __pyx_L20_except_error;
                }
                __pyx_L62_continue: {
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  goto __pyx_L60_except_continue;
                }
              }
              __pyx_L60_except_continue:;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              goto __pyx_L24_try_continue;
            }

            /* "ws_package/controllers/activity_controller.py":3474
 *                         # Skip this screenshot and continue processing
 *                         continue
 *                     except NetworkError as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Network error during screenshot sync for screenshot: %s", e)
 *                         logger.error("Context: file=%s, dest=%s%s", ss, self.s3_screenshot_path, self.screenshot_controller.format_ss_name(self.forward_ss(ss)))
*/
            __Pyx_ErrFetch(&__pyx_t_2, &__pyx_t_16, &__pyx_t_3);
            __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_NetworkError); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3474, __pyx_L20_except_error)
            __Pyx_GOTREF(__pyx_t_13);
            __pyx_t_34 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_2, __pyx_t_13);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_ErrRestore(__pyx_t_2, __pyx_t_16, __pyx_t_3);
            __pyx_t_2 = 0; __pyx_t_16 = 0; __pyx_t_3 = 0;
            if (__pyx_t_34) {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.ss", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_16, &__pyx_t_2) < 0) __PYX_ERR(0, 3474, __pyx_L20_except_error)
              __Pyx_XGOTREF(__pyx_t_3);
              __Pyx_XGOTREF(__pyx_t_16);
              __Pyx_XGOTREF(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_16);
              __Pyx_GIVEREF(__pyx_t_16);
              __pyx_cur_scope->__pyx_v_e = __pyx_t_16;
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":3475
 *                         continue
 *                     except NetworkError as e:
 *                         logger.error("Network error during screenshot sync for screenshot: %s", e)             # <<<<<<<<<<<<<<
 *                         logger.error("Context: file=%s, dest=%s%s", ss, self.s3_screenshot_path, self.screenshot_controller.format_ss_name(self.forward_ss(ss)))
 *                         # Skip this screenshot and continue processing
*/
                __pyx_t_21 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3475, __pyx_L80_error)
                __Pyx_GOTREF(__pyx_t_25);
                __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3475, __pyx_L80_error)
                __Pyx_GOTREF(__pyx_t_14);
                __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                __pyx_t_4 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_14))) {
                  __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_14);
                  assert(__pyx_t_21);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
                  __Pyx_INCREF(__pyx_t_21);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
                  __pyx_t_4 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_21, __pyx_mstate_global->__pyx_kp_u_Network_error_during_screenshot, __pyx_cur_scope->__pyx_v_e};
                  __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                  if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3475, __pyx_L80_error)
                  __Pyx_GOTREF(__pyx_t_13);
                }
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

                /* "ws_package/controllers/activity_controller.py":3476
 *                     except NetworkError as e:
 *                         logger.error("Network error during screenshot sync for screenshot: %s", e)
 *                         logger.error("Context: file=%s, dest=%s%s", ss, self.s3_screenshot_path, self.screenshot_controller.format_ss_name(self.forward_ss(ss)))             # <<<<<<<<<<<<<<
 *                         # Skip this screenshot and continue processing
 *                         continue
*/
                __pyx_t_14 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3476, __pyx_L80_error)
                __Pyx_GOTREF(__pyx_t_21);
                __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3476, __pyx_L80_error)
                __Pyx_GOTREF(__pyx_t_25);
                __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_s3_screenshot_path); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3476, __pyx_L80_error)
                __Pyx_GOTREF(__pyx_t_21);
                __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3476, __pyx_L80_error)
                __Pyx_GOTREF(__pyx_t_20);
                __pyx_t_24 = __pyx_t_20;
                __Pyx_INCREF(__pyx_t_24);
                __pyx_t_23 = __pyx_cur_scope->__pyx_v_self;
                __Pyx_INCREF(__pyx_t_23);
                __pyx_t_4 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_23, __pyx_cur_scope->__pyx_v_ss};
                  __pyx_t_26 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_forward_ss, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                  if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 3476, __pyx_L80_error)
                  __Pyx_GOTREF(__pyx_t_26);
                }
                __pyx_t_4 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_24, __pyx_t_26};
                  __pyx_t_28 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_format_ss_name, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                  __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                  if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 3476, __pyx_L80_error)
                  __Pyx_GOTREF(__pyx_t_28);
                }
                __pyx_t_4 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_25))) {
                  __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_25);
                  assert(__pyx_t_14);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_25);
                  __Pyx_INCREF(__pyx_t_14);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_25, __pyx__function);
                  __pyx_t_4 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[5] = {__pyx_t_14, __pyx_mstate_global->__pyx_kp_u_Context_file_s_dest_s_s, __pyx_cur_scope->__pyx_v_ss, __pyx_t_21, __pyx_t_28};
                  __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_25, __pyx_callargs+__pyx_t_4, (5-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                  __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
                  __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                  if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3476, __pyx_L80_error)
                  __Pyx_GOTREF(__pyx_t_13);
                }
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

                /* "ws_package/controllers/activity_controller.py":3478
 *                         logger.error("Context: file=%s, dest=%s%s", ss, self.s3_screenshot_path, self.screenshot_controller.format_ss_name(self.forward_ss(ss)))
 *                         # Skip this screenshot and continue processing
 *                         continue             # <<<<<<<<<<<<<<
 *                     except Exception as e:
 *                         error_message = str(e)
*/
                goto __pyx_L77_continue;
              }

              /* "ws_package/controllers/activity_controller.py":3474
 *                         # Skip this screenshot and continue processing
 *                         continue
 *                     except NetworkError as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Network error during screenshot sync for screenshot: %s", e)
 *                         logger.error("Context: file=%s, dest=%s%s", ss, self.s3_screenshot_path, self.screenshot_controller.format_ss_name(self.forward_ss(ss)))
*/
              /*finally:*/ {
                __pyx_L80_error:;
                /*exception exit:*/{
                  __Pyx_PyThreadState_assign
                  __pyx_t_32 = 0; __pyx_t_31 = 0; __pyx_t_30 = 0; __pyx_t_41 = 0; __pyx_t_40 = 0; __pyx_t_39 = 0;
                  __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                  __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                  __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                  __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                  __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                  __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                  __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                  __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
                   __Pyx_ExceptionSwap(&__pyx_t_41, &__pyx_t_40, &__pyx_t_39);
                  if ( unlikely(__Pyx_GetException(&__pyx_t_32, &__pyx_t_31, &__pyx_t_30) < 0)) __Pyx_ErrFetch(&__pyx_t_32, &__pyx_t_31, &__pyx_t_30);
                  __Pyx_XGOTREF(__pyx_t_32);
                  __Pyx_XGOTREF(__pyx_t_31);
                  __Pyx_XGOTREF(__pyx_t_30);
                  __Pyx_XGOTREF(__pyx_t_41);
                  __Pyx_XGOTREF(__pyx_t_40);
                  __Pyx_XGOTREF(__pyx_t_39);
                  __pyx_t_34 = __pyx_lineno; __pyx_t_33 = __pyx_clineno; __pyx_t_44 = __pyx_filename;
                  {
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  }
                  __Pyx_XGIVEREF(__pyx_t_41);
                  __Pyx_XGIVEREF(__pyx_t_40);
                  __Pyx_XGIVEREF(__pyx_t_39);
                  __Pyx_ExceptionReset(__pyx_t_41, __pyx_t_40, __pyx_t_39);
                  __Pyx_XGIVEREF(__pyx_t_32);
                  __Pyx_XGIVEREF(__pyx_t_31);
                  __Pyx_XGIVEREF(__pyx_t_30);
                  __Pyx_ErrRestore(__pyx_t_32, __pyx_t_31, __pyx_t_30);
                  __pyx_t_32 = 0; __pyx_t_31 = 0; __pyx_t_30 = 0; __pyx_t_41 = 0; __pyx_t_40 = 0; __pyx_t_39 = 0;
                  __pyx_lineno = __pyx_t_34; __pyx_clineno = __pyx_t_33; __pyx_filename = __pyx_t_44;
                  goto __pyx_L20_except_error;
                }
                __pyx_L77_continue: {
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  goto __pyx_L75_except_continue;
                }
              }
              __pyx_L75_except_continue:;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              goto __pyx_L24_try_continue;
            }

            /* "ws_package/controllers/activity_controller.py":3479
 *                         # Skip this screenshot and continue processing
 *                         continue
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         error_message = str(e)
 *                         if "S3_TIME_TAMPERING" in error_message or "RequestTimeTooSkewed" in error_message:
*/
            __pyx_t_33 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
            if (__pyx_t_33) {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.ss", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_16, &__pyx_t_3) < 0) __PYX_ERR(0, 3479, __pyx_L20_except_error)
              __Pyx_XGOTREF(__pyx_t_2);
              __Pyx_XGOTREF(__pyx_t_16);
              __Pyx_XGOTREF(__pyx_t_3);
              __Pyx_INCREF(__pyx_t_16);
              __Pyx_GIVEREF(__pyx_t_16);
              __pyx_cur_scope->__pyx_v_e = __pyx_t_16;
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":3480
 *                         continue
 *                     except Exception as e:
 *                         error_message = str(e)             # <<<<<<<<<<<<<<
 *                         if "S3_TIME_TAMPERING" in error_message or "RequestTimeTooSkewed" in error_message:
 *                             logger.error("S3 TIME TAMPERING DETECTED during screenshot upload: %s", error_message)
*/
                __pyx_t_13 = __Pyx_PyObject_Unicode(__pyx_cur_scope->__pyx_v_e); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3480, __pyx_L91_error)
                __Pyx_GOTREF(__pyx_t_13);
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_error_message);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_error_message, ((PyObject*)__pyx_t_13));
                __Pyx_GIVEREF(__pyx_t_13);
                __pyx_t_13 = 0;

                /* "ws_package/controllers/activity_controller.py":3481
 *                     except Exception as e:
 *                         error_message = str(e)
 *                         if "S3_TIME_TAMPERING" in error_message or "RequestTimeTooSkewed" in error_message:             # <<<<<<<<<<<<<<
 *                             logger.error("S3 TIME TAMPERING DETECTED during screenshot upload: %s", error_message)
 *                             self.handle_s3_time_error(error_message)
*/
                __pyx_t_15 = (__Pyx_PyUnicode_ContainsTF(__pyx_mstate_global->__pyx_n_u_S3_TIME_TAMPERING, __pyx_cur_scope->__pyx_v_error_message, Py_EQ)); if (unlikely((__pyx_t_15 < 0))) __PYX_ERR(0, 3481, __pyx_L91_error)
                if (!__pyx_t_15) {
                } else {
                  __pyx_t_8 = __pyx_t_15;
                  goto __pyx_L94_bool_binop_done;
                }
                __pyx_t_15 = (__Pyx_PyUnicode_ContainsTF(__pyx_mstate_global->__pyx_n_u_RequestTimeTooSkewed, __pyx_cur_scope->__pyx_v_error_message, Py_EQ)); if (unlikely((__pyx_t_15 < 0))) __PYX_ERR(0, 3481, __pyx_L91_error)
                __pyx_t_8 = __pyx_t_15;
                __pyx_L94_bool_binop_done:;
                if (__pyx_t_8) {

                  /* "ws_package/controllers/activity_controller.py":3482
 *                         error_message = str(e)
 *                         if "S3_TIME_TAMPERING" in error_message or "RequestTimeTooSkewed" in error_message:
 *                             logger.error("S3 TIME TAMPERING DETECTED during screenshot upload: %s", error_message)             # <<<<<<<<<<<<<<
 *                             self.handle_s3_time_error(error_message)
 *                         else:
*/
                  __pyx_t_25 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_28, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 3482, __pyx_L91_error)
                  __Pyx_GOTREF(__pyx_t_28);
                  __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_28, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3482, __pyx_L91_error)
                  __Pyx_GOTREF(__pyx_t_21);
                  __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
                  __pyx_t_4 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_21))) {
                    __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_21);
                    assert(__pyx_t_25);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_21);
                    __Pyx_INCREF(__pyx_t_25);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_21, __pyx__function);
                    __pyx_t_4 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[3] = {__pyx_t_25, __pyx_mstate_global->__pyx_kp_u_S3_TIME_TAMPERING_DETECTED_durin, __pyx_cur_scope->__pyx_v_error_message};
                    __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_21, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                    if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3482, __pyx_L91_error)
                    __Pyx_GOTREF(__pyx_t_13);
                  }
                  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

                  /* "ws_package/controllers/activity_controller.py":3483
 *                         if "S3_TIME_TAMPERING" in error_message or "RequestTimeTooSkewed" in error_message:
 *                             logger.error("S3 TIME TAMPERING DETECTED during screenshot upload: %s", error_message)
 *                             self.handle_s3_time_error(error_message)             # <<<<<<<<<<<<<<
 *                         else:
 *                             logger.error("Unexpected error during screenshot sync for screenshot: %s", e)
*/
                  __pyx_t_21 = __pyx_cur_scope->__pyx_v_self;
                  __Pyx_INCREF(__pyx_t_21);
                  __pyx_t_4 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_21, __pyx_cur_scope->__pyx_v_error_message};
                    __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_handle_s3_time_error, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                    if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3483, __pyx_L91_error)
                    __Pyx_GOTREF(__pyx_t_13);
                  }
                  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

                  /* "ws_package/controllers/activity_controller.py":3481
 *                     except Exception as e:
 *                         error_message = str(e)
 *                         if "S3_TIME_TAMPERING" in error_message or "RequestTimeTooSkewed" in error_message:             # <<<<<<<<<<<<<<
 *                             logger.error("S3 TIME TAMPERING DETECTED during screenshot upload: %s", error_message)
 *                             self.handle_s3_time_error(error_message)
*/
                  goto __pyx_L93;
                }

                /* "ws_package/controllers/activity_controller.py":3485
 *                             self.handle_s3_time_error(error_message)
 *                         else:
 *                             logger.error("Unexpected error during screenshot sync for screenshot: %s", e)             # <<<<<<<<<<<<<<
 *                             logger.error("Context: file=%s, dest=%s%s", ss, self.s3_screenshot_path, self.screenshot_controller.format_ss_name(self.forward_ss(ss)))
 *                         # Skip this screenshot and continue processing
*/
                /*else*/ {
                  __pyx_t_21 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3485, __pyx_L91_error)
                  __Pyx_GOTREF(__pyx_t_25);
                  __pyx_t_28 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 3485, __pyx_L91_error)
                  __Pyx_GOTREF(__pyx_t_28);
                  __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                  __pyx_t_4 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_28))) {
                    __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_28);
                    assert(__pyx_t_21);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_28);
                    __Pyx_INCREF(__pyx_t_21);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_28, __pyx__function);
                    __pyx_t_4 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[3] = {__pyx_t_21, __pyx_mstate_global->__pyx_kp_u_Unexpected_error_during_screensh, __pyx_cur_scope->__pyx_v_e};
                    __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_28, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
                    if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3485, __pyx_L91_error)
                    __Pyx_GOTREF(__pyx_t_13);
                  }
                  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

                  /* "ws_package/controllers/activity_controller.py":3486
 *                         else:
 *                             logger.error("Unexpected error during screenshot sync for screenshot: %s", e)
 *                             logger.error("Context: file=%s, dest=%s%s", ss, self.s3_screenshot_path, self.screenshot_controller.format_ss_name(self.forward_ss(ss)))             # <<<<<<<<<<<<<<
 *                         # Skip this screenshot and continue processing
 *                         continue
*/
                  __pyx_t_28 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3486, __pyx_L91_error)
                  __Pyx_GOTREF(__pyx_t_21);
                  __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3486, __pyx_L91_error)
                  __Pyx_GOTREF(__pyx_t_25);
                  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                  __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_s3_screenshot_path); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3486, __pyx_L91_error)
                  __Pyx_GOTREF(__pyx_t_21);
                  __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 3486, __pyx_L91_error)
                  __Pyx_GOTREF(__pyx_t_26);
                  __pyx_t_20 = __pyx_t_26;
                  __Pyx_INCREF(__pyx_t_20);
                  __pyx_t_23 = __pyx_cur_scope->__pyx_v_self;
                  __Pyx_INCREF(__pyx_t_23);
                  __pyx_t_4 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_23, __pyx_cur_scope->__pyx_v_ss};
                    __pyx_t_24 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_forward_ss, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                    if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3486, __pyx_L91_error)
                    __Pyx_GOTREF(__pyx_t_24);
                  }
                  __pyx_t_4 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_20, __pyx_t_24};
                    __pyx_t_14 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_format_ss_name, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                    __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                    if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3486, __pyx_L91_error)
                    __Pyx_GOTREF(__pyx_t_14);
                  }
                  __pyx_t_4 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_25))) {
                    __pyx_t_28 = PyMethod_GET_SELF(__pyx_t_25);
                    assert(__pyx_t_28);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_25);
                    __Pyx_INCREF(__pyx_t_28);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_25, __pyx__function);
                    __pyx_t_4 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[5] = {__pyx_t_28, __pyx_mstate_global->__pyx_kp_u_Context_file_s_dest_s_s, __pyx_cur_scope->__pyx_v_ss, __pyx_t_21, __pyx_t_14};
                    __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_25, __pyx_callargs+__pyx_t_4, (5-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
                    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                    if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3486, __pyx_L91_error)
                    __Pyx_GOTREF(__pyx_t_13);
                  }
                  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                }
                __pyx_L93:;

                /* "ws_package/controllers/activity_controller.py":3488
 *                             logger.error("Context: file=%s, dest=%s%s", ss, self.s3_screenshot_path, self.screenshot_controller.format_ss_name(self.forward_ss(ss)))
 *                         # Skip this screenshot and continue processing
 *                         continue             # <<<<<<<<<<<<<<
 * 
 *                     # Extract timestamp with error handling
*/
                goto __pyx_L88_continue;
              }

              /* "ws_package/controllers/activity_controller.py":3479
 *                         # Skip this screenshot and continue processing
 *                         continue
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         error_message = str(e)
 *                         if "S3_TIME_TAMPERING" in error_message or "RequestTimeTooSkewed" in error_message:
*/
              /*finally:*/ {
                __pyx_L91_error:;
                /*exception exit:*/{
                  __Pyx_PyThreadState_assign
                  __pyx_t_39 = 0; __pyx_t_40 = 0; __pyx_t_41 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0;
                  __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                  __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                  __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                  __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                  __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                  __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                  __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                  __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
                   __Pyx_ExceptionSwap(&__pyx_t_30, &__pyx_t_31, &__pyx_t_32);
                  if ( unlikely(__Pyx_GetException(&__pyx_t_39, &__pyx_t_40, &__pyx_t_41) < 0)) __Pyx_ErrFetch(&__pyx_t_39, &__pyx_t_40, &__pyx_t_41);
                  __Pyx_XGOTREF(__pyx_t_39);
                  __Pyx_XGOTREF(__pyx_t_40);
                  __Pyx_XGOTREF(__pyx_t_41);
                  __Pyx_XGOTREF(__pyx_t_30);
                  __Pyx_XGOTREF(__pyx_t_31);
                  __Pyx_XGOTREF(__pyx_t_32);
                  __pyx_t_33 = __pyx_lineno; __pyx_t_34 = __pyx_clineno; __pyx_t_45 = __pyx_filename;
                  {
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  }
                  __Pyx_XGIVEREF(__pyx_t_30);
                  __Pyx_XGIVEREF(__pyx_t_31);
                  __Pyx_XGIVEREF(__pyx_t_32);
                  __Pyx_ExceptionReset(__pyx_t_30, __pyx_t_31, __pyx_t_32);
                  __Pyx_XGIVEREF(__pyx_t_39);
                  __Pyx_XGIVEREF(__pyx_t_40);
                  __Pyx_XGIVEREF(__pyx_t_41);
                  __Pyx_ErrRestore(__pyx_t_39, __pyx_t_40, __pyx_t_41);
                  __pyx_t_39 = 0; __pyx_t_40 = 0; __pyx_t_41 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0;
                  __pyx_lineno = __pyx_t_33; __pyx_clineno = __pyx_t_34; __pyx_filename = __pyx_t_45;
                  goto __pyx_L20_except_error;
                }
                __pyx_L88_continue: {
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  goto __pyx_L86_except_continue;
                }
              }
              __pyx_L86_except_continue:;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              goto __pyx_L24_try_continue;
            }
            goto __pyx_L20_except_error;

            /* "ws_package/controllers/activity_controller.py":3432
 *                         continue
 * 
 *                     try:             # <<<<<<<<<<<<<<
 *                         task = asyncio.create_task(
 *                             self.screenshot_controller.screenshot_service.sync(
*/
            __pyx_L20_except_error:;
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_XGIVEREF(__pyx_t_19);
            __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19);
            goto __pyx_L8_error;
            __pyx_L24_try_continue:;
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_XGIVEREF(__pyx_t_19);
            __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19);
            goto __pyx_L14_try_continue;
            __pyx_L25_try_end:;
          }

          /* "ws_package/controllers/activity_controller.py":3491
 * 
 *                     # Extract timestamp with error handling
 *                     try:             # <<<<<<<<<<<<<<
 *                         particular_timestamp = self.screenshot_controller.extract_datetime_from_filename(ss)
 *                     except Exception as e:
*/
          {
            __Pyx_ExceptionSave(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17);
            __Pyx_XGOTREF(__pyx_t_19);
            __Pyx_XGOTREF(__pyx_t_18);
            __Pyx_XGOTREF(__pyx_t_17);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":3492
 *                     # Extract timestamp with error handling
 *                     try:
 *                         particular_timestamp = self.screenshot_controller.extract_datetime_from_filename(ss)             # <<<<<<<<<<<<<<
 *                     except Exception as e:
 *                         logger.warning("Failed to extract timestamp from filename %s: %s", ss, e)
*/
              __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3492, __pyx_L100_error)
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_t_16 = __pyx_t_2;
              __Pyx_INCREF(__pyx_t_16);
              __pyx_t_4 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_16, __pyx_cur_scope->__pyx_v_ss};
                __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_extract_datetime_from_filename, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3492, __pyx_L100_error)
                __Pyx_GOTREF(__pyx_t_3);
              }
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_particular_timestamp);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_particular_timestamp, __pyx_t_3);
              __Pyx_GIVEREF(__pyx_t_3);
              __pyx_t_3 = 0;

              /* "ws_package/controllers/activity_controller.py":3491
 * 
 *                     # Extract timestamp with error handling
 *                     try:             # <<<<<<<<<<<<<<
 *                         particular_timestamp = self.screenshot_controller.extract_datetime_from_filename(ss)
 *                     except Exception as e:
*/
            }
            __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
            goto __pyx_L107_try_end;
            __pyx_L100_error:;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
            __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
            __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
            __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
            __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
            __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
            __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
            __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

            /* "ws_package/controllers/activity_controller.py":3493
 *                     try:
 *                         particular_timestamp = self.screenshot_controller.extract_datetime_from_filename(ss)
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.warning("Failed to extract timestamp from filename %s: %s", ss, e)
 *                         particular_timestamp = datetime.datetime.now()
*/
            __pyx_t_34 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
            if (__pyx_t_34) {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.ss", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_2, &__pyx_t_16) < 0) __PYX_ERR(0, 3493, __pyx_L102_except_error)
              __Pyx_XGOTREF(__pyx_t_3);
              __Pyx_XGOTREF(__pyx_t_2);
              __Pyx_XGOTREF(__pyx_t_16);
              __Pyx_INCREF(__pyx_t_2);
              __Pyx_GIVEREF(__pyx_t_2);
              __pyx_cur_scope->__pyx_v_e = __pyx_t_2;
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":3494
 *                         particular_timestamp = self.screenshot_controller.extract_datetime_from_filename(ss)
 *                     except Exception as e:
 *                         logger.warning("Failed to extract timestamp from filename %s: %s", ss, e)             # <<<<<<<<<<<<<<
 *                         particular_timestamp = datetime.datetime.now()
 * 
*/
                __pyx_t_25 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3494, __pyx_L113_error)
                __Pyx_GOTREF(__pyx_t_14);
                __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3494, __pyx_L113_error)
                __Pyx_GOTREF(__pyx_t_21);
                __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                __pyx_t_4 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_21))) {
                  __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_21);
                  assert(__pyx_t_25);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_21);
                  __Pyx_INCREF(__pyx_t_25);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_21, __pyx__function);
                  __pyx_t_4 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[4] = {__pyx_t_25, __pyx_mstate_global->__pyx_kp_u_Failed_to_extract_timestamp_from, __pyx_cur_scope->__pyx_v_ss, __pyx_cur_scope->__pyx_v_e};
                  __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_21, __pyx_callargs+__pyx_t_4, (4-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                  if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3494, __pyx_L113_error)
                  __Pyx_GOTREF(__pyx_t_13);
                }
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

                /* "ws_package/controllers/activity_controller.py":3495
 *                     except Exception as e:
 *                         logger.warning("Failed to extract timestamp from filename %s: %s", ss, e)
 *                         particular_timestamp = datetime.datetime.now()             # <<<<<<<<<<<<<<
 * 
 *                     screenshot_entity = ScreenshotEntity(
*/
                __Pyx_GetModuleGlobalName(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3495, __pyx_L113_error)
                __Pyx_GOTREF(__pyx_t_25);
                __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3495, __pyx_L113_error)
                __Pyx_GOTREF(__pyx_t_14);
                __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                __pyx_t_21 = __pyx_t_14;
                __Pyx_INCREF(__pyx_t_21);
                __pyx_t_4 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_21, NULL};
                  __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                  if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3495, __pyx_L113_error)
                  __Pyx_GOTREF(__pyx_t_13);
                }
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_particular_timestamp);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_particular_timestamp, __pyx_t_13);
                __Pyx_GIVEREF(__pyx_t_13);
                __pyx_t_13 = 0;
              }

              /* "ws_package/controllers/activity_controller.py":3493
 *                     try:
 *                         particular_timestamp = self.screenshot_controller.extract_datetime_from_filename(ss)
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.warning("Failed to extract timestamp from filename %s: %s", ss, e)
 *                         particular_timestamp = datetime.datetime.now()
*/
              /*finally:*/ {
                /*normal exit:*/{
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  goto __pyx_L114;
                }
                __pyx_L113_error:;
                /*exception exit:*/{
                  __Pyx_PyThreadState_assign
                  __pyx_t_32 = 0; __pyx_t_31 = 0; __pyx_t_30 = 0; __pyx_t_41 = 0; __pyx_t_40 = 0; __pyx_t_39 = 0;
                  __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                  __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                  __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                  __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                  __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                  __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                  __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                  __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
                   __Pyx_ExceptionSwap(&__pyx_t_41, &__pyx_t_40, &__pyx_t_39);
                  if ( unlikely(__Pyx_GetException(&__pyx_t_32, &__pyx_t_31, &__pyx_t_30) < 0)) __Pyx_ErrFetch(&__pyx_t_32, &__pyx_t_31, &__pyx_t_30);
                  __Pyx_XGOTREF(__pyx_t_32);
                  __Pyx_XGOTREF(__pyx_t_31);
                  __Pyx_XGOTREF(__pyx_t_30);
                  __Pyx_XGOTREF(__pyx_t_41);
                  __Pyx_XGOTREF(__pyx_t_40);
                  __Pyx_XGOTREF(__pyx_t_39);
                  __pyx_t_34 = __pyx_lineno; __pyx_t_33 = __pyx_clineno; __pyx_t_46 = __pyx_filename;
                  {
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  }
                  __Pyx_XGIVEREF(__pyx_t_41);
                  __Pyx_XGIVEREF(__pyx_t_40);
                  __Pyx_XGIVEREF(__pyx_t_39);
                  __Pyx_ExceptionReset(__pyx_t_41, __pyx_t_40, __pyx_t_39);
                  __Pyx_XGIVEREF(__pyx_t_32);
                  __Pyx_XGIVEREF(__pyx_t_31);
                  __Pyx_XGIVEREF(__pyx_t_30);
                  __Pyx_ErrRestore(__pyx_t_32, __pyx_t_31, __pyx_t_30);
                  __pyx_t_32 = 0; __pyx_t_31 = 0; __pyx_t_30 = 0; __pyx_t_41 = 0; __pyx_t_40 = 0; __pyx_t_39 = 0;
                  __pyx_lineno = __pyx_t_34; __pyx_clineno = __pyx_t_33; __pyx_filename = __pyx_t_46;
                  goto __pyx_L102_except_error;
                }
                __pyx_L114:;
              }
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
              goto __pyx_L101_exception_handled;
            }
            goto __pyx_L102_except_error;

            /* "ws_package/controllers/activity_controller.py":3491
 * 
 *                     # Extract timestamp with error handling
 *                     try:             # <<<<<<<<<<<<<<
 *                         particular_timestamp = self.screenshot_controller.extract_datetime_from_filename(ss)
 *                     except Exception as e:
*/
            __pyx_L102_except_error:;
            __Pyx_XGIVEREF(__pyx_t_19);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_18, __pyx_t_17);
            goto __pyx_L8_error;
            __pyx_L101_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_19);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_18, __pyx_t_17);
            __pyx_L107_try_end:;
          }

          /* "ws_package/controllers/activity_controller.py":3497
 *                         particular_timestamp = datetime.datetime.now()
 * 
 *                     screenshot_entity = ScreenshotEntity(             # <<<<<<<<<<<<<<
 *                         file_name=ss,
 *                         blur=True,
*/
          __pyx_t_2 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_ScreenshotEntity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3497, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_3);

          /* "ws_package/controllers/activity_controller.py":3501
 *                         blur=True,
 *                         s3_upload_link=s3_upload_link,
 *                         file_size=str(0000),             # <<<<<<<<<<<<<<
 *                         is_uploaded=False,
 *                         file_location=ss,
*/
          __pyx_t_13 = __Pyx_PyObject_Unicode(__pyx_mstate_global->__pyx_int_0); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3501, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_13);

          /* "ws_package/controllers/activity_controller.py":3506
 *                         timestamp=particular_timestamp,
 *                         is_s3_uploaded=True,
 *                         counter=self.last_count+1             # <<<<<<<<<<<<<<
 *                     )
 * 
*/
          __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3506, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_14);
          __pyx_t_21 = __Pyx_PyLong_AddObjC(__pyx_t_14, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3506, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_21);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __pyx_t_4 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_3))) {
            __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
            assert(__pyx_t_2);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_2);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
            __pyx_t_4 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 9 : 0)] = {__pyx_t_2, NULL};
            __pyx_t_14 = __Pyx_MakeVectorcallBuilderKwds(9); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3497, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_14);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_file_name, __pyx_cur_scope->__pyx_v_ss, __pyx_t_14, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 3497, __pyx_L8_error)
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_blur, Py_True, __pyx_t_14, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 3497, __pyx_L8_error)
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_s3_upload_link, __pyx_cur_scope->__pyx_v_s3_upload_link, __pyx_t_14, __pyx_callargs+1, 2) < (0)) __PYX_ERR(0, 3497, __pyx_L8_error)
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_file_size, __pyx_t_13, __pyx_t_14, __pyx_callargs+1, 3) < (0)) __PYX_ERR(0, 3497, __pyx_L8_error)
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_is_uploaded, Py_False, __pyx_t_14, __pyx_callargs+1, 4) < (0)) __PYX_ERR(0, 3497, __pyx_L8_error)
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_file_location, __pyx_cur_scope->__pyx_v_ss, __pyx_t_14, __pyx_callargs+1, 5) < (0)) __PYX_ERR(0, 3497, __pyx_L8_error)
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_timestamp, __pyx_cur_scope->__pyx_v_particular_timestamp, __pyx_t_14, __pyx_callargs+1, 6) < (0)) __PYX_ERR(0, 3497, __pyx_L8_error)
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_is_s3_uploaded, Py_True, __pyx_t_14, __pyx_callargs+1, 7) < (0)) __PYX_ERR(0, 3497, __pyx_L8_error)
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_counter, __pyx_t_21, __pyx_t_14, __pyx_callargs+1, 8) < (0)) __PYX_ERR(0, 3497, __pyx_L8_error)
            __pyx_t_16 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_14);
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3497, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_16);
          }
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_screenshot_entity);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_screenshot_entity, __pyx_t_16);
          __Pyx_GIVEREF(__pyx_t_16);
          __pyx_t_16 = 0;

          /* "ws_package/controllers/activity_controller.py":3422
 * 
 *             else:
 *                 try:             # <<<<<<<<<<<<<<
 *                     # Validate screenshot file exists and is accessible
 *                     if not os.path.exists(ss):
*/
        }
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        goto __pyx_L15_try_end;
        __pyx_L8_error:;
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
        __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
        __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
        __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
        __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
        __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
        __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
        __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
        __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "ws_package/controllers/activity_controller.py":3509
 *                     )
 * 
 *                 except FileNotFoundError as e:             # <<<<<<<<<<<<<<
 *                     logger.warning("Screenshot file not found: %s - %s", ss, e)
 *                     continue
*/
        __pyx_t_33 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_FileNotFoundError))));
        if (__pyx_t_33) {
          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.ss", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_16, &__pyx_t_3, &__pyx_t_14) < 0) __PYX_ERR(0, 3509, __pyx_L10_except_error)
          __Pyx_XGOTREF(__pyx_t_16);
          __Pyx_XGOTREF(__pyx_t_3);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_3);
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":3510
 * 
 *                 except FileNotFoundError as e:
 *                     logger.warning("Screenshot file not found: %s - %s", ss, e)             # <<<<<<<<<<<<<<
 *                     continue
 *                 except PermissionError as e:
*/
            __pyx_t_13 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3510, __pyx_L124_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3510, __pyx_L124_error)
            __Pyx_GOTREF(__pyx_t_25);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_25))) {
              __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_25);
              assert(__pyx_t_13);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_25);
              __Pyx_INCREF(__pyx_t_13);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_25, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[4] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Screenshot_file_not_found_s_s, __pyx_cur_scope->__pyx_v_ss, __pyx_cur_scope->__pyx_v_e};
              __pyx_t_21 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_25, __pyx_callargs+__pyx_t_4, (4-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
              if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3510, __pyx_L124_error)
              __Pyx_GOTREF(__pyx_t_21);
            }
            __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;

            /* "ws_package/controllers/activity_controller.py":3511
 *                 except FileNotFoundError as e:
 *                     logger.warning("Screenshot file not found: %s - %s", ss, e)
 *                     continue             # <<<<<<<<<<<<<<
 *                 except PermissionError as e:
 *                     logger.warning("Permission denied accessing screenshot: %s - %s", ss, e)
*/
            goto __pyx_L121_continue;
          }

          /* "ws_package/controllers/activity_controller.py":3509
 *                     )
 * 
 *                 except FileNotFoundError as e:             # <<<<<<<<<<<<<<
 *                     logger.warning("Screenshot file not found: %s - %s", ss, e)
 *                     continue
*/
          /*finally:*/ {
            __pyx_L124_error:;
            /*exception exit:*/{
              __Pyx_PyThreadState_assign
              __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_39 = 0; __pyx_t_40 = 0; __pyx_t_41 = 0;
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
              __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
              __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
              __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
              __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
              __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
               __Pyx_ExceptionSwap(&__pyx_t_39, &__pyx_t_40, &__pyx_t_41);
              if ( unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
              __Pyx_XGOTREF(__pyx_t_17);
              __Pyx_XGOTREF(__pyx_t_18);
              __Pyx_XGOTREF(__pyx_t_19);
              __Pyx_XGOTREF(__pyx_t_39);
              __Pyx_XGOTREF(__pyx_t_40);
              __Pyx_XGOTREF(__pyx_t_41);
              __pyx_t_33 = __pyx_lineno; __pyx_t_34 = __pyx_clineno; __pyx_t_47 = __pyx_filename;
              {
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
              }
              __Pyx_XGIVEREF(__pyx_t_39);
              __Pyx_XGIVEREF(__pyx_t_40);
              __Pyx_XGIVEREF(__pyx_t_41);
              __Pyx_ExceptionReset(__pyx_t_39, __pyx_t_40, __pyx_t_41);
              __Pyx_XGIVEREF(__pyx_t_17);
              __Pyx_XGIVEREF(__pyx_t_18);
              __Pyx_XGIVEREF(__pyx_t_19);
              __Pyx_ErrRestore(__pyx_t_17, __pyx_t_18, __pyx_t_19);
              __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_39 = 0; __pyx_t_40 = 0; __pyx_t_41 = 0;
              __pyx_lineno = __pyx_t_33; __pyx_clineno = __pyx_t_34; __pyx_filename = __pyx_t_47;
              goto __pyx_L10_except_error;
            }
            __pyx_L121_continue: {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
              goto __pyx_L119_except_continue;
            }
          }
          __pyx_L119_except_continue:;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          goto __pyx_L14_try_continue;
        }

        /* "ws_package/controllers/activity_controller.py":3512
 *                     logger.warning("Screenshot file not found: %s - %s", ss, e)
 *                     continue
 *                 except PermissionError as e:             # <<<<<<<<<<<<<<
 *                     logger.warning("Permission denied accessing screenshot: %s - %s", ss, e)
 *                     continue
*/
        __pyx_t_34 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_PermissionError))));
        if (__pyx_t_34) {
          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.ss", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_14, &__pyx_t_3, &__pyx_t_16) < 0) __PYX_ERR(0, 3512, __pyx_L10_except_error)
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_3);
          __Pyx_XGOTREF(__pyx_t_16);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_3);
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":3513
 *                     continue
 *                 except PermissionError as e:
 *                     logger.warning("Permission denied accessing screenshot: %s - %s", ss, e)             # <<<<<<<<<<<<<<
 *                     continue
 *                 except OSError as e:
*/
            __pyx_t_25 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3513, __pyx_L135_error)
            __Pyx_GOTREF(__pyx_t_13);
            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3513, __pyx_L135_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_2))) {
              __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_2);
              assert(__pyx_t_25);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_25);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[4] = {__pyx_t_25, __pyx_mstate_global->__pyx_kp_u_Permission_denied_accessing_scre, __pyx_cur_scope->__pyx_v_ss, __pyx_cur_scope->__pyx_v_e};
              __pyx_t_21 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_4, (4-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3513, __pyx_L135_error)
              __Pyx_GOTREF(__pyx_t_21);
            }
            __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;

            /* "ws_package/controllers/activity_controller.py":3514
 *                 except PermissionError as e:
 *                     logger.warning("Permission denied accessing screenshot: %s - %s", ss, e)
 *                     continue             # <<<<<<<<<<<<<<
 *                 except OSError as e:
 *                     logger.warning("OS error accessing screenshot: %s - %s", ss, e)
*/
            goto __pyx_L132_continue;
          }

          /* "ws_package/controllers/activity_controller.py":3512
 *                     logger.warning("Screenshot file not found: %s - %s", ss, e)
 *                     continue
 *                 except PermissionError as e:             # <<<<<<<<<<<<<<
 *                     logger.warning("Permission denied accessing screenshot: %s - %s", ss, e)
 *                     continue
*/
          /*finally:*/ {
            __pyx_L135_error:;
            /*exception exit:*/{
              __Pyx_PyThreadState_assign
              __pyx_t_41 = 0; __pyx_t_40 = 0; __pyx_t_39 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0;
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
              __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
              __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
              __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
              __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
              __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
               __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17);
              if ( unlikely(__Pyx_GetException(&__pyx_t_41, &__pyx_t_40, &__pyx_t_39) < 0)) __Pyx_ErrFetch(&__pyx_t_41, &__pyx_t_40, &__pyx_t_39);
              __Pyx_XGOTREF(__pyx_t_41);
              __Pyx_XGOTREF(__pyx_t_40);
              __Pyx_XGOTREF(__pyx_t_39);
              __Pyx_XGOTREF(__pyx_t_19);
              __Pyx_XGOTREF(__pyx_t_18);
              __Pyx_XGOTREF(__pyx_t_17);
              __pyx_t_34 = __pyx_lineno; __pyx_t_33 = __pyx_clineno; __pyx_t_48 = __pyx_filename;
              {
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
              }
              __Pyx_XGIVEREF(__pyx_t_19);
              __Pyx_XGIVEREF(__pyx_t_18);
              __Pyx_XGIVEREF(__pyx_t_17);
              __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_18, __pyx_t_17);
              __Pyx_XGIVEREF(__pyx_t_41);
              __Pyx_XGIVEREF(__pyx_t_40);
              __Pyx_XGIVEREF(__pyx_t_39);
              __Pyx_ErrRestore(__pyx_t_41, __pyx_t_40, __pyx_t_39);
              __pyx_t_41 = 0; __pyx_t_40 = 0; __pyx_t_39 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0;
              __pyx_lineno = __pyx_t_34; __pyx_clineno = __pyx_t_33; __pyx_filename = __pyx_t_48;
              goto __pyx_L10_except_error;
            }
            __pyx_L132_continue: {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
              goto __pyx_L130_except_continue;
            }
          }
          __pyx_L130_except_continue:;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          goto __pyx_L14_try_continue;
        }

        /* "ws_package/controllers/activity_controller.py":3515
 *                     logger.warning("Permission denied accessing screenshot: %s - %s", ss, e)
 *                     continue
 *                 except OSError as e:             # <<<<<<<<<<<<<<
 *                     logger.warning("OS error accessing screenshot: %s - %s", ss, e)
 *                     continue
*/
        __pyx_t_33 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_OSError))));
        if (__pyx_t_33) {
          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.ss", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_16, &__pyx_t_3, &__pyx_t_14) < 0) __PYX_ERR(0, 3515, __pyx_L10_except_error)
          __Pyx_XGOTREF(__pyx_t_16);
          __Pyx_XGOTREF(__pyx_t_3);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_3);
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":3516
 *                     continue
 *                 except OSError as e:
 *                     logger.warning("OS error accessing screenshot: %s - %s", ss, e)             # <<<<<<<<<<<<<<
 *                     continue
 *                 except APIError as e:
*/
            __pyx_t_2 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3516, __pyx_L146_error)
            __Pyx_GOTREF(__pyx_t_25);
            __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3516, __pyx_L146_error)
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_13))) {
              __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_13);
              assert(__pyx_t_2);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
              __Pyx_INCREF(__pyx_t_2);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[4] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_OS_error_accessing_screenshot_s, __pyx_cur_scope->__pyx_v_ss, __pyx_cur_scope->__pyx_v_e};
              __pyx_t_21 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_4, (4-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3516, __pyx_L146_error)
              __Pyx_GOTREF(__pyx_t_21);
            }
            __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;

            /* "ws_package/controllers/activity_controller.py":3517
 *                 except OSError as e:
 *                     logger.warning("OS error accessing screenshot: %s - %s", ss, e)
 *                     continue             # <<<<<<<<<<<<<<
 *                 except APIError as e:
 *                     logger.error("API error uploading screenshot %s: %s", ss, e)
*/
            goto __pyx_L143_continue;
          }

          /* "ws_package/controllers/activity_controller.py":3515
 *                     logger.warning("Permission denied accessing screenshot: %s - %s", ss, e)
 *                     continue
 *                 except OSError as e:             # <<<<<<<<<<<<<<
 *                     logger.warning("OS error accessing screenshot: %s - %s", ss, e)
 *                     continue
*/
          /*finally:*/ {
            __pyx_L146_error:;
            /*exception exit:*/{
              __Pyx_PyThreadState_assign
              __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_39 = 0; __pyx_t_40 = 0; __pyx_t_41 = 0;
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
              __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
              __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
              __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
              __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
              __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
               __Pyx_ExceptionSwap(&__pyx_t_39, &__pyx_t_40, &__pyx_t_41);
              if ( unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
              __Pyx_XGOTREF(__pyx_t_17);
              __Pyx_XGOTREF(__pyx_t_18);
              __Pyx_XGOTREF(__pyx_t_19);
              __Pyx_XGOTREF(__pyx_t_39);
              __Pyx_XGOTREF(__pyx_t_40);
              __Pyx_XGOTREF(__pyx_t_41);
              __pyx_t_33 = __pyx_lineno; __pyx_t_34 = __pyx_clineno; __pyx_t_49 = __pyx_filename;
              {
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
              }
              __Pyx_XGIVEREF(__pyx_t_39);
              __Pyx_XGIVEREF(__pyx_t_40);
              __Pyx_XGIVEREF(__pyx_t_41);
              __Pyx_ExceptionReset(__pyx_t_39, __pyx_t_40, __pyx_t_41);
              __Pyx_XGIVEREF(__pyx_t_17);
              __Pyx_XGIVEREF(__pyx_t_18);
              __Pyx_XGIVEREF(__pyx_t_19);
              __Pyx_ErrRestore(__pyx_t_17, __pyx_t_18, __pyx_t_19);
              __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_39 = 0; __pyx_t_40 = 0; __pyx_t_41 = 0;
              __pyx_lineno = __pyx_t_33; __pyx_clineno = __pyx_t_34; __pyx_filename = __pyx_t_49;
              goto __pyx_L10_except_error;
            }
            __pyx_L143_continue: {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
              goto __pyx_L141_except_continue;
            }
          }
          __pyx_L141_except_continue:;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          goto __pyx_L14_try_continue;
        }

        /* "ws_package/controllers/activity_controller.py":3518
 *                     logger.warning("OS error accessing screenshot: %s - %s", ss, e)
 *                     continue
 *                 except APIError as e:             # <<<<<<<<<<<<<<
 *                     logger.error("API error uploading screenshot %s: %s", ss, e)
 *                     continue
*/
        __Pyx_ErrFetch(&__pyx_t_14, &__pyx_t_3, &__pyx_t_16);
        __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_APIError); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3518, __pyx_L10_except_error)
        __Pyx_GOTREF(__pyx_t_21);
        __pyx_t_34 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_14, __pyx_t_21);
        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
        __Pyx_ErrRestore(__pyx_t_14, __pyx_t_3, __pyx_t_16);
        __pyx_t_14 = 0; __pyx_t_3 = 0; __pyx_t_16 = 0;
        if (__pyx_t_34) {
          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.ss", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_16, &__pyx_t_3, &__pyx_t_14) < 0) __PYX_ERR(0, 3518, __pyx_L10_except_error)
          __Pyx_XGOTREF(__pyx_t_16);
          __Pyx_XGOTREF(__pyx_t_3);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_3);
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":3519
 *                     continue
 *                 except APIError as e:
 *                     logger.error("API error uploading screenshot %s: %s", ss, e)             # <<<<<<<<<<<<<<
 *                     continue
 *                 except NetworkError as e:
*/
            __pyx_t_13 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3519, __pyx_L157_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3519, __pyx_L157_error)
            __Pyx_GOTREF(__pyx_t_25);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_25))) {
              __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_25);
              assert(__pyx_t_13);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_25);
              __Pyx_INCREF(__pyx_t_13);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_25, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[4] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_API_error_uploading_screenshot_s, __pyx_cur_scope->__pyx_v_ss, __pyx_cur_scope->__pyx_v_e};
              __pyx_t_21 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_25, __pyx_callargs+__pyx_t_4, (4-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
              if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3519, __pyx_L157_error)
              __Pyx_GOTREF(__pyx_t_21);
            }
            __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;

            /* "ws_package/controllers/activity_controller.py":3520
 *                 except APIError as e:
 *                     logger.error("API error uploading screenshot %s: %s", ss, e)
 *                     continue             # <<<<<<<<<<<<<<
 *                 except NetworkError as e:
 *                     logger.error("Network error uploading screenshot %s: %s", ss, e)
*/
            goto __pyx_L154_continue;
          }

          /* "ws_package/controllers/activity_controller.py":3518
 *                     logger.warning("OS error accessing screenshot: %s - %s", ss, e)
 *                     continue
 *                 except APIError as e:             # <<<<<<<<<<<<<<
 *                     logger.error("API error uploading screenshot %s: %s", ss, e)
 *                     continue
*/
          /*finally:*/ {
            __pyx_L157_error:;
            /*exception exit:*/{
              __Pyx_PyThreadState_assign
              __pyx_t_41 = 0; __pyx_t_40 = 0; __pyx_t_39 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0;
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
              __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
              __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
              __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
              __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
              __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
               __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17);
              if ( unlikely(__Pyx_GetException(&__pyx_t_41, &__pyx_t_40, &__pyx_t_39) < 0)) __Pyx_ErrFetch(&__pyx_t_41, &__pyx_t_40, &__pyx_t_39);
              __Pyx_XGOTREF(__pyx_t_41);
              __Pyx_XGOTREF(__pyx_t_40);
              __Pyx_XGOTREF(__pyx_t_39);
              __Pyx_XGOTREF(__pyx_t_19);
              __Pyx_XGOTREF(__pyx_t_18);
              __Pyx_XGOTREF(__pyx_t_17);
              __pyx_t_34 = __pyx_lineno; __pyx_t_33 = __pyx_clineno; __pyx_t_50 = __pyx_filename;
              {
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
              }
              __Pyx_XGIVEREF(__pyx_t_19);
              __Pyx_XGIVEREF(__pyx_t_18);
              __Pyx_XGIVEREF(__pyx_t_17);
              __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_18, __pyx_t_17);
              __Pyx_XGIVEREF(__pyx_t_41);
              __Pyx_XGIVEREF(__pyx_t_40);
              __Pyx_XGIVEREF(__pyx_t_39);
              __Pyx_ErrRestore(__pyx_t_41, __pyx_t_40, __pyx_t_39);
              __pyx_t_41 = 0; __pyx_t_40 = 0; __pyx_t_39 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0;
              __pyx_lineno = __pyx_t_34; __pyx_clineno = __pyx_t_33; __pyx_filename = __pyx_t_50;
              goto __pyx_L10_except_error;
            }
            __pyx_L154_continue: {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
              goto __pyx_L152_except_continue;
            }
          }
          __pyx_L152_except_continue:;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          goto __pyx_L14_try_continue;
        }

        /* "ws_package/controllers/activity_controller.py":3521
 *                     logger.error("API error uploading screenshot %s: %s", ss, e)
 *                     continue
 *                 except NetworkError as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Network error uploading screenshot %s: %s", ss, e)
 *                     continue
*/
        __Pyx_ErrFetch(&__pyx_t_14, &__pyx_t_3, &__pyx_t_16);
        __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_NetworkError); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3521, __pyx_L10_except_error)
        __Pyx_GOTREF(__pyx_t_21);
        __pyx_t_33 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_14, __pyx_t_21);
        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
        __Pyx_ErrRestore(__pyx_t_14, __pyx_t_3, __pyx_t_16);
        __pyx_t_14 = 0; __pyx_t_3 = 0; __pyx_t_16 = 0;
        if (__pyx_t_33) {
          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.ss", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_16, &__pyx_t_3, &__pyx_t_14) < 0) __PYX_ERR(0, 3521, __pyx_L10_except_error)
          __Pyx_XGOTREF(__pyx_t_16);
          __Pyx_XGOTREF(__pyx_t_3);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_3);
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":3522
 *                     continue
 *                 except NetworkError as e:
 *                     logger.error("Network error uploading screenshot %s: %s", ss, e)             # <<<<<<<<<<<<<<
 *                     continue
 *                 except ValidationError as e:
*/
            __pyx_t_25 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3522, __pyx_L168_error)
            __Pyx_GOTREF(__pyx_t_13);
            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3522, __pyx_L168_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_2))) {
              __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_2);
              assert(__pyx_t_25);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_25);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[4] = {__pyx_t_25, __pyx_mstate_global->__pyx_kp_u_Network_error_uploading_screensh, __pyx_cur_scope->__pyx_v_ss, __pyx_cur_scope->__pyx_v_e};
              __pyx_t_21 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_4, (4-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3522, __pyx_L168_error)
              __Pyx_GOTREF(__pyx_t_21);
            }
            __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;

            /* "ws_package/controllers/activity_controller.py":3523
 *                 except NetworkError as e:
 *                     logger.error("Network error uploading screenshot %s: %s", ss, e)
 *                     continue             # <<<<<<<<<<<<<<
 *                 except ValidationError as e:
 *                     logger.error("Validation error with screenshot %s: %s", ss, e)
*/
            goto __pyx_L165_continue;
          }

          /* "ws_package/controllers/activity_controller.py":3521
 *                     logger.error("API error uploading screenshot %s: %s", ss, e)
 *                     continue
 *                 except NetworkError as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Network error uploading screenshot %s: %s", ss, e)
 *                     continue
*/
          /*finally:*/ {
            __pyx_L168_error:;
            /*exception exit:*/{
              __Pyx_PyThreadState_assign
              __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_39 = 0; __pyx_t_40 = 0; __pyx_t_41 = 0;
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
              __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
              __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
              __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
              __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
              __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
               __Pyx_ExceptionSwap(&__pyx_t_39, &__pyx_t_40, &__pyx_t_41);
              if ( unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
              __Pyx_XGOTREF(__pyx_t_17);
              __Pyx_XGOTREF(__pyx_t_18);
              __Pyx_XGOTREF(__pyx_t_19);
              __Pyx_XGOTREF(__pyx_t_39);
              __Pyx_XGOTREF(__pyx_t_40);
              __Pyx_XGOTREF(__pyx_t_41);
              __pyx_t_33 = __pyx_lineno; __pyx_t_34 = __pyx_clineno; __pyx_t_51 = __pyx_filename;
              {
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
              }
              __Pyx_XGIVEREF(__pyx_t_39);
              __Pyx_XGIVEREF(__pyx_t_40);
              __Pyx_XGIVEREF(__pyx_t_41);
              __Pyx_ExceptionReset(__pyx_t_39, __pyx_t_40, __pyx_t_41);
              __Pyx_XGIVEREF(__pyx_t_17);
              __Pyx_XGIVEREF(__pyx_t_18);
              __Pyx_XGIVEREF(__pyx_t_19);
              __Pyx_ErrRestore(__pyx_t_17, __pyx_t_18, __pyx_t_19);
              __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_39 = 0; __pyx_t_40 = 0; __pyx_t_41 = 0;
              __pyx_lineno = __pyx_t_33; __pyx_clineno = __pyx_t_34; __pyx_filename = __pyx_t_51;
              goto __pyx_L10_except_error;
            }
            __pyx_L165_continue: {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
              goto __pyx_L163_except_continue;
            }
          }
          __pyx_L163_except_continue:;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          goto __pyx_L14_try_continue;
        }

        /* "ws_package/controllers/activity_controller.py":3524
 *                     logger.error("Network error uploading screenshot %s: %s", ss, e)
 *                     continue
 *                 except ValidationError as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Validation error with screenshot %s: %s", ss, e)
 *                     continue
*/
        __Pyx_ErrFetch(&__pyx_t_14, &__pyx_t_3, &__pyx_t_16);
        __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_ValidationError); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3524, __pyx_L10_except_error)
        __Pyx_GOTREF(__pyx_t_21);
        __pyx_t_34 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_14, __pyx_t_21);
        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
        __Pyx_ErrRestore(__pyx_t_14, __pyx_t_3, __pyx_t_16);
        __pyx_t_14 = 0; __pyx_t_3 = 0; __pyx_t_16 = 0;
        if (__pyx_t_34) {
          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.ss", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_16, &__pyx_t_3, &__pyx_t_14) < 0) __PYX_ERR(0, 3524, __pyx_L10_except_error)
          __Pyx_XGOTREF(__pyx_t_16);
          __Pyx_XGOTREF(__pyx_t_3);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_3);
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":3525
 *                     continue
 *                 except ValidationError as e:
 *                     logger.error("Validation error with screenshot %s: %s", ss, e)             # <<<<<<<<<<<<<<
 *                     continue
 *                 except Exception as e:
*/
            __pyx_t_2 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3525, __pyx_L179_error)
            __Pyx_GOTREF(__pyx_t_25);
            __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3525, __pyx_L179_error)
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_13))) {
              __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_13);
              assert(__pyx_t_2);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
              __Pyx_INCREF(__pyx_t_2);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[4] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Validation_error_with_screenshot, __pyx_cur_scope->__pyx_v_ss, __pyx_cur_scope->__pyx_v_e};
              __pyx_t_21 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_4, (4-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3525, __pyx_L179_error)
              __Pyx_GOTREF(__pyx_t_21);
            }
            __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;

            /* "ws_package/controllers/activity_controller.py":3526
 *                 except ValidationError as e:
 *                     logger.error("Validation error with screenshot %s: %s", ss, e)
 *                     continue             # <<<<<<<<<<<<<<
 *                 except Exception as e:
 *                     logger.error("Unexpected error uploading screenshot %s: %s", ss, e)
*/
            goto __pyx_L176_continue;
          }

          /* "ws_package/controllers/activity_controller.py":3524
 *                     logger.error("Network error uploading screenshot %s: %s", ss, e)
 *                     continue
 *                 except ValidationError as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Validation error with screenshot %s: %s", ss, e)
 *                     continue
*/
          /*finally:*/ {
            __pyx_L179_error:;
            /*exception exit:*/{
              __Pyx_PyThreadState_assign
              __pyx_t_41 = 0; __pyx_t_40 = 0; __pyx_t_39 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0;
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
              __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
              __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
              __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
              __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
              __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
               __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17);
              if ( unlikely(__Pyx_GetException(&__pyx_t_41, &__pyx_t_40, &__pyx_t_39) < 0)) __Pyx_ErrFetch(&__pyx_t_41, &__pyx_t_40, &__pyx_t_39);
              __Pyx_XGOTREF(__pyx_t_41);
              __Pyx_XGOTREF(__pyx_t_40);
              __Pyx_XGOTREF(__pyx_t_39);
              __Pyx_XGOTREF(__pyx_t_19);
              __Pyx_XGOTREF(__pyx_t_18);
              __Pyx_XGOTREF(__pyx_t_17);
              __pyx_t_34 = __pyx_lineno; __pyx_t_33 = __pyx_clineno; __pyx_t_52 = __pyx_filename;
              {
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
              }
              __Pyx_XGIVEREF(__pyx_t_19);
              __Pyx_XGIVEREF(__pyx_t_18);
              __Pyx_XGIVEREF(__pyx_t_17);
              __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_18, __pyx_t_17);
              __Pyx_XGIVEREF(__pyx_t_41);
              __Pyx_XGIVEREF(__pyx_t_40);
              __Pyx_XGIVEREF(__pyx_t_39);
              __Pyx_ErrRestore(__pyx_t_41, __pyx_t_40, __pyx_t_39);
              __pyx_t_41 = 0; __pyx_t_40 = 0; __pyx_t_39 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0;
              __pyx_lineno = __pyx_t_34; __pyx_clineno = __pyx_t_33; __pyx_filename = __pyx_t_52;
              goto __pyx_L10_except_error;
            }
            __pyx_L176_continue: {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
              goto __pyx_L174_except_continue;
            }
          }
          __pyx_L174_except_continue:;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          goto __pyx_L14_try_continue;
        }

        /* "ws_package/controllers/activity_controller.py":3527
 *                     logger.error("Validation error with screenshot %s: %s", ss, e)
 *                     continue
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Unexpected error uploading screenshot %s: %s", ss, e)
 *                     continue
*/
        __pyx_t_33 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
        if (__pyx_t_33) {
          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.ss", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_14, &__pyx_t_3, &__pyx_t_16) < 0) __PYX_ERR(0, 3527, __pyx_L10_except_error)
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_3);
          __Pyx_XGOTREF(__pyx_t_16);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_3);
          __Pyx_GIVEREF(__pyx_t_3);
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":3528
 *                     continue
 *                 except Exception as e:
 *                     logger.error("Unexpected error uploading screenshot %s: %s", ss, e)             # <<<<<<<<<<<<<<
 *                     continue
 * 
*/
            __pyx_t_13 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3528, __pyx_L190_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3528, __pyx_L190_error)
            __Pyx_GOTREF(__pyx_t_25);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_25))) {
              __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_25);
              assert(__pyx_t_13);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_25);
              __Pyx_INCREF(__pyx_t_13);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_25, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[4] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Unexpected_error_uploading_scree, __pyx_cur_scope->__pyx_v_ss, __pyx_cur_scope->__pyx_v_e};
              __pyx_t_21 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_25, __pyx_callargs+__pyx_t_4, (4-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
              if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3528, __pyx_L190_error)
              __Pyx_GOTREF(__pyx_t_21);
            }
            __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;

            /* "ws_package/controllers/activity_controller.py":3529
 *                 except Exception as e:
 *                     logger.error("Unexpected error uploading screenshot %s: %s", ss, e)
 *                     continue             # <<<<<<<<<<<<<<
 * 
 *         return ans_array
*/
            goto __pyx_L187_continue;
          }

          /* "ws_package/controllers/activity_controller.py":3527
 *                     logger.error("Validation error with screenshot %s: %s", ss, e)
 *                     continue
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Unexpected error uploading screenshot %s: %s", ss, e)
 *                     continue
*/
          /*finally:*/ {
            __pyx_L190_error:;
            /*exception exit:*/{
              __Pyx_PyThreadState_assign
              __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_39 = 0; __pyx_t_40 = 0; __pyx_t_41 = 0;
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
              __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
              __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
              __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
              __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
              __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
               __Pyx_ExceptionSwap(&__pyx_t_39, &__pyx_t_40, &__pyx_t_41);
              if ( unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
              __Pyx_XGOTREF(__pyx_t_17);
              __Pyx_XGOTREF(__pyx_t_18);
              __Pyx_XGOTREF(__pyx_t_19);
              __Pyx_XGOTREF(__pyx_t_39);
              __Pyx_XGOTREF(__pyx_t_40);
              __Pyx_XGOTREF(__pyx_t_41);
              __pyx_t_33 = __pyx_lineno; __pyx_t_34 = __pyx_clineno; __pyx_t_53 = __pyx_filename;
              {
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
              }
              __Pyx_XGIVEREF(__pyx_t_39);
              __Pyx_XGIVEREF(__pyx_t_40);
              __Pyx_XGIVEREF(__pyx_t_41);
              __Pyx_ExceptionReset(__pyx_t_39, __pyx_t_40, __pyx_t_41);
              __Pyx_XGIVEREF(__pyx_t_17);
              __Pyx_XGIVEREF(__pyx_t_18);
              __Pyx_XGIVEREF(__pyx_t_19);
              __Pyx_ErrRestore(__pyx_t_17, __pyx_t_18, __pyx_t_19);
              __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_39 = 0; __pyx_t_40 = 0; __pyx_t_41 = 0;
              __pyx_lineno = __pyx_t_33; __pyx_clineno = __pyx_t_34; __pyx_filename = __pyx_t_53;
              goto __pyx_L10_except_error;
            }
            __pyx_L187_continue: {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
              goto __pyx_L185_except_continue;
            }
          }
          __pyx_L185_except_continue:;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          goto __pyx_L14_try_continue;
        }
        goto __pyx_L10_except_error;

        /* "ws_package/controllers/activity_controller.py":3422
 * 
 *             else:
 *                 try:             # <<<<<<<<<<<<<<
 *                     # Validate screenshot file exists and is accessible
 *                     if not os.path.exists(ss):
*/
        __pyx_L10_except_error:;
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
        goto __pyx_L1_error;
        __pyx_L14_try_continue:;
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
        goto __pyx_L5_continue;
        __pyx_L15_try_end:;
      }
    }
    __pyx_L7:;

    /* "ws_package/controllers/activity_controller.py":3417
 *         ss_array = await self.activity_service.get_screenshots(interval_start_time, interval_end_time)
 *         ans_array = []
 *         for ss in ss_array:             # <<<<<<<<<<<<<<
 *             if self.is_link(ss):
 *                 ans_array.append(ss)
*/
    __pyx_L5_continue:;
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":3531
 *                     continue
 * 
 *         return ans_array             # <<<<<<<<<<<<<<
 * 
 *     def group_intervals_by_day(self, intervals):
*/
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_ans_array);
  __pyx_r = __pyx_cur_scope->__pyx_v_ans_array;
  goto __pyx_L0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":3414
 *         return self.screenshot_manager.forward_ss(ss)
 * 
 *     async def ss(self, interval_start_time, interval_end_time, user_entity: UserEntity): # This is a validator chck if screenshot is link or not everytime and renaming before uploading             # <<<<<<<<<<<<<<
 *         ss_array = await self.activity_service.get_screenshots(interval_start_time, interval_end_time)
 *         ans_array = []
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_XDECREF(__pyx_t_23);
  __Pyx_XDECREF(__pyx_t_24);
  __Pyx_XDECREF(__pyx_t_25);
  __Pyx_XDECREF(__pyx_t_26);
  __Pyx_XDECREF(__pyx_t_27);
  __Pyx_XDECREF(__pyx_t_28);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("ss", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":3533
 *         return ans_array
 * 
 *     def group_intervals_by_day(self, intervals):             # <<<<<<<<<<<<<<
 *         """Group intervals by their start date."""
 *         grouped_intervals = defaultdict(list)
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_117group_intervals_by_day(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_116group_intervals_by_day, "Group intervals by their start date.");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_117group_intervals_by_day = {"group_intervals_by_day", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_117group_intervals_by_day, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_116group_intervals_by_day};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_117group_intervals_by_day(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  CYTHON_UNUSED PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_intervals = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("group_intervals_by_day (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_intervals,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 3533, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3533, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3533, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "group_intervals_by_day", 0) < (0)) __PYX_ERR(0, 3533, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("group_intervals_by_day", 1, 2, 2, i); __PYX_ERR(0, 3533, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3533, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3533, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_intervals = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("group_intervals_by_day", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 3533, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.group_intervals_by_day", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_116group_intervals_by_day(__pyx_self, __pyx_v_self, __pyx_v_intervals);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_116group_intervals_by_day(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_intervals) {
  PyObject *__pyx_v_grouped_intervals = NULL;
  PyObject *__pyx_v_interval = NULL;
  PyObject *__pyx_v_interval_date = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  size_t __pyx_t_4;
  Py_ssize_t __pyx_t_5;
  PyObject *(*__pyx_t_6)(PyObject *);
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("group_intervals_by_day", 0);

  /* "ws_package/controllers/activity_controller.py":3535
 *     def group_intervals_by_day(self, intervals):
 *         """Group intervals by their start date."""
 *         grouped_intervals = defaultdict(list)             # <<<<<<<<<<<<<<
 * 
 *         for interval in intervals:
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_defaultdict); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3535, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
    __pyx_t_4 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, ((PyObject *)(&PyList_Type))};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3535, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_v_grouped_intervals = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":3537
 *         grouped_intervals = defaultdict(list)
 * 
 *         for interval in intervals:             # <<<<<<<<<<<<<<
 *             # Extract the date from the start_time
 *             interval_date = interval.start_time.date()
*/
  if (likely(PyList_CheckExact(__pyx_v_intervals)) || PyTuple_CheckExact(__pyx_v_intervals)) {
    __pyx_t_1 = __pyx_v_intervals; __Pyx_INCREF(__pyx_t_1);
    __pyx_t_5 = 0;
    __pyx_t_6 = NULL;
  } else {
    __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_intervals); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3537, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_6 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3537, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_6)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3537, __pyx_L1_error)
          #endif
          if (__pyx_t_5 >= __pyx_temp) break;
        }
        __pyx_t_3 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_1, __pyx_t_5, __Pyx_ReferenceSharing_OwnStrongReference);
        ++__pyx_t_5;
      } else {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3537, __pyx_L1_error)
          #endif
          if (__pyx_t_5 >= __pyx_temp) break;
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_3 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5));
        #else
        __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_5);
        #endif
        ++__pyx_t_5;
      }
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3537, __pyx_L1_error)
    } else {
      __pyx_t_3 = __pyx_t_6(__pyx_t_1);
      if (unlikely(!__pyx_t_3)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 3537, __pyx_L1_error)
          PyErr_Clear();
        }
        break;
      }
    }
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_XDECREF_SET(__pyx_v_interval, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "ws_package/controllers/activity_controller.py":3539
 *         for interval in intervals:
 *             # Extract the date from the start_time
 *             interval_date = interval.start_time.date()             # <<<<<<<<<<<<<<
 *             grouped_intervals[interval_date].append(interval)
 * 
*/
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3539, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_2 = __pyx_t_7;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_4 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
      __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_date, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3539, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_XDECREF_SET(__pyx_v_interval_date, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "ws_package/controllers/activity_controller.py":3540
 *             # Extract the date from the start_time
 *             interval_date = interval.start_time.date()
 *             grouped_intervals[interval_date].append(interval)             # <<<<<<<<<<<<<<
 * 
 *         return grouped_intervals
*/
    __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_grouped_intervals, __pyx_v_interval_date); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3540, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_8 = __Pyx_PyObject_Append(__pyx_t_3, __pyx_v_interval); if (unlikely(__pyx_t_8 == ((int)-1))) __PYX_ERR(0, 3540, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "ws_package/controllers/activity_controller.py":3537
 *         grouped_intervals = defaultdict(list)
 * 
 *         for interval in intervals:             # <<<<<<<<<<<<<<
 *             # Extract the date from the start_time
 *             interval_date = interval.start_time.date()
*/
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":3542
 *             grouped_intervals[interval_date].append(interval)
 * 
 *         return grouped_intervals             # <<<<<<<<<<<<<<
 * 
 *     def _calculate_gap_seconds(self, prev_interval, current_interval) -> float:
*/
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_grouped_intervals);
  __pyx_r = __pyx_v_grouped_intervals;
  goto __pyx_L0;

  /* "ws_package/controllers/activity_controller.py":3533
 *         return ans_array
 * 
 *     def group_intervals_by_day(self, intervals):             # <<<<<<<<<<<<<<
 *         """Group intervals by their start date."""
 *         grouped_intervals = defaultdict(list)
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.group_intervals_by_day", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_grouped_intervals);
  __Pyx_XDECREF(__pyx_v_interval);
  __Pyx_XDECREF(__pyx_v_interval_date);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":3544
 *         return grouped_intervals
 * 
 *     def _calculate_gap_seconds(self, prev_interval, current_interval) -> float:             # <<<<<<<<<<<<<<
 *         """Return the time gap (in seconds) between two consecutive intervals."""
 *         if not prev_interval or not current_interval:
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_119_calculate_gap_seconds(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_118_calculate_gap_seconds, "Return the time gap (in seconds) between two consecutive intervals.");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_119_calculate_gap_seconds = {"_calculate_gap_seconds", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_119_calculate_gap_seconds, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_118_calculate_gap_seconds};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_119_calculate_gap_seconds(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  CYTHON_UNUSED PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_prev_interval = 0;
  PyObject *__pyx_v_current_interval = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_calculate_gap_seconds (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_prev_interval,&__pyx_mstate_global->__pyx_n_u_current_interval,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 3544, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 3544, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3544, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3544, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_calculate_gap_seconds", 0) < (0)) __PYX_ERR(0, 3544, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 3; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_calculate_gap_seconds", 1, 3, 3, i); __PYX_ERR(0, 3544, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 3)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3544, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3544, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 3544, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_prev_interval = values[1];
    __pyx_v_current_interval = values[2];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_calculate_gap_seconds", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 3544, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._calculate_gap_seconds", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_118_calculate_gap_seconds(__pyx_self, __pyx_v_self, __pyx_v_prev_interval, __pyx_v_current_interval);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_118_calculate_gap_seconds(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_prev_interval, PyObject *__pyx_v_current_interval) {
  PyObject *__pyx_v_e = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  size_t __pyx_t_12;
  int __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  char const *__pyx_t_17;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_calculate_gap_seconds", 0);

  /* "ws_package/controllers/activity_controller.py":3546
 *     def _calculate_gap_seconds(self, prev_interval, current_interval) -> float:
 *         """Return the time gap (in seconds) between two consecutive intervals."""
 *         if not prev_interval or not current_interval:             # <<<<<<<<<<<<<<
 *             return 0.0
 *         try:
*/
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_prev_interval); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3546, __pyx_L1_error)
  __pyx_t_3 = (!__pyx_t_2);
  if (!__pyx_t_3) {
  } else {
    __pyx_t_1 = __pyx_t_3;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_current_interval); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 3546, __pyx_L1_error)
  __pyx_t_2 = (!__pyx_t_3);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "ws_package/controllers/activity_controller.py":3547
 *         """Return the time gap (in seconds) between two consecutive intervals."""
 *         if not prev_interval or not current_interval:
 *             return 0.0             # <<<<<<<<<<<<<<
 *         try:
 *             return (current_interval.start_time - prev_interval.end_time).total_seconds()
*/
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_mstate_global->__pyx_float_0_0);
    __pyx_r = __pyx_mstate_global->__pyx_float_0_0;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":3546
 *     def _calculate_gap_seconds(self, prev_interval, current_interval) -> float:
 *         """Return the time gap (in seconds) between two consecutive intervals."""
 *         if not prev_interval or not current_interval:             # <<<<<<<<<<<<<<
 *             return 0.0
 *         try:
*/
  }

  /* "ws_package/controllers/activity_controller.py":3548
 *         if not prev_interval or not current_interval:
 *             return 0.0
 *         try:             # <<<<<<<<<<<<<<
 *             return (current_interval.start_time - prev_interval.end_time).total_seconds()
 *         except Exception as e:
*/
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":3549
 *             return 0.0
 *         try:
 *             return (current_interval.start_time - prev_interval.end_time).total_seconds()             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             logger.debug("Failed to calculate gap between intervals: %s", e)
*/
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_current_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3549, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_v_prev_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3549, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_11 = PyNumber_Subtract(__pyx_t_9, __pyx_t_10); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3549, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_8 = __pyx_t_11;
      __Pyx_INCREF(__pyx_t_8);
      __pyx_t_12 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
        __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_total_seconds, __pyx_callargs+__pyx_t_12, (1-__pyx_t_12) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3549, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_7);
      }
      __pyx_r = __pyx_t_7;
      __pyx_t_7 = 0;
      goto __pyx_L10_try_return;

      /* "ws_package/controllers/activity_controller.py":3548
 *         if not prev_interval or not current_interval:
 *             return 0.0
 *         try:             # <<<<<<<<<<<<<<
 *             return (current_interval.start_time - prev_interval.end_time).total_seconds()
 *         except Exception as e:
*/
    }
    __pyx_L6_error:;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "ws_package/controllers/activity_controller.py":3550
 *         try:
 *             return (current_interval.start_time - prev_interval.end_time).total_seconds()
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.debug("Failed to calculate gap between intervals: %s", e)
 *             return 0.0
*/
    __pyx_t_13 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_13) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._calculate_gap_seconds", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_11, &__pyx_t_8) < 0) __PYX_ERR(0, 3550, __pyx_L8_except_error)
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_11);
      __pyx_v_e = __pyx_t_11;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":3551
 *             return (current_interval.start_time - prev_interval.end_time).total_seconds()
 *         except Exception as e:
 *             logger.debug("Failed to calculate gap between intervals: %s", e)             # <<<<<<<<<<<<<<
 *             return 0.0
 * 
*/
        __pyx_t_9 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3551, __pyx_L17_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3551, __pyx_L17_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_12 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_15))) {
          __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_15);
          assert(__pyx_t_9);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
          __pyx_t_12 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_9, __pyx_mstate_global->__pyx_kp_u_Failed_to_calculate_gap_between, __pyx_v_e};
          __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_12, (3-__pyx_t_12) | (__pyx_t_12*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 3551, __pyx_L17_error)
          __Pyx_GOTREF(__pyx_t_10);
        }
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

        /* "ws_package/controllers/activity_controller.py":3552
 *         except Exception as e:
 *             logger.debug("Failed to calculate gap between intervals: %s", e)
 *             return 0.0             # <<<<<<<<<<<<<<
 * 
 *     def _determine_sleep_reason(self, gap_seconds: float) -> str:
*/
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(__pyx_mstate_global->__pyx_float_0_0);
        __pyx_r = __pyx_mstate_global->__pyx_float_0_0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L16_return;
      }

      /* "ws_package/controllers/activity_controller.py":3550
 *         try:
 *             return (current_interval.start_time - prev_interval.end_time).total_seconds()
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.debug("Failed to calculate gap between intervals: %s", e)
 *             return 0.0
*/
      /*finally:*/ {
        __pyx_L17_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
          if ( unlikely(__Pyx_GetException(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20) < 0)) __Pyx_ErrFetch(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_18);
          __Pyx_XGOTREF(__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_23);
          __pyx_t_13 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_17 = __pyx_filename;
          {
            __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_23);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_ErrRestore(__pyx_t_18, __pyx_t_19, __pyx_t_20);
          __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
          __pyx_lineno = __pyx_t_13; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_17;
          goto __pyx_L8_except_error;
        }
        __pyx_L16_return: {
          __pyx_t_23 = __pyx_r;
          __pyx_r = 0;
          __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
          __pyx_r = __pyx_t_23;
          __pyx_t_23 = 0;
          goto __pyx_L9_except_return;
        }
      }
    }
    goto __pyx_L8_except_error;

    /* "ws_package/controllers/activity_controller.py":3548
 *         if not prev_interval or not current_interval:
 *             return 0.0
 *         try:             # <<<<<<<<<<<<<<
 *             return (current_interval.start_time - prev_interval.end_time).total_seconds()
 *         except Exception as e:
*/
    __pyx_L8_except_error:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L10_try_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
    __pyx_L9_except_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
  }

  /* "ws_package/controllers/activity_controller.py":3544
 *         return grouped_intervals
 * 
 *     def _calculate_gap_seconds(self, prev_interval, current_interval) -> float:             # <<<<<<<<<<<<<<
 *         """Return the time gap (in seconds) between two consecutive intervals."""
 *         if not prev_interval or not current_interval:
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._calculate_gap_seconds", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":3554
 *             return 0.0
 * 
 *     def _determine_sleep_reason(self, gap_seconds: float) -> str:             # <<<<<<<<<<<<<<
 *         """
 *         Provide a descriptive reason for large gaps.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_121_determine_sleep_reason(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_120_determine_sleep_reason, "\n        Provide a descriptive reason for large gaps.\n        Uses idle_time_limit_in_seconds from API instead of hardcoded values.\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_121_determine_sleep_reason = {"_determine_sleep_reason", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_121_determine_sleep_reason, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_120_determine_sleep_reason};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_121_determine_sleep_reason(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  double __pyx_v_gap_seconds;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_determine_sleep_reason (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_gap_seconds,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 3554, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3554, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3554, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_determine_sleep_reason", 0) < (0)) __PYX_ERR(0, 3554, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_determine_sleep_reason", 1, 2, 2, i); __PYX_ERR(0, 3554, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3554, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3554, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_gap_seconds = __Pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_gap_seconds == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 3554, __pyx_L3_error)
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_determine_sleep_reason", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 3554, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._determine_sleep_reason", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_120_determine_sleep_reason(__pyx_self, __pyx_v_self, __pyx_v_gap_seconds);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_120_determine_sleep_reason(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, double __pyx_v_gap_seconds) {
  PyObject *__pyx_v_idle_threshold = NULL;
  PyObject *__pyx_v_system_name = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_determine_sleep_reason", 0);

  /* "ws_package/controllers/activity_controller.py":3560
 *         """
 *         # Use API value, fallback to default if not set
 *         idle_threshold = getattr(self, 'idle_time_limit_in_seconds', 3600)             # <<<<<<<<<<<<<<
 * 
 *         system_name = platform.system()
*/
  __pyx_t_1 = __Pyx_GetAttr3(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_time_limit_in_seconds, __pyx_mstate_global->__pyx_int_3600); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3560, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_v_idle_threshold = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":3562
 *         idle_threshold = getattr(self, 'idle_time_limit_in_seconds', 3600)
 * 
 *         system_name = platform.system()             # <<<<<<<<<<<<<<
 *         if system_name == "Windows":
 *             return "windows_sleep_or_restart" if gap_seconds >= idle_threshold else "windows_idle_gap"
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3562, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_system); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3562, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3562, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_v_system_name = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":3563
 * 
 *         system_name = platform.system()
 *         if system_name == "Windows":             # <<<<<<<<<<<<<<
 *             return "windows_sleep_or_restart" if gap_seconds >= idle_threshold else "windows_idle_gap"
 *         if system_name == "Darwin":
*/
  __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_system_name, __pyx_mstate_global->__pyx_n_u_Windows, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 3563, __pyx_L1_error)
  if (__pyx_t_6) {

    /* "ws_package/controllers/activity_controller.py":3564
 *         system_name = platform.system()
 *         if system_name == "Windows":
 *             return "windows_sleep_or_restart" if gap_seconds >= idle_threshold else "windows_idle_gap"             # <<<<<<<<<<<<<<
 *         if system_name == "Darwin":
 *             return "macos_sleep_or_shutdown" if gap_seconds >= idle_threshold else "macos_idle_gap"
*/
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_4 = PyFloat_FromDouble(__pyx_v_gap_seconds); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3564, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, __pyx_v_idle_threshold, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3564, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 3564, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    if (__pyx_t_6) {
      __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_windows_sleep_or_restart);
      __pyx_t_1 = __pyx_mstate_global->__pyx_n_u_windows_sleep_or_restart;
    } else {
      __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_windows_idle_gap);
      __pyx_t_1 = __pyx_mstate_global->__pyx_n_u_windows_idle_gap;
    }
    __pyx_r = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":3563
 * 
 *         system_name = platform.system()
 *         if system_name == "Windows":             # <<<<<<<<<<<<<<
 *             return "windows_sleep_or_restart" if gap_seconds >= idle_threshold else "windows_idle_gap"
 *         if system_name == "Darwin":
*/
  }

  /* "ws_package/controllers/activity_controller.py":3565
 *         if system_name == "Windows":
 *             return "windows_sleep_or_restart" if gap_seconds >= idle_threshold else "windows_idle_gap"
 *         if system_name == "Darwin":             # <<<<<<<<<<<<<<
 *             return "macos_sleep_or_shutdown" if gap_seconds >= idle_threshold else "macos_idle_gap"
 *         return "linux_sleep_or_shutdown" if gap_seconds >= idle_threshold else "linux_idle_gap"
*/
  __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_v_system_name, __pyx_mstate_global->__pyx_n_u_Darwin, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 3565, __pyx_L1_error)
  if (__pyx_t_6) {

    /* "ws_package/controllers/activity_controller.py":3566
 *             return "windows_sleep_or_restart" if gap_seconds >= idle_threshold else "windows_idle_gap"
 *         if system_name == "Darwin":
 *             return "macos_sleep_or_shutdown" if gap_seconds >= idle_threshold else "macos_idle_gap"             # <<<<<<<<<<<<<<
 *         return "linux_sleep_or_shutdown" if gap_seconds >= idle_threshold else "linux_idle_gap"
 * 
*/
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_2 = PyFloat_FromDouble(__pyx_v_gap_seconds); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3566, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_v_idle_threshold, Py_GE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3566, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 3566, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_6) {
      __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_macos_sleep_or_shutdown);
      __pyx_t_1 = __pyx_mstate_global->__pyx_n_u_macos_sleep_or_shutdown;
    } else {
      __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_macos_idle_gap);
      __pyx_t_1 = __pyx_mstate_global->__pyx_n_u_macos_idle_gap;
    }
    __pyx_r = ((PyObject*)__pyx_t_1);
    __pyx_t_1 = 0;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":3565
 *         if system_name == "Windows":
 *             return "windows_sleep_or_restart" if gap_seconds >= idle_threshold else "windows_idle_gap"
 *         if system_name == "Darwin":             # <<<<<<<<<<<<<<
 *             return "macos_sleep_or_shutdown" if gap_seconds >= idle_threshold else "macos_idle_gap"
 *         return "linux_sleep_or_shutdown" if gap_seconds >= idle_threshold else "linux_idle_gap"
*/
  }

  /* "ws_package/controllers/activity_controller.py":3567
 *         if system_name == "Darwin":
 *             return "macos_sleep_or_shutdown" if gap_seconds >= idle_threshold else "macos_idle_gap"
 *         return "linux_sleep_or_shutdown" if gap_seconds >= idle_threshold else "linux_idle_gap"             # <<<<<<<<<<<<<<
 * 
 *     def _log_session_split_reason(self, reason: str, prev_interval, current_interval, gap_seconds: float) -> None:
*/
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_gap_seconds); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3567, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_2 = PyObject_RichCompare(__pyx_t_4, __pyx_v_idle_threshold, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3567, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 3567, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_6) {
    __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_linux_sleep_or_shutdown);
    __pyx_t_1 = __pyx_mstate_global->__pyx_n_u_linux_sleep_or_shutdown;
  } else {
    __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_linux_idle_gap);
    __pyx_t_1 = __pyx_mstate_global->__pyx_n_u_linux_idle_gap;
  }
  __pyx_r = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "ws_package/controllers/activity_controller.py":3554
 *             return 0.0
 * 
 *     def _determine_sleep_reason(self, gap_seconds: float) -> str:             # <<<<<<<<<<<<<<
 *         """
 *         Provide a descriptive reason for large gaps.
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._determine_sleep_reason", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_idle_threshold);
  __Pyx_XDECREF(__pyx_v_system_name);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":3569
 *         return "linux_sleep_or_shutdown" if gap_seconds >= idle_threshold else "linux_idle_gap"
 * 
 *     def _log_session_split_reason(self, reason: str, prev_interval, current_interval, gap_seconds: float) -> None:             # <<<<<<<<<<<<<<
 *         """Log session split metadata for diagnostics."""
 *         gap_minutes = gap_seconds / 60 if gap_seconds else 0.0
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_123_log_session_split_reason(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_122_log_session_split_reason, "Log session split metadata for diagnostics.");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_123_log_session_split_reason = {"_log_session_split_reason", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_123_log_session_split_reason, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_122_log_session_split_reason};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_123_log_session_split_reason(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  CYTHON_UNUSED PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_reason = 0;
  PyObject *__pyx_v_prev_interval = 0;
  PyObject *__pyx_v_current_interval = 0;
  double __pyx_v_gap_seconds;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[5] = {0,0,0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_log_session_split_reason (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_reason,&__pyx_mstate_global->__pyx_n_u_prev_interval,&__pyx_mstate_global->__pyx_n_u_current_interval,&__pyx_mstate_global->__pyx_n_u_gap_seconds,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 3569, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  5:
        values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 3569, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  4:
        values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 3569, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 3569, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3569, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3569, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_log_session_split_reason", 0) < (0)) __PYX_ERR(0, 3569, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 5; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_log_session_split_reason", 1, 5, 5, i); __PYX_ERR(0, 3569, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 5)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3569, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3569, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 3569, __pyx_L3_error)
      values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 3569, __pyx_L3_error)
      values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 3569, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_reason = ((PyObject*)values[1]);
    __pyx_v_prev_interval = values[2];
    __pyx_v_current_interval = values[3];
    __pyx_v_gap_seconds = __Pyx_PyFloat_AsDouble(values[4]); if (unlikely((__pyx_v_gap_seconds == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 3569, __pyx_L3_error)
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_log_session_split_reason", 1, 5, 5, __pyx_nargs); __PYX_ERR(0, 3569, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._log_session_split_reason", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_reason), (&PyUnicode_Type), 0, "reason", 2))) __PYX_ERR(0, 3569, __pyx_L1_error)
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_122_log_session_split_reason(__pyx_self, __pyx_v_self, __pyx_v_reason, __pyx_v_prev_interval, __pyx_v_current_interval, __pyx_v_gap_seconds);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  goto __pyx_L7_cleaned_up;
  __pyx_L0:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __pyx_L7_cleaned_up:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_122_log_session_split_reason(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_reason, PyObject *__pyx_v_prev_interval, PyObject *__pyx_v_current_interval, double __pyx_v_gap_seconds) {
  double __pyx_v_gap_minutes;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  double __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  size_t __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_log_session_split_reason", 0);

  /* "ws_package/controllers/activity_controller.py":3571
 *     def _log_session_split_reason(self, reason: str, prev_interval, current_interval, gap_seconds: float) -> None:
 *         """Log session split metadata for diagnostics."""
 *         gap_minutes = gap_seconds / 60 if gap_seconds else 0.0             # <<<<<<<<<<<<<<
 *         logger.info(
 *             "Session split detected | reason=%s | platform=%s | gap_minutes=%.2f | prev_end=%s | next_start=%s | prev_counter=%s | next_counter=%s",
*/
  __pyx_t_2 = (__pyx_v_gap_seconds != 0);
  if (__pyx_t_2) {
    __pyx_t_1 = (__pyx_v_gap_seconds / 60.0);
  } else {
    __pyx_t_1 = 0.0;
  }
  __pyx_v_gap_minutes = __pyx_t_1;

  /* "ws_package/controllers/activity_controller.py":3572
 *         """Log session split metadata for diagnostics."""
 *         gap_minutes = gap_seconds / 60 if gap_seconds else 0.0
 *         logger.info(             # <<<<<<<<<<<<<<
 *             "Session split detected | reason=%s | platform=%s | gap_minutes=%.2f | prev_end=%s | next_start=%s | prev_counter=%s | next_counter=%s",
 *             reason,
*/
  __pyx_t_4 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3572, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3572, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "ws_package/controllers/activity_controller.py":3575
 *             "Session split detected | reason=%s | platform=%s | gap_minutes=%.2f | prev_end=%s | next_start=%s | prev_counter=%s | next_counter=%s",
 *             reason,
 *             platform.system(),             # <<<<<<<<<<<<<<
 *             gap_minutes,
 *             getattr(prev_interval, "end_time", None),
*/
  __pyx_t_7 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3575, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_system); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3575, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_10 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9);
    assert(__pyx_t_7);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
    __Pyx_INCREF(__pyx_t_7);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
    __pyx_t_10 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
    __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3575, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
  }

  /* "ws_package/controllers/activity_controller.py":3576
 *             reason,
 *             platform.system(),
 *             gap_minutes,             # <<<<<<<<<<<<<<
 *             getattr(prev_interval, "end_time", None),
 *             getattr(current_interval, "start_time", None),
*/
  __pyx_t_9 = PyFloat_FromDouble(__pyx_v_gap_minutes); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3576, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);

  /* "ws_package/controllers/activity_controller.py":3577
 *             platform.system(),
 *             gap_minutes,
 *             getattr(prev_interval, "end_time", None),             # <<<<<<<<<<<<<<
 *             getattr(current_interval, "start_time", None),
 *             getattr(prev_interval, "counter", None),
*/
  __pyx_t_7 = __Pyx_GetAttr3(__pyx_v_prev_interval, __pyx_mstate_global->__pyx_n_u_end_time, Py_None); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3577, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);

  /* "ws_package/controllers/activity_controller.py":3578
 *             gap_minutes,
 *             getattr(prev_interval, "end_time", None),
 *             getattr(current_interval, "start_time", None),             # <<<<<<<<<<<<<<
 *             getattr(prev_interval, "counter", None),
 *             getattr(current_interval, "counter", None),
*/
  __pyx_t_8 = __Pyx_GetAttr3(__pyx_v_current_interval, __pyx_mstate_global->__pyx_n_u_start_time, Py_None); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3578, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);

  /* "ws_package/controllers/activity_controller.py":3579
 *             getattr(prev_interval, "end_time", None),
 *             getattr(current_interval, "start_time", None),
 *             getattr(prev_interval, "counter", None),             # <<<<<<<<<<<<<<
 *             getattr(current_interval, "counter", None),
 *         )
*/
  __pyx_t_11 = __Pyx_GetAttr3(__pyx_v_prev_interval, __pyx_mstate_global->__pyx_n_u_counter, Py_None); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 3579, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_11);

  /* "ws_package/controllers/activity_controller.py":3580
 *             getattr(current_interval, "start_time", None),
 *             getattr(prev_interval, "counter", None),
 *             getattr(current_interval, "counter", None),             # <<<<<<<<<<<<<<
 *         )
 * 
*/
  __pyx_t_12 = __Pyx_GetAttr3(__pyx_v_current_interval, __pyx_mstate_global->__pyx_n_u_counter, Py_None); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 3580, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_12);
  __pyx_t_10 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
    assert(__pyx_t_4);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
    __pyx_t_10 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[9] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Session_split_detected_reason_s, __pyx_v_reason, __pyx_t_5, __pyx_t_9, __pyx_t_7, __pyx_t_8, __pyx_t_11, __pyx_t_12};
    __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_10, (9-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3572, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  }
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "ws_package/controllers/activity_controller.py":3569
 *         return "linux_sleep_or_shutdown" if gap_seconds >= idle_threshold else "linux_idle_gap"
 * 
 *     def _log_session_split_reason(self, reason: str, prev_interval, current_interval, gap_seconds: float) -> None:             # <<<<<<<<<<<<<<
 *         """Log session split metadata for diagnostics."""
 *         gap_minutes = gap_seconds / 60 if gap_seconds else 0.0
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._log_session_split_reason", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":3583
 *         )
 * 
 *     def _should_start_new_session(self, prev_interval, current_interval) -> bool:             # <<<<<<<<<<<<<<
 *         """Determine whether a new session should begin based on counters and gaps."""
 *         if not prev_interval:
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_125_should_start_new_session(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_124_should_start_new_session, "Determine whether a new session should begin based on counters and gaps.");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_125_should_start_new_session = {"_should_start_new_session", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_125_should_start_new_session, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_124_should_start_new_session};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_125_should_start_new_session(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_prev_interval = 0;
  PyObject *__pyx_v_current_interval = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_should_start_new_session (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_prev_interval,&__pyx_mstate_global->__pyx_n_u_current_interval,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 3583, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 3583, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3583, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3583, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_should_start_new_session", 0) < (0)) __PYX_ERR(0, 3583, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 3; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_should_start_new_session", 1, 3, 3, i); __PYX_ERR(0, 3583, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 3)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3583, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3583, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 3583, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_prev_interval = values[1];
    __pyx_v_current_interval = values[2];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_should_start_new_session", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 3583, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._should_start_new_session", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_124_should_start_new_session(__pyx_self, __pyx_v_self, __pyx_v_prev_interval, __pyx_v_current_interval);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_124_should_start_new_session(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_prev_interval, PyObject *__pyx_v_current_interval) {
  PyObject *__pyx_v_gap_seconds = NULL;
  PyObject *__pyx_v_reason = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  size_t __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_should_start_new_session", 0);

  /* "ws_package/controllers/activity_controller.py":3585
 *     def _should_start_new_session(self, prev_interval, current_interval) -> bool:
 *         """Determine whether a new session should begin based on counters and gaps."""
 *         if not prev_interval:             # <<<<<<<<<<<<<<
 *             return False
 * 
*/
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_prev_interval); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 3585, __pyx_L1_error)
  __pyx_t_2 = (!__pyx_t_1);
  if (__pyx_t_2) {

    /* "ws_package/controllers/activity_controller.py":3586
 *         """Determine whether a new session should begin based on counters and gaps."""
 *         if not prev_interval:
 *             return False             # <<<<<<<<<<<<<<
 * 
 *         # Counter increments indicate application restart or forced stop
*/
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":3585
 *     def _should_start_new_session(self, prev_interval, current_interval) -> bool:
 *         """Determine whether a new session should begin based on counters and gaps."""
 *         if not prev_interval:             # <<<<<<<<<<<<<<
 *             return False
 * 
*/
  }

  /* "ws_package/controllers/activity_controller.py":3589
 * 
 *         # Counter increments indicate application restart or forced stop
 *         if current_interval.counter != prev_interval.counter:             # <<<<<<<<<<<<<<
 *             self._log_session_split_reason(
 *                 "application_restart",
*/
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_current_interval, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_prev_interval, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3589, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, __pyx_t_4, Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3589, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3589, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_2) {

    /* "ws_package/controllers/activity_controller.py":3590
 *         # Counter increments indicate application restart or forced stop
 *         if current_interval.counter != prev_interval.counter:
 *             self._log_session_split_reason(             # <<<<<<<<<<<<<<
 *                 "application_restart",
 *                 prev_interval,
*/
    __pyx_t_4 = __pyx_v_self;
    __Pyx_INCREF(__pyx_t_4);

    /* "ws_package/controllers/activity_controller.py":3594
 *                 prev_interval,
 *                 current_interval,
 *                 self._calculate_gap_seconds(prev_interval, current_interval),             # <<<<<<<<<<<<<<
 *             )
 *             return True
*/
    __pyx_t_6 = __pyx_v_self;
    __Pyx_INCREF(__pyx_t_6);
    __pyx_t_7 = 0;
    {
      PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_v_prev_interval, __pyx_v_current_interval};
      __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_calculate_gap_seconds, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3594, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __pyx_t_7 = 0;
    {
      PyObject *__pyx_callargs[5] = {__pyx_t_4, __pyx_mstate_global->__pyx_n_u_application_restart, __pyx_v_prev_interval, __pyx_v_current_interval, __pyx_t_3};
      __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_log_session_split_reason, __pyx_callargs+__pyx_t_7, (5-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3590, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "ws_package/controllers/activity_controller.py":3596
 *                 self._calculate_gap_seconds(prev_interval, current_interval),
 *             )
 *             return True             # <<<<<<<<<<<<<<
 * 
 *         gap_seconds = self._calculate_gap_seconds(prev_interval, current_interval)
*/
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_True);
    __pyx_r = Py_True;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":3589
 * 
 *         # Counter increments indicate application restart or forced stop
 *         if current_interval.counter != prev_interval.counter:             # <<<<<<<<<<<<<<
 *             self._log_session_split_reason(
 *                 "application_restart",
*/
  }

  /* "ws_package/controllers/activity_controller.py":3598
 *             return True
 * 
 *         gap_seconds = self._calculate_gap_seconds(prev_interval, current_interval)             # <<<<<<<<<<<<<<
 *         if gap_seconds > self.session_gap_threshold_seconds:
 *             reason = self._determine_sleep_reason(gap_seconds)
*/
  __pyx_t_3 = __pyx_v_self;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_7 = 0;
  {
    PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_v_prev_interval, __pyx_v_current_interval};
    __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_calculate_gap_seconds, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3598, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
  }
  __pyx_v_gap_seconds = __pyx_t_5;
  __pyx_t_5 = 0;

  /* "ws_package/controllers/activity_controller.py":3599
 * 
 *         gap_seconds = self._calculate_gap_seconds(prev_interval, current_interval)
 *         if gap_seconds > self.session_gap_threshold_seconds:             # <<<<<<<<<<<<<<
 *             reason = self._determine_sleep_reason(gap_seconds)
 *             self._log_session_split_reason(reason, prev_interval, current_interval, gap_seconds)
*/
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_session_gap_threshold_seconds); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3599, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_3 = PyObject_RichCompare(__pyx_v_gap_seconds, __pyx_t_5, Py_GT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3599, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3599, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_2) {

    /* "ws_package/controllers/activity_controller.py":3600
 *         gap_seconds = self._calculate_gap_seconds(prev_interval, current_interval)
 *         if gap_seconds > self.session_gap_threshold_seconds:
 *             reason = self._determine_sleep_reason(gap_seconds)             # <<<<<<<<<<<<<<
 *             self._log_session_split_reason(reason, prev_interval, current_interval, gap_seconds)
 *             return True
*/
    __pyx_t_5 = __pyx_v_self;
    __Pyx_INCREF(__pyx_t_5);
    __pyx_t_7 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_gap_seconds};
      __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_determine_sleep_reason, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3600, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __pyx_v_reason = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "ws_package/controllers/activity_controller.py":3601
 *         if gap_seconds > self.session_gap_threshold_seconds:
 *             reason = self._determine_sleep_reason(gap_seconds)
 *             self._log_session_split_reason(reason, prev_interval, current_interval, gap_seconds)             # <<<<<<<<<<<<<<
 *             return True
 * 
*/
    __pyx_t_5 = __pyx_v_self;
    __Pyx_INCREF(__pyx_t_5);
    __pyx_t_7 = 0;
    {
      PyObject *__pyx_callargs[5] = {__pyx_t_5, __pyx_v_reason, __pyx_v_prev_interval, __pyx_v_current_interval, __pyx_v_gap_seconds};
      __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_log_session_split_reason, __pyx_callargs+__pyx_t_7, (5-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3601, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "ws_package/controllers/activity_controller.py":3602
 *             reason = self._determine_sleep_reason(gap_seconds)
 *             self._log_session_split_reason(reason, prev_interval, current_interval, gap_seconds)
 *             return True             # <<<<<<<<<<<<<<
 * 
 *         return False
*/
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_True);
    __pyx_r = Py_True;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":3599
 * 
 *         gap_seconds = self._calculate_gap_seconds(prev_interval, current_interval)
 *         if gap_seconds > self.session_gap_threshold_seconds:             # <<<<<<<<<<<<<<
 *             reason = self._determine_sleep_reason(gap_seconds)
 *             self._log_session_split_reason(reason, prev_interval, current_interval, gap_seconds)
*/
  }

  /* "ws_package/controllers/activity_controller.py":3604
 *             return True
 * 
 *         return False             # <<<<<<<<<<<<<<
 * 
 *     async def _verify_user_activity_during_period(self, start_time: datetime.datetime, end_time: datetime.datetime) -> bool:
*/
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(Py_False);
  __pyx_r = Py_False;
  goto __pyx_L0;

  /* "ws_package/controllers/activity_controller.py":3583
 *         )
 * 
 *     def _should_start_new_session(self, prev_interval, current_interval) -> bool:             # <<<<<<<<<<<<<<
 *         """Determine whether a new session should begin based on counters and gaps."""
 *         if not prev_interval:
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._should_start_new_session", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_gap_seconds);
  __Pyx_XDECREF(__pyx_v_reason);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_128generator24(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":3606
 *         return False
 * 
 *     async def _verify_user_activity_during_period(self, start_time: datetime.datetime, end_time: datetime.datetime) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Verify if there was actual user activity (keyboard/mouse) during a time period.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_127_verify_user_activity_during_period(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_126_verify_user_activity_during_period, "\n        Verify if there was actual user activity (keyboard/mouse) during a time period.\n        This helps prevent creating intervals for background wake events.\n        \n        Returns:\n            True if user activity detected, False otherwise\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_127_verify_user_activity_during_period = {"_verify_user_activity_during_period", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_127_verify_user_activity_during_period, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_126_verify_user_activity_during_period};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_127_verify_user_activity_during_period(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  CYTHON_UNUSED PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_start_time = 0;
  PyObject *__pyx_v_end_time = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_verify_user_activity_during_period (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_start_time,&__pyx_mstate_global->__pyx_n_u_end_time,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 3606, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 3606, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3606, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3606, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_verify_user_activity_during_period", 0) < (0)) __PYX_ERR(0, 3606, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 3; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_verify_user_activity_during_period", 1, 3, 3, i); __PYX_ERR(0, 3606, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 3)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3606, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3606, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 3606, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_start_time = values[1];
    __pyx_v_end_time = values[2];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_verify_user_activity_during_period", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 3606, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._verify_user_activity_during_period", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_126_verify_user_activity_during_period(__pyx_self, __pyx_v_self, __pyx_v_start_time, __pyx_v_end_time);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_126_verify_user_activity_during_period(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_start_time, PyObject *__pyx_v_end_time) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_verify_user_activity_during_period", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 3606, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_start_time = __pyx_v_start_time;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_start_time);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_start_time);
  __pyx_cur_scope->__pyx_v_end_time = __pyx_v_end_time;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_end_time);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_end_time);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_128generator24, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[40]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_verify_user_activity_during_per, __pyx_mstate_global->__pyx_n_u_ActivityController__verify_user, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 3606, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._verify_user_activity_during_period", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_128generator24(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  size_t __pyx_t_8;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  Py_ssize_t __pyx_t_17;
  PyObject *(*__pyx_t_18)(PyObject *);
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  double __pyx_t_22;
  PyObject *__pyx_t_23[9];
  PyObject *__pyx_t_24 = NULL;
  int __pyx_t_25;
  int __pyx_t_26;
  char const *__pyx_t_27;
  PyObject *__pyx_t_28 = NULL;
  PyObject *__pyx_t_29 = NULL;
  PyObject *__pyx_t_30 = NULL;
  __Pyx_PySendResult __pyx_t_31;
  PyObject *__pyx_t_32 = NULL;
  PyObject *__pyx_t_33 = NULL;
  PyObject *__pyx_t_34 = NULL;
  int __pyx_t_35;
  char const *__pyx_t_36;
  char const *__pyx_t_37;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_verify_user_activity_during_period", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L62_resume_from_await;
    case 2: goto __pyx_L72_resume_from_await;
    case 3: goto __pyx_L76_resume_from_await;
    case 4: goto __pyx_L77_resume_from_await;
    case 5: goto __pyx_L78_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 3606, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":3614
 *             True if user activity detected, False otherwise
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # On macOS, check HID idle time to verify user activity
 *             if platform.system() == "Darwin":
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":3616
 *         try:
 *             # On macOS, check HID idle time to verify user activity
 *             if platform.system() == "Darwin":             # <<<<<<<<<<<<<<
 *                 try:
 *                     # Get current HID idle time
*/
      __pyx_t_5 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3616, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_system); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3616, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_5);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3616, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_t_9 = (__Pyx_PyUnicode_Equals(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_Darwin, Py_EQ)); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 3616, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_9) {

        /* "ws_package/controllers/activity_controller.py":3617
 *             # On macOS, check HID idle time to verify user activity
 *             if platform.system() == "Darwin":
 *                 try:             # <<<<<<<<<<<<<<
 *                     # Get current HID idle time
 *                     ioreg_output = subprocess.check_output(
*/
        {
          __Pyx_ExceptionSave(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_12);
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":3619
 *                 try:
 *                     # Get current HID idle time
 *                     ioreg_output = subprocess.check_output(             # <<<<<<<<<<<<<<
 *                         ['ioreg', '-c', 'IOHIDSystem'],
 *                         stderr=subprocess.DEVNULL,
*/
            __pyx_t_6 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_subprocess); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3619, __pyx_L11_error)
            __Pyx_GOTREF(__pyx_t_13);
            __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_check_output); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3619, __pyx_L11_error)
            __Pyx_GOTREF(__pyx_t_14);
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

            /* "ws_package/controllers/activity_controller.py":3620
 *                     # Get current HID idle time
 *                     ioreg_output = subprocess.check_output(
 *                         ['ioreg', '-c', 'IOHIDSystem'],             # <<<<<<<<<<<<<<
 *                         stderr=subprocess.DEVNULL,
 *                         timeout=2
*/
            __pyx_t_13 = PyList_New(3); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3620, __pyx_L11_error)
            __Pyx_GOTREF(__pyx_t_13);
            __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_ioreg);
            __Pyx_GIVEREF(__pyx_mstate_global->__pyx_n_u_ioreg);
            if (__Pyx_PyList_SET_ITEM(__pyx_t_13, 0, __pyx_mstate_global->__pyx_n_u_ioreg) != (0)) __PYX_ERR(0, 3620, __pyx_L11_error);
            __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_c);
            __Pyx_GIVEREF(__pyx_mstate_global->__pyx_kp_u_c);
            if (__Pyx_PyList_SET_ITEM(__pyx_t_13, 1, __pyx_mstate_global->__pyx_kp_u_c) != (0)) __PYX_ERR(0, 3620, __pyx_L11_error);
            __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_IOHIDSystem);
            __Pyx_GIVEREF(__pyx_mstate_global->__pyx_n_u_IOHIDSystem);
            if (__Pyx_PyList_SET_ITEM(__pyx_t_13, 2, __pyx_mstate_global->__pyx_n_u_IOHIDSystem) != (0)) __PYX_ERR(0, 3620, __pyx_L11_error);

            /* "ws_package/controllers/activity_controller.py":3621
 *                     ioreg_output = subprocess.check_output(
 *                         ['ioreg', '-c', 'IOHIDSystem'],
 *                         stderr=subprocess.DEVNULL,             # <<<<<<<<<<<<<<
 *                         timeout=2
 *                     ).decode('ascii', errors='ignore')
*/
            __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_subprocess); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3621, __pyx_L11_error)
            __Pyx_GOTREF(__pyx_t_15);
            __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_DEVNULL); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3621, __pyx_L11_error)
            __Pyx_GOTREF(__pyx_t_16);
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_14))) {
              __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_14);
              assert(__pyx_t_6);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
              __Pyx_INCREF(__pyx_t_6);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 2 : 0)] = {__pyx_t_6, __pyx_t_13};
              __pyx_t_15 = __Pyx_MakeVectorcallBuilderKwds(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3619, __pyx_L11_error)
              __Pyx_GOTREF(__pyx_t_15);
              if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_stderr, __pyx_t_16, __pyx_t_15, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 3619, __pyx_L11_error)
              if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_timeout, __pyx_mstate_global->__pyx_int_2, __pyx_t_15, __pyx_callargs+2, 1) < (0)) __PYX_ERR(0, 3619, __pyx_L11_error)
              __pyx_t_5 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_15);
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3619, __pyx_L11_error)
              __Pyx_GOTREF(__pyx_t_5);
            }
            __pyx_t_7 = __pyx_t_5;
            __Pyx_INCREF(__pyx_t_7);
            __pyx_t_8 = 0;
            {
              PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_7, __pyx_mstate_global->__pyx_n_u_ascii};
              __pyx_t_14 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3623, __pyx_L11_error)
              __Pyx_GOTREF(__pyx_t_14);
              if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_errors, __pyx_mstate_global->__pyx_n_u_ignore, __pyx_t_14, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 3623, __pyx_L11_error)
              __pyx_t_4 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_decode, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_14);
              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3623, __pyx_L11_error)
              __Pyx_GOTREF(__pyx_t_4);
            }
            __Pyx_GIVEREF(__pyx_t_4);
            __pyx_cur_scope->__pyx_v_ioreg_output = __pyx_t_4;
            __pyx_t_4 = 0;

            /* "ws_package/controllers/activity_controller.py":3626
 * 
 *                     # Extract HIDIdleTime (time since last keyboard/mouse input)
 *                     for line in ioreg_output.splitlines():             # <<<<<<<<<<<<<<
 *                         if 'HIDIdleTime' in line:
 *                             try:
*/
            __pyx_t_5 = __pyx_cur_scope->__pyx_v_ioreg_output;
            __Pyx_INCREF(__pyx_t_5);
            __pyx_t_8 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
              __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_splitlines, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3626, __pyx_L11_error)
              __Pyx_GOTREF(__pyx_t_4);
            }
            if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
              __pyx_t_5 = __pyx_t_4; __Pyx_INCREF(__pyx_t_5);
              __pyx_t_17 = 0;
              __pyx_t_18 = NULL;
            } else {
              __pyx_t_17 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3626, __pyx_L11_error)
              __Pyx_GOTREF(__pyx_t_5);
              __pyx_t_18 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3626, __pyx_L11_error)
            }
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            for (;;) {
              if (likely(!__pyx_t_18)) {
                if (likely(PyList_CheckExact(__pyx_t_5))) {
                  {
                    Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_5);
                    #if !CYTHON_ASSUME_SAFE_SIZE
                    if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3626, __pyx_L11_error)
                    #endif
                    if (__pyx_t_17 >= __pyx_temp) break;
                  }
                  __pyx_t_4 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_5, __pyx_t_17, __Pyx_ReferenceSharing_OwnStrongReference);
                  ++__pyx_t_17;
                } else {
                  {
                    Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_5);
                    #if !CYTHON_ASSUME_SAFE_SIZE
                    if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3626, __pyx_L11_error)
                    #endif
                    if (__pyx_t_17 >= __pyx_temp) break;
                  }
                  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                  __pyx_t_4 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_17));
                  #else
                  __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_17);
                  #endif
                  ++__pyx_t_17;
                }
                if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3626, __pyx_L11_error)
              } else {
                __pyx_t_4 = __pyx_t_18(__pyx_t_5);
                if (unlikely(!__pyx_t_4)) {
                  PyObject* exc_type = PyErr_Occurred();
                  if (exc_type) {
                    if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 3626, __pyx_L11_error)
                    PyErr_Clear();
                  }
                  break;
                }
              }
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_line);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_line, __pyx_t_4);
              __Pyx_GIVEREF(__pyx_t_4);
              __pyx_t_4 = 0;

              /* "ws_package/controllers/activity_controller.py":3627
 *                     # Extract HIDIdleTime (time since last keyboard/mouse input)
 *                     for line in ioreg_output.splitlines():
 *                         if 'HIDIdleTime' in line:             # <<<<<<<<<<<<<<
 *                             try:
 *                                 idle_time_ns = int(line.split('=')[-1].strip().rstrip(';'))
*/
              __pyx_t_9 = (__Pyx_PySequence_ContainsTF(__pyx_mstate_global->__pyx_n_u_HIDIdleTime, __pyx_cur_scope->__pyx_v_line, Py_EQ)); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 3627, __pyx_L11_error)
              if (__pyx_t_9) {

                /* "ws_package/controllers/activity_controller.py":3628
 *                     for line in ioreg_output.splitlines():
 *                         if 'HIDIdleTime' in line:
 *                             try:             # <<<<<<<<<<<<<<
 *                                 idle_time_ns = int(line.split('=')[-1].strip().rstrip(';'))
 *                                 idle_time_seconds = idle_time_ns / 1000000000.0
*/
                {
                  __Pyx_ExceptionSave(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21);
                  __Pyx_XGOTREF(__pyx_t_19);
                  __Pyx_XGOTREF(__pyx_t_20);
                  __Pyx_XGOTREF(__pyx_t_21);
                  /*try:*/ {

                    /* "ws_package/controllers/activity_controller.py":3629
 *                         if 'HIDIdleTime' in line:
 *                             try:
 *                                 idle_time_ns = int(line.split('=')[-1].strip().rstrip(';'))             # <<<<<<<<<<<<<<
 *                                 idle_time_seconds = idle_time_ns / 1000000000.0
 * 
*/
                    __pyx_t_13 = __pyx_cur_scope->__pyx_v_line;
                    __Pyx_INCREF(__pyx_t_13);
                    __pyx_t_8 = 0;
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u__10};
                      __pyx_t_16 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_split, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                      if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3629, __pyx_L20_error)
                      __Pyx_GOTREF(__pyx_t_16);
                    }
                    __pyx_t_13 = __Pyx_GetItemInt(__pyx_t_16, -1L, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3629, __pyx_L20_error)
                    __Pyx_GOTREF(__pyx_t_13);
                    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                    __pyx_t_15 = __pyx_t_13;
                    __Pyx_INCREF(__pyx_t_15);
                    __pyx_t_8 = 0;
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL};
                      __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strip, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                      if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3629, __pyx_L20_error)
                      __Pyx_GOTREF(__pyx_t_7);
                    }
                    __pyx_t_14 = __pyx_t_7;
                    __Pyx_INCREF(__pyx_t_14);
                    __pyx_t_8 = 0;
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_14, __pyx_mstate_global->__pyx_kp_u__11};
                      __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_rstrip, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3629, __pyx_L20_error)
                      __Pyx_GOTREF(__pyx_t_4);
                    }
                    __pyx_t_7 = __Pyx_PyNumber_Int(__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3629, __pyx_L20_error)
                    __Pyx_GOTREF(__pyx_t_7);
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_idle_time_ns);
                    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_idle_time_ns, ((PyObject*)__pyx_t_7));
                    __Pyx_GIVEREF(__pyx_t_7);
                    __pyx_t_7 = 0;

                    /* "ws_package/controllers/activity_controller.py":3630
 *                             try:
 *                                 idle_time_ns = int(line.split('=')[-1].strip().rstrip(';'))
 *                                 idle_time_seconds = idle_time_ns / 1000000000.0             # <<<<<<<<<<<<<<
 * 
 *                                 # If idle time is very recent (< 5 minutes), user was likely active
*/
                    __pyx_t_7 = __Pyx_PyFloat_TrueDivideObjC(__pyx_cur_scope->__pyx_v_idle_time_ns, __pyx_mstate_global->__pyx_float_1000000000_0, 1000000000.0, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3630, __pyx_L20_error)
                    __Pyx_GOTREF(__pyx_t_7);
                    __pyx_t_22 = __Pyx_PyFloat_AsDouble(__pyx_t_7); if (unlikely((__pyx_t_22 == (double)-1) && PyErr_Occurred())) __PYX_ERR(0, 3630, __pyx_L20_error)
                    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                    __pyx_cur_scope->__pyx_v_idle_time_seconds = __pyx_t_22;

                    /* "ws_package/controllers/activity_controller.py":3634
 *                                 # If idle time is very recent (< 5 minutes), user was likely active
 *                                 # If idle time is long (> 10 minutes), likely no user activity
 *                                 current_time = datetime.datetime.now()             # <<<<<<<<<<<<<<
 *                                 period_duration = (end_time - start_time).total_seconds()
 * 
*/
                    __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3634, __pyx_L20_error)
                    __Pyx_GOTREF(__pyx_t_14);
                    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3634, __pyx_L20_error)
                    __Pyx_GOTREF(__pyx_t_13);
                    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                    __pyx_t_4 = __pyx_t_13;
                    __Pyx_INCREF(__pyx_t_4);
                    __pyx_t_8 = 0;
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
                      __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                      if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3634, __pyx_L20_error)
                      __Pyx_GOTREF(__pyx_t_7);
                    }
                    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_current_time);
                    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_current_time, __pyx_t_7);
                    __Pyx_GIVEREF(__pyx_t_7);
                    __pyx_t_7 = 0;

                    /* "ws_package/controllers/activity_controller.py":3635
 *                                 # If idle time is long (> 10 minutes), likely no user activity
 *                                 current_time = datetime.datetime.now()
 *                                 period_duration = (end_time - start_time).total_seconds()             # <<<<<<<<<<<<<<
 * 
 *                                 # If the period is in the past and idle time is much longer than period duration,
*/
                    __pyx_t_4 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_end_time, __pyx_cur_scope->__pyx_v_start_time); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3635, __pyx_L20_error)
                    __Pyx_GOTREF(__pyx_t_4);
                    __pyx_t_13 = __pyx_t_4;
                    __Pyx_INCREF(__pyx_t_13);
                    __pyx_t_8 = 0;
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_13, NULL};
                      __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_total_seconds, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3635, __pyx_L20_error)
                      __Pyx_GOTREF(__pyx_t_7);
                    }
                    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_period_duration);
                    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_period_duration, __pyx_t_7);
                    __Pyx_GIVEREF(__pyx_t_7);
                    __pyx_t_7 = 0;

                    /* "ws_package/controllers/activity_controller.py":3639
 *                                 # If the period is in the past and idle time is much longer than period duration,
 *                                 # it's likely there was no user activity during that period
 *                                 if end_time < current_time:             # <<<<<<<<<<<<<<
 *                                     # Period is in the past - check if idle time suggests no activity
 *                                     if idle_time_seconds > period_duration + 300:  # 5 min buffer
*/
                    __pyx_t_7 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_end_time, __pyx_cur_scope->__pyx_v_current_time, Py_LT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3639, __pyx_L20_error)
                    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 3639, __pyx_L20_error)
                    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                    if (__pyx_t_9) {

                      /* "ws_package/controllers/activity_controller.py":3641
 *                                 if end_time < current_time:
 *                                     # Period is in the past - check if idle time suggests no activity
 *                                     if idle_time_seconds > period_duration + 300:  # 5 min buffer             # <<<<<<<<<<<<<<
 *                                         logger.debug(
 *                                             f"No user activity during period {start_time} - {end_time}: "
*/
                      __pyx_t_7 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_idle_time_seconds); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3641, __pyx_L20_error)
                      __Pyx_GOTREF(__pyx_t_7);
                      __pyx_t_4 = __Pyx_PyLong_AddObjC(__pyx_cur_scope->__pyx_v_period_duration, __pyx_mstate_global->__pyx_int_300, 0x12C, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3641, __pyx_L20_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __pyx_t_13 = PyObject_RichCompare(__pyx_t_7, __pyx_t_4, Py_GT); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3641, __pyx_L20_error)
                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 3641, __pyx_L20_error)
                      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                      if (__pyx_t_9) {

                        /* "ws_package/controllers/activity_controller.py":3642
 *                                     # Period is in the past - check if idle time suggests no activity
 *                                     if idle_time_seconds > period_duration + 300:  # 5 min buffer
 *                                         logger.debug(             # <<<<<<<<<<<<<<
 *                                             f"No user activity during period {start_time} - {end_time}: "
 *                                             f"Current idle time ({idle_time_seconds:.0f}s) >> period duration ({period_duration:.0f}s)"
*/
                        __pyx_t_4 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3642, __pyx_L20_error)
                        __Pyx_GOTREF(__pyx_t_7);
                        __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3642, __pyx_L20_error)
                        __Pyx_GOTREF(__pyx_t_14);
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

                        /* "ws_package/controllers/activity_controller.py":3643
 *                                     if idle_time_seconds > period_duration + 300:  # 5 min buffer
 *                                         logger.debug(
 *                                             f"No user activity during period {start_time} - {end_time}: "             # <<<<<<<<<<<<<<
 *                                             f"Current idle time ({idle_time_seconds:.0f}s) >> period duration ({period_duration:.0f}s)"
 *                                         )
*/
                        __pyx_t_7 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_start_time, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3643, __pyx_L20_error)
                        __Pyx_GOTREF(__pyx_t_7);
                        __pyx_t_15 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_end_time, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3643, __pyx_L20_error)
                        __Pyx_GOTREF(__pyx_t_15);

                        /* "ws_package/controllers/activity_controller.py":3644
 *                                         logger.debug(
 *                                             f"No user activity during period {start_time} - {end_time}: "
 *                                             f"Current idle time ({idle_time_seconds:.0f}s) >> period duration ({period_duration:.0f}s)"             # <<<<<<<<<<<<<<
 *                                         )
 *                                         return False
*/
                        __pyx_t_16 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_idle_time_seconds); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3644, __pyx_L20_error)
                        __Pyx_GOTREF(__pyx_t_16);
                        __pyx_t_6 = __Pyx_PyObject_Format(__pyx_t_16, __pyx_mstate_global->__pyx_kp_u_0f); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3644, __pyx_L20_error)
                        __Pyx_GOTREF(__pyx_t_6);
                        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                        __pyx_t_16 = __Pyx_PyObject_Format(__pyx_cur_scope->__pyx_v_period_duration, __pyx_mstate_global->__pyx_kp_u_0f); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3644, __pyx_L20_error)
                        __Pyx_GOTREF(__pyx_t_16);
                        __pyx_t_23[0] = __pyx_mstate_global->__pyx_kp_u_No_user_activity_during_period;
                        __pyx_t_23[1] = __pyx_t_7;
                        __pyx_t_23[2] = __pyx_mstate_global->__pyx_kp_u__8;
                        __pyx_t_23[3] = __pyx_t_15;
                        __pyx_t_23[4] = __pyx_mstate_global->__pyx_kp_u_Current_idle_time;
                        __pyx_t_23[5] = __pyx_t_6;
                        __pyx_t_23[6] = __pyx_mstate_global->__pyx_kp_u_s_period_duration;
                        __pyx_t_23[7] = __pyx_t_16;
                        __pyx_t_23[8] = __pyx_mstate_global->__pyx_kp_u_s;

                        /* "ws_package/controllers/activity_controller.py":3643
 *                                     if idle_time_seconds > period_duration + 300:  # 5 min buffer
 *                                         logger.debug(
 *                                             f"No user activity during period {start_time} - {end_time}: "             # <<<<<<<<<<<<<<
 *                                             f"Current idle time ({idle_time_seconds:.0f}s) >> period duration ({period_duration:.0f}s)"
 *                                         )
*/
                        __pyx_t_24 = __Pyx_PyUnicode_Join(__pyx_t_23, 9, 31 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_7) + 3 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_15) + 21 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6) + 23 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_16) + 2, 127 | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_7) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_15) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_16));
                        if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3643, __pyx_L20_error)
                        __Pyx_GOTREF(__pyx_t_24);
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                        __pyx_t_8 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_14))) {
                          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_14);
                          assert(__pyx_t_4);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
                          __Pyx_INCREF(__pyx_t_4);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
                          __pyx_t_8 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_24};
                          __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                          __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                          if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3642, __pyx_L20_error)
                          __Pyx_GOTREF(__pyx_t_13);
                        }
                        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

                        /* "ws_package/controllers/activity_controller.py":3646
 *                                             f"Current idle time ({idle_time_seconds:.0f}s) >> period duration ({period_duration:.0f}s)"
 *                                         )
 *                                         return False             # <<<<<<<<<<<<<<
 * 
 *                                 # If idle time is short (< 5 min), user is currently active
*/
                        __Pyx_XDECREF(__pyx_r);
                        __Pyx_INCREF(Py_False);
                        __pyx_r = Py_False;
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                        goto __pyx_L24_try_return;

                        /* "ws_package/controllers/activity_controller.py":3641
 *                                 if end_time < current_time:
 *                                     # Period is in the past - check if idle time suggests no activity
 *                                     if idle_time_seconds > period_duration + 300:  # 5 min buffer             # <<<<<<<<<<<<<<
 *                                         logger.debug(
 *                                             f"No user activity during period {start_time} - {end_time}: "
*/
                      }

                      /* "ws_package/controllers/activity_controller.py":3639
 *                                 # If the period is in the past and idle time is much longer than period duration,
 *                                 # it's likely there was no user activity during that period
 *                                 if end_time < current_time:             # <<<<<<<<<<<<<<
 *                                     # Period is in the past - check if idle time suggests no activity
 *                                     if idle_time_seconds > period_duration + 300:  # 5 min buffer
*/
                    }

                    /* "ws_package/controllers/activity_controller.py":3650
 *                                 # If idle time is short (< 5 min), user is currently active
 *                                 # This suggests the period might have had activity
 *                                 if idle_time_seconds < 300:             # <<<<<<<<<<<<<<
 *                                     return True
 * 
*/
                    __pyx_t_9 = (__pyx_cur_scope->__pyx_v_idle_time_seconds < 300.0);
                    if (__pyx_t_9) {

                      /* "ws_package/controllers/activity_controller.py":3651
 *                                 # This suggests the period might have had activity
 *                                 if idle_time_seconds < 300:
 *                                     return True             # <<<<<<<<<<<<<<
 * 
 *                             except (ValueError, IndexError):
*/
                      __Pyx_XDECREF(__pyx_r);
                      __Pyx_INCREF(Py_True);
                      __pyx_r = Py_True;
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      goto __pyx_L24_try_return;

                      /* "ws_package/controllers/activity_controller.py":3650
 *                                 # If idle time is short (< 5 min), user is currently active
 *                                 # This suggests the period might have had activity
 *                                 if idle_time_seconds < 300:             # <<<<<<<<<<<<<<
 *                                     return True
 * 
*/
                    }

                    /* "ws_package/controllers/activity_controller.py":3628
 *                     for line in ioreg_output.splitlines():
 *                         if 'HIDIdleTime' in line:
 *                             try:             # <<<<<<<<<<<<<<
 *                                 idle_time_ns = int(line.split('=')[-1].strip().rstrip(';'))
 *                                 idle_time_seconds = idle_time_ns / 1000000000.0
*/
                  }
                  __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                  __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                  __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                  goto __pyx_L27_try_end;
                  __pyx_L20_error:;
                  __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                  __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

                  /* "ws_package/controllers/activity_controller.py":3653
 *                                     return True
 * 
 *                             except (ValueError, IndexError):             # <<<<<<<<<<<<<<
 *                                 pass
 * 
*/
                  __pyx_t_25 = __Pyx_PyErr_ExceptionMatches2(((PyObject *)(((PyTypeObject*)PyExc_ValueError))), ((PyObject *)(((PyTypeObject*)PyExc_IndexError))));
                  if (__pyx_t_25) {
                    __Pyx_ErrRestore(0,0,0);
                    goto __pyx_L21_exception_handled;
                  }
                  goto __pyx_L22_except_error;

                  /* "ws_package/controllers/activity_controller.py":3628
 *                     for line in ioreg_output.splitlines():
 *                         if 'HIDIdleTime' in line:
 *                             try:             # <<<<<<<<<<<<<<
 *                                 idle_time_ns = int(line.split('=')[-1].strip().rstrip(';'))
 *                                 idle_time_seconds = idle_time_ns / 1000000000.0
*/
                  __pyx_L22_except_error:;
                  __Pyx_XGIVEREF(__pyx_t_19);
                  __Pyx_XGIVEREF(__pyx_t_20);
                  __Pyx_XGIVEREF(__pyx_t_21);
                  __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21);
                  goto __pyx_L11_error;
                  __pyx_L24_try_return:;
                  __Pyx_XGIVEREF(__pyx_t_19);
                  __Pyx_XGIVEREF(__pyx_t_20);
                  __Pyx_XGIVEREF(__pyx_t_21);
                  __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21);
                  goto __pyx_L15_try_return;
                  __pyx_L21_exception_handled:;
                  __Pyx_XGIVEREF(__pyx_t_19);
                  __Pyx_XGIVEREF(__pyx_t_20);
                  __Pyx_XGIVEREF(__pyx_t_21);
                  __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21);
                  __pyx_L27_try_end:;
                }

                /* "ws_package/controllers/activity_controller.py":3627
 *                     # Extract HIDIdleTime (time since last keyboard/mouse input)
 *                     for line in ioreg_output.splitlines():
 *                         if 'HIDIdleTime' in line:             # <<<<<<<<<<<<<<
 *                             try:
 *                                 idle_time_ns = int(line.split('=')[-1].strip().rstrip(';'))
*/
              }

              /* "ws_package/controllers/activity_controller.py":3626
 * 
 *                     # Extract HIDIdleTime (time since last keyboard/mouse input)
 *                     for line in ioreg_output.splitlines():             # <<<<<<<<<<<<<<
 *                         if 'HIDIdleTime' in line:
 *                             try:
*/
            }
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

            /* "ws_package/controllers/activity_controller.py":3658
 *                     # If we can't determine, be conservative and return False
 *                     # Better to skip an interval than create a false one
 *                     return False             # <<<<<<<<<<<<<<
 * 
 *                 except Exception as e:
*/
            __Pyx_XDECREF(__pyx_r);
            __Pyx_INCREF(Py_False);
            __pyx_r = Py_False;
            goto __pyx_L15_try_return;

            /* "ws_package/controllers/activity_controller.py":3617
 *             # On macOS, check HID idle time to verify user activity
 *             if platform.system() == "Darwin":
 *                 try:             # <<<<<<<<<<<<<<
 *                     # Get current HID idle time
 *                     ioreg_output = subprocess.check_output(
*/
          }
          __pyx_L11_error:;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "ws_package/controllers/activity_controller.py":3660
 *                     return False
 * 
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.debug("Could not verify macOS user activity: %s", e)
 *                     # On error, be conservative - don't create interval
*/
          __pyx_t_25 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
          if (__pyx_t_25) {
            __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._verify_user_activity_during_period", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_13, &__pyx_t_14) < 0) __PYX_ERR(0, 3660, __pyx_L13_except_error)
            __Pyx_XGOTREF(__pyx_t_5);
            __Pyx_XGOTREF(__pyx_t_13);
            __Pyx_XGOTREF(__pyx_t_14);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_GIVEREF(__pyx_t_13);
            __pyx_cur_scope->__pyx_v_e = __pyx_t_13;
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":3661
 * 
 *                 except Exception as e:
 *                     logger.debug("Could not verify macOS user activity: %s", e)             # <<<<<<<<<<<<<<
 *                     # On error, be conservative - don't create interval
 *                     return False
*/
              __pyx_t_4 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3661, __pyx_L39_error)
              __Pyx_GOTREF(__pyx_t_16);
              __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3661, __pyx_L39_error)
              __Pyx_GOTREF(__pyx_t_6);
              __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_6))) {
                __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
                assert(__pyx_t_4);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                __Pyx_INCREF(__pyx_t_4);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Could_not_verify_macOS_user_acti, __pyx_cur_scope->__pyx_v_e};
                __pyx_t_24 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3661, __pyx_L39_error)
                __Pyx_GOTREF(__pyx_t_24);
              }
              __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;

              /* "ws_package/controllers/activity_controller.py":3663
 *                     logger.debug("Could not verify macOS user activity: %s", e)
 *                     # On error, be conservative - don't create interval
 *                     return False             # <<<<<<<<<<<<<<
 * 
 *             # For Windows/Linux, use a simpler check
*/
              __Pyx_XDECREF(__pyx_r);
              __Pyx_INCREF(Py_False);
              __pyx_r = Py_False;
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              goto __pyx_L38_return;
            }

            /* "ws_package/controllers/activity_controller.py":3660
 *                     return False
 * 
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.debug("Could not verify macOS user activity: %s", e)
 *                     # On error, be conservative - don't create interval
*/
            /*finally:*/ {
              __pyx_L39_error:;
              /*exception exit:*/{
                __Pyx_PyThreadState_assign
                __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_t_30 = 0;
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                 __Pyx_ExceptionSwap(&__pyx_t_28, &__pyx_t_29, &__pyx_t_30);
                if ( unlikely(__Pyx_GetException(&__pyx_t_21, &__pyx_t_20, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_21, &__pyx_t_20, &__pyx_t_19);
                __Pyx_XGOTREF(__pyx_t_21);
                __Pyx_XGOTREF(__pyx_t_20);
                __Pyx_XGOTREF(__pyx_t_19);
                __Pyx_XGOTREF(__pyx_t_28);
                __Pyx_XGOTREF(__pyx_t_29);
                __Pyx_XGOTREF(__pyx_t_30);
                __pyx_t_25 = __pyx_lineno; __pyx_t_26 = __pyx_clineno; __pyx_t_27 = __pyx_filename;
                {
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                }
                __Pyx_XGIVEREF(__pyx_t_28);
                __Pyx_XGIVEREF(__pyx_t_29);
                __Pyx_XGIVEREF(__pyx_t_30);
                __Pyx_ExceptionReset(__pyx_t_28, __pyx_t_29, __pyx_t_30);
                __Pyx_XGIVEREF(__pyx_t_21);
                __Pyx_XGIVEREF(__pyx_t_20);
                __Pyx_XGIVEREF(__pyx_t_19);
                __Pyx_ErrRestore(__pyx_t_21, __pyx_t_20, __pyx_t_19);
                __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_t_30 = 0;
                __pyx_lineno = __pyx_t_25; __pyx_clineno = __pyx_t_26; __pyx_filename = __pyx_t_27;
                goto __pyx_L13_except_error;
              }
              __pyx_L38_return: {
                __pyx_t_30 = __pyx_r;
                __pyx_r = 0;
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                __pyx_r = __pyx_t_30;
                __pyx_t_30 = 0;
                goto __pyx_L14_except_return;
              }
            }
          }
          goto __pyx_L13_except_error;

          /* "ws_package/controllers/activity_controller.py":3617
 *             # On macOS, check HID idle time to verify user activity
 *             if platform.system() == "Darwin":
 *                 try:             # <<<<<<<<<<<<<<
 *                     # Get current HID idle time
 *                     ioreg_output = subprocess.check_output(
*/
          __pyx_L13_except_error:;
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
          goto __pyx_L4_error;
          __pyx_L15_try_return:;
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
          goto __pyx_L8_try_return;
          __pyx_L14_except_return:;
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ExceptionReset(__pyx_t_10, __pyx_t_11, __pyx_t_12);
          goto __pyx_L8_try_return;
        }

        /* "ws_package/controllers/activity_controller.py":3616
 *         try:
 *             # On macOS, check HID idle time to verify user activity
 *             if platform.system() == "Darwin":             # <<<<<<<<<<<<<<
 *                 try:
 *                     # Get current HID idle time
*/
      }

      /* "ws_package/controllers/activity_controller.py":3667
 *             # For Windows/Linux, use a simpler check
 *             # Check if there are any app monitor records during this period
 *             try:             # <<<<<<<<<<<<<<
 *                 with db_lock_manager.read_lock():
 *                     async with async_session() as session:
*/
      {
        __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_11, &__pyx_t_10);
        __Pyx_XGOTREF(__pyx_t_12);
        __Pyx_XGOTREF(__pyx_t_11);
        __Pyx_XGOTREF(__pyx_t_10);
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":3668
 *             # Check if there are any app monitor records during this period
 *             try:
 *                 with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                     async with async_session() as session:
 *                         query = select(Appmonitor).where(
*/
          /*with:*/ {
            __pyx_t_13 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3668, __pyx_L45_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3668, __pyx_L45_error)
            __Pyx_GOTREF(__pyx_t_24);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_24))) {
              __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_24);
              assert(__pyx_t_13);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_24);
              __Pyx_INCREF(__pyx_t_13);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_24, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_13, NULL};
              __pyx_t_14 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_24, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
              if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3668, __pyx_L45_error)
              __Pyx_GOTREF(__pyx_t_14);
            }
            __pyx_t_30 = __Pyx_PyObject_LookupSpecial(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 3668, __pyx_L45_error)
            __Pyx_GOTREF(__pyx_t_30);
            __pyx_t_13 = NULL;
            __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3668, __pyx_L51_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (likely(PyMethod_Check(__pyx_t_5))) {
              __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_5);
              assert(__pyx_t_13);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
              __Pyx_INCREF(__pyx_t_13);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_13, NULL};
              __pyx_t_24 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3668, __pyx_L51_error)
              __Pyx_GOTREF(__pyx_t_24);
            }
            __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            /*try:*/ {
              {
                __Pyx_ExceptionSave(&__pyx_t_29, &__pyx_t_28, &__pyx_t_19);
                __Pyx_XGOTREF(__pyx_t_29);
                __Pyx_XGOTREF(__pyx_t_28);
                __Pyx_XGOTREF(__pyx_t_19);
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":3669
 *             try:
 *                 with db_lock_manager.read_lock():
 *                     async with async_session() as session:             # <<<<<<<<<<<<<<
 *                         query = select(Appmonitor).where(
 *                             Appmonitor.timestamp >= start_time,
*/
                  /*with:*/ {
                    __pyx_t_24 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3669, __pyx_L55_error)
                    __Pyx_GOTREF(__pyx_t_5);
                    __pyx_t_8 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_5))) {
                      __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_5);
                      assert(__pyx_t_24);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                      __Pyx_INCREF(__pyx_t_24);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                      __pyx_t_8 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_24, NULL};
                      __pyx_t_14 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3669, __pyx_L55_error)
                      __Pyx_GOTREF(__pyx_t_14);
                    }
                    __pyx_t_20 = __Pyx_PyObject_LookupSpecial(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3669, __pyx_L55_error)
                    __Pyx_GOTREF(__pyx_t_20);
                    __pyx_t_24 = NULL;
                    __pyx_t_13 = __Pyx_PyObject_LookupSpecial(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3669, __pyx_L61_error)
                    __Pyx_GOTREF(__pyx_t_13);
                    __pyx_t_8 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (likely(PyMethod_Check(__pyx_t_13))) {
                      __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_13);
                      assert(__pyx_t_24);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
                      __Pyx_INCREF(__pyx_t_24);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
                      __pyx_t_8 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_24, NULL};
                      __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3669, __pyx_L61_error)
                      __Pyx_GOTREF(__pyx_t_5);
                    }
                    __pyx_t_31 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                    if (likely(__pyx_t_31 == PYGEN_NEXT)) {
                      __Pyx_GOTREF(__pyx_r);
                      __Pyx_XGIVEREF(__pyx_t_1);
                      __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                      __Pyx_XGIVEREF(__pyx_t_2);
                      __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                      __Pyx_XGIVEREF(__pyx_t_3);
                      __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                      __Pyx_XGIVEREF(__pyx_t_10);
                      __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                      __Pyx_XGIVEREF(__pyx_t_11);
                      __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
                      __Pyx_XGIVEREF(__pyx_t_12);
                      __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                      __Pyx_XGIVEREF(__pyx_t_14);
                      __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                      __Pyx_XGIVEREF(__pyx_t_19);
                      __pyx_cur_scope->__pyx_t_7 = __pyx_t_19;
                      __Pyx_XGIVEREF(__pyx_t_20);
                      __pyx_cur_scope->__pyx_t_8 = __pyx_t_20;
                      __Pyx_XGIVEREF(__pyx_t_28);
                      __pyx_cur_scope->__pyx_t_9 = __pyx_t_28;
                      __Pyx_XGIVEREF(__pyx_t_29);
                      __pyx_cur_scope->__pyx_t_10 = __pyx_t_29;
                      __Pyx_XGIVEREF(__pyx_t_30);
                      __pyx_cur_scope->__pyx_t_11 = __pyx_t_30;
                      __Pyx_XGIVEREF(__pyx_r);
                      __Pyx_RefNannyFinishContext();
                      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                      /* return from generator, awaiting value */
                      __pyx_generator->resume_label = 1;
                      return __pyx_r;
                      __pyx_L62_resume_from_await:;
                      __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                      __pyx_cur_scope->__pyx_t_0 = 0;
                      __Pyx_XGOTREF(__pyx_t_1);
                      __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                      __pyx_cur_scope->__pyx_t_1 = 0;
                      __Pyx_XGOTREF(__pyx_t_2);
                      __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                      __pyx_cur_scope->__pyx_t_2 = 0;
                      __Pyx_XGOTREF(__pyx_t_3);
                      __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                      __pyx_cur_scope->__pyx_t_3 = 0;
                      __Pyx_XGOTREF(__pyx_t_10);
                      __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
                      __pyx_cur_scope->__pyx_t_4 = 0;
                      __Pyx_XGOTREF(__pyx_t_11);
                      __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                      __pyx_cur_scope->__pyx_t_5 = 0;
                      __Pyx_XGOTREF(__pyx_t_12);
                      __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                      __pyx_cur_scope->__pyx_t_6 = 0;
                      __Pyx_XGOTREF(__pyx_t_14);
                      __pyx_t_19 = __pyx_cur_scope->__pyx_t_7;
                      __pyx_cur_scope->__pyx_t_7 = 0;
                      __Pyx_XGOTREF(__pyx_t_19);
                      __pyx_t_20 = __pyx_cur_scope->__pyx_t_8;
                      __pyx_cur_scope->__pyx_t_8 = 0;
                      __Pyx_XGOTREF(__pyx_t_20);
                      __pyx_t_28 = __pyx_cur_scope->__pyx_t_9;
                      __pyx_cur_scope->__pyx_t_9 = 0;
                      __Pyx_XGOTREF(__pyx_t_28);
                      __pyx_t_29 = __pyx_cur_scope->__pyx_t_10;
                      __pyx_cur_scope->__pyx_t_10 = 0;
                      __Pyx_XGOTREF(__pyx_t_29);
                      __pyx_t_30 = __pyx_cur_scope->__pyx_t_11;
                      __pyx_cur_scope->__pyx_t_11 = 0;
                      __Pyx_XGOTREF(__pyx_t_30);
                      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3669, __pyx_L61_error)
                      __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
                    } else if (likely(__pyx_t_31 == PYGEN_RETURN)) {
                      __Pyx_GOTREF(__pyx_r);
                      __pyx_t_5 = __pyx_r; __pyx_r = NULL;
                    } else {
                      __Pyx_XGOTREF(__pyx_r);
                      __PYX_ERR(0, 3669, __pyx_L61_error)
                    }
                    __pyx_t_13 = __pyx_t_5;
                    __pyx_t_5 = 0;
                    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                    /*try:*/ {
                      {
                        __Pyx_ExceptionSave(&__pyx_t_21, &__pyx_t_32, &__pyx_t_33);
                        __Pyx_XGOTREF(__pyx_t_21);
                        __Pyx_XGOTREF(__pyx_t_32);
                        __Pyx_XGOTREF(__pyx_t_33);
                        /*try:*/ {
                          __Pyx_GIVEREF(__pyx_t_13);
                          __pyx_cur_scope->__pyx_v_session = __pyx_t_13;
                          __pyx_t_13 = 0;

                          /* "ws_package/controllers/activity_controller.py":3670
 *                 with db_lock_manager.read_lock():
 *                     async with async_session() as session:
 *                         query = select(Appmonitor).where(             # <<<<<<<<<<<<<<
 *                             Appmonitor.timestamp >= start_time,
 *                             Appmonitor.timestamp <= end_time
*/
                          __pyx_t_4 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3670, __pyx_L66_error)
                          __Pyx_GOTREF(__pyx_t_16);
                          __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_Appmonitor); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3670, __pyx_L66_error)
                          __Pyx_GOTREF(__pyx_t_15);
                          __pyx_t_8 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_16))) {
                            __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_16);
                            assert(__pyx_t_4);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_16);
                            __Pyx_INCREF(__pyx_t_4);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_16, __pyx__function);
                            __pyx_t_8 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_15};
                            __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_16, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                            __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                            if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3670, __pyx_L66_error)
                            __Pyx_GOTREF(__pyx_t_6);
                          }
                          __pyx_t_24 = __pyx_t_6;
                          __Pyx_INCREF(__pyx_t_24);

                          /* "ws_package/controllers/activity_controller.py":3671
 *                     async with async_session() as session:
 *                         query = select(Appmonitor).where(
 *                             Appmonitor.timestamp >= start_time,             # <<<<<<<<<<<<<<
 *                             Appmonitor.timestamp <= end_time
 *                         ).limit(1)
*/
                          __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_Appmonitor); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3671, __pyx_L66_error)
                          __Pyx_GOTREF(__pyx_t_16);
                          __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_timestamp); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3671, __pyx_L66_error)
                          __Pyx_GOTREF(__pyx_t_15);
                          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                          __pyx_t_16 = PyObject_RichCompare(__pyx_t_15, __pyx_cur_scope->__pyx_v_start_time, Py_GE); __Pyx_XGOTREF(__pyx_t_16); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3671, __pyx_L66_error)
                          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

                          /* "ws_package/controllers/activity_controller.py":3672
 *                         query = select(Appmonitor).where(
 *                             Appmonitor.timestamp >= start_time,
 *                             Appmonitor.timestamp <= end_time             # <<<<<<<<<<<<<<
 *                         ).limit(1)
 * 
*/
                          __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_Appmonitor); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3672, __pyx_L66_error)
                          __Pyx_GOTREF(__pyx_t_15);
                          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_timestamp); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3672, __pyx_L66_error)
                          __Pyx_GOTREF(__pyx_t_4);
                          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                          __pyx_t_15 = PyObject_RichCompare(__pyx_t_4, __pyx_cur_scope->__pyx_v_end_time, Py_LE); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3672, __pyx_L66_error)
                          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                          __pyx_t_8 = 0;
                          {
                            PyObject *__pyx_callargs[3] = {__pyx_t_24, __pyx_t_16, __pyx_t_15};
                            __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                            __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3670, __pyx_L66_error)
                            __Pyx_GOTREF(__pyx_t_5);
                          }
                          __pyx_t_14 = __pyx_t_5;
                          __Pyx_INCREF(__pyx_t_14);
                          __pyx_t_8 = 0;
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_14, __pyx_mstate_global->__pyx_int_1};
                            __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_limit, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                            if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3673, __pyx_L66_error)
                            __Pyx_GOTREF(__pyx_t_13);
                          }
                          __Pyx_GIVEREF(__pyx_t_13);
                          __pyx_cur_scope->__pyx_v_query = __pyx_t_13;
                          __pyx_t_13 = 0;

                          /* "ws_package/controllers/activity_controller.py":3675
 *                         ).limit(1)
 * 
 *                         result = await session.execute(query)             # <<<<<<<<<<<<<<
 *                         app_data = result.scalars().first()
 * 
*/
                          __pyx_t_5 = __pyx_cur_scope->__pyx_v_session;
                          __Pyx_INCREF(__pyx_t_5);
                          __pyx_t_8 = 0;
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_query};
                            __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                            if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3675, __pyx_L66_error)
                            __Pyx_GOTREF(__pyx_t_13);
                          }
                          __pyx_t_31 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_13, &__pyx_r);
                          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                          if (likely(__pyx_t_31 == PYGEN_NEXT)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_XGIVEREF(__pyx_t_1);
                            __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                            __Pyx_XGIVEREF(__pyx_t_2);
                            __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                            __Pyx_XGIVEREF(__pyx_t_3);
                            __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                            __Pyx_XGIVEREF(__pyx_t_10);
                            __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                            __Pyx_XGIVEREF(__pyx_t_11);
                            __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
                            __Pyx_XGIVEREF(__pyx_t_12);
                            __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                            __Pyx_XGIVEREF(__pyx_t_19);
                            __pyx_cur_scope->__pyx_t_6 = __pyx_t_19;
                            __Pyx_XGIVEREF(__pyx_t_20);
                            __pyx_cur_scope->__pyx_t_7 = __pyx_t_20;
                            __Pyx_XGIVEREF(__pyx_t_21);
                            __pyx_cur_scope->__pyx_t_8 = __pyx_t_21;
                            __Pyx_XGIVEREF(__pyx_t_28);
                            __pyx_cur_scope->__pyx_t_9 = __pyx_t_28;
                            __Pyx_XGIVEREF(__pyx_t_29);
                            __pyx_cur_scope->__pyx_t_10 = __pyx_t_29;
                            __Pyx_XGIVEREF(__pyx_t_30);
                            __pyx_cur_scope->__pyx_t_11 = __pyx_t_30;
                            __Pyx_XGIVEREF(__pyx_t_32);
                            __pyx_cur_scope->__pyx_t_12 = __pyx_t_32;
                            __Pyx_XGIVEREF(__pyx_t_33);
                            __pyx_cur_scope->__pyx_t_13 = __pyx_t_33;
                            __Pyx_XGIVEREF(__pyx_r);
                            __Pyx_RefNannyFinishContext();
                            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                            /* return from generator, awaiting value */
                            __pyx_generator->resume_label = 2;
                            return __pyx_r;
                            __pyx_L72_resume_from_await:;
                            __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                            __pyx_cur_scope->__pyx_t_0 = 0;
                            __Pyx_XGOTREF(__pyx_t_1);
                            __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                            __pyx_cur_scope->__pyx_t_1 = 0;
                            __Pyx_XGOTREF(__pyx_t_2);
                            __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                            __pyx_cur_scope->__pyx_t_2 = 0;
                            __Pyx_XGOTREF(__pyx_t_3);
                            __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                            __pyx_cur_scope->__pyx_t_3 = 0;
                            __Pyx_XGOTREF(__pyx_t_10);
                            __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
                            __pyx_cur_scope->__pyx_t_4 = 0;
                            __Pyx_XGOTREF(__pyx_t_11);
                            __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                            __pyx_cur_scope->__pyx_t_5 = 0;
                            __Pyx_XGOTREF(__pyx_t_12);
                            __pyx_t_19 = __pyx_cur_scope->__pyx_t_6;
                            __pyx_cur_scope->__pyx_t_6 = 0;
                            __Pyx_XGOTREF(__pyx_t_19);
                            __pyx_t_20 = __pyx_cur_scope->__pyx_t_7;
                            __pyx_cur_scope->__pyx_t_7 = 0;
                            __Pyx_XGOTREF(__pyx_t_20);
                            __pyx_t_21 = __pyx_cur_scope->__pyx_t_8;
                            __pyx_cur_scope->__pyx_t_8 = 0;
                            __Pyx_XGOTREF(__pyx_t_21);
                            __pyx_t_28 = __pyx_cur_scope->__pyx_t_9;
                            __pyx_cur_scope->__pyx_t_9 = 0;
                            __Pyx_XGOTREF(__pyx_t_28);
                            __pyx_t_29 = __pyx_cur_scope->__pyx_t_10;
                            __pyx_cur_scope->__pyx_t_10 = 0;
                            __Pyx_XGOTREF(__pyx_t_29);
                            __pyx_t_30 = __pyx_cur_scope->__pyx_t_11;
                            __pyx_cur_scope->__pyx_t_11 = 0;
                            __Pyx_XGOTREF(__pyx_t_30);
                            __pyx_t_32 = __pyx_cur_scope->__pyx_t_12;
                            __pyx_cur_scope->__pyx_t_12 = 0;
                            __Pyx_XGOTREF(__pyx_t_32);
                            __pyx_t_33 = __pyx_cur_scope->__pyx_t_13;
                            __pyx_cur_scope->__pyx_t_13 = 0;
                            __Pyx_XGOTREF(__pyx_t_33);
                            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3675, __pyx_L66_error)
                            __pyx_t_13 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_13);
                          } else if (likely(__pyx_t_31 == PYGEN_RETURN)) {
                            __Pyx_GOTREF(__pyx_r);
                            __pyx_t_13 = __pyx_r; __pyx_r = NULL;
                          } else {
                            __Pyx_XGOTREF(__pyx_r);
                            __PYX_ERR(0, 3675, __pyx_L66_error)
                          }
                          __Pyx_GIVEREF(__pyx_t_13);
                          __pyx_cur_scope->__pyx_v_result = __pyx_t_13;
                          __pyx_t_13 = 0;

                          /* "ws_package/controllers/activity_controller.py":3676
 * 
 *                         result = await session.execute(query)
 *                         app_data = result.scalars().first()             # <<<<<<<<<<<<<<
 * 
 *                         # If there are app monitor records, there was likely user activity
*/
                          __pyx_t_6 = __pyx_cur_scope->__pyx_v_result;
                          __Pyx_INCREF(__pyx_t_6);
                          __pyx_t_8 = 0;
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
                            __pyx_t_14 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalars, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                            if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3676, __pyx_L66_error)
                            __Pyx_GOTREF(__pyx_t_14);
                          }
                          __pyx_t_5 = __pyx_t_14;
                          __Pyx_INCREF(__pyx_t_5);
                          __pyx_t_8 = 0;
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                            __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_first, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                            if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3676, __pyx_L66_error)
                            __Pyx_GOTREF(__pyx_t_13);
                          }
                          __Pyx_GIVEREF(__pyx_t_13);
                          __pyx_cur_scope->__pyx_v_app_data = __pyx_t_13;
                          __pyx_t_13 = 0;

                          /* "ws_package/controllers/activity_controller.py":3679
 * 
 *                         # If there are app monitor records, there was likely user activity
 *                         return app_data is not None             # <<<<<<<<<<<<<<
 * 
 *             except Exception as e:
*/
                          __Pyx_XDECREF(__pyx_r);
                          __pyx_t_9 = (__pyx_cur_scope->__pyx_v_app_data != Py_None);
                          __pyx_t_13 = __Pyx_PyBool_FromLong(__pyx_t_9); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3679, __pyx_L66_error)
                          __Pyx_GOTREF(__pyx_t_13);
                          __pyx_r = __pyx_t_13;
                          __pyx_t_13 = 0;
                          goto __pyx_L70_try_return;

                          /* "ws_package/controllers/activity_controller.py":3669
 *             try:
 *                 with db_lock_manager.read_lock():
 *                     async with async_session() as session:             # <<<<<<<<<<<<<<
 *                         query = select(Appmonitor).where(
 *                             Appmonitor.timestamp >= start_time,
*/
                        }
                        __pyx_L66_error:;
                        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                        __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                        /*except:*/ {
                          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._verify_user_activity_during_period", __pyx_clineno, __pyx_lineno, __pyx_filename);
                          if (__Pyx_GetException(&__pyx_t_13, &__pyx_t_14, &__pyx_t_5) < 0) __PYX_ERR(0, 3669, __pyx_L68_except_error)
                          __Pyx_XGOTREF(__pyx_t_13);
                          __Pyx_XGOTREF(__pyx_t_14);
                          __Pyx_XGOTREF(__pyx_t_5);
                          __pyx_t_6 = PyTuple_Pack(3, __pyx_t_13, __pyx_t_14, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3669, __pyx_L68_except_error)
                          __Pyx_GOTREF(__pyx_t_6);
                          __pyx_t_34 = __Pyx_PyObject_Call(__pyx_t_20, __pyx_t_6, NULL);
                          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                          if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 3669, __pyx_L68_except_error)
                          __Pyx_GOTREF(__pyx_t_34);
                          __pyx_t_31 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_34, &__pyx_r);
                          __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                          if (likely(__pyx_t_31 == PYGEN_NEXT)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_XGIVEREF(__pyx_t_1);
                            __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                            __Pyx_XGIVEREF(__pyx_t_2);
                            __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                            __Pyx_XGIVEREF(__pyx_t_3);
                            __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                            __Pyx_XGIVEREF(__pyx_t_5);
                            __pyx_cur_scope->__pyx_t_3 = __pyx_t_5;
                            __Pyx_XGIVEREF(__pyx_t_10);
                            __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                            __Pyx_XGIVEREF(__pyx_t_11);
                            __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
                            __Pyx_XGIVEREF(__pyx_t_12);
                            __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
                            __Pyx_XGIVEREF(__pyx_t_13);
                            __pyx_cur_scope->__pyx_t_7 = __pyx_t_13;
                            __Pyx_XGIVEREF(__pyx_t_14);
                            __pyx_cur_scope->__pyx_t_8 = __pyx_t_14;
                            __Pyx_XGIVEREF(__pyx_t_19);
                            __pyx_cur_scope->__pyx_t_9 = __pyx_t_19;
                            __Pyx_XGIVEREF(__pyx_t_20);
                            __pyx_cur_scope->__pyx_t_10 = __pyx_t_20;
                            __Pyx_XGIVEREF(__pyx_t_21);
                            __pyx_cur_scope->__pyx_t_11 = __pyx_t_21;
                            __Pyx_XGIVEREF(__pyx_t_28);
                            __pyx_cur_scope->__pyx_t_12 = __pyx_t_28;
                            __Pyx_XGIVEREF(__pyx_t_29);
                            __pyx_cur_scope->__pyx_t_13 = __pyx_t_29;
                            __Pyx_XGIVEREF(__pyx_t_30);
                            __pyx_cur_scope->__pyx_t_14 = __pyx_t_30;
                            __Pyx_XGIVEREF(__pyx_t_32);
                            __pyx_cur_scope->__pyx_t_15 = __pyx_t_32;
                            __Pyx_XGIVEREF(__pyx_t_33);
                            __pyx_cur_scope->__pyx_t_16 = __pyx_t_33;
                            __Pyx_XGIVEREF(__pyx_t_34);
                            __pyx_cur_scope->__pyx_t_17 = __pyx_t_34;
                            __Pyx_XGIVEREF(__pyx_r);
                            __Pyx_RefNannyFinishContext();
                            __Pyx_Coroutine_SwapException(__pyx_generator);
                            /* return from generator, awaiting value */
                            __pyx_generator->resume_label = 3;
                            return __pyx_r;
                            __pyx_L76_resume_from_await:;
                            __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                            __pyx_cur_scope->__pyx_t_0 = 0;
                            __Pyx_XGOTREF(__pyx_t_1);
                            __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                            __pyx_cur_scope->__pyx_t_1 = 0;
                            __Pyx_XGOTREF(__pyx_t_2);
                            __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                            __pyx_cur_scope->__pyx_t_2 = 0;
                            __Pyx_XGOTREF(__pyx_t_3);
                            __pyx_t_5 = __pyx_cur_scope->__pyx_t_3;
                            __pyx_cur_scope->__pyx_t_3 = 0;
                            __Pyx_XGOTREF(__pyx_t_5);
                            __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                            __pyx_cur_scope->__pyx_t_4 = 0;
                            __Pyx_XGOTREF(__pyx_t_10);
                            __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
                            __pyx_cur_scope->__pyx_t_5 = 0;
                            __Pyx_XGOTREF(__pyx_t_11);
                            __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
                            __pyx_cur_scope->__pyx_t_6 = 0;
                            __Pyx_XGOTREF(__pyx_t_12);
                            __pyx_t_13 = __pyx_cur_scope->__pyx_t_7;
                            __pyx_cur_scope->__pyx_t_7 = 0;
                            __Pyx_XGOTREF(__pyx_t_13);
                            __pyx_t_14 = __pyx_cur_scope->__pyx_t_8;
                            __pyx_cur_scope->__pyx_t_8 = 0;
                            __Pyx_XGOTREF(__pyx_t_14);
                            __pyx_t_19 = __pyx_cur_scope->__pyx_t_9;
                            __pyx_cur_scope->__pyx_t_9 = 0;
                            __Pyx_XGOTREF(__pyx_t_19);
                            __pyx_t_20 = __pyx_cur_scope->__pyx_t_10;
                            __pyx_cur_scope->__pyx_t_10 = 0;
                            __Pyx_XGOTREF(__pyx_t_20);
                            __pyx_t_21 = __pyx_cur_scope->__pyx_t_11;
                            __pyx_cur_scope->__pyx_t_11 = 0;
                            __Pyx_XGOTREF(__pyx_t_21);
                            __pyx_t_28 = __pyx_cur_scope->__pyx_t_12;
                            __pyx_cur_scope->__pyx_t_12 = 0;
                            __Pyx_XGOTREF(__pyx_t_28);
                            __pyx_t_29 = __pyx_cur_scope->__pyx_t_13;
                            __pyx_cur_scope->__pyx_t_13 = 0;
                            __Pyx_XGOTREF(__pyx_t_29);
                            __pyx_t_30 = __pyx_cur_scope->__pyx_t_14;
                            __pyx_cur_scope->__pyx_t_14 = 0;
                            __Pyx_XGOTREF(__pyx_t_30);
                            __pyx_t_32 = __pyx_cur_scope->__pyx_t_15;
                            __pyx_cur_scope->__pyx_t_15 = 0;
                            __Pyx_XGOTREF(__pyx_t_32);
                            __pyx_t_33 = __pyx_cur_scope->__pyx_t_16;
                            __pyx_cur_scope->__pyx_t_16 = 0;
                            __Pyx_XGOTREF(__pyx_t_33);
                            __pyx_t_34 = __pyx_cur_scope->__pyx_t_17;
                            __pyx_cur_scope->__pyx_t_17 = 0;
                            __Pyx_XGOTREF(__pyx_t_34);
                            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3669, __pyx_L68_except_error)
                            __pyx_t_6 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_6);
                          } else if (likely(__pyx_t_31 == PYGEN_RETURN)) {
                            __Pyx_GOTREF(__pyx_r);
                            __pyx_t_6 = __pyx_r; __pyx_r = NULL;
                          } else {
                            __Pyx_XGOTREF(__pyx_r);
                            __PYX_ERR(0, 3669, __pyx_L68_except_error)
                          }
                          __pyx_t_34 = __pyx_t_6;
                          __pyx_t_6 = 0;
                          __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_34);
                          __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                          if (__pyx_t_9 < (0)) __PYX_ERR(0, 3669, __pyx_L68_except_error)
                          __pyx_t_35 = (!__pyx_t_9);
                          if (unlikely(__pyx_t_35)) {
                            __Pyx_GIVEREF(__pyx_t_13);
                            __Pyx_GIVEREF(__pyx_t_14);
                            __Pyx_XGIVEREF(__pyx_t_5);
                            __Pyx_ErrRestoreWithState(__pyx_t_13, __pyx_t_14, __pyx_t_5);
                            __pyx_t_13 = 0;  __pyx_t_14 = 0;  __pyx_t_5 = 0; 
                            __PYX_ERR(0, 3669, __pyx_L68_except_error)
                          }
                          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                          goto __pyx_L67_exception_handled;
                        }
                        __pyx_L68_except_error:;
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __Pyx_XGIVEREF(__pyx_t_32);
                        __Pyx_XGIVEREF(__pyx_t_33);
                        __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_32, __pyx_t_33);
                        goto __pyx_L55_error;
                        __pyx_L70_try_return:;
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __Pyx_XGIVEREF(__pyx_t_32);
                        __Pyx_XGIVEREF(__pyx_t_33);
                        __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_32, __pyx_t_33);
                        goto __pyx_L63_return;
                        __pyx_L67_exception_handled:;
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __Pyx_XGIVEREF(__pyx_t_32);
                        __Pyx_XGIVEREF(__pyx_t_33);
                        __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_32, __pyx_t_33);
                      }
                    }
                    /*finally:*/ {
                      /*normal exit:*/{
                        if (__pyx_t_20) {
                          __pyx_t_33 = __Pyx_PyObject_Call(__pyx_t_20, __pyx_mstate_global->__pyx_tuple[7], NULL);
                          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                          if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 3669, __pyx_L55_error)
                          __Pyx_GOTREF(__pyx_t_33);
                          __pyx_t_31 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_33, &__pyx_r);
                          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                          if (likely(__pyx_t_31 == PYGEN_NEXT)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_XGIVEREF(__pyx_t_1);
                            __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                            __Pyx_XGIVEREF(__pyx_t_2);
                            __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                            __Pyx_XGIVEREF(__pyx_t_3);
                            __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                            __Pyx_XGIVEREF(__pyx_t_10);
                            __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                            __Pyx_XGIVEREF(__pyx_t_11);
                            __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
                            __Pyx_XGIVEREF(__pyx_t_12);
                            __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                            __Pyx_XGIVEREF(__pyx_t_19);
                            __pyx_cur_scope->__pyx_t_6 = __pyx_t_19;
                            __Pyx_XGIVEREF(__pyx_t_20);
                            __pyx_cur_scope->__pyx_t_7 = __pyx_t_20;
                            __Pyx_XGIVEREF(__pyx_t_28);
                            __pyx_cur_scope->__pyx_t_8 = __pyx_t_28;
                            __Pyx_XGIVEREF(__pyx_t_29);
                            __pyx_cur_scope->__pyx_t_9 = __pyx_t_29;
                            __Pyx_XGIVEREF(__pyx_t_30);
                            __pyx_cur_scope->__pyx_t_10 = __pyx_t_30;
                            __Pyx_XGIVEREF(__pyx_t_33);
                            __pyx_cur_scope->__pyx_t_11 = __pyx_t_33;
                            __Pyx_XGIVEREF(__pyx_r);
                            __Pyx_RefNannyFinishContext();
                            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                            /* return from generator, awaiting value */
                            __pyx_generator->resume_label = 4;
                            return __pyx_r;
                            __pyx_L77_resume_from_await:;
                            __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                            __pyx_cur_scope->__pyx_t_0 = 0;
                            __Pyx_XGOTREF(__pyx_t_1);
                            __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                            __pyx_cur_scope->__pyx_t_1 = 0;
                            __Pyx_XGOTREF(__pyx_t_2);
                            __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                            __pyx_cur_scope->__pyx_t_2 = 0;
                            __Pyx_XGOTREF(__pyx_t_3);
                            __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                            __pyx_cur_scope->__pyx_t_3 = 0;
                            __Pyx_XGOTREF(__pyx_t_10);
                            __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
                            __pyx_cur_scope->__pyx_t_4 = 0;
                            __Pyx_XGOTREF(__pyx_t_11);
                            __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                            __pyx_cur_scope->__pyx_t_5 = 0;
                            __Pyx_XGOTREF(__pyx_t_12);
                            __pyx_t_19 = __pyx_cur_scope->__pyx_t_6;
                            __pyx_cur_scope->__pyx_t_6 = 0;
                            __Pyx_XGOTREF(__pyx_t_19);
                            __pyx_t_20 = __pyx_cur_scope->__pyx_t_7;
                            __pyx_cur_scope->__pyx_t_7 = 0;
                            __Pyx_XGOTREF(__pyx_t_20);
                            __pyx_t_28 = __pyx_cur_scope->__pyx_t_8;
                            __pyx_cur_scope->__pyx_t_8 = 0;
                            __Pyx_XGOTREF(__pyx_t_28);
                            __pyx_t_29 = __pyx_cur_scope->__pyx_t_9;
                            __pyx_cur_scope->__pyx_t_9 = 0;
                            __Pyx_XGOTREF(__pyx_t_29);
                            __pyx_t_30 = __pyx_cur_scope->__pyx_t_10;
                            __pyx_cur_scope->__pyx_t_10 = 0;
                            __Pyx_XGOTREF(__pyx_t_30);
                            __pyx_t_33 = __pyx_cur_scope->__pyx_t_11;
                            __pyx_cur_scope->__pyx_t_11 = 0;
                            __Pyx_XGOTREF(__pyx_t_33);
                            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3669, __pyx_L55_error)
                            __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
                          } else if (likely(__pyx_t_31 == PYGEN_RETURN)) {
                            __Pyx_GOTREF(__pyx_r);
                            __pyx_t_5 = __pyx_r; __pyx_r = NULL;
                          } else {
                            __Pyx_XGOTREF(__pyx_r);
                            __PYX_ERR(0, 3669, __pyx_L55_error)
                          }
                          __pyx_t_33 = __pyx_t_5;
                          __pyx_t_5 = 0;
                          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                        }
                        goto __pyx_L65;
                      }
                      __pyx_L63_return: {
                        __pyx_t_33 = __pyx_r;
                        __pyx_r = 0;
                        if (__pyx_t_20) {
                          __pyx_t_32 = __Pyx_PyObject_Call(__pyx_t_20, __pyx_mstate_global->__pyx_tuple[7], NULL);
                          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                          if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 3669, __pyx_L55_error)
                          __Pyx_GOTREF(__pyx_t_32);
                          __pyx_t_31 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_32, &__pyx_r);
                          __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0;
                          if (likely(__pyx_t_31 == PYGEN_NEXT)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_XGIVEREF(__pyx_t_1);
                            __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                            __Pyx_XGIVEREF(__pyx_t_2);
                            __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                            __Pyx_XGIVEREF(__pyx_t_3);
                            __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                            __Pyx_XGIVEREF(__pyx_t_10);
                            __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                            __Pyx_XGIVEREF(__pyx_t_11);
                            __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
                            __Pyx_XGIVEREF(__pyx_t_12);
                            __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                            __Pyx_XGIVEREF(__pyx_t_19);
                            __pyx_cur_scope->__pyx_t_6 = __pyx_t_19;
                            __Pyx_XGIVEREF(__pyx_t_20);
                            __pyx_cur_scope->__pyx_t_7 = __pyx_t_20;
                            __Pyx_XGIVEREF(__pyx_t_28);
                            __pyx_cur_scope->__pyx_t_8 = __pyx_t_28;
                            __Pyx_XGIVEREF(__pyx_t_29);
                            __pyx_cur_scope->__pyx_t_9 = __pyx_t_29;
                            __Pyx_XGIVEREF(__pyx_t_30);
                            __pyx_cur_scope->__pyx_t_10 = __pyx_t_30;
                            __Pyx_XGIVEREF(__pyx_t_32);
                            __pyx_cur_scope->__pyx_t_11 = __pyx_t_32;
                            __Pyx_XGIVEREF(__pyx_t_33);
                            __pyx_cur_scope->__pyx_t_12 = __pyx_t_33;
                            __Pyx_XGIVEREF(__pyx_r);
                            __Pyx_RefNannyFinishContext();
                            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                            /* return from generator, awaiting value */
                            __pyx_generator->resume_label = 5;
                            return __pyx_r;
                            __pyx_L78_resume_from_await:;
                            __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                            __pyx_cur_scope->__pyx_t_0 = 0;
                            __Pyx_XGOTREF(__pyx_t_1);
                            __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                            __pyx_cur_scope->__pyx_t_1 = 0;
                            __Pyx_XGOTREF(__pyx_t_2);
                            __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                            __pyx_cur_scope->__pyx_t_2 = 0;
                            __Pyx_XGOTREF(__pyx_t_3);
                            __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                            __pyx_cur_scope->__pyx_t_3 = 0;
                            __Pyx_XGOTREF(__pyx_t_10);
                            __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
                            __pyx_cur_scope->__pyx_t_4 = 0;
                            __Pyx_XGOTREF(__pyx_t_11);
                            __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                            __pyx_cur_scope->__pyx_t_5 = 0;
                            __Pyx_XGOTREF(__pyx_t_12);
                            __pyx_t_19 = __pyx_cur_scope->__pyx_t_6;
                            __pyx_cur_scope->__pyx_t_6 = 0;
                            __Pyx_XGOTREF(__pyx_t_19);
                            __pyx_t_20 = __pyx_cur_scope->__pyx_t_7;
                            __pyx_cur_scope->__pyx_t_7 = 0;
                            __Pyx_XGOTREF(__pyx_t_20);
                            __pyx_t_28 = __pyx_cur_scope->__pyx_t_8;
                            __pyx_cur_scope->__pyx_t_8 = 0;
                            __Pyx_XGOTREF(__pyx_t_28);
                            __pyx_t_29 = __pyx_cur_scope->__pyx_t_9;
                            __pyx_cur_scope->__pyx_t_9 = 0;
                            __Pyx_XGOTREF(__pyx_t_29);
                            __pyx_t_30 = __pyx_cur_scope->__pyx_t_10;
                            __pyx_cur_scope->__pyx_t_10 = 0;
                            __Pyx_XGOTREF(__pyx_t_30);
                            __pyx_t_32 = __pyx_cur_scope->__pyx_t_11;
                            __pyx_cur_scope->__pyx_t_11 = 0;
                            __Pyx_XGOTREF(__pyx_t_32);
                            __pyx_t_33 = __pyx_cur_scope->__pyx_t_12;
                            __pyx_cur_scope->__pyx_t_12 = 0;
                            __Pyx_XGOTREF(__pyx_t_33);
                            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3669, __pyx_L55_error)
                            __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
                          } else if (likely(__pyx_t_31 == PYGEN_RETURN)) {
                            __Pyx_GOTREF(__pyx_r);
                            __pyx_t_5 = __pyx_r; __pyx_r = NULL;
                          } else {
                            __Pyx_XGOTREF(__pyx_r);
                            __PYX_ERR(0, 3669, __pyx_L55_error)
                          }
                          __pyx_t_32 = __pyx_t_5;
                          __pyx_t_5 = 0;
                          __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0;
                        }
                        __pyx_r = __pyx_t_33;
                        __pyx_t_33 = 0;
                        goto __pyx_L59_try_return;
                      }
                      __pyx_L65:;
                    }
                    goto __pyx_L79;
                    __pyx_L61_error:;
                    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                    goto __pyx_L55_error;
                    __pyx_L79:;
                  }

                  /* "ws_package/controllers/activity_controller.py":3668
 *             # Check if there are any app monitor records during this period
 *             try:
 *                 with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                     async with async_session() as session:
 *                         query = select(Appmonitor).where(
*/
                }
                __Pyx_XDECREF(__pyx_t_29); __pyx_t_29 = 0;
                __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
                __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                goto __pyx_L60_try_end;
                __pyx_L55_error:;
                __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                /*except:*/ {
                  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._verify_user_activity_during_period", __pyx_clineno, __pyx_lineno, __pyx_filename);
                  if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_14, &__pyx_t_13) < 0) __PYX_ERR(0, 3668, __pyx_L57_except_error)
                  __Pyx_XGOTREF(__pyx_t_5);
                  __Pyx_XGOTREF(__pyx_t_14);
                  __Pyx_XGOTREF(__pyx_t_13);
                  __pyx_t_6 = PyTuple_Pack(3, __pyx_t_5, __pyx_t_14, __pyx_t_13); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3668, __pyx_L57_except_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  __pyx_t_20 = __Pyx_PyObject_Call(__pyx_t_30, __pyx_t_6, NULL);
                  __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 3668, __pyx_L57_except_error)
                  __Pyx_GOTREF(__pyx_t_20);
                  __pyx_t_35 = __Pyx_PyObject_IsTrue(__pyx_t_20);
                  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                  if (__pyx_t_35 < (0)) __PYX_ERR(0, 3668, __pyx_L57_except_error)
                  __pyx_t_9 = (!__pyx_t_35);
                  if (unlikely(__pyx_t_9)) {
                    __Pyx_GIVEREF(__pyx_t_5);
                    __Pyx_GIVEREF(__pyx_t_14);
                    __Pyx_XGIVEREF(__pyx_t_13);
                    __Pyx_ErrRestoreWithState(__pyx_t_5, __pyx_t_14, __pyx_t_13);
                    __pyx_t_5 = 0;  __pyx_t_14 = 0;  __pyx_t_13 = 0; 
                    __PYX_ERR(0, 3668, __pyx_L57_except_error)
                  }
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                  __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                  goto __pyx_L56_exception_handled;
                }
                __pyx_L57_except_error:;
                __Pyx_XGIVEREF(__pyx_t_29);
                __Pyx_XGIVEREF(__pyx_t_28);
                __Pyx_XGIVEREF(__pyx_t_19);
                __Pyx_ExceptionReset(__pyx_t_29, __pyx_t_28, __pyx_t_19);
                goto __pyx_L45_error;
                __pyx_L59_try_return:;
                __Pyx_XGIVEREF(__pyx_t_29);
                __Pyx_XGIVEREF(__pyx_t_28);
                __Pyx_XGIVEREF(__pyx_t_19);
                __Pyx_ExceptionReset(__pyx_t_29, __pyx_t_28, __pyx_t_19);
                goto __pyx_L52_return;
                __pyx_L56_exception_handled:;
                __Pyx_XGIVEREF(__pyx_t_29);
                __Pyx_XGIVEREF(__pyx_t_28);
                __Pyx_XGIVEREF(__pyx_t_19);
                __Pyx_ExceptionReset(__pyx_t_29, __pyx_t_28, __pyx_t_19);
                __pyx_L60_try_end:;
              }
            }
            /*finally:*/ {
              /*normal exit:*/{
                if (__pyx_t_30) {
                  __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_30, __pyx_mstate_global->__pyx_tuple[7], NULL);
                  __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
                  if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 3668, __pyx_L45_error)
                  __Pyx_GOTREF(__pyx_t_19);
                  __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                }
                goto __pyx_L54;
              }
              __pyx_L52_return: {
                __pyx_t_19 = __pyx_r;
                __pyx_r = 0;
                if (__pyx_t_30) {
                  __pyx_t_28 = __Pyx_PyObject_Call(__pyx_t_30, __pyx_mstate_global->__pyx_tuple[7], NULL);
                  __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
                  if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 3668, __pyx_L45_error)
                  __Pyx_GOTREF(__pyx_t_28);
                  __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
                }
                __pyx_r = __pyx_t_19;
                __pyx_t_19 = 0;
                goto __pyx_L49_try_return;
              }
              __pyx_L54:;
            }
            goto __pyx_L83;
            __pyx_L51_error:;
            __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
            goto __pyx_L45_error;
            __pyx_L83:;
          }

          /* "ws_package/controllers/activity_controller.py":3667
 *             # For Windows/Linux, use a simpler check
 *             # Check if there are any app monitor records during this period
 *             try:             # <<<<<<<<<<<<<<
 *                 with db_lock_manager.read_lock():
 *                     async with async_session() as session:
*/
        }
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L50_try_end;
        __pyx_L45_error:;
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
        __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "ws_package/controllers/activity_controller.py":3681
 *                         return app_data is not None
 * 
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 logger.debug("Could not verify user activity via app monitor: %s", e)
 *                 # On error, be conservative
*/
        __pyx_t_26 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
        if (__pyx_t_26) {
          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._verify_user_activity_during_period", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_13, &__pyx_t_14, &__pyx_t_5) < 0) __PYX_ERR(0, 3681, __pyx_L47_except_error)
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_14);
          __Pyx_GIVEREF(__pyx_t_14);
          __pyx_cur_scope->__pyx_v_e = __pyx_t_14;
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":3682
 * 
 *             except Exception as e:
 *                 logger.debug("Could not verify user activity via app monitor: %s", e)             # <<<<<<<<<<<<<<
 *                 # On error, be conservative
 *                 return False
*/
            __pyx_t_15 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3682, __pyx_L89_error)
            __Pyx_GOTREF(__pyx_t_16);
            __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3682, __pyx_L89_error)
            __Pyx_GOTREF(__pyx_t_24);
            __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_24))) {
              __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_24);
              assert(__pyx_t_15);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_24);
              __Pyx_INCREF(__pyx_t_15);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_24, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Could_not_verify_user_activity_v, __pyx_cur_scope->__pyx_v_e};
              __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_24, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
              __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
              if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3682, __pyx_L89_error)
              __Pyx_GOTREF(__pyx_t_6);
            }
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

            /* "ws_package/controllers/activity_controller.py":3684
 *                 logger.debug("Could not verify user activity via app monitor: %s", e)
 *                 # On error, be conservative
 *                 return False             # <<<<<<<<<<<<<<
 * 
 *         except Exception as e:
*/
            __Pyx_XDECREF(__pyx_r);
            __Pyx_INCREF(Py_False);
            __pyx_r = Py_False;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            goto __pyx_L88_return;
          }

          /* "ws_package/controllers/activity_controller.py":3681
 *                         return app_data is not None
 * 
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 logger.debug("Could not verify user activity via app monitor: %s", e)
 *                 # On error, be conservative
*/
          /*finally:*/ {
            __pyx_L89_error:;
            /*exception exit:*/{
              __Pyx_PyThreadState_assign
              __pyx_t_30 = 0; __pyx_t_19 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_t_20 = 0; __pyx_t_33 = 0;
              __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
              __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
               __Pyx_ExceptionSwap(&__pyx_t_29, &__pyx_t_20, &__pyx_t_33);
              if ( unlikely(__Pyx_GetException(&__pyx_t_30, &__pyx_t_19, &__pyx_t_28) < 0)) __Pyx_ErrFetch(&__pyx_t_30, &__pyx_t_19, &__pyx_t_28);
              __Pyx_XGOTREF(__pyx_t_30);
              __Pyx_XGOTREF(__pyx_t_19);
              __Pyx_XGOTREF(__pyx_t_28);
              __Pyx_XGOTREF(__pyx_t_29);
              __Pyx_XGOTREF(__pyx_t_20);
              __Pyx_XGOTREF(__pyx_t_33);
              __pyx_t_26 = __pyx_lineno; __pyx_t_25 = __pyx_clineno; __pyx_t_36 = __pyx_filename;
              {
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
              }
              __Pyx_XGIVEREF(__pyx_t_29);
              __Pyx_XGIVEREF(__pyx_t_20);
              __Pyx_XGIVEREF(__pyx_t_33);
              __Pyx_ExceptionReset(__pyx_t_29, __pyx_t_20, __pyx_t_33);
              __Pyx_XGIVEREF(__pyx_t_30);
              __Pyx_XGIVEREF(__pyx_t_19);
              __Pyx_XGIVEREF(__pyx_t_28);
              __Pyx_ErrRestore(__pyx_t_30, __pyx_t_19, __pyx_t_28);
              __pyx_t_30 = 0; __pyx_t_19 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_t_20 = 0; __pyx_t_33 = 0;
              __pyx_lineno = __pyx_t_26; __pyx_clineno = __pyx_t_25; __pyx_filename = __pyx_t_36;
              goto __pyx_L47_except_error;
            }
            __pyx_L88_return: {
              __pyx_t_33 = __pyx_r;
              __pyx_r = 0;
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
              __pyx_r = __pyx_t_33;
              __pyx_t_33 = 0;
              goto __pyx_L48_except_return;
            }
          }
        }
        goto __pyx_L47_except_error;

        /* "ws_package/controllers/activity_controller.py":3667
 *             # For Windows/Linux, use a simpler check
 *             # Check if there are any app monitor records during this period
 *             try:             # <<<<<<<<<<<<<<
 *                 with db_lock_manager.read_lock():
 *                     async with async_session() as session:
*/
        __pyx_L47_except_error:;
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_11, __pyx_t_10);
        goto __pyx_L4_error;
        __pyx_L49_try_return:;
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_11, __pyx_t_10);
        goto __pyx_L8_try_return;
        __pyx_L48_except_return:;
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_11, __pyx_t_10);
        goto __pyx_L8_try_return;
        __pyx_L50_try_end:;
      }

      /* "ws_package/controllers/activity_controller.py":3614
 *             True if user activity detected, False otherwise
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # On macOS, check HID idle time to verify user activity
 *             if platform.system() == "Darwin":
*/
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L9_try_end;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "ws_package/controllers/activity_controller.py":3686
 *                 return False
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.debug("Error verifying user activity during period: %s", e)
 *             # Fail-safe: return False to prevent false intervals
*/
    __pyx_t_25 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_25) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._verify_user_activity_during_period", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_14, &__pyx_t_13) < 0) __PYX_ERR(0, 3686, __pyx_L6_except_error)
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_14);
      __Pyx_XGOTREF(__pyx_t_13);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_14);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":3687
 * 
 *         except Exception as e:
 *             logger.debug("Error verifying user activity during period: %s", e)             # <<<<<<<<<<<<<<
 *             # Fail-safe: return False to prevent false intervals
 *             return False
*/
        __pyx_t_24 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3687, __pyx_L100_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3687, __pyx_L100_error)
        __Pyx_GOTREF(__pyx_t_16);
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_16))) {
          __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_16);
          assert(__pyx_t_24);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_16);
          __Pyx_INCREF(__pyx_t_24);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_16, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_24, __pyx_mstate_global->__pyx_kp_u_Error_verifying_user_activity_du, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_16, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3687, __pyx_L100_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "ws_package/controllers/activity_controller.py":3689
 *             logger.debug("Error verifying user activity during period: %s", e)
 *             # Fail-safe: return False to prevent false intervals
 *             return False             # <<<<<<<<<<<<<<
 * 
 *     def is_idle_interval(self, interval) -> bool:
*/
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_False);
        __pyx_r = Py_False;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        goto __pyx_L99_return;
      }

      /* "ws_package/controllers/activity_controller.py":3686
 *                 return False
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.debug("Error verifying user activity during period: %s", e)
 *             # Fail-safe: return False to prevent false intervals
*/
      /*finally:*/ {
        __pyx_L100_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_33 = 0; __pyx_t_20 = 0; __pyx_t_29 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_33, &__pyx_t_20, &__pyx_t_29);
          if ( unlikely(__Pyx_GetException(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12) < 0)) __Pyx_ErrFetch(&__pyx_t_10, &__pyx_t_11, &__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_33);
          __Pyx_XGOTREF(__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_29);
          __pyx_t_25 = __pyx_lineno; __pyx_t_26 = __pyx_clineno; __pyx_t_37 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_33);
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_XGIVEREF(__pyx_t_29);
          __Pyx_ExceptionReset(__pyx_t_33, __pyx_t_20, __pyx_t_29);
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ErrRestore(__pyx_t_10, __pyx_t_11, __pyx_t_12);
          __pyx_t_10 = 0; __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_33 = 0; __pyx_t_20 = 0; __pyx_t_29 = 0;
          __pyx_lineno = __pyx_t_25; __pyx_clineno = __pyx_t_26; __pyx_filename = __pyx_t_37;
          goto __pyx_L6_except_error;
        }
        __pyx_L99_return: {
          __pyx_t_29 = __pyx_r;
          __pyx_r = 0;
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          __pyx_r = __pyx_t_29;
          __pyx_t_29 = 0;
          goto __pyx_L7_except_return;
        }
      }
    }
    goto __pyx_L6_except_error;

    /* "ws_package/controllers/activity_controller.py":3614
 *             True if user activity detected, False otherwise
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # On macOS, check HID idle time to verify user activity
 *             if platform.system() == "Darwin":
*/
    __pyx_L6_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L7_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L9_try_end:;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":3606
 *         return False
 * 
 *     async def _verify_user_activity_during_period(self, start_time: datetime.datetime, end_time: datetime.datetime) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Verify if there was actual user activity (keyboard/mouse) during a time period.
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_24);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("_verify_user_activity_during_period", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":3691
 *             return False
 * 
 *     def is_idle_interval(self, interval) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Our idle definition: keyboard AND mouse activity are zero for the whole interval.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_130is_idle_interval(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_129is_idle_interval, "\n        Our idle definition: keyboard AND mouse activity are zero for the whole interval.\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_130is_idle_interval = {"is_idle_interval", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_130is_idle_interval, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_129is_idle_interval};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_130is_idle_interval(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  CYTHON_UNUSED PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_interval = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("is_idle_interval (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_interval,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 3691, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3691, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3691, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "is_idle_interval", 0) < (0)) __PYX_ERR(0, 3691, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("is_idle_interval", 1, 2, 2, i); __PYX_ERR(0, 3691, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3691, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3691, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_interval = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("is_idle_interval", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 3691, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.is_idle_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_129is_idle_interval(__pyx_self, __pyx_v_self, __pyx_v_interval);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_129is_idle_interval(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_interval) {
  PyObject *__pyx_v_activity_level = NULL;
  double __pyx_v_mouse;
  double __pyx_v_keyboard;
  double __pyx_v_average;
  PyObject *__pyx_v_e = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  size_t __pyx_t_10;
  double __pyx_t_11;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  char const *__pyx_t_17;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("is_idle_interval", 0);

  /* "ws_package/controllers/activity_controller.py":3695
 *         Our idle definition: keyboard AND mouse activity are zero for the whole interval.
 *         """
 *         if not interval:             # <<<<<<<<<<<<<<
 *             return False
 * 
*/
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_interval); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 3695, __pyx_L1_error)
  __pyx_t_2 = (!__pyx_t_1);
  if (__pyx_t_2) {

    /* "ws_package/controllers/activity_controller.py":3696
 *         """
 *         if not interval:
 *             return False             # <<<<<<<<<<<<<<
 * 
 *         try:
*/
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":3695
 *         Our idle definition: keyboard AND mouse activity are zero for the whole interval.
 *         """
 *         if not interval:             # <<<<<<<<<<<<<<
 *             return False
 * 
*/
  }

  /* "ws_package/controllers/activity_controller.py":3698
 *             return False
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             activity_level = interval.activityLevel
 *             if isinstance(activity_level, str):
*/
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":3699
 * 
 *         try:
 *             activity_level = interval.activityLevel             # <<<<<<<<<<<<<<
 *             if isinstance(activity_level, str):
 *                 activity_level = json.loads(activity_level)
*/
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_activityLevel); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3699, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_v_activity_level = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":3700
 *         try:
 *             activity_level = interval.activityLevel
 *             if isinstance(activity_level, str):             # <<<<<<<<<<<<<<
 *                 activity_level = json.loads(activity_level)
 *             activity_level = activity_level or {}
*/
      __pyx_t_2 = PyUnicode_Check(__pyx_v_activity_level); 
      if (__pyx_t_2) {

        /* "ws_package/controllers/activity_controller.py":3701
 *             activity_level = interval.activityLevel
 *             if isinstance(activity_level, str):
 *                 activity_level = json.loads(activity_level)             # <<<<<<<<<<<<<<
 *             activity_level = activity_level or {}
 *             mouse = float(activity_level.get("mouse", 0) or 0)
*/
        __pyx_t_7 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_json); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3701, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_loads); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3701, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9);
          assert(__pyx_t_7);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_v_activity_level};
          __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3701, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __Pyx_DECREF_SET(__pyx_v_activity_level, __pyx_t_6);
        __pyx_t_6 = 0;

        /* "ws_package/controllers/activity_controller.py":3700
 *         try:
 *             activity_level = interval.activityLevel
 *             if isinstance(activity_level, str):             # <<<<<<<<<<<<<<
 *                 activity_level = json.loads(activity_level)
 *             activity_level = activity_level or {}
*/
      }

      /* "ws_package/controllers/activity_controller.py":3702
 *             if isinstance(activity_level, str):
 *                 activity_level = json.loads(activity_level)
 *             activity_level = activity_level or {}             # <<<<<<<<<<<<<<
 *             mouse = float(activity_level.get("mouse", 0) or 0)
 *             keyboard = float(activity_level.get("keyboard", 0) or 0)
*/
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_activity_level); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3702, __pyx_L4_error)
      if (!__pyx_t_2) {
      } else {
        __Pyx_INCREF(__pyx_v_activity_level);
        __pyx_t_6 = __pyx_v_activity_level;
        goto __pyx_L11_bool_binop_done;
      }
      __pyx_t_9 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3702, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_9);
      __pyx_t_6 = __pyx_t_9;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_L11_bool_binop_done:;
      __Pyx_DECREF_SET(__pyx_v_activity_level, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":3703
 *                 activity_level = json.loads(activity_level)
 *             activity_level = activity_level or {}
 *             mouse = float(activity_level.get("mouse", 0) or 0)             # <<<<<<<<<<<<<<
 *             keyboard = float(activity_level.get("keyboard", 0) or 0)
 *             average = float(activity_level.get("average", 0) or 0)
*/
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_activity_level, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3703, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_mstate_global->__pyx_tuple[16], NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3703, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3703, __pyx_L4_error)
      if (!__pyx_t_2) {
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else {
        __Pyx_INCREF(__pyx_t_7);
        __pyx_t_6 = __pyx_t_7;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L13_bool_binop_done;
      }
      __pyx_t_7 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3703, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = __pyx_t_7;
      __pyx_t_7 = 0;
      __pyx_L13_bool_binop_done:;
      __pyx_t_11 = __Pyx_PyObject_AsDouble(__pyx_t_6); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_11, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 3703, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_v_mouse = __pyx_t_11;

      /* "ws_package/controllers/activity_controller.py":3704
 *             activity_level = activity_level or {}
 *             mouse = float(activity_level.get("mouse", 0) or 0)
 *             keyboard = float(activity_level.get("keyboard", 0) or 0)             # <<<<<<<<<<<<<<
 *             average = float(activity_level.get("average", 0) or 0)
 *             return mouse == 0.0 and keyboard == 0.0 and average == 0.0
*/
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_activity_level, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3704, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_mstate_global->__pyx_tuple[15], NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3704, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3704, __pyx_L4_error)
      if (!__pyx_t_2) {
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      } else {
        __Pyx_INCREF(__pyx_t_9);
        __pyx_t_6 = __pyx_t_9;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L15_bool_binop_done;
      }
      __pyx_t_9 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3704, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_6 = __pyx_t_9;
      __pyx_t_9 = 0;
      __pyx_L15_bool_binop_done:;
      __pyx_t_11 = __Pyx_PyObject_AsDouble(__pyx_t_6); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_11, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 3704, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_v_keyboard = __pyx_t_11;

      /* "ws_package/controllers/activity_controller.py":3705
 *             mouse = float(activity_level.get("mouse", 0) or 0)
 *             keyboard = float(activity_level.get("keyboard", 0) or 0)
 *             average = float(activity_level.get("average", 0) or 0)             # <<<<<<<<<<<<<<
 *             return mouse == 0.0 and keyboard == 0.0 and average == 0.0
 *         except Exception as e:
*/
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_v_activity_level, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3705, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_mstate_global->__pyx_tuple[17], NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3705, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3705, __pyx_L4_error)
      if (!__pyx_t_2) {
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else {
        __Pyx_INCREF(__pyx_t_7);
        __pyx_t_6 = __pyx_t_7;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L17_bool_binop_done;
      }
      __pyx_t_7 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3705, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = __pyx_t_7;
      __pyx_t_7 = 0;
      __pyx_L17_bool_binop_done:;
      __pyx_t_11 = __Pyx_PyObject_AsDouble(__pyx_t_6); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_11, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 3705, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_v_average = __pyx_t_11;

      /* "ws_package/controllers/activity_controller.py":3706
 *             keyboard = float(activity_level.get("keyboard", 0) or 0)
 *             average = float(activity_level.get("average", 0) or 0)
 *             return mouse == 0.0 and keyboard == 0.0 and average == 0.0             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             logger.debug("Failed to evaluate idle interval: %s", e)
*/
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_2 = (__pyx_v_mouse == 0.0);
      if (__pyx_t_2) {
      } else {
        __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3706, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_6 = __pyx_t_7;
        __pyx_t_7 = 0;
        goto __pyx_L19_bool_binop_done;
      }
      __pyx_t_2 = (__pyx_v_keyboard == 0.0);
      if (__pyx_t_2) {
      } else {
        __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3706, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_6 = __pyx_t_7;
        __pyx_t_7 = 0;
        goto __pyx_L19_bool_binop_done;
      }
      __pyx_t_2 = (__pyx_v_average == 0.0);
      __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3706, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = __pyx_t_7;
      __pyx_t_7 = 0;
      __pyx_L19_bool_binop_done:;
      __pyx_r = __pyx_t_6;
      __pyx_t_6 = 0;
      goto __pyx_L8_try_return;

      /* "ws_package/controllers/activity_controller.py":3698
 *             return False
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             activity_level = interval.activityLevel
 *             if isinstance(activity_level, str):
*/
    }
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "ws_package/controllers/activity_controller.py":3707
 *             average = float(activity_level.get("average", 0) or 0)
 *             return mouse == 0.0 and keyboard == 0.0 and average == 0.0
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.debug("Failed to evaluate idle interval: %s", e)
 *             return False
*/
    __pyx_t_12 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_12) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.is_idle_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_9) < 0) __PYX_ERR(0, 3707, __pyx_L6_except_error)
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_7);
      __pyx_v_e = __pyx_t_7;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":3708
 *             return mouse == 0.0 and keyboard == 0.0 and average == 0.0
 *         except Exception as e:
 *             logger.debug("Failed to evaluate idle interval: %s", e)             # <<<<<<<<<<<<<<
 *             return False
 * 
*/
        __pyx_t_13 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3708, __pyx_L27_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3708, __pyx_L27_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_15))) {
          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_15);
          assert(__pyx_t_13);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Failed_to_evaluate_idle_interval, __pyx_v_e};
          __pyx_t_8 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_10, (3-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3708, __pyx_L27_error)
          __Pyx_GOTREF(__pyx_t_8);
        }
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

        /* "ws_package/controllers/activity_controller.py":3709
 *         except Exception as e:
 *             logger.debug("Failed to evaluate idle interval: %s", e)
 *             return False             # <<<<<<<<<<<<<<
 * 
 *     def group_intervals_by_session(self, intervals):
*/
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_False);
        __pyx_r = Py_False;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L26_return;
      }

      /* "ws_package/controllers/activity_controller.py":3707
 *             average = float(activity_level.get("average", 0) or 0)
 *             return mouse == 0.0 and keyboard == 0.0 and average == 0.0
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.debug("Failed to evaluate idle interval: %s", e)
 *             return False
*/
      /*finally:*/ {
        __pyx_L27_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
          if ( unlikely(__Pyx_GetException(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20) < 0)) __Pyx_ErrFetch(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_18);
          __Pyx_XGOTREF(__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_23);
          __pyx_t_12 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_17 = __pyx_filename;
          {
            __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_23);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_ErrRestore(__pyx_t_18, __pyx_t_19, __pyx_t_20);
          __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
          __pyx_lineno = __pyx_t_12; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_17;
          goto __pyx_L6_except_error;
        }
        __pyx_L26_return: {
          __pyx_t_23 = __pyx_r;
          __pyx_r = 0;
          __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
          __pyx_r = __pyx_t_23;
          __pyx_t_23 = 0;
          goto __pyx_L7_except_return;
        }
      }
    }
    goto __pyx_L6_except_error;

    /* "ws_package/controllers/activity_controller.py":3698
 *             return False
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             activity_level = interval.activityLevel
 *             if isinstance(activity_level, str):
*/
    __pyx_L6_except_error:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L8_try_return:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L0;
    __pyx_L7_except_return:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L0;
  }

  /* "ws_package/controllers/activity_controller.py":3691
 *             return False
 * 
 *     def is_idle_interval(self, interval) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Our idle definition: keyboard AND mouse activity are zero for the whole interval.
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.is_idle_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_activity_level);
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":3711
 *             return False
 * 
 *     def group_intervals_by_session(self, intervals):             # <<<<<<<<<<<<<<
 *         """
 *         Group intervals into logical sessions.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_132group_intervals_by_session(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_131group_intervals_by_session, "\n        Group intervals into logical sessions.\n        \n        Splits occur when:\n        1. The counter changes (indicates application restart or forced stop).\n        2. The chronological gap between intervals exceeds the configured threshold.\n        \n        Idle intervals remain within the current session.\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_132group_intervals_by_session = {"group_intervals_by_session", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_132group_intervals_by_session, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_131group_intervals_by_session};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_132group_intervals_by_session(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_intervals = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("group_intervals_by_session (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_intervals,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 3711, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3711, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3711, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "group_intervals_by_session", 0) < (0)) __PYX_ERR(0, 3711, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("group_intervals_by_session", 1, 2, 2, i); __PYX_ERR(0, 3711, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3711, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3711, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_intervals = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("group_intervals_by_session", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 3711, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.group_intervals_by_session", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_131group_intervals_by_session(__pyx_self, __pyx_v_self, __pyx_v_intervals);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":3724
 *             return []
 * 
 *         sorted_intervals = sorted(intervals, key=lambda x: x.start_time)             # <<<<<<<<<<<<<<
 *         sessions = []
 *         current_session = [sorted_intervals[0]]
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_26group_intervals_by_session_lambda3(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_26group_intervals_by_session_lambda3 = {"lambda3", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_26group_intervals_by_session_lambda3, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_26group_intervals_by_session_lambda3(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_x = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[1] = {0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("lambda3 (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_x,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 3724, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3724, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "lambda3", 0) < (0)) __PYX_ERR(0, 3724, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("lambda3", 1, 1, 1, i); __PYX_ERR(0, 3724, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 1)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3724, __pyx_L3_error)
    }
    __pyx_v_x = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("lambda3", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 3724, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.group_intervals_by_session.lambda3", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_lambda_funcdef_lambda3(__pyx_self, __pyx_v_x);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_lambda_funcdef_lambda3(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_x) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("lambda3", 0);
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_x, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3724, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.group_intervals_by_session.lambda3", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":3711
 *             return False
 * 
 *     def group_intervals_by_session(self, intervals):             # <<<<<<<<<<<<<<
 *         """
 *         Group intervals into logical sessions.
*/

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_131group_intervals_by_session(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_intervals) {
  PyObject *__pyx_v_sorted_intervals = NULL;
  PyObject *__pyx_v_sessions = NULL;
  PyObject *__pyx_v_current_session = NULL;
  PyObject *__pyx_v_i = NULL;
  PyObject *__pyx_v_prev_interval = NULL;
  PyObject *__pyx_v_current_interval = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  size_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  PyObject *(*__pyx_t_9)(PyObject *);
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("group_intervals_by_session", 0);

  /* "ws_package/controllers/activity_controller.py":3721
 *         Idle intervals remain within the current session.
 *         """
 *         if not intervals:             # <<<<<<<<<<<<<<
 *             return []
 * 
*/
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_intervals); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 3721, __pyx_L1_error)
  __pyx_t_2 = (!__pyx_t_1);
  if (__pyx_t_2) {

    /* "ws_package/controllers/activity_controller.py":3722
 *         """
 *         if not intervals:
 *             return []             # <<<<<<<<<<<<<<
 * 
 *         sorted_intervals = sorted(intervals, key=lambda x: x.start_time)
*/
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3722, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":3721
 *         Idle intervals remain within the current session.
 *         """
 *         if not intervals:             # <<<<<<<<<<<<<<
 *             return []
 * 
*/
  }

  /* "ws_package/controllers/activity_controller.py":3724
 *             return []
 * 
 *         sorted_intervals = sorted(intervals, key=lambda x: x.start_time)             # <<<<<<<<<<<<<<
 *         sessions = []
 *         current_session = [sorted_intervals[0]]
*/
  __pyx_t_4 = NULL;
  __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_26group_intervals_by_session_lambda3, 0, __pyx_mstate_global->__pyx_n_u_ActivityController_group_interva, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[41])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3724, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = 1;
  {
    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_4, __pyx_v_intervals};
    __pyx_t_7 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3724, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_key, __pyx_t_5, __pyx_t_7, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 3724, __pyx_L1_error)
    __pyx_t_3 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_builtin_sorted, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_7);
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3724, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  }
  __pyx_v_sorted_intervals = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "ws_package/controllers/activity_controller.py":3725
 * 
 *         sorted_intervals = sorted(intervals, key=lambda x: x.start_time)
 *         sessions = []             # <<<<<<<<<<<<<<
 *         current_session = [sorted_intervals[0]]
 * 
*/
  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3725, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_v_sessions = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "ws_package/controllers/activity_controller.py":3726
 *         sorted_intervals = sorted(intervals, key=lambda x: x.start_time)
 *         sessions = []
 *         current_session = [sorted_intervals[0]]             # <<<<<<<<<<<<<<
 * 
 *         for i in range(1, len(sorted_intervals)):
*/
  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_sorted_intervals, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3726, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_7 = PyList_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3726, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_GIVEREF(__pyx_t_3);
  if (__Pyx_PyList_SET_ITEM(__pyx_t_7, 0, __pyx_t_3) != (0)) __PYX_ERR(0, 3726, __pyx_L1_error);
  __pyx_t_3 = 0;
  __pyx_v_current_session = ((PyObject*)__pyx_t_7);
  __pyx_t_7 = 0;

  /* "ws_package/controllers/activity_controller.py":3728
 *         current_session = [sorted_intervals[0]]
 * 
 *         for i in range(1, len(sorted_intervals)):             # <<<<<<<<<<<<<<
 *             prev_interval = sorted_intervals[i - 1]
 *             current_interval = sorted_intervals[i]
*/
  __pyx_t_3 = NULL;
  __pyx_t_8 = PyObject_Length(__pyx_v_sorted_intervals); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3728, __pyx_L1_error)
  __pyx_t_5 = PyLong_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3728, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = 1;
  {
    PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_mstate_global->__pyx_int_1, __pyx_t_5};
    __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)(&PyRange_Type), __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3728, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
  }
  __pyx_t_5 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3728, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_9 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 3728, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
  for (;;) {
    {
      __pyx_t_7 = __pyx_t_9(__pyx_t_5);
      if (unlikely(!__pyx_t_7)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 3728, __pyx_L1_error)
          PyErr_Clear();
        }
        break;
      }
    }
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_7);
    __pyx_t_7 = 0;

    /* "ws_package/controllers/activity_controller.py":3729
 * 
 *         for i in range(1, len(sorted_intervals)):
 *             prev_interval = sorted_intervals[i - 1]             # <<<<<<<<<<<<<<
 *             current_interval = sorted_intervals[i]
 * 
*/
    __pyx_t_7 = __Pyx_PyLong_SubtractObjC(__pyx_v_i, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3729, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_sorted_intervals, __pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3729, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF_SET(__pyx_v_prev_interval, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "ws_package/controllers/activity_controller.py":3730
 *         for i in range(1, len(sorted_intervals)):
 *             prev_interval = sorted_intervals[i - 1]
 *             current_interval = sorted_intervals[i]             # <<<<<<<<<<<<<<
 * 
 *             if self._should_start_new_session(prev_interval, current_interval):
*/
    __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_v_sorted_intervals, __pyx_v_i); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3730, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_XDECREF_SET(__pyx_v_current_interval, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "ws_package/controllers/activity_controller.py":3732
 *             current_interval = sorted_intervals[i]
 * 
 *             if self._should_start_new_session(prev_interval, current_interval):             # <<<<<<<<<<<<<<
 *                 sessions.append(current_session)
 *                 current_session = [current_interval]
*/
    __pyx_t_7 = __pyx_v_self;
    __Pyx_INCREF(__pyx_t_7);
    __pyx_t_6 = 0;
    {
      PyObject *__pyx_callargs[3] = {__pyx_t_7, __pyx_v_prev_interval, __pyx_v_current_interval};
      __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_should_start_new_session, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3732, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3732, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (__pyx_t_2) {

      /* "ws_package/controllers/activity_controller.py":3733
 * 
 *             if self._should_start_new_session(prev_interval, current_interval):
 *                 sessions.append(current_session)             # <<<<<<<<<<<<<<
 *                 current_session = [current_interval]
 *             else:
*/
      __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_sessions, __pyx_v_current_session); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 3733, __pyx_L1_error)

      /* "ws_package/controllers/activity_controller.py":3734
 *             if self._should_start_new_session(prev_interval, current_interval):
 *                 sessions.append(current_session)
 *                 current_session = [current_interval]             # <<<<<<<<<<<<<<
 *             else:
 *                 current_session.append(current_interval)
*/
      __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3734, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_v_current_interval);
      __Pyx_GIVEREF(__pyx_v_current_interval);
      if (__Pyx_PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_current_interval) != (0)) __PYX_ERR(0, 3734, __pyx_L1_error);
      __Pyx_DECREF_SET(__pyx_v_current_session, ((PyObject*)__pyx_t_3));
      __pyx_t_3 = 0;

      /* "ws_package/controllers/activity_controller.py":3732
 *             current_interval = sorted_intervals[i]
 * 
 *             if self._should_start_new_session(prev_interval, current_interval):             # <<<<<<<<<<<<<<
 *                 sessions.append(current_session)
 *                 current_session = [current_interval]
*/
      goto __pyx_L6;
    }

    /* "ws_package/controllers/activity_controller.py":3736
 *                 current_session = [current_interval]
 *             else:
 *                 current_session.append(current_interval)             # <<<<<<<<<<<<<<
 * 
 *         if current_session:
*/
    /*else*/ {
      __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_current_session, __pyx_v_current_interval); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 3736, __pyx_L1_error)
    }
    __pyx_L6:;

    /* "ws_package/controllers/activity_controller.py":3728
 *         current_session = [sorted_intervals[0]]
 * 
 *         for i in range(1, len(sorted_intervals)):             # <<<<<<<<<<<<<<
 *             prev_interval = sorted_intervals[i - 1]
 *             current_interval = sorted_intervals[i]
*/
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "ws_package/controllers/activity_controller.py":3738
 *                 current_session.append(current_interval)
 * 
 *         if current_session:             # <<<<<<<<<<<<<<
 *             sessions.append(current_session)
 * 
*/
  {
    Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_v_current_session);
    if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 3738, __pyx_L1_error)
    __pyx_t_2 = (__pyx_temp != 0);
  }

  if (__pyx_t_2) {

    /* "ws_package/controllers/activity_controller.py":3739
 * 
 *         if current_session:
 *             sessions.append(current_session)             # <<<<<<<<<<<<<<
 * 
 *         return sessions
*/
    __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_sessions, __pyx_v_current_session); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 3739, __pyx_L1_error)

    /* "ws_package/controllers/activity_controller.py":3738
 *                 current_session.append(current_interval)
 * 
 *         if current_session:             # <<<<<<<<<<<<<<
 *             sessions.append(current_session)
 * 
*/
  }

  /* "ws_package/controllers/activity_controller.py":3741
 *             sessions.append(current_session)
 * 
 *         return sessions             # <<<<<<<<<<<<<<
 * 
 *     def get_day_start_time(self, target_date, intervals_for_day):
*/
  __Pyx_XDECREF(__pyx_r);
  __Pyx_INCREF(__pyx_v_sessions);
  __pyx_r = __pyx_v_sessions;
  goto __pyx_L0;

  /* "ws_package/controllers/activity_controller.py":3711
 *             return False
 * 
 *     def group_intervals_by_session(self, intervals):             # <<<<<<<<<<<<<<
 *         """
 *         Group intervals into logical sessions.
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.group_intervals_by_session", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_sorted_intervals);
  __Pyx_XDECREF(__pyx_v_sessions);
  __Pyx_XDECREF(__pyx_v_current_session);
  __Pyx_XDECREF(__pyx_v_i);
  __Pyx_XDECREF(__pyx_v_prev_interval);
  __Pyx_XDECREF(__pyx_v_current_interval);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":3743
 *         return sessions
 * 
 *     def get_day_start_time(self, target_date, intervals_for_day):             # <<<<<<<<<<<<<<
 *         """
 *         Returns the appropriate start time for a given day's intervals.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_134get_day_start_time(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_133get_day_start_time, "\n        Returns the appropriate start time for a given day's intervals.\n        For the current day: uses current_session_start_time if set (after break end, new session),\n        otherwise the timer start time (self.start_date). For other days, uses 00:00:00 of that day.\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_134get_day_start_time = {"get_day_start_time", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_134get_day_start_time, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_133get_day_start_time};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_134get_day_start_time(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_target_date = 0;
  PyObject *__pyx_v_intervals_for_day = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_day_start_time (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_target_date,&__pyx_mstate_global->__pyx_n_u_intervals_for_day,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 3743, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 3743, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3743, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3743, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "get_day_start_time", 0) < (0)) __PYX_ERR(0, 3743, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 3; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("get_day_start_time", 1, 3, 3, i); __PYX_ERR(0, 3743, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 3)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3743, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3743, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 3743, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_target_date = values[1];
    __pyx_v_intervals_for_day = values[2];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_day_start_time", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 3743, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.get_day_start_time", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_133get_day_start_time(__pyx_self, __pyx_v_self, __pyx_v_target_date, __pyx_v_intervals_for_day);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_133get_day_start_time(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_target_date, PyObject *__pyx_v_intervals_for_day) {
  PyObject *__pyx_v_pinned = NULL;
  PyObject *__pyx_v_session_start = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  size_t __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_day_start_time", 0);

  /* "ws_package/controllers/activity_controller.py":3749
 *         otherwise the timer start time (self.start_date). For other days, uses 00:00:00 of that day.
 *         """
 *         if not intervals_for_day:             # <<<<<<<<<<<<<<
 *             return datetime.datetime.combine(target_date, datetime.time.min)
 * 
*/
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_intervals_for_day); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 3749, __pyx_L1_error)
  __pyx_t_2 = (!__pyx_t_1);
  if (__pyx_t_2) {

    /* "ws_package/controllers/activity_controller.py":3750
 *         """
 *         if not intervals_for_day:
 *             return datetime.datetime.combine(target_date, datetime.time.min)             # <<<<<<<<<<<<<<
 * 
 *         pinned = self._get_pinned_activity_log_session_start(target_date)
*/
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3750, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3750, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_4 = __pyx_t_6;
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3750, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_time); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3750, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_min); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3750, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = 0;
    {
      PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_v_target_date, __pyx_t_5};
      __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_combine, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3750, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":3749
 *         otherwise the timer start time (self.start_date). For other days, uses 00:00:00 of that day.
 *         """
 *         if not intervals_for_day:             # <<<<<<<<<<<<<<
 *             return datetime.datetime.combine(target_date, datetime.time.min)
 * 
*/
  }

  /* "ws_package/controllers/activity_controller.py":3752
 *             return datetime.datetime.combine(target_date, datetime.time.min)
 * 
 *         pinned = self._get_pinned_activity_log_session_start(target_date)             # <<<<<<<<<<<<<<
 *         if pinned is not None:
 *             return pinned
*/
  __pyx_t_6 = __pyx_v_self;
  __Pyx_INCREF(__pyx_t_6);
  __pyx_t_8 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_v_target_date};
    __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_pinned_activity_log_session, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3752, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  }
  __pyx_v_pinned = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "ws_package/controllers/activity_controller.py":3753
 * 
 *         pinned = self._get_pinned_activity_log_session_start(target_date)
 *         if pinned is not None:             # <<<<<<<<<<<<<<
 *             return pinned
 * 
*/
  __pyx_t_2 = (__pyx_v_pinned != Py_None);
  if (__pyx_t_2) {

    /* "ws_package/controllers/activity_controller.py":3754
 *         pinned = self._get_pinned_activity_log_session_start(target_date)
 *         if pinned is not None:
 *             return pinned             # <<<<<<<<<<<<<<
 * 
 *         if target_date == self.start_date.date():
*/
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(__pyx_v_pinned);
    __pyx_r = __pyx_v_pinned;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":3753
 * 
 *         pinned = self._get_pinned_activity_log_session_start(target_date)
 *         if pinned is not None:             # <<<<<<<<<<<<<<
 *             return pinned
 * 
*/
  }

  /* "ws_package/controllers/activity_controller.py":3756
 *             return pinned
 * 
 *         if target_date == self.start_date.date():             # <<<<<<<<<<<<<<
 *             # After break end, counter is incremented and current_session_start_time is set:
 *             # use it so payload "start" is the new session start time, not the original timer start
*/
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_start_date); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3756, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __pyx_t_5;
  __Pyx_INCREF(__pyx_t_6);
  __pyx_t_8 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
    __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_date, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3756, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  }
  __pyx_t_5 = PyObject_RichCompare(__pyx_v_target_date, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3756, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3756, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  if (__pyx_t_2) {

    /* "ws_package/controllers/activity_controller.py":3759
 *             # After break end, counter is incremented and current_session_start_time is set:
 *             # use it so payload "start" is the new session start time, not the original timer start
 *             session_start = getattr(self, "current_session_start_time", None)             # <<<<<<<<<<<<<<
 *             if session_start is not None and session_start.date() == target_date:
 *                 return self._normalize_activity_log_start(session_start)
*/
    __pyx_t_5 = __Pyx_GetAttr3(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_session_start_time, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3759, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_v_session_start = __pyx_t_5;
    __pyx_t_5 = 0;

    /* "ws_package/controllers/activity_controller.py":3760
 *             # use it so payload "start" is the new session start time, not the original timer start
 *             session_start = getattr(self, "current_session_start_time", None)
 *             if session_start is not None and session_start.date() == target_date:             # <<<<<<<<<<<<<<
 *                 return self._normalize_activity_log_start(session_start)
 *             return self._normalize_activity_log_start(self.start_date)
*/
    __pyx_t_1 = (__pyx_v_session_start != Py_None);
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L7_bool_binop_done;
    }
    __pyx_t_3 = __pyx_v_session_start;
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_8 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
      __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_date, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3760, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    __pyx_t_3 = PyObject_RichCompare(__pyx_t_5, __pyx_v_target_date, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3760, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 3760, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_2 = __pyx_t_1;
    __pyx_L7_bool_binop_done:;
    if (__pyx_t_2) {

      /* "ws_package/controllers/activity_controller.py":3761
 *             session_start = getattr(self, "current_session_start_time", None)
 *             if session_start is not None and session_start.date() == target_date:
 *                 return self._normalize_activity_log_start(session_start)             # <<<<<<<<<<<<<<
 *             return self._normalize_activity_log_start(self.start_date)
 *         else:
*/
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_5 = __pyx_v_self;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_v_session_start};
        __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_normalize_activity_log_start, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3761, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_3);
      }
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      goto __pyx_L0;

      /* "ws_package/controllers/activity_controller.py":3760
 *             # use it so payload "start" is the new session start time, not the original timer start
 *             session_start = getattr(self, "current_session_start_time", None)
 *             if session_start is not None and session_start.date() == target_date:             # <<<<<<<<<<<<<<
 *                 return self._normalize_activity_log_start(session_start)
 *             return self._normalize_activity_log_start(self.start_date)
*/
    }

    /* "ws_package/controllers/activity_controller.py":3762
 *             if session_start is not None and session_start.date() == target_date:
 *                 return self._normalize_activity_log_start(session_start)
 *             return self._normalize_activity_log_start(self.start_date)             # <<<<<<<<<<<<<<
 *         else:
 *             return datetime.datetime.combine(target_date, datetime.time.min)
*/
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_5 = __pyx_v_self;
    __Pyx_INCREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_start_date); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3762, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_8 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_6};
      __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_normalize_activity_log_start, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3762, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":3756
 *             return pinned
 * 
 *         if target_date == self.start_date.date():             # <<<<<<<<<<<<<<
 *             # After break end, counter is incremented and current_session_start_time is set:
 *             # use it so payload "start" is the new session start time, not the original timer start
*/
  }

  /* "ws_package/controllers/activity_controller.py":3764
 *             return self._normalize_activity_log_start(self.start_date)
 *         else:
 *             return datetime.datetime.combine(target_date, datetime.time.min)             # <<<<<<<<<<<<<<
 * 
 *     def _get_activity_level_from_interval(self, interval) -> dict:
*/
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_6 = __pyx_t_4;
    __Pyx_INCREF(__pyx_t_6);
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_time); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_min); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3764, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = 0;
    {
      PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_v_target_date, __pyx_t_5};
      __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_combine, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3764, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;
  }

  /* "ws_package/controllers/activity_controller.py":3743
 *         return sessions
 * 
 *     def get_day_start_time(self, target_date, intervals_for_day):             # <<<<<<<<<<<<<<
 *         """
 *         Returns the appropriate start time for a given day's intervals.
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.get_day_start_time", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_pinned);
  __Pyx_XDECREF(__pyx_v_session_start);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":3766
 *             return datetime.datetime.combine(target_date, datetime.time.min)
 * 
 *     def _get_activity_level_from_interval(self, interval) -> dict:             # <<<<<<<<<<<<<<
 *         return ActivityIntervalMixin._get_activity_level_from_interval(self, interval)
 * 
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_136_get_activity_level_from_interval(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_136_get_activity_level_from_interval = {"_get_activity_level_from_interval", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_136_get_activity_level_from_interval, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_136_get_activity_level_from_interval(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_interval = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_get_activity_level_from_interval (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_interval,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 3766, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3766, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3766, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_get_activity_level_from_interval", 0) < (0)) __PYX_ERR(0, 3766, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_get_activity_level_from_interval", 1, 2, 2, i); __PYX_ERR(0, 3766, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3766, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3766, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_interval = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_get_activity_level_from_interval", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 3766, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._get_activity_level_from_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_135_get_activity_level_from_interval(__pyx_self, __pyx_v_self, __pyx_v_interval);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_135_get_activity_level_from_interval(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_interval) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_get_activity_level_from_interval", 0);

  /* "ws_package/controllers/activity_controller.py":3767
 * 
 *     def _get_activity_level_from_interval(self, interval) -> dict:
 *         return ActivityIntervalMixin._get_activity_level_from_interval(self, interval)             # <<<<<<<<<<<<<<
 * 
 *     async def get_activity_level_from_db(self, start_time, end_time):
*/
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_ActivityIntervalMixin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3767, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_get_activity_level_from_interva); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3767, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_v_self, __pyx_v_interval};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3767, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  if (!(likely(PyDict_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None) || __Pyx_RaiseUnexpectedTypeError("dict", __pyx_t_1))) __PYX_ERR(0, 3767, __pyx_L1_error)
  __pyx_r = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;
  goto __pyx_L0;

  /* "ws_package/controllers/activity_controller.py":3766
 *             return datetime.datetime.combine(target_date, datetime.time.min)
 * 
 *     def _get_activity_level_from_interval(self, interval) -> dict:             # <<<<<<<<<<<<<<
 *         return ActivityIntervalMixin._get_activity_level_from_interval(self, interval)
 * 
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._get_activity_level_from_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_139generator25(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":3769
 *         return ActivityIntervalMixin._get_activity_level_from_interval(self, interval)
 * 
 *     async def get_activity_level_from_db(self, start_time, end_time):             # <<<<<<<<<<<<<<
 *         return await ActivityIntervalMixin.get_activity_level_from_db(self, start_time, end_time)
 * 
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_138get_activity_level_from_db(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_138get_activity_level_from_db = {"get_activity_level_from_db", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_138get_activity_level_from_db, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_138get_activity_level_from_db(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_start_time = 0;
  PyObject *__pyx_v_end_time = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_activity_level_from_db (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_start_time,&__pyx_mstate_global->__pyx_n_u_end_time,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 3769, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 3769, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3769, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3769, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "get_activity_level_from_db", 0) < (0)) __PYX_ERR(0, 3769, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 3; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("get_activity_level_from_db", 1, 3, 3, i); __PYX_ERR(0, 3769, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 3)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3769, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3769, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 3769, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_start_time = values[1];
    __pyx_v_end_time = values[2];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("get_activity_level_from_db", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 3769, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.get_activity_level_from_db", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_137get_activity_level_from_db(__pyx_self, __pyx_v_self, __pyx_v_start_time, __pyx_v_end_time);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_137get_activity_level_from_db(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_start_time, PyObject *__pyx_v_end_time) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("get_activity_level_from_db", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 3769, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_start_time = __pyx_v_start_time;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_start_time);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_start_time);
  __pyx_cur_scope->__pyx_v_end_time = __pyx_v_end_time;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_end_time);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_end_time);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_139generator25, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[42]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_get_activity_level_from_db, __pyx_mstate_global->__pyx_n_u_ActivityController_get_activity, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 3769, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.get_activity_level_from_db", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_139generator25(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  __Pyx_PySendResult __pyx_t_6;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("get_activity_level_from_db", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L4_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 3769, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":3770
 * 
 *     async def get_activity_level_from_db(self, start_time, end_time):
 *         return await ActivityIntervalMixin.get_activity_level_from_db(self, start_time, end_time)             # <<<<<<<<<<<<<<
 * 
 *     async def _is_app_monitor_data_stale(self, app_monitor_time: datetime.datetime, wake_time: Optional[datetime.datetime]) -> bool:
*/
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_ActivityIntervalMixin); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3770, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_get_activity_level_from_db); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3770, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[4] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_self, __pyx_cur_scope->__pyx_v_start_time, __pyx_cur_scope->__pyx_v_end_time};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (4-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3770, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_6 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (likely(__pyx_t_6 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L4_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3770, __pyx_L1_error)
    __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
  } else if (likely(__pyx_t_6 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __pyx_t_1 = __pyx_r; __pyx_r = NULL;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 3770, __pyx_L1_error)
  }
  __pyx_r = __pyx_t_1;
  __pyx_t_1 = 0;
  goto __pyx_L0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":3769
 *         return ActivityIntervalMixin._get_activity_level_from_interval(self, interval)
 * 
 *     async def get_activity_level_from_db(self, start_time, end_time):             # <<<<<<<<<<<<<<
 *         return await ActivityIntervalMixin.get_activity_level_from_db(self, start_time, end_time)
 * 
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("get_activity_level_from_db", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_142generator26(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":3772
 *         return await ActivityIntervalMixin.get_activity_level_from_db(self, start_time, end_time)
 * 
 *     async def _is_app_monitor_data_stale(self, app_monitor_time: datetime.datetime, wake_time: Optional[datetime.datetime]) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Check if app monitor data is stale (from before system wake).
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_141_is_app_monitor_data_stale(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_140_is_app_monitor_data_stale, "\n        Check if app monitor data is stale (from before system wake).\n        \n        Args:\n            app_monitor_time: Timestamp of app monitor entry\n            wake_time: When system woke up (if known)\n            \n        Returns:\n            bool: True if data is likely stale (from before wake or within 30 seconds after wake)\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_141_is_app_monitor_data_stale = {"_is_app_monitor_data_stale", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_141_is_app_monitor_data_stale, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_140_is_app_monitor_data_stale};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_141_is_app_monitor_data_stale(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  CYTHON_UNUSED PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_app_monitor_time = 0;
  PyObject *__pyx_v_wake_time = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_is_app_monitor_data_stale (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_app_monitor_time,&__pyx_mstate_global->__pyx_n_u_wake_time,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 3772, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 3772, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3772, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3772, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_is_app_monitor_data_stale", 0) < (0)) __PYX_ERR(0, 3772, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 3; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_is_app_monitor_data_stale", 1, 3, 3, i); __PYX_ERR(0, 3772, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 3)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3772, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3772, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 3772, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_app_monitor_time = values[1];
    __pyx_v_wake_time = values[2];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_is_app_monitor_data_stale", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 3772, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._is_app_monitor_data_stale", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_140_is_app_monitor_data_stale(__pyx_self, __pyx_v_self, __pyx_v_app_monitor_time, __pyx_v_wake_time);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_140_is_app_monitor_data_stale(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_app_monitor_time, PyObject *__pyx_v_wake_time) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_is_app_monitor_data_stale", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 3772, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_app_monitor_time = __pyx_v_app_monitor_time;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_app_monitor_time);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_app_monitor_time);
  __pyx_cur_scope->__pyx_v_wake_time = __pyx_v_wake_time;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_wake_time);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_wake_time);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_142generator26, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[43]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_is_app_monitor_data_stale, __pyx_mstate_global->__pyx_n_u_ActivityController__is_app_monit, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 3772, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._is_app_monitor_data_stale", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_142generator26(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_is_app_monitor_data_stale", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 3772, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":3783
 *             bool: True if data is likely stale (from before wake or within 30 seconds after wake)
 *         """
 *         if wake_time is None:             # <<<<<<<<<<<<<<
 *             return False  # Can't determine if stale without wake time
 * 
*/
  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_wake_time == Py_None);
  if (__pyx_t_1) {

    /* "ws_package/controllers/activity_controller.py":3784
 *         """
 *         if wake_time is None:
 *             return False  # Can't determine if stale without wake time             # <<<<<<<<<<<<<<
 * 
 *         # If app monitor data is from before wake or within 30 seconds after wake, it's likely stale
*/
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":3783
 *             bool: True if data is likely stale (from before wake or within 30 seconds after wake)
 *         """
 *         if wake_time is None:             # <<<<<<<<<<<<<<
 *             return False  # Can't determine if stale without wake time
 * 
*/
  }

  /* "ws_package/controllers/activity_controller.py":3787
 * 
 *         # If app monitor data is from before wake or within 30 seconds after wake, it's likely stale
 *         time_diff = (app_monitor_time - wake_time).total_seconds()             # <<<<<<<<<<<<<<
 *         return time_diff < 30  # Within 30 seconds of wake = likely stale
 * 
*/
  __pyx_t_4 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_app_monitor_time, __pyx_cur_scope->__pyx_v_wake_time); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3787, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_3 = __pyx_t_4;
  __Pyx_INCREF(__pyx_t_3);
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
    __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_total_seconds, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3787, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
  }
  __Pyx_GIVEREF(__pyx_t_2);
  __pyx_cur_scope->__pyx_v_time_diff = __pyx_t_2;
  __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":3788
 *         # If app monitor data is from before wake or within 30 seconds after wake, it's likely stale
 *         time_diff = (app_monitor_time - wake_time).total_seconds()
 *         return time_diff < 30  # Within 30 seconds of wake = likely stale             # <<<<<<<<<<<<<<
 * 
 *     async def _has_any_activity_in_interval(self, start_time: datetime.datetime, end_time: datetime.datetime, counter: int) -> bool:
*/
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_time_diff, __pyx_mstate_global->__pyx_int_30, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3788, __pyx_L1_error)
  __pyx_r = __pyx_t_2;
  __pyx_t_2 = 0;
  goto __pyx_L0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":3772
 *         return await ActivityIntervalMixin.get_activity_level_from_db(self, start_time, end_time)
 * 
 *     async def _is_app_monitor_data_stale(self, app_monitor_time: datetime.datetime, wake_time: Optional[datetime.datetime]) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Check if app monitor data is stale (from before system wake).
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("_is_app_monitor_data_stale", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_145generator27(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":3790
 *         return time_diff < 30  # Within 30 seconds of wake = likely stale
 * 
 *     async def _has_any_activity_in_interval(self, start_time: datetime.datetime, end_time: datetime.datetime, counter: int) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Check if there was ANY activity (keyboard, mouse, or app monitor) during an interval.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_144_has_any_activity_in_interval(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_143_has_any_activity_in_interval, "\n        Check if there was ANY activity (keyboard, mouse, or app monitor) during an interval.\n        \n        Args:\n            start_time: Start of the interval\n            end_time: End of the interval\n            counter: Counter value to filter by\n            \n        Returns:\n            bool: True if any activity exists during the interval\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_144_has_any_activity_in_interval = {"_has_any_activity_in_interval", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_144_has_any_activity_in_interval, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_143_has_any_activity_in_interval};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_144_has_any_activity_in_interval(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  CYTHON_UNUSED PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_start_time = 0;
  PyObject *__pyx_v_end_time = 0;
  PyObject *__pyx_v_counter = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[4] = {0,0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_has_any_activity_in_interval (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_start_time,&__pyx_mstate_global->__pyx_n_u_end_time,&__pyx_mstate_global->__pyx_n_u_counter,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 3790, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  4:
        values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 3790, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 3790, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3790, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3790, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_has_any_activity_in_interval", 0) < (0)) __PYX_ERR(0, 3790, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 4; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_has_any_activity_in_interval", 1, 4, 4, i); __PYX_ERR(0, 3790, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 4)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3790, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3790, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 3790, __pyx_L3_error)
      values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 3790, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_start_time = values[1];
    __pyx_v_end_time = values[2];
    if (__Pyx_PyInt_FromNumber(&values[3], "counter", 0) < (0)) __PYX_ERR(0, 3790, __pyx_L3_error)
    __pyx_v_counter = ((PyObject*)values[3]);
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_has_any_activity_in_interval", 1, 4, 4, __pyx_nargs); __PYX_ERR(0, 3790, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._has_any_activity_in_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_counter), (&PyLong_Type), 0, "counter", 2))) __PYX_ERR(0, 3790, __pyx_L1_error)
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_143_has_any_activity_in_interval(__pyx_self, __pyx_v_self, __pyx_v_start_time, __pyx_v_end_time, __pyx_v_counter);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  goto __pyx_L7_cleaned_up;
  __pyx_L0:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __pyx_L7_cleaned_up:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_143_has_any_activity_in_interval(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self, PyObject *__pyx_v_start_time, PyObject *__pyx_v_end_time, PyObject *__pyx_v_counter) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_has_any_activity_in_interval", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 3790, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_start_time = __pyx_v_start_time;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_start_time);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_start_time);
  __pyx_cur_scope->__pyx_v_end_time = __pyx_v_end_time;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_end_time);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_end_time);
  __pyx_cur_scope->__pyx_v_counter = __pyx_v_counter;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_counter);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_counter);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_145generator27, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[44]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_has_any_activity_in_interval, __pyx_mstate_global->__pyx_n_u_ActivityController__has_any_acti, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 3790, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._has_any_activity_in_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_145generator27(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  size_t __pyx_t_8;
  __Pyx_PySendResult __pyx_t_9;
  int __pyx_t_10;
  double __pyx_t_11;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  PyObject *__pyx_t_26 = NULL;
  int __pyx_t_27;
  int __pyx_t_28;
  char const *__pyx_t_29;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_has_any_activity_in_interval", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L10_resume_from_await;
    case 2: goto __pyx_L33_resume_from_await;
    case 3: goto __pyx_L43_resume_from_await;
    case 4: goto __pyx_L48_resume_from_await;
    case 5: goto __pyx_L49_resume_from_await;
    case 6: goto __pyx_L50_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 3790, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":3802
 *             bool: True if any activity exists during the interval
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # First check activity_percentage table for keyboard/mouse activity
 *             result = await activity_percentage_manager.find_overlapping_activity_percentage(start_time, end_time)
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":3804
 *         try:
 *             # First check activity_percentage table for keyboard/mouse activity
 *             result = await activity_percentage_manager.find_overlapping_activity_percentage(start_time, end_time)             # <<<<<<<<<<<<<<
 *             if result is not None:
 *                 keyboard_activity = float(result.keyboard or 0)
*/
      __pyx_t_5 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_activity_percentage_manager); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3804, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_find_overlapping_activity_percen); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3804, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_5);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_start_time, __pyx_cur_scope->__pyx_v_end_time};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3804, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (likely(__pyx_t_9 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
        __Pyx_XGIVEREF(__pyx_t_2);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
        __Pyx_XGIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 1;
        return __pyx_r;
        __pyx_L10_resume_from_await:;
        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_1);
        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_2);
        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_3);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3804, __pyx_L4_error)
        __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
      } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __pyx_t_4 = __pyx_r; __pyx_r = NULL;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 3804, __pyx_L4_error)
      }
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_cur_scope->__pyx_v_result = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":3805
 *             # First check activity_percentage table for keyboard/mouse activity
 *             result = await activity_percentage_manager.find_overlapping_activity_percentage(start_time, end_time)
 *             if result is not None:             # <<<<<<<<<<<<<<
 *                 keyboard_activity = float(result.keyboard or 0)
 *                 mouse_activity = float(result.mouse or 0)
*/
      __pyx_t_10 = (__pyx_cur_scope->__pyx_v_result != Py_None);
      if (__pyx_t_10) {

        /* "ws_package/controllers/activity_controller.py":3806
 *             result = await activity_percentage_manager.find_overlapping_activity_percentage(start_time, end_time)
 *             if result is not None:
 *                 keyboard_activity = float(result.keyboard or 0)             # <<<<<<<<<<<<<<
 *                 mouse_activity = float(result.mouse or 0)
 *                 average_activity = float(result.average or 0)
*/
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_result, __pyx_mstate_global->__pyx_n_u_keyboard); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3806, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 3806, __pyx_L4_error)
        if (!__pyx_t_10) {
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        } else {
          __Pyx_INCREF(__pyx_t_7);
          __pyx_t_4 = __pyx_t_7;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          goto __pyx_L12_bool_binop_done;
        }
        __pyx_t_7 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3806, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_4 = __pyx_t_7;
        __pyx_t_7 = 0;
        __pyx_L12_bool_binop_done:;
        __pyx_t_11 = __Pyx_PyObject_AsDouble(__pyx_t_4); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_11, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 3806, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_cur_scope->__pyx_v_keyboard_activity = __pyx_t_11;

        /* "ws_package/controllers/activity_controller.py":3807
 *             if result is not None:
 *                 keyboard_activity = float(result.keyboard or 0)
 *                 mouse_activity = float(result.mouse or 0)             # <<<<<<<<<<<<<<
 *                 average_activity = float(result.average or 0)
 * 
*/
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_result, __pyx_mstate_global->__pyx_n_u_mouse); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3807, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 3807, __pyx_L4_error)
        if (!__pyx_t_10) {
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        } else {
          __Pyx_INCREF(__pyx_t_7);
          __pyx_t_4 = __pyx_t_7;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          goto __pyx_L14_bool_binop_done;
        }
        __pyx_t_7 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3807, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_4 = __pyx_t_7;
        __pyx_t_7 = 0;
        __pyx_L14_bool_binop_done:;
        __pyx_t_11 = __Pyx_PyObject_AsDouble(__pyx_t_4); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_11, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 3807, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_cur_scope->__pyx_v_mouse_activity = __pyx_t_11;

        /* "ws_package/controllers/activity_controller.py":3808
 *                 keyboard_activity = float(result.keyboard or 0)
 *                 mouse_activity = float(result.mouse or 0)
 *                 average_activity = float(result.average or 0)             # <<<<<<<<<<<<<<
 * 
 *                 if keyboard_activity > 0 or mouse_activity > 0 or average_activity > 0:
*/
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_result, __pyx_mstate_global->__pyx_n_u_average); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3808, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 3808, __pyx_L4_error)
        if (!__pyx_t_10) {
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        } else {
          __Pyx_INCREF(__pyx_t_7);
          __pyx_t_4 = __pyx_t_7;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          goto __pyx_L16_bool_binop_done;
        }
        __pyx_t_7 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3808, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_4 = __pyx_t_7;
        __pyx_t_7 = 0;
        __pyx_L16_bool_binop_done:;
        __pyx_t_11 = __Pyx_PyObject_AsDouble(__pyx_t_4); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_11, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 3808, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_cur_scope->__pyx_v_average_activity = __pyx_t_11;

        /* "ws_package/controllers/activity_controller.py":3810
 *                 average_activity = float(result.average or 0)
 * 
 *                 if keyboard_activity > 0 or mouse_activity > 0 or average_activity > 0:             # <<<<<<<<<<<<<<
 *                     logger.debug("Activity found in activity_percentage for %s to %s: keyboard=%s, mouse=%s, average=%s",
 *                                start_time, end_time, keyboard_activity, mouse_activity, average_activity)
*/
        __pyx_t_12 = (__pyx_cur_scope->__pyx_v_keyboard_activity > 0.0);
        if (!__pyx_t_12) {
        } else {
          __pyx_t_10 = __pyx_t_12;
          goto __pyx_L19_bool_binop_done;
        }
        __pyx_t_12 = (__pyx_cur_scope->__pyx_v_mouse_activity > 0.0);
        if (!__pyx_t_12) {
        } else {
          __pyx_t_10 = __pyx_t_12;
          goto __pyx_L19_bool_binop_done;
        }
        __pyx_t_12 = (__pyx_cur_scope->__pyx_v_average_activity > 0.0);
        __pyx_t_10 = __pyx_t_12;
        __pyx_L19_bool_binop_done:;
        if (__pyx_t_10) {

          /* "ws_package/controllers/activity_controller.py":3811
 * 
 *                 if keyboard_activity > 0 or mouse_activity > 0 or average_activity > 0:
 *                     logger.debug("Activity found in activity_percentage for %s to %s: keyboard=%s, mouse=%s, average=%s",             # <<<<<<<<<<<<<<
 *                                start_time, end_time, keyboard_activity, mouse_activity, average_activity)
 *                     return True
*/
          __pyx_t_7 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3811, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3811, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":3812
 *                 if keyboard_activity > 0 or mouse_activity > 0 or average_activity > 0:
 *                     logger.debug("Activity found in activity_percentage for %s to %s: keyboard=%s, mouse=%s, average=%s",
 *                                start_time, end_time, keyboard_activity, mouse_activity, average_activity)             # <<<<<<<<<<<<<<
 *                     return True
 * 
*/
          __pyx_t_5 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_keyboard_activity); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3812, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_13 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_mouse_activity); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3812, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_14 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_average_activity); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3812, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_14);
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_6))) {
            __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
            assert(__pyx_t_7);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_7);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[7] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Activity_found_in_activity_perce, __pyx_cur_scope->__pyx_v_start_time, __pyx_cur_scope->__pyx_v_end_time, __pyx_t_5, __pyx_t_13, __pyx_t_14};
            __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (7-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3811, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_4);
          }
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

          /* "ws_package/controllers/activity_controller.py":3813
 *                     logger.debug("Activity found in activity_percentage for %s to %s: keyboard=%s, mouse=%s, average=%s",
 *                                start_time, end_time, keyboard_activity, mouse_activity, average_activity)
 *                     return True             # <<<<<<<<<<<<<<
 * 
 *             # Also check app monitor activity as fallback
*/
          __Pyx_XDECREF(__pyx_r);
          __Pyx_INCREF(Py_True);
          __pyx_r = Py_True;
          goto __pyx_L8_try_return;

          /* "ws_package/controllers/activity_controller.py":3810
 *                 average_activity = float(result.average or 0)
 * 
 *                 if keyboard_activity > 0 or mouse_activity > 0 or average_activity > 0:             # <<<<<<<<<<<<<<
 *                     logger.debug("Activity found in activity_percentage for %s to %s: keyboard=%s, mouse=%s, average=%s",
 *                                start_time, end_time, keyboard_activity, mouse_activity, average_activity)
*/
        }

        /* "ws_package/controllers/activity_controller.py":3805
 *             # First check activity_percentage table for keyboard/mouse activity
 *             result = await activity_percentage_manager.find_overlapping_activity_percentage(start_time, end_time)
 *             if result is not None:             # <<<<<<<<<<<<<<
 *                 keyboard_activity = float(result.keyboard or 0)
 *                 mouse_activity = float(result.mouse or 0)
*/
      }

      /* "ws_package/controllers/activity_controller.py":3816
 * 
 *             # Also check app monitor activity as fallback
 *             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     query = select(Appmonitor).where(
*/
      /*with:*/ {
        __pyx_t_6 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3816, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3816, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_13))) {
          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_13);
          assert(__pyx_t_6);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3816, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __pyx_t_15 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3816, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_6 = NULL;
        __pyx_t_14 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3816, __pyx_L22_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (likely(PyMethod_Check(__pyx_t_14))) {
          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_14);
          assert(__pyx_t_6);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
          __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3816, __pyx_L22_error)
          __Pyx_GOTREF(__pyx_t_13);
        }
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        /*try:*/ {
          {
            __Pyx_ExceptionSave(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
            __Pyx_XGOTREF(__pyx_t_16);
            __Pyx_XGOTREF(__pyx_t_17);
            __Pyx_XGOTREF(__pyx_t_18);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":3817
 *             # Also check app monitor activity as fallback
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     query = select(Appmonitor).where(
 *                         Appmonitor.counter == counter,
*/
              /*with:*/ {
                __pyx_t_13 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3817, __pyx_L26_error)
                __Pyx_GOTREF(__pyx_t_14);
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_14))) {
                  __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_14);
                  assert(__pyx_t_13);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
                  __Pyx_INCREF(__pyx_t_13);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_13, NULL};
                  __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3817, __pyx_L26_error)
                  __Pyx_GOTREF(__pyx_t_4);
                }
                __pyx_t_19 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 3817, __pyx_L26_error)
                __Pyx_GOTREF(__pyx_t_19);
                __pyx_t_13 = NULL;
                __pyx_t_6 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3817, __pyx_L32_error)
                __Pyx_GOTREF(__pyx_t_6);
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (likely(PyMethod_Check(__pyx_t_6))) {
                  __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_6);
                  assert(__pyx_t_13);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                  __Pyx_INCREF(__pyx_t_13);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_13, NULL};
                  __pyx_t_14 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3817, __pyx_L32_error)
                  __Pyx_GOTREF(__pyx_t_14);
                }
                __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_14, &__pyx_r);
                __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                if (likely(__pyx_t_9 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_1);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                  __Pyx_XGIVEREF(__pyx_t_2);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                  __Pyx_XGIVEREF(__pyx_t_3);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                  __Pyx_XGIVEREF(__pyx_t_4);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_15;
                  __Pyx_XGIVEREF(__pyx_t_16);
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_16;
                  __Pyx_XGIVEREF(__pyx_t_17);
                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_17;
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_18;
                  __Pyx_XGIVEREF(__pyx_t_19);
                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_19;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 2;
                  return __pyx_r;
                  __pyx_L33_resume_from_await:;
                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_1);
                  __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_2);
                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_3);
                  __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_4);
                  __pyx_t_15 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_15);
                  __pyx_t_16 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = 0;
                  __Pyx_XGOTREF(__pyx_t_16);
                  __pyx_t_17 = __pyx_cur_scope->__pyx_t_6;
                  __pyx_cur_scope->__pyx_t_6 = 0;
                  __Pyx_XGOTREF(__pyx_t_17);
                  __pyx_t_18 = __pyx_cur_scope->__pyx_t_7;
                  __pyx_cur_scope->__pyx_t_7 = 0;
                  __Pyx_XGOTREF(__pyx_t_18);
                  __pyx_t_19 = __pyx_cur_scope->__pyx_t_8;
                  __pyx_cur_scope->__pyx_t_8 = 0;
                  __Pyx_XGOTREF(__pyx_t_19);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3817, __pyx_L32_error)
                  __pyx_t_14 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_14);
                } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __pyx_t_14 = __pyx_r; __pyx_r = NULL;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 3817, __pyx_L32_error)
                }
                __pyx_t_6 = __pyx_t_14;
                __pyx_t_14 = 0;
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                /*try:*/ {
                  {
                    __Pyx_ExceptionSave(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
                    __Pyx_XGOTREF(__pyx_t_20);
                    __Pyx_XGOTREF(__pyx_t_21);
                    __Pyx_XGOTREF(__pyx_t_22);
                    /*try:*/ {
                      __Pyx_GIVEREF(__pyx_t_6);
                      __pyx_cur_scope->__pyx_v_session = __pyx_t_6;
                      __pyx_t_6 = 0;

                      /* "ws_package/controllers/activity_controller.py":3818
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:
 *                     query = select(Appmonitor).where(             # <<<<<<<<<<<<<<
 *                         Appmonitor.counter == counter,
 *                         Appmonitor.timestamp >= start_time,
*/
                      __pyx_t_7 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 3818, __pyx_L37_error)
                      __Pyx_GOTREF(__pyx_t_23);
                      __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_Appmonitor); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3818, __pyx_L37_error)
                      __Pyx_GOTREF(__pyx_t_24);
                      __pyx_t_8 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_23))) {
                        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_23);
                        assert(__pyx_t_7);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_23);
                        __Pyx_INCREF(__pyx_t_7);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_23, __pyx__function);
                        __pyx_t_8 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_t_24};
                        __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_23, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3818, __pyx_L37_error)
                        __Pyx_GOTREF(__pyx_t_5);
                      }
                      __pyx_t_13 = __pyx_t_5;
                      __Pyx_INCREF(__pyx_t_13);

                      /* "ws_package/controllers/activity_controller.py":3819
 *                 async with async_session() as session:
 *                     query = select(Appmonitor).where(
 *                         Appmonitor.counter == counter,             # <<<<<<<<<<<<<<
 *                         Appmonitor.timestamp >= start_time,
 *                         Appmonitor.timestamp <= end_time
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_Appmonitor); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 3819, __pyx_L37_error)
                      __Pyx_GOTREF(__pyx_t_23);
                      __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3819, __pyx_L37_error)
                      __Pyx_GOTREF(__pyx_t_24);
                      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                      __pyx_t_23 = PyObject_RichCompare(__pyx_t_24, __pyx_cur_scope->__pyx_v_counter, Py_EQ); __Pyx_XGOTREF(__pyx_t_23); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 3819, __pyx_L37_error)
                      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;

                      /* "ws_package/controllers/activity_controller.py":3820
 *                     query = select(Appmonitor).where(
 *                         Appmonitor.counter == counter,
 *                         Appmonitor.timestamp >= start_time,             # <<<<<<<<<<<<<<
 *                         Appmonitor.timestamp <= end_time
 *                     ).limit(1)
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_Appmonitor); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3820, __pyx_L37_error)
                      __Pyx_GOTREF(__pyx_t_24);
                      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_timestamp); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3820, __pyx_L37_error)
                      __Pyx_GOTREF(__pyx_t_7);
                      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                      __pyx_t_24 = PyObject_RichCompare(__pyx_t_7, __pyx_cur_scope->__pyx_v_start_time, Py_GE); __Pyx_XGOTREF(__pyx_t_24); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3820, __pyx_L37_error)
                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

                      /* "ws_package/controllers/activity_controller.py":3821
 *                         Appmonitor.counter == counter,
 *                         Appmonitor.timestamp >= start_time,
 *                         Appmonitor.timestamp <= end_time             # <<<<<<<<<<<<<<
 *                     ).limit(1)
 * 
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_Appmonitor); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3821, __pyx_L37_error)
                      __Pyx_GOTREF(__pyx_t_7);
                      __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_timestamp); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3821, __pyx_L37_error)
                      __Pyx_GOTREF(__pyx_t_25);
                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                      __pyx_t_7 = PyObject_RichCompare(__pyx_t_25, __pyx_cur_scope->__pyx_v_end_time, Py_LE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3821, __pyx_L37_error)
                      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[4] = {__pyx_t_13, __pyx_t_23, __pyx_t_24, __pyx_t_7};
                        __pyx_t_14 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                        if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3818, __pyx_L37_error)
                        __Pyx_GOTREF(__pyx_t_14);
                      }
                      __pyx_t_4 = __pyx_t_14;
                      __Pyx_INCREF(__pyx_t_4);
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_int_1};
                        __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_limit, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3822, __pyx_L37_error)
                        __Pyx_GOTREF(__pyx_t_6);
                      }
                      __Pyx_GIVEREF(__pyx_t_6);
                      __pyx_cur_scope->__pyx_v_query = __pyx_t_6;
                      __pyx_t_6 = 0;

                      /* "ws_package/controllers/activity_controller.py":3824
 *                     ).limit(1)
 * 
 *                     result = await session.execute(query)             # <<<<<<<<<<<<<<
 *                     app_data = result.scalars().first()
 * 
*/
                      __pyx_t_14 = __pyx_cur_scope->__pyx_v_session;
                      __Pyx_INCREF(__pyx_t_14);
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_14, __pyx_cur_scope->__pyx_v_query};
                        __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3824, __pyx_L37_error)
                        __Pyx_GOTREF(__pyx_t_6);
                      }
                      __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_6, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                      if (likely(__pyx_t_9 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_t_19);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_19;
                        __Pyx_XGIVEREF(__pyx_t_20);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_20;
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_21;
                        __Pyx_XGIVEREF(__pyx_t_22);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_22;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 3;
                        return __pyx_r;
                        __pyx_L43_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        __pyx_t_19 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_19);
                        __pyx_t_20 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_20);
                        __pyx_t_21 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_21);
                        __pyx_t_22 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_22);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3824, __pyx_L37_error)
                        __pyx_t_6 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_6);
                      } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_6 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 3824, __pyx_L37_error)
                      }
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_result);
                      __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_result, __pyx_t_6);
                      __Pyx_GIVEREF(__pyx_t_6);
                      __pyx_t_6 = 0;

                      /* "ws_package/controllers/activity_controller.py":3825
 * 
 *                     result = await session.execute(query)
 *                     app_data = result.scalars().first()             # <<<<<<<<<<<<<<
 * 
 *                     if app_data:
*/
                      __pyx_t_5 = __pyx_cur_scope->__pyx_v_result;
                      __Pyx_INCREF(__pyx_t_5);
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalars, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3825, __pyx_L37_error)
                        __Pyx_GOTREF(__pyx_t_4);
                      }
                      __pyx_t_14 = __pyx_t_4;
                      __Pyx_INCREF(__pyx_t_14);
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_14, NULL};
                        __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_first, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3825, __pyx_L37_error)
                        __Pyx_GOTREF(__pyx_t_6);
                      }
                      __Pyx_GIVEREF(__pyx_t_6);
                      __pyx_cur_scope->__pyx_v_app_data = __pyx_t_6;
                      __pyx_t_6 = 0;

                      /* "ws_package/controllers/activity_controller.py":3827
 *                     app_data = result.scalars().first()
 * 
 *                     if app_data:             # <<<<<<<<<<<<<<
 *                         logger.debug("App monitor activity found for %s to %s", start_time, end_time)
 *                         return True
*/
                      __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_app_data); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 3827, __pyx_L37_error)
                      if (__pyx_t_10) {

                        /* "ws_package/controllers/activity_controller.py":3828
 * 
 *                     if app_data:
 *                         logger.debug("App monitor activity found for %s to %s", start_time, end_time)             # <<<<<<<<<<<<<<
 *                         return True
 * 
*/
                        __pyx_t_4 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3828, __pyx_L37_error)
                        __Pyx_GOTREF(__pyx_t_14);
                        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3828, __pyx_L37_error)
                        __Pyx_GOTREF(__pyx_t_5);
                        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                        __pyx_t_8 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_5))) {
                          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
                          assert(__pyx_t_4);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                          __Pyx_INCREF(__pyx_t_4);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                          __pyx_t_8 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[4] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_App_monitor_activity_found_for_s, __pyx_cur_scope->__pyx_v_start_time, __pyx_cur_scope->__pyx_v_end_time};
                          __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3828, __pyx_L37_error)
                          __Pyx_GOTREF(__pyx_t_6);
                        }
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

                        /* "ws_package/controllers/activity_controller.py":3829
 *                     if app_data:
 *                         logger.debug("App monitor activity found for %s to %s", start_time, end_time)
 *                         return True             # <<<<<<<<<<<<<<
 * 
 *             return False
*/
                        __Pyx_XDECREF(__pyx_r);
                        __Pyx_INCREF(Py_True);
                        __pyx_r = Py_True;
                        goto __pyx_L41_try_return;

                        /* "ws_package/controllers/activity_controller.py":3827
 *                     app_data = result.scalars().first()
 * 
 *                     if app_data:             # <<<<<<<<<<<<<<
 *                         logger.debug("App monitor activity found for %s to %s", start_time, end_time)
 *                         return True
*/
                      }

                      /* "ws_package/controllers/activity_controller.py":3817
 *             # Also check app monitor activity as fallback
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     query = select(Appmonitor).where(
 *                         Appmonitor.counter == counter,
*/
                    }
                    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                    goto __pyx_L42_try_end;
                    __pyx_L37_error:;
                    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                    __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                    /*except:*/ {
                      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._has_any_activity_in_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4) < 0) __PYX_ERR(0, 3817, __pyx_L39_except_error)
                      __Pyx_XGOTREF(__pyx_t_6);
                      __Pyx_XGOTREF(__pyx_t_5);
                      __Pyx_XGOTREF(__pyx_t_4);
                      __pyx_t_14 = PyTuple_Pack(3, __pyx_t_6, __pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3817, __pyx_L39_except_error)
                      __Pyx_GOTREF(__pyx_t_14);
                      __pyx_t_26 = __Pyx_PyObject_Call(__pyx_t_19, __pyx_t_14, NULL);
                      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                      if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 3817, __pyx_L39_except_error)
                      __Pyx_GOTREF(__pyx_t_26);
                      __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_26, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                      if (likely(__pyx_t_9 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_4);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
                        __Pyx_XGIVEREF(__pyx_t_5);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_5;
                        __Pyx_XGIVEREF(__pyx_t_6);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_6;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_t_19);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_19;
                        __Pyx_XGIVEREF(__pyx_t_20);
                        __pyx_cur_scope->__pyx_t_11 = __pyx_t_20;
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __pyx_cur_scope->__pyx_t_12 = __pyx_t_21;
                        __Pyx_XGIVEREF(__pyx_t_22);
                        __pyx_cur_scope->__pyx_t_13 = __pyx_t_22;
                        __Pyx_XGIVEREF(__pyx_t_26);
                        __pyx_cur_scope->__pyx_t_14 = __pyx_t_26;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_SwapException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 4;
                        return __pyx_r;
                        __pyx_L48_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_4);
                        __pyx_t_5 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_5);
                        __pyx_t_6 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_6);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        __pyx_t_19 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_19);
                        __pyx_t_20 = __pyx_cur_scope->__pyx_t_11;
                        __pyx_cur_scope->__pyx_t_11 = 0;
                        __Pyx_XGOTREF(__pyx_t_20);
                        __pyx_t_21 = __pyx_cur_scope->__pyx_t_12;
                        __pyx_cur_scope->__pyx_t_12 = 0;
                        __Pyx_XGOTREF(__pyx_t_21);
                        __pyx_t_22 = __pyx_cur_scope->__pyx_t_13;
                        __pyx_cur_scope->__pyx_t_13 = 0;
                        __Pyx_XGOTREF(__pyx_t_22);
                        __pyx_t_26 = __pyx_cur_scope->__pyx_t_14;
                        __pyx_cur_scope->__pyx_t_14 = 0;
                        __Pyx_XGOTREF(__pyx_t_26);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3817, __pyx_L39_except_error)
                        __pyx_t_14 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_14);
                      } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_14 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 3817, __pyx_L39_except_error)
                      }
                      __pyx_t_26 = __pyx_t_14;
                      __pyx_t_14 = 0;
                      __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_26);
                      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                      if (__pyx_t_10 < (0)) __PYX_ERR(0, 3817, __pyx_L39_except_error)
                      __pyx_t_12 = (!__pyx_t_10);
                      if (unlikely(__pyx_t_12)) {
                        __Pyx_GIVEREF(__pyx_t_6);
                        __Pyx_GIVEREF(__pyx_t_5);
                        __Pyx_XGIVEREF(__pyx_t_4);
                        __Pyx_ErrRestoreWithState(__pyx_t_6, __pyx_t_5, __pyx_t_4);
                        __pyx_t_6 = 0;  __pyx_t_5 = 0;  __pyx_t_4 = 0; 
                        __PYX_ERR(0, 3817, __pyx_L39_except_error)
                      }
                      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      goto __pyx_L38_exception_handled;
                    }
                    __pyx_L39_except_error:;
                    __Pyx_XGIVEREF(__pyx_t_20);
                    __Pyx_XGIVEREF(__pyx_t_21);
                    __Pyx_XGIVEREF(__pyx_t_22);
                    __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22);
                    goto __pyx_L26_error;
                    __pyx_L41_try_return:;
                    __Pyx_XGIVEREF(__pyx_t_20);
                    __Pyx_XGIVEREF(__pyx_t_21);
                    __Pyx_XGIVEREF(__pyx_t_22);
                    __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22);
                    goto __pyx_L34_return;
                    __pyx_L38_exception_handled:;
                    __Pyx_XGIVEREF(__pyx_t_20);
                    __Pyx_XGIVEREF(__pyx_t_21);
                    __Pyx_XGIVEREF(__pyx_t_22);
                    __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22);
                    __pyx_L42_try_end:;
                  }
                }
                /*finally:*/ {
                  /*normal exit:*/{
                    if (__pyx_t_19) {
                      __pyx_t_22 = __Pyx_PyObject_Call(__pyx_t_19, __pyx_mstate_global->__pyx_tuple[7], NULL);
                      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                      if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 3817, __pyx_L26_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_22, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                      if (likely(__pyx_t_9 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_t_19);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_19;
                        __Pyx_XGIVEREF(__pyx_t_22);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_22;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 5;
                        return __pyx_r;
                        __pyx_L49_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        __pyx_t_19 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_19);
                        __pyx_t_22 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_22);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3817, __pyx_L26_error)
                        __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                      } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 3817, __pyx_L26_error)
                      }
                      __pyx_t_22 = __pyx_t_4;
                      __pyx_t_4 = 0;
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                    }
                    goto __pyx_L36;
                  }
                  __pyx_L34_return: {
                    __pyx_t_22 = __pyx_r;
                    __pyx_r = 0;
                    if (__pyx_t_19) {
                      __pyx_t_21 = __Pyx_PyObject_Call(__pyx_t_19, __pyx_mstate_global->__pyx_tuple[7], NULL);
                      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                      if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3817, __pyx_L26_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_21, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                      if (likely(__pyx_t_9 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_t_19);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_19;
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_21;
                        __Pyx_XGIVEREF(__pyx_t_22);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_22;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 6;
                        return __pyx_r;
                        __pyx_L50_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        __pyx_t_19 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_19);
                        __pyx_t_21 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_21);
                        __pyx_t_22 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_22);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3817, __pyx_L26_error)
                        __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                      } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 3817, __pyx_L26_error)
                      }
                      __pyx_t_21 = __pyx_t_4;
                      __pyx_t_4 = 0;
                      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                    }
                    __pyx_r = __pyx_t_22;
                    __pyx_t_22 = 0;
                    goto __pyx_L30_try_return;
                  }
                  __pyx_L36:;
                }
                goto __pyx_L51;
                __pyx_L32_error:;
                __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                goto __pyx_L26_error;
                __pyx_L51:;
              }

              /* "ws_package/controllers/activity_controller.py":3816
 * 
 *             # Also check app monitor activity as fallback
 *             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     query = select(Appmonitor).where(
*/
            }
            __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
            __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            goto __pyx_L31_try_end;
            __pyx_L26_error:;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
            __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            /*except:*/ {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._has_any_activity_in_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6) < 0) __PYX_ERR(0, 3816, __pyx_L28_except_error)
              __Pyx_XGOTREF(__pyx_t_4);
              __Pyx_XGOTREF(__pyx_t_5);
              __Pyx_XGOTREF(__pyx_t_6);
              __pyx_t_14 = PyTuple_Pack(3, __pyx_t_4, __pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3816, __pyx_L28_except_error)
              __Pyx_GOTREF(__pyx_t_14);
              __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_14, NULL);
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 3816, __pyx_L28_except_error)
              __Pyx_GOTREF(__pyx_t_19);
              __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_19);
              __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
              if (__pyx_t_12 < (0)) __PYX_ERR(0, 3816, __pyx_L28_except_error)
              __pyx_t_10 = (!__pyx_t_12);
              if (unlikely(__pyx_t_10)) {
                __Pyx_GIVEREF(__pyx_t_4);
                __Pyx_GIVEREF(__pyx_t_5);
                __Pyx_XGIVEREF(__pyx_t_6);
                __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_5, __pyx_t_6);
                __pyx_t_4 = 0;  __pyx_t_5 = 0;  __pyx_t_6 = 0; 
                __PYX_ERR(0, 3816, __pyx_L28_except_error)
              }
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              goto __pyx_L27_exception_handled;
            }
            __pyx_L28_except_error:;
            __Pyx_XGIVEREF(__pyx_t_16);
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
            goto __pyx_L4_error;
            __pyx_L30_try_return:;
            __Pyx_XGIVEREF(__pyx_t_16);
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
            goto __pyx_L23_return;
            __pyx_L27_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_16);
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
            __pyx_L31_try_end:;
          }
        }
        /*finally:*/ {
          /*normal exit:*/{
            if (__pyx_t_15) {
              __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_mstate_global->__pyx_tuple[7], NULL);
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 3816, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_18);
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
            }
            goto __pyx_L25;
          }
          __pyx_L23_return: {
            __pyx_t_18 = __pyx_r;
            __pyx_r = 0;
            if (__pyx_t_15) {
              __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_mstate_global->__pyx_tuple[7], NULL);
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 3816, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_17);
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            }
            __pyx_r = __pyx_t_18;
            __pyx_t_18 = 0;
            goto __pyx_L8_try_return;
          }
          __pyx_L25:;
        }
        goto __pyx_L55;
        __pyx_L22_error:;
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        goto __pyx_L4_error;
        __pyx_L55:;
      }

      /* "ws_package/controllers/activity_controller.py":3831
 *                         return True
 * 
 *             return False             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             logger.debug("Error checking activity in interval: %s", e)
*/
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_False);
      __pyx_r = Py_False;
      goto __pyx_L8_try_return;

      /* "ws_package/controllers/activity_controller.py":3802
 *             bool: True if any activity exists during the interval
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # First check activity_percentage table for keyboard/mouse activity
 *             result = await activity_percentage_manager.find_overlapping_activity_percentage(start_time, end_time)
*/
    }
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
    __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "ws_package/controllers/activity_controller.py":3832
 * 
 *             return False
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.debug("Error checking activity in interval: %s", e)
 *             return False  # Fail-safe: if we can't check, assume no activity
*/
    __pyx_t_27 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_27) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._has_any_activity_in_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_5, &__pyx_t_4) < 0) __PYX_ERR(0, 3832, __pyx_L6_except_error)
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_cur_scope->__pyx_v_e = __pyx_t_5;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":3833
 *             return False
 *         except Exception as e:
 *             logger.debug("Error checking activity in interval: %s", e)             # <<<<<<<<<<<<<<
 *             return False  # Fail-safe: if we can't check, assume no activity
 * 
*/
        __pyx_t_7 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3833, __pyx_L61_error)
        __Pyx_GOTREF(__pyx_t_24);
        __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 3833, __pyx_L61_error)
        __Pyx_GOTREF(__pyx_t_23);
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_23))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_23);
          assert(__pyx_t_7);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_23);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_23, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Error_checking_activity_in_inter, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_14 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_23, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
          if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3833, __pyx_L61_error)
          __Pyx_GOTREF(__pyx_t_14);
        }
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

        /* "ws_package/controllers/activity_controller.py":3834
 *         except Exception as e:
 *             logger.debug("Error checking activity in interval: %s", e)
 *             return False  # Fail-safe: if we can't check, assume no activity             # <<<<<<<<<<<<<<
 * 
 *     async def process_intervals_bulk(
*/
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_False);
        __pyx_r = Py_False;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        goto __pyx_L60_return;
      }

      /* "ws_package/controllers/activity_controller.py":3832
 * 
 *             return False
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.debug("Error checking activity in interval: %s", e)
 *             return False  # Fail-safe: if we can't check, assume no activity
*/
      /*finally:*/ {
        __pyx_L61_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_15 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0; __pyx_t_16 = 0; __pyx_t_19 = 0; __pyx_t_22 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
          __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_16, &__pyx_t_19, &__pyx_t_22);
          if ( unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_18, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_18, &__pyx_t_17);
          __Pyx_XGOTREF(__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_18);
          __Pyx_XGOTREF(__pyx_t_17);
          __Pyx_XGOTREF(__pyx_t_16);
          __Pyx_XGOTREF(__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_22);
          __pyx_t_27 = __pyx_lineno; __pyx_t_28 = __pyx_clineno; __pyx_t_29 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_16);
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_19, __pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_ErrRestore(__pyx_t_15, __pyx_t_18, __pyx_t_17);
          __pyx_t_15 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0; __pyx_t_16 = 0; __pyx_t_19 = 0; __pyx_t_22 = 0;
          __pyx_lineno = __pyx_t_27; __pyx_clineno = __pyx_t_28; __pyx_filename = __pyx_t_29;
          goto __pyx_L6_except_error;
        }
        __pyx_L60_return: {
          __pyx_t_22 = __pyx_r;
          __pyx_r = 0;
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          __pyx_r = __pyx_t_22;
          __pyx_t_22 = 0;
          goto __pyx_L7_except_return;
        }
      }
    }
    goto __pyx_L6_except_error;

    /* "ws_package/controllers/activity_controller.py":3802
 *             bool: True if any activity exists during the interval
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # First check activity_percentage table for keyboard/mouse activity
 *             result = await activity_percentage_manager.find_overlapping_activity_percentage(start_time, end_time)
*/
    __pyx_L6_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L7_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":3790
 *         return time_diff < 30  # Within 30 seconds of wake = likely stale
 * 
 *     async def _has_any_activity_in_interval(self, start_time: datetime.datetime, end_time: datetime.datetime, counter: int) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Check if there was ANY activity (keyboard, mouse, or app monitor) during an interval.
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_23);
  __Pyx_XDECREF(__pyx_t_24);
  __Pyx_XDECREF(__pyx_t_25);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("_has_any_activity_in_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_148generator28(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":3836
 *             return False  # Fail-safe: if we can't check, assume no activity
 * 
 *     async def process_intervals_bulk(             # <<<<<<<<<<<<<<
 *         self,
 *         intervals,
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_147process_intervals_bulk(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_147process_intervals_bulk = {"process_intervals_bulk", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_147process_intervals_bulk, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_147process_intervals_bulk(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_intervals = 0;
  PyObject *__pyx_v_org_id = 0;
  PyObject *__pyx_v_user_entity = 0;
  PyObject *__pyx_v_last_interval = 0;
  PyObject *__pyx_v_payload_project_id = 0;
  PyObject *__pyx_v_payload_task_id = 0;
  PyObject *__pyx_v_force_stop_time = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[8] = {0,0,0,0,0,0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("process_intervals_bulk (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_intervals,&__pyx_mstate_global->__pyx_n_u_org_id,&__pyx_mstate_global->__pyx_n_u_user_entity,&__pyx_mstate_global->__pyx_n_u_last_interval,&__pyx_mstate_global->__pyx_n_u_payload_project_id,&__pyx_mstate_global->__pyx_n_u_payload_task_id,&__pyx_mstate_global->__pyx_n_u_force_stop_time,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 3836, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  5:
        values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 3836, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  4:
        values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 3836, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 3836, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3836, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3836, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "process_intervals_bulk", 0) < (0)) __PYX_ERR(0, 3836, __pyx_L3_error)

      /* "ws_package/controllers/activity_controller.py":3841
 *         org_id,
 *         user_entity: UserEntity,
 *         last_interval=None,             # <<<<<<<<<<<<<<
 *         *,
 *         payload_project_id: Optional[str] = None,
*/
      if (!values[4]) values[4] = __Pyx_NewRef(((PyObject *)Py_None));

      /* "ws_package/controllers/activity_controller.py":3843
 *         last_interval=None,
 *         *,
 *         payload_project_id: Optional[str] = None,             # <<<<<<<<<<<<<<
 *         payload_task_id: Optional[str] = None,
 *         force_stop_time: Optional[datetime.datetime] = None,
*/
      if (!values[5]) values[5] = __Pyx_NewRef(((PyObject*)Py_None));

      /* "ws_package/controllers/activity_controller.py":3844
 *         *,
 *         payload_project_id: Optional[str] = None,
 *         payload_task_id: Optional[str] = None,             # <<<<<<<<<<<<<<
 *         force_stop_time: Optional[datetime.datetime] = None,
 *     ):
*/
      if (!values[6]) values[6] = __Pyx_NewRef(((PyObject*)Py_None));

      /* "ws_package/controllers/activity_controller.py":3845
 *         payload_project_id: Optional[str] = None,
 *         payload_task_id: Optional[str] = None,
 *         force_stop_time: Optional[datetime.datetime] = None,             # <<<<<<<<<<<<<<
 *     ):
 *         if intervals is None or len(intervals) == 0:
*/
      if (!values[7]) values[7] = __Pyx_NewRef(((PyObject *)Py_None));
      for (Py_ssize_t i = __pyx_nargs; i < 4; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("process_intervals_bulk", 0, 4, 5, i); __PYX_ERR(0, 3836, __pyx_L3_error) }
      }
    } else {
      switch (__pyx_nargs) {
        case  5:
        values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 3836, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  4:
        values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 3836, __pyx_L3_error)
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 3836, __pyx_L3_error)
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3836, __pyx_L3_error)
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3836, __pyx_L3_error)
        break;
        default: goto __pyx_L5_argtuple_error;
      }

      /* "ws_package/controllers/activity_controller.py":3841
 *         org_id,
 *         user_entity: UserEntity,
 *         last_interval=None,             # <<<<<<<<<<<<<<
 *         *,
 *         payload_project_id: Optional[str] = None,
*/
      if (!values[4]) values[4] = __Pyx_NewRef(((PyObject *)Py_None));

      /* "ws_package/controllers/activity_controller.py":3843
 *         last_interval=None,
 *         *,
 *         payload_project_id: Optional[str] = None,             # <<<<<<<<<<<<<<
 *         payload_task_id: Optional[str] = None,
 *         force_stop_time: Optional[datetime.datetime] = None,
*/
      if (!values[5]) values[5] = __Pyx_NewRef(((PyObject*)Py_None));

      /* "ws_package/controllers/activity_controller.py":3844
 *         *,
 *         payload_project_id: Optional[str] = None,
 *         payload_task_id: Optional[str] = None,             # <<<<<<<<<<<<<<
 *         force_stop_time: Optional[datetime.datetime] = None,
 *     ):
*/
      if (!values[6]) values[6] = __Pyx_NewRef(((PyObject*)Py_None));

      /* "ws_package/controllers/activity_controller.py":3845
 *         payload_project_id: Optional[str] = None,
 *         payload_task_id: Optional[str] = None,
 *         force_stop_time: Optional[datetime.datetime] = None,             # <<<<<<<<<<<<<<
 *     ):
 *         if intervals is None or len(intervals) == 0:
*/
      if (!values[7]) values[7] = __Pyx_NewRef(((PyObject *)Py_None));
    }
    __pyx_v_self = values[0];
    __pyx_v_intervals = values[1];
    __pyx_v_org_id = values[2];
    __pyx_v_user_entity = values[3];
    __pyx_v_last_interval = values[4];
    __pyx_v_payload_project_id = ((PyObject*)values[5]);
    __pyx_v_payload_task_id = ((PyObject*)values[6]);
    __pyx_v_force_stop_time = values[7];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("process_intervals_bulk", 0, 4, 5, __pyx_nargs); __PYX_ERR(0, 3836, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.process_intervals_bulk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_payload_project_id), (&PyUnicode_Type), 1, "payload_project_id", 2))) __PYX_ERR(0, 3843, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_payload_task_id), (&PyUnicode_Type), 1, "payload_task_id", 2))) __PYX_ERR(0, 3844, __pyx_L1_error)
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_146process_intervals_bulk(__pyx_self, __pyx_v_self, __pyx_v_intervals, __pyx_v_org_id, __pyx_v_user_entity, __pyx_v_last_interval, __pyx_v_payload_project_id, __pyx_v_payload_task_id, __pyx_v_force_stop_time);

  /* "ws_package/controllers/activity_controller.py":3836
 *             return False  # Fail-safe: if we can't check, assume no activity
 * 
 *     async def process_intervals_bulk(             # <<<<<<<<<<<<<<
 *         self,
 *         intervals,
*/

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  goto __pyx_L7_cleaned_up;
  __pyx_L0:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __pyx_L7_cleaned_up:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_22process_intervals_bulk_6generator63(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":4076
 *                     last_in_this_day = any(
 *                         _dt_match(getattr(iv, 'start_time', None), getattr(last_interval, 'start_time', None))
 *                         and _dt_match(getattr(iv, 'end_time', None), getattr(last_interval, 'end_time', None))             # <<<<<<<<<<<<<<
 *                         and getattr(iv, 'counter', None) == getattr(last_interval, 'counter', None)
 *                         for iv in day_intervals
*/

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_22process_intervals_bulk_4genexpr(PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 4076, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk *) __pyx_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  __pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_22process_intervals_bulk_6generator63, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[45]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_genexpr, __pyx_mstate_global->__pyx_n_u_ActivityController_process_inter, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 4076, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.process_intervals_bulk.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_22process_intervals_bulk_6generator63(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4076, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":4078
 *                         and _dt_match(getattr(iv, 'end_time', None), getattr(last_interval, 'end_time', None))
 *                         and getattr(iv, 'counter', None) == getattr(last_interval, 'counter', None)
 *                         for iv in day_intervals             # <<<<<<<<<<<<<<
 *                     )
 *                     if last_in_this_day:
*/
  if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 4078, __pyx_L1_error) }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1);
    __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_genexpr_arg_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4078, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4078, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4078, __pyx_L1_error)
          #endif
          if (__pyx_t_2 >= __pyx_temp) break;
        }
        __pyx_t_4 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_1, __pyx_t_2, __Pyx_ReferenceSharing_OwnStrongReference);
        ++__pyx_t_2;
      } else {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4078, __pyx_L1_error)
          #endif
          if (__pyx_t_2 >= __pyx_temp) break;
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2));
        #else
        __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2);
        #endif
        ++__pyx_t_2;
      }
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4078, __pyx_L1_error)
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 4078, __pyx_L1_error)
          PyErr_Clear();
        }
        break;
      }
    }
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_iv);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_iv, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;

    /* "ws_package/controllers/activity_controller.py":4075
 *                 if not is_sleep_interval:
 *                     last_in_this_day = any(
 *                         _dt_match(getattr(iv, 'start_time', None), getattr(last_interval, 'start_time', None))             # <<<<<<<<<<<<<<
 *                         and _dt_match(getattr(iv, 'end_time', None), getattr(last_interval, 'end_time', None))
 *                         and getattr(iv, 'counter', None) == getattr(last_interval, 'counter', None)
*/
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v__dt_match)) { __Pyx_RaiseClosureNameError("_dt_match"); __PYX_ERR(0, 4075, __pyx_L1_error) }
    __pyx_t_4 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_start_time, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4075, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval)) { __Pyx_RaiseClosureNameError("last_interval"); __PYX_ERR(0, 4075, __pyx_L1_error) }
    __pyx_t_6 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval;
    __Pyx_INCREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_GetAttr3(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_start_time, Py_None); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4075, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4075, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_4);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4) != (0)) __PYX_ERR(0, 4075, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_7);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_7) != (0)) __PYX_ERR(0, 4075, __pyx_L1_error);
    __pyx_t_4 = 0;
    __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_cur_scope->__pyx_outer_scope->__pyx_v__dt_match, __pyx_t_6, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4075, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 4075, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (__pyx_t_8) {
    } else {
      __pyx_t_5 = __pyx_t_8;
      goto __pyx_L7_bool_binop_done;
    }

    /* "ws_package/controllers/activity_controller.py":4076
 *                     last_in_this_day = any(
 *                         _dt_match(getattr(iv, 'start_time', None), getattr(last_interval, 'start_time', None))
 *                         and _dt_match(getattr(iv, 'end_time', None), getattr(last_interval, 'end_time', None))             # <<<<<<<<<<<<<<
 *                         and getattr(iv, 'counter', None) == getattr(last_interval, 'counter', None)
 *                         for iv in day_intervals
*/
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v__dt_match)) { __Pyx_RaiseClosureNameError("_dt_match"); __PYX_ERR(0, 4076, __pyx_L1_error) }
    __pyx_t_7 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_end_time, Py_None); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4076, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval)) { __Pyx_RaiseClosureNameError("last_interval"); __PYX_ERR(0, 4076, __pyx_L1_error) }
    __pyx_t_6 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval;
    __Pyx_INCREF(__pyx_t_6);
    __pyx_t_4 = __Pyx_GetAttr3(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_end_time, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4076, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4076, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_GIVEREF(__pyx_t_7);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7) != (0)) __PYX_ERR(0, 4076, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_4);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_4) != (0)) __PYX_ERR(0, 4076, __pyx_L1_error);
    __pyx_t_7 = 0;
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_cur_scope->__pyx_outer_scope->__pyx_v__dt_match, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4076, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 4076, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_8) {
    } else {
      __pyx_t_5 = __pyx_t_8;
      goto __pyx_L7_bool_binop_done;
    }

    /* "ws_package/controllers/activity_controller.py":4077
 *                         _dt_match(getattr(iv, 'start_time', None), getattr(last_interval, 'start_time', None))
 *                         and _dt_match(getattr(iv, 'end_time', None), getattr(last_interval, 'end_time', None))
 *                         and getattr(iv, 'counter', None) == getattr(last_interval, 'counter', None)             # <<<<<<<<<<<<<<
 *                         for iv in day_intervals
 *                     )
*/
    __pyx_t_4 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_counter, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4077, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval)) { __Pyx_RaiseClosureNameError("last_interval"); __PYX_ERR(0, 4077, __pyx_L1_error) }
    __pyx_t_6 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval;
    __Pyx_INCREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_GetAttr3(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_counter, Py_None); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4077, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = PyObject_RichCompare(__pyx_t_4, __pyx_t_7, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4077, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 4077, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_5 = __pyx_t_8;
    __pyx_L7_bool_binop_done:;

    /* "ws_package/controllers/activity_controller.py":4076
 *                     last_in_this_day = any(
 *                         _dt_match(getattr(iv, 'start_time', None), getattr(last_interval, 'start_time', None))
 *                         and _dt_match(getattr(iv, 'end_time', None), getattr(last_interval, 'end_time', None))             # <<<<<<<<<<<<<<
 *                         and getattr(iv, 'counter', None) == getattr(last_interval, 'counter', None)
 *                         for iv in day_intervals
*/
    if (__pyx_t_5) {

      /* "ws_package/controllers/activity_controller.py":4074
 * 
 *                 if not is_sleep_interval:
 *                     last_in_this_day = any(             # <<<<<<<<<<<<<<
 *                         _dt_match(getattr(iv, 'start_time', None), getattr(last_interval, 'start_time', None))
 *                         and _dt_match(getattr(iv, 'end_time', None), getattr(last_interval, 'end_time', None))
*/
      __Pyx_XDECREF(__pyx_r);

      /* "ws_package/controllers/activity_controller.py":4076
 *                     last_in_this_day = any(
 *                         _dt_match(getattr(iv, 'start_time', None), getattr(last_interval, 'start_time', None))
 *                         and _dt_match(getattr(iv, 'end_time', None), getattr(last_interval, 'end_time', None))             # <<<<<<<<<<<<<<
 *                         and getattr(iv, 'counter', None) == getattr(last_interval, 'counter', None)
 *                         for iv in day_intervals
*/
      __Pyx_INCREF(Py_True);
      __pyx_r = Py_True;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }

    /* "ws_package/controllers/activity_controller.py":4078
 *                         and _dt_match(getattr(iv, 'end_time', None), getattr(last_interval, 'end_time', None))
 *                         and getattr(iv, 'counter', None) == getattr(last_interval, 'counter', None)
 *                         for iv in day_intervals             # <<<<<<<<<<<<<<
 *                     )
 *                     if last_in_this_day:
*/
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  /*else*/ {

    /* "ws_package/controllers/activity_controller.py":4074
 * 
 *                 if not is_sleep_interval:
 *                     last_in_this_day = any(             # <<<<<<<<<<<<<<
 *                         _dt_match(getattr(iv, 'start_time', None), getattr(last_interval, 'start_time', None))
 *                         and _dt_match(getattr(iv, 'end_time', None), getattr(last_interval, 'end_time', None))
*/
    __Pyx_XDECREF(__pyx_r);

    /* "ws_package/controllers/activity_controller.py":4076
 *                     last_in_this_day = any(
 *                         _dt_match(getattr(iv, 'start_time', None), getattr(last_interval, 'start_time', None))
 *                         and _dt_match(getattr(iv, 'end_time', None), getattr(last_interval, 'end_time', None))             # <<<<<<<<<<<<<<
 *                         and getattr(iv, 'counter', None) == getattr(last_interval, 'counter', None)
 *                         for iv in day_intervals
*/
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":3836
 *             return False  # Fail-safe: if we can't check, assume no activity
 * 
 *     async def process_intervals_bulk(             # <<<<<<<<<<<<<<
 *         self,
 *         intervals,
*/

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_146process_intervals_bulk(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_intervals, PyObject *__pyx_v_org_id, PyObject *__pyx_v_user_entity, PyObject *__pyx_v_last_interval, PyObject *__pyx_v_payload_project_id, PyObject *__pyx_v_payload_task_id, PyObject *__pyx_v_force_stop_time) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk *__pyx_cur_scope;
  PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_22process_intervals_bulk_6generator63 = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("process_intervals_bulk", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 3836, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_intervals = __pyx_v_intervals;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_intervals);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_intervals);
  __pyx_cur_scope->__pyx_v_org_id = __pyx_v_org_id;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_org_id);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_org_id);
  __pyx_cur_scope->__pyx_v_user_entity = __pyx_v_user_entity;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_user_entity);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_user_entity);
  __pyx_cur_scope->__pyx_v_last_interval = __pyx_v_last_interval;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_last_interval);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_last_interval);
  __pyx_cur_scope->__pyx_v_payload_project_id = __pyx_v_payload_project_id;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_payload_project_id);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_payload_project_id);
  __pyx_cur_scope->__pyx_v_payload_task_id = __pyx_v_payload_task_id;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_payload_task_id);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_payload_task_id);
  __pyx_cur_scope->__pyx_v_force_stop_time = __pyx_v_force_stop_time;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_force_stop_time);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_force_stop_time);
  {
    __pyx_CoroutineObject *gen = __Pyx_AsyncGen_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_148generator28, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[46]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_process_intervals_bulk, __pyx_mstate_global->__pyx_n_u_ActivityController_process_inter_2, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 3836, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.process_intervals_bulk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XDECREF(__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_22process_intervals_bulk_6generator63);
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":3941
 *                 ss_end_time = interval.end_time
 *                 if last_interval is not None:
 *                     def _dt_match(a, b, tol=1.0):             # <<<<<<<<<<<<<<
 *                         if a is None or b is None:
 *                             return a == b
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_22process_intervals_bulk_1_dt_match(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_22process_intervals_bulk_1_dt_match = {"_dt_match", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_22process_intervals_bulk_1_dt_match, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_22process_intervals_bulk_1_dt_match(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_v_b = 0;
  PyObject *__pyx_v_tol = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_dt_match (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_a,&__pyx_mstate_global->__pyx_n_u_b,&__pyx_mstate_global->__pyx_n_u_tol,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 3941, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 3941, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3941, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3941, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_dt_match", 0) < (0)) __PYX_ERR(0, 3941, __pyx_L3_error)
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject *)((PyObject*)__pyx_mstate_global->__pyx_float_1_0)));
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_dt_match", 0, 2, 3, i); __PYX_ERR(0, 3941, __pyx_L3_error) }
      }
    } else {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 3941, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 3941, __pyx_L3_error)
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 3941, __pyx_L3_error)
        break;
        default: goto __pyx_L5_argtuple_error;
      }
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject *)((PyObject*)__pyx_mstate_global->__pyx_float_1_0)));
    }
    __pyx_v_a = values[0];
    __pyx_v_b = values[1];
    __pyx_v_tol = values[2];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_dt_match", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 3941, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.process_intervals_bulk._dt_match", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_22process_intervals_bulk__dt_match(__pyx_self, __pyx_v_a, __pyx_v_b, __pyx_v_tol);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_22process_intervals_bulk__dt_match(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_tol) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  size_t __pyx_t_9;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_dt_match", 0);

  /* "ws_package/controllers/activity_controller.py":3942
 *                 if last_interval is not None:
 *                     def _dt_match(a, b, tol=1.0):
 *                         if a is None or b is None:             # <<<<<<<<<<<<<<
 *                             return a == b
 *                         try:
*/
  __pyx_t_2 = (__pyx_v_a == Py_None);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = (__pyx_v_b == Py_None);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "ws_package/controllers/activity_controller.py":3943
 *                     def _dt_match(a, b, tol=1.0):
 *                         if a is None or b is None:
 *                             return a == b             # <<<<<<<<<<<<<<
 *                         try:
 *                             return abs((a - b).total_seconds()) <= tol
*/
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_a, __pyx_v_b, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3943, __pyx_L1_error)
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":3942
 *                 if last_interval is not None:
 *                     def _dt_match(a, b, tol=1.0):
 *                         if a is None or b is None:             # <<<<<<<<<<<<<<
 *                             return a == b
 *                         try:
*/
  }

  /* "ws_package/controllers/activity_controller.py":3944
 *                         if a is None or b is None:
 *                             return a == b
 *                         try:             # <<<<<<<<<<<<<<
 *                             return abs((a - b).total_seconds()) <= tol
 *                         except Exception:
*/
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":3945
 *                             return a == b
 *                         try:
 *                             return abs((a - b).total_seconds()) <= tol             # <<<<<<<<<<<<<<
 *                         except Exception:
 *                             return False
*/
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_8 = PyNumber_Subtract(__pyx_v_a, __pyx_v_b); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3945, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_7 = __pyx_t_8;
      __Pyx_INCREF(__pyx_t_7);
      __pyx_t_9 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
        __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_total_seconds, __pyx_callargs+__pyx_t_9, (1-__pyx_t_9) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3945, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_3);
      }
      __pyx_t_8 = __Pyx_PyNumber_Absolute(__pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3945, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_RichCompare(__pyx_t_8, __pyx_v_tol, Py_LE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 3945, __pyx_L6_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      goto __pyx_L10_try_return;

      /* "ws_package/controllers/activity_controller.py":3944
 *                         if a is None or b is None:
 *                             return a == b
 *                         try:             # <<<<<<<<<<<<<<
 *                             return abs((a - b).total_seconds()) <= tol
 *                         except Exception:
*/
    }
    __pyx_L6_error:;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "ws_package/controllers/activity_controller.py":3946
 *                         try:
 *                             return abs((a - b).total_seconds()) <= tol
 *                         except Exception:             # <<<<<<<<<<<<<<
 *                             return False
 *                     last_match = (
*/
    __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_10) {
      __Pyx_ErrRestore(0,0,0);

      /* "ws_package/controllers/activity_controller.py":3947
 *                             return abs((a - b).total_seconds()) <= tol
 *                         except Exception:
 *                             return False             # <<<<<<<<<<<<<<
 *                     last_match = (
 *                         _dt_match(getattr(interval, 'start_time', None), getattr(last_interval, 'start_time', None))
*/
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_False);
      __pyx_r = Py_False;
      goto __pyx_L9_except_return;
    }
    goto __pyx_L8_except_error;

    /* "ws_package/controllers/activity_controller.py":3944
 *                         if a is None or b is None:
 *                             return a == b
 *                         try:             # <<<<<<<<<<<<<<
 *                             return abs((a - b).total_seconds()) <= tol
 *                         except Exception:
*/
    __pyx_L8_except_error:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L10_try_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
    __pyx_L9_except_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
  }

  /* "ws_package/controllers/activity_controller.py":3941
 *                 ss_end_time = interval.end_time
 *                 if last_interval is not None:
 *                     def _dt_match(a, b, tol=1.0):             # <<<<<<<<<<<<<<
 *                         if a is None or b is None:
 *                             return a == b
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.process_intervals_bulk._dt_match", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":4033
 *             stop_dt_for_intervals = None
 *             if last_interval is not None:
 *                 def _dt_match(a, b, tol=1.0):             # <<<<<<<<<<<<<<
 *                     if a is None or b is None:
 *                         return a == b
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_22process_intervals_bulk_3_dt_match(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_22process_intervals_bulk_3_dt_match = {"_dt_match", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_22process_intervals_bulk_3_dt_match, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_22process_intervals_bulk_3_dt_match(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_a = 0;
  PyObject *__pyx_v_b = 0;
  PyObject *__pyx_v_tol = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_dt_match (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_a,&__pyx_mstate_global->__pyx_n_u_b,&__pyx_mstate_global->__pyx_n_u_tol,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 4033, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 4033, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 4033, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4033, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_dt_match", 0) < (0)) __PYX_ERR(0, 4033, __pyx_L3_error)
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject *)((PyObject*)__pyx_mstate_global->__pyx_float_1_0)));
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_dt_match", 0, 2, 3, i); __PYX_ERR(0, 4033, __pyx_L3_error) }
      }
    } else {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 4033, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 4033, __pyx_L3_error)
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4033, __pyx_L3_error)
        break;
        default: goto __pyx_L5_argtuple_error;
      }
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject *)((PyObject*)__pyx_mstate_global->__pyx_float_1_0)));
    }
    __pyx_v_a = values[0];
    __pyx_v_b = values[1];
    __pyx_v_tol = values[2];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_dt_match", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 4033, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.process_intervals_bulk._dt_match", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_22process_intervals_bulk_2_dt_match(__pyx_self, __pyx_v_a, __pyx_v_b, __pyx_v_tol);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_22process_intervals_bulk_2_dt_match(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_a, PyObject *__pyx_v_b, PyObject *__pyx_v_tol) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  size_t __pyx_t_9;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_dt_match", 0);

  /* "ws_package/controllers/activity_controller.py":4034
 *             if last_interval is not None:
 *                 def _dt_match(a, b, tol=1.0):
 *                     if a is None or b is None:             # <<<<<<<<<<<<<<
 *                         return a == b
 *                     try:
*/
  __pyx_t_2 = (__pyx_v_a == Py_None);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = (__pyx_v_b == Py_None);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "ws_package/controllers/activity_controller.py":4035
 *                 def _dt_match(a, b, tol=1.0):
 *                     if a is None or b is None:
 *                         return a == b             # <<<<<<<<<<<<<<
 *                     try:
 *                         return abs((a - b).total_seconds()) <= tol
*/
    __Pyx_XDECREF(__pyx_r);
    __pyx_t_3 = PyObject_RichCompare(__pyx_v_a, __pyx_v_b, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4035, __pyx_L1_error)
    __pyx_r = __pyx_t_3;
    __pyx_t_3 = 0;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":4034
 *             if last_interval is not None:
 *                 def _dt_match(a, b, tol=1.0):
 *                     if a is None or b is None:             # <<<<<<<<<<<<<<
 *                         return a == b
 *                     try:
*/
  }

  /* "ws_package/controllers/activity_controller.py":4036
 *                     if a is None or b is None:
 *                         return a == b
 *                     try:             # <<<<<<<<<<<<<<
 *                         return abs((a - b).total_seconds()) <= tol
 *                     except Exception:
*/
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_4, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":4037
 *                         return a == b
 *                     try:
 *                         return abs((a - b).total_seconds()) <= tol             # <<<<<<<<<<<<<<
 *                     except Exception:
 *                         return False
*/
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_8 = PyNumber_Subtract(__pyx_v_a, __pyx_v_b); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4037, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_7 = __pyx_t_8;
      __Pyx_INCREF(__pyx_t_7);
      __pyx_t_9 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
        __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_total_seconds, __pyx_callargs+__pyx_t_9, (1-__pyx_t_9) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4037, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_3);
      }
      __pyx_t_8 = __Pyx_PyNumber_Absolute(__pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4037, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_3 = PyObject_RichCompare(__pyx_t_8, __pyx_v_tol, Py_LE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4037, __pyx_L6_error)
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_r = __pyx_t_3;
      __pyx_t_3 = 0;
      goto __pyx_L10_try_return;

      /* "ws_package/controllers/activity_controller.py":4036
 *                     if a is None or b is None:
 *                         return a == b
 *                     try:             # <<<<<<<<<<<<<<
 *                         return abs((a - b).total_seconds()) <= tol
 *                     except Exception:
*/
    }
    __pyx_L6_error:;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "ws_package/controllers/activity_controller.py":4038
 *                     try:
 *                         return abs((a - b).total_seconds()) <= tol
 *                     except Exception:             # <<<<<<<<<<<<<<
 *                         return False
 * 
*/
    __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_10) {
      __Pyx_ErrRestore(0,0,0);

      /* "ws_package/controllers/activity_controller.py":4039
 *                         return abs((a - b).total_seconds()) <= tol
 *                     except Exception:
 *                         return False             # <<<<<<<<<<<<<<
 * 
 *                 # NEW: Check if this is a sleep interval (long gap with zero activity)
*/
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_False);
      __pyx_r = Py_False;
      goto __pyx_L9_except_return;
    }
    goto __pyx_L8_except_error;

    /* "ws_package/controllers/activity_controller.py":4036
 *                     if a is None or b is None:
 *                         return a == b
 *                     try:             # <<<<<<<<<<<<<<
 *                         return abs((a - b).total_seconds()) <= tol
 *                     except Exception:
*/
    __pyx_L8_except_error:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L10_try_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
    __pyx_L9_except_return:;
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_4, __pyx_t_5, __pyx_t_6);
    goto __pyx_L0;
  }

  /* "ws_package/controllers/activity_controller.py":4033
 *             stop_dt_for_intervals = None
 *             if last_interval is not None:
 *                 def _dt_match(a, b, tol=1.0):             # <<<<<<<<<<<<<<
 *                     if a is None or b is None:
 *                         return a == b
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.process_intervals_bulk._dt_match", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":3836
 *             return False  # Fail-safe: if we can't check, assume no activity
 * 
 *     async def process_intervals_bulk(             # <<<<<<<<<<<<<<
 *         self,
 *         intervals,
*/

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_148generator28(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  int __pyx_t_2;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  size_t __pyx_t_8;
  Py_ssize_t __pyx_t_9;
  int __pyx_t_10;
  int __pyx_t_11;
  Py_ssize_t __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *(*__pyx_t_16)(PyObject *);
  int __pyx_t_17;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  __Pyx_PySendResult __pyx_t_26;
  PyObject *__pyx_t_27 = NULL;
  PyObject *__pyx_t_28 = NULL;
  PyObject *__pyx_t_29 = NULL;
  Py_ssize_t __pyx_t_30;
  PyObject *(*__pyx_t_31)(PyObject *);
  PyObject *__pyx_t_32 = NULL;
  PyObject *__pyx_t_33 = NULL;
  int __pyx_t_34;
  char const *__pyx_t_35;
  PyObject *(*__pyx_t_36)(PyObject *);
  PyObject *__pyx_t_37 = NULL;
  int __pyx_t_38;
  double __pyx_t_39;
  PyObject *__pyx_t_40 = NULL;
  PyObject *__pyx_t_41 = NULL;
  char const *__pyx_t_42;
  char const *__pyx_t_43;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("process_intervals_bulk", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L7_resume_from_yield;
    case 2: goto __pyx_L51_resume_from_await;
    case 3: goto __pyx_L65_resume_from_await;
    case 4: goto __pyx_L81_resume_from_await;
    case 5: goto __pyx_L82_resume_from_await;
    case 6: goto __pyx_L120_resume_from_await;
    case 7: goto __pyx_L121_resume_from_await;
    case 8: goto __pyx_L122_resume_from_await;
    case 9: goto __pyx_L140_resume_from_await;
    case 10: goto __pyx_L199_resume_from_yield;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started async generator");
    __PYX_ERR(0, 3836, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":3847
 *         force_stop_time: Optional[datetime.datetime] = None,
 *     ):
 *         if intervals is None or len(intervals) == 0:             # <<<<<<<<<<<<<<
 *             logger.info("No intervals found for the given date range.")
 *             yield None
*/
  __pyx_t_2 = (__pyx_cur_scope->__pyx_v_intervals == Py_None);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_3 = PyObject_Length(__pyx_cur_scope->__pyx_v_intervals); if (unlikely(__pyx_t_3 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3847, __pyx_L1_error)
  __pyx_t_2 = (__pyx_t_3 == 0);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_1) {

    /* "ws_package/controllers/activity_controller.py":3848
 *     ):
 *         if intervals is None or len(intervals) == 0:
 *             logger.info("No intervals found for the given date range.")             # <<<<<<<<<<<<<<
 *             yield None
 * 
*/
    __pyx_t_5 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3848, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3848, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_8 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
      assert(__pyx_t_5);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
      __pyx_t_8 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_No_intervals_found_for_the_given};
      __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3848, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "ws_package/controllers/activity_controller.py":3849
 *         if intervals is None or len(intervals) == 0:
 *             logger.info("No intervals found for the given date range.")
 *             yield None             # <<<<<<<<<<<<<<
 * 
 *         # Group intervals by day
*/
    __Pyx_INCREF(Py_None);
    __pyx_r = Py_None;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from async generator, yielding value */
    __pyx_generator->resume_label = 1;
    return __Pyx__PyAsyncGenValueWrapperNew(__pyx_r);
    __pyx_L7_resume_from_yield:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3849, __pyx_L1_error)

    /* "ws_package/controllers/activity_controller.py":3847
 *         force_stop_time: Optional[datetime.datetime] = None,
 *     ):
 *         if intervals is None or len(intervals) == 0:             # <<<<<<<<<<<<<<
 *             logger.info("No intervals found for the given date range.")
 *             yield None
*/
  }

  /* "ws_package/controllers/activity_controller.py":3852
 * 
 *         # Group intervals by day
 *         grouped_intervals = self.group_intervals_by_day(intervals)             # <<<<<<<<<<<<<<
 * 
 *         # Process each day separately
*/
  __pyx_t_7 = __pyx_cur_scope->__pyx_v_self;
  __Pyx_INCREF(__pyx_t_7);
  __pyx_t_8 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_cur_scope->__pyx_v_intervals};
    __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_group_intervals_by_day, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 3852, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  }
  __Pyx_GIVEREF(__pyx_t_4);
  __pyx_cur_scope->__pyx_v_grouped_intervals = __pyx_t_4;
  __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":3855
 * 
 *         # Process each day separately
 *         for target_date, day_intervals in grouped_intervals.items():             # <<<<<<<<<<<<<<
 *             # Edge case: Ensure the intervals array contains at most 100 objects per day
 *             if len(day_intervals) > 100:
*/
  __pyx_t_3 = 0;
  if (unlikely(__pyx_cur_scope->__pyx_v_grouped_intervals == Py_None)) {
    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items");
    __PYX_ERR(0, 3855, __pyx_L1_error)
  }
  __pyx_t_7 = __Pyx_dict_iterator(__pyx_cur_scope->__pyx_v_grouped_intervals, 0, __pyx_mstate_global->__pyx_n_u_items, (&__pyx_t_9), (&__pyx_t_10)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3855, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_4);
  __pyx_t_4 = __pyx_t_7;
  __pyx_t_7 = 0;
  while (1) {
    __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_4, __pyx_t_9, &__pyx_t_3, &__pyx_t_7, &__pyx_t_5, NULL, __pyx_t_10);
    if (unlikely(__pyx_t_11 == 0)) break;
    if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 3855, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_target_date);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_target_date, __pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_7);
    __pyx_t_7 = 0;
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_day_intervals);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_day_intervals, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;

    /* "ws_package/controllers/activity_controller.py":3857
 *         for target_date, day_intervals in grouped_intervals.items():
 *             # Edge case: Ensure the intervals array contains at most 100 objects per day
 *             if len(day_intervals) > 100:             # <<<<<<<<<<<<<<
 *                 day_intervals = day_intervals[:100]
 *             logger.info("Target date of intervals %s", target_date)
*/
    __pyx_t_12 = PyObject_Length(__pyx_cur_scope->__pyx_v_day_intervals); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3857, __pyx_L1_error)
    __pyx_t_1 = (__pyx_t_12 > 0x64);
    if (__pyx_t_1) {

      /* "ws_package/controllers/activity_controller.py":3858
 *             # Edge case: Ensure the intervals array contains at most 100 objects per day
 *             if len(day_intervals) > 100:
 *                 day_intervals = day_intervals[:100]             # <<<<<<<<<<<<<<
 *             logger.info("Target date of intervals %s", target_date)
 *             # Get the appropriate start time for this day
*/
      __pyx_t_5 = __Pyx_PyObject_GetSlice(__pyx_cur_scope->__pyx_v_day_intervals, 0, 0x64, NULL, NULL, &__pyx_mstate_global->__pyx_slice[2], 0, 1, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3858, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_day_intervals);
      __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_day_intervals, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_5 = 0;

      /* "ws_package/controllers/activity_controller.py":3857
 *         for target_date, day_intervals in grouped_intervals.items():
 *             # Edge case: Ensure the intervals array contains at most 100 objects per day
 *             if len(day_intervals) > 100:             # <<<<<<<<<<<<<<
 *                 day_intervals = day_intervals[:100]
 *             logger.info("Target date of intervals %s", target_date)
*/
    }

    /* "ws_package/controllers/activity_controller.py":3859
 *             if len(day_intervals) > 100:
 *                 day_intervals = day_intervals[:100]
 *             logger.info("Target date of intervals %s", target_date)             # <<<<<<<<<<<<<<
 *             # Get the appropriate start time for this day
 *             day_start_time = self.get_day_start_time(target_date, day_intervals)
*/
    __pyx_t_7 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3859, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3859, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_8 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_13))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_13);
      assert(__pyx_t_7);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
      __pyx_t_8 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[3] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Target_date_of_intervals_s, __pyx_cur_scope->__pyx_v_target_date};
      __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3859, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "ws_package/controllers/activity_controller.py":3861
 *             logger.info("Target date of intervals %s", target_date)
 *             # Get the appropriate start time for this day
 *             day_start_time = self.get_day_start_time(target_date, day_intervals)             # <<<<<<<<<<<<<<
 *             # When project/task was changed on running timer, use current segment start (now) for today's payload
 *             effective_start_time = day_start_time
*/
    __pyx_t_13 = __pyx_cur_scope->__pyx_v_self;
    __Pyx_INCREF(__pyx_t_13);
    __pyx_t_8 = 0;
    {
      PyObject *__pyx_callargs[3] = {__pyx_t_13, __pyx_cur_scope->__pyx_v_target_date, __pyx_cur_scope->__pyx_v_day_intervals};
      __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_day_start_time, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3861, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_day_start_time);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_day_start_time, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;

    /* "ws_package/controllers/activity_controller.py":3863
 *             day_start_time = self.get_day_start_time(target_date, day_intervals)
 *             # When project/task was changed on running timer, use current segment start (now) for today's payload
 *             effective_start_time = day_start_time             # <<<<<<<<<<<<<<
 *             pinned_start = self._get_pinned_activity_log_session_start(target_date)
 *             if pinned_start is not None:
*/
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_day_start_time);
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_effective_start_time);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_effective_start_time, __pyx_cur_scope->__pyx_v_day_start_time);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_day_start_time);

    /* "ws_package/controllers/activity_controller.py":3864
 *             # When project/task was changed on running timer, use current segment start (now) for today's payload
 *             effective_start_time = day_start_time
 *             pinned_start = self._get_pinned_activity_log_session_start(target_date)             # <<<<<<<<<<<<<<
 *             if pinned_start is not None:
 *                 effective_start_time = pinned_start
*/
    __pyx_t_13 = __pyx_cur_scope->__pyx_v_self;
    __Pyx_INCREF(__pyx_t_13);
    __pyx_t_8 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_cur_scope->__pyx_v_target_date};
      __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_pinned_activity_log_session, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3864, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_pinned_start);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_pinned_start, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;

    /* "ws_package/controllers/activity_controller.py":3865
 *             effective_start_time = day_start_time
 *             pinned_start = self._get_pinned_activity_log_session_start(target_date)
 *             if pinned_start is not None:             # <<<<<<<<<<<<<<
 *                 effective_start_time = pinned_start
 *                 logger.info("Using pinned activity/log session start: %s", effective_start_time)
*/
    __pyx_t_1 = (__pyx_cur_scope->__pyx_v_pinned_start != Py_None);
    if (__pyx_t_1) {

      /* "ws_package/controllers/activity_controller.py":3866
 *             pinned_start = self._get_pinned_activity_log_session_start(target_date)
 *             if pinned_start is not None:
 *                 effective_start_time = pinned_start             # <<<<<<<<<<<<<<
 *                 logger.info("Using pinned activity/log session start: %s", effective_start_time)
 *             elif target_date == datetime.datetime.now().date() and self.current_segment_start_time is not None:
*/
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_pinned_start);
      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_effective_start_time);
      __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_effective_start_time, __pyx_cur_scope->__pyx_v_pinned_start);
      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_pinned_start);

      /* "ws_package/controllers/activity_controller.py":3867
 *             if pinned_start is not None:
 *                 effective_start_time = pinned_start
 *                 logger.info("Using pinned activity/log session start: %s", effective_start_time)             # <<<<<<<<<<<<<<
 *             elif target_date == datetime.datetime.now().date() and self.current_segment_start_time is not None:
 *                 effective_start_time = self.current_segment_start_time
*/
      __pyx_t_13 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3867, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3867, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_6);
        assert(__pyx_t_13);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_13);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Using_pinned_activity_log_sessio, __pyx_cur_scope->__pyx_v_effective_start_time};
        __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3867, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "ws_package/controllers/activity_controller.py":3865
 *             effective_start_time = day_start_time
 *             pinned_start = self._get_pinned_activity_log_session_start(target_date)
 *             if pinned_start is not None:             # <<<<<<<<<<<<<<
 *                 effective_start_time = pinned_start
 *                 logger.info("Using pinned activity/log session start: %s", effective_start_time)
*/
      goto __pyx_L11;
    }

    /* "ws_package/controllers/activity_controller.py":3868
 *                 effective_start_time = pinned_start
 *                 logger.info("Using pinned activity/log session start: %s", effective_start_time)
 *             elif target_date == datetime.datetime.now().date() and self.current_segment_start_time is not None:             # <<<<<<<<<<<<<<
 *                 effective_start_time = self.current_segment_start_time
 *                 logger.info("Using segment start (project/task changed on running timer): %s", effective_start_time)
*/
    __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3868, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3868, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
    __pyx_t_7 = __pyx_t_15;
    __Pyx_INCREF(__pyx_t_7);
    __pyx_t_8 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
      __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
      if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3868, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
    }
    __pyx_t_6 = __pyx_t_13;
    __Pyx_INCREF(__pyx_t_6);
    __pyx_t_8 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
      __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_date, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3868, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    __pyx_t_13 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_target_date, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3868, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3868, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    if (__pyx_t_2) {
    } else {
      __pyx_t_1 = __pyx_t_2;
      goto __pyx_L12_bool_binop_done;
    }
    __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_segment_start_time); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3868, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_2 = (__pyx_t_13 != Py_None);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_1 = __pyx_t_2;
    __pyx_L12_bool_binop_done:;
    if (__pyx_t_1) {

      /* "ws_package/controllers/activity_controller.py":3869
 *                 logger.info("Using pinned activity/log session start: %s", effective_start_time)
 *             elif target_date == datetime.datetime.now().date() and self.current_segment_start_time is not None:
 *                 effective_start_time = self.current_segment_start_time             # <<<<<<<<<<<<<<
 *                 logger.info("Using segment start (project/task changed on running timer): %s", effective_start_time)
 *             effective_start_time = self._normalize_activity_log_start(effective_start_time)
*/
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_segment_start_time); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3869, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_effective_start_time);
      __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_effective_start_time, __pyx_t_13);
      __Pyx_GIVEREF(__pyx_t_13);
      __pyx_t_13 = 0;

      /* "ws_package/controllers/activity_controller.py":3870
 *             elif target_date == datetime.datetime.now().date() and self.current_segment_start_time is not None:
 *                 effective_start_time = self.current_segment_start_time
 *                 logger.info("Using segment start (project/task changed on running timer): %s", effective_start_time)             # <<<<<<<<<<<<<<
 *             effective_start_time = self._normalize_activity_log_start(effective_start_time)
 * 
*/
      __pyx_t_5 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3870, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3870, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_15))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_15);
        assert(__pyx_t_5);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Using_segment_start_project_task, __pyx_cur_scope->__pyx_v_effective_start_time};
        __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3870, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
      }
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

      /* "ws_package/controllers/activity_controller.py":3868
 *                 effective_start_time = pinned_start
 *                 logger.info("Using pinned activity/log session start: %s", effective_start_time)
 *             elif target_date == datetime.datetime.now().date() and self.current_segment_start_time is not None:             # <<<<<<<<<<<<<<
 *                 effective_start_time = self.current_segment_start_time
 *                 logger.info("Using segment start (project/task changed on running timer): %s", effective_start_time)
*/
    }
    __pyx_L11:;

    /* "ws_package/controllers/activity_controller.py":3871
 *                 effective_start_time = self.current_segment_start_time
 *                 logger.info("Using segment start (project/task changed on running timer): %s", effective_start_time)
 *             effective_start_time = self._normalize_activity_log_start(effective_start_time)             # <<<<<<<<<<<<<<
 * 
 *             # CRITICAL: Filter out intervals that completely end before effective_start_time.
*/
    __pyx_t_15 = __pyx_cur_scope->__pyx_v_self;
    __Pyx_INCREF(__pyx_t_15);
    __pyx_t_8 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_cur_scope->__pyx_v_effective_start_time};
      __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_normalize_activity_log_start, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3871, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
    }
    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_effective_start_time);
    __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_effective_start_time, __pyx_t_13);
    __Pyx_GIVEREF(__pyx_t_13);
    __pyx_t_13 = 0;

    /* "ws_package/controllers/activity_controller.py":3880
 *             # This ensures intervals that start at or overlap with effective_start_time are included
 *             # (e.g., break ends at 10:02, interval created 10:02-10:10 should be included)
 *             if day_intervals:             # <<<<<<<<<<<<<<
 *                 filtered_intervals = []
 *                 filtered_count = 0
*/
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_day_intervals); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 3880, __pyx_L1_error)
    if (__pyx_t_1) {

      /* "ws_package/controllers/activity_controller.py":3881
 *             # (e.g., break ends at 10:02, interval created 10:02-10:10 should be included)
 *             if day_intervals:
 *                 filtered_intervals = []             # <<<<<<<<<<<<<<
 *                 filtered_count = 0
 *                 for interval in day_intervals:
*/
      __pyx_t_13 = PyList_New(0); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3881, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_filtered_intervals);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_filtered_intervals, ((PyObject*)__pyx_t_13));
      __Pyx_GIVEREF(__pyx_t_13);
      __pyx_t_13 = 0;

      /* "ws_package/controllers/activity_controller.py":3882
 *             if day_intervals:
 *                 filtered_intervals = []
 *                 filtered_count = 0             # <<<<<<<<<<<<<<
 *                 for interval in day_intervals:
 *                     # Only filter if interval completely ends before effective_start_time
*/
      __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_filtered_count);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_filtered_count, __pyx_mstate_global->__pyx_int_0);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_0);

      /* "ws_package/controllers/activity_controller.py":3883
 *                 filtered_intervals = []
 *                 filtered_count = 0
 *                 for interval in day_intervals:             # <<<<<<<<<<<<<<
 *                     # Only filter if interval completely ends before effective_start_time
 *                     if hasattr(interval, 'start_time') and hasattr(interval, 'end_time') and interval.end_time < effective_start_time:
*/
      if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_day_intervals)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_day_intervals)) {
        __pyx_t_13 = __pyx_cur_scope->__pyx_v_day_intervals; __Pyx_INCREF(__pyx_t_13);
        __pyx_t_12 = 0;
        __pyx_t_16 = NULL;
      } else {
        __pyx_t_12 = -1; __pyx_t_13 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_day_intervals); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3883, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_16 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_13); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3883, __pyx_L1_error)
      }
      for (;;) {
        if (likely(!__pyx_t_16)) {
          if (likely(PyList_CheckExact(__pyx_t_13))) {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_13);
              #if !CYTHON_ASSUME_SAFE_SIZE
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3883, __pyx_L1_error)
              #endif
              if (__pyx_t_12 >= __pyx_temp) break;
            }
            __pyx_t_15 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_13, __pyx_t_12, __Pyx_ReferenceSharing_OwnStrongReference);
            ++__pyx_t_12;
          } else {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_13);
              #if !CYTHON_ASSUME_SAFE_SIZE
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3883, __pyx_L1_error)
              #endif
              if (__pyx_t_12 >= __pyx_temp) break;
            }
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_15 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_13, __pyx_t_12));
            #else
            __pyx_t_15 = __Pyx_PySequence_ITEM(__pyx_t_13, __pyx_t_12);
            #endif
            ++__pyx_t_12;
          }
          if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3883, __pyx_L1_error)
        } else {
          __pyx_t_15 = __pyx_t_16(__pyx_t_13);
          if (unlikely(!__pyx_t_15)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 3883, __pyx_L1_error)
              PyErr_Clear();
            }
            break;
          }
        }
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_15);
        __Pyx_GIVEREF(__pyx_t_15);
        __pyx_t_15 = 0;

        /* "ws_package/controllers/activity_controller.py":3885
 *                 for interval in day_intervals:
 *                     # Only filter if interval completely ends before effective_start_time
 *                     if hasattr(interval, 'start_time') and hasattr(interval, 'end_time') and interval.end_time < effective_start_time:             # <<<<<<<<<<<<<<
 *                         filtered_count += 1
 *                         logger.debug("Filtering out interval (start=%s, end=%s) - completely ends before payload start time (%s)", interval.start_time, interval.end_time, effective_start_time)
*/
        __pyx_t_2 = __Pyx_HasAttr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 3885, __pyx_L1_error)
        if (__pyx_t_2) {
        } else {
          __pyx_t_1 = __pyx_t_2;
          goto __pyx_L18_bool_binop_done;
        }
        __pyx_t_2 = __Pyx_HasAttr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 3885, __pyx_L1_error)
        if (__pyx_t_2) {
        } else {
          __pyx_t_1 = __pyx_t_2;
          goto __pyx_L18_bool_binop_done;
        }
        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3885, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_5 = PyObject_RichCompare(__pyx_t_15, __pyx_cur_scope->__pyx_v_effective_start_time, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3885, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3885, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_1 = __pyx_t_2;
        __pyx_L18_bool_binop_done:;
        if (__pyx_t_1) {

          /* "ws_package/controllers/activity_controller.py":3886
 *                     # Only filter if interval completely ends before effective_start_time
 *                     if hasattr(interval, 'start_time') and hasattr(interval, 'end_time') and interval.end_time < effective_start_time:
 *                         filtered_count += 1             # <<<<<<<<<<<<<<
 *                         logger.debug("Filtering out interval (start=%s, end=%s) - completely ends before payload start time (%s)", interval.start_time, interval.end_time, effective_start_time)
 *                     else:
*/
          __pyx_t_5 = __Pyx_PyLong_AddObjC(__pyx_cur_scope->__pyx_v_filtered_count, __pyx_mstate_global->__pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3886, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_filtered_count);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_filtered_count, __pyx_t_5);
          __Pyx_GIVEREF(__pyx_t_5);
          __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":3887
 *                     if hasattr(interval, 'start_time') and hasattr(interval, 'end_time') and interval.end_time < effective_start_time:
 *                         filtered_count += 1
 *                         logger.debug("Filtering out interval (start=%s, end=%s) - completely ends before payload start time (%s)", interval.start_time, interval.end_time, effective_start_time)             # <<<<<<<<<<<<<<
 *                     else:
 *                         filtered_intervals.append(interval)
*/
          __pyx_t_15 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3887, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3887, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3887, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3887, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_7))) {
            __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_7);
            assert(__pyx_t_15);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
            __Pyx_INCREF(__pyx_t_15);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[5] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Filtering_out_interval_start_s_e, __pyx_t_6, __pyx_t_14, __pyx_cur_scope->__pyx_v_effective_start_time};
            __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3887, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_5);
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":3885
 *                 for interval in day_intervals:
 *                     # Only filter if interval completely ends before effective_start_time
 *                     if hasattr(interval, 'start_time') and hasattr(interval, 'end_time') and interval.end_time < effective_start_time:             # <<<<<<<<<<<<<<
 *                         filtered_count += 1
 *                         logger.debug("Filtering out interval (start=%s, end=%s) - completely ends before payload start time (%s)", interval.start_time, interval.end_time, effective_start_time)
*/
          goto __pyx_L17;
        }

        /* "ws_package/controllers/activity_controller.py":3889
 *                         logger.debug("Filtering out interval (start=%s, end=%s) - completely ends before payload start time (%s)", interval.start_time, interval.end_time, effective_start_time)
 *                     else:
 *                         filtered_intervals.append(interval)             # <<<<<<<<<<<<<<
 * 
 *                 if filtered_count > 0:
*/
        /*else*/ {
          __pyx_t_17 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_filtered_intervals, __pyx_cur_scope->__pyx_v_interval); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 3889, __pyx_L1_error)
        }
        __pyx_L17:;

        /* "ws_package/controllers/activity_controller.py":3883
 *                 filtered_intervals = []
 *                 filtered_count = 0
 *                 for interval in day_intervals:             # <<<<<<<<<<<<<<
 *                     # Only filter if interval completely ends before effective_start_time
 *                     if hasattr(interval, 'start_time') and hasattr(interval, 'end_time') and interval.end_time < effective_start_time:
*/
      }
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

      /* "ws_package/controllers/activity_controller.py":3891
 *                         filtered_intervals.append(interval)
 * 
 *                 if filtered_count > 0:             # <<<<<<<<<<<<<<
 *                     logger.info("Filtered out %s interval(s) that completely end before effective_start_time (%s)", filtered_count, effective_start_time)
 *                     day_intervals = filtered_intervals
*/
      __pyx_t_13 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_filtered_count, __pyx_mstate_global->__pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3891, __pyx_L1_error)
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 3891, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (__pyx_t_1) {

        /* "ws_package/controllers/activity_controller.py":3892
 * 
 *                 if filtered_count > 0:
 *                     logger.info("Filtered out %s interval(s) that completely end before effective_start_time (%s)", filtered_count, effective_start_time)             # <<<<<<<<<<<<<<
 *                     day_intervals = filtered_intervals
 * 
*/
        __pyx_t_5 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3892, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3892, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_14))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_14);
          assert(__pyx_t_5);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[4] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Filtered_out_s_interval_s_that_c, __pyx_cur_scope->__pyx_v_filtered_count, __pyx_cur_scope->__pyx_v_effective_start_time};
          __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3892, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
        }
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

        /* "ws_package/controllers/activity_controller.py":3893
 *                 if filtered_count > 0:
 *                     logger.info("Filtered out %s interval(s) that completely end before effective_start_time (%s)", filtered_count, effective_start_time)
 *                     day_intervals = filtered_intervals             # <<<<<<<<<<<<<<
 * 
 *                 if not day_intervals:
*/
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_filtered_intervals);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_day_intervals);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_day_intervals, __pyx_cur_scope->__pyx_v_filtered_intervals);
        __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_filtered_intervals);

        /* "ws_package/controllers/activity_controller.py":3891
 *                         filtered_intervals.append(interval)
 * 
 *                 if filtered_count > 0:             # <<<<<<<<<<<<<<
 *                     logger.info("Filtered out %s interval(s) that completely end before effective_start_time (%s)", filtered_count, effective_start_time)
 *                     day_intervals = filtered_intervals
*/
      }

      /* "ws_package/controllers/activity_controller.py":3895
 *                     day_intervals = filtered_intervals
 * 
 *                 if not day_intervals:             # <<<<<<<<<<<<<<
 *                     logger.info("No intervals remain after filtering - skipping this day")
 *                     continue
*/
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_day_intervals); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 3895, __pyx_L1_error)
      __pyx_t_2 = (!__pyx_t_1);
      if (__pyx_t_2) {

        /* "ws_package/controllers/activity_controller.py":3896
 * 
 *                 if not day_intervals:
 *                     logger.info("No intervals remain after filtering - skipping this day")             # <<<<<<<<<<<<<<
 *                     continue
 * 
*/
        __pyx_t_14 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3896, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3896, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_7);
          assert(__pyx_t_14);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_14);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_14, __pyx_mstate_global->__pyx_kp_u_No_intervals_remain_after_filter};
          __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3896, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
        }
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

        /* "ws_package/controllers/activity_controller.py":3897
 *                 if not day_intervals:
 *                     logger.info("No intervals remain after filtering - skipping this day")
 *                     continue             # <<<<<<<<<<<<<<
 * 
 *             # Prepare the list of interval payloads for this day
*/
        goto __pyx_L8_continue;

        /* "ws_package/controllers/activity_controller.py":3895
 *                     day_intervals = filtered_intervals
 * 
 *                 if not day_intervals:             # <<<<<<<<<<<<<<
 *                     logger.info("No intervals remain after filtering - skipping this day")
 *                     continue
*/
      }

      /* "ws_package/controllers/activity_controller.py":3880
 *             # This ensures intervals that start at or overlap with effective_start_time are included
 *             # (e.g., break ends at 10:02, interval created 10:02-10:10 should be included)
 *             if day_intervals:             # <<<<<<<<<<<<<<
 *                 filtered_intervals = []
 *                 filtered_count = 0
*/
    }

    /* "ws_package/controllers/activity_controller.py":3900
 * 
 *             # Prepare the list of interval payloads for this day
 *             interval_payloads = []             # <<<<<<<<<<<<<<
 * 
 *             # Fetch notes for all intervals in this day from Notes table
*/
    __pyx_t_13 = PyList_New(0); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3900, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval_payloads);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval_payloads, ((PyObject*)__pyx_t_13));
    __Pyx_GIVEREF(__pyx_t_13);
    __pyx_t_13 = 0;

    /* "ws_package/controllers/activity_controller.py":3903
 * 
 *             # Fetch notes for all intervals in this day from Notes table
 *             interval_ids = [interval.id for interval in day_intervals if hasattr(interval, 'id')]             # <<<<<<<<<<<<<<
 *             interval_note_map = {}
 *             interval_file_map = {}
*/
    { /* enter inner scope */
      __pyx_t_13 = PyList_New(0); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3903, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_day_intervals)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_day_intervals)) {
        __pyx_t_7 = __pyx_cur_scope->__pyx_v_day_intervals; __Pyx_INCREF(__pyx_t_7);
        __pyx_t_12 = 0;
        __pyx_t_16 = NULL;
      } else {
        __pyx_t_12 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_day_intervals); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3903, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_16 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_7); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3903, __pyx_L1_error)
      }
      for (;;) {
        if (likely(!__pyx_t_16)) {
          if (likely(PyList_CheckExact(__pyx_t_7))) {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_7);
              #if !CYTHON_ASSUME_SAFE_SIZE
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3903, __pyx_L1_error)
              #endif
              if (__pyx_t_12 >= __pyx_temp) break;
            }
            __pyx_t_14 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_7, __pyx_t_12, __Pyx_ReferenceSharing_OwnStrongReference);
            ++__pyx_t_12;
          } else {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_7);
              #if !CYTHON_ASSUME_SAFE_SIZE
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3903, __pyx_L1_error)
              #endif
              if (__pyx_t_12 >= __pyx_temp) break;
            }
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_14 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_12));
            #else
            __pyx_t_14 = __Pyx_PySequence_ITEM(__pyx_t_7, __pyx_t_12);
            #endif
            ++__pyx_t_12;
          }
          if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3903, __pyx_L1_error)
        } else {
          __pyx_t_14 = __pyx_t_16(__pyx_t_7);
          if (unlikely(!__pyx_t_14)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 3903, __pyx_L1_error)
              PyErr_Clear();
            }
            break;
          }
        }
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_9genexpr15__pyx_v_interval);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_9genexpr15__pyx_v_interval, __pyx_t_14);
        __Pyx_GIVEREF(__pyx_t_14);
        __pyx_t_14 = 0;
        __pyx_t_2 = __Pyx_HasAttr(__pyx_cur_scope->__pyx_9genexpr15__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 3903, __pyx_L1_error)
        if (__pyx_t_2) {
          __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_9genexpr15__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3903, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
          if (unlikely(__Pyx_ListComp_Append(__pyx_t_13, (PyObject*)__pyx_t_14))) __PYX_ERR(0, 3903, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    } /* exit inner scope */
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval_ids);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval_ids, ((PyObject*)__pyx_t_13));
    __Pyx_GIVEREF(__pyx_t_13);
    __pyx_t_13 = 0;

    /* "ws_package/controllers/activity_controller.py":3904
 *             # Fetch notes for all intervals in this day from Notes table
 *             interval_ids = [interval.id for interval in day_intervals if hasattr(interval, 'id')]
 *             interval_note_map = {}             # <<<<<<<<<<<<<<
 *             interval_file_map = {}
 * 
*/
    __pyx_t_13 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3904, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval_note_map);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval_note_map, ((PyObject*)__pyx_t_13));
    __Pyx_GIVEREF(__pyx_t_13);
    __pyx_t_13 = 0;

    /* "ws_package/controllers/activity_controller.py":3905
 *             interval_ids = [interval.id for interval in day_intervals if hasattr(interval, 'id')]
 *             interval_note_map = {}
 *             interval_file_map = {}             # <<<<<<<<<<<<<<
 * 
 *             # Query Notes table for entries that contain any of these interval IDs
*/
    __pyx_t_13 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3905, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval_file_map);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval_file_map, ((PyObject*)__pyx_t_13));
    __Pyx_GIVEREF(__pyx_t_13);
    __pyx_t_13 = 0;

    /* "ws_package/controllers/activity_controller.py":3909
 *             # Query Notes table for entries that contain any of these interval IDs
 *             # Notes.activity_interval_id is a JSON array, so we need to check if any interval_id is in the array
 *             try:             # <<<<<<<<<<<<<<
 *                 with db_lock_manager.read_lock():
 *                     async with async_session() as session:
*/
    {
      __Pyx_ExceptionSave(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20);
      __Pyx_XGOTREF(__pyx_t_18);
      __Pyx_XGOTREF(__pyx_t_19);
      __Pyx_XGOTREF(__pyx_t_20);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":3910
 *             # Notes.activity_interval_id is a JSON array, so we need to check if any interval_id is in the array
 *             try:
 *                 with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                     async with async_session() as session:
 *                         notes_query = select(Notes)
*/
        /*with:*/ {
          __pyx_t_7 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3910, __pyx_L28_error)
          __Pyx_GOTREF(__pyx_t_14);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3910, __pyx_L28_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_5))) {
            __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
            assert(__pyx_t_7);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_7);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
            __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3910, __pyx_L28_error)
            __Pyx_GOTREF(__pyx_t_13);
          }
          __pyx_t_21 = __Pyx_PyObject_LookupSpecial(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 3910, __pyx_L28_error)
          __Pyx_GOTREF(__pyx_t_21);
          __pyx_t_7 = NULL;
          __pyx_t_14 = __Pyx_PyObject_LookupSpecial(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3910, __pyx_L36_error)
          __Pyx_GOTREF(__pyx_t_14);
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (likely(PyMethod_Check(__pyx_t_14))) {
            __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_14);
            assert(__pyx_t_7);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
            __Pyx_INCREF(__pyx_t_7);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
            __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3910, __pyx_L36_error)
            __Pyx_GOTREF(__pyx_t_5);
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          /*try:*/ {
            {
              __Pyx_ExceptionSave(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
              __Pyx_XGOTREF(__pyx_t_22);
              __Pyx_XGOTREF(__pyx_t_23);
              __Pyx_XGOTREF(__pyx_t_24);
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":3911
 *             try:
 *                 with db_lock_manager.read_lock():
 *                     async with async_session() as session:             # <<<<<<<<<<<<<<
 *                         notes_query = select(Notes)
 *                         notes_result = await session.execute(notes_query)
*/
                /*with:*/ {
                  __pyx_t_5 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3911, __pyx_L42_error)
                  __Pyx_GOTREF(__pyx_t_14);
                  __pyx_t_8 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_14))) {
                    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_14);
                    assert(__pyx_t_5);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
                    __Pyx_INCREF(__pyx_t_5);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
                    __pyx_t_8 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                    __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                    if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3911, __pyx_L42_error)
                    __Pyx_GOTREF(__pyx_t_13);
                  }
                  __pyx_t_25 = __Pyx_PyObject_LookupSpecial(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3911, __pyx_L42_error)
                  __Pyx_GOTREF(__pyx_t_25);
                  __pyx_t_5 = NULL;
                  __pyx_t_7 = __Pyx_PyObject_LookupSpecial(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3911, __pyx_L50_error)
                  __Pyx_GOTREF(__pyx_t_7);
                  __pyx_t_8 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (likely(PyMethod_Check(__pyx_t_7))) {
                    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
                    assert(__pyx_t_5);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                    __Pyx_INCREF(__pyx_t_5);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                    __pyx_t_8 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                    __pyx_t_14 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                    if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3911, __pyx_L50_error)
                    __Pyx_GOTREF(__pyx_t_14);
                  }
                  __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_14, &__pyx_r);
                  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                  if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                    __Pyx_GOTREF(__pyx_r);
                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
                    __Pyx_XGIVEREF(__pyx_t_4);
                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                    __Pyx_XGIVEREF(__pyx_t_13);
                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_18;
                    __Pyx_XGIVEREF(__pyx_t_19);
                    __pyx_cur_scope->__pyx_t_6 = __pyx_t_19;
                    __Pyx_XGIVEREF(__pyx_t_20);
                    __pyx_cur_scope->__pyx_t_7 = __pyx_t_20;
                    __Pyx_XGIVEREF(__pyx_t_21);
                    __pyx_cur_scope->__pyx_t_8 = __pyx_t_21;
                    __Pyx_XGIVEREF(__pyx_t_22);
                    __pyx_cur_scope->__pyx_t_9 = __pyx_t_22;
                    __Pyx_XGIVEREF(__pyx_t_23);
                    __pyx_cur_scope->__pyx_t_10 = __pyx_t_23;
                    __Pyx_XGIVEREF(__pyx_t_24);
                    __pyx_cur_scope->__pyx_t_11 = __pyx_t_24;
                    __Pyx_XGIVEREF(__pyx_t_25);
                    __pyx_cur_scope->__pyx_t_12 = __pyx_t_25;
                    __Pyx_XGIVEREF(__pyx_r);
                    __Pyx_RefNannyFinishContext();
                    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                    /* return from async generator, awaiting value */
                    __pyx_generator->resume_label = 2;
                    return __pyx_r;
                    __pyx_L51_resume_from_await:;
                    __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
                    __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
                    __pyx_cur_scope->__pyx_t_1 = 0;
                    __Pyx_XGOTREF(__pyx_t_4);
                    __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
                    __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                    __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                    __pyx_cur_scope->__pyx_t_4 = 0;
                    __Pyx_XGOTREF(__pyx_t_13);
                    __pyx_t_18 = __pyx_cur_scope->__pyx_t_5;
                    __pyx_cur_scope->__pyx_t_5 = 0;
                    __Pyx_XGOTREF(__pyx_t_18);
                    __pyx_t_19 = __pyx_cur_scope->__pyx_t_6;
                    __pyx_cur_scope->__pyx_t_6 = 0;
                    __Pyx_XGOTREF(__pyx_t_19);
                    __pyx_t_20 = __pyx_cur_scope->__pyx_t_7;
                    __pyx_cur_scope->__pyx_t_7 = 0;
                    __Pyx_XGOTREF(__pyx_t_20);
                    __pyx_t_21 = __pyx_cur_scope->__pyx_t_8;
                    __pyx_cur_scope->__pyx_t_8 = 0;
                    __Pyx_XGOTREF(__pyx_t_21);
                    __pyx_t_22 = __pyx_cur_scope->__pyx_t_9;
                    __pyx_cur_scope->__pyx_t_9 = 0;
                    __Pyx_XGOTREF(__pyx_t_22);
                    __pyx_t_23 = __pyx_cur_scope->__pyx_t_10;
                    __pyx_cur_scope->__pyx_t_10 = 0;
                    __Pyx_XGOTREF(__pyx_t_23);
                    __pyx_t_24 = __pyx_cur_scope->__pyx_t_11;
                    __pyx_cur_scope->__pyx_t_11 = 0;
                    __Pyx_XGOTREF(__pyx_t_24);
                    __pyx_t_25 = __pyx_cur_scope->__pyx_t_12;
                    __pyx_cur_scope->__pyx_t_12 = 0;
                    __Pyx_XGOTREF(__pyx_t_25);
                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3911, __pyx_L50_error)
                    __pyx_t_14 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_14);
                  } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                    __Pyx_GOTREF(__pyx_r);
                    __pyx_t_14 = __pyx_r; __pyx_r = NULL;
                  } else {
                    __Pyx_XGOTREF(__pyx_r);
                    __PYX_ERR(0, 3911, __pyx_L50_error)
                  }
                  __pyx_t_7 = __pyx_t_14;
                  __pyx_t_14 = 0;
                  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                  /*try:*/ {
                    {
                      __Pyx_ExceptionSave(&__pyx_t_27, &__pyx_t_28, &__pyx_t_29);
                      __Pyx_XGOTREF(__pyx_t_27);
                      __Pyx_XGOTREF(__pyx_t_28);
                      __Pyx_XGOTREF(__pyx_t_29);
                      /*try:*/ {
                        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_session);
                        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_session, __pyx_t_7);
                        __Pyx_GIVEREF(__pyx_t_7);
                        __pyx_t_7 = 0;

                        /* "ws_package/controllers/activity_controller.py":3912
 *                 with db_lock_manager.read_lock():
 *                     async with async_session() as session:
 *                         notes_query = select(Notes)             # <<<<<<<<<<<<<<
 *                         notes_result = await session.execute(notes_query)
 *                         notes_entries = notes_result.scalars().all()
*/
                        __pyx_t_13 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3912, __pyx_L57_error)
                        __Pyx_GOTREF(__pyx_t_14);
                        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_Notes); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3912, __pyx_L57_error)
                        __Pyx_GOTREF(__pyx_t_5);
                        __pyx_t_8 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_14))) {
                          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_14);
                          assert(__pyx_t_13);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
                          __Pyx_INCREF(__pyx_t_13);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
                          __pyx_t_8 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_t_5};
                          __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3912, __pyx_L57_error)
                          __Pyx_GOTREF(__pyx_t_7);
                        }
                        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_notes_query);
                        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_notes_query, __pyx_t_7);
                        __Pyx_GIVEREF(__pyx_t_7);
                        __pyx_t_7 = 0;

                        /* "ws_package/controllers/activity_controller.py":3913
 *                     async with async_session() as session:
 *                         notes_query = select(Notes)
 *                         notes_result = await session.execute(notes_query)             # <<<<<<<<<<<<<<
 *                         notes_entries = notes_result.scalars().all()
 * 
*/
                        __pyx_t_14 = __pyx_cur_scope->__pyx_v_session;
                        __Pyx_INCREF(__pyx_t_14);
                        __pyx_t_8 = 0;
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_14, __pyx_cur_scope->__pyx_v_notes_query};
                          __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3913, __pyx_L57_error)
                          __Pyx_GOTREF(__pyx_t_7);
                        }
                        __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7, &__pyx_r);
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                        if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                          __Pyx_GOTREF(__pyx_r);
                          __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
                          __Pyx_XGIVEREF(__pyx_t_4);
                          __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
                          __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
                          __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                          __Pyx_XGIVEREF(__pyx_t_18);
                          __pyx_cur_scope->__pyx_t_4 = __pyx_t_18;
                          __Pyx_XGIVEREF(__pyx_t_19);
                          __pyx_cur_scope->__pyx_t_5 = __pyx_t_19;
                          __Pyx_XGIVEREF(__pyx_t_20);
                          __pyx_cur_scope->__pyx_t_6 = __pyx_t_20;
                          __Pyx_XGIVEREF(__pyx_t_21);
                          __pyx_cur_scope->__pyx_t_7 = __pyx_t_21;
                          __Pyx_XGIVEREF(__pyx_t_22);
                          __pyx_cur_scope->__pyx_t_8 = __pyx_t_22;
                          __Pyx_XGIVEREF(__pyx_t_23);
                          __pyx_cur_scope->__pyx_t_9 = __pyx_t_23;
                          __Pyx_XGIVEREF(__pyx_t_24);
                          __pyx_cur_scope->__pyx_t_10 = __pyx_t_24;
                          __Pyx_XGIVEREF(__pyx_t_25);
                          __pyx_cur_scope->__pyx_t_11 = __pyx_t_25;
                          __Pyx_XGIVEREF(__pyx_t_27);
                          __pyx_cur_scope->__pyx_t_12 = __pyx_t_27;
                          __Pyx_XGIVEREF(__pyx_t_28);
                          __pyx_cur_scope->__pyx_t_13 = __pyx_t_28;
                          __Pyx_XGIVEREF(__pyx_t_29);
                          __pyx_cur_scope->__pyx_t_14 = __pyx_t_29;
                          __Pyx_XGIVEREF(__pyx_r);
                          __Pyx_RefNannyFinishContext();
                          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                          /* return from async generator, awaiting value */
                          __pyx_generator->resume_label = 3;
                          return __pyx_r;
                          __pyx_L65_resume_from_await:;
                          __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
                          __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
                          __pyx_cur_scope->__pyx_t_1 = 0;
                          __Pyx_XGOTREF(__pyx_t_4);
                          __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
                          __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                          __pyx_t_18 = __pyx_cur_scope->__pyx_t_4;
                          __pyx_cur_scope->__pyx_t_4 = 0;
                          __Pyx_XGOTREF(__pyx_t_18);
                          __pyx_t_19 = __pyx_cur_scope->__pyx_t_5;
                          __pyx_cur_scope->__pyx_t_5 = 0;
                          __Pyx_XGOTREF(__pyx_t_19);
                          __pyx_t_20 = __pyx_cur_scope->__pyx_t_6;
                          __pyx_cur_scope->__pyx_t_6 = 0;
                          __Pyx_XGOTREF(__pyx_t_20);
                          __pyx_t_21 = __pyx_cur_scope->__pyx_t_7;
                          __pyx_cur_scope->__pyx_t_7 = 0;
                          __Pyx_XGOTREF(__pyx_t_21);
                          __pyx_t_22 = __pyx_cur_scope->__pyx_t_8;
                          __pyx_cur_scope->__pyx_t_8 = 0;
                          __Pyx_XGOTREF(__pyx_t_22);
                          __pyx_t_23 = __pyx_cur_scope->__pyx_t_9;
                          __pyx_cur_scope->__pyx_t_9 = 0;
                          __Pyx_XGOTREF(__pyx_t_23);
                          __pyx_t_24 = __pyx_cur_scope->__pyx_t_10;
                          __pyx_cur_scope->__pyx_t_10 = 0;
                          __Pyx_XGOTREF(__pyx_t_24);
                          __pyx_t_25 = __pyx_cur_scope->__pyx_t_11;
                          __pyx_cur_scope->__pyx_t_11 = 0;
                          __Pyx_XGOTREF(__pyx_t_25);
                          __pyx_t_27 = __pyx_cur_scope->__pyx_t_12;
                          __pyx_cur_scope->__pyx_t_12 = 0;
                          __Pyx_XGOTREF(__pyx_t_27);
                          __pyx_t_28 = __pyx_cur_scope->__pyx_t_13;
                          __pyx_cur_scope->__pyx_t_13 = 0;
                          __Pyx_XGOTREF(__pyx_t_28);
                          __pyx_t_29 = __pyx_cur_scope->__pyx_t_14;
                          __pyx_cur_scope->__pyx_t_14 = 0;
                          __Pyx_XGOTREF(__pyx_t_29);
                          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3913, __pyx_L57_error)
                          __pyx_t_7 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_7);
                        } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                          __Pyx_GOTREF(__pyx_r);
                          __pyx_t_7 = __pyx_r; __pyx_r = NULL;
                        } else {
                          __Pyx_XGOTREF(__pyx_r);
                          __PYX_ERR(0, 3913, __pyx_L57_error)
                        }
                        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_notes_result);
                        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_notes_result, __pyx_t_7);
                        __Pyx_GIVEREF(__pyx_t_7);
                        __pyx_t_7 = 0;

                        /* "ws_package/controllers/activity_controller.py":3914
 *                         notes_query = select(Notes)
 *                         notes_result = await session.execute(notes_query)
 *                         notes_entries = notes_result.scalars().all()             # <<<<<<<<<<<<<<
 * 
 *                         # Create a mapping of interval_id -> note and file_path
*/
                        __pyx_t_13 = __pyx_cur_scope->__pyx_v_notes_result;
                        __Pyx_INCREF(__pyx_t_13);
                        __pyx_t_8 = 0;
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_13, NULL};
                          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalars, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3914, __pyx_L57_error)
                          __Pyx_GOTREF(__pyx_t_5);
                        }
                        __pyx_t_14 = __pyx_t_5;
                        __Pyx_INCREF(__pyx_t_14);
                        __pyx_t_8 = 0;
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_14, NULL};
                          __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_all, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3914, __pyx_L57_error)
                          __Pyx_GOTREF(__pyx_t_7);
                        }
                        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_notes_entries);
                        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_notes_entries, __pyx_t_7);
                        __Pyx_GIVEREF(__pyx_t_7);
                        __pyx_t_7 = 0;

                        /* "ws_package/controllers/activity_controller.py":3917
 * 
 *                         # Create a mapping of interval_id -> note and file_path
 *                         for notes_entry in notes_entries:             # <<<<<<<<<<<<<<
 *                             if notes_entry.activity_interval_id:  # Check if array is not None
 *                                 for interval_id in notes_entry.activity_interval_id:
*/
                        if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_notes_entries)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_notes_entries)) {
                          __pyx_t_7 = __pyx_cur_scope->__pyx_v_notes_entries; __Pyx_INCREF(__pyx_t_7);
                          __pyx_t_12 = 0;
                          __pyx_t_16 = NULL;
                        } else {
                          __pyx_t_12 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_notes_entries); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3917, __pyx_L57_error)
                          __Pyx_GOTREF(__pyx_t_7);
                          __pyx_t_16 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_7); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3917, __pyx_L57_error)
                        }
                        for (;;) {
                          if (likely(!__pyx_t_16)) {
                            if (likely(PyList_CheckExact(__pyx_t_7))) {
                              {
                                Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_7);
                                #if !CYTHON_ASSUME_SAFE_SIZE
                                if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3917, __pyx_L57_error)
                                #endif
                                if (__pyx_t_12 >= __pyx_temp) break;
                              }
                              __pyx_t_5 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_7, __pyx_t_12, __Pyx_ReferenceSharing_OwnStrongReference);
                              ++__pyx_t_12;
                            } else {
                              {
                                Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_7);
                                #if !CYTHON_ASSUME_SAFE_SIZE
                                if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3917, __pyx_L57_error)
                                #endif
                                if (__pyx_t_12 >= __pyx_temp) break;
                              }
                              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                              __pyx_t_5 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_12));
                              #else
                              __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_7, __pyx_t_12);
                              #endif
                              ++__pyx_t_12;
                            }
                            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3917, __pyx_L57_error)
                          } else {
                            __pyx_t_5 = __pyx_t_16(__pyx_t_7);
                            if (unlikely(!__pyx_t_5)) {
                              PyObject* exc_type = PyErr_Occurred();
                              if (exc_type) {
                                if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 3917, __pyx_L57_error)
                                PyErr_Clear();
                              }
                              break;
                            }
                          }
                          __Pyx_GOTREF(__pyx_t_5);
                          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_notes_entry);
                          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_notes_entry, __pyx_t_5);
                          __Pyx_GIVEREF(__pyx_t_5);
                          __pyx_t_5 = 0;

                          /* "ws_package/controllers/activity_controller.py":3918
 *                         # Create a mapping of interval_id -> note and file_path
 *                         for notes_entry in notes_entries:
 *                             if notes_entry.activity_interval_id:  # Check if array is not None             # <<<<<<<<<<<<<<
 *                                 for interval_id in notes_entry.activity_interval_id:
 *                                     if interval_id in interval_ids:
*/
                          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_notes_entry, __pyx_mstate_global->__pyx_n_u_activity_interval_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3918, __pyx_L57_error)
                          __Pyx_GOTREF(__pyx_t_5);
                          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3918, __pyx_L57_error)
                          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                          if (__pyx_t_2) {

                            /* "ws_package/controllers/activity_controller.py":3919
 *                         for notes_entry in notes_entries:
 *                             if notes_entry.activity_interval_id:  # Check if array is not None
 *                                 for interval_id in notes_entry.activity_interval_id:             # <<<<<<<<<<<<<<
 *                                     if interval_id in interval_ids:
 *                                         interval_note_map[interval_id] = notes_entry.note
*/
                            __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_notes_entry, __pyx_mstate_global->__pyx_n_u_activity_interval_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3919, __pyx_L57_error)
                            __Pyx_GOTREF(__pyx_t_5);
                            if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) {
                              __pyx_t_14 = __pyx_t_5; __Pyx_INCREF(__pyx_t_14);
                              __pyx_t_30 = 0;
                              __pyx_t_31 = NULL;
                            } else {
                              __pyx_t_30 = -1; __pyx_t_14 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3919, __pyx_L57_error)
                              __Pyx_GOTREF(__pyx_t_14);
                              __pyx_t_31 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_14); if (unlikely(!__pyx_t_31)) __PYX_ERR(0, 3919, __pyx_L57_error)
                            }
                            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                            for (;;) {
                              if (likely(!__pyx_t_31)) {
                                if (likely(PyList_CheckExact(__pyx_t_14))) {
                                  {
                                    Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_14);
                                    #if !CYTHON_ASSUME_SAFE_SIZE
                                    if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3919, __pyx_L57_error)
                                    #endif
                                    if (__pyx_t_30 >= __pyx_temp) break;
                                  }
                                  __pyx_t_5 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_14, __pyx_t_30, __Pyx_ReferenceSharing_OwnStrongReference);
                                  ++__pyx_t_30;
                                } else {
                                  {
                                    Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_14);
                                    #if !CYTHON_ASSUME_SAFE_SIZE
                                    if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3919, __pyx_L57_error)
                                    #endif
                                    if (__pyx_t_30 >= __pyx_temp) break;
                                  }
                                  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                                  __pyx_t_5 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_14, __pyx_t_30));
                                  #else
                                  __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_14, __pyx_t_30);
                                  #endif
                                  ++__pyx_t_30;
                                }
                                if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3919, __pyx_L57_error)
                              } else {
                                __pyx_t_5 = __pyx_t_31(__pyx_t_14);
                                if (unlikely(!__pyx_t_5)) {
                                  PyObject* exc_type = PyErr_Occurred();
                                  if (exc_type) {
                                    if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 3919, __pyx_L57_error)
                                    PyErr_Clear();
                                  }
                                  break;
                                }
                              }
                              __Pyx_GOTREF(__pyx_t_5);
                              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval_id);
                              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval_id, __pyx_t_5);
                              __Pyx_GIVEREF(__pyx_t_5);
                              __pyx_t_5 = 0;

                              /* "ws_package/controllers/activity_controller.py":3920
 *                             if notes_entry.activity_interval_id:  # Check if array is not None
 *                                 for interval_id in notes_entry.activity_interval_id:
 *                                     if interval_id in interval_ids:             # <<<<<<<<<<<<<<
 *                                         interval_note_map[interval_id] = notes_entry.note
 *                                         if hasattr(notes_entry, 'file_path') and notes_entry.file_path:
*/
                              __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_cur_scope->__pyx_v_interval_id, __pyx_cur_scope->__pyx_v_interval_ids, Py_EQ)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3920, __pyx_L57_error)
                              if (__pyx_t_2) {

                                /* "ws_package/controllers/activity_controller.py":3921
 *                                 for interval_id in notes_entry.activity_interval_id:
 *                                     if interval_id in interval_ids:
 *                                         interval_note_map[interval_id] = notes_entry.note             # <<<<<<<<<<<<<<
 *                                         if hasattr(notes_entry, 'file_path') and notes_entry.file_path:
 *                                             interval_file_map[interval_id] = notes_entry.file_path
*/
                                __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_notes_entry, __pyx_mstate_global->__pyx_n_u_note); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3921, __pyx_L57_error)
                                __Pyx_GOTREF(__pyx_t_5);
                                if (unlikely((PyDict_SetItem(__pyx_cur_scope->__pyx_v_interval_note_map, __pyx_cur_scope->__pyx_v_interval_id, __pyx_t_5) < 0))) __PYX_ERR(0, 3921, __pyx_L57_error)
                                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                                /* "ws_package/controllers/activity_controller.py":3922
 *                                     if interval_id in interval_ids:
 *                                         interval_note_map[interval_id] = notes_entry.note
 *                                         if hasattr(notes_entry, 'file_path') and notes_entry.file_path:             # <<<<<<<<<<<<<<
 *                                             interval_file_map[interval_id] = notes_entry.file_path
 * 
*/
                                __pyx_t_1 = __Pyx_HasAttr(__pyx_cur_scope->__pyx_v_notes_entry, __pyx_mstate_global->__pyx_n_u_file_path); if (unlikely(__pyx_t_1 == ((int)-1))) __PYX_ERR(0, 3922, __pyx_L57_error)
                                if (__pyx_t_1) {
                                } else {
                                  __pyx_t_2 = __pyx_t_1;
                                  goto __pyx_L73_bool_binop_done;
                                }
                                __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_notes_entry, __pyx_mstate_global->__pyx_n_u_file_path); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3922, __pyx_L57_error)
                                __Pyx_GOTREF(__pyx_t_5);
                                __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 3922, __pyx_L57_error)
                                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                                __pyx_t_2 = __pyx_t_1;
                                __pyx_L73_bool_binop_done:;
                                if (__pyx_t_2) {

                                  /* "ws_package/controllers/activity_controller.py":3923
 *                                         interval_note_map[interval_id] = notes_entry.note
 *                                         if hasattr(notes_entry, 'file_path') and notes_entry.file_path:
 *                                             interval_file_map[interval_id] = notes_entry.file_path             # <<<<<<<<<<<<<<
 * 
 *                         if interval_note_map:
*/
                                  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_notes_entry, __pyx_mstate_global->__pyx_n_u_file_path); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3923, __pyx_L57_error)
                                  __Pyx_GOTREF(__pyx_t_5);
                                  if (unlikely((PyDict_SetItem(__pyx_cur_scope->__pyx_v_interval_file_map, __pyx_cur_scope->__pyx_v_interval_id, __pyx_t_5) < 0))) __PYX_ERR(0, 3923, __pyx_L57_error)
                                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                                  /* "ws_package/controllers/activity_controller.py":3922
 *                                     if interval_id in interval_ids:
 *                                         interval_note_map[interval_id] = notes_entry.note
 *                                         if hasattr(notes_entry, 'file_path') and notes_entry.file_path:             # <<<<<<<<<<<<<<
 *                                             interval_file_map[interval_id] = notes_entry.file_path
 * 
*/
                                }

                                /* "ws_package/controllers/activity_controller.py":3920
 *                             if notes_entry.activity_interval_id:  # Check if array is not None
 *                                 for interval_id in notes_entry.activity_interval_id:
 *                                     if interval_id in interval_ids:             # <<<<<<<<<<<<<<
 *                                         interval_note_map[interval_id] = notes_entry.note
 *                                         if hasattr(notes_entry, 'file_path') and notes_entry.file_path:
*/
                              }

                              /* "ws_package/controllers/activity_controller.py":3919
 *                         for notes_entry in notes_entries:
 *                             if notes_entry.activity_interval_id:  # Check if array is not None
 *                                 for interval_id in notes_entry.activity_interval_id:             # <<<<<<<<<<<<<<
 *                                     if interval_id in interval_ids:
 *                                         interval_note_map[interval_id] = notes_entry.note
*/
                            }
                            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

                            /* "ws_package/controllers/activity_controller.py":3918
 *                         # Create a mapping of interval_id -> note and file_path
 *                         for notes_entry in notes_entries:
 *                             if notes_entry.activity_interval_id:  # Check if array is not None             # <<<<<<<<<<<<<<
 *                                 for interval_id in notes_entry.activity_interval_id:
 *                                     if interval_id in interval_ids:
*/
                          }

                          /* "ws_package/controllers/activity_controller.py":3917
 * 
 *                         # Create a mapping of interval_id -> note and file_path
 *                         for notes_entry in notes_entries:             # <<<<<<<<<<<<<<
 *                             if notes_entry.activity_interval_id:  # Check if array is not None
 *                                 for interval_id in notes_entry.activity_interval_id:
*/
                        }
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

                        /* "ws_package/controllers/activity_controller.py":3925
 *                                             interval_file_map[interval_id] = notes_entry.file_path
 * 
 *                         if interval_note_map:             # <<<<<<<<<<<<<<
 *                             logger.info("Found notes for %s intervals", len(interval_note_map))
 *             except Exception as e:
*/
                        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_interval_note_map); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3925, __pyx_L57_error)
                        if (__pyx_t_2) {

                          /* "ws_package/controllers/activity_controller.py":3926
 * 
 *                         if interval_note_map:
 *                             logger.info("Found notes for %s intervals", len(interval_note_map))             # <<<<<<<<<<<<<<
 *             except Exception as e:
 *                 logger.error("Error fetching notes from Notes table: %s", e, exc_info=True)
*/
                          __pyx_t_14 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3926, __pyx_L57_error)
                          __Pyx_GOTREF(__pyx_t_5);
                          __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3926, __pyx_L57_error)
                          __Pyx_GOTREF(__pyx_t_13);
                          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                          __pyx_t_12 = PyDict_Size(__pyx_cur_scope->__pyx_v_interval_note_map); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 3926, __pyx_L57_error)
                          __pyx_t_5 = PyLong_FromSsize_t(__pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3926, __pyx_L57_error)
                          __Pyx_GOTREF(__pyx_t_5);
                          __pyx_t_8 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_13))) {
                            __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_13);
                            assert(__pyx_t_14);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
                            __Pyx_INCREF(__pyx_t_14);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
                            __pyx_t_8 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[3] = {__pyx_t_14, __pyx_mstate_global->__pyx_kp_u_Found_notes_for_s_intervals, __pyx_t_5};
                            __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                            if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3926, __pyx_L57_error)
                            __Pyx_GOTREF(__pyx_t_7);
                          }
                          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

                          /* "ws_package/controllers/activity_controller.py":3925
 *                                             interval_file_map[interval_id] = notes_entry.file_path
 * 
 *                         if interval_note_map:             # <<<<<<<<<<<<<<
 *                             logger.info("Found notes for %s intervals", len(interval_note_map))
 *             except Exception as e:
*/
                        }

                        /* "ws_package/controllers/activity_controller.py":3911
 *             try:
 *                 with db_lock_manager.read_lock():
 *                     async with async_session() as session:             # <<<<<<<<<<<<<<
 *                         notes_query = select(Notes)
 *                         notes_result = await session.execute(notes_query)
*/
                      }
                      __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                      __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
                      __Pyx_XDECREF(__pyx_t_29); __pyx_t_29 = 0;
                      goto __pyx_L64_try_end;
                      __pyx_L57_error:;
                      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                      /*except:*/ {
                        __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.process_intervals_bulk", __pyx_clineno, __pyx_lineno, __pyx_filename);
                        if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_13, &__pyx_t_5) < 0) __PYX_ERR(0, 3911, __pyx_L59_except_error)
                        __Pyx_XGOTREF(__pyx_t_7);
                        __Pyx_XGOTREF(__pyx_t_13);
                        __Pyx_XGOTREF(__pyx_t_5);
                        __pyx_t_14 = PyTuple_Pack(3, __pyx_t_7, __pyx_t_13, __pyx_t_5); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3911, __pyx_L59_except_error)
                        __Pyx_GOTREF(__pyx_t_14);
                        __pyx_t_32 = __Pyx_PyObject_Call(__pyx_t_25, __pyx_t_14, NULL);
                        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                        if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 3911, __pyx_L59_except_error)
                        __Pyx_GOTREF(__pyx_t_32);
                        __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_32, &__pyx_r);
                        __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0;
                        if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                          __Pyx_GOTREF(__pyx_r);
                          __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
                          __Pyx_XGIVEREF(__pyx_t_4);
                          __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
                          __Pyx_XGIVEREF(__pyx_t_5);
                          __pyx_cur_scope->__pyx_t_4 = __pyx_t_5;
                          __Pyx_XGIVEREF(__pyx_t_7);
                          __pyx_cur_scope->__pyx_t_5 = __pyx_t_7;
                          __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
                          __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                          __Pyx_XGIVEREF(__pyx_t_13);
                          __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                          __Pyx_XGIVEREF(__pyx_t_18);
                          __pyx_cur_scope->__pyx_t_7 = __pyx_t_18;
                          __Pyx_XGIVEREF(__pyx_t_19);
                          __pyx_cur_scope->__pyx_t_8 = __pyx_t_19;
                          __Pyx_XGIVEREF(__pyx_t_20);
                          __pyx_cur_scope->__pyx_t_9 = __pyx_t_20;
                          __Pyx_XGIVEREF(__pyx_t_21);
                          __pyx_cur_scope->__pyx_t_10 = __pyx_t_21;
                          __Pyx_XGIVEREF(__pyx_t_22);
                          __pyx_cur_scope->__pyx_t_11 = __pyx_t_22;
                          __Pyx_XGIVEREF(__pyx_t_23);
                          __pyx_cur_scope->__pyx_t_12 = __pyx_t_23;
                          __Pyx_XGIVEREF(__pyx_t_24);
                          __pyx_cur_scope->__pyx_t_13 = __pyx_t_24;
                          __Pyx_XGIVEREF(__pyx_t_25);
                          __pyx_cur_scope->__pyx_t_14 = __pyx_t_25;
                          __Pyx_XGIVEREF(__pyx_t_27);
                          __pyx_cur_scope->__pyx_t_15 = __pyx_t_27;
                          __Pyx_XGIVEREF(__pyx_t_28);
                          __pyx_cur_scope->__pyx_t_16 = __pyx_t_28;
                          __Pyx_XGIVEREF(__pyx_t_29);
                          __pyx_cur_scope->__pyx_t_17 = __pyx_t_29;
                          __Pyx_XGIVEREF(__pyx_t_32);
                          __pyx_cur_scope->__pyx_t_18 = __pyx_t_32;
                          __Pyx_XGIVEREF(__pyx_r);
                          __Pyx_RefNannyFinishContext();
                          __Pyx_Coroutine_SwapException(__pyx_generator);
                          /* return from async generator, awaiting value */
                          __pyx_generator->resume_label = 4;
                          return __pyx_r;
                          __pyx_L81_resume_from_await:;
                          __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
                          __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
                          __pyx_cur_scope->__pyx_t_1 = 0;
                          __Pyx_XGOTREF(__pyx_t_4);
                          __pyx_t_5 = __pyx_cur_scope->__pyx_t_4;
                          __pyx_cur_scope->__pyx_t_4 = 0;
                          __Pyx_XGOTREF(__pyx_t_5);
                          __pyx_t_7 = __pyx_cur_scope->__pyx_t_5;
                          __pyx_cur_scope->__pyx_t_5 = 0;
                          __Pyx_XGOTREF(__pyx_t_7);
                          __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
                          __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                          __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                          __pyx_cur_scope->__pyx_t_6 = 0;
                          __Pyx_XGOTREF(__pyx_t_13);
                          __pyx_t_18 = __pyx_cur_scope->__pyx_t_7;
                          __pyx_cur_scope->__pyx_t_7 = 0;
                          __Pyx_XGOTREF(__pyx_t_18);
                          __pyx_t_19 = __pyx_cur_scope->__pyx_t_8;
                          __pyx_cur_scope->__pyx_t_8 = 0;
                          __Pyx_XGOTREF(__pyx_t_19);
                          __pyx_t_20 = __pyx_cur_scope->__pyx_t_9;
                          __pyx_cur_scope->__pyx_t_9 = 0;
                          __Pyx_XGOTREF(__pyx_t_20);
                          __pyx_t_21 = __pyx_cur_scope->__pyx_t_10;
                          __pyx_cur_scope->__pyx_t_10 = 0;
                          __Pyx_XGOTREF(__pyx_t_21);
                          __pyx_t_22 = __pyx_cur_scope->__pyx_t_11;
                          __pyx_cur_scope->__pyx_t_11 = 0;
                          __Pyx_XGOTREF(__pyx_t_22);
                          __pyx_t_23 = __pyx_cur_scope->__pyx_t_12;
                          __pyx_cur_scope->__pyx_t_12 = 0;
                          __Pyx_XGOTREF(__pyx_t_23);
                          __pyx_t_24 = __pyx_cur_scope->__pyx_t_13;
                          __pyx_cur_scope->__pyx_t_13 = 0;
                          __Pyx_XGOTREF(__pyx_t_24);
                          __pyx_t_25 = __pyx_cur_scope->__pyx_t_14;
                          __pyx_cur_scope->__pyx_t_14 = 0;
                          __Pyx_XGOTREF(__pyx_t_25);
                          __pyx_t_27 = __pyx_cur_scope->__pyx_t_15;
                          __pyx_cur_scope->__pyx_t_15 = 0;
                          __Pyx_XGOTREF(__pyx_t_27);
                          __pyx_t_28 = __pyx_cur_scope->__pyx_t_16;
                          __pyx_cur_scope->__pyx_t_16 = 0;
                          __Pyx_XGOTREF(__pyx_t_28);
                          __pyx_t_29 = __pyx_cur_scope->__pyx_t_17;
                          __pyx_cur_scope->__pyx_t_17 = 0;
                          __Pyx_XGOTREF(__pyx_t_29);
                          __pyx_t_32 = __pyx_cur_scope->__pyx_t_18;
                          __pyx_cur_scope->__pyx_t_18 = 0;
                          __Pyx_XGOTREF(__pyx_t_32);
                          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3911, __pyx_L59_except_error)
                          __pyx_t_14 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_14);
                        } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                          __Pyx_GOTREF(__pyx_r);
                          __pyx_t_14 = __pyx_r; __pyx_r = NULL;
                        } else {
                          __Pyx_XGOTREF(__pyx_r);
                          __PYX_ERR(0, 3911, __pyx_L59_except_error)
                        }
                        __pyx_t_32 = __pyx_t_14;
                        __pyx_t_14 = 0;
                        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_32);
                        __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0;
                        if (__pyx_t_2 < (0)) __PYX_ERR(0, 3911, __pyx_L59_except_error)
                        __pyx_t_1 = (!__pyx_t_2);
                        if (unlikely(__pyx_t_1)) {
                          __Pyx_GIVEREF(__pyx_t_7);
                          __Pyx_GIVEREF(__pyx_t_13);
                          __Pyx_XGIVEREF(__pyx_t_5);
                          __Pyx_ErrRestoreWithState(__pyx_t_7, __pyx_t_13, __pyx_t_5);
                          __pyx_t_7 = 0;  __pyx_t_13 = 0;  __pyx_t_5 = 0; 
                          __PYX_ERR(0, 3911, __pyx_L59_except_error)
                        }
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                        goto __pyx_L58_exception_handled;
                      }
                      __pyx_L59_except_error:;
                      __Pyx_XGIVEREF(__pyx_t_27);
                      __Pyx_XGIVEREF(__pyx_t_28);
                      __Pyx_XGIVEREF(__pyx_t_29);
                      __Pyx_ExceptionReset(__pyx_t_27, __pyx_t_28, __pyx_t_29);
                      goto __pyx_L42_error;
                      __pyx_L58_exception_handled:;
                      __Pyx_XGIVEREF(__pyx_t_27);
                      __Pyx_XGIVEREF(__pyx_t_28);
                      __Pyx_XGIVEREF(__pyx_t_29);
                      __Pyx_ExceptionReset(__pyx_t_27, __pyx_t_28, __pyx_t_29);
                      __pyx_L64_try_end:;
                    }
                  }
                  /*finally:*/ {
                    /*normal exit:*/{
                      if (__pyx_t_25) {
                        __pyx_t_29 = __Pyx_PyObject_Call(__pyx_t_25, __pyx_mstate_global->__pyx_tuple[7], NULL);
                        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                        if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 3911, __pyx_L42_error)
                        __Pyx_GOTREF(__pyx_t_29);
                        __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_29, &__pyx_r);
                        __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
                        if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                          __Pyx_GOTREF(__pyx_r);
                          __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
                          __Pyx_XGIVEREF(__pyx_t_4);
                          __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
                          __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
                          __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                          __Pyx_XGIVEREF(__pyx_t_18);
                          __pyx_cur_scope->__pyx_t_4 = __pyx_t_18;
                          __Pyx_XGIVEREF(__pyx_t_19);
                          __pyx_cur_scope->__pyx_t_5 = __pyx_t_19;
                          __Pyx_XGIVEREF(__pyx_t_20);
                          __pyx_cur_scope->__pyx_t_6 = __pyx_t_20;
                          __Pyx_XGIVEREF(__pyx_t_21);
                          __pyx_cur_scope->__pyx_t_7 = __pyx_t_21;
                          __Pyx_XGIVEREF(__pyx_t_22);
                          __pyx_cur_scope->__pyx_t_8 = __pyx_t_22;
                          __Pyx_XGIVEREF(__pyx_t_23);
                          __pyx_cur_scope->__pyx_t_9 = __pyx_t_23;
                          __Pyx_XGIVEREF(__pyx_t_24);
                          __pyx_cur_scope->__pyx_t_10 = __pyx_t_24;
                          __Pyx_XGIVEREF(__pyx_t_25);
                          __pyx_cur_scope->__pyx_t_11 = __pyx_t_25;
                          __Pyx_XGIVEREF(__pyx_t_29);
                          __pyx_cur_scope->__pyx_t_12 = __pyx_t_29;
                          __Pyx_XGIVEREF(__pyx_r);
                          __Pyx_RefNannyFinishContext();
                          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                          /* return from async generator, awaiting value */
                          __pyx_generator->resume_label = 5;
                          return __pyx_r;
                          __pyx_L82_resume_from_await:;
                          __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
                          __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
                          __pyx_cur_scope->__pyx_t_1 = 0;
                          __Pyx_XGOTREF(__pyx_t_4);
                          __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
                          __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                          __pyx_t_18 = __pyx_cur_scope->__pyx_t_4;
                          __pyx_cur_scope->__pyx_t_4 = 0;
                          __Pyx_XGOTREF(__pyx_t_18);
                          __pyx_t_19 = __pyx_cur_scope->__pyx_t_5;
                          __pyx_cur_scope->__pyx_t_5 = 0;
                          __Pyx_XGOTREF(__pyx_t_19);
                          __pyx_t_20 = __pyx_cur_scope->__pyx_t_6;
                          __pyx_cur_scope->__pyx_t_6 = 0;
                          __Pyx_XGOTREF(__pyx_t_20);
                          __pyx_t_21 = __pyx_cur_scope->__pyx_t_7;
                          __pyx_cur_scope->__pyx_t_7 = 0;
                          __Pyx_XGOTREF(__pyx_t_21);
                          __pyx_t_22 = __pyx_cur_scope->__pyx_t_8;
                          __pyx_cur_scope->__pyx_t_8 = 0;
                          __Pyx_XGOTREF(__pyx_t_22);
                          __pyx_t_23 = __pyx_cur_scope->__pyx_t_9;
                          __pyx_cur_scope->__pyx_t_9 = 0;
                          __Pyx_XGOTREF(__pyx_t_23);
                          __pyx_t_24 = __pyx_cur_scope->__pyx_t_10;
                          __pyx_cur_scope->__pyx_t_10 = 0;
                          __Pyx_XGOTREF(__pyx_t_24);
                          __pyx_t_25 = __pyx_cur_scope->__pyx_t_11;
                          __pyx_cur_scope->__pyx_t_11 = 0;
                          __Pyx_XGOTREF(__pyx_t_25);
                          __pyx_t_29 = __pyx_cur_scope->__pyx_t_12;
                          __pyx_cur_scope->__pyx_t_12 = 0;
                          __Pyx_XGOTREF(__pyx_t_29);
                          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3911, __pyx_L42_error)
                          __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
                        } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                          __Pyx_GOTREF(__pyx_r);
                          __pyx_t_5 = __pyx_r; __pyx_r = NULL;
                        } else {
                          __Pyx_XGOTREF(__pyx_r);
                          __PYX_ERR(0, 3911, __pyx_L42_error)
                        }
                        __pyx_t_29 = __pyx_t_5;
                        __pyx_t_5 = 0;
                        __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
                      }
                      goto __pyx_L56;
                    }
                    __pyx_L56:;
                  }
                  goto __pyx_L83;
                  __pyx_L50_error:;
                  __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                  goto __pyx_L42_error;
                  __pyx_L83:;
                }

                /* "ws_package/controllers/activity_controller.py":3910
 *             # Notes.activity_interval_id is a JSON array, so we need to check if any interval_id is in the array
 *             try:
 *                 with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                     async with async_session() as session:
 *                         notes_query = select(Notes)
*/
              }
              __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
              goto __pyx_L49_try_end;
              __pyx_L42_error:;
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
              /*except:*/ {
                __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.process_intervals_bulk", __pyx_clineno, __pyx_lineno, __pyx_filename);
                if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_13, &__pyx_t_7) < 0) __PYX_ERR(0, 3910, __pyx_L44_except_error)
                __Pyx_XGOTREF(__pyx_t_5);
                __Pyx_XGOTREF(__pyx_t_13);
                __Pyx_XGOTREF(__pyx_t_7);
                __pyx_t_14 = PyTuple_Pack(3, __pyx_t_5, __pyx_t_13, __pyx_t_7); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3910, __pyx_L44_except_error)
                __Pyx_GOTREF(__pyx_t_14);
                __pyx_t_25 = __Pyx_PyObject_Call(__pyx_t_21, __pyx_t_14, NULL);
                __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 3910, __pyx_L44_except_error)
                __Pyx_GOTREF(__pyx_t_25);
                __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_25);
                __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                if (__pyx_t_1 < (0)) __PYX_ERR(0, 3910, __pyx_L44_except_error)
                __pyx_t_2 = (!__pyx_t_1);
                if (unlikely(__pyx_t_2)) {
                  __Pyx_GIVEREF(__pyx_t_5);
                  __Pyx_GIVEREF(__pyx_t_13);
                  __Pyx_XGIVEREF(__pyx_t_7);
                  __Pyx_ErrRestoreWithState(__pyx_t_5, __pyx_t_13, __pyx_t_7);
                  __pyx_t_5 = 0;  __pyx_t_13 = 0;  __pyx_t_7 = 0; 
                  __PYX_ERR(0, 3910, __pyx_L44_except_error)
                }
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                goto __pyx_L43_exception_handled;
              }
              __pyx_L44_except_error:;
              __Pyx_XGIVEREF(__pyx_t_22);
              __Pyx_XGIVEREF(__pyx_t_23);
              __Pyx_XGIVEREF(__pyx_t_24);
              __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_23, __pyx_t_24);
              goto __pyx_L28_error;
              __pyx_L43_exception_handled:;
              __Pyx_XGIVEREF(__pyx_t_22);
              __Pyx_XGIVEREF(__pyx_t_23);
              __Pyx_XGIVEREF(__pyx_t_24);
              __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_23, __pyx_t_24);
              __pyx_L49_try_end:;
            }
          }
          /*finally:*/ {
            /*normal exit:*/{
              if (__pyx_t_21) {
                __pyx_t_24 = __Pyx_PyObject_Call(__pyx_t_21, __pyx_mstate_global->__pyx_tuple[7], NULL);
                __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 3910, __pyx_L28_error)
                __Pyx_GOTREF(__pyx_t_24);
                __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
              }
              goto __pyx_L41;
            }
            __pyx_L41:;
          }
          goto __pyx_L87;
          __pyx_L36_error:;
          __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
          goto __pyx_L28_error;
          __pyx_L87:;
        }

        /* "ws_package/controllers/activity_controller.py":3909
 *             # Query Notes table for entries that contain any of these interval IDs
 *             # Notes.activity_interval_id is a JSON array, so we need to check if any interval_id is in the array
 *             try:             # <<<<<<<<<<<<<<
 *                 with db_lock_manager.read_lock():
 *                     async with async_session() as session:
*/
      }
      __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
      __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
      __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
      goto __pyx_L35_try_end;
      __pyx_L28_error:;
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "ws_package/controllers/activity_controller.py":3927
 *                         if interval_note_map:
 *                             logger.info("Found notes for %s intervals", len(interval_note_map))
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 logger.error("Error fetching notes from Notes table: %s", e, exc_info=True)
 *                 # Continue without notes if there's an error
*/
      __pyx_t_11 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
      if (__pyx_t_11) {
        __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.process_intervals_bulk", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_13, &__pyx_t_5) < 0) __PYX_ERR(0, 3927, __pyx_L30_except_error)
        __Pyx_XGOTREF(__pyx_t_7);
        __Pyx_XGOTREF(__pyx_t_13);
        __Pyx_XGOTREF(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_13);
        __Pyx_GIVEREF(__pyx_t_13);
        __pyx_cur_scope->__pyx_v_e = __pyx_t_13;
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":3928
 *                             logger.info("Found notes for %s intervals", len(interval_note_map))
 *             except Exception as e:
 *                 logger.error("Error fetching notes from Notes table: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 *                 # Continue without notes if there's an error
 * 
*/
          __pyx_t_6 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3928, __pyx_L93_error)
          __Pyx_GOTREF(__pyx_t_15);
          __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 3928, __pyx_L93_error)
          __Pyx_GOTREF(__pyx_t_33);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_33))) {
            __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_33);
            assert(__pyx_t_6);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
            __Pyx_INCREF(__pyx_t_6);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Error_fetching_notes_from_Notes, __pyx_cur_scope->__pyx_v_e};
            __pyx_t_15 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3928, __pyx_L93_error)
            __Pyx_GOTREF(__pyx_t_15);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_15, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 3928, __pyx_L93_error)
            __pyx_t_14 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_15);
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
            if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3928, __pyx_L93_error)
            __Pyx_GOTREF(__pyx_t_14);
          }
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        }

        /* "ws_package/controllers/activity_controller.py":3927
 *                         if interval_note_map:
 *                             logger.info("Found notes for %s intervals", len(interval_note_map))
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 logger.error("Error fetching notes from Notes table: %s", e, exc_info=True)
 *                 # Continue without notes if there's an error
*/
        /*finally:*/ {
          /*normal exit:*/{
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
            goto __pyx_L94;
          }
          __pyx_L93_error:;
          /*exception exit:*/{
            __Pyx_PyThreadState_assign
            __pyx_t_21 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_25 = 0; __pyx_t_29 = 0;
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
             __Pyx_ExceptionSwap(&__pyx_t_22, &__pyx_t_25, &__pyx_t_29);
            if ( unlikely(__Pyx_GetException(&__pyx_t_21, &__pyx_t_24, &__pyx_t_23) < 0)) __Pyx_ErrFetch(&__pyx_t_21, &__pyx_t_24, &__pyx_t_23);
            __Pyx_XGOTREF(__pyx_t_21);
            __Pyx_XGOTREF(__pyx_t_24);
            __Pyx_XGOTREF(__pyx_t_23);
            __Pyx_XGOTREF(__pyx_t_22);
            __Pyx_XGOTREF(__pyx_t_25);
            __Pyx_XGOTREF(__pyx_t_29);
            __pyx_t_11 = __pyx_lineno; __pyx_t_34 = __pyx_clineno; __pyx_t_35 = __pyx_filename;
            {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
            }
            __Pyx_XGIVEREF(__pyx_t_22);
            __Pyx_XGIVEREF(__pyx_t_25);
            __Pyx_XGIVEREF(__pyx_t_29);
            __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_25, __pyx_t_29);
            __Pyx_XGIVEREF(__pyx_t_21);
            __Pyx_XGIVEREF(__pyx_t_24);
            __Pyx_XGIVEREF(__pyx_t_23);
            __Pyx_ErrRestore(__pyx_t_21, __pyx_t_24, __pyx_t_23);
            __pyx_t_21 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_25 = 0; __pyx_t_29 = 0;
            __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_34; __pyx_filename = __pyx_t_35;
            goto __pyx_L30_except_error;
          }
          __pyx_L94:;
        }
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        goto __pyx_L29_exception_handled;
      }
      goto __pyx_L30_except_error;

      /* "ws_package/controllers/activity_controller.py":3909
 *             # Query Notes table for entries that contain any of these interval IDs
 *             # Notes.activity_interval_id is a JSON array, so we need to check if any interval_id is in the array
 *             try:             # <<<<<<<<<<<<<<
 *                 with db_lock_manager.read_lock():
 *                     async with async_session() as session:
*/
      __pyx_L30_except_error:;
      __Pyx_XGIVEREF(__pyx_t_18);
      __Pyx_XGIVEREF(__pyx_t_19);
      __Pyx_XGIVEREF(__pyx_t_20);
      __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20);
      goto __pyx_L1_error;
      __pyx_L29_exception_handled:;
      __Pyx_XGIVEREF(__pyx_t_18);
      __Pyx_XGIVEREF(__pyx_t_19);
      __Pyx_XGIVEREF(__pyx_t_20);
      __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20);
      __pyx_L35_try_end:;
    }

    /* "ws_package/controllers/activity_controller.py":3931
 *                 # Continue without notes if there's an error
 * 
 *             for interval in day_intervals:             # <<<<<<<<<<<<<<
 *                 # Format idle_note_url
 *                 interval_id = getattr(interval, 'id', None)
*/
    if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_day_intervals)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_day_intervals)) {
      __pyx_t_5 = __pyx_cur_scope->__pyx_v_day_intervals; __Pyx_INCREF(__pyx_t_5);
      __pyx_t_12 = 0;
      __pyx_t_16 = NULL;
    } else {
      __pyx_t_12 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_day_intervals); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 3931, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_16 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 3931, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_16)) {
        if (likely(PyList_CheckExact(__pyx_t_5))) {
          {
            Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_5);
            #if !CYTHON_ASSUME_SAFE_SIZE
            if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3931, __pyx_L1_error)
            #endif
            if (__pyx_t_12 >= __pyx_temp) break;
          }
          __pyx_t_13 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_5, __pyx_t_12, __Pyx_ReferenceSharing_OwnStrongReference);
          ++__pyx_t_12;
        } else {
          {
            Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_5);
            #if !CYTHON_ASSUME_SAFE_SIZE
            if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 3931, __pyx_L1_error)
            #endif
            if (__pyx_t_12 >= __pyx_temp) break;
          }
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_13 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_12));
          #else
          __pyx_t_13 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_12);
          #endif
          ++__pyx_t_12;
        }
        if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3931, __pyx_L1_error)
      } else {
        __pyx_t_13 = __pyx_t_16(__pyx_t_5);
        if (unlikely(!__pyx_t_13)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 3931, __pyx_L1_error)
            PyErr_Clear();
          }
          break;
        }
      }
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_13);
      __Pyx_GIVEREF(__pyx_t_13);
      __pyx_t_13 = 0;

      /* "ws_package/controllers/activity_controller.py":3933
 *             for interval in day_intervals:
 *                 # Format idle_note_url
 *                 interval_id = getattr(interval, 'id', None)             # <<<<<<<<<<<<<<
 *                 file_path = interval_file_map.get(interval_id)
 *                 idle_note_url = {"image_url": file_path} if file_path else None
*/
      __pyx_t_13 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id, Py_None); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3933, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval_id);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval_id, __pyx_t_13);
      __Pyx_GIVEREF(__pyx_t_13);
      __pyx_t_13 = 0;

      /* "ws_package/controllers/activity_controller.py":3934
 *                 # Format idle_note_url
 *                 interval_id = getattr(interval, 'id', None)
 *                 file_path = interval_file_map.get(interval_id)             # <<<<<<<<<<<<<<
 *                 idle_note_url = {"image_url": file_path} if file_path else None
 * 
*/
      __pyx_t_13 = __Pyx_PyDict_GetItemDefault(__pyx_cur_scope->__pyx_v_interval_file_map, __pyx_cur_scope->__pyx_v_interval_id, Py_None); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3934, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_file_path);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_file_path, __pyx_t_13);
      __Pyx_GIVEREF(__pyx_t_13);
      __pyx_t_13 = 0;

      /* "ws_package/controllers/activity_controller.py":3935
 *                 interval_id = getattr(interval, 'id', None)
 *                 file_path = interval_file_map.get(interval_id)
 *                 idle_note_url = {"image_url": file_path} if file_path else None             # <<<<<<<<<<<<<<
 * 
 *                 # For the last interval (stop), extend end_time to now when fetching screenshots so the
*/
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_file_path); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3935, __pyx_L1_error)
      if (__pyx_t_2) {
        __pyx_t_7 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3935, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        if (PyDict_SetItem(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_image_url, __pyx_cur_scope->__pyx_v_file_path) < (0)) __PYX_ERR(0, 3935, __pyx_L1_error)
        __pyx_t_13 = __pyx_t_7;
        __pyx_t_7 = 0;
      } else {
        __Pyx_INCREF(Py_None);
        __pyx_t_13 = Py_None;
      }
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_idle_note_url);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_idle_note_url, __pyx_t_13);
      __Pyx_GIVEREF(__pyx_t_13);
      __pyx_t_13 = 0;

      /* "ws_package/controllers/activity_controller.py":3939
 *                 # For the last interval (stop), extend end_time to now when fetching screenshots so the
 *                 # stop screenshot (captured at stop button press) is included in the payload
 *                 ss_end_time = interval.end_time             # <<<<<<<<<<<<<<
 *                 if last_interval is not None:
 *                     def _dt_match(a, b, tol=1.0):
*/
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3939, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_ss_end_time);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_ss_end_time, __pyx_t_13);
      __Pyx_GIVEREF(__pyx_t_13);
      __pyx_t_13 = 0;

      /* "ws_package/controllers/activity_controller.py":3940
 *                 # stop screenshot (captured at stop button press) is included in the payload
 *                 ss_end_time = interval.end_time
 *                 if last_interval is not None:             # <<<<<<<<<<<<<<
 *                     def _dt_match(a, b, tol=1.0):
 *                         if a is None or b is None:
*/
      __pyx_t_2 = (__pyx_cur_scope->__pyx_v_last_interval != Py_None);
      if (__pyx_t_2) {

        /* "ws_package/controllers/activity_controller.py":3941
 *                 ss_end_time = interval.end_time
 *                 if last_interval is not None:
 *                     def _dt_match(a, b, tol=1.0):             # <<<<<<<<<<<<<<
 *                         if a is None or b is None:
 *                             return a == b
*/
        __pyx_t_13 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_22process_intervals_bulk_1_dt_match, 0, __pyx_mstate_global->__pyx_n_u_ActivityController_process_inter_3, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[47])); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3941, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_13, __pyx_mstate_global->__pyx_tuple[28]);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v__dt_match);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v__dt_match, __pyx_t_13);
        __Pyx_GIVEREF(__pyx_t_13);
        __pyx_t_13 = 0;

        /* "ws_package/controllers/activity_controller.py":3949
 *                             return False
 *                     last_match = (
 *                         _dt_match(getattr(interval, 'start_time', None), getattr(last_interval, 'start_time', None))             # <<<<<<<<<<<<<<
 *                         and _dt_match(getattr(interval, 'end_time', None), getattr(last_interval, 'end_time', None))
 *                         and getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
*/
        __pyx_t_7 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_start_time, Py_None); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3949, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_14 = __pyx_cur_scope->__pyx_v_last_interval;
        __Pyx_INCREF(__pyx_t_14);
        __pyx_t_33 = __Pyx_GetAttr3(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_start_time, Py_None); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 3949, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_33);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3949, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_GIVEREF(__pyx_t_7);
        if (__Pyx_PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_7) != (0)) __PYX_ERR(0, 3949, __pyx_L1_error);
        __Pyx_GIVEREF(__pyx_t_33);
        if (__Pyx_PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_33) != (0)) __PYX_ERR(0, 3949, __pyx_L1_error);
        __pyx_t_7 = 0;
        __pyx_t_33 = 0;
        __pyx_t_33 = __Pyx_PyObject_Call(__pyx_cur_scope->__pyx_v__dt_match, __pyx_t_14, NULL); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 3949, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_33);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_33); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3949, __pyx_L1_error)
        if (__pyx_t_2) {
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
        } else {
          __Pyx_INCREF(__pyx_t_33);
          __pyx_t_13 = __pyx_t_33;
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
          goto __pyx_L102_bool_binop_done;
        }

        /* "ws_package/controllers/activity_controller.py":3950
 *                     last_match = (
 *                         _dt_match(getattr(interval, 'start_time', None), getattr(last_interval, 'start_time', None))
 *                         and _dt_match(getattr(interval, 'end_time', None), getattr(last_interval, 'end_time', None))             # <<<<<<<<<<<<<<
 *                         and getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
 *                     )
*/
        __pyx_t_33 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time, Py_None); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 3950, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_33);
        __pyx_t_14 = __pyx_cur_scope->__pyx_v_last_interval;
        __Pyx_INCREF(__pyx_t_14);
        __pyx_t_7 = __Pyx_GetAttr3(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_end_time, Py_None); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3950, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_14 = PyTuple_New(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3950, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_GIVEREF(__pyx_t_33);
        if (__Pyx_PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_33) != (0)) __PYX_ERR(0, 3950, __pyx_L1_error);
        __Pyx_GIVEREF(__pyx_t_7);
        if (__Pyx_PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_7) != (0)) __PYX_ERR(0, 3950, __pyx_L1_error);
        __pyx_t_33 = 0;
        __pyx_t_7 = 0;
        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_cur_scope->__pyx_v__dt_match, __pyx_t_14, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3950, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3950, __pyx_L1_error)
        if (__pyx_t_2) {
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        } else {
          __Pyx_INCREF(__pyx_t_7);
          __pyx_t_13 = __pyx_t_7;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          goto __pyx_L102_bool_binop_done;
        }

        /* "ws_package/controllers/activity_controller.py":3951
 *                         _dt_match(getattr(interval, 'start_time', None), getattr(last_interval, 'start_time', None))
 *                         and _dt_match(getattr(interval, 'end_time', None), getattr(last_interval, 'end_time', None))
 *                         and getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)             # <<<<<<<<<<<<<<
 *                     )
 *                     if last_match:
*/
        __pyx_t_7 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_counter, Py_None); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3951, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_14 = __pyx_cur_scope->__pyx_v_last_interval;
        __Pyx_INCREF(__pyx_t_14);
        __pyx_t_33 = __Pyx_GetAttr3(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_counter, Py_None); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 3951, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_33);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_14 = PyObject_RichCompare(__pyx_t_7, __pyx_t_33, Py_EQ); __Pyx_XGOTREF(__pyx_t_14); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3951, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
        __Pyx_INCREF(__pyx_t_14);
        __pyx_t_13 = __pyx_t_14;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_L102_bool_binop_done:;
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_last_match);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_last_match, __pyx_t_13);
        __Pyx_GIVEREF(__pyx_t_13);
        __pyx_t_13 = 0;

        /* "ws_package/controllers/activity_controller.py":3953
 *                         and getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
 *                     )
 *                     if last_match:             # <<<<<<<<<<<<<<
 *                         ss_end_time = max(interval.end_time, datetime.datetime.now())
 *                         logger.info("Last interval (stop): extending screenshot range to %s to include stop screenshot", ss_end_time)
*/
        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_match); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3953, __pyx_L1_error)
        if (__pyx_t_2) {

          /* "ws_package/controllers/activity_controller.py":3954
 *                     )
 *                     if last_match:
 *                         ss_end_time = max(interval.end_time, datetime.datetime.now())             # <<<<<<<<<<<<<<
 *                         logger.info("Last interval (stop): extending screenshot range to %s to include stop screenshot", ss_end_time)
 * 
*/
          __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 3954, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_33);
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3954, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
          __pyx_t_14 = __pyx_t_7;
          __Pyx_INCREF(__pyx_t_14);
          __pyx_t_8 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_14, NULL};
            __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3954, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_13);
          }
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3954, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_33 = PyObject_RichCompare(__pyx_t_13, __pyx_t_7, Py_GT); __Pyx_XGOTREF(__pyx_t_33); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 3954, __pyx_L1_error)
          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_33); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3954, __pyx_L1_error)
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
          if (__pyx_t_2) {
            __Pyx_INCREF(__pyx_t_13);
            __pyx_t_14 = __pyx_t_13;
          } else {
            __Pyx_INCREF(__pyx_t_7);
            __pyx_t_14 = __pyx_t_7;
          }
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __pyx_t_13 = __pyx_t_14;
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_ss_end_time);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_ss_end_time, __pyx_t_13);
          __Pyx_GIVEREF(__pyx_t_13);
          __pyx_t_13 = 0;

          /* "ws_package/controllers/activity_controller.py":3955
 *                     if last_match:
 *                         ss_end_time = max(interval.end_time, datetime.datetime.now())
 *                         logger.info("Last interval (stop): extending screenshot range to %s to include stop screenshot", ss_end_time)             # <<<<<<<<<<<<<<
 * 
 *                 payload_from, payload_to = self._payload_interval_bounds(interval, effective_start_time)
*/
          __pyx_t_14 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3955, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 3955, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_33);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_33))) {
            __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_33);
            assert(__pyx_t_14);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_33);
            __Pyx_INCREF(__pyx_t_14);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_33, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_14, __pyx_mstate_global->__pyx_kp_u_Last_interval_stop_extending_scr, __pyx_cur_scope->__pyx_v_ss_end_time};
            __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_33, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
            if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3955, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_13);
          }
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

          /* "ws_package/controllers/activity_controller.py":3953
 *                         and getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
 *                     )
 *                     if last_match:             # <<<<<<<<<<<<<<
 *                         ss_end_time = max(interval.end_time, datetime.datetime.now())
 *                         logger.info("Last interval (stop): extending screenshot range to %s to include stop screenshot", ss_end_time)
*/
        }

        /* "ws_package/controllers/activity_controller.py":3940
 *                 # stop screenshot (captured at stop button press) is included in the payload
 *                 ss_end_time = interval.end_time
 *                 if last_interval is not None:             # <<<<<<<<<<<<<<
 *                     def _dt_match(a, b, tol=1.0):
 *                         if a is None or b is None:
*/
      }

      /* "ws_package/controllers/activity_controller.py":3957
 *                         logger.info("Last interval (stop): extending screenshot range to %s to include stop screenshot", ss_end_time)
 * 
 *                 payload_from, payload_to = self._payload_interval_bounds(interval, effective_start_time)             # <<<<<<<<<<<<<<
 *                 align_stop = (
 *                     force_stop_time
*/
      __pyx_t_33 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_33);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_33, __pyx_cur_scope->__pyx_v_interval, __pyx_cur_scope->__pyx_v_effective_start_time};
        __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_payload_interval_bounds, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
        if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3957, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
      }
      if ((likely(PyTuple_CheckExact(__pyx_t_13))) || (PyList_CheckExact(__pyx_t_13))) {
        PyObject* sequence = __pyx_t_13;
        Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
        if (unlikely(size != 2)) {
          if (size > 2) __Pyx_RaiseTooManyValuesError(2);
          else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
          __PYX_ERR(0, 3957, __pyx_L1_error)
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        if (likely(PyTuple_CheckExact(sequence))) {
          __pyx_t_33 = PyTuple_GET_ITEM(sequence, 0);
          __Pyx_INCREF(__pyx_t_33);
          __pyx_t_14 = PyTuple_GET_ITEM(sequence, 1);
          __Pyx_INCREF(__pyx_t_14);
        } else {
          __pyx_t_33 = __Pyx_PyList_GET_ITEM_REF(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
          if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 3957, __pyx_L1_error)
          __Pyx_XGOTREF(__pyx_t_33);
          __pyx_t_14 = __Pyx_PyList_GET_ITEM_REF(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
          if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3957, __pyx_L1_error)
          __Pyx_XGOTREF(__pyx_t_14);
        }
        #else
        __pyx_t_33 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 3957, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_33);
        __pyx_t_14 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3957, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        #endif
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      } else {
        Py_ssize_t index = -1;
        __pyx_t_7 = PyObject_GetIter(__pyx_t_13); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3957, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_36 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_7);
        index = 0; __pyx_t_33 = __pyx_t_36(__pyx_t_7); if (unlikely(!__pyx_t_33)) goto __pyx_L106_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_33);
        index = 1; __pyx_t_14 = __pyx_t_36(__pyx_t_7); if (unlikely(!__pyx_t_14)) goto __pyx_L106_unpacking_failed;
        __Pyx_GOTREF(__pyx_t_14);
        if (__Pyx_IternextUnpackEndCheck(__pyx_t_36(__pyx_t_7), 2) < (0)) __PYX_ERR(0, 3957, __pyx_L1_error)
        __pyx_t_36 = NULL;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L107_unpacking_done;
        __pyx_L106_unpacking_failed:;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_36 = NULL;
        if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
        __PYX_ERR(0, 3957, __pyx_L1_error)
        __pyx_L107_unpacking_done:;
      }
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_payload_from);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_payload_from, __pyx_t_33);
      __Pyx_GIVEREF(__pyx_t_33);
      __pyx_t_33 = 0;
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_payload_to);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_payload_to, __pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_14);
      __pyx_t_14 = 0;

      /* "ws_package/controllers/activity_controller.py":3959
 *                 payload_from, payload_to = self._payload_interval_bounds(interval, effective_start_time)
 *                 align_stop = (
 *                     force_stop_time             # <<<<<<<<<<<<<<
 *                     or getattr(self, "_last_work_stop_time", None)
 *                 )
*/
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_force_stop_time); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3959, __pyx_L1_error)
      if (!__pyx_t_2) {
      } else {
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_force_stop_time);
        __pyx_t_13 = __pyx_cur_scope->__pyx_v_force_stop_time;
        goto __pyx_L108_bool_binop_done;
      }

      /* "ws_package/controllers/activity_controller.py":3960
 *                 align_stop = (
 *                     force_stop_time
 *                     or getattr(self, "_last_work_stop_time", None)             # <<<<<<<<<<<<<<
 *                 )
 *                 if last_interval is not None and last_match and align_stop is not None:
*/
      __pyx_t_14 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_work_stop_time, Py_None); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3960, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_INCREF(__pyx_t_14);
      __pyx_t_13 = __pyx_t_14;
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __pyx_L108_bool_binop_done:;
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_align_stop);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_align_stop, __pyx_t_13);
      __Pyx_GIVEREF(__pyx_t_13);
      __pyx_t_13 = 0;

      /* "ws_package/controllers/activity_controller.py":3962
 *                     or getattr(self, "_last_work_stop_time", None)
 *                 )
 *                 if last_interval is not None and last_match and align_stop is not None:             # <<<<<<<<<<<<<<
 *                     payload_to = align_stop.replace(microsecond=0)
 *                     logger.info(
*/
      __pyx_t_1 = (__pyx_cur_scope->__pyx_v_last_interval != Py_None);
      if (__pyx_t_1) {
      } else {
        __pyx_t_2 = __pyx_t_1;
        goto __pyx_L111_bool_binop_done;
      }
      if (unlikely(!__pyx_cur_scope->__pyx_v_last_match)) { __Pyx_RaiseUnboundLocalError("last_match"); __PYX_ERR(0, 3962, __pyx_L1_error) }
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_match); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 3962, __pyx_L1_error)
      if (__pyx_t_1) {
      } else {
        __pyx_t_2 = __pyx_t_1;
        goto __pyx_L111_bool_binop_done;
      }
      __pyx_t_1 = (__pyx_cur_scope->__pyx_v_align_stop != Py_None);
      __pyx_t_2 = __pyx_t_1;
      __pyx_L111_bool_binop_done:;
      if (__pyx_t_2) {

        /* "ws_package/controllers/activity_controller.py":3963
 *                 )
 *                 if last_interval is not None and last_match and align_stop is not None:
 *                     payload_to = align_stop.replace(microsecond=0)             # <<<<<<<<<<<<<<
 *                     logger.info(
 *                         "Last interval (stop): aligning payload 'to' with activity/log stop %s",
*/
        __pyx_t_14 = __pyx_cur_scope->__pyx_v_align_stop;
        __Pyx_INCREF(__pyx_t_14);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_14, NULL};
          __pyx_t_33 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 3963, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_33);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_33, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 3963, __pyx_L1_error)
          __pyx_t_13 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_33);
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
          if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3963, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
        }
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_payload_to);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_payload_to, __pyx_t_13);
        __Pyx_GIVEREF(__pyx_t_13);
        __pyx_t_13 = 0;

        /* "ws_package/controllers/activity_controller.py":3964
 *                 if last_interval is not None and last_match and align_stop is not None:
 *                     payload_to = align_stop.replace(microsecond=0)
 *                     logger.info(             # <<<<<<<<<<<<<<
 *                         "Last interval (stop): aligning payload 'to' with activity/log stop %s",
 *                         payload_to,
*/
        __pyx_t_33 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3964, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3964, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

        /* "ws_package/controllers/activity_controller.py":3966
 *                     logger.info(
 *                         "Last interval (stop): aligning payload 'to' with activity/log stop %s",
 *                         payload_to,             # <<<<<<<<<<<<<<
 *                     )
 *                 if payload_to is not None and payload_from is not None and payload_to <= payload_from:
*/
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_7);
          assert(__pyx_t_33);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_33);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_33, __pyx_mstate_global->__pyx_kp_u_Last_interval_stop_aligning_payl, __pyx_cur_scope->__pyx_v_payload_to};
          __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3964, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
        }
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

        /* "ws_package/controllers/activity_controller.py":3962
 *                     or getattr(self, "_last_work_stop_time", None)
 *                 )
 *                 if last_interval is not None and last_match and align_stop is not None:             # <<<<<<<<<<<<<<
 *                     payload_to = align_stop.replace(microsecond=0)
 *                     logger.info(
*/
      }

      /* "ws_package/controllers/activity_controller.py":3968
 *                         payload_to,
 *                     )
 *                 if payload_to is not None and payload_from is not None and payload_to <= payload_from:             # <<<<<<<<<<<<<<
 *                     logger.info(
 *                         "Skipping interval (start=%s, end=%s)  no time left after clipping to payload start %s",
*/
      __pyx_t_1 = (__pyx_cur_scope->__pyx_v_payload_to != Py_None);
      if (__pyx_t_1) {
      } else {
        __pyx_t_2 = __pyx_t_1;
        goto __pyx_L115_bool_binop_done;
      }
      __pyx_t_1 = (__pyx_cur_scope->__pyx_v_payload_from != Py_None);
      if (__pyx_t_1) {
      } else {
        __pyx_t_2 = __pyx_t_1;
        goto __pyx_L115_bool_binop_done;
      }
      __pyx_t_13 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_payload_to, __pyx_cur_scope->__pyx_v_payload_from, Py_LE); __Pyx_XGOTREF(__pyx_t_13); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3968, __pyx_L1_error)
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 3968, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __pyx_t_2 = __pyx_t_1;
      __pyx_L115_bool_binop_done:;
      if (__pyx_t_2) {

        /* "ws_package/controllers/activity_controller.py":3969
 *                     )
 *                 if payload_to is not None and payload_from is not None and payload_to <= payload_from:
 *                     logger.info(             # <<<<<<<<<<<<<<
 *                         "Skipping interval (start=%s, end=%s)  no time left after clipping to payload start %s",
 *                         interval.start_time,
*/
        __pyx_t_7 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 3969, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_33);
        __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3969, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;

        /* "ws_package/controllers/activity_controller.py":3971
 *                     logger.info(
 *                         "Skipping interval (start=%s, end=%s)  no time left after clipping to payload start %s",
 *                         interval.start_time,             # <<<<<<<<<<<<<<
 *                         interval.end_time,
 *                         effective_start_time,
*/
        __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 3971, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_33);

        /* "ws_package/controllers/activity_controller.py":3972
 *                         "Skipping interval (start=%s, end=%s)  no time left after clipping to payload start %s",
 *                         interval.start_time,
 *                         interval.end_time,             # <<<<<<<<<<<<<<
 *                         effective_start_time,
 *                     )
*/
        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3972, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_15);

        /* "ws_package/controllers/activity_controller.py":3973
 *                         interval.start_time,
 *                         interval.end_time,
 *                         effective_start_time,             # <<<<<<<<<<<<<<
 *                     )
 *                     continue
*/
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_14))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_14);
          assert(__pyx_t_7);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[5] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Skipping_interval_start_s_end_s, __pyx_t_33, __pyx_t_15, __pyx_cur_scope->__pyx_v_effective_start_time};
          __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3969, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
        }
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

        /* "ws_package/controllers/activity_controller.py":3975
 *                         effective_start_time,
 *                     )
 *                     continue             # <<<<<<<<<<<<<<
 * 
 *                 interval_payload = {
*/
        goto __pyx_L99_continue;

        /* "ws_package/controllers/activity_controller.py":3968
 *                         payload_to,
 *                     )
 *                 if payload_to is not None and payload_from is not None and payload_to <= payload_from:             # <<<<<<<<<<<<<<
 *                     logger.info(
 *                         "Skipping interval (start=%s, end=%s)  no time left after clipping to payload start %s",
*/
      }

      /* "ws_package/controllers/activity_controller.py":3978
 * 
 *                 interval_payload = {
 *                     "Entry": interval_id or 0,  # Use 0 as default if id doesn't exist (e.g., ActivityIntervalEntity)             # <<<<<<<<<<<<<<
 *                     "from": payload_from.strftime("%Y-%m-%d %H:%M:%S"),
 *                     "to": payload_to.strftime("%Y-%m-%d %H:%M:%S"),
*/
      __pyx_t_13 = __Pyx_PyDict_NewPresized(14); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 3978, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_interval_id); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 3978, __pyx_L1_error)
      if (!__pyx_t_2) {
      } else {
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_interval_id);
        __pyx_t_14 = __pyx_cur_scope->__pyx_v_interval_id;
        goto __pyx_L118_bool_binop_done;
      }
      __pyx_t_15 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3978, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_15);
      __pyx_t_14 = __pyx_t_15;
      __pyx_t_15 = 0;
      __pyx_L118_bool_binop_done:;
      if (PyDict_SetItem(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_Entry, __pyx_t_14) < (0)) __PYX_ERR(0, 3978, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

      /* "ws_package/controllers/activity_controller.py":3979
 *                 interval_payload = {
 *                     "Entry": interval_id or 0,  # Use 0 as default if id doesn't exist (e.g., ActivityIntervalEntity)
 *                     "from": payload_from.strftime("%Y-%m-%d %H:%M:%S"),             # <<<<<<<<<<<<<<
 *                     "to": payload_to.strftime("%Y-%m-%d %H:%M:%S"),
 *                     "screenUrl": await self.ss(payload_from, ss_end_time, user_entity),
*/
      __pyx_t_15 = __pyx_cur_scope->__pyx_v_payload_from;
      __Pyx_INCREF(__pyx_t_15);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Y_m_d_H_M_S};
        __pyx_t_14 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strftime, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3979, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
      }
      if (PyDict_SetItem(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_from, __pyx_t_14) < (0)) __PYX_ERR(0, 3978, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

      /* "ws_package/controllers/activity_controller.py":3980
 *                     "Entry": interval_id or 0,  # Use 0 as default if id doesn't exist (e.g., ActivityIntervalEntity)
 *                     "from": payload_from.strftime("%Y-%m-%d %H:%M:%S"),
 *                     "to": payload_to.strftime("%Y-%m-%d %H:%M:%S"),             # <<<<<<<<<<<<<<
 *                     "screenUrl": await self.ss(payload_from, ss_end_time, user_entity),
 *                     "activityLevel": await self.get_activity_level_from_db(payload_from, payload_to),
*/
      __pyx_t_15 = __pyx_cur_scope->__pyx_v_payload_to;
      __Pyx_INCREF(__pyx_t_15);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Y_m_d_H_M_S};
        __pyx_t_14 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strftime, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3980, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
      }
      if (PyDict_SetItem(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_to, __pyx_t_14) < (0)) __PYX_ERR(0, 3978, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

      /* "ws_package/controllers/activity_controller.py":3981
 *                     "from": payload_from.strftime("%Y-%m-%d %H:%M:%S"),
 *                     "to": payload_to.strftime("%Y-%m-%d %H:%M:%S"),
 *                     "screenUrl": await self.ss(payload_from, ss_end_time, user_entity),             # <<<<<<<<<<<<<<
 *                     "activityLevel": await self.get_activity_level_from_db(payload_from, payload_to),
 *                     "appAndUrls": await self.activity_service.get_apps_urls(payload_from, payload_to, self.appandurlstatus),
*/
      __pyx_t_15 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_15);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[4] = {__pyx_t_15, __pyx_cur_scope->__pyx_v_payload_from, __pyx_cur_scope->__pyx_v_ss_end_time, __pyx_cur_scope->__pyx_v_user_entity};
        __pyx_t_14 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_ss, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3981, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
      }
      __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_14, &__pyx_r);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      if (likely(__pyx_t_26 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
        __Pyx_XGIVEREF(__pyx_t_4);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
        __Pyx_XGIVEREF(__pyx_t_5);
        __pyx_cur_scope->__pyx_t_4 = __pyx_t_5;
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
        __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
        __pyx_cur_scope->__pyx_t_19 = __pyx_t_12;
        __Pyx_XGIVEREF(__pyx_t_13);
        __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
        __pyx_cur_scope->__pyx_t_20 = __pyx_t_16;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from async generator, awaiting value */
        __pyx_generator->resume_label = 6;
        return __pyx_r;
        __pyx_L120_resume_from_await:;
        __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
        __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_4);
        __pyx_t_5 = __pyx_cur_scope->__pyx_t_4;
        __pyx_cur_scope->__pyx_t_4 = 0;
        __Pyx_XGOTREF(__pyx_t_5);
        __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
        __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
        __pyx_t_12 = __pyx_cur_scope->__pyx_t_19;
        __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
        __pyx_cur_scope->__pyx_t_5 = 0;
        __Pyx_XGOTREF(__pyx_t_13);
        __pyx_t_16 = __pyx_cur_scope->__pyx_t_20;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3981, __pyx_L1_error)
        __pyx_t_14 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_14);
      } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __pyx_t_14 = __pyx_r; __pyx_r = NULL;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 3981, __pyx_L1_error)
      }
      if (PyDict_SetItem(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_screenUrl, __pyx_t_14) < (0)) __PYX_ERR(0, 3978, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

      /* "ws_package/controllers/activity_controller.py":3982
 *                     "to": payload_to.strftime("%Y-%m-%d %H:%M:%S"),
 *                     "screenUrl": await self.ss(payload_from, ss_end_time, user_entity),
 *                     "activityLevel": await self.get_activity_level_from_db(payload_from, payload_to),             # <<<<<<<<<<<<<<
 *                     "appAndUrls": await self.activity_service.get_apps_urls(payload_from, payload_to, self.appandurlstatus),
 *                     "deviceType": self.get_os_type_caps(),
*/
      __pyx_t_15 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_15);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_15, __pyx_cur_scope->__pyx_v_payload_from, __pyx_cur_scope->__pyx_v_payload_to};
        __pyx_t_14 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_activity_level_from_db, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3982, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
      }
      __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_14, &__pyx_r);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      if (likely(__pyx_t_26 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
        __Pyx_XGIVEREF(__pyx_t_4);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
        __Pyx_XGIVEREF(__pyx_t_5);
        __pyx_cur_scope->__pyx_t_4 = __pyx_t_5;
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
        __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
        __pyx_cur_scope->__pyx_t_19 = __pyx_t_12;
        __Pyx_XGIVEREF(__pyx_t_13);
        __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
        __pyx_cur_scope->__pyx_t_20 = __pyx_t_16;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from async generator, awaiting value */
        __pyx_generator->resume_label = 7;
        return __pyx_r;
        __pyx_L121_resume_from_await:;
        __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
        __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_4);
        __pyx_t_5 = __pyx_cur_scope->__pyx_t_4;
        __pyx_cur_scope->__pyx_t_4 = 0;
        __Pyx_XGOTREF(__pyx_t_5);
        __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
        __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
        __pyx_t_12 = __pyx_cur_scope->__pyx_t_19;
        __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
        __pyx_cur_scope->__pyx_t_5 = 0;
        __Pyx_XGOTREF(__pyx_t_13);
        __pyx_t_16 = __pyx_cur_scope->__pyx_t_20;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3982, __pyx_L1_error)
        __pyx_t_14 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_14);
      } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __pyx_t_14 = __pyx_r; __pyx_r = NULL;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 3982, __pyx_L1_error)
      }
      if (PyDict_SetItem(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_activityLevel, __pyx_t_14) < (0)) __PYX_ERR(0, 3978, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

      /* "ws_package/controllers/activity_controller.py":3983
 *                     "screenUrl": await self.ss(payload_from, ss_end_time, user_entity),
 *                     "activityLevel": await self.get_activity_level_from_db(payload_from, payload_to),
 *                     "appAndUrls": await self.activity_service.get_apps_urls(payload_from, payload_to, self.appandurlstatus),             # <<<<<<<<<<<<<<
 *                     "deviceType": self.get_os_type_caps(),
 *                     "os_type": self.get_os_type_caps(),
*/
      __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 3983, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_33);
      __pyx_t_15 = __pyx_t_33;
      __Pyx_INCREF(__pyx_t_15);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3983, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[4] = {__pyx_t_15, __pyx_cur_scope->__pyx_v_payload_from, __pyx_cur_scope->__pyx_v_payload_to, __pyx_t_7};
        __pyx_t_14 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_apps_urls, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
        if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3983, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
      }
      __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_14, &__pyx_r);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      if (likely(__pyx_t_26 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
        __Pyx_XGIVEREF(__pyx_t_4);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
        __Pyx_XGIVEREF(__pyx_t_5);
        __pyx_cur_scope->__pyx_t_4 = __pyx_t_5;
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
        __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
        __pyx_cur_scope->__pyx_t_19 = __pyx_t_12;
        __Pyx_XGIVEREF(__pyx_t_13);
        __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
        __pyx_cur_scope->__pyx_t_20 = __pyx_t_16;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from async generator, awaiting value */
        __pyx_generator->resume_label = 8;
        return __pyx_r;
        __pyx_L122_resume_from_await:;
        __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
        __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_4);
        __pyx_t_5 = __pyx_cur_scope->__pyx_t_4;
        __pyx_cur_scope->__pyx_t_4 = 0;
        __Pyx_XGOTREF(__pyx_t_5);
        __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
        __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
        __pyx_t_12 = __pyx_cur_scope->__pyx_t_19;
        __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
        __pyx_cur_scope->__pyx_t_5 = 0;
        __Pyx_XGOTREF(__pyx_t_13);
        __pyx_t_16 = __pyx_cur_scope->__pyx_t_20;
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 3983, __pyx_L1_error)
        __pyx_t_14 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_14);
      } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __pyx_t_14 = __pyx_r; __pyx_r = NULL;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 3983, __pyx_L1_error)
      }
      if (PyDict_SetItem(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_appAndUrls, __pyx_t_14) < (0)) __PYX_ERR(0, 3978, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

      /* "ws_package/controllers/activity_controller.py":3984
 *                     "activityLevel": await self.get_activity_level_from_db(payload_from, payload_to),
 *                     "appAndUrls": await self.activity_service.get_apps_urls(payload_from, payload_to, self.appandurlstatus),
 *                     "deviceType": self.get_os_type_caps(),             # <<<<<<<<<<<<<<
 *                     "os_type": self.get_os_type_caps(),
 *                     "note": interval_note_map.get(interval_id),  # Get note from Notes table mapping
*/
      __pyx_t_33 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_33);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_33, NULL};
        __pyx_t_14 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type_caps, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
        if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3984, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
      }
      if (PyDict_SetItem(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_deviceType, __pyx_t_14) < (0)) __PYX_ERR(0, 3978, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

      /* "ws_package/controllers/activity_controller.py":3985
 *                     "appAndUrls": await self.activity_service.get_apps_urls(payload_from, payload_to, self.appandurlstatus),
 *                     "deviceType": self.get_os_type_caps(),
 *                     "os_type": self.get_os_type_caps(),             # <<<<<<<<<<<<<<
 *                     "note": interval_note_map.get(interval_id),  # Get note from Notes table mapping
 *                     "idle_note_url": idle_note_url,
*/
      __pyx_t_33 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_33);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_33, NULL};
        __pyx_t_14 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type_caps, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
        if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3985, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
      }
      if (PyDict_SetItem(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_os_type, __pyx_t_14) < (0)) __PYX_ERR(0, 3978, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

      /* "ws_package/controllers/activity_controller.py":3986
 *                     "deviceType": self.get_os_type_caps(),
 *                     "os_type": self.get_os_type_caps(),
 *                     "note": interval_note_map.get(interval_id),  # Get note from Notes table mapping             # <<<<<<<<<<<<<<
 *                     "idle_note_url": idle_note_url,
 *                     "idleInterval": None,
*/
      __pyx_t_14 = __Pyx_PyDict_GetItemDefault(__pyx_cur_scope->__pyx_v_interval_note_map, __pyx_cur_scope->__pyx_v_interval_id, Py_None); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3986, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      if (PyDict_SetItem(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_note, __pyx_t_14) < (0)) __PYX_ERR(0, 3978, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

      /* "ws_package/controllers/activity_controller.py":3987
 *                     "os_type": self.get_os_type_caps(),
 *                     "note": interval_note_map.get(interval_id),  # Get note from Notes table mapping
 *                     "idle_note_url": idle_note_url,             # <<<<<<<<<<<<<<
 *                     "idleInterval": None,
 *                     "location": LocationEntity(
*/
      if (PyDict_SetItem(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_idle_note_url, __pyx_cur_scope->__pyx_v_idle_note_url) < (0)) __PYX_ERR(0, 3978, __pyx_L1_error)

      /* "ws_package/controllers/activity_controller.py":3988
 *                     "note": interval_note_map.get(interval_id),  # Get note from Notes table mapping
 *                     "idle_note_url": idle_note_url,
 *                     "idleInterval": None,             # <<<<<<<<<<<<<<
 *                     "location": LocationEntity(
 *                         long="null",
*/
      if (PyDict_SetItem(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_idleInterval, Py_None) < (0)) __PYX_ERR(0, 3978, __pyx_L1_error)

      /* "ws_package/controllers/activity_controller.py":3989
 *                     "idle_note_url": idle_note_url,
 *                     "idleInterval": None,
 *                     "location": LocationEntity(             # <<<<<<<<<<<<<<
 *                         long="null",
 *                         lat="null"
*/
      __pyx_t_15 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_LocationEntity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 3989, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_6);
        assert(__pyx_t_15);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_15);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 2 : 0)] = {__pyx_t_15, NULL};
        __pyx_t_37 = __Pyx_MakeVectorcallBuilderKwds(2); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 3989, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_37);
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_long, __pyx_mstate_global->__pyx_n_u_null, __pyx_t_37, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 3989, __pyx_L1_error)
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_lat, __pyx_mstate_global->__pyx_n_u_null, __pyx_t_37, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 3989, __pyx_L1_error)
        __pyx_t_7 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_37);
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3989, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
      }
      __pyx_t_33 = __pyx_t_7;
      __Pyx_INCREF(__pyx_t_33);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_33, NULL};
        __pyx_t_14 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_model_dump, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3992, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
      }
      if (PyDict_SetItem(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_location, __pyx_t_14) < (0)) __PYX_ERR(0, 3978, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

      /* "ws_package/controllers/activity_controller.py":3993
 *                         lat="null"
 *                     ).model_dump(),
 *                     "interval_time_db": int(self.interval/60),             # <<<<<<<<<<<<<<
 *                     "has_on_demand_screenshot": getattr(interval, "has_on_demand_screenshot", False),
 *                 }
*/
      __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3993, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_7 = __Pyx_PyLong_TrueDivideObjC(__pyx_t_14, __pyx_mstate_global->__pyx_int_60, 60, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 3993, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __pyx_t_14 = __Pyx_PyNumber_Int(__pyx_t_7); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3993, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (PyDict_SetItem(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_interval_time_db, __pyx_t_14) < (0)) __PYX_ERR(0, 3978, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

      /* "ws_package/controllers/activity_controller.py":3994
 *                     ).model_dump(),
 *                     "interval_time_db": int(self.interval/60),
 *                     "has_on_demand_screenshot": getattr(interval, "has_on_demand_screenshot", False),             # <<<<<<<<<<<<<<
 *                 }
 *                 interval_payloads.append(interval_payload)
*/
      __pyx_t_14 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_has_on_demand_screenshot, Py_False); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 3994, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      if (PyDict_SetItem(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_has_on_demand_screenshot, __pyx_t_14) < (0)) __PYX_ERR(0, 3978, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval_payload);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval_payload, ((PyObject*)__pyx_t_13));
      __Pyx_GIVEREF(__pyx_t_13);
      __pyx_t_13 = 0;

      /* "ws_package/controllers/activity_controller.py":3996
 *                     "has_on_demand_screenshot": getattr(interval, "has_on_demand_screenshot", False),
 *                 }
 *                 interval_payloads.append(interval_payload)             # <<<<<<<<<<<<<<
 * 
 *             # Build the final payload for this day
*/
      __pyx_t_17 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_interval_payloads, __pyx_cur_scope->__pyx_v_interval_payload); if (unlikely(__pyx_t_17 == ((int)-1))) __PYX_ERR(0, 3996, __pyx_L1_error)

      /* "ws_package/controllers/activity_controller.py":3931
 *                 # Continue without notes if there's an error
 * 
 *             for interval in day_intervals:             # <<<<<<<<<<<<<<
 *                 # Format idle_note_url
 *                 interval_id = getattr(interval, 'id', None)
*/
      __pyx_L99_continue:;
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "ws_package/controllers/activity_controller.py":4001
 *             project_id = (
 *                 payload_project_id
 *                 if payload_project_id is not None             # <<<<<<<<<<<<<<
 *                 else (self.current_project_id if self.current_project_id else "1001")
 *             )
*/
    __pyx_t_2 = (__pyx_cur_scope->__pyx_v_payload_project_id != ((PyObject*)Py_None));
    if (__pyx_t_2) {

      /* "ws_package/controllers/activity_controller.py":4000
 *             # Build the final payload for this day
 *             project_id = (
 *                 payload_project_id             # <<<<<<<<<<<<<<
 *                 if payload_project_id is not None
 *                 else (self.current_project_id if self.current_project_id else "1001")
*/
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_payload_project_id);
      __pyx_t_5 = __pyx_cur_scope->__pyx_v_payload_project_id;
    } else {

      /* "ws_package/controllers/activity_controller.py":4002
 *                 payload_project_id
 *                 if payload_project_id is not None
 *                 else (self.current_project_id if self.current_project_id else "1001")             # <<<<<<<<<<<<<<
 *             )
 *             task_id = (
*/
      __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_project_id); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4002, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 4002, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      if (__pyx_t_1) {
        __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_project_id); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4002, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_13 = __pyx_t_14;
        __pyx_t_14 = 0;
      } else {
        __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_1001);
        __pyx_t_13 = __pyx_mstate_global->__pyx_kp_u_1001;
      }
      __pyx_t_5 = __pyx_t_13;
      __pyx_t_13 = 0;
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_project_id);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_project_id, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;

    /* "ws_package/controllers/activity_controller.py":4006
 *             task_id = (
 *                 payload_task_id
 *                 if payload_task_id is not None             # <<<<<<<<<<<<<<
 *                 else (self.current_task_id if self.current_task_id else "0")
 *             )
*/
    __pyx_t_2 = (__pyx_cur_scope->__pyx_v_payload_task_id != ((PyObject*)Py_None));
    if (__pyx_t_2) {

      /* "ws_package/controllers/activity_controller.py":4005
 *             )
 *             task_id = (
 *                 payload_task_id             # <<<<<<<<<<<<<<
 *                 if payload_task_id is not None
 *                 else (self.current_task_id if self.current_task_id else "0")
*/
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_payload_task_id);
      __pyx_t_5 = __pyx_cur_scope->__pyx_v_payload_task_id;
    } else {

      /* "ws_package/controllers/activity_controller.py":4007
 *                 payload_task_id
 *                 if payload_task_id is not None
 *                 else (self.current_task_id if self.current_task_id else "0")             # <<<<<<<<<<<<<<
 *             )
 *             if payload_project_id is None and not self.current_project_id:
*/
      __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_task_id); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4007, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 4007, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      if (__pyx_t_1) {
        __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_task_id); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4007, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_13 = __pyx_t_14;
        __pyx_t_14 = 0;
      } else {
        __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_0);
        __pyx_t_13 = __pyx_mstate_global->__pyx_kp_u_0;
      }
      __pyx_t_5 = __pyx_t_13;
      __pyx_t_13 = 0;
    }
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_task_id);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_task_id, __pyx_t_5);
    __Pyx_GIVEREF(__pyx_t_5);
    __pyx_t_5 = 0;

    /* "ws_package/controllers/activity_controller.py":4009
 *                 else (self.current_task_id if self.current_task_id else "0")
 *             )
 *             if payload_project_id is None and not self.current_project_id:             # <<<<<<<<<<<<<<
 *                 logger.warning(
 *                     "No project selected in Python  using fallback project_id=%s. "
*/
    __pyx_t_1 = (__pyx_cur_scope->__pyx_v_payload_project_id == ((PyObject*)Py_None));
    if (__pyx_t_1) {
    } else {
      __pyx_t_2 = __pyx_t_1;
      goto __pyx_L125_bool_binop_done;
    }
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_project_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4009, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 4009, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_38 = (!__pyx_t_1);
    __pyx_t_2 = __pyx_t_38;
    __pyx_L125_bool_binop_done:;
    if (__pyx_t_2) {

      /* "ws_package/controllers/activity_controller.py":4010
 *             )
 *             if payload_project_id is None and not self.current_project_id:
 *                 logger.warning(             # <<<<<<<<<<<<<<
 *                     "No project selected in Python  using fallback project_id=%s. "
 *                     "Ensure Electron sends set_project_task before start_activity_monitoring.",
*/
      __pyx_t_13 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4010, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_14);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4010, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

      /* "ws_package/controllers/activity_controller.py":4013
 *                     "No project selected in Python  using fallback project_id=%s. "
 *                     "Ensure Electron sends set_project_task before start_activity_monitoring.",
 *                     project_id,             # <<<<<<<<<<<<<<
 *                 )
 *             logger.info(
*/
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_13);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_13);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_No_project_selected_in_Python_us, __pyx_cur_scope->__pyx_v_project_id};
        __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4010, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_5);
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "ws_package/controllers/activity_controller.py":4009
 *                 else (self.current_task_id if self.current_task_id else "0")
 *             )
 *             if payload_project_id is None and not self.current_project_id:             # <<<<<<<<<<<<<<
 *                 logger.warning(
 *                     "No project selected in Python  using fallback project_id=%s. "
*/
    }

    /* "ws_package/controllers/activity_controller.py":4015
 *                     project_id,
 *                 )
 *             logger.info(             # <<<<<<<<<<<<<<
 *                 "Using project_id=%s, task_id=%s for activity log payload (override=%s)",
 *                 project_id,
*/
    __pyx_t_7 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4015, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4015, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

    /* "ws_package/controllers/activity_controller.py":4019
 *                 project_id,
 *                 task_id,
 *                 payload_project_id is not None,             # <<<<<<<<<<<<<<
 *             )
 *             logger.info(
*/
    __pyx_t_2 = (__pyx_cur_scope->__pyx_v_payload_project_id != ((PyObject*)Py_None));
    __pyx_t_13 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4019, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_8 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_14))) {
      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_14);
      assert(__pyx_t_7);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
      __pyx_t_8 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[5] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Using_project_id_s_task_id_s_for, __pyx_cur_scope->__pyx_v_project_id, __pyx_cur_scope->__pyx_v_task_id, __pyx_t_13};
      __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4015, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "ws_package/controllers/activity_controller.py":4021
 *                 payload_project_id is not None,
 *             )
 *             logger.info(             # <<<<<<<<<<<<<<
 *                 "Building activity/log stop fields (last_interval=%s, force_stop_time=%s, intervals=%s)",
 *                 last_interval is not None,
*/
    __pyx_t_14 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4021, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4021, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

    /* "ws_package/controllers/activity_controller.py":4023
 *             logger.info(
 *                 "Building activity/log stop fields (last_interval=%s, force_stop_time=%s, intervals=%s)",
 *                 last_interval is not None,             # <<<<<<<<<<<<<<
 *                 force_stop_time,
 *                 len(interval_payloads),
*/
    __pyx_t_2 = (__pyx_cur_scope->__pyx_v_last_interval != Py_None);
    __pyx_t_13 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4023, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);

    /* "ws_package/controllers/activity_controller.py":4025
 *                 last_interval is not None,
 *                 force_stop_time,
 *                 len(interval_payloads),             # <<<<<<<<<<<<<<
 *             )
 * 
*/
    __pyx_t_12 = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_interval_payloads); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4025, __pyx_L1_error)
    __pyx_t_33 = PyLong_FromSsize_t(__pyx_t_12); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 4025, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_33);
    __pyx_t_8 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_7))) {
      __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_7);
      assert(__pyx_t_14);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
      __pyx_t_8 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[5] = {__pyx_t_14, __pyx_mstate_global->__pyx_kp_u_Building_activity_log_stop_field, __pyx_t_13, __pyx_cur_scope->__pyx_v_force_stop_time, __pyx_t_33};
      __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4021, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

    /* "ws_package/controllers/activity_controller.py":4030
 *             # When sending last interval (stop click), set "stop" to datetime.now()
 *             # BUT: Don't set "stop" for sleep intervals (long gaps with zero activity)
 *             stop_value = None             # <<<<<<<<<<<<<<
 *             stop_dt_for_intervals = None
 *             if last_interval is not None:
*/
    __Pyx_INCREF(Py_None);
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_stop_value);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_stop_value, Py_None);
    __Pyx_GIVEREF(Py_None);

    /* "ws_package/controllers/activity_controller.py":4031
 *             # BUT: Don't set "stop" for sleep intervals (long gaps with zero activity)
 *             stop_value = None
 *             stop_dt_for_intervals = None             # <<<<<<<<<<<<<<
 *             if last_interval is not None:
 *                 def _dt_match(a, b, tol=1.0):
*/
    __Pyx_INCREF(Py_None);
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_stop_dt_for_intervals);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_stop_dt_for_intervals, Py_None);
    __Pyx_GIVEREF(Py_None);

    /* "ws_package/controllers/activity_controller.py":4032
 *             stop_value = None
 *             stop_dt_for_intervals = None
 *             if last_interval is not None:             # <<<<<<<<<<<<<<
 *                 def _dt_match(a, b, tol=1.0):
 *                     if a is None or b is None:
*/
    __pyx_t_2 = (__pyx_cur_scope->__pyx_v_last_interval != Py_None);
    if (__pyx_t_2) {

      /* "ws_package/controllers/activity_controller.py":4033
 *             stop_dt_for_intervals = None
 *             if last_interval is not None:
 *                 def _dt_match(a, b, tol=1.0):             # <<<<<<<<<<<<<<
 *                     if a is None or b is None:
 *                         return a == b
*/
      __pyx_t_5 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_22process_intervals_bulk_3_dt_match, 0, __pyx_mstate_global->__pyx_n_u_ActivityController_process_inter_3, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[48])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4033, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_5, __pyx_mstate_global->__pyx_tuple[28]);
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v__dt_match);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v__dt_match, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_5 = 0;

      /* "ws_package/controllers/activity_controller.py":4043
 *                 # NEW: Check if this is a sleep interval (long gap with zero activity)
 *                 # Sleep intervals should NOT get a "stop" timestamp
 *                 is_sleep_interval = False             # <<<<<<<<<<<<<<
 *                 if hasattr(last_interval, 'start_time') and hasattr(last_interval, 'end_time'):
 *                     gap_seconds = (last_interval.end_time - last_interval.start_time).total_seconds()
*/
      __pyx_cur_scope->__pyx_v_is_sleep_interval = 0;

      /* "ws_package/controllers/activity_controller.py":4044
 *                 # Sleep intervals should NOT get a "stop" timestamp
 *                 is_sleep_interval = False
 *                 if hasattr(last_interval, 'start_time') and hasattr(last_interval, 'end_time'):             # <<<<<<<<<<<<<<
 *                     gap_seconds = (last_interval.end_time - last_interval.start_time).total_seconds()
 *                     # Check if it's a long interval (>= 1 hour) with zero activity (typical sleep pattern)
*/
      __pyx_t_5 = __pyx_cur_scope->__pyx_v_last_interval;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_38 = __Pyx_HasAttr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(__pyx_t_38 == ((int)-1))) __PYX_ERR(0, 4044, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (__pyx_t_38) {
      } else {
        __pyx_t_2 = __pyx_t_38;
        goto __pyx_L129_bool_binop_done;
      }
      __pyx_t_5 = __pyx_cur_scope->__pyx_v_last_interval;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_38 = __Pyx_HasAttr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(__pyx_t_38 == ((int)-1))) __PYX_ERR(0, 4044, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_2 = __pyx_t_38;
      __pyx_L129_bool_binop_done:;
      if (__pyx_t_2) {

        /* "ws_package/controllers/activity_controller.py":4045
 *                 is_sleep_interval = False
 *                 if hasattr(last_interval, 'start_time') and hasattr(last_interval, 'end_time'):
 *                     gap_seconds = (last_interval.end_time - last_interval.start_time).total_seconds()             # <<<<<<<<<<<<<<
 *                     # Check if it's a long interval (>= 1 hour) with zero activity (typical sleep pattern)
 *                     if gap_seconds >= 3600:  # 1 hour
*/
        __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 4045, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_33);
        __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4045, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_14 = PyNumber_Subtract(__pyx_t_33, __pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4045, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_7 = __pyx_t_14;
        __Pyx_INCREF(__pyx_t_7);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_total_seconds, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4045, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_gap_seconds);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_gap_seconds, __pyx_t_5);
        __Pyx_GIVEREF(__pyx_t_5);
        __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":4047
 *                     gap_seconds = (last_interval.end_time - last_interval.start_time).total_seconds()
 *                     # Check if it's a long interval (>= 1 hour) with zero activity (typical sleep pattern)
 *                     if gap_seconds >= 3600:  # 1 hour             # <<<<<<<<<<<<<<
 *                         # Check if activity level is zero (sleep intervals have zero activity)
 *                         try:
*/
        __pyx_t_5 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_gap_seconds, __pyx_mstate_global->__pyx_int_3600, Py_GE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4047, __pyx_L1_error)
        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 4047, __pyx_L1_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (__pyx_t_2) {

          /* "ws_package/controllers/activity_controller.py":4049
 *                     if gap_seconds >= 3600:  # 1 hour
 *                         # Check if activity level is zero (sleep intervals have zero activity)
 *                         try:             # <<<<<<<<<<<<<<
 *                             activity_level = await self.get_activity_level_from_db(last_interval.start_time, last_interval.end_time)
 *                             if activity_level:
*/
          {
            __Pyx_ExceptionSave(&__pyx_t_20, &__pyx_t_19, &__pyx_t_18);
            __Pyx_XGOTREF(__pyx_t_20);
            __Pyx_XGOTREF(__pyx_t_19);
            __Pyx_XGOTREF(__pyx_t_18);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":4050
 *                         # Check if activity level is zero (sleep intervals have zero activity)
 *                         try:
 *                             activity_level = await self.get_activity_level_from_db(last_interval.start_time, last_interval.end_time)             # <<<<<<<<<<<<<<
 *                             if activity_level:
 *                                 keyboard = float(activity_level.get('keyboard', 0) or 0)
*/
              __pyx_t_14 = __pyx_cur_scope->__pyx_v_self;
              __Pyx_INCREF(__pyx_t_14);
              __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4050, __pyx_L132_error)
              __Pyx_GOTREF(__pyx_t_7);
              __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4050, __pyx_L132_error)
              __Pyx_GOTREF(__pyx_t_13);
              __pyx_t_8 = 0;
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_14, __pyx_t_7, __pyx_t_13};
                __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_activity_level_from_db, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4050, __pyx_L132_error)
                __Pyx_GOTREF(__pyx_t_5);
              }
              __pyx_t_26 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              if (likely(__pyx_t_26 == PYGEN_NEXT)) {
                __Pyx_GOTREF(__pyx_r);
                __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
                __Pyx_XGIVEREF(__pyx_t_4);
                __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
                __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
                __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                __Pyx_XGIVEREF(__pyx_t_18);
                __pyx_cur_scope->__pyx_t_4 = __pyx_t_18;
                __Pyx_XGIVEREF(__pyx_t_19);
                __pyx_cur_scope->__pyx_t_5 = __pyx_t_19;
                __Pyx_XGIVEREF(__pyx_t_20);
                __pyx_cur_scope->__pyx_t_6 = __pyx_t_20;
                __Pyx_XGIVEREF(__pyx_r);
                __Pyx_RefNannyFinishContext();
                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                /* return from async generator, awaiting value */
                __pyx_generator->resume_label = 9;
                return __pyx_r;
                __pyx_L140_resume_from_await:;
                __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
                __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
                __pyx_cur_scope->__pyx_t_1 = 0;
                __Pyx_XGOTREF(__pyx_t_4);
                __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
                __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                __pyx_t_18 = __pyx_cur_scope->__pyx_t_4;
                __pyx_cur_scope->__pyx_t_4 = 0;
                __Pyx_XGOTREF(__pyx_t_18);
                __pyx_t_19 = __pyx_cur_scope->__pyx_t_5;
                __pyx_cur_scope->__pyx_t_5 = 0;
                __Pyx_XGOTREF(__pyx_t_19);
                __pyx_t_20 = __pyx_cur_scope->__pyx_t_6;
                __pyx_cur_scope->__pyx_t_6 = 0;
                __Pyx_XGOTREF(__pyx_t_20);
                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4050, __pyx_L132_error)
                __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
              } else if (likely(__pyx_t_26 == PYGEN_RETURN)) {
                __Pyx_GOTREF(__pyx_r);
                __pyx_t_5 = __pyx_r; __pyx_r = NULL;
              } else {
                __Pyx_XGOTREF(__pyx_r);
                __PYX_ERR(0, 4050, __pyx_L132_error)
              }
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_activity_level);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_activity_level, __pyx_t_5);
              __Pyx_GIVEREF(__pyx_t_5);
              __pyx_t_5 = 0;

              /* "ws_package/controllers/activity_controller.py":4051
 *                         try:
 *                             activity_level = await self.get_activity_level_from_db(last_interval.start_time, last_interval.end_time)
 *                             if activity_level:             # <<<<<<<<<<<<<<
 *                                 keyboard = float(activity_level.get('keyboard', 0) or 0)
 *                                 mouse = float(activity_level.get('mouse', 0) or 0)
*/
              __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_activity_level); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 4051, __pyx_L132_error)
              if (__pyx_t_2) {

                /* "ws_package/controllers/activity_controller.py":4052
 *                             activity_level = await self.get_activity_level_from_db(last_interval.start_time, last_interval.end_time)
 *                             if activity_level:
 *                                 keyboard = float(activity_level.get('keyboard', 0) or 0)             # <<<<<<<<<<<<<<
 *                                 mouse = float(activity_level.get('mouse', 0) or 0)
 *                                 average = float(activity_level.get('average', 0) or 0)
*/
                __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activity_level, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4052, __pyx_L132_error)
                __Pyx_GOTREF(__pyx_t_13);
                __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_mstate_global->__pyx_tuple[15], NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4052, __pyx_L132_error)
                __Pyx_GOTREF(__pyx_t_7);
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 4052, __pyx_L132_error)
                if (!__pyx_t_2) {
                  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                } else {
                  __Pyx_INCREF(__pyx_t_7);
                  __pyx_t_5 = __pyx_t_7;
                  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                  goto __pyx_L142_bool_binop_done;
                }
                __pyx_t_7 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4052, __pyx_L132_error)
                __Pyx_GOTREF(__pyx_t_7);
                __pyx_t_5 = __pyx_t_7;
                __pyx_t_7 = 0;
                __pyx_L142_bool_binop_done:;
                __pyx_t_39 = __Pyx_PyObject_AsDouble(__pyx_t_5); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_39, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 4052, __pyx_L132_error)
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __pyx_cur_scope->__pyx_v_keyboard = __pyx_t_39;

                /* "ws_package/controllers/activity_controller.py":4053
 *                             if activity_level:
 *                                 keyboard = float(activity_level.get('keyboard', 0) or 0)
 *                                 mouse = float(activity_level.get('mouse', 0) or 0)             # <<<<<<<<<<<<<<
 *                                 average = float(activity_level.get('average', 0) or 0)
 *                                 if keyboard == 0.0 and mouse == 0.0 and average == 0.0:
*/
                __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activity_level, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4053, __pyx_L132_error)
                __Pyx_GOTREF(__pyx_t_7);
                __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_mstate_global->__pyx_tuple[16], NULL); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4053, __pyx_L132_error)
                __Pyx_GOTREF(__pyx_t_13);
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 4053, __pyx_L132_error)
                if (!__pyx_t_2) {
                  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                } else {
                  __Pyx_INCREF(__pyx_t_13);
                  __pyx_t_5 = __pyx_t_13;
                  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                  goto __pyx_L144_bool_binop_done;
                }
                __pyx_t_13 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4053, __pyx_L132_error)
                __Pyx_GOTREF(__pyx_t_13);
                __pyx_t_5 = __pyx_t_13;
                __pyx_t_13 = 0;
                __pyx_L144_bool_binop_done:;
                __pyx_t_39 = __Pyx_PyObject_AsDouble(__pyx_t_5); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_39, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 4053, __pyx_L132_error)
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __pyx_cur_scope->__pyx_v_mouse = __pyx_t_39;

                /* "ws_package/controllers/activity_controller.py":4054
 *                                 keyboard = float(activity_level.get('keyboard', 0) or 0)
 *                                 mouse = float(activity_level.get('mouse', 0) or 0)
 *                                 average = float(activity_level.get('average', 0) or 0)             # <<<<<<<<<<<<<<
 *                                 if keyboard == 0.0 and mouse == 0.0 and average == 0.0:
 *                                     is_sleep_interval = True
*/
                __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activity_level, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4054, __pyx_L132_error)
                __Pyx_GOTREF(__pyx_t_13);
                __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_mstate_global->__pyx_tuple[17], NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4054, __pyx_L132_error)
                __Pyx_GOTREF(__pyx_t_7);
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 4054, __pyx_L132_error)
                if (!__pyx_t_2) {
                  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                } else {
                  __Pyx_INCREF(__pyx_t_7);
                  __pyx_t_5 = __pyx_t_7;
                  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                  goto __pyx_L146_bool_binop_done;
                }
                __pyx_t_7 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4054, __pyx_L132_error)
                __Pyx_GOTREF(__pyx_t_7);
                __pyx_t_5 = __pyx_t_7;
                __pyx_t_7 = 0;
                __pyx_L146_bool_binop_done:;
                __pyx_t_39 = __Pyx_PyObject_AsDouble(__pyx_t_5); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_39, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 4054, __pyx_L132_error)
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __pyx_cur_scope->__pyx_v_average = __pyx_t_39;

                /* "ws_package/controllers/activity_controller.py":4055
 *                                 mouse = float(activity_level.get('mouse', 0) or 0)
 *                                 average = float(activity_level.get('average', 0) or 0)
 *                                 if keyboard == 0.0 and mouse == 0.0 and average == 0.0:             # <<<<<<<<<<<<<<
 *                                     is_sleep_interval = True
 *                                     logger.info("[SleepInterval] Detected sleep interval (%s hours) - will NOT set 'stop' timestamp", gap_seconds/3600)
*/
                __pyx_t_38 = (__pyx_cur_scope->__pyx_v_keyboard == 0.0);
                if (__pyx_t_38) {
                } else {
                  __pyx_t_2 = __pyx_t_38;
                  goto __pyx_L149_bool_binop_done;
                }
                __pyx_t_38 = (__pyx_cur_scope->__pyx_v_mouse == 0.0);
                if (__pyx_t_38) {
                } else {
                  __pyx_t_2 = __pyx_t_38;
                  goto __pyx_L149_bool_binop_done;
                }
                __pyx_t_38 = (__pyx_cur_scope->__pyx_v_average == 0.0);
                __pyx_t_2 = __pyx_t_38;
                __pyx_L149_bool_binop_done:;
                if (__pyx_t_2) {

                  /* "ws_package/controllers/activity_controller.py":4056
 *                                 average = float(activity_level.get('average', 0) or 0)
 *                                 if keyboard == 0.0 and mouse == 0.0 and average == 0.0:
 *                                     is_sleep_interval = True             # <<<<<<<<<<<<<<
 *                                     logger.info("[SleepInterval] Detected sleep interval (%s hours) - will NOT set 'stop' timestamp", gap_seconds/3600)
 *                         except Exception as e:
*/
                  __pyx_cur_scope->__pyx_v_is_sleep_interval = 1;

                  /* "ws_package/controllers/activity_controller.py":4057
 *                                 if keyboard == 0.0 and mouse == 0.0 and average == 0.0:
 *                                     is_sleep_interval = True
 *                                     logger.info("[SleepInterval] Detected sleep interval (%s hours) - will NOT set 'stop' timestamp", gap_seconds/3600)             # <<<<<<<<<<<<<<
 *                         except Exception as e:
 *                             logger.debug("Could not check activity level for sleep detection: %s", e)
*/
                  __pyx_t_7 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4057, __pyx_L132_error)
                  __Pyx_GOTREF(__pyx_t_13);
                  __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4057, __pyx_L132_error)
                  __Pyx_GOTREF(__pyx_t_14);
                  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                  __pyx_t_13 = __Pyx_PyLong_TrueDivideObjC(__pyx_cur_scope->__pyx_v_gap_seconds, __pyx_mstate_global->__pyx_int_3600, 0xE10, 0, 0); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4057, __pyx_L132_error)
                  __Pyx_GOTREF(__pyx_t_13);
                  __pyx_t_8 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_14))) {
                    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_14);
                    assert(__pyx_t_7);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
                    __Pyx_INCREF(__pyx_t_7);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
                    __pyx_t_8 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[3] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_SleepInterval_Detected_sleep_in, __pyx_t_13};
                    __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4057, __pyx_L132_error)
                    __Pyx_GOTREF(__pyx_t_5);
                  }
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                  /* "ws_package/controllers/activity_controller.py":4055
 *                                 mouse = float(activity_level.get('mouse', 0) or 0)
 *                                 average = float(activity_level.get('average', 0) or 0)
 *                                 if keyboard == 0.0 and mouse == 0.0 and average == 0.0:             # <<<<<<<<<<<<<<
 *                                     is_sleep_interval = True
 *                                     logger.info("[SleepInterval] Detected sleep interval (%s hours) - will NOT set 'stop' timestamp", gap_seconds/3600)
*/
                }

                /* "ws_package/controllers/activity_controller.py":4051
 *                         try:
 *                             activity_level = await self.get_activity_level_from_db(last_interval.start_time, last_interval.end_time)
 *                             if activity_level:             # <<<<<<<<<<<<<<
 *                                 keyboard = float(activity_level.get('keyboard', 0) or 0)
 *                                 mouse = float(activity_level.get('mouse', 0) or 0)
*/
              }

              /* "ws_package/controllers/activity_controller.py":4049
 *                     if gap_seconds >= 3600:  # 1 hour
 *                         # Check if activity level is zero (sleep intervals have zero activity)
 *                         try:             # <<<<<<<<<<<<<<
 *                             activity_level = await self.get_activity_level_from_db(last_interval.start_time, last_interval.end_time)
 *                             if activity_level:
*/
            }
            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
            __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            goto __pyx_L139_try_end;
            __pyx_L132_error:;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
            __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

            /* "ws_package/controllers/activity_controller.py":4058
 *                                     is_sleep_interval = True
 *                                     logger.info("[SleepInterval] Detected sleep interval (%s hours) - will NOT set 'stop' timestamp", gap_seconds/3600)
 *                         except Exception as e:             # <<<<<<<<<<<<<<
 *                             logger.debug("Could not check activity level for sleep detection: %s", e)
 *                             # If we can't check, also check if the interval has activityLevel attribute directly
*/
            __pyx_t_34 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
            if (__pyx_t_34) {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.process_intervals_bulk", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_14, &__pyx_t_13) < 0) __PYX_ERR(0, 4058, __pyx_L134_except_error)
              __Pyx_XGOTREF(__pyx_t_5);
              __Pyx_XGOTREF(__pyx_t_14);
              __Pyx_XGOTREF(__pyx_t_13);
              __Pyx_INCREF(__pyx_t_14);
              __Pyx_GIVEREF(__pyx_t_14);
              __pyx_cur_scope->__pyx_v_e = __pyx_t_14;
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":4059
 *                                     logger.info("[SleepInterval] Detected sleep interval (%s hours) - will NOT set 'stop' timestamp", gap_seconds/3600)
 *                         except Exception as e:
 *                             logger.debug("Could not check activity level for sleep detection: %s", e)             # <<<<<<<<<<<<<<
 *                             # If we can't check, also check if the interval has activityLevel attribute directly
 *                             if hasattr(last_interval, 'activityLevel') and last_interval.activityLevel:
*/
                __pyx_t_33 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4059, __pyx_L157_error)
                __Pyx_GOTREF(__pyx_t_6);
                __pyx_t_37 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 4059, __pyx_L157_error)
                __Pyx_GOTREF(__pyx_t_37);
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_37))) {
                  __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_37);
                  assert(__pyx_t_33);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_37);
                  __Pyx_INCREF(__pyx_t_33);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_37, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_33, __pyx_mstate_global->__pyx_kp_u_Could_not_check_activity_level_f, __pyx_cur_scope->__pyx_v_e};
                  __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_37, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                  __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4059, __pyx_L157_error)
                  __Pyx_GOTREF(__pyx_t_7);
                }
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

                /* "ws_package/controllers/activity_controller.py":4061
 *                             logger.debug("Could not check activity level for sleep detection: %s", e)
 *                             # If we can't check, also check if the interval has activityLevel attribute directly
 *                             if hasattr(last_interval, 'activityLevel') and last_interval.activityLevel:             # <<<<<<<<<<<<<<
 *                                 try:
 *                                     activity_level = last_interval.activityLevel
*/
                __pyx_t_7 = __pyx_cur_scope->__pyx_v_last_interval;
                __Pyx_INCREF(__pyx_t_7);
                __pyx_t_38 = __Pyx_HasAttr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_activityLevel); if (unlikely(__pyx_t_38 == ((int)-1))) __PYX_ERR(0, 4061, __pyx_L157_error)
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                if (__pyx_t_38) {
                } else {
                  __pyx_t_2 = __pyx_t_38;
                  goto __pyx_L160_bool_binop_done;
                }
                __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_activityLevel); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4061, __pyx_L157_error)
                __Pyx_GOTREF(__pyx_t_7);
                __pyx_t_38 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_38 < 0))) __PYX_ERR(0, 4061, __pyx_L157_error)
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                __pyx_t_2 = __pyx_t_38;
                __pyx_L160_bool_binop_done:;
                if (__pyx_t_2) {

                  /* "ws_package/controllers/activity_controller.py":4062
 *                             # If we can't check, also check if the interval has activityLevel attribute directly
 *                             if hasattr(last_interval, 'activityLevel') and last_interval.activityLevel:
 *                                 try:             # <<<<<<<<<<<<<<
 *                                     activity_level = last_interval.activityLevel
 *                                     keyboard = float(activity_level.get('keyboard', 0) if isinstance(activity_level, dict) else 0)
*/
                  {
                    __Pyx_ExceptionSave(&__pyx_t_29, &__pyx_t_25, &__pyx_t_22);
                    __Pyx_XGOTREF(__pyx_t_29);
                    __Pyx_XGOTREF(__pyx_t_25);
                    __Pyx_XGOTREF(__pyx_t_22);
                    /*try:*/ {

                      /* "ws_package/controllers/activity_controller.py":4063
 *                             if hasattr(last_interval, 'activityLevel') and last_interval.activityLevel:
 *                                 try:
 *                                     activity_level = last_interval.activityLevel             # <<<<<<<<<<<<<<
 *                                     keyboard = float(activity_level.get('keyboard', 0) if isinstance(activity_level, dict) else 0)
 *                                     mouse = float(activity_level.get('mouse', 0) if isinstance(activity_level, dict) else 0)
*/
                      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_activityLevel); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4063, __pyx_L162_error)
                      __Pyx_GOTREF(__pyx_t_7);
                      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_activity_level);
                      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_activity_level, __pyx_t_7);
                      __Pyx_GIVEREF(__pyx_t_7);
                      __pyx_t_7 = 0;

                      /* "ws_package/controllers/activity_controller.py":4064
 *                                 try:
 *                                     activity_level = last_interval.activityLevel
 *                                     keyboard = float(activity_level.get('keyboard', 0) if isinstance(activity_level, dict) else 0)             # <<<<<<<<<<<<<<
 *                                     mouse = float(activity_level.get('mouse', 0) if isinstance(activity_level, dict) else 0)
 *                                     average = float(activity_level.get('average', 0) if isinstance(activity_level, dict) else 0)
*/
                      __pyx_t_2 = PyDict_Check(__pyx_cur_scope->__pyx_v_activity_level); 
                      if (__pyx_t_2) {
                        __pyx_t_37 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activity_level, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 4064, __pyx_L162_error)
                        __Pyx_GOTREF(__pyx_t_37);
                        __pyx_t_33 = __Pyx_PyObject_Call(__pyx_t_37, __pyx_mstate_global->__pyx_tuple[15], NULL); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 4064, __pyx_L162_error)
                        __Pyx_GOTREF(__pyx_t_33);
                        __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                        __pyx_t_7 = __pyx_t_33;
                        __pyx_t_33 = 0;
                      } else {
                        __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
                        __pyx_t_7 = __pyx_mstate_global->__pyx_int_0;
                      }
                      __pyx_t_39 = __Pyx_PyObject_AsDouble(__pyx_t_7); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_39, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 4064, __pyx_L162_error)
                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                      __pyx_cur_scope->__pyx_v_keyboard = __pyx_t_39;

                      /* "ws_package/controllers/activity_controller.py":4065
 *                                     activity_level = last_interval.activityLevel
 *                                     keyboard = float(activity_level.get('keyboard', 0) if isinstance(activity_level, dict) else 0)
 *                                     mouse = float(activity_level.get('mouse', 0) if isinstance(activity_level, dict) else 0)             # <<<<<<<<<<<<<<
 *                                     average = float(activity_level.get('average', 0) if isinstance(activity_level, dict) else 0)
 *                                     if keyboard == 0.0 and mouse == 0.0 and average == 0.0:
*/
                      __pyx_t_2 = PyDict_Check(__pyx_cur_scope->__pyx_v_activity_level); 
                      if (__pyx_t_2) {
                        __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activity_level, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 4065, __pyx_L162_error)
                        __Pyx_GOTREF(__pyx_t_33);
                        __pyx_t_37 = __Pyx_PyObject_Call(__pyx_t_33, __pyx_mstate_global->__pyx_tuple[16], NULL); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 4065, __pyx_L162_error)
                        __Pyx_GOTREF(__pyx_t_37);
                        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                        __pyx_t_7 = __pyx_t_37;
                        __pyx_t_37 = 0;
                      } else {
                        __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
                        __pyx_t_7 = __pyx_mstate_global->__pyx_int_0;
                      }
                      __pyx_t_39 = __Pyx_PyObject_AsDouble(__pyx_t_7); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_39, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 4065, __pyx_L162_error)
                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                      __pyx_cur_scope->__pyx_v_mouse = __pyx_t_39;

                      /* "ws_package/controllers/activity_controller.py":4066
 *                                     keyboard = float(activity_level.get('keyboard', 0) if isinstance(activity_level, dict) else 0)
 *                                     mouse = float(activity_level.get('mouse', 0) if isinstance(activity_level, dict) else 0)
 *                                     average = float(activity_level.get('average', 0) if isinstance(activity_level, dict) else 0)             # <<<<<<<<<<<<<<
 *                                     if keyboard == 0.0 and mouse == 0.0 and average == 0.0:
 *                                         is_sleep_interval = True
*/
                      __pyx_t_2 = PyDict_Check(__pyx_cur_scope->__pyx_v_activity_level); 
                      if (__pyx_t_2) {
                        __pyx_t_37 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activity_level, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 4066, __pyx_L162_error)
                        __Pyx_GOTREF(__pyx_t_37);
                        __pyx_t_33 = __Pyx_PyObject_Call(__pyx_t_37, __pyx_mstate_global->__pyx_tuple[17], NULL); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 4066, __pyx_L162_error)
                        __Pyx_GOTREF(__pyx_t_33);
                        __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                        __pyx_t_7 = __pyx_t_33;
                        __pyx_t_33 = 0;
                      } else {
                        __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
                        __pyx_t_7 = __pyx_mstate_global->__pyx_int_0;
                      }
                      __pyx_t_39 = __Pyx_PyObject_AsDouble(__pyx_t_7); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_39, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 4066, __pyx_L162_error)
                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                      __pyx_cur_scope->__pyx_v_average = __pyx_t_39;

                      /* "ws_package/controllers/activity_controller.py":4067
 *                                     mouse = float(activity_level.get('mouse', 0) if isinstance(activity_level, dict) else 0)
 *                                     average = float(activity_level.get('average', 0) if isinstance(activity_level, dict) else 0)
 *                                     if keyboard == 0.0 and mouse == 0.0 and average == 0.0:             # <<<<<<<<<<<<<<
 *                                         is_sleep_interval = True
 *                                         logger.info("[SleepInterval] Detected sleep interval from activityLevel attribute (%s hours) - will NOT set 'stop' timestamp", gap_seconds/3600)
*/
                      __pyx_t_38 = (__pyx_cur_scope->__pyx_v_keyboard == 0.0);
                      if (__pyx_t_38) {
                      } else {
                        __pyx_t_2 = __pyx_t_38;
                        goto __pyx_L171_bool_binop_done;
                      }
                      __pyx_t_38 = (__pyx_cur_scope->__pyx_v_mouse == 0.0);
                      if (__pyx_t_38) {
                      } else {
                        __pyx_t_2 = __pyx_t_38;
                        goto __pyx_L171_bool_binop_done;
                      }
                      __pyx_t_38 = (__pyx_cur_scope->__pyx_v_average == 0.0);
                      __pyx_t_2 = __pyx_t_38;
                      __pyx_L171_bool_binop_done:;
                      if (__pyx_t_2) {

                        /* "ws_package/controllers/activity_controller.py":4068
 *                                     average = float(activity_level.get('average', 0) if isinstance(activity_level, dict) else 0)
 *                                     if keyboard == 0.0 and mouse == 0.0 and average == 0.0:
 *                                         is_sleep_interval = True             # <<<<<<<<<<<<<<
 *                                         logger.info("[SleepInterval] Detected sleep interval from activityLevel attribute (%s hours) - will NOT set 'stop' timestamp", gap_seconds/3600)
 *                                 except Exception as e2:
*/
                        __pyx_cur_scope->__pyx_v_is_sleep_interval = 1;

                        /* "ws_package/controllers/activity_controller.py":4069
 *                                     if keyboard == 0.0 and mouse == 0.0 and average == 0.0:
 *                                         is_sleep_interval = True
 *                                         logger.info("[SleepInterval] Detected sleep interval from activityLevel attribute (%s hours) - will NOT set 'stop' timestamp", gap_seconds/3600)             # <<<<<<<<<<<<<<
 *                                 except Exception as e2:
 *                                     logger.debug("Could not check activityLevel attribute: %s", e2)
*/
                        __pyx_t_33 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 4069, __pyx_L162_error)
                        __Pyx_GOTREF(__pyx_t_37);
                        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4069, __pyx_L162_error)
                        __Pyx_GOTREF(__pyx_t_6);
                        __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                        __pyx_t_37 = __Pyx_PyLong_TrueDivideObjC(__pyx_cur_scope->__pyx_v_gap_seconds, __pyx_mstate_global->__pyx_int_3600, 0xE10, 0, 0); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 4069, __pyx_L162_error)
                        __Pyx_GOTREF(__pyx_t_37);
                        __pyx_t_8 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_6))) {
                          __pyx_t_33 = PyMethod_GET_SELF(__pyx_t_6);
                          assert(__pyx_t_33);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                          __Pyx_INCREF(__pyx_t_33);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                          __pyx_t_8 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[3] = {__pyx_t_33, __pyx_mstate_global->__pyx_kp_u_SleepInterval_Detected_sleep_in_2, __pyx_t_37};
                          __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                          __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4069, __pyx_L162_error)
                          __Pyx_GOTREF(__pyx_t_7);
                        }
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

                        /* "ws_package/controllers/activity_controller.py":4067
 *                                     mouse = float(activity_level.get('mouse', 0) if isinstance(activity_level, dict) else 0)
 *                                     average = float(activity_level.get('average', 0) if isinstance(activity_level, dict) else 0)
 *                                     if keyboard == 0.0 and mouse == 0.0 and average == 0.0:             # <<<<<<<<<<<<<<
 *                                         is_sleep_interval = True
 *                                         logger.info("[SleepInterval] Detected sleep interval from activityLevel attribute (%s hours) - will NOT set 'stop' timestamp", gap_seconds/3600)
*/
                      }

                      /* "ws_package/controllers/activity_controller.py":4062
 *                             # If we can't check, also check if the interval has activityLevel attribute directly
 *                             if hasattr(last_interval, 'activityLevel') and last_interval.activityLevel:
 *                                 try:             # <<<<<<<<<<<<<<
 *                                     activity_level = last_interval.activityLevel
 *                                     keyboard = float(activity_level.get('keyboard', 0) if isinstance(activity_level, dict) else 0)
*/
                    }
                    __Pyx_XDECREF(__pyx_t_29); __pyx_t_29 = 0;
                    __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                    goto __pyx_L169_try_end;
                    __pyx_L162_error:;
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                    __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

                    /* "ws_package/controllers/activity_controller.py":4070
 *                                         is_sleep_interval = True
 *                                         logger.info("[SleepInterval] Detected sleep interval from activityLevel attribute (%s hours) - will NOT set 'stop' timestamp", gap_seconds/3600)
 *                                 except Exception as e2:             # <<<<<<<<<<<<<<
 *                                     logger.debug("Could not check activityLevel attribute: %s", e2)
 * 
*/
                    __pyx_t_34 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                    if (__pyx_t_34) {
                      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.process_intervals_bulk", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_6, &__pyx_t_37) < 0) __PYX_ERR(0, 4070, __pyx_L164_except_error)
                      __Pyx_XGOTREF(__pyx_t_7);
                      __Pyx_XGOTREF(__pyx_t_6);
                      __Pyx_XGOTREF(__pyx_t_37);
                      __Pyx_INCREF(__pyx_t_6);
                      __Pyx_GIVEREF(__pyx_t_6);
                      __pyx_cur_scope->__pyx_v_e2 = __pyx_t_6;
                      /*try:*/ {

                        /* "ws_package/controllers/activity_controller.py":4071
 *                                         logger.info("[SleepInterval] Detected sleep interval from activityLevel attribute (%s hours) - will NOT set 'stop' timestamp", gap_seconds/3600)
 *                                 except Exception as e2:
 *                                     logger.debug("Could not check activityLevel attribute: %s", e2)             # <<<<<<<<<<<<<<
 * 
 *                 if not is_sleep_interval:
*/
                        __pyx_t_15 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_40, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_40)) __PYX_ERR(0, 4071, __pyx_L179_error)
                        __Pyx_GOTREF(__pyx_t_40);
                        __pyx_t_41 = __Pyx_PyObject_GetAttrStr(__pyx_t_40, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_41)) __PYX_ERR(0, 4071, __pyx_L179_error)
                        __Pyx_GOTREF(__pyx_t_41);
                        __Pyx_DECREF(__pyx_t_40); __pyx_t_40 = 0;
                        __pyx_t_8 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_41))) {
                          __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_41);
                          assert(__pyx_t_15);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_41);
                          __Pyx_INCREF(__pyx_t_15);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_41, __pyx__function);
                          __pyx_t_8 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[3] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Could_not_check_activityLevel_at, __pyx_cur_scope->__pyx_v_e2};
                          __pyx_t_33 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_41, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                          __Pyx_DECREF(__pyx_t_41); __pyx_t_41 = 0;
                          if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 4071, __pyx_L179_error)
                          __Pyx_GOTREF(__pyx_t_33);
                        }
                        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                      }

                      /* "ws_package/controllers/activity_controller.py":4070
 *                                         is_sleep_interval = True
 *                                         logger.info("[SleepInterval] Detected sleep interval from activityLevel attribute (%s hours) - will NOT set 'stop' timestamp", gap_seconds/3600)
 *                                 except Exception as e2:             # <<<<<<<<<<<<<<
 *                                     logger.debug("Could not check activityLevel attribute: %s", e2)
 * 
*/
                      /*finally:*/ {
                        /*normal exit:*/{
                          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e2);
                          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e2); __pyx_cur_scope->__pyx_v_e2 = 0;
                          goto __pyx_L180;
                        }
                        __pyx_L179_error:;
                        /*exception exit:*/{
                          __Pyx_PyThreadState_assign
                          __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_21 = 0; __pyx_t_28 = 0; __pyx_t_27 = 0; __pyx_t_32 = 0;
                          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                          __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                          __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                          __Pyx_XDECREF(__pyx_t_41); __pyx_t_41 = 0;
                           __Pyx_ExceptionSwap(&__pyx_t_28, &__pyx_t_27, &__pyx_t_32);
                          if ( unlikely(__Pyx_GetException(&__pyx_t_23, &__pyx_t_24, &__pyx_t_21) < 0)) __Pyx_ErrFetch(&__pyx_t_23, &__pyx_t_24, &__pyx_t_21);
                          __Pyx_XGOTREF(__pyx_t_23);
                          __Pyx_XGOTREF(__pyx_t_24);
                          __Pyx_XGOTREF(__pyx_t_21);
                          __Pyx_XGOTREF(__pyx_t_28);
                          __Pyx_XGOTREF(__pyx_t_27);
                          __Pyx_XGOTREF(__pyx_t_32);
                          __pyx_t_34 = __pyx_lineno; __pyx_t_11 = __pyx_clineno; __pyx_t_42 = __pyx_filename;
                          {
                            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e2);
                            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e2); __pyx_cur_scope->__pyx_v_e2 = 0;
                          }
                          __Pyx_XGIVEREF(__pyx_t_28);
                          __Pyx_XGIVEREF(__pyx_t_27);
                          __Pyx_XGIVEREF(__pyx_t_32);
                          __Pyx_ExceptionReset(__pyx_t_28, __pyx_t_27, __pyx_t_32);
                          __Pyx_XGIVEREF(__pyx_t_23);
                          __Pyx_XGIVEREF(__pyx_t_24);
                          __Pyx_XGIVEREF(__pyx_t_21);
                          __Pyx_ErrRestore(__pyx_t_23, __pyx_t_24, __pyx_t_21);
                          __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_21 = 0; __pyx_t_28 = 0; __pyx_t_27 = 0; __pyx_t_32 = 0;
                          __pyx_lineno = __pyx_t_34; __pyx_clineno = __pyx_t_11; __pyx_filename = __pyx_t_42;
                          goto __pyx_L164_except_error;
                        }
                        __pyx_L180:;
                      }
                      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                      __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                      goto __pyx_L163_exception_handled;
                    }
                    goto __pyx_L164_except_error;

                    /* "ws_package/controllers/activity_controller.py":4062
 *                             # If we can't check, also check if the interval has activityLevel attribute directly
 *                             if hasattr(last_interval, 'activityLevel') and last_interval.activityLevel:
 *                                 try:             # <<<<<<<<<<<<<<
 *                                     activity_level = last_interval.activityLevel
 *                                     keyboard = float(activity_level.get('keyboard', 0) if isinstance(activity_level, dict) else 0)
*/
                    __pyx_L164_except_error:;
                    __Pyx_XGIVEREF(__pyx_t_29);
                    __Pyx_XGIVEREF(__pyx_t_25);
                    __Pyx_XGIVEREF(__pyx_t_22);
                    __Pyx_ExceptionReset(__pyx_t_29, __pyx_t_25, __pyx_t_22);
                    goto __pyx_L157_error;
                    __pyx_L163_exception_handled:;
                    __Pyx_XGIVEREF(__pyx_t_29);
                    __Pyx_XGIVEREF(__pyx_t_25);
                    __Pyx_XGIVEREF(__pyx_t_22);
                    __Pyx_ExceptionReset(__pyx_t_29, __pyx_t_25, __pyx_t_22);
                    __pyx_L169_try_end:;
                  }

                  /* "ws_package/controllers/activity_controller.py":4061
 *                             logger.debug("Could not check activity level for sleep detection: %s", e)
 *                             # If we can't check, also check if the interval has activityLevel attribute directly
 *                             if hasattr(last_interval, 'activityLevel') and last_interval.activityLevel:             # <<<<<<<<<<<<<<
 *                                 try:
 *                                     activity_level = last_interval.activityLevel
*/
                }
              }

              /* "ws_package/controllers/activity_controller.py":4058
 *                                     is_sleep_interval = True
 *                                     logger.info("[SleepInterval] Detected sleep interval (%s hours) - will NOT set 'stop' timestamp", gap_seconds/3600)
 *                         except Exception as e:             # <<<<<<<<<<<<<<
 *                             logger.debug("Could not check activity level for sleep detection: %s", e)
 *                             # If we can't check, also check if the interval has activityLevel attribute directly
*/
              /*finally:*/ {
                /*normal exit:*/{
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  goto __pyx_L158;
                }
                __pyx_L157_error:;
                /*exception exit:*/{
                  __Pyx_PyThreadState_assign
                  __pyx_t_22 = 0; __pyx_t_25 = 0; __pyx_t_29 = 0; __pyx_t_32 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0;
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                  __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                  __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                  __Pyx_XDECREF(__pyx_t_41); __pyx_t_41 = 0;
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                   __Pyx_ExceptionSwap(&__pyx_t_32, &__pyx_t_27, &__pyx_t_28);
                  if ( unlikely(__Pyx_GetException(&__pyx_t_22, &__pyx_t_25, &__pyx_t_29) < 0)) __Pyx_ErrFetch(&__pyx_t_22, &__pyx_t_25, &__pyx_t_29);
                  __Pyx_XGOTREF(__pyx_t_22);
                  __Pyx_XGOTREF(__pyx_t_25);
                  __Pyx_XGOTREF(__pyx_t_29);
                  __Pyx_XGOTREF(__pyx_t_32);
                  __Pyx_XGOTREF(__pyx_t_27);
                  __Pyx_XGOTREF(__pyx_t_28);
                  __pyx_t_11 = __pyx_lineno; __pyx_t_34 = __pyx_clineno; __pyx_t_43 = __pyx_filename;
                  {
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  }
                  __Pyx_XGIVEREF(__pyx_t_32);
                  __Pyx_XGIVEREF(__pyx_t_27);
                  __Pyx_XGIVEREF(__pyx_t_28);
                  __Pyx_ExceptionReset(__pyx_t_32, __pyx_t_27, __pyx_t_28);
                  __Pyx_XGIVEREF(__pyx_t_22);
                  __Pyx_XGIVEREF(__pyx_t_25);
                  __Pyx_XGIVEREF(__pyx_t_29);
                  __Pyx_ErrRestore(__pyx_t_22, __pyx_t_25, __pyx_t_29);
                  __pyx_t_22 = 0; __pyx_t_25 = 0; __pyx_t_29 = 0; __pyx_t_32 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0;
                  __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_34; __pyx_filename = __pyx_t_43;
                  goto __pyx_L134_except_error;
                }
                __pyx_L158:;
              }
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              goto __pyx_L133_exception_handled;
            }
            goto __pyx_L134_except_error;

            /* "ws_package/controllers/activity_controller.py":4049
 *                     if gap_seconds >= 3600:  # 1 hour
 *                         # Check if activity level is zero (sleep intervals have zero activity)
 *                         try:             # <<<<<<<<<<<<<<
 *                             activity_level = await self.get_activity_level_from_db(last_interval.start_time, last_interval.end_time)
 *                             if activity_level:
*/
            __pyx_L134_except_error:;
            __Pyx_XGIVEREF(__pyx_t_20);
            __Pyx_XGIVEREF(__pyx_t_19);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_19, __pyx_t_18);
            goto __pyx_L1_error;
            __pyx_L133_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_20);
            __Pyx_XGIVEREF(__pyx_t_19);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_19, __pyx_t_18);
            __pyx_L139_try_end:;
          }

          /* "ws_package/controllers/activity_controller.py":4047
 *                     gap_seconds = (last_interval.end_time - last_interval.start_time).total_seconds()
 *                     # Check if it's a long interval (>= 1 hour) with zero activity (typical sleep pattern)
 *                     if gap_seconds >= 3600:  # 1 hour             # <<<<<<<<<<<<<<
 *                         # Check if activity level is zero (sleep intervals have zero activity)
 *                         try:
*/
        }

        /* "ws_package/controllers/activity_controller.py":4044
 *                 # Sleep intervals should NOT get a "stop" timestamp
 *                 is_sleep_interval = False
 *                 if hasattr(last_interval, 'start_time') and hasattr(last_interval, 'end_time'):             # <<<<<<<<<<<<<<
 *                     gap_seconds = (last_interval.end_time - last_interval.start_time).total_seconds()
 *                     # Check if it's a long interval (>= 1 hour) with zero activity (typical sleep pattern)
*/
      }

      /* "ws_package/controllers/activity_controller.py":4073
 *                                     logger.debug("Could not check activityLevel attribute: %s", e2)
 * 
 *                 if not is_sleep_interval:             # <<<<<<<<<<<<<<
 *                     last_in_this_day = any(
 *                         _dt_match(getattr(iv, 'start_time', None), getattr(last_interval, 'start_time', None))
*/
      __pyx_t_2 = (!__pyx_cur_scope->__pyx_v_is_sleep_interval);
      if (__pyx_t_2) {

        /* "ws_package/controllers/activity_controller.py":4076
 *                     last_in_this_day = any(
 *                         _dt_match(getattr(iv, 'start_time', None), getattr(last_interval, 'start_time', None))
 *                         and _dt_match(getattr(iv, 'end_time', None), getattr(last_interval, 'end_time', None))             # <<<<<<<<<<<<<<
 *                         and getattr(iv, 'counter', None) == getattr(last_interval, 'counter', None)
 *                         for iv in day_intervals
*/
        __pyx_t_13 = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_22process_intervals_bulk_4genexpr(((PyObject*)__pyx_cur_scope), __pyx_cur_scope->__pyx_v_day_intervals); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4076, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_14 = __Pyx_Generator_GetInlinedResult(__pyx_t_13); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4076, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_last_in_this_day);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_last_in_this_day, __pyx_t_14);
        __Pyx_GIVEREF(__pyx_t_14);
        __pyx_t_14 = 0;

        /* "ws_package/controllers/activity_controller.py":4080
 *                         for iv in day_intervals
 *                     )
 *                     if last_in_this_day:             # <<<<<<<<<<<<<<
 *                         stop_dt = (
 *                             force_stop_time
*/
        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_in_this_day); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 4080, __pyx_L1_error)
        if (__pyx_t_2) {

          /* "ws_package/controllers/activity_controller.py":4082
 *                     if last_in_this_day:
 *                         stop_dt = (
 *                             force_stop_time             # <<<<<<<<<<<<<<
 *                             or getattr(self, '_last_work_stop_time', None)
 *                             or datetime.datetime.now()
*/
          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_force_stop_time); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 4082, __pyx_L1_error)
          if (!__pyx_t_2) {
          } else {
            __Pyx_INCREF(__pyx_cur_scope->__pyx_v_force_stop_time);
            __pyx_t_14 = __pyx_cur_scope->__pyx_v_force_stop_time;
            goto __pyx_L191_bool_binop_done;
          }

          /* "ws_package/controllers/activity_controller.py":4083
 *                         stop_dt = (
 *                             force_stop_time
 *                             or getattr(self, '_last_work_stop_time', None)             # <<<<<<<<<<<<<<
 *                             or datetime.datetime.now()
 *                         )
*/
          __pyx_t_13 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_work_stop_time, Py_None); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4083, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_13); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 4083, __pyx_L1_error)
          if (!__pyx_t_2) {
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          } else {
            __Pyx_INCREF(__pyx_t_13);
            __pyx_t_14 = __pyx_t_13;
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            goto __pyx_L191_bool_binop_done;
          }

          /* "ws_package/controllers/activity_controller.py":4084
 *                             force_stop_time
 *                             or getattr(self, '_last_work_stop_time', None)
 *                             or datetime.datetime.now()             # <<<<<<<<<<<<<<
 *                         )
 *                         stop_dt_for_intervals = stop_dt.replace(microsecond=0)
*/
          __Pyx_GetModuleGlobalName(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 4084, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_37);
          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4084, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
          __pyx_t_5 = __pyx_t_6;
          __Pyx_INCREF(__pyx_t_5);
          __pyx_t_8 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
            __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4084, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_13);
          }
          __Pyx_INCREF(__pyx_t_13);
          __pyx_t_14 = __pyx_t_13;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __pyx_L191_bool_binop_done:;
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_stop_dt);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_stop_dt, __pyx_t_14);
          __Pyx_GIVEREF(__pyx_t_14);
          __pyx_t_14 = 0;

          /* "ws_package/controllers/activity_controller.py":4086
 *                             or datetime.datetime.now()
 *                         )
 *                         stop_dt_for_intervals = stop_dt.replace(microsecond=0)             # <<<<<<<<<<<<<<
 *                         stop_value = stop_dt_for_intervals.strftime("%Y-%m-%d %H:%M:%S")
 *                         logger.info("Last interval in this batch (stop click): setting payload 'stop' to %s", stop_value)
*/
          __pyx_t_13 = __pyx_cur_scope->__pyx_v_stop_dt;
          __Pyx_INCREF(__pyx_t_13);
          __pyx_t_8 = 0;
          {
            PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_13, NULL};
            __pyx_t_6 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4086, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_6);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_6, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 4086, __pyx_L1_error)
            __pyx_t_14 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_6);
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4086, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_14);
          }
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_stop_dt_for_intervals);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_stop_dt_for_intervals, __pyx_t_14);
          __Pyx_GIVEREF(__pyx_t_14);
          __pyx_t_14 = 0;

          /* "ws_package/controllers/activity_controller.py":4087
 *                         )
 *                         stop_dt_for_intervals = stop_dt.replace(microsecond=0)
 *                         stop_value = stop_dt_for_intervals.strftime("%Y-%m-%d %H:%M:%S")             # <<<<<<<<<<<<<<
 *                         logger.info("Last interval in this batch (stop click): setting payload 'stop' to %s", stop_value)
 *                 else:
*/
          __pyx_t_6 = __pyx_cur_scope->__pyx_v_stop_dt_for_intervals;
          __Pyx_INCREF(__pyx_t_6);
          __pyx_t_8 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Y_m_d_H_M_S};
            __pyx_t_14 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strftime, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4087, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_14);
          }
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_stop_value);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_stop_value, __pyx_t_14);
          __Pyx_GIVEREF(__pyx_t_14);
          __pyx_t_14 = 0;

          /* "ws_package/controllers/activity_controller.py":4088
 *                         stop_dt_for_intervals = stop_dt.replace(microsecond=0)
 *                         stop_value = stop_dt_for_intervals.strftime("%Y-%m-%d %H:%M:%S")
 *                         logger.info("Last interval in this batch (stop click): setting payload 'stop' to %s", stop_value)             # <<<<<<<<<<<<<<
 *                 else:
 *                     logger.info("[SleepInterval] Skipping 'stop' timestamp for sleep interval (start=%s, end=%s)", last_interval.start_time, last_interval.end_time)
*/
          __pyx_t_6 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4088, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4088, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_5))) {
            __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
            assert(__pyx_t_6);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_6);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Last_interval_in_this_batch_stop, __pyx_cur_scope->__pyx_v_stop_value};
            __pyx_t_14 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4088, __pyx_L1_error)
            __Pyx_GOTREF(__pyx_t_14);
          }
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

          /* "ws_package/controllers/activity_controller.py":4080
 *                         for iv in day_intervals
 *                     )
 *                     if last_in_this_day:             # <<<<<<<<<<<<<<
 *                         stop_dt = (
 *                             force_stop_time
*/
        }

        /* "ws_package/controllers/activity_controller.py":4073
 *                                     logger.debug("Could not check activityLevel attribute: %s", e2)
 * 
 *                 if not is_sleep_interval:             # <<<<<<<<<<<<<<
 *                     last_in_this_day = any(
 *                         _dt_match(getattr(iv, 'start_time', None), getattr(last_interval, 'start_time', None))
*/
        goto __pyx_L189;
      }

      /* "ws_package/controllers/activity_controller.py":4090
 *                         logger.info("Last interval in this batch (stop click): setting payload 'stop' to %s", stop_value)
 *                 else:
 *                     logger.info("[SleepInterval] Skipping 'stop' timestamp for sleep interval (start=%s, end=%s)", last_interval.start_time, last_interval.end_time)             # <<<<<<<<<<<<<<
 * 
 *             if (
*/
      /*else*/ {
        __pyx_t_5 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4090, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4090, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4090, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_37 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 4090, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_37);
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_13))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_13);
          assert(__pyx_t_5);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[4] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_SleepInterval_Skipping_stop_tim, __pyx_t_6, __pyx_t_37};
          __pyx_t_14 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4090, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_14);
        }
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      }
      __pyx_L189:;

      /* "ws_package/controllers/activity_controller.py":4032
 *             stop_value = None
 *             stop_dt_for_intervals = None
 *             if last_interval is not None:             # <<<<<<<<<<<<<<
 *                 def _dt_match(a, b, tol=1.0):
 *                     if a is None or b is None:
*/
    }

    /* "ws_package/controllers/activity_controller.py":4093
 * 
 *             if (
 *                 stop_value is None             # <<<<<<<<<<<<<<
 *                 and force_stop_time is not None
 *                 and interval_payloads
*/
    __pyx_t_38 = (__pyx_cur_scope->__pyx_v_stop_value == Py_None);
    if (__pyx_t_38) {
    } else {
      __pyx_t_2 = __pyx_t_38;
      goto __pyx_L195_bool_binop_done;
    }

    /* "ws_package/controllers/activity_controller.py":4094
 *             if (
 *                 stop_value is None
 *                 and force_stop_time is not None             # <<<<<<<<<<<<<<
 *                 and interval_payloads
 *             ):
*/
    __pyx_t_38 = (__pyx_cur_scope->__pyx_v_force_stop_time != Py_None);
    if (__pyx_t_38) {
    } else {
      __pyx_t_2 = __pyx_t_38;
      goto __pyx_L195_bool_binop_done;
    }

    /* "ws_package/controllers/activity_controller.py":4095
 *                 stop_value is None
 *                 and force_stop_time is not None
 *                 and interval_payloads             # <<<<<<<<<<<<<<
 *             ):
 *                 stop_dt_for_intervals = force_stop_time.replace(microsecond=0)
*/
    {
      Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_interval_payloads);
      if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 4095, __pyx_L1_error)
      __pyx_t_38 = (__pyx_temp != 0);
    }

    __pyx_t_2 = __pyx_t_38;
    __pyx_L195_bool_binop_done:;

    /* "ws_package/controllers/activity_controller.py":4092
 *                     logger.info("[SleepInterval] Skipping 'stop' timestamp for sleep interval (start=%s, end=%s)", last_interval.start_time, last_interval.end_time)
 * 
 *             if (             # <<<<<<<<<<<<<<
 *                 stop_value is None
 *                 and force_stop_time is not None
*/
    if (__pyx_t_2) {

      /* "ws_package/controllers/activity_controller.py":4097
 *                 and interval_payloads
 *             ):
 *                 stop_dt_for_intervals = force_stop_time.replace(microsecond=0)             # <<<<<<<<<<<<<<
 *                 stop_value = stop_dt_for_intervals.strftime("%Y-%m-%d %H:%M:%S")
 *                 interval_payloads[-1]["to"] = stop_value
*/
      __pyx_t_13 = __pyx_cur_scope->__pyx_v_force_stop_time;
      __Pyx_INCREF(__pyx_t_13);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_13, NULL};
        __pyx_t_37 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 4097, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_37);
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_37, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 4097, __pyx_L1_error)
        __pyx_t_14 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_37);
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
        if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4097, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
      }
      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_stop_dt_for_intervals);
      __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_stop_dt_for_intervals, __pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_14);
      __pyx_t_14 = 0;

      /* "ws_package/controllers/activity_controller.py":4098
 *             ):
 *                 stop_dt_for_intervals = force_stop_time.replace(microsecond=0)
 *                 stop_value = stop_dt_for_intervals.strftime("%Y-%m-%d %H:%M:%S")             # <<<<<<<<<<<<<<
 *                 interval_payloads[-1]["to"] = stop_value
 *                 logger.info(
*/
      __pyx_t_37 = __pyx_cur_scope->__pyx_v_stop_dt_for_intervals;
      __Pyx_INCREF(__pyx_t_37);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_37, __pyx_mstate_global->__pyx_kp_u_Y_m_d_H_M_S};
        __pyx_t_14 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strftime, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
        if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4098, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
      }
      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_stop_value);
      __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_stop_value, __pyx_t_14);
      __Pyx_GIVEREF(__pyx_t_14);
      __pyx_t_14 = 0;

      /* "ws_package/controllers/activity_controller.py":4099
 *                 stop_dt_for_intervals = force_stop_time.replace(microsecond=0)
 *                 stop_value = stop_dt_for_intervals.strftime("%Y-%m-%d %H:%M:%S")
 *                 interval_payloads[-1]["to"] = stop_value             # <<<<<<<<<<<<<<
 *                 logger.info(
 *                     "Forced session close: setting payload stop and last interval 'to' to %s",
*/
      if (unlikely((PyObject_SetItem(__Pyx_PyList_GET_ITEM(__pyx_cur_scope->__pyx_v_interval_payloads, -1L), __pyx_mstate_global->__pyx_n_u_to, __pyx_cur_scope->__pyx_v_stop_value) < 0))) __PYX_ERR(0, 4099, __pyx_L1_error)

      /* "ws_package/controllers/activity_controller.py":4100
 *                 stop_value = stop_dt_for_intervals.strftime("%Y-%m-%d %H:%M:%S")
 *                 interval_payloads[-1]["to"] = stop_value
 *                 logger.info(             # <<<<<<<<<<<<<<
 *                     "Forced session close: setting payload stop and last interval 'to' to %s",
 *                     stop_value,
*/
      __pyx_t_37 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4100, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4100, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

      /* "ws_package/controllers/activity_controller.py":4102
 *                 logger.info(
 *                     "Forced session close: setting payload stop and last interval 'to' to %s",
 *                     stop_value,             # <<<<<<<<<<<<<<
 *                 )
 * 
*/
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_37 = PyMethod_GET_SELF(__pyx_t_6);
        assert(__pyx_t_37);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_37);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_37, __pyx_mstate_global->__pyx_kp_u_Forced_session_close_setting_pay, __pyx_cur_scope->__pyx_v_stop_value};
        __pyx_t_14 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4100, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_14);
      }
      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

      /* "ws_package/controllers/activity_controller.py":4092
 *                     logger.info("[SleepInterval] Skipping 'stop' timestamp for sleep interval (start=%s, end=%s)", last_interval.start_time, last_interval.end_time)
 * 
 *             if (             # <<<<<<<<<<<<<<
 *                 stop_value is None
 *                 and force_stop_time is not None
*/
    }

    /* "ws_package/controllers/activity_controller.py":4106
 * 
 *             payload = [{
 *                 "projectId": str(project_id),             # <<<<<<<<<<<<<<
 *                 "start": effective_start_time.strftime("%Y-%m-%d %H:%M:%S"),
 *                 "stop": stop_value,
*/
    __pyx_t_14 = __Pyx_PyDict_NewPresized(18); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4106, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_14);
    __pyx_t_6 = __Pyx_PyObject_Unicode(__pyx_cur_scope->__pyx_v_project_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4106, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_projectId, __pyx_t_6) < (0)) __PYX_ERR(0, 4106, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "ws_package/controllers/activity_controller.py":4107
 *             payload = [{
 *                 "projectId": str(project_id),
 *                 "start": effective_start_time.strftime("%Y-%m-%d %H:%M:%S"),             # <<<<<<<<<<<<<<
 *                 "stop": stop_value,
 *                 "selfi_id": None,
*/
    __pyx_t_37 = __pyx_cur_scope->__pyx_v_effective_start_time;
    __Pyx_INCREF(__pyx_t_37);
    __pyx_t_8 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_37, __pyx_mstate_global->__pyx_kp_u_Y_m_d_H_M_S};
      __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strftime, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4107, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    }
    if (PyDict_SetItem(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_start, __pyx_t_6) < (0)) __PYX_ERR(0, 4106, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "ws_package/controllers/activity_controller.py":4108
 *                 "projectId": str(project_id),
 *                 "start": effective_start_time.strftime("%Y-%m-%d %H:%M:%S"),
 *                 "stop": stop_value,             # <<<<<<<<<<<<<<
 *                 "selfi_id": None,
 *                "timezone": self._normalize_timezone(str(self.timezone_manager.local_timezone) if self.timezone_manager.local_timezone else str(self.get_system_timezone())),
*/
    if (PyDict_SetItem(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_stop, __pyx_cur_scope->__pyx_v_stop_value) < (0)) __PYX_ERR(0, 4106, __pyx_L1_error)

    /* "ws_package/controllers/activity_controller.py":4109
 *                 "start": effective_start_time.strftime("%Y-%m-%d %H:%M:%S"),
 *                 "stop": stop_value,
 *                 "selfi_id": None,             # <<<<<<<<<<<<<<
 *                "timezone": self._normalize_timezone(str(self.timezone_manager.local_timezone) if self.timezone_manager.local_timezone else str(self.get_system_timezone())),
 *                 "break_id": None,
*/
    if (PyDict_SetItem(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_selfi_id, Py_None) < (0)) __PYX_ERR(0, 4106, __pyx_L1_error)

    /* "ws_package/controllers/activity_controller.py":4110
 *                 "stop": stop_value,
 *                 "selfi_id": None,
 *                "timezone": self._normalize_timezone(str(self.timezone_manager.local_timezone) if self.timezone_manager.local_timezone else str(self.get_system_timezone())),             # <<<<<<<<<<<<<<
 *                 "break_id": None,
 *                 "deviceType": self.get_os_type_caps(),
*/
    __pyx_t_37 = __pyx_cur_scope->__pyx_v_self;
    __Pyx_INCREF(__pyx_t_37);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_timezone_manager); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4110, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_local_timezone); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4110, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 4110, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (__pyx_t_2) {
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_timezone_manager); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4110, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_local_timezone); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4110, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_7 = __Pyx_PyObject_Unicode(__pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4110, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_13 = __pyx_t_7;
      __pyx_t_7 = 0;
    } else {
      __pyx_t_5 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
        __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_system_timezone, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4110, __pyx_L1_error)
        __Pyx_GOTREF(__pyx_t_7);
      }
      __pyx_t_5 = __Pyx_PyObject_Unicode(__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4110, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_13 = __pyx_t_5;
      __pyx_t_5 = 0;
    }
    __pyx_t_8 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_37, __pyx_t_13};
      __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_normalize_timezone, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4110, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    }
    if (PyDict_SetItem(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_timezone, __pyx_t_6) < (0)) __PYX_ERR(0, 4106, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "ws_package/controllers/activity_controller.py":4111
 *                 "selfi_id": None,
 *                "timezone": self._normalize_timezone(str(self.timezone_manager.local_timezone) if self.timezone_manager.local_timezone else str(self.get_system_timezone())),
 *                 "break_id": None,             # <<<<<<<<<<<<<<
 *                 "deviceType": self.get_os_type_caps(),
 *                 "os_type": self.get_os_type_caps(),
*/
    if (PyDict_SetItem(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_break_id, Py_None) < (0)) __PYX_ERR(0, 4106, __pyx_L1_error)

    /* "ws_package/controllers/activity_controller.py":4112
 *                "timezone": self._normalize_timezone(str(self.timezone_manager.local_timezone) if self.timezone_manager.local_timezone else str(self.get_system_timezone())),
 *                 "break_id": None,
 *                 "deviceType": self.get_os_type_caps(),             # <<<<<<<<<<<<<<
 *                 "os_type": self.get_os_type_caps(),
 *                 "selfiVerification": True,
*/
    __pyx_t_13 = __pyx_cur_scope->__pyx_v_self;
    __Pyx_INCREF(__pyx_t_13);
    __pyx_t_8 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_13, NULL};
      __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type_caps, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4112, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    }
    if (PyDict_SetItem(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_deviceType, __pyx_t_6) < (0)) __PYX_ERR(0, 4106, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "ws_package/controllers/activity_controller.py":4113
 *                 "break_id": None,
 *                 "deviceType": self.get_os_type_caps(),
 *                 "os_type": self.get_os_type_caps(),             # <<<<<<<<<<<<<<
 *                 "selfiVerification": True,
 *                 "intervals": interval_payloads,
*/
    __pyx_t_13 = __pyx_cur_scope->__pyx_v_self;
    __Pyx_INCREF(__pyx_t_13);
    __pyx_t_8 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_13, NULL};
      __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type_caps, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4113, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    }
    if (PyDict_SetItem(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_os_type, __pyx_t_6) < (0)) __PYX_ERR(0, 4106, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "ws_package/controllers/activity_controller.py":4114
 *                 "deviceType": self.get_os_type_caps(),
 *                 "os_type": self.get_os_type_caps(),
 *                 "selfiVerification": True,             # <<<<<<<<<<<<<<
 *                 "intervals": interval_payloads,
 *                 "time_type": "1",
*/
    if (PyDict_SetItem(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_selfiVerification, Py_True) < (0)) __PYX_ERR(0, 4106, __pyx_L1_error)

    /* "ws_package/controllers/activity_controller.py":4115
 *                 "os_type": self.get_os_type_caps(),
 *                 "selfiVerification": True,
 *                 "intervals": interval_payloads,             # <<<<<<<<<<<<<<
 *                 "time_type": "1",
 *                 "interval_time": int(self.interval/60),
*/
    if (PyDict_SetItem(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_intervals, __pyx_cur_scope->__pyx_v_interval_payloads) < (0)) __PYX_ERR(0, 4106, __pyx_L1_error)
    if (PyDict_SetItem(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_time_type, __pyx_mstate_global->__pyx_kp_u_1) < (0)) __PYX_ERR(0, 4106, __pyx_L1_error)

    /* "ws_package/controllers/activity_controller.py":4117
 *                 "intervals": interval_payloads,
 *                 "time_type": "1",
 *                 "interval_time": int(self.interval/60),             # <<<<<<<<<<<<<<
 *                 "source_type": "4",
 *                 "org_id": str(org_id),
*/
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4117, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_13 = __Pyx_PyLong_TrueDivideObjC(__pyx_t_6, __pyx_mstate_global->__pyx_int_60, 60, 0, 0); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4117, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyNumber_Int(__pyx_t_13); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4117, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    if (PyDict_SetItem(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_interval_time, __pyx_t_6) < (0)) __PYX_ERR(0, 4106, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (PyDict_SetItem(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_source_type, __pyx_mstate_global->__pyx_kp_u_4) < (0)) __PYX_ERR(0, 4106, __pyx_L1_error)

    /* "ws_package/controllers/activity_controller.py":4119
 *                 "interval_time": int(self.interval/60),
 *                 "source_type": "4",
 *                 "org_id": str(org_id),             # <<<<<<<<<<<<<<
 *                 "todo_id": str(task_id) if task_id is not None else "0",
 *                 "deviceId": self.system_unique_id,
*/
    __pyx_t_6 = __Pyx_PyObject_Unicode(__pyx_cur_scope->__pyx_v_org_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4119, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_org_id, __pyx_t_6) < (0)) __PYX_ERR(0, 4106, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "ws_package/controllers/activity_controller.py":4120
 *                 "source_type": "4",
 *                 "org_id": str(org_id),
 *                 "todo_id": str(task_id) if task_id is not None else "0",             # <<<<<<<<<<<<<<
 *                 "deviceId": self.system_unique_id,
 *                 "ip_address": str(get_ip()),
*/
    __pyx_t_2 = (__pyx_cur_scope->__pyx_v_task_id != Py_None);
    if (__pyx_t_2) {
      __pyx_t_13 = __Pyx_PyObject_Unicode(__pyx_cur_scope->__pyx_v_task_id); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4120, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_6 = __pyx_t_13;
      __pyx_t_13 = 0;
    } else {
      __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_0);
      __pyx_t_6 = __pyx_mstate_global->__pyx_kp_u_0;
    }
    if (PyDict_SetItem(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_todo_id, __pyx_t_6) < (0)) __PYX_ERR(0, 4106, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "ws_package/controllers/activity_controller.py":4121
 *                 "org_id": str(org_id),
 *                 "todo_id": str(task_id) if task_id is not None else "0",
 *                 "deviceId": self.system_unique_id,             # <<<<<<<<<<<<<<
 *                 "ip_address": str(get_ip()),
 *                 "os_version": get_os_version()
*/
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_system_unique_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4121, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (PyDict_SetItem(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_deviceId, __pyx_t_6) < (0)) __PYX_ERR(0, 4106, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

    /* "ws_package/controllers/activity_controller.py":4122
 *                 "todo_id": str(task_id) if task_id is not None else "0",
 *                 "deviceId": self.system_unique_id,
 *                 "ip_address": str(get_ip()),             # <<<<<<<<<<<<<<
 *                 "os_version": get_os_version()
 *             }]
*/
    __pyx_t_13 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_37, __pyx_mstate_global->__pyx_n_u_get_ip); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 4122, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_37);
    __pyx_t_8 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_37))) {
      __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_37);
      assert(__pyx_t_13);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_37);
      __Pyx_INCREF(__pyx_t_13);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_37, __pyx__function);
      __pyx_t_8 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_13, NULL};
      __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_37, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4122, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
    }
    __pyx_t_37 = __Pyx_PyObject_Unicode(__pyx_t_6); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 4122, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_37);
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (PyDict_SetItem(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_ip_address, __pyx_t_37) < (0)) __PYX_ERR(0, 4106, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;

    /* "ws_package/controllers/activity_controller.py":4123
 *                 "deviceId": self.system_unique_id,
 *                 "ip_address": str(get_ip()),
 *                 "os_version": get_os_version()             # <<<<<<<<<<<<<<
 *             }]
 * 
*/
    __pyx_t_6 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_get_os_version); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4123, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_8 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_13))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_13);
      assert(__pyx_t_6);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
      __pyx_t_8 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
      __pyx_t_37 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 4123, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_37);
    }
    if (PyDict_SetItem(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_os_version, __pyx_t_37) < (0)) __PYX_ERR(0, 4106, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;

    /* "ws_package/controllers/activity_controller.py":4105
 *                 )
 * 
 *             payload = [{             # <<<<<<<<<<<<<<
 *                 "projectId": str(project_id),
 *                 "start": effective_start_time.strftime("%Y-%m-%d %H:%M:%S"),
*/
    __pyx_t_37 = PyList_New(1); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 4105, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_37);
    __Pyx_GIVEREF(__pyx_t_14);
    if (__Pyx_PyList_SET_ITEM(__pyx_t_37, 0, __pyx_t_14) != (0)) __PYX_ERR(0, 4105, __pyx_L1_error);
    __pyx_t_14 = 0;
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_payload);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_payload, ((PyObject*)__pyx_t_37));
    __Pyx_GIVEREF(__pyx_t_37);
    __pyx_t_37 = 0;

    /* "ws_package/controllers/activity_controller.py":4126
 *             }]
 * 
 *             logger.info("Generated payload for date %s with start time %s and %s intervals", target_date, effective_start_time.strftime('%Y-%m-%d %H:%M:%S'), len(day_intervals))             # <<<<<<<<<<<<<<
 *             # Clear segment start after using it so next payload uses normal day start
 *             if effective_start_time == self.current_segment_start_time:
*/
    __pyx_t_14 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4126, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_13);
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4126, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
    __pyx_t_5 = __pyx_cur_scope->__pyx_v_effective_start_time;
    __Pyx_INCREF(__pyx_t_5);
    __pyx_t_8 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Y_m_d_H_M_S};
      __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strftime, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4126, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_13);
    }
    __pyx_t_12 = PyObject_Length(__pyx_cur_scope->__pyx_v_day_intervals); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4126, __pyx_L1_error)
    __pyx_t_5 = PyLong_FromSsize_t(__pyx_t_12); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4126, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_8 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_6))) {
      __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_6);
      assert(__pyx_t_14);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_14);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
      __pyx_t_8 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[5] = {__pyx_t_14, __pyx_mstate_global->__pyx_kp_u_Generated_payload_for_date_s_wit, __pyx_cur_scope->__pyx_v_target_date, __pyx_t_13, __pyx_t_5};
      __pyx_t_37 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 4126, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_37);
    }
    __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;

    /* "ws_package/controllers/activity_controller.py":4128
 *             logger.info("Generated payload for date %s with start time %s and %s intervals", target_date, effective_start_time.strftime('%Y-%m-%d %H:%M:%S'), len(day_intervals))
 *             # Clear segment start after using it so next payload uses normal day start
 *             if effective_start_time == self.current_segment_start_time:             # <<<<<<<<<<<<<<
 *                 self.current_segment_start_time = None
 *             yield payload, day_intervals
*/
    __pyx_t_37 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_segment_start_time); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 4128, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_37);
    __pyx_t_6 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_effective_start_time, __pyx_t_37, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4128, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 4128, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_2) {

      /* "ws_package/controllers/activity_controller.py":4129
 *             # Clear segment start after using it so next payload uses normal day start
 *             if effective_start_time == self.current_segment_start_time:
 *                 self.current_segment_start_time = None             # <<<<<<<<<<<<<<
 *             yield payload, day_intervals
 * 
*/
      if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_segment_start_time, Py_None) < (0)) __PYX_ERR(0, 4129, __pyx_L1_error)

      /* "ws_package/controllers/activity_controller.py":4128
 *             logger.info("Generated payload for date %s with start time %s and %s intervals", target_date, effective_start_time.strftime('%Y-%m-%d %H:%M:%S'), len(day_intervals))
 *             # Clear segment start after using it so next payload uses normal day start
 *             if effective_start_time == self.current_segment_start_time:             # <<<<<<<<<<<<<<
 *                 self.current_segment_start_time = None
 *             yield payload, day_intervals
*/
    }

    /* "ws_package/controllers/activity_controller.py":4130
 *             if effective_start_time == self.current_segment_start_time:
 *                 self.current_segment_start_time = None
 *             yield payload, day_intervals             # <<<<<<<<<<<<<<
 * 
 *     async def delete_old_data_and_screenshots(self):
*/
    __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4130, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_payload);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_payload);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_cur_scope->__pyx_v_payload) != (0)) __PYX_ERR(0, 4130, __pyx_L1_error);
    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_day_intervals);
    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_day_intervals);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_cur_scope->__pyx_v_day_intervals) != (0)) __PYX_ERR(0, 4130, __pyx_L1_error);
    __pyx_r = __pyx_t_6;
    __pyx_t_6 = 0;
    __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
    __Pyx_XGIVEREF(__pyx_t_4);
    __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
    __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
    __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from async generator, yielding value */
    __pyx_generator->resume_label = 10;
    return __Pyx__PyAsyncGenValueWrapperNew(__pyx_r);
    __pyx_L199_resume_from_yield:;
    __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
    __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
    __pyx_cur_scope->__pyx_t_1 = 0;
    __Pyx_XGOTREF(__pyx_t_4);
    __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
    __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4130, __pyx_L1_error)
    __pyx_L8_continue:;
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":3836
 *             return False  # Fail-safe: if we can't check, assume no activity
 * 
 *     async def process_intervals_bulk(             # <<<<<<<<<<<<<<
 *         self,
 *         intervals,
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_33);
  __Pyx_XDECREF(__pyx_t_37);
  __Pyx_XDECREF(__pyx_t_40);
  __Pyx_XDECREF(__pyx_t_41);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(1);
    __Pyx_AddTraceback("process_intervals_bulk", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_151generator29(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":4132
 *             yield payload, day_intervals
 * 
 *     async def delete_old_data_and_screenshots(self):             # <<<<<<<<<<<<<<
 *         """
 *         Delete old data and screenshots older than 7 days.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_150delete_old_data_and_screenshots(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_149delete_old_data_and_screenshots, "\n        Delete old data and screenshots older than 7 days.\n        \n        FIXED: Separated file operations from database operations to prevent long lock holds.\n        Pattern: Read from DB (quick) -> Release lock -> Delete files (slow) -> Re-acquire lock -> Delete from DB (quick)\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_150delete_old_data_and_screenshots = {"delete_old_data_and_screenshots", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_150delete_old_data_and_screenshots, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_149delete_old_data_and_screenshots};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_150delete_old_data_and_screenshots(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[1] = {0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("delete_old_data_and_screenshots (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 4132, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4132, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "delete_old_data_and_screenshots", 0) < (0)) __PYX_ERR(0, 4132, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("delete_old_data_and_screenshots", 1, 1, 1, i); __PYX_ERR(0, 4132, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 1)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4132, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("delete_old_data_and_screenshots", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 4132, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.delete_old_data_and_screenshots", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_149delete_old_data_and_screenshots(__pyx_self, __pyx_v_self);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_149delete_old_data_and_screenshots(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("delete_old_data_and_screenshots", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 4132, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_151generator29, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[49]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_delete_old_data_and_screenshots, __pyx_mstate_global->__pyx_n_u_ActivityController_delete_old_da, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 4132, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.delete_old_data_and_screenshots", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_151generator29(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  size_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  __Pyx_PySendResult __pyx_t_19;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  Py_ssize_t __pyx_t_26;
  PyObject *(*__pyx_t_27)(PyObject *);
  int __pyx_t_28;
  int __pyx_t_29;
  int __pyx_t_30;
  char const *__pyx_t_31;
  PyObject *__pyx_t_32 = NULL;
  PyObject *__pyx_t_33 = NULL;
  PyObject *__pyx_t_34 = NULL;
  PyObject *__pyx_t_35 = NULL;
  PyObject *__pyx_t_36 = NULL;
  PyObject *__pyx_t_37 = NULL;
  PyObject *__pyx_t_38 = NULL;
  PyObject *__pyx_t_39 = NULL;
  char const *__pyx_t_40;
  char const *__pyx_t_41;
  char const *__pyx_t_42;
  char const *__pyx_t_43;
  char const *__pyx_t_44;
  char const *__pyx_t_45;
  PyObject *__pyx_t_46 = NULL;
  PyObject *__pyx_t_47 = NULL;
  PyObject *__pyx_t_48 = NULL;
  char const *__pyx_t_49;
  char const *__pyx_t_50;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("delete_old_data_and_screenshots", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L26_resume_from_await;
    case 2: goto __pyx_L42_resume_from_await;
    case 3: goto __pyx_L62_resume_from_await;
    case 4: goto __pyx_L63_resume_from_await;
    case 5: goto __pyx_L64_resume_from_await;
    case 6: goto __pyx_L201_resume_from_await;
    case 7: goto __pyx_L221_resume_from_await;
    case 8: goto __pyx_L222_resume_from_await;
    case 9: goto __pyx_L223_resume_from_await;
    case 10: goto __pyx_L224_resume_from_await;
    case 11: goto __pyx_L225_resume_from_await;
    case 12: goto __pyx_L228_resume_from_await;
    case 13: goto __pyx_L236_resume_from_await;
    case 14: goto __pyx_L244_resume_from_await;
    case 15: goto __pyx_L245_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 4132, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":4140
 *         """
 *         # Database operation timeout constant
 *         DB_OPERATION_TIMEOUT = 5.0             # <<<<<<<<<<<<<<
 * 
 *         if getattr(sys, 'frozen', False) and platform.system() == "Linux":  # Running as a PyInstaller EXE in linux
*/
  __pyx_cur_scope->__pyx_v_DB_OPERATION_TIMEOUT = 5.0;

  /* "ws_package/controllers/activity_controller.py":4142
 *         DB_OPERATION_TIMEOUT = 5.0
 * 
 *         if getattr(sys, 'frozen', False) and platform.system() == "Linux":  # Running as a PyInstaller EXE in linux             # <<<<<<<<<<<<<<
 *             script_path = Path(sys.executable).resolve()
 *             target_directory = script_path.parents[0] # Just one level up from the executable
*/
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_sys); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4142, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_GetAttr3(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_frozen, Py_False); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4142, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 4142, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  if (__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4142, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_system); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4142, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_7 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_6))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_6);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
    __pyx_t_7 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
    __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4142, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  }
  __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_Linux, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 4142, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = __pyx_t_4;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_1) {

    /* "ws_package/controllers/activity_controller.py":4143
 * 
 *         if getattr(sys, 'frozen', False) and platform.system() == "Linux":  # Running as a PyInstaller EXE in linux
 *             script_path = Path(sys.executable).resolve()             # <<<<<<<<<<<<<<
 *             target_directory = script_path.parents[0] # Just one level up from the executable
 *             target_directory_stealth = script_path.parents[1] # Two levels up from the executable
*/
    __pyx_t_5 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_Path); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4143, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_sys); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4143, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_executable); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4143, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_8);
      assert(__pyx_t_5);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_10};
      __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4143, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    }
    __pyx_t_6 = __pyx_t_2;
    __Pyx_INCREF(__pyx_t_6);
    __pyx_t_7 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
      __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_resolve, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4143, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_cur_scope->__pyx_v_script_path = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "ws_package/controllers/activity_controller.py":4144
 *         if getattr(sys, 'frozen', False) and platform.system() == "Linux":  # Running as a PyInstaller EXE in linux
 *             script_path = Path(sys.executable).resolve()
 *             target_directory = script_path.parents[0] # Just one level up from the executable             # <<<<<<<<<<<<<<
 *             target_directory_stealth = script_path.parents[1] # Two levels up from the executable
 *         elif getattr(sys, 'frozen', False) and platform.system() == "Windows":  # Running as a PyInstaller EXE in Windows
*/
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_script_path, __pyx_mstate_global->__pyx_n_u_parents); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4144, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_3, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4144, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_cur_scope->__pyx_v_target_directory = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "ws_package/controllers/activity_controller.py":4145
 *             script_path = Path(sys.executable).resolve()
 *             target_directory = script_path.parents[0] # Just one level up from the executable
 *             target_directory_stealth = script_path.parents[1] # Two levels up from the executable             # <<<<<<<<<<<<<<
 *         elif getattr(sys, 'frozen', False) and platform.system() == "Windows":  # Running as a PyInstaller EXE in Windows
 *             script_path = Path(sys.executable).resolve()
*/
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_script_path, __pyx_mstate_global->__pyx_n_u_parents); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4145, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4145, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_cur_scope->__pyx_v_target_directory_stealth = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "ws_package/controllers/activity_controller.py":4142
 *         DB_OPERATION_TIMEOUT = 5.0
 * 
 *         if getattr(sys, 'frozen', False) and platform.system() == "Linux":  # Running as a PyInstaller EXE in linux             # <<<<<<<<<<<<<<
 *             script_path = Path(sys.executable).resolve()
 *             target_directory = script_path.parents[0] # Just one level up from the executable
*/
    goto __pyx_L4;
  }

  /* "ws_package/controllers/activity_controller.py":4146
 *             target_directory = script_path.parents[0] # Just one level up from the executable
 *             target_directory_stealth = script_path.parents[1] # Two levels up from the executable
 *         elif getattr(sys, 'frozen', False) and platform.system() == "Windows":  # Running as a PyInstaller EXE in Windows             # <<<<<<<<<<<<<<
 *             script_path = Path(sys.executable).resolve()
 *             target_directoryw = script_path.parents[0]
*/
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_sys); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_GetAttr3(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_frozen, Py_False); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 4146, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_4) {
  } else {
    __pyx_t_1 = __pyx_t_4;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_3 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_system); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_t_7 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8);
    assert(__pyx_t_3);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
    __pyx_t_7 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
    __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4146, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
  }
  __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_Windows, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 4146, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_1 = __pyx_t_4;
  __pyx_L7_bool_binop_done:;
  if (__pyx_t_1) {

    /* "ws_package/controllers/activity_controller.py":4147
 *             target_directory_stealth = script_path.parents[1] # Two levels up from the executable
 *         elif getattr(sys, 'frozen', False) and platform.system() == "Windows":  # Running as a PyInstaller EXE in Windows
 *             script_path = Path(sys.executable).resolve()             # <<<<<<<<<<<<<<
 *             target_directoryw = script_path.parents[0]
 *         elif sys.platform == 'darwin':
*/
    __pyx_t_6 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_Path); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4147, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_sys); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4147, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_executable); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4147, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_10);
      assert(__pyx_t_6);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_9};
      __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4147, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __pyx_t_8 = __pyx_t_3;
    __Pyx_INCREF(__pyx_t_8);
    __pyx_t_7 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
      __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_resolve, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4147, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_GIVEREF(__pyx_t_2);
    __pyx_cur_scope->__pyx_v_script_path = __pyx_t_2;
    __pyx_t_2 = 0;

    /* "ws_package/controllers/activity_controller.py":4148
 *         elif getattr(sys, 'frozen', False) and platform.system() == "Windows":  # Running as a PyInstaller EXE in Windows
 *             script_path = Path(sys.executable).resolve()
 *             target_directoryw = script_path.parents[0]             # <<<<<<<<<<<<<<
 *         elif sys.platform == 'darwin':
 *             target_directory_mac = Path.home() / "Library/Application Support/Workstatus"
*/
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_script_path, __pyx_mstate_global->__pyx_n_u_parents); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4148, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4148, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_cur_scope->__pyx_v_target_directoryw = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "ws_package/controllers/activity_controller.py":4146
 *             target_directory = script_path.parents[0] # Just one level up from the executable
 *             target_directory_stealth = script_path.parents[1] # Two levels up from the executable
 *         elif getattr(sys, 'frozen', False) and platform.system() == "Windows":  # Running as a PyInstaller EXE in Windows             # <<<<<<<<<<<<<<
 *             script_path = Path(sys.executable).resolve()
 *             target_directoryw = script_path.parents[0]
*/
    goto __pyx_L4;
  }

  /* "ws_package/controllers/activity_controller.py":4149
 *             script_path = Path(sys.executable).resolve()
 *             target_directoryw = script_path.parents[0]
 *         elif sys.platform == 'darwin':             # <<<<<<<<<<<<<<
 *             target_directory_mac = Path.home() / "Library/Application Support/Workstatus"
 *         else:  # DEV MODE
*/
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_sys); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_darwin, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 4149, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__pyx_t_1) {

    /* "ws_package/controllers/activity_controller.py":4150
 *             target_directoryw = script_path.parents[0]
 *         elif sys.platform == 'darwin':
 *             target_directory_mac = Path.home() / "Library/Application Support/Workstatus"             # <<<<<<<<<<<<<<
 *         else:  # DEV MODE
 *             script_path = Path(__file__).resolve()
*/
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_Path); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4150, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_home); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4150, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
      __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4150, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    }
    __pyx_t_10 = __Pyx_PyNumber_Divide(__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Library_Application_Support_Work); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4150, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_GIVEREF(__pyx_t_10);
    __pyx_cur_scope->__pyx_v_target_directory_mac = __pyx_t_10;
    __pyx_t_10 = 0;

    /* "ws_package/controllers/activity_controller.py":4149
 *             script_path = Path(sys.executable).resolve()
 *             target_directoryw = script_path.parents[0]
 *         elif sys.platform == 'darwin':             # <<<<<<<<<<<<<<
 *             target_directory_mac = Path.home() / "Library/Application Support/Workstatus"
 *         else:  # DEV MODE
*/
    goto __pyx_L4;
  }

  /* "ws_package/controllers/activity_controller.py":4152
 *             target_directory_mac = Path.home() / "Library/Application Support/Workstatus"
 *         else:  # DEV MODE
 *             script_path = Path(__file__).resolve()             # <<<<<<<<<<<<<<
 *             target_directory = f"{script_path.parents[3]}/workstatus"
 *             target_directory_stealth = f"{target_directory}/workstatus/"
*/
  /*else*/ {
    __pyx_t_8 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_Path); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4152, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_file); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4152, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_9))) {
      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9);
      assert(__pyx_t_8);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
      __pyx_t_7 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_t_6};
      __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4152, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __pyx_t_2 = __pyx_t_3;
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_7 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
      __pyx_t_10 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_resolve, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4152, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_10);
    }
    __Pyx_GIVEREF(__pyx_t_10);
    __pyx_cur_scope->__pyx_v_script_path = __pyx_t_10;
    __pyx_t_10 = 0;

    /* "ws_package/controllers/activity_controller.py":4153
 *         else:  # DEV MODE
 *             script_path = Path(__file__).resolve()
 *             target_directory = f"{script_path.parents[3]}/workstatus"             # <<<<<<<<<<<<<<
 *             target_directory_stealth = f"{target_directory}/workstatus/"
 *         logger.info("Starting deletion of old data and screenshots.")
*/
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_script_path, __pyx_mstate_global->__pyx_n_u_parents); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4153, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_10, 3, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4153, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __pyx_t_10 = __Pyx_PyObject_FormatSimple(__pyx_t_3, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4153, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __pyx_t_3 = __Pyx_PyUnicode_Concat__Pyx_ReferenceSharing_OwnStrongReferenceInPlace(__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_workstatus); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4153, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_GIVEREF(__pyx_t_3);
    __pyx_cur_scope->__pyx_v_target_directory = __pyx_t_3;
    __pyx_t_3 = 0;

    /* "ws_package/controllers/activity_controller.py":4154
 *             script_path = Path(__file__).resolve()
 *             target_directory = f"{script_path.parents[3]}/workstatus"
 *             target_directory_stealth = f"{target_directory}/workstatus/"             # <<<<<<<<<<<<<<
 *         logger.info("Starting deletion of old data and screenshots.")
 * 
*/
    __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_target_directory, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __pyx_t_10 = __Pyx_PyUnicode_Concat__Pyx_ReferenceSharing_OwnStrongReferenceInPlace(__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_workstatus_2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4154, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_GIVEREF(__pyx_t_10);
    __pyx_cur_scope->__pyx_v_target_directory_stealth = __pyx_t_10;
    __pyx_t_10 = 0;
  }
  __pyx_L4:;

  /* "ws_package/controllers/activity_controller.py":4155
 *             target_directory = f"{script_path.parents[3]}/workstatus"
 *             target_directory_stealth = f"{target_directory}/workstatus/"
 *         logger.info("Starting deletion of old data and screenshots.")             # <<<<<<<<<<<<<<
 * 
 *         try:
*/
  __pyx_t_3 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4155, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4155, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_7 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_9))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
    assert(__pyx_t_3);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
    __pyx_t_7 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Starting_deletion_of_old_data_an};
    __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4155, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
  }
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

  /* "ws_package/controllers/activity_controller.py":4157
 *         logger.info("Starting deletion of old data and screenshots.")
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             seven_days_ago = datetime.datetime.now() - datetime.timedelta(days=7)
 * 
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
    __Pyx_XGOTREF(__pyx_t_11);
    __Pyx_XGOTREF(__pyx_t_12);
    __Pyx_XGOTREF(__pyx_t_13);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":4158
 * 
 *         try:
 *             seven_days_ago = datetime.datetime.now() - datetime.timedelta(days=7)             # <<<<<<<<<<<<<<
 * 
 *             # STEP 1: Get list of screenshots to delete (QUICK, inside lock)
*/
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4158, __pyx_L9_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4158, __pyx_L9_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_9 = __pyx_t_2;
      __Pyx_INCREF(__pyx_t_9);
      __pyx_t_7 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_9, NULL};
        __pyx_t_10 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4158, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_10);
      }
      __pyx_t_9 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4158, __pyx_L9_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_timedelta); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4158, __pyx_L9_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_7 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_6);
        assert(__pyx_t_9);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
        __pyx_t_7 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_9, NULL};
        __pyx_t_3 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4158, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_3);
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_days, __pyx_mstate_global->__pyx_int_7, __pyx_t_3, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 4158, __pyx_L9_error)
        __pyx_t_2 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_3);
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4158, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_2);
      }
      __pyx_t_6 = PyNumber_Subtract(__pyx_t_10, __pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4158, __pyx_L9_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_cur_scope->__pyx_v_seven_days_ago = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":4161
 * 
 *             # STEP 1: Get list of screenshots to delete (QUICK, inside lock)
 *             screenshots_to_delete = []             # <<<<<<<<<<<<<<
 *             with db_lock_manager.write_lock():
 *                 async with async_session() as session:
*/
      __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4161, __pyx_L9_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_cur_scope->__pyx_v_screenshots_to_delete = ((PyObject*)__pyx_t_6);
      __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":4162
 *             # STEP 1: Get list of screenshots to delete (QUICK, inside lock)
 *             screenshots_to_delete = []
 *             with db_lock_manager.write_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     screenshot_query = select(Screenshots).where(Screenshots.timestamp < seven_days_ago)
*/
      /*with:*/ {
        __pyx_t_2 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4162, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_write_lock); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4162, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
          assert(__pyx_t_2);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
          __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4162, __pyx_L9_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __pyx_t_14 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4162, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_2 = NULL;
        __pyx_t_10 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4162, __pyx_L15_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (likely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_10);
          assert(__pyx_t_2);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
          __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4162, __pyx_L15_error)
          __Pyx_GOTREF(__pyx_t_3);
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        /*try:*/ {
          {
            __Pyx_ExceptionSave(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
            __Pyx_XGOTREF(__pyx_t_15);
            __Pyx_XGOTREF(__pyx_t_16);
            __Pyx_XGOTREF(__pyx_t_17);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":4163
 *             screenshots_to_delete = []
 *             with db_lock_manager.write_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     screenshot_query = select(Screenshots).where(Screenshots.timestamp < seven_days_ago)
 *                     try:
*/
              /*with:*/ {
                __pyx_t_3 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4163, __pyx_L19_error)
                __Pyx_GOTREF(__pyx_t_10);
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_10))) {
                  __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10);
                  assert(__pyx_t_3);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
                  __Pyx_INCREF(__pyx_t_3);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
                  __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4163, __pyx_L19_error)
                  __Pyx_GOTREF(__pyx_t_6);
                }
                __pyx_t_18 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4163, __pyx_L19_error)
                __Pyx_GOTREF(__pyx_t_18);
                __pyx_t_3 = NULL;
                __pyx_t_2 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4163, __pyx_L25_error)
                __Pyx_GOTREF(__pyx_t_2);
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (likely(PyMethod_Check(__pyx_t_2))) {
                  __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
                  assert(__pyx_t_3);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
                  __Pyx_INCREF(__pyx_t_3);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
                  __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                  if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4163, __pyx_L25_error)
                  __Pyx_GOTREF(__pyx_t_10);
                }
                __pyx_t_19 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_10, &__pyx_r);
                __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                if (likely(__pyx_t_19 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_6);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
                  __Pyx_XGIVEREF(__pyx_t_11);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_11;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_t_14);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_14;
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_15;
                  __Pyx_XGIVEREF(__pyx_t_16);
                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_16;
                  __Pyx_XGIVEREF(__pyx_t_17);
                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_17;
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_18;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 1;
                  return __pyx_r;
                  __pyx_L26_resume_from_await:;
                  __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_6);
                  __pyx_t_11 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_11);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  __pyx_t_14 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_14);
                  __pyx_t_15 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = 0;
                  __Pyx_XGOTREF(__pyx_t_15);
                  __pyx_t_16 = __pyx_cur_scope->__pyx_t_6;
                  __pyx_cur_scope->__pyx_t_6 = 0;
                  __Pyx_XGOTREF(__pyx_t_16);
                  __pyx_t_17 = __pyx_cur_scope->__pyx_t_7;
                  __pyx_cur_scope->__pyx_t_7 = 0;
                  __Pyx_XGOTREF(__pyx_t_17);
                  __pyx_t_18 = __pyx_cur_scope->__pyx_t_8;
                  __pyx_cur_scope->__pyx_t_8 = 0;
                  __Pyx_XGOTREF(__pyx_t_18);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4163, __pyx_L25_error)
                  __pyx_t_10 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_10);
                } else if (likely(__pyx_t_19 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __pyx_t_10 = __pyx_r; __pyx_r = NULL;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 4163, __pyx_L25_error)
                }
                __pyx_t_2 = __pyx_t_10;
                __pyx_t_10 = 0;
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                /*try:*/ {
                  {
                    __Pyx_ExceptionSave(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
                    __Pyx_XGOTREF(__pyx_t_20);
                    __Pyx_XGOTREF(__pyx_t_21);
                    __Pyx_XGOTREF(__pyx_t_22);
                    /*try:*/ {
                      __Pyx_GIVEREF(__pyx_t_2);
                      __pyx_cur_scope->__pyx_v_session = __pyx_t_2;
                      __pyx_t_2 = 0;

                      /* "ws_package/controllers/activity_controller.py":4164
 *             with db_lock_manager.write_lock():
 *                 async with async_session() as session:
 *                     screenshot_query = select(Screenshots).where(Screenshots.timestamp < seven_days_ago)             # <<<<<<<<<<<<<<
 *                     try:
 *                         result = await asyncio.wait_for(
*/
                      __pyx_t_3 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4164, __pyx_L30_error)
                      __Pyx_GOTREF(__pyx_t_9);
                      __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_Screenshots); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4164, __pyx_L30_error)
                      __Pyx_GOTREF(__pyx_t_8);
                      __pyx_t_7 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_9))) {
                        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
                        assert(__pyx_t_3);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
                        __Pyx_INCREF(__pyx_t_3);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
                        __pyx_t_7 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_8};
                        __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                        if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4164, __pyx_L30_error)
                        __Pyx_GOTREF(__pyx_t_10);
                      }
                      __pyx_t_6 = __pyx_t_10;
                      __Pyx_INCREF(__pyx_t_6);
                      __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_Screenshots); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4164, __pyx_L30_error)
                      __Pyx_GOTREF(__pyx_t_9);
                      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_timestamp); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4164, __pyx_L30_error)
                      __Pyx_GOTREF(__pyx_t_8);
                      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                      __pyx_t_9 = PyObject_RichCompare(__pyx_t_8, __pyx_cur_scope->__pyx_v_seven_days_ago, Py_LT); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4164, __pyx_L30_error)
                      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                      __pyx_t_7 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_9};
                        __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4164, __pyx_L30_error)
                        __Pyx_GOTREF(__pyx_t_2);
                      }
                      __Pyx_GIVEREF(__pyx_t_2);
                      __pyx_cur_scope->__pyx_v_screenshot_query = __pyx_t_2;
                      __pyx_t_2 = 0;

                      /* "ws_package/controllers/activity_controller.py":4165
 *                 async with async_session() as session:
 *                     screenshot_query = select(Screenshots).where(Screenshots.timestamp < seven_days_ago)
 *                     try:             # <<<<<<<<<<<<<<
 *                         result = await asyncio.wait_for(
 *                             session.execute(screenshot_query),
*/
                      {
                        __Pyx_ExceptionSave(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25);
                        __Pyx_XGOTREF(__pyx_t_23);
                        __Pyx_XGOTREF(__pyx_t_24);
                        __Pyx_XGOTREF(__pyx_t_25);
                        /*try:*/ {

                          /* "ws_package/controllers/activity_controller.py":4166
 *                     screenshot_query = select(Screenshots).where(Screenshots.timestamp < seven_days_ago)
 *                     try:
 *                         result = await asyncio.wait_for(             # <<<<<<<<<<<<<<
 *                             session.execute(screenshot_query),
 *                             timeout=DB_OPERATION_TIMEOUT
*/
                          __pyx_t_10 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4166, __pyx_L36_error)
                          __Pyx_GOTREF(__pyx_t_9);
                          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_wait_for); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4166, __pyx_L36_error)
                          __Pyx_GOTREF(__pyx_t_6);
                          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

                          /* "ws_package/controllers/activity_controller.py":4167
 *                     try:
 *                         result = await asyncio.wait_for(
 *                             session.execute(screenshot_query),             # <<<<<<<<<<<<<<
 *                             timeout=DB_OPERATION_TIMEOUT
 *                         )
*/
                          __pyx_t_8 = __pyx_cur_scope->__pyx_v_session;
                          __Pyx_INCREF(__pyx_t_8);
                          __pyx_t_7 = 0;
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_cur_scope->__pyx_v_screenshot_query};
                            __pyx_t_9 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                            if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4167, __pyx_L36_error)
                            __Pyx_GOTREF(__pyx_t_9);
                          }

                          /* "ws_package/controllers/activity_controller.py":4168
 *                         result = await asyncio.wait_for(
 *                             session.execute(screenshot_query),
 *                             timeout=DB_OPERATION_TIMEOUT             # <<<<<<<<<<<<<<
 *                         )
 *                         old_screenshots = result.scalars().all()
*/
                          __pyx_t_8 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_DB_OPERATION_TIMEOUT); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4168, __pyx_L36_error)
                          __Pyx_GOTREF(__pyx_t_8);
                          __pyx_t_7 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_6))) {
                            __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6);
                            assert(__pyx_t_10);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                            __Pyx_INCREF(__pyx_t_10);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                            __pyx_t_7 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_10, __pyx_t_9};
                            __pyx_t_3 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4166, __pyx_L36_error)
                            __Pyx_GOTREF(__pyx_t_3);
                            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_timeout, __pyx_t_8, __pyx_t_3, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 4166, __pyx_L36_error)
                            __pyx_t_2 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_3);
                            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4166, __pyx_L36_error)
                            __Pyx_GOTREF(__pyx_t_2);
                          }
                          __pyx_t_19 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_2, &__pyx_r);
                          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                          if (likely(__pyx_t_19 == PYGEN_NEXT)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_XGIVEREF(__pyx_t_11);
                            __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                            __Pyx_XGIVEREF(__pyx_t_12);
                            __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                            __Pyx_XGIVEREF(__pyx_t_13);
                            __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                            __Pyx_XGIVEREF(__pyx_t_14);
                            __pyx_cur_scope->__pyx_t_3 = __pyx_t_14;
                            __Pyx_XGIVEREF(__pyx_t_15);
                            __pyx_cur_scope->__pyx_t_4 = __pyx_t_15;
                            __Pyx_XGIVEREF(__pyx_t_16);
                            __pyx_cur_scope->__pyx_t_5 = __pyx_t_16;
                            __Pyx_XGIVEREF(__pyx_t_17);
                            __pyx_cur_scope->__pyx_t_6 = __pyx_t_17;
                            __Pyx_XGIVEREF(__pyx_t_18);
                            __pyx_cur_scope->__pyx_t_7 = __pyx_t_18;
                            __Pyx_XGIVEREF(__pyx_t_20);
                            __pyx_cur_scope->__pyx_t_8 = __pyx_t_20;
                            __Pyx_XGIVEREF(__pyx_t_21);
                            __pyx_cur_scope->__pyx_t_9 = __pyx_t_21;
                            __Pyx_XGIVEREF(__pyx_t_22);
                            __pyx_cur_scope->__pyx_t_10 = __pyx_t_22;
                            __Pyx_XGIVEREF(__pyx_t_23);
                            __pyx_cur_scope->__pyx_t_11 = __pyx_t_23;
                            __Pyx_XGIVEREF(__pyx_t_24);
                            __pyx_cur_scope->__pyx_t_12 = __pyx_t_24;
                            __Pyx_XGIVEREF(__pyx_t_25);
                            __pyx_cur_scope->__pyx_t_13 = __pyx_t_25;
                            __Pyx_XGIVEREF(__pyx_r);
                            __Pyx_RefNannyFinishContext();
                            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                            /* return from generator, awaiting value */
                            __pyx_generator->resume_label = 2;
                            return __pyx_r;
                            __pyx_L42_resume_from_await:;
                            __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                            __pyx_cur_scope->__pyx_t_0 = 0;
                            __Pyx_XGOTREF(__pyx_t_11);
                            __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                            __pyx_cur_scope->__pyx_t_1 = 0;
                            __Pyx_XGOTREF(__pyx_t_12);
                            __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                            __pyx_cur_scope->__pyx_t_2 = 0;
                            __Pyx_XGOTREF(__pyx_t_13);
                            __pyx_t_14 = __pyx_cur_scope->__pyx_t_3;
                            __pyx_cur_scope->__pyx_t_3 = 0;
                            __Pyx_XGOTREF(__pyx_t_14);
                            __pyx_t_15 = __pyx_cur_scope->__pyx_t_4;
                            __pyx_cur_scope->__pyx_t_4 = 0;
                            __Pyx_XGOTREF(__pyx_t_15);
                            __pyx_t_16 = __pyx_cur_scope->__pyx_t_5;
                            __pyx_cur_scope->__pyx_t_5 = 0;
                            __Pyx_XGOTREF(__pyx_t_16);
                            __pyx_t_17 = __pyx_cur_scope->__pyx_t_6;
                            __pyx_cur_scope->__pyx_t_6 = 0;
                            __Pyx_XGOTREF(__pyx_t_17);
                            __pyx_t_18 = __pyx_cur_scope->__pyx_t_7;
                            __pyx_cur_scope->__pyx_t_7 = 0;
                            __Pyx_XGOTREF(__pyx_t_18);
                            __pyx_t_20 = __pyx_cur_scope->__pyx_t_8;
                            __pyx_cur_scope->__pyx_t_8 = 0;
                            __Pyx_XGOTREF(__pyx_t_20);
                            __pyx_t_21 = __pyx_cur_scope->__pyx_t_9;
                            __pyx_cur_scope->__pyx_t_9 = 0;
                            __Pyx_XGOTREF(__pyx_t_21);
                            __pyx_t_22 = __pyx_cur_scope->__pyx_t_10;
                            __pyx_cur_scope->__pyx_t_10 = 0;
                            __Pyx_XGOTREF(__pyx_t_22);
                            __pyx_t_23 = __pyx_cur_scope->__pyx_t_11;
                            __pyx_cur_scope->__pyx_t_11 = 0;
                            __Pyx_XGOTREF(__pyx_t_23);
                            __pyx_t_24 = __pyx_cur_scope->__pyx_t_12;
                            __pyx_cur_scope->__pyx_t_12 = 0;
                            __Pyx_XGOTREF(__pyx_t_24);
                            __pyx_t_25 = __pyx_cur_scope->__pyx_t_13;
                            __pyx_cur_scope->__pyx_t_13 = 0;
                            __Pyx_XGOTREF(__pyx_t_25);
                            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4166, __pyx_L36_error)
                            __pyx_t_2 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_2);
                          } else if (likely(__pyx_t_19 == PYGEN_RETURN)) {
                            __Pyx_GOTREF(__pyx_r);
                            __pyx_t_2 = __pyx_r; __pyx_r = NULL;
                          } else {
                            __Pyx_XGOTREF(__pyx_r);
                            __PYX_ERR(0, 4166, __pyx_L36_error)
                          }
                          __Pyx_GIVEREF(__pyx_t_2);
                          __pyx_cur_scope->__pyx_v_result = __pyx_t_2;
                          __pyx_t_2 = 0;

                          /* "ws_package/controllers/activity_controller.py":4170
 *                             timeout=DB_OPERATION_TIMEOUT
 *                         )
 *                         old_screenshots = result.scalars().all()             # <<<<<<<<<<<<<<
 * 
 *                         # Extract screenshot data while session is still open
*/
                          __pyx_t_8 = __pyx_cur_scope->__pyx_v_result;
                          __Pyx_INCREF(__pyx_t_8);
                          __pyx_t_7 = 0;
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
                            __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalars, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4170, __pyx_L36_error)
                            __Pyx_GOTREF(__pyx_t_3);
                          }
                          __pyx_t_6 = __pyx_t_3;
                          __Pyx_INCREF(__pyx_t_6);
                          __pyx_t_7 = 0;
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
                            __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_all, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4170, __pyx_L36_error)
                            __Pyx_GOTREF(__pyx_t_2);
                          }
                          __Pyx_GIVEREF(__pyx_t_2);
                          __pyx_cur_scope->__pyx_v_old_screenshots = __pyx_t_2;
                          __pyx_t_2 = 0;

                          /* "ws_package/controllers/activity_controller.py":4173
 * 
 *                         # Extract screenshot data while session is still open
 *                         for screenshot in old_screenshots:             # <<<<<<<<<<<<<<
 *                             screenshots_to_delete.append({
 *                                 'id': screenshot.id,
*/
                          if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_old_screenshots)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_old_screenshots)) {
                            __pyx_t_2 = __pyx_cur_scope->__pyx_v_old_screenshots; __Pyx_INCREF(__pyx_t_2);
                            __pyx_t_26 = 0;
                            __pyx_t_27 = NULL;
                          } else {
                            __pyx_t_26 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_old_screenshots); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4173, __pyx_L36_error)
                            __Pyx_GOTREF(__pyx_t_2);
                            __pyx_t_27 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 4173, __pyx_L36_error)
                          }
                          for (;;) {
                            if (likely(!__pyx_t_27)) {
                              if (likely(PyList_CheckExact(__pyx_t_2))) {
                                {
                                  Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2);
                                  #if !CYTHON_ASSUME_SAFE_SIZE
                                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4173, __pyx_L36_error)
                                  #endif
                                  if (__pyx_t_26 >= __pyx_temp) break;
                                }
                                __pyx_t_3 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_2, __pyx_t_26, __Pyx_ReferenceSharing_OwnStrongReference);
                                ++__pyx_t_26;
                              } else {
                                {
                                  Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2);
                                  #if !CYTHON_ASSUME_SAFE_SIZE
                                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4173, __pyx_L36_error)
                                  #endif
                                  if (__pyx_t_26 >= __pyx_temp) break;
                                }
                                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                                __pyx_t_3 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_26));
                                #else
                                __pyx_t_3 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_26);
                                #endif
                                ++__pyx_t_26;
                              }
                              if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4173, __pyx_L36_error)
                            } else {
                              __pyx_t_3 = __pyx_t_27(__pyx_t_2);
                              if (unlikely(!__pyx_t_3)) {
                                PyObject* exc_type = PyErr_Occurred();
                                if (exc_type) {
                                  if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 4173, __pyx_L36_error)
                                  PyErr_Clear();
                                }
                                break;
                              }
                            }
                            __Pyx_GOTREF(__pyx_t_3);
                            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_screenshot);
                            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_screenshot, __pyx_t_3);
                            __Pyx_GIVEREF(__pyx_t_3);
                            __pyx_t_3 = 0;

                            /* "ws_package/controllers/activity_controller.py":4175
 *                         for screenshot in old_screenshots:
 *                             screenshots_to_delete.append({
 *                                 'id': screenshot.id,             # <<<<<<<<<<<<<<
 *                                 'file_location': screenshot.file_location,
 *                                 'file_name': screenshot.file_name
*/
                            __pyx_t_3 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4175, __pyx_L36_error)
                            __Pyx_GOTREF(__pyx_t_3);
                            __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_screenshot, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4175, __pyx_L36_error)
                            __Pyx_GOTREF(__pyx_t_6);
                            if (PyDict_SetItem(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_id, __pyx_t_6) < (0)) __PYX_ERR(0, 4175, __pyx_L36_error)
                            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

                            /* "ws_package/controllers/activity_controller.py":4176
 *                             screenshots_to_delete.append({
 *                                 'id': screenshot.id,
 *                                 'file_location': screenshot.file_location,             # <<<<<<<<<<<<<<
 *                                 'file_name': screenshot.file_name
 *                             })
*/
                            __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_screenshot, __pyx_mstate_global->__pyx_n_u_file_location); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4176, __pyx_L36_error)
                            __Pyx_GOTREF(__pyx_t_6);
                            if (PyDict_SetItem(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_file_location, __pyx_t_6) < (0)) __PYX_ERR(0, 4175, __pyx_L36_error)
                            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

                            /* "ws_package/controllers/activity_controller.py":4177
 *                                 'id': screenshot.id,
 *                                 'file_location': screenshot.file_location,
 *                                 'file_name': screenshot.file_name             # <<<<<<<<<<<<<<
 *                             })
 *                     except asyncio.TimeoutError:
*/
                            __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_screenshot, __pyx_mstate_global->__pyx_n_u_file_name); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4177, __pyx_L36_error)
                            __Pyx_GOTREF(__pyx_t_6);
                            if (PyDict_SetItem(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_file_name, __pyx_t_6) < (0)) __PYX_ERR(0, 4175, __pyx_L36_error)
                            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

                            /* "ws_package/controllers/activity_controller.py":4174
 *                         # Extract screenshot data while session is still open
 *                         for screenshot in old_screenshots:
 *                             screenshots_to_delete.append({             # <<<<<<<<<<<<<<
 *                                 'id': screenshot.id,
 *                                 'file_location': screenshot.file_location,
*/
                            __pyx_t_28 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_screenshots_to_delete, __pyx_t_3); if (unlikely(__pyx_t_28 == ((int)-1))) __PYX_ERR(0, 4174, __pyx_L36_error)
                            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                            /* "ws_package/controllers/activity_controller.py":4173
 * 
 *                         # Extract screenshot data while session is still open
 *                         for screenshot in old_screenshots:             # <<<<<<<<<<<<<<
 *                             screenshots_to_delete.append({
 *                                 'id': screenshot.id,
*/
                          }
                          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

                          /* "ws_package/controllers/activity_controller.py":4165
 *                 async with async_session() as session:
 *                     screenshot_query = select(Screenshots).where(Screenshots.timestamp < seven_days_ago)
 *                     try:             # <<<<<<<<<<<<<<
 *                         result = await asyncio.wait_for(
 *                             session.execute(screenshot_query),
*/
                        }
                        __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                        goto __pyx_L41_try_end;
                        __pyx_L36_error:;
                        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

                        /* "ws_package/controllers/activity_controller.py":4179
 *                                 'file_name': screenshot.file_name
 *                             })
 *                     except asyncio.TimeoutError:             # <<<<<<<<<<<<<<
 *                         logger.error("Database query timed out after %ss while getting old screenshots", DB_OPERATION_TIMEOUT)
 *                         return
*/
                        __Pyx_ErrFetch(&__pyx_t_2, &__pyx_t_3, &__pyx_t_6);
                        __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4179, __pyx_L38_except_error)
                        __Pyx_GOTREF(__pyx_t_8);
                        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_TimeoutError); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4179, __pyx_L38_except_error)
                        __Pyx_GOTREF(__pyx_t_9);
                        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                        __pyx_t_29 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_2, __pyx_t_9);
                        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                        __Pyx_ErrRestore(__pyx_t_2, __pyx_t_3, __pyx_t_6);
                        __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_6 = 0;
                        if (__pyx_t_29) {
                          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.delete_old_data_and_screenshots", __pyx_clineno, __pyx_lineno, __pyx_filename);
                          if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_3, &__pyx_t_2) < 0) __PYX_ERR(0, 4179, __pyx_L38_except_error)
                          __Pyx_XGOTREF(__pyx_t_6);
                          __Pyx_XGOTREF(__pyx_t_3);
                          __Pyx_XGOTREF(__pyx_t_2);

                          /* "ws_package/controllers/activity_controller.py":4180
 *                             })
 *                     except asyncio.TimeoutError:
 *                         logger.error("Database query timed out after %ss while getting old screenshots", DB_OPERATION_TIMEOUT)             # <<<<<<<<<<<<<<
 *                         return
 *                     except Exception as e:
*/
                          __pyx_t_8 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4180, __pyx_L38_except_error)
                          __Pyx_GOTREF(__pyx_t_10);
                          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4180, __pyx_L38_except_error)
                          __Pyx_GOTREF(__pyx_t_5);
                          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                          __pyx_t_10 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_DB_OPERATION_TIMEOUT); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4180, __pyx_L38_except_error)
                          __Pyx_GOTREF(__pyx_t_10);
                          __pyx_t_7 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_5))) {
                            __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5);
                            assert(__pyx_t_8);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                            __Pyx_INCREF(__pyx_t_8);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                            __pyx_t_7 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[3] = {__pyx_t_8, __pyx_mstate_global->__pyx_kp_u_Database_query_timed_out_after_s_4, __pyx_t_10};
                            __pyx_t_9 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                            if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4180, __pyx_L38_except_error)
                            __Pyx_GOTREF(__pyx_t_9);
                          }
                          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

                          /* "ws_package/controllers/activity_controller.py":4181
 *                     except asyncio.TimeoutError:
 *                         logger.error("Database query timed out after %ss while getting old screenshots", DB_OPERATION_TIMEOUT)
 *                         return             # <<<<<<<<<<<<<<
 *                     except Exception as e:
 *                         logger.error("Error getting old screenshots: %s", e)
*/
                          __Pyx_XDECREF(__pyx_r);
                          __pyx_r = Py_None; __Pyx_INCREF(Py_None);
                          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                          goto __pyx_L39_except_return;
                        }

                        /* "ws_package/controllers/activity_controller.py":4182
 *                         logger.error("Database query timed out after %ss while getting old screenshots", DB_OPERATION_TIMEOUT)
 *                         return
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error getting old screenshots: %s", e)
 *                         return
*/
                        __pyx_t_29 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                        if (__pyx_t_29) {
                          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.delete_old_data_and_screenshots", __pyx_clineno, __pyx_lineno, __pyx_filename);
                          if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_6) < 0) __PYX_ERR(0, 4182, __pyx_L38_except_error)
                          __Pyx_XGOTREF(__pyx_t_2);
                          __Pyx_XGOTREF(__pyx_t_3);
                          __Pyx_XGOTREF(__pyx_t_6);
                          __Pyx_INCREF(__pyx_t_3);
                          __Pyx_GIVEREF(__pyx_t_3);
                          __pyx_cur_scope->__pyx_v_e = __pyx_t_3;
                          /*try:*/ {

                            /* "ws_package/controllers/activity_controller.py":4183
 *                         return
 *                     except Exception as e:
 *                         logger.error("Error getting old screenshots: %s", e)             # <<<<<<<<<<<<<<
 *                         return
 * 
*/
                            __pyx_t_5 = NULL;
                            __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4183, __pyx_L53_error)
                            __Pyx_GOTREF(__pyx_t_10);
                            __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4183, __pyx_L53_error)
                            __Pyx_GOTREF(__pyx_t_8);
                            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                            __pyx_t_7 = 1;
                            #if CYTHON_UNPACK_METHODS
                            if (unlikely(PyMethod_Check(__pyx_t_8))) {
                              __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_8);
                              assert(__pyx_t_5);
                              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
                              __Pyx_INCREF(__pyx_t_5);
                              __Pyx_INCREF(__pyx__function);
                              __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
                              __pyx_t_7 = 0;
                            }
                            #endif
                            {
                              PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Error_getting_old_screenshots_s, __pyx_cur_scope->__pyx_v_e};
                              __pyx_t_9 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                              if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4183, __pyx_L53_error)
                              __Pyx_GOTREF(__pyx_t_9);
                            }
                            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

                            /* "ws_package/controllers/activity_controller.py":4184
 *                     except Exception as e:
 *                         logger.error("Error getting old screenshots: %s", e)
 *                         return             # <<<<<<<<<<<<<<
 * 
 *             # STEP 2: Delete files OUTSIDE lock (SLOW I/O operations - don't block database)
*/
                            __Pyx_XDECREF(__pyx_r);
                            __pyx_r = Py_None; __Pyx_INCREF(Py_None);
                            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                            goto __pyx_L52_return;
                          }

                          /* "ws_package/controllers/activity_controller.py":4182
 *                         logger.error("Database query timed out after %ss while getting old screenshots", DB_OPERATION_TIMEOUT)
 *                         return
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error getting old screenshots: %s", e)
 *                         return
*/
                          /*finally:*/ {
                            __pyx_L53_error:;
                            /*exception exit:*/{
                              __Pyx_PyThreadState_assign
                              __pyx_t_32 = 0; __pyx_t_33 = 0; __pyx_t_34 = 0; __pyx_t_35 = 0; __pyx_t_36 = 0; __pyx_t_37 = 0;
                              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                              __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                              __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                               __Pyx_ExceptionSwap(&__pyx_t_35, &__pyx_t_36, &__pyx_t_37);
                              if ( unlikely(__Pyx_GetException(&__pyx_t_32, &__pyx_t_33, &__pyx_t_34) < 0)) __Pyx_ErrFetch(&__pyx_t_32, &__pyx_t_33, &__pyx_t_34);
                              __Pyx_XGOTREF(__pyx_t_32);
                              __Pyx_XGOTREF(__pyx_t_33);
                              __Pyx_XGOTREF(__pyx_t_34);
                              __Pyx_XGOTREF(__pyx_t_35);
                              __Pyx_XGOTREF(__pyx_t_36);
                              __Pyx_XGOTREF(__pyx_t_37);
                              __pyx_t_29 = __pyx_lineno; __pyx_t_30 = __pyx_clineno; __pyx_t_31 = __pyx_filename;
                              {
                                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                              }
                              __Pyx_XGIVEREF(__pyx_t_35);
                              __Pyx_XGIVEREF(__pyx_t_36);
                              __Pyx_XGIVEREF(__pyx_t_37);
                              __Pyx_ExceptionReset(__pyx_t_35, __pyx_t_36, __pyx_t_37);
                              __Pyx_XGIVEREF(__pyx_t_32);
                              __Pyx_XGIVEREF(__pyx_t_33);
                              __Pyx_XGIVEREF(__pyx_t_34);
                              __Pyx_ErrRestore(__pyx_t_32, __pyx_t_33, __pyx_t_34);
                              __pyx_t_32 = 0; __pyx_t_33 = 0; __pyx_t_34 = 0; __pyx_t_35 = 0; __pyx_t_36 = 0; __pyx_t_37 = 0;
                              __pyx_lineno = __pyx_t_29; __pyx_clineno = __pyx_t_30; __pyx_filename = __pyx_t_31;
                              goto __pyx_L38_except_error;
                            }
                            __pyx_L52_return: {
                              __pyx_t_37 = __pyx_r;
                              __pyx_r = 0;
                              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                              __pyx_r = __pyx_t_37;
                              __pyx_t_37 = 0;
                              goto __pyx_L39_except_return;
                            }
                          }
                        }
                        goto __pyx_L38_except_error;

                        /* "ws_package/controllers/activity_controller.py":4165
 *                 async with async_session() as session:
 *                     screenshot_query = select(Screenshots).where(Screenshots.timestamp < seven_days_ago)
 *                     try:             # <<<<<<<<<<<<<<
 *                         result = await asyncio.wait_for(
 *                             session.execute(screenshot_query),
*/
                        __pyx_L38_except_error:;
                        __Pyx_XGIVEREF(__pyx_t_23);
                        __Pyx_XGIVEREF(__pyx_t_24);
                        __Pyx_XGIVEREF(__pyx_t_25);
                        __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_24, __pyx_t_25);
                        goto __pyx_L30_error;
                        __pyx_L39_except_return:;
                        __Pyx_XGIVEREF(__pyx_t_23);
                        __Pyx_XGIVEREF(__pyx_t_24);
                        __Pyx_XGIVEREF(__pyx_t_25);
                        __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_24, __pyx_t_25);
                        goto __pyx_L34_try_return;
                        __pyx_L41_try_end:;
                      }

                      /* "ws_package/controllers/activity_controller.py":4163
 *             screenshots_to_delete = []
 *             with db_lock_manager.write_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     screenshot_query = select(Screenshots).where(Screenshots.timestamp < seven_days_ago)
 *                     try:
*/
                    }
                    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                    goto __pyx_L35_try_end;
                    __pyx_L30_error:;
                    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                    /*except:*/ {
                      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.delete_old_data_and_screenshots", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_3, &__pyx_t_2) < 0) __PYX_ERR(0, 4163, __pyx_L32_except_error)
                      __Pyx_XGOTREF(__pyx_t_6);
                      __Pyx_XGOTREF(__pyx_t_3);
                      __Pyx_XGOTREF(__pyx_t_2);
                      __pyx_t_9 = PyTuple_Pack(3, __pyx_t_6, __pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4163, __pyx_L32_except_error)
                      __Pyx_GOTREF(__pyx_t_9);
                      __pyx_t_25 = __Pyx_PyObject_Call(__pyx_t_18, __pyx_t_9, NULL);
                      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                      if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 4163, __pyx_L32_except_error)
                      __Pyx_GOTREF(__pyx_t_25);
                      __pyx_t_19 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_25, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                      if (likely(__pyx_t_19 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_6);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_6;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_t_20);
                        __pyx_cur_scope->__pyx_t_11 = __pyx_t_20;
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __pyx_cur_scope->__pyx_t_12 = __pyx_t_21;
                        __Pyx_XGIVEREF(__pyx_t_22);
                        __pyx_cur_scope->__pyx_t_13 = __pyx_t_22;
                        __Pyx_XGIVEREF(__pyx_t_25);
                        __pyx_cur_scope->__pyx_t_14 = __pyx_t_25;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_SwapException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 3;
                        return __pyx_r;
                        __pyx_L62_resume_from_await:;
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_6 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_6);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        __pyx_t_20 = __pyx_cur_scope->__pyx_t_11;
                        __pyx_cur_scope->__pyx_t_11 = 0;
                        __Pyx_XGOTREF(__pyx_t_20);
                        __pyx_t_21 = __pyx_cur_scope->__pyx_t_12;
                        __pyx_cur_scope->__pyx_t_12 = 0;
                        __Pyx_XGOTREF(__pyx_t_21);
                        __pyx_t_22 = __pyx_cur_scope->__pyx_t_13;
                        __pyx_cur_scope->__pyx_t_13 = 0;
                        __Pyx_XGOTREF(__pyx_t_22);
                        __pyx_t_25 = __pyx_cur_scope->__pyx_t_14;
                        __pyx_cur_scope->__pyx_t_14 = 0;
                        __Pyx_XGOTREF(__pyx_t_25);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4163, __pyx_L32_except_error)
                        __pyx_t_9 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_9);
                      } else if (likely(__pyx_t_19 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_9 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 4163, __pyx_L32_except_error)
                      }
                      __pyx_t_25 = __pyx_t_9;
                      __pyx_t_9 = 0;
                      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_25);
                      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                      if (__pyx_t_1 < (0)) __PYX_ERR(0, 4163, __pyx_L32_except_error)
                      __pyx_t_4 = (!__pyx_t_1);
                      if (unlikely(__pyx_t_4)) {
                        __Pyx_GIVEREF(__pyx_t_6);
                        __Pyx_GIVEREF(__pyx_t_3);
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __Pyx_ErrRestoreWithState(__pyx_t_6, __pyx_t_3, __pyx_t_2);
                        __pyx_t_6 = 0;  __pyx_t_3 = 0;  __pyx_t_2 = 0; 
                        __PYX_ERR(0, 4163, __pyx_L32_except_error)
                      }
                      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                      goto __pyx_L31_exception_handled;
                    }
                    __pyx_L32_except_error:;
                    __Pyx_XGIVEREF(__pyx_t_20);
                    __Pyx_XGIVEREF(__pyx_t_21);
                    __Pyx_XGIVEREF(__pyx_t_22);
                    __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22);
                    goto __pyx_L19_error;
                    __pyx_L34_try_return:;
                    __Pyx_XGIVEREF(__pyx_t_20);
                    __Pyx_XGIVEREF(__pyx_t_21);
                    __Pyx_XGIVEREF(__pyx_t_22);
                    __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22);
                    goto __pyx_L27_return;
                    __pyx_L31_exception_handled:;
                    __Pyx_XGIVEREF(__pyx_t_20);
                    __Pyx_XGIVEREF(__pyx_t_21);
                    __Pyx_XGIVEREF(__pyx_t_22);
                    __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22);
                    __pyx_L35_try_end:;
                  }
                }
                /*finally:*/ {
                  /*normal exit:*/{
                    if (__pyx_t_18) {
                      __pyx_t_22 = __Pyx_PyObject_Call(__pyx_t_18, __pyx_mstate_global->__pyx_tuple[7], NULL);
                      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                      if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 4163, __pyx_L19_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __pyx_t_19 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_22, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                      if (likely(__pyx_t_19 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_t_22);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_22;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 4;
                        return __pyx_r;
                        __pyx_L63_resume_from_await:;
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        __pyx_t_22 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_22);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4163, __pyx_L19_error)
                        __pyx_t_2 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_2);
                      } else if (likely(__pyx_t_19 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_2 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 4163, __pyx_L19_error)
                      }
                      __pyx_t_22 = __pyx_t_2;
                      __pyx_t_2 = 0;
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                    }
                    goto __pyx_L29;
                  }
                  __pyx_L27_return: {
                    __pyx_t_22 = __pyx_r;
                    __pyx_r = 0;
                    if (__pyx_t_18) {
                      __pyx_t_21 = __Pyx_PyObject_Call(__pyx_t_18, __pyx_mstate_global->__pyx_tuple[7], NULL);
                      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                      if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 4163, __pyx_L19_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __pyx_t_19 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_21, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                      if (likely(__pyx_t_19 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_21;
                        __Pyx_XGIVEREF(__pyx_t_22);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_22;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 5;
                        return __pyx_r;
                        __pyx_L64_resume_from_await:;
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        __pyx_t_21 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_21);
                        __pyx_t_22 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_22);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4163, __pyx_L19_error)
                        __pyx_t_2 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_2);
                      } else if (likely(__pyx_t_19 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_2 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 4163, __pyx_L19_error)
                      }
                      __pyx_t_21 = __pyx_t_2;
                      __pyx_t_2 = 0;
                      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                    }
                    __pyx_r = __pyx_t_22;
                    __pyx_t_22 = 0;
                    goto __pyx_L23_try_return;
                  }
                  __pyx_L29:;
                }
                goto __pyx_L65;
                __pyx_L25_error:;
                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                goto __pyx_L19_error;
                __pyx_L65:;
              }

              /* "ws_package/controllers/activity_controller.py":4162
 *             # STEP 1: Get list of screenshots to delete (QUICK, inside lock)
 *             screenshots_to_delete = []
 *             with db_lock_manager.write_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     screenshot_query = select(Screenshots).where(Screenshots.timestamp < seven_days_ago)
*/
            }
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
            __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
            goto __pyx_L24_try_end;
            __pyx_L19_error:;
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
            /*except:*/ {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.delete_old_data_and_screenshots", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_6) < 0) __PYX_ERR(0, 4162, __pyx_L21_except_error)
              __Pyx_XGOTREF(__pyx_t_2);
              __Pyx_XGOTREF(__pyx_t_3);
              __Pyx_XGOTREF(__pyx_t_6);
              __pyx_t_9 = PyTuple_Pack(3, __pyx_t_2, __pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4162, __pyx_L21_except_error)
              __Pyx_GOTREF(__pyx_t_9);
              __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_9, NULL);
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
              if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4162, __pyx_L21_except_error)
              __Pyx_GOTREF(__pyx_t_18);
              __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_18);
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
              if (__pyx_t_4 < (0)) __PYX_ERR(0, 4162, __pyx_L21_except_error)
              __pyx_t_1 = (!__pyx_t_4);
              if (unlikely(__pyx_t_1)) {
                __Pyx_GIVEREF(__pyx_t_2);
                __Pyx_GIVEREF(__pyx_t_3);
                __Pyx_XGIVEREF(__pyx_t_6);
                __Pyx_ErrRestoreWithState(__pyx_t_2, __pyx_t_3, __pyx_t_6);
                __pyx_t_2 = 0;  __pyx_t_3 = 0;  __pyx_t_6 = 0; 
                __PYX_ERR(0, 4162, __pyx_L21_except_error)
              }
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              goto __pyx_L20_exception_handled;
            }
            __pyx_L21_except_error:;
            __Pyx_XGIVEREF(__pyx_t_15);
            __Pyx_XGIVEREF(__pyx_t_16);
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
            goto __pyx_L9_error;
            __pyx_L23_try_return:;
            __Pyx_XGIVEREF(__pyx_t_15);
            __Pyx_XGIVEREF(__pyx_t_16);
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
            goto __pyx_L16_return;
            __pyx_L20_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_15);
            __Pyx_XGIVEREF(__pyx_t_16);
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
            __pyx_L24_try_end:;
          }
        }
        /*finally:*/ {
          /*normal exit:*/{
            if (__pyx_t_14) {
              __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_mstate_global->__pyx_tuple[7], NULL);
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4162, __pyx_L9_error)
              __Pyx_GOTREF(__pyx_t_17);
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            }
            goto __pyx_L18;
          }
          __pyx_L16_return: {
            __pyx_t_17 = __pyx_r;
            __pyx_r = 0;
            if (__pyx_t_14) {
              __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_mstate_global->__pyx_tuple[7], NULL);
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 4162, __pyx_L9_error)
              __Pyx_GOTREF(__pyx_t_16);
              __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
            }
            __pyx_r = __pyx_t_17;
            __pyx_t_17 = 0;
            goto __pyx_L13_try_return;
          }
          __pyx_L18:;
        }
        goto __pyx_L69;
        __pyx_L15_error:;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        goto __pyx_L9_error;
        __pyx_L69:;
      }

      /* "ws_package/controllers/activity_controller.py":4187
 * 
 *             # STEP 2: Delete files OUTSIDE lock (SLOW I/O operations - don't block database)
 *             if screenshots_to_delete:             # <<<<<<<<<<<<<<
 *                 logger.info("Deleting %s screenshot files...", len(screenshots_to_delete))
 *                 for idx, screenshot_data in enumerate(screenshots_to_delete):
*/
      {
        Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_screenshots_to_delete);
        if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 4187, __pyx_L9_error)
        __pyx_t_1 = (__pyx_temp != 0);
      }

      if (__pyx_t_1) {

        /* "ws_package/controllers/activity_controller.py":4188
 *             # STEP 2: Delete files OUTSIDE lock (SLOW I/O operations - don't block database)
 *             if screenshots_to_delete:
 *                 logger.info("Deleting %s screenshot files...", len(screenshots_to_delete))             # <<<<<<<<<<<<<<
 *                 for idx, screenshot_data in enumerate(screenshots_to_delete):
 *                     file_location = screenshot_data['file_location']
*/
        __pyx_t_3 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4188, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4188, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_26 = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_screenshots_to_delete); if (unlikely(__pyx_t_26 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4188, __pyx_L9_error)
        __pyx_t_2 = PyLong_FromSsize_t(__pyx_t_26); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4188, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
          assert(__pyx_t_3);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Deleting_s_screenshot_files, __pyx_t_2};
          __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4188, __pyx_L9_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "ws_package/controllers/activity_controller.py":4189
 *             if screenshots_to_delete:
 *                 logger.info("Deleting %s screenshot files...", len(screenshots_to_delete))
 *                 for idx, screenshot_data in enumerate(screenshots_to_delete):             # <<<<<<<<<<<<<<
 *                     file_location = screenshot_data['file_location']
 *                     file_name = screenshot_data['file_name']
*/
        __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
        __pyx_t_6 = __pyx_mstate_global->__pyx_int_0;
        __pyx_t_9 = __pyx_cur_scope->__pyx_v_screenshots_to_delete; __Pyx_INCREF(__pyx_t_9);
        __pyx_t_26 = 0;
        for (;;) {
          {
            Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_9);
            #if !CYTHON_ASSUME_SAFE_SIZE
            if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4189, __pyx_L9_error)
            #endif
            if (__pyx_t_26 >= __pyx_temp) break;
          }
          __pyx_t_2 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_9, __pyx_t_26, __Pyx_ReferenceSharing_OwnStrongReference);
          ++__pyx_t_26;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4189, __pyx_L9_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_screenshot_data);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_screenshot_data, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __pyx_t_2 = 0;
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_idx);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_idx, __pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_6);
          __pyx_t_2 = __Pyx_PyLong_AddObjC(__pyx_t_6, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4189, __pyx_L9_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_6);
          __pyx_t_6 = __pyx_t_2;
          __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":4190
 *                 logger.info("Deleting %s screenshot files...", len(screenshots_to_delete))
 *                 for idx, screenshot_data in enumerate(screenshots_to_delete):
 *                     file_location = screenshot_data['file_location']             # <<<<<<<<<<<<<<
 *                     file_name = screenshot_data['file_name']
 * 
*/
          __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_cur_scope->__pyx_v_screenshot_data, __pyx_mstate_global->__pyx_n_u_file_location); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4190, __pyx_L9_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_file_location);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_file_location, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":4191
 *                 for idx, screenshot_data in enumerate(screenshots_to_delete):
 *                     file_location = screenshot_data['file_location']
 *                     file_name = screenshot_data['file_name']             # <<<<<<<<<<<<<<
 * 
 *                     try:
*/
          __pyx_t_2 = __Pyx_PyObject_Dict_GetItem(__pyx_cur_scope->__pyx_v_screenshot_data, __pyx_mstate_global->__pyx_n_u_file_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4191, __pyx_L9_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_file_name);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_file_name, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":4193
 *                     file_name = screenshot_data['file_name']
 * 
 *                     try:             # <<<<<<<<<<<<<<
 *                         if platform.system() == "Linux":
 *                             try:
*/
          {
            __Pyx_ExceptionSave(&__pyx_t_14, &__pyx_t_17, &__pyx_t_16);
            __Pyx_XGOTREF(__pyx_t_14);
            __Pyx_XGOTREF(__pyx_t_17);
            __Pyx_XGOTREF(__pyx_t_16);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":4194
 * 
 *                     try:
 *                         if platform.system() == "Linux":             # <<<<<<<<<<<<<<
 *                             try:
 *                                 self.screenshot_controller.delete_screenshot(
*/
              __pyx_t_3 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4194, __pyx_L73_error)
              __Pyx_GOTREF(__pyx_t_8);
              __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_system); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4194, __pyx_L73_error)
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_5))) {
                __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
                assert(__pyx_t_3);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                __Pyx_INCREF(__pyx_t_3);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
                __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4194, __pyx_L73_error)
                __Pyx_GOTREF(__pyx_t_2);
              }
              __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_Linux, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 4194, __pyx_L73_error)
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              if (__pyx_t_1) {

                /* "ws_package/controllers/activity_controller.py":4195
 *                     try:
 *                         if platform.system() == "Linux":
 *                             try:             # <<<<<<<<<<<<<<
 *                                 self.screenshot_controller.delete_screenshot(
 *                                     file_location.split("/")[1],
*/
                {
                  __Pyx_ExceptionSave(&__pyx_t_15, &__pyx_t_18, &__pyx_t_22);
                  __Pyx_XGOTREF(__pyx_t_15);
                  __Pyx_XGOTREF(__pyx_t_18);
                  __Pyx_XGOTREF(__pyx_t_22);
                  /*try:*/ {

                    /* "ws_package/controllers/activity_controller.py":4196
 *                         if platform.system() == "Linux":
 *                             try:
 *                                 self.screenshot_controller.delete_screenshot(             # <<<<<<<<<<<<<<
 *                                     file_location.split("/")[1],
 *                                     f"{target_directory_stealth}/screenshots"
*/
                    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4196, __pyx_L82_error)
                    __Pyx_GOTREF(__pyx_t_3);
                    __pyx_t_5 = __pyx_t_3;
                    __Pyx_INCREF(__pyx_t_5);

                    /* "ws_package/controllers/activity_controller.py":4197
 *                             try:
 *                                 self.screenshot_controller.delete_screenshot(
 *                                     file_location.split("/")[1],             # <<<<<<<<<<<<<<
 *                                     f"{target_directory_stealth}/screenshots"
 *                                 )
*/
                    __pyx_t_10 = __pyx_cur_scope->__pyx_v_file_location;
                    __Pyx_INCREF(__pyx_t_10);
                    __pyx_t_7 = 0;
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u__9};
                      __pyx_t_8 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_split, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                      if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4197, __pyx_L82_error)
                      __Pyx_GOTREF(__pyx_t_8);
                    }
                    __pyx_t_10 = __Pyx_GetItemInt(__pyx_t_8, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4197, __pyx_L82_error)
                    __Pyx_GOTREF(__pyx_t_10);
                    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

                    /* "ws_package/controllers/activity_controller.py":4198
 *                                 self.screenshot_controller.delete_screenshot(
 *                                     file_location.split("/")[1],
 *                                     f"{target_directory_stealth}/screenshots"             # <<<<<<<<<<<<<<
 *                                 )
 *                             except Exception as e:
*/
                    if (unlikely(!__pyx_cur_scope->__pyx_v_target_directory_stealth)) { __Pyx_RaiseUnboundLocalError("target_directory_stealth"); __PYX_ERR(0, 4198, __pyx_L82_error) }
                    __pyx_t_8 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_target_directory_stealth, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4198, __pyx_L82_error)
                    __Pyx_GOTREF(__pyx_t_8);
                    __pyx_t_38 = __Pyx_PyUnicode_Concat__Pyx_ReferenceSharing_OwnStrongReferenceInPlace(__pyx_t_8, __pyx_mstate_global->__pyx_kp_u_screenshots_2); if (unlikely(!__pyx_t_38)) __PYX_ERR(0, 4198, __pyx_L82_error)
                    __Pyx_GOTREF(__pyx_t_38);
                    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                    __pyx_t_7 = 0;
                    {
                      PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_t_10, __pyx_t_38};
                      __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_delete_screenshot, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                      __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0;
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4196, __pyx_L82_error)
                      __Pyx_GOTREF(__pyx_t_2);
                    }
                    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

                    /* "ws_package/controllers/activity_controller.py":4195
 *                     try:
 *                         if platform.system() == "Linux":
 *                             try:             # <<<<<<<<<<<<<<
 *                                 self.screenshot_controller.delete_screenshot(
 *                                     file_location.split("/")[1],
*/
                  }
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                  __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                  goto __pyx_L89_try_end;
                  __pyx_L82_error:;
                  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

                  /* "ws_package/controllers/activity_controller.py":4200
 *                                     f"{target_directory_stealth}/screenshots"
 *                                 )
 *                             except Exception as e:             # <<<<<<<<<<<<<<
 *                                 logger.error("Error deleting screenshot: %s in %s/screenshots", e, target_directory_stealth)
 *                             try:
*/
                  __pyx_t_30 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                  if (__pyx_t_30) {
                    __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.delete_old_data_and_screenshots", __pyx_clineno, __pyx_lineno, __pyx_filename);
                    if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_38) < 0) __PYX_ERR(0, 4200, __pyx_L84_except_error)
                    __Pyx_XGOTREF(__pyx_t_2);
                    __Pyx_XGOTREF(__pyx_t_3);
                    __Pyx_XGOTREF(__pyx_t_38);
                    __Pyx_INCREF(__pyx_t_3);
                    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_3);
                    __Pyx_GIVEREF(__pyx_t_3);
                    /*try:*/ {

                      /* "ws_package/controllers/activity_controller.py":4201
 *                                 )
 *                             except Exception as e:
 *                                 logger.error("Error deleting screenshot: %s in %s/screenshots", e, target_directory_stealth)             # <<<<<<<<<<<<<<
 *                             try:
 *                                 self.screenshot_controller.delete_screenshot(
*/
                      __pyx_t_5 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4201, __pyx_L95_error)
                      __Pyx_GOTREF(__pyx_t_8);
                      __pyx_t_39 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 4201, __pyx_L95_error)
                      __Pyx_GOTREF(__pyx_t_39);
                      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                      if (unlikely(!__pyx_cur_scope->__pyx_v_target_directory_stealth)) { __Pyx_RaiseUnboundLocalError("target_directory_stealth"); __PYX_ERR(0, 4201, __pyx_L95_error) }
                      __pyx_t_7 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_39))) {
                        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_39);
                        assert(__pyx_t_5);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_39);
                        __Pyx_INCREF(__pyx_t_5);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_39, __pyx__function);
                        __pyx_t_7 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[4] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Error_deleting_screenshot_s_in_s, __pyx_cur_scope->__pyx_v_e, __pyx_cur_scope->__pyx_v_target_directory_stealth};
                        __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_39, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                        __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                        if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4201, __pyx_L95_error)
                        __Pyx_GOTREF(__pyx_t_10);
                      }
                      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                    }

                    /* "ws_package/controllers/activity_controller.py":4200
 *                                     f"{target_directory_stealth}/screenshots"
 *                                 )
 *                             except Exception as e:             # <<<<<<<<<<<<<<
 *                                 logger.error("Error deleting screenshot: %s in %s/screenshots", e, target_directory_stealth)
 *                             try:
*/
                    /*finally:*/ {
                      /*normal exit:*/{
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                        __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                        goto __pyx_L96;
                      }
                      __pyx_L95_error:;
                      /*exception exit:*/{
                        __Pyx_PyThreadState_assign
                        __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_t_37 = 0;
                        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                        __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                         __Pyx_ExceptionSwap(&__pyx_t_24, &__pyx_t_23, &__pyx_t_37);
                        if ( unlikely(__Pyx_GetException(&__pyx_t_21, &__pyx_t_20, &__pyx_t_25) < 0)) __Pyx_ErrFetch(&__pyx_t_21, &__pyx_t_20, &__pyx_t_25);
                        __Pyx_XGOTREF(__pyx_t_21);
                        __Pyx_XGOTREF(__pyx_t_20);
                        __Pyx_XGOTREF(__pyx_t_25);
                        __Pyx_XGOTREF(__pyx_t_24);
                        __Pyx_XGOTREF(__pyx_t_23);
                        __Pyx_XGOTREF(__pyx_t_37);
                        __pyx_t_30 = __pyx_lineno; __pyx_t_29 = __pyx_clineno; __pyx_t_40 = __pyx_filename;
                        {
                          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                        }
                        __Pyx_XGIVEREF(__pyx_t_24);
                        __Pyx_XGIVEREF(__pyx_t_23);
                        __Pyx_XGIVEREF(__pyx_t_37);
                        __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_23, __pyx_t_37);
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __Pyx_XGIVEREF(__pyx_t_20);
                        __Pyx_XGIVEREF(__pyx_t_25);
                        __Pyx_ErrRestore(__pyx_t_21, __pyx_t_20, __pyx_t_25);
                        __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_t_37 = 0;
                        __pyx_lineno = __pyx_t_30; __pyx_clineno = __pyx_t_29; __pyx_filename = __pyx_t_40;
                        goto __pyx_L84_except_error;
                      }
                      __pyx_L96:;
                    }
                    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                    goto __pyx_L83_exception_handled;
                  }
                  goto __pyx_L84_except_error;

                  /* "ws_package/controllers/activity_controller.py":4195
 *                     try:
 *                         if platform.system() == "Linux":
 *                             try:             # <<<<<<<<<<<<<<
 *                                 self.screenshot_controller.delete_screenshot(
 *                                     file_location.split("/")[1],
*/
                  __pyx_L84_except_error:;
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __Pyx_XGIVEREF(__pyx_t_22);
                  __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_18, __pyx_t_22);
                  goto __pyx_L73_error;
                  __pyx_L83_exception_handled:;
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __Pyx_XGIVEREF(__pyx_t_22);
                  __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_18, __pyx_t_22);
                  __pyx_L89_try_end:;
                }

                /* "ws_package/controllers/activity_controller.py":4202
 *                             except Exception as e:
 *                                 logger.error("Error deleting screenshot: %s in %s/screenshots", e, target_directory_stealth)
 *                             try:             # <<<<<<<<<<<<<<
 *                                 self.screenshot_controller.delete_screenshot(
 *                                     file_location.split("/")[1],
*/
                {
                  __Pyx_ExceptionSave(&__pyx_t_22, &__pyx_t_18, &__pyx_t_15);
                  __Pyx_XGOTREF(__pyx_t_22);
                  __Pyx_XGOTREF(__pyx_t_18);
                  __Pyx_XGOTREF(__pyx_t_15);
                  /*try:*/ {

                    /* "ws_package/controllers/activity_controller.py":4203
 *                                 logger.error("Error deleting screenshot: %s in %s/screenshots", e, target_directory_stealth)
 *                             try:
 *                                 self.screenshot_controller.delete_screenshot(             # <<<<<<<<<<<<<<
 *                                     file_location.split("/")[1],
 *                                     f"{target_directory}/screenshots"
*/
                    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4203, __pyx_L101_error)
                    __Pyx_GOTREF(__pyx_t_2);
                    __pyx_t_3 = __pyx_t_2;
                    __Pyx_INCREF(__pyx_t_3);

                    /* "ws_package/controllers/activity_controller.py":4204
 *                             try:
 *                                 self.screenshot_controller.delete_screenshot(
 *                                     file_location.split("/")[1],             # <<<<<<<<<<<<<<
 *                                     f"{target_directory}/screenshots"
 *                                 )
*/
                    __pyx_t_39 = __pyx_cur_scope->__pyx_v_file_location;
                    __Pyx_INCREF(__pyx_t_39);
                    __pyx_t_7 = 0;
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_39, __pyx_mstate_global->__pyx_kp_u__9};
                      __pyx_t_10 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_split, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                      if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4204, __pyx_L101_error)
                      __Pyx_GOTREF(__pyx_t_10);
                    }
                    __pyx_t_39 = __Pyx_GetItemInt(__pyx_t_10, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 4204, __pyx_L101_error)
                    __Pyx_GOTREF(__pyx_t_39);
                    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

                    /* "ws_package/controllers/activity_controller.py":4205
 *                                 self.screenshot_controller.delete_screenshot(
 *                                     file_location.split("/")[1],
 *                                     f"{target_directory}/screenshots"             # <<<<<<<<<<<<<<
 *                                 )
 *                             except Exception as e:
*/
                    if (unlikely(!__pyx_cur_scope->__pyx_v_target_directory)) { __Pyx_RaiseUnboundLocalError("target_directory"); __PYX_ERR(0, 4205, __pyx_L101_error) }
                    __pyx_t_10 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_target_directory, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4205, __pyx_L101_error)
                    __Pyx_GOTREF(__pyx_t_10);
                    __pyx_t_5 = __Pyx_PyUnicode_Concat__Pyx_ReferenceSharing_OwnStrongReferenceInPlace(__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_screenshots_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4205, __pyx_L101_error)
                    __Pyx_GOTREF(__pyx_t_5);
                    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                    __pyx_t_7 = 0;
                    {
                      PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_t_39, __pyx_t_5};
                      __pyx_t_38 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_delete_screenshot, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                      __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                      if (unlikely(!__pyx_t_38)) __PYX_ERR(0, 4203, __pyx_L101_error)
                      __Pyx_GOTREF(__pyx_t_38);
                    }
                    __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0;

                    /* "ws_package/controllers/activity_controller.py":4202
 *                             except Exception as e:
 *                                 logger.error("Error deleting screenshot: %s in %s/screenshots", e, target_directory_stealth)
 *                             try:             # <<<<<<<<<<<<<<
 *                                 self.screenshot_controller.delete_screenshot(
 *                                     file_location.split("/")[1],
*/
                  }
                  __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                  __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  goto __pyx_L108_try_end;
                  __pyx_L101_error:;
                  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                  __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

                  /* "ws_package/controllers/activity_controller.py":4207
 *                                     f"{target_directory}/screenshots"
 *                                 )
 *                             except Exception as e:             # <<<<<<<<<<<<<<
 *                                 logger.error("Error deleting screenshot: %s in %s/screenshots", e, target_directory)
 *                         elif platform.system() == "Windows":
*/
                  __pyx_t_29 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                  if (__pyx_t_29) {
                    __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.delete_old_data_and_screenshots", __pyx_clineno, __pyx_lineno, __pyx_filename);
                    if (__Pyx_GetException(&__pyx_t_38, &__pyx_t_2, &__pyx_t_5) < 0) __PYX_ERR(0, 4207, __pyx_L103_except_error)
                    __Pyx_XGOTREF(__pyx_t_38);
                    __Pyx_XGOTREF(__pyx_t_2);
                    __Pyx_XGOTREF(__pyx_t_5);
                    __Pyx_INCREF(__pyx_t_2);
                    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_2);
                    __Pyx_GIVEREF(__pyx_t_2);
                    /*try:*/ {

                      /* "ws_package/controllers/activity_controller.py":4208
 *                                 )
 *                             except Exception as e:
 *                                 logger.error("Error deleting screenshot: %s in %s/screenshots", e, target_directory)             # <<<<<<<<<<<<<<
 *                         elif platform.system() == "Windows":
 *                             try:
*/
                      __pyx_t_3 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4208, __pyx_L114_error)
                      __Pyx_GOTREF(__pyx_t_10);
                      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4208, __pyx_L114_error)
                      __Pyx_GOTREF(__pyx_t_8);
                      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                      if (unlikely(!__pyx_cur_scope->__pyx_v_target_directory)) { __Pyx_RaiseUnboundLocalError("target_directory"); __PYX_ERR(0, 4208, __pyx_L114_error) }
                      __pyx_t_7 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_8))) {
                        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8);
                        assert(__pyx_t_3);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
                        __Pyx_INCREF(__pyx_t_3);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
                        __pyx_t_7 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[4] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Error_deleting_screenshot_s_in_s, __pyx_cur_scope->__pyx_v_e, __pyx_cur_scope->__pyx_v_target_directory};
                        __pyx_t_39 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                        if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 4208, __pyx_L114_error)
                        __Pyx_GOTREF(__pyx_t_39);
                      }
                      __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                    }

                    /* "ws_package/controllers/activity_controller.py":4207
 *                                     f"{target_directory}/screenshots"
 *                                 )
 *                             except Exception as e:             # <<<<<<<<<<<<<<
 *                                 logger.error("Error deleting screenshot: %s in %s/screenshots", e, target_directory)
 *                         elif platform.system() == "Windows":
*/
                    /*finally:*/ {
                      /*normal exit:*/{
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                        __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                        goto __pyx_L115;
                      }
                      __pyx_L114_error:;
                      /*exception exit:*/{
                        __Pyx_PyThreadState_assign
                        __pyx_t_37 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0;
                        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                        __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                         __Pyx_ExceptionSwap(&__pyx_t_25, &__pyx_t_20, &__pyx_t_21);
                        if ( unlikely(__Pyx_GetException(&__pyx_t_37, &__pyx_t_23, &__pyx_t_24) < 0)) __Pyx_ErrFetch(&__pyx_t_37, &__pyx_t_23, &__pyx_t_24);
                        __Pyx_XGOTREF(__pyx_t_37);
                        __Pyx_XGOTREF(__pyx_t_23);
                        __Pyx_XGOTREF(__pyx_t_24);
                        __Pyx_XGOTREF(__pyx_t_25);
                        __Pyx_XGOTREF(__pyx_t_20);
                        __Pyx_XGOTREF(__pyx_t_21);
                        __pyx_t_29 = __pyx_lineno; __pyx_t_30 = __pyx_clineno; __pyx_t_41 = __pyx_filename;
                        {
                          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                        }
                        __Pyx_XGIVEREF(__pyx_t_25);
                        __Pyx_XGIVEREF(__pyx_t_20);
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __Pyx_ExceptionReset(__pyx_t_25, __pyx_t_20, __pyx_t_21);
                        __Pyx_XGIVEREF(__pyx_t_37);
                        __Pyx_XGIVEREF(__pyx_t_23);
                        __Pyx_XGIVEREF(__pyx_t_24);
                        __Pyx_ErrRestore(__pyx_t_37, __pyx_t_23, __pyx_t_24);
                        __pyx_t_37 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0;
                        __pyx_lineno = __pyx_t_29; __pyx_clineno = __pyx_t_30; __pyx_filename = __pyx_t_41;
                        goto __pyx_L103_except_error;
                      }
                      __pyx_L115:;
                    }
                    __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    goto __pyx_L102_exception_handled;
                  }
                  goto __pyx_L103_except_error;

                  /* "ws_package/controllers/activity_controller.py":4202
 *                             except Exception as e:
 *                                 logger.error("Error deleting screenshot: %s in %s/screenshots", e, target_directory_stealth)
 *                             try:             # <<<<<<<<<<<<<<
 *                                 self.screenshot_controller.delete_screenshot(
 *                                     file_location.split("/")[1],
*/
                  __pyx_L103_except_error:;
                  __Pyx_XGIVEREF(__pyx_t_22);
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_18, __pyx_t_15);
                  goto __pyx_L73_error;
                  __pyx_L102_exception_handled:;
                  __Pyx_XGIVEREF(__pyx_t_22);
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_18, __pyx_t_15);
                  __pyx_L108_try_end:;
                }

                /* "ws_package/controllers/activity_controller.py":4194
 * 
 *                     try:
 *                         if platform.system() == "Linux":             # <<<<<<<<<<<<<<
 *                             try:
 *                                 self.screenshot_controller.delete_screenshot(
*/
                goto __pyx_L81;
              }

              /* "ws_package/controllers/activity_controller.py":4209
 *                             except Exception as e:
 *                                 logger.error("Error deleting screenshot: %s in %s/screenshots", e, target_directory)
 *                         elif platform.system() == "Windows":             # <<<<<<<<<<<<<<
 *                             try:
 *                                 logger.info("Cleaning function Build for windows")
*/
              __pyx_t_2 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_38, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_38)) __PYX_ERR(0, 4209, __pyx_L73_error)
              __Pyx_GOTREF(__pyx_t_38);
              __pyx_t_39 = __Pyx_PyObject_GetAttrStr(__pyx_t_38, __pyx_mstate_global->__pyx_n_u_system); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 4209, __pyx_L73_error)
              __Pyx_GOTREF(__pyx_t_39);
              __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0;
              __pyx_t_7 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_39))) {
                __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_39);
                assert(__pyx_t_2);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_39);
                __Pyx_INCREF(__pyx_t_2);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_39, __pyx__function);
                __pyx_t_7 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
                __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_39, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4209, __pyx_L73_error)
                __Pyx_GOTREF(__pyx_t_5);
              }
              __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_Windows, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 4209, __pyx_L73_error)
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              if (__pyx_t_1) {

                /* "ws_package/controllers/activity_controller.py":4210
 *                                 logger.error("Error deleting screenshot: %s in %s/screenshots", e, target_directory)
 *                         elif platform.system() == "Windows":
 *                             try:             # <<<<<<<<<<<<<<
 *                                 logger.info("Cleaning function Build for windows")
 *                                 self.screenshot_controller.delete_screenshot(
*/
                {
                  __Pyx_ExceptionSave(&__pyx_t_15, &__pyx_t_18, &__pyx_t_22);
                  __Pyx_XGOTREF(__pyx_t_15);
                  __Pyx_XGOTREF(__pyx_t_18);
                  __Pyx_XGOTREF(__pyx_t_22);
                  /*try:*/ {

                    /* "ws_package/controllers/activity_controller.py":4211
 *                         elif platform.system() == "Windows":
 *                             try:
 *                                 logger.info("Cleaning function Build for windows")             # <<<<<<<<<<<<<<
 *                                 self.screenshot_controller.delete_screenshot(
 *                                     file_location.split("\\")[1],
*/
                    __pyx_t_39 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4211, __pyx_L120_error)
                    __Pyx_GOTREF(__pyx_t_2);
                    __pyx_t_38 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_38)) __PYX_ERR(0, 4211, __pyx_L120_error)
                    __Pyx_GOTREF(__pyx_t_38);
                    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __pyx_t_7 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_38))) {
                      __pyx_t_39 = PyMethod_GET_SELF(__pyx_t_38);
                      assert(__pyx_t_39);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_38);
                      __Pyx_INCREF(__pyx_t_39);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_38, __pyx__function);
                      __pyx_t_7 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_39, __pyx_mstate_global->__pyx_kp_u_Cleaning_function_Build_for_wind};
                      __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_38, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                      __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0;
                      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4211, __pyx_L120_error)
                      __Pyx_GOTREF(__pyx_t_5);
                    }
                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                    /* "ws_package/controllers/activity_controller.py":4212
 *                             try:
 *                                 logger.info("Cleaning function Build for windows")
 *                                 self.screenshot_controller.delete_screenshot(             # <<<<<<<<<<<<<<
 *                                     file_location.split("\\")[1],
 *                                     f"{target_directoryw}\\screenshots"
*/
                    __pyx_t_39 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 4212, __pyx_L120_error)
                    __Pyx_GOTREF(__pyx_t_39);
                    __pyx_t_38 = __pyx_t_39;
                    __Pyx_INCREF(__pyx_t_38);

                    /* "ws_package/controllers/activity_controller.py":4213
 *                                 logger.info("Cleaning function Build for windows")
 *                                 self.screenshot_controller.delete_screenshot(
 *                                     file_location.split("\\")[1],             # <<<<<<<<<<<<<<
 *                                     f"{target_directoryw}\\screenshots"
 *                                 )
*/
                    __pyx_t_8 = __pyx_cur_scope->__pyx_v_file_location;
                    __Pyx_INCREF(__pyx_t_8);
                    __pyx_t_7 = 0;
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_mstate_global->__pyx_kp_u__12};
                      __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_split, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4213, __pyx_L120_error)
                      __Pyx_GOTREF(__pyx_t_2);
                    }
                    __pyx_t_8 = __Pyx_GetItemInt(__pyx_t_2, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4213, __pyx_L120_error)
                    __Pyx_GOTREF(__pyx_t_8);
                    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

                    /* "ws_package/controllers/activity_controller.py":4214
 *                                 self.screenshot_controller.delete_screenshot(
 *                                     file_location.split("\\")[1],
 *                                     f"{target_directoryw}\\screenshots"             # <<<<<<<<<<<<<<
 *                                 )
 *                             except Exception as e:
*/
                    if (unlikely(!__pyx_cur_scope->__pyx_v_target_directoryw)) { __Pyx_RaiseUnboundLocalError("target_directoryw"); __PYX_ERR(0, 4214, __pyx_L120_error) }
                    __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_target_directoryw, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4214, __pyx_L120_error)
                    __Pyx_GOTREF(__pyx_t_2);
                    __pyx_t_3 = __Pyx_PyUnicode_Concat__Pyx_ReferenceSharing_OwnStrongReferenceInPlace(__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_screenshots_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4214, __pyx_L120_error)
                    __Pyx_GOTREF(__pyx_t_3);
                    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __pyx_t_7 = 0;
                    {
                      PyObject *__pyx_callargs[3] = {__pyx_t_38, __pyx_t_8, __pyx_t_3};
                      __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_delete_screenshot, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                      __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4212, __pyx_L120_error)
                      __Pyx_GOTREF(__pyx_t_5);
                    }
                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                    /* "ws_package/controllers/activity_controller.py":4210
 *                                 logger.error("Error deleting screenshot: %s in %s/screenshots", e, target_directory)
 *                         elif platform.system() == "Windows":
 *                             try:             # <<<<<<<<<<<<<<
 *                                 logger.info("Cleaning function Build for windows")
 *                                 self.screenshot_controller.delete_screenshot(
*/
                  }
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                  __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                  goto __pyx_L127_try_end;
                  __pyx_L120_error:;
                  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                  __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

                  /* "ws_package/controllers/activity_controller.py":4216
 *                                     f"{target_directoryw}\\screenshots"
 *                                 )
 *                             except Exception as e:             # <<<<<<<<<<<<<<
 *                                 logger.error("Error deleting screenshot: %s in %s\\screenshots", e, target_directoryw)
 *                             # Log cleanup (only once, not per screenshot)
*/
                  __pyx_t_30 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                  if (__pyx_t_30) {
                    __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.delete_old_data_and_screenshots", __pyx_clineno, __pyx_lineno, __pyx_filename);
                    if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_39, &__pyx_t_3) < 0) __PYX_ERR(0, 4216, __pyx_L122_except_error)
                    __Pyx_XGOTREF(__pyx_t_5);
                    __Pyx_XGOTREF(__pyx_t_39);
                    __Pyx_XGOTREF(__pyx_t_3);
                    __Pyx_INCREF(__pyx_t_39);
                    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_39);
                    __Pyx_GIVEREF(__pyx_t_39);
                    /*try:*/ {

                      /* "ws_package/controllers/activity_controller.py":4217
 *                                 )
 *                             except Exception as e:
 *                                 logger.error("Error deleting screenshot: %s in %s\\screenshots", e, target_directoryw)             # <<<<<<<<<<<<<<
 *                             # Log cleanup (only once, not per screenshot)
 *                             if idx == 0:  # Only cleanup logs once (first iteration)
*/
                      __pyx_t_38 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4217, __pyx_L133_error)
                      __Pyx_GOTREF(__pyx_t_2);
                      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4217, __pyx_L133_error)
                      __Pyx_GOTREF(__pyx_t_10);
                      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                      if (unlikely(!__pyx_cur_scope->__pyx_v_target_directoryw)) { __Pyx_RaiseUnboundLocalError("target_directoryw"); __PYX_ERR(0, 4217, __pyx_L133_error) }
                      __pyx_t_7 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_10))) {
                        __pyx_t_38 = PyMethod_GET_SELF(__pyx_t_10);
                        assert(__pyx_t_38);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
                        __Pyx_INCREF(__pyx_t_38);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
                        __pyx_t_7 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[4] = {__pyx_t_38, __pyx_mstate_global->__pyx_kp_u_Error_deleting_screenshot_s_in_s_2, __pyx_cur_scope->__pyx_v_e, __pyx_cur_scope->__pyx_v_target_directoryw};
                        __pyx_t_8 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                        if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4217, __pyx_L133_error)
                        __Pyx_GOTREF(__pyx_t_8);
                      }
                      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                    }

                    /* "ws_package/controllers/activity_controller.py":4216
 *                                     f"{target_directoryw}\\screenshots"
 *                                 )
 *                             except Exception as e:             # <<<<<<<<<<<<<<
 *                                 logger.error("Error deleting screenshot: %s in %s\\screenshots", e, target_directoryw)
 *                             # Log cleanup (only once, not per screenshot)
*/
                    /*finally:*/ {
                      /*normal exit:*/{
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                        __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                        goto __pyx_L134;
                      }
                      __pyx_L133_error:;
                      /*exception exit:*/{
                        __Pyx_PyThreadState_assign
                        __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_t_37 = 0;
                        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                        __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                         __Pyx_ExceptionSwap(&__pyx_t_24, &__pyx_t_23, &__pyx_t_37);
                        if ( unlikely(__Pyx_GetException(&__pyx_t_21, &__pyx_t_20, &__pyx_t_25) < 0)) __Pyx_ErrFetch(&__pyx_t_21, &__pyx_t_20, &__pyx_t_25);
                        __Pyx_XGOTREF(__pyx_t_21);
                        __Pyx_XGOTREF(__pyx_t_20);
                        __Pyx_XGOTREF(__pyx_t_25);
                        __Pyx_XGOTREF(__pyx_t_24);
                        __Pyx_XGOTREF(__pyx_t_23);
                        __Pyx_XGOTREF(__pyx_t_37);
                        __pyx_t_30 = __pyx_lineno; __pyx_t_29 = __pyx_clineno; __pyx_t_42 = __pyx_filename;
                        {
                          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                        }
                        __Pyx_XGIVEREF(__pyx_t_24);
                        __Pyx_XGIVEREF(__pyx_t_23);
                        __Pyx_XGIVEREF(__pyx_t_37);
                        __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_23, __pyx_t_37);
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __Pyx_XGIVEREF(__pyx_t_20);
                        __Pyx_XGIVEREF(__pyx_t_25);
                        __Pyx_ErrRestore(__pyx_t_21, __pyx_t_20, __pyx_t_25);
                        __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_t_37 = 0;
                        __pyx_lineno = __pyx_t_30; __pyx_clineno = __pyx_t_29; __pyx_filename = __pyx_t_42;
                        goto __pyx_L122_except_error;
                      }
                      __pyx_L134:;
                    }
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    goto __pyx_L121_exception_handled;
                  }
                  goto __pyx_L122_except_error;

                  /* "ws_package/controllers/activity_controller.py":4210
 *                                 logger.error("Error deleting screenshot: %s in %s/screenshots", e, target_directory)
 *                         elif platform.system() == "Windows":
 *                             try:             # <<<<<<<<<<<<<<
 *                                 logger.info("Cleaning function Build for windows")
 *                                 self.screenshot_controller.delete_screenshot(
*/
                  __pyx_L122_except_error:;
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __Pyx_XGIVEREF(__pyx_t_22);
                  __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_18, __pyx_t_22);
                  goto __pyx_L73_error;
                  __pyx_L121_exception_handled:;
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __Pyx_XGIVEREF(__pyx_t_22);
                  __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_18, __pyx_t_22);
                  __pyx_L127_try_end:;
                }

                /* "ws_package/controllers/activity_controller.py":4219
 *                                 logger.error("Error deleting screenshot: %s in %s\\screenshots", e, target_directoryw)
 *                             # Log cleanup (only once, not per screenshot)
 *                             if idx == 0:  # Only cleanup logs once (first iteration)             # <<<<<<<<<<<<<<
 *                                 try:
 *                                     logs.cleanup_old_files(f"{target_directoryw}\\logsy")
*/
                __pyx_t_1 = (__Pyx_PyLong_BoolEqObjC(__pyx_cur_scope->__pyx_v_idx, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 4219, __pyx_L73_error)
                if (__pyx_t_1) {

                  /* "ws_package/controllers/activity_controller.py":4220
 *                             # Log cleanup (only once, not per screenshot)
 *                             if idx == 0:  # Only cleanup logs once (first iteration)
 *                                 try:             # <<<<<<<<<<<<<<
 *                                     logs.cleanup_old_files(f"{target_directoryw}\\logsy")
 *                                 except Exception as e:
*/
                  {
                    __Pyx_ExceptionSave(&__pyx_t_22, &__pyx_t_18, &__pyx_t_15);
                    __Pyx_XGOTREF(__pyx_t_22);
                    __Pyx_XGOTREF(__pyx_t_18);
                    __Pyx_XGOTREF(__pyx_t_15);
                    /*try:*/ {

                      /* "ws_package/controllers/activity_controller.py":4221
 *                             if idx == 0:  # Only cleanup logs once (first iteration)
 *                                 try:
 *                                     logs.cleanup_old_files(f"{target_directoryw}\\logsy")             # <<<<<<<<<<<<<<
 *                                 except Exception as e:
 *                                     logger.error("Error in deleting logs: %s in %s\\logsy", e, target_directoryw)
*/
                      __pyx_t_39 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logs); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4221, __pyx_L140_error)
                      __Pyx_GOTREF(__pyx_t_5);
                      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_cleanup_old_files); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4221, __pyx_L140_error)
                      __Pyx_GOTREF(__pyx_t_8);
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      if (unlikely(!__pyx_cur_scope->__pyx_v_target_directoryw)) { __Pyx_RaiseUnboundLocalError("target_directoryw"); __PYX_ERR(0, 4221, __pyx_L140_error) }
                      __pyx_t_5 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_target_directoryw, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4221, __pyx_L140_error)
                      __Pyx_GOTREF(__pyx_t_5);
                      __pyx_t_10 = __Pyx_PyUnicode_Concat__Pyx_ReferenceSharing_OwnStrongReferenceInPlace(__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_logsy); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4221, __pyx_L140_error)
                      __Pyx_GOTREF(__pyx_t_10);
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __pyx_t_7 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_8))) {
                        __pyx_t_39 = PyMethod_GET_SELF(__pyx_t_8);
                        assert(__pyx_t_39);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
                        __Pyx_INCREF(__pyx_t_39);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
                        __pyx_t_7 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_39, __pyx_t_10};
                        __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4221, __pyx_L140_error)
                        __Pyx_GOTREF(__pyx_t_3);
                      }
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                      /* "ws_package/controllers/activity_controller.py":4220
 *                             # Log cleanup (only once, not per screenshot)
 *                             if idx == 0:  # Only cleanup logs once (first iteration)
 *                                 try:             # <<<<<<<<<<<<<<
 *                                     logs.cleanup_old_files(f"{target_directoryw}\\logsy")
 *                                 except Exception as e:
*/
                    }
                    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    goto __pyx_L147_try_end;
                    __pyx_L140_error:;
                    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                    __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

                    /* "ws_package/controllers/activity_controller.py":4222
 *                                 try:
 *                                     logs.cleanup_old_files(f"{target_directoryw}\\logsy")
 *                                 except Exception as e:             # <<<<<<<<<<<<<<
 *                                     logger.error("Error in deleting logs: %s in %s\\logsy", e, target_directoryw)
 *                         elif sys.platform == 'darwin':
*/
                    __pyx_t_29 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                    if (__pyx_t_29) {
                      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.delete_old_data_and_screenshots", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_8, &__pyx_t_10) < 0) __PYX_ERR(0, 4222, __pyx_L142_except_error)
                      __Pyx_XGOTREF(__pyx_t_3);
                      __Pyx_XGOTREF(__pyx_t_8);
                      __Pyx_XGOTREF(__pyx_t_10);
                      __Pyx_INCREF(__pyx_t_8);
                      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
                      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_8);
                      __Pyx_GIVEREF(__pyx_t_8);
                      /*try:*/ {

                        /* "ws_package/controllers/activity_controller.py":4223
 *                                     logs.cleanup_old_files(f"{target_directoryw}\\logsy")
 *                                 except Exception as e:
 *                                     logger.error("Error in deleting logs: %s in %s\\logsy", e, target_directoryw)             # <<<<<<<<<<<<<<
 *                         elif sys.platform == 'darwin':
 *                             try:
*/
                        __pyx_t_5 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_38, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_38)) __PYX_ERR(0, 4223, __pyx_L153_error)
                        __Pyx_GOTREF(__pyx_t_38);
                        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_38, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4223, __pyx_L153_error)
                        __Pyx_GOTREF(__pyx_t_2);
                        __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0;
                        if (unlikely(!__pyx_cur_scope->__pyx_v_target_directoryw)) { __Pyx_RaiseUnboundLocalError("target_directoryw"); __PYX_ERR(0, 4223, __pyx_L153_error) }
                        __pyx_t_7 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_2))) {
                          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
                          assert(__pyx_t_5);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
                          __Pyx_INCREF(__pyx_t_5);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
                          __pyx_t_7 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[4] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Error_in_deleting_logs_s_in_s_lo, __pyx_cur_scope->__pyx_v_e, __pyx_cur_scope->__pyx_v_target_directoryw};
                          __pyx_t_39 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                          if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 4223, __pyx_L153_error)
                          __Pyx_GOTREF(__pyx_t_39);
                        }
                        __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                      }

                      /* "ws_package/controllers/activity_controller.py":4222
 *                                 try:
 *                                     logs.cleanup_old_files(f"{target_directoryw}\\logsy")
 *                                 except Exception as e:             # <<<<<<<<<<<<<<
 *                                     logger.error("Error in deleting logs: %s in %s\\logsy", e, target_directoryw)
 *                         elif sys.platform == 'darwin':
*/
                      /*finally:*/ {
                        /*normal exit:*/{
                          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                          goto __pyx_L154;
                        }
                        __pyx_L153_error:;
                        /*exception exit:*/{
                          __Pyx_PyThreadState_assign
                          __pyx_t_37 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0;
                          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                          __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                          __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                           __Pyx_ExceptionSwap(&__pyx_t_25, &__pyx_t_20, &__pyx_t_21);
                          if ( unlikely(__Pyx_GetException(&__pyx_t_37, &__pyx_t_23, &__pyx_t_24) < 0)) __Pyx_ErrFetch(&__pyx_t_37, &__pyx_t_23, &__pyx_t_24);
                          __Pyx_XGOTREF(__pyx_t_37);
                          __Pyx_XGOTREF(__pyx_t_23);
                          __Pyx_XGOTREF(__pyx_t_24);
                          __Pyx_XGOTREF(__pyx_t_25);
                          __Pyx_XGOTREF(__pyx_t_20);
                          __Pyx_XGOTREF(__pyx_t_21);
                          __pyx_t_29 = __pyx_lineno; __pyx_t_30 = __pyx_clineno; __pyx_t_43 = __pyx_filename;
                          {
                            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                          }
                          __Pyx_XGIVEREF(__pyx_t_25);
                          __Pyx_XGIVEREF(__pyx_t_20);
                          __Pyx_XGIVEREF(__pyx_t_21);
                          __Pyx_ExceptionReset(__pyx_t_25, __pyx_t_20, __pyx_t_21);
                          __Pyx_XGIVEREF(__pyx_t_37);
                          __Pyx_XGIVEREF(__pyx_t_23);
                          __Pyx_XGIVEREF(__pyx_t_24);
                          __Pyx_ErrRestore(__pyx_t_37, __pyx_t_23, __pyx_t_24);
                          __pyx_t_37 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0;
                          __pyx_lineno = __pyx_t_29; __pyx_clineno = __pyx_t_30; __pyx_filename = __pyx_t_43;
                          goto __pyx_L142_except_error;
                        }
                        __pyx_L154:;
                      }
                      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                      goto __pyx_L141_exception_handled;
                    }
                    goto __pyx_L142_except_error;

                    /* "ws_package/controllers/activity_controller.py":4220
 *                             # Log cleanup (only once, not per screenshot)
 *                             if idx == 0:  # Only cleanup logs once (first iteration)
 *                                 try:             # <<<<<<<<<<<<<<
 *                                     logs.cleanup_old_files(f"{target_directoryw}\\logsy")
 *                                 except Exception as e:
*/
                    __pyx_L142_except_error:;
                    __Pyx_XGIVEREF(__pyx_t_22);
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_18, __pyx_t_15);
                    goto __pyx_L73_error;
                    __pyx_L141_exception_handled:;
                    __Pyx_XGIVEREF(__pyx_t_22);
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_18, __pyx_t_15);
                    __pyx_L147_try_end:;
                  }

                  /* "ws_package/controllers/activity_controller.py":4219
 *                                 logger.error("Error deleting screenshot: %s in %s\\screenshots", e, target_directoryw)
 *                             # Log cleanup (only once, not per screenshot)
 *                             if idx == 0:  # Only cleanup logs once (first iteration)             # <<<<<<<<<<<<<<
 *                                 try:
 *                                     logs.cleanup_old_files(f"{target_directoryw}\\logsy")
*/
                }

                /* "ws_package/controllers/activity_controller.py":4209
 *                             except Exception as e:
 *                                 logger.error("Error deleting screenshot: %s in %s/screenshots", e, target_directory)
 *                         elif platform.system() == "Windows":             # <<<<<<<<<<<<<<
 *                             try:
 *                                 logger.info("Cleaning function Build for windows")
*/
                goto __pyx_L81;
              }

              /* "ws_package/controllers/activity_controller.py":4224
 *                                 except Exception as e:
 *                                     logger.error("Error in deleting logs: %s in %s\\logsy", e, target_directoryw)
 *                         elif sys.platform == 'darwin':             # <<<<<<<<<<<<<<
 *                             try:
 *                                 self.screenshot_controller.delete_screenshot(
*/
              __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_sys); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4224, __pyx_L73_error)
              __Pyx_GOTREF(__pyx_t_10);
              __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4224, __pyx_L73_error)
              __Pyx_GOTREF(__pyx_t_8);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              __pyx_t_1 = (__Pyx_PyUnicode_Equals(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_darwin, Py_EQ)); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 4224, __pyx_L73_error)
              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
              if (__pyx_t_1) {

                /* "ws_package/controllers/activity_controller.py":4225
 *                                     logger.error("Error in deleting logs: %s in %s\\logsy", e, target_directoryw)
 *                         elif sys.platform == 'darwin':
 *                             try:             # <<<<<<<<<<<<<<
 *                                 self.screenshot_controller.delete_screenshot(
 *                                     file_location.split("/")[1],
*/
                {
                  __Pyx_ExceptionSave(&__pyx_t_15, &__pyx_t_18, &__pyx_t_22);
                  __Pyx_XGOTREF(__pyx_t_15);
                  __Pyx_XGOTREF(__pyx_t_18);
                  __Pyx_XGOTREF(__pyx_t_22);
                  /*try:*/ {

                    /* "ws_package/controllers/activity_controller.py":4226
 *                         elif sys.platform == 'darwin':
 *                             try:
 *                                 self.screenshot_controller.delete_screenshot(             # <<<<<<<<<<<<<<
 *                                     file_location.split("/")[1],
 *                                     f"{target_directory_mac}/screenshots"
*/
                    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4226, __pyx_L159_error)
                    __Pyx_GOTREF(__pyx_t_3);
                    __pyx_t_10 = __pyx_t_3;
                    __Pyx_INCREF(__pyx_t_10);

                    /* "ws_package/controllers/activity_controller.py":4227
 *                             try:
 *                                 self.screenshot_controller.delete_screenshot(
 *                                     file_location.split("/")[1],             # <<<<<<<<<<<<<<
 *                                     f"{target_directory_mac}/screenshots"
 *                                 )
*/
                    __pyx_t_2 = __pyx_cur_scope->__pyx_v_file_location;
                    __Pyx_INCREF(__pyx_t_2);
                    __pyx_t_7 = 0;
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u__9};
                      __pyx_t_39 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_split, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                      if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 4227, __pyx_L159_error)
                      __Pyx_GOTREF(__pyx_t_39);
                    }
                    __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_39, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4227, __pyx_L159_error)
                    __Pyx_GOTREF(__pyx_t_2);
                    __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;

                    /* "ws_package/controllers/activity_controller.py":4228
 *                                 self.screenshot_controller.delete_screenshot(
 *                                     file_location.split("/")[1],
 *                                     f"{target_directory_mac}/screenshots"             # <<<<<<<<<<<<<<
 *                                 )
 *                             except Exception as e:
*/
                    if (unlikely(!__pyx_cur_scope->__pyx_v_target_directory_mac)) { __Pyx_RaiseUnboundLocalError("target_directory_mac"); __PYX_ERR(0, 4228, __pyx_L159_error) }
                    __pyx_t_39 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_target_directory_mac, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 4228, __pyx_L159_error)
                    __Pyx_GOTREF(__pyx_t_39);
                    __pyx_t_5 = __Pyx_PyUnicode_Concat__Pyx_ReferenceSharing_OwnStrongReferenceInPlace(__pyx_t_39, __pyx_mstate_global->__pyx_kp_u_screenshots_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4228, __pyx_L159_error)
                    __Pyx_GOTREF(__pyx_t_5);
                    __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                    __pyx_t_7 = 0;
                    {
                      PyObject *__pyx_callargs[3] = {__pyx_t_10, __pyx_t_2, __pyx_t_5};
                      __pyx_t_8 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_delete_screenshot, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                      if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4226, __pyx_L159_error)
                      __Pyx_GOTREF(__pyx_t_8);
                    }
                    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

                    /* "ws_package/controllers/activity_controller.py":4225
 *                                     logger.error("Error in deleting logs: %s in %s\\logsy", e, target_directoryw)
 *                         elif sys.platform == 'darwin':
 *                             try:             # <<<<<<<<<<<<<<
 *                                 self.screenshot_controller.delete_screenshot(
 *                                     file_location.split("/")[1],
*/
                  }
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                  __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                  goto __pyx_L166_try_end;
                  __pyx_L159_error:;
                  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                  __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

                  /* "ws_package/controllers/activity_controller.py":4230
 *                                     f"{target_directory_mac}/screenshots"
 *                                 )
 *                             except Exception as e:             # <<<<<<<<<<<<<<
 *                                 logger.error("Error deleting screenshot: %s in %s/screenshots", e, target_directory_mac)
 *                     except Exception as e:
*/
                  __pyx_t_30 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                  if (__pyx_t_30) {
                    __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.delete_old_data_and_screenshots", __pyx_clineno, __pyx_lineno, __pyx_filename);
                    if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_3, &__pyx_t_5) < 0) __PYX_ERR(0, 4230, __pyx_L161_except_error)
                    __Pyx_XGOTREF(__pyx_t_8);
                    __Pyx_XGOTREF(__pyx_t_3);
                    __Pyx_XGOTREF(__pyx_t_5);
                    __Pyx_INCREF(__pyx_t_3);
                    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_3);
                    __Pyx_GIVEREF(__pyx_t_3);
                    /*try:*/ {

                      /* "ws_package/controllers/activity_controller.py":4231
 *                                 )
 *                             except Exception as e:
 *                                 logger.error("Error deleting screenshot: %s in %s/screenshots", e, target_directory_mac)             # <<<<<<<<<<<<<<
 *                     except Exception as e:
 *                         logger.error("Error deleting screenshot file %s: %s", file_name, e)
*/
                      __pyx_t_10 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 4231, __pyx_L172_error)
                      __Pyx_GOTREF(__pyx_t_39);
                      __pyx_t_38 = __Pyx_PyObject_GetAttrStr(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_38)) __PYX_ERR(0, 4231, __pyx_L172_error)
                      __Pyx_GOTREF(__pyx_t_38);
                      __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                      if (unlikely(!__pyx_cur_scope->__pyx_v_target_directory_mac)) { __Pyx_RaiseUnboundLocalError("target_directory_mac"); __PYX_ERR(0, 4231, __pyx_L172_error) }
                      __pyx_t_7 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_38))) {
                        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_38);
                        assert(__pyx_t_10);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_38);
                        __Pyx_INCREF(__pyx_t_10);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_38, __pyx__function);
                        __pyx_t_7 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[4] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Error_deleting_screenshot_s_in_s, __pyx_cur_scope->__pyx_v_e, __pyx_cur_scope->__pyx_v_target_directory_mac};
                        __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_38, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                        __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0;
                        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4231, __pyx_L172_error)
                        __Pyx_GOTREF(__pyx_t_2);
                      }
                      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                    }

                    /* "ws_package/controllers/activity_controller.py":4230
 *                                     f"{target_directory_mac}/screenshots"
 *                                 )
 *                             except Exception as e:             # <<<<<<<<<<<<<<
 *                                 logger.error("Error deleting screenshot: %s in %s/screenshots", e, target_directory_mac)
 *                     except Exception as e:
*/
                    /*finally:*/ {
                      /*normal exit:*/{
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                        __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                        goto __pyx_L173;
                      }
                      __pyx_L172_error:;
                      /*exception exit:*/{
                        __Pyx_PyThreadState_assign
                        __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_t_37 = 0;
                        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                        __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                        __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                         __Pyx_ExceptionSwap(&__pyx_t_24, &__pyx_t_23, &__pyx_t_37);
                        if ( unlikely(__Pyx_GetException(&__pyx_t_21, &__pyx_t_20, &__pyx_t_25) < 0)) __Pyx_ErrFetch(&__pyx_t_21, &__pyx_t_20, &__pyx_t_25);
                        __Pyx_XGOTREF(__pyx_t_21);
                        __Pyx_XGOTREF(__pyx_t_20);
                        __Pyx_XGOTREF(__pyx_t_25);
                        __Pyx_XGOTREF(__pyx_t_24);
                        __Pyx_XGOTREF(__pyx_t_23);
                        __Pyx_XGOTREF(__pyx_t_37);
                        __pyx_t_30 = __pyx_lineno; __pyx_t_29 = __pyx_clineno; __pyx_t_44 = __pyx_filename;
                        {
                          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                        }
                        __Pyx_XGIVEREF(__pyx_t_24);
                        __Pyx_XGIVEREF(__pyx_t_23);
                        __Pyx_XGIVEREF(__pyx_t_37);
                        __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_23, __pyx_t_37);
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __Pyx_XGIVEREF(__pyx_t_20);
                        __Pyx_XGIVEREF(__pyx_t_25);
                        __Pyx_ErrRestore(__pyx_t_21, __pyx_t_20, __pyx_t_25);
                        __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_t_37 = 0;
                        __pyx_lineno = __pyx_t_30; __pyx_clineno = __pyx_t_29; __pyx_filename = __pyx_t_44;
                        goto __pyx_L161_except_error;
                      }
                      __pyx_L173:;
                    }
                    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    goto __pyx_L160_exception_handled;
                  }
                  goto __pyx_L161_except_error;

                  /* "ws_package/controllers/activity_controller.py":4225
 *                                     logger.error("Error in deleting logs: %s in %s\\logsy", e, target_directoryw)
 *                         elif sys.platform == 'darwin':
 *                             try:             # <<<<<<<<<<<<<<
 *                                 self.screenshot_controller.delete_screenshot(
 *                                     file_location.split("/")[1],
*/
                  __pyx_L161_except_error:;
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __Pyx_XGIVEREF(__pyx_t_22);
                  __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_18, __pyx_t_22);
                  goto __pyx_L73_error;
                  __pyx_L160_exception_handled:;
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __Pyx_XGIVEREF(__pyx_t_22);
                  __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_18, __pyx_t_22);
                  __pyx_L166_try_end:;
                }

                /* "ws_package/controllers/activity_controller.py":4224
 *                                 except Exception as e:
 *                                     logger.error("Error in deleting logs: %s in %s\\logsy", e, target_directoryw)
 *                         elif sys.platform == 'darwin':             # <<<<<<<<<<<<<<
 *                             try:
 *                                 self.screenshot_controller.delete_screenshot(
*/
              }
              __pyx_L81:;

              /* "ws_package/controllers/activity_controller.py":4193
 *                     file_name = screenshot_data['file_name']
 * 
 *                     try:             # <<<<<<<<<<<<<<
 *                         if platform.system() == "Linux":
 *                             try:
*/
            }
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
            goto __pyx_L80_try_end;
            __pyx_L73_error:;
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
            __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

            /* "ws_package/controllers/activity_controller.py":4232
 *                             except Exception as e:
 *                                 logger.error("Error deleting screenshot: %s in %s/screenshots", e, target_directory_mac)
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error deleting screenshot file %s: %s", file_name, e)
 *                         # Continue with next screenshot even if one fails
*/
            __pyx_t_29 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
            if (__pyx_t_29) {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.delete_old_data_and_screenshots", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_3, &__pyx_t_8) < 0) __PYX_ERR(0, 4232, __pyx_L75_except_error)
              __Pyx_XGOTREF(__pyx_t_5);
              __Pyx_XGOTREF(__pyx_t_3);
              __Pyx_XGOTREF(__pyx_t_8);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_3);
              __Pyx_GIVEREF(__pyx_t_3);
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":4233
 *                                 logger.error("Error deleting screenshot: %s in %s/screenshots", e, target_directory_mac)
 *                     except Exception as e:
 *                         logger.error("Error deleting screenshot file %s: %s", file_name, e)             # <<<<<<<<<<<<<<
 *                         # Continue with next screenshot even if one fails
 *             else:
*/
                __pyx_t_38 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4233, __pyx_L183_error)
                __Pyx_GOTREF(__pyx_t_10);
                __pyx_t_39 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 4233, __pyx_L183_error)
                __Pyx_GOTREF(__pyx_t_39);
                __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_39))) {
                  __pyx_t_38 = PyMethod_GET_SELF(__pyx_t_39);
                  assert(__pyx_t_38);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_39);
                  __Pyx_INCREF(__pyx_t_38);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_39, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[4] = {__pyx_t_38, __pyx_mstate_global->__pyx_kp_u_Error_deleting_screenshot_file_s, __pyx_cur_scope->__pyx_v_file_name, __pyx_cur_scope->__pyx_v_e};
                  __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_39, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                  __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4233, __pyx_L183_error)
                  __Pyx_GOTREF(__pyx_t_2);
                }
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              }

              /* "ws_package/controllers/activity_controller.py":4232
 *                             except Exception as e:
 *                                 logger.error("Error deleting screenshot: %s in %s/screenshots", e, target_directory_mac)
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error deleting screenshot file %s: %s", file_name, e)
 *                         # Continue with next screenshot even if one fails
*/
              /*finally:*/ {
                /*normal exit:*/{
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  goto __pyx_L184;
                }
                __pyx_L183_error:;
                /*exception exit:*/{
                  __Pyx_PyThreadState_assign
                  __pyx_t_22 = 0; __pyx_t_18 = 0; __pyx_t_15 = 0; __pyx_t_37 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0;
                  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                  __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                  __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                   __Pyx_ExceptionSwap(&__pyx_t_37, &__pyx_t_23, &__pyx_t_24);
                  if ( unlikely(__Pyx_GetException(&__pyx_t_22, &__pyx_t_18, &__pyx_t_15) < 0)) __Pyx_ErrFetch(&__pyx_t_22, &__pyx_t_18, &__pyx_t_15);
                  __Pyx_XGOTREF(__pyx_t_22);
                  __Pyx_XGOTREF(__pyx_t_18);
                  __Pyx_XGOTREF(__pyx_t_15);
                  __Pyx_XGOTREF(__pyx_t_37);
                  __Pyx_XGOTREF(__pyx_t_23);
                  __Pyx_XGOTREF(__pyx_t_24);
                  __pyx_t_29 = __pyx_lineno; __pyx_t_30 = __pyx_clineno; __pyx_t_45 = __pyx_filename;
                  {
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  }
                  __Pyx_XGIVEREF(__pyx_t_37);
                  __Pyx_XGIVEREF(__pyx_t_23);
                  __Pyx_XGIVEREF(__pyx_t_24);
                  __Pyx_ExceptionReset(__pyx_t_37, __pyx_t_23, __pyx_t_24);
                  __Pyx_XGIVEREF(__pyx_t_22);
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __Pyx_ErrRestore(__pyx_t_22, __pyx_t_18, __pyx_t_15);
                  __pyx_t_22 = 0; __pyx_t_18 = 0; __pyx_t_15 = 0; __pyx_t_37 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0;
                  __pyx_lineno = __pyx_t_29; __pyx_clineno = __pyx_t_30; __pyx_filename = __pyx_t_45;
                  goto __pyx_L75_except_error;
                }
                __pyx_L184:;
              }
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
              goto __pyx_L74_exception_handled;
            }
            goto __pyx_L75_except_error;

            /* "ws_package/controllers/activity_controller.py":4193
 *                     file_name = screenshot_data['file_name']
 * 
 *                     try:             # <<<<<<<<<<<<<<
 *                         if platform.system() == "Linux":
 *                             try:
*/
            __pyx_L75_except_error:;
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_XGIVEREF(__pyx_t_16);
            __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_17, __pyx_t_16);
            goto __pyx_L9_error;
            __pyx_L74_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_XGIVEREF(__pyx_t_16);
            __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_17, __pyx_t_16);
            __pyx_L80_try_end:;
          }

          /* "ws_package/controllers/activity_controller.py":4189
 *             if screenshots_to_delete:
 *                 logger.info("Deleting %s screenshot files...", len(screenshots_to_delete))
 *                 for idx, screenshot_data in enumerate(screenshots_to_delete):             # <<<<<<<<<<<<<<
 *                     file_location = screenshot_data['file_location']
 *                     file_name = screenshot_data['file_name']
*/
        }
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "ws_package/controllers/activity_controller.py":4187
 * 
 *             # STEP 2: Delete files OUTSIDE lock (SLOW I/O operations - don't block database)
 *             if screenshots_to_delete:             # <<<<<<<<<<<<<<
 *                 logger.info("Deleting %s screenshot files...", len(screenshots_to_delete))
 *                 for idx, screenshot_data in enumerate(screenshots_to_delete):
*/
        goto __pyx_L70;
      }

      /* "ws_package/controllers/activity_controller.py":4236
 *                         # Continue with next screenshot even if one fails
 *             else:
 *                 logger.info("No screenshots older than 7 days found for deletion.")             # <<<<<<<<<<<<<<
 * 
 *             # STEP 3: Delete database entries (QUICK, inside lock)
*/
      /*else*/ {
        __pyx_t_9 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4236, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4236, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3);
          assert(__pyx_t_9);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_mstate_global->__pyx_kp_u_No_screenshots_older_than_7_days};
          __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4236, __pyx_L9_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }
      __pyx_L70:;

      /* "ws_package/controllers/activity_controller.py":4239
 * 
 *             # STEP 3: Delete database entries (QUICK, inside lock)
 *             with db_lock_manager.write_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     try:
*/
      /*with:*/ {
        __pyx_t_3 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4239, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_write_lock); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4239, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8);
          assert(__pyx_t_3);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
          __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4239, __pyx_L9_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __pyx_t_16 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 4239, __pyx_L9_error)
        __Pyx_GOTREF(__pyx_t_16);
        __pyx_t_3 = NULL;
        __pyx_t_9 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4239, __pyx_L190_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (likely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
          assert(__pyx_t_3);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
          __pyx_t_8 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4239, __pyx_L190_error)
          __Pyx_GOTREF(__pyx_t_8);
        }
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        /*try:*/ {
          {
            __Pyx_ExceptionSave(&__pyx_t_17, &__pyx_t_14, &__pyx_t_24);
            __Pyx_XGOTREF(__pyx_t_17);
            __Pyx_XGOTREF(__pyx_t_14);
            __Pyx_XGOTREF(__pyx_t_24);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":4240
 *             # STEP 3: Delete database entries (QUICK, inside lock)
 *             with db_lock_manager.write_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     try:
 *                         # Delete screenshots from database (bulk delete is faster)
*/
              /*with:*/ {
                __pyx_t_8 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4240, __pyx_L194_error)
                __Pyx_GOTREF(__pyx_t_9);
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_9))) {
                  __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9);
                  assert(__pyx_t_8);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
                  __Pyx_INCREF(__pyx_t_8);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
                  __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4240, __pyx_L194_error)
                  __Pyx_GOTREF(__pyx_t_6);
                }
                __pyx_t_23 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 4240, __pyx_L194_error)
                __Pyx_GOTREF(__pyx_t_23);
                __pyx_t_8 = NULL;
                __pyx_t_3 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4240, __pyx_L200_error)
                __Pyx_GOTREF(__pyx_t_3);
                __pyx_t_7 = 1;
                #if CYTHON_UNPACK_METHODS
                if (likely(PyMethod_Check(__pyx_t_3))) {
                  __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
                  assert(__pyx_t_8);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
                  __Pyx_INCREF(__pyx_t_8);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
                  __pyx_t_7 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
                  __pyx_t_9 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4240, __pyx_L200_error)
                  __Pyx_GOTREF(__pyx_t_9);
                }
                __pyx_t_19 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_9, &__pyx_r);
                __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                if (likely(__pyx_t_19 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_6);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
                  __Pyx_XGIVEREF(__pyx_t_11);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_11;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_t_14);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_14;
                  __Pyx_XGIVEREF(__pyx_t_16);
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_16;
                  __Pyx_XGIVEREF(__pyx_t_17);
                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_17;
                  __Pyx_XGIVEREF(__pyx_t_23);
                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_23;
                  __Pyx_XGIVEREF(__pyx_t_24);
                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_24;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 6;
                  return __pyx_r;
                  __pyx_L201_resume_from_await:;
                  __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_6);
                  __pyx_t_11 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_11);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  __pyx_t_14 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_14);
                  __pyx_t_16 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = 0;
                  __Pyx_XGOTREF(__pyx_t_16);
                  __pyx_t_17 = __pyx_cur_scope->__pyx_t_6;
                  __pyx_cur_scope->__pyx_t_6 = 0;
                  __Pyx_XGOTREF(__pyx_t_17);
                  __pyx_t_23 = __pyx_cur_scope->__pyx_t_7;
                  __pyx_cur_scope->__pyx_t_7 = 0;
                  __Pyx_XGOTREF(__pyx_t_23);
                  __pyx_t_24 = __pyx_cur_scope->__pyx_t_8;
                  __pyx_cur_scope->__pyx_t_8 = 0;
                  __Pyx_XGOTREF(__pyx_t_24);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4240, __pyx_L200_error)
                  __pyx_t_9 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_9);
                } else if (likely(__pyx_t_19 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __pyx_t_9 = __pyx_r; __pyx_r = NULL;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 4240, __pyx_L200_error)
                }
                __pyx_t_3 = __pyx_t_9;
                __pyx_t_9 = 0;
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                /*try:*/ {
                  {
                    __Pyx_ExceptionSave(&__pyx_t_37, &__pyx_t_15, &__pyx_t_18);
                    __Pyx_XGOTREF(__pyx_t_37);
                    __Pyx_XGOTREF(__pyx_t_15);
                    __Pyx_XGOTREF(__pyx_t_18);
                    /*try:*/ {
                      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_session);
                      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_session, __pyx_t_3);
                      __Pyx_GIVEREF(__pyx_t_3);
                      __pyx_t_3 = 0;

                      /* "ws_package/controllers/activity_controller.py":4241
 *             with db_lock_manager.write_lock():
 *                 async with async_session() as session:
 *                     try:             # <<<<<<<<<<<<<<
 *                         # Delete screenshots from database (bulk delete is faster)
 *                         if screenshots_to_delete:
*/
                      {
                        __Pyx_ExceptionSave(&__pyx_t_22, &__pyx_t_25, &__pyx_t_20);
                        __Pyx_XGOTREF(__pyx_t_22);
                        __Pyx_XGOTREF(__pyx_t_25);
                        __Pyx_XGOTREF(__pyx_t_20);
                        /*try:*/ {

                          /* "ws_package/controllers/activity_controller.py":4243
 *                     try:
 *                         # Delete screenshots from database (bulk delete is faster)
 *                         if screenshots_to_delete:             # <<<<<<<<<<<<<<
 *                             screenshot_ids = [s['id'] for s in screenshots_to_delete]
 *                             await asyncio.wait_for(
*/
                          {
                            Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_screenshots_to_delete);
                            if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 4243, __pyx_L211_error)
                            __pyx_t_1 = (__pyx_temp != 0);
                          }

                          if (__pyx_t_1) {

                            /* "ws_package/controllers/activity_controller.py":4244
 *                         # Delete screenshots from database (bulk delete is faster)
 *                         if screenshots_to_delete:
 *                             screenshot_ids = [s['id'] for s in screenshots_to_delete]             # <<<<<<<<<<<<<<
 *                             await asyncio.wait_for(
 *                                 session.execute(
*/
                            { /* enter inner scope */
                              __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4244, __pyx_L211_error)
                              __Pyx_GOTREF(__pyx_t_3);
                              __pyx_t_6 = __pyx_cur_scope->__pyx_v_screenshots_to_delete; __Pyx_INCREF(__pyx_t_6);
                              __pyx_t_26 = 0;
                              for (;;) {
                                {
                                  Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
                                  #if !CYTHON_ASSUME_SAFE_SIZE
                                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4244, __pyx_L211_error)
                                  #endif
                                  if (__pyx_t_26 >= __pyx_temp) break;
                                }
                                __pyx_t_9 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_6, __pyx_t_26, __Pyx_ReferenceSharing_OwnStrongReference);
                                ++__pyx_t_26;
                                if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4244, __pyx_L211_error)
                                __Pyx_GOTREF(__pyx_t_9);
                                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_9genexpr17__pyx_v_s);
                                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_9genexpr17__pyx_v_s, __pyx_t_9);
                                __Pyx_GIVEREF(__pyx_t_9);
                                __pyx_t_9 = 0;
                                __pyx_t_9 = __Pyx_PyObject_Dict_GetItem(__pyx_cur_scope->__pyx_9genexpr17__pyx_v_s, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4244, __pyx_L211_error)
                                __Pyx_GOTREF(__pyx_t_9);
                                if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_9))) __PYX_ERR(0, 4244, __pyx_L211_error)
                                __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                              }
                              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                            } /* exit inner scope */
                            __Pyx_GIVEREF(__pyx_t_3);
                            __pyx_cur_scope->__pyx_v_screenshot_ids = ((PyObject*)__pyx_t_3);
                            __pyx_t_3 = 0;

                            /* "ws_package/controllers/activity_controller.py":4245
 *                         if screenshots_to_delete:
 *                             screenshot_ids = [s['id'] for s in screenshots_to_delete]
 *                             await asyncio.wait_for(             # <<<<<<<<<<<<<<
 *                                 session.execute(
 *                                     delete(Screenshots).where(Screenshots.id.in_(screenshot_ids))
*/
                            __pyx_t_6 = NULL;
                            __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4245, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_9);
                            __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_wait_for); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4245, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_8);
                            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

                            /* "ws_package/controllers/activity_controller.py":4246
 *                             screenshot_ids = [s['id'] for s in screenshots_to_delete]
 *                             await asyncio.wait_for(
 *                                 session.execute(             # <<<<<<<<<<<<<<
 *                                     delete(Screenshots).where(Screenshots.id.in_(screenshot_ids))
 *                                 ),
*/
                            __pyx_t_5 = __pyx_cur_scope->__pyx_v_session;
                            __Pyx_INCREF(__pyx_t_5);

                            /* "ws_package/controllers/activity_controller.py":4247
 *                             await asyncio.wait_for(
 *                                 session.execute(
 *                                     delete(Screenshots).where(Screenshots.id.in_(screenshot_ids))             # <<<<<<<<<<<<<<
 *                                 ),
 *                                 timeout=DB_OPERATION_TIMEOUT
*/
                            __pyx_t_10 = NULL;
                            __Pyx_GetModuleGlobalName(__pyx_t_46, __pyx_mstate_global->__pyx_n_u_delete); if (unlikely(!__pyx_t_46)) __PYX_ERR(0, 4247, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_46);
                            __Pyx_GetModuleGlobalName(__pyx_t_47, __pyx_mstate_global->__pyx_n_u_Screenshots); if (unlikely(!__pyx_t_47)) __PYX_ERR(0, 4247, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_47);
                            __pyx_t_7 = 1;
                            #if CYTHON_UNPACK_METHODS
                            if (unlikely(PyMethod_Check(__pyx_t_46))) {
                              __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_46);
                              assert(__pyx_t_10);
                              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_46);
                              __Pyx_INCREF(__pyx_t_10);
                              __Pyx_INCREF(__pyx__function);
                              __Pyx_DECREF_SET(__pyx_t_46, __pyx__function);
                              __pyx_t_7 = 0;
                            }
                            #endif
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_t_47};
                              __pyx_t_38 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_46, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                              __Pyx_DECREF(__pyx_t_47); __pyx_t_47 = 0;
                              __Pyx_DECREF(__pyx_t_46); __pyx_t_46 = 0;
                              if (unlikely(!__pyx_t_38)) __PYX_ERR(0, 4247, __pyx_L211_error)
                              __Pyx_GOTREF(__pyx_t_38);
                            }
                            __pyx_t_39 = __pyx_t_38;
                            __Pyx_INCREF(__pyx_t_39);
                            __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_Screenshots); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4247, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_10);
                            __pyx_t_48 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_48)) __PYX_ERR(0, 4247, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_48);
                            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                            __pyx_t_47 = __pyx_t_48;
                            __Pyx_INCREF(__pyx_t_47);
                            __pyx_t_7 = 0;
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_47, __pyx_cur_scope->__pyx_v_screenshot_ids};
                              __pyx_t_46 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_in, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_47); __pyx_t_47 = 0;
                              __Pyx_DECREF(__pyx_t_48); __pyx_t_48 = 0;
                              if (unlikely(!__pyx_t_46)) __PYX_ERR(0, 4247, __pyx_L211_error)
                              __Pyx_GOTREF(__pyx_t_46);
                            }
                            __pyx_t_7 = 0;
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_39, __pyx_t_46};
                              __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                              __Pyx_DECREF(__pyx_t_46); __pyx_t_46 = 0;
                              __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0;
                              if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4247, __pyx_L211_error)
                              __Pyx_GOTREF(__pyx_t_2);
                            }
                            __pyx_t_7 = 0;
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_2};
                              __pyx_t_9 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                              if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4246, __pyx_L211_error)
                              __Pyx_GOTREF(__pyx_t_9);
                            }

                            /* "ws_package/controllers/activity_controller.py":4249
 *                                     delete(Screenshots).where(Screenshots.id.in_(screenshot_ids))
 *                                 ),
 *                                 timeout=DB_OPERATION_TIMEOUT             # <<<<<<<<<<<<<<
 *                             )
 *                             logger.info("Deleted %s screenshot database entries.", len(screenshot_ids))
*/
                            __pyx_t_2 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_DB_OPERATION_TIMEOUT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4249, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_2);
                            __pyx_t_7 = 1;
                            #if CYTHON_UNPACK_METHODS
                            if (unlikely(PyMethod_Check(__pyx_t_8))) {
                              __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8);
                              assert(__pyx_t_6);
                              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
                              __Pyx_INCREF(__pyx_t_6);
                              __Pyx_INCREF(__pyx__function);
                              __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
                              __pyx_t_7 = 0;
                            }
                            #endif
                            {
                              PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_6, __pyx_t_9};
                              __pyx_t_5 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4245, __pyx_L211_error)
                              __Pyx_GOTREF(__pyx_t_5);
                              if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_timeout, __pyx_t_2, __pyx_t_5, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 4245, __pyx_L211_error)
                              __pyx_t_3 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_5);
                              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                              if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4245, __pyx_L211_error)
                              __Pyx_GOTREF(__pyx_t_3);
                            }
                            __pyx_t_19 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_3, &__pyx_r);
                            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                            if (likely(__pyx_t_19 == PYGEN_NEXT)) {
                              __Pyx_GOTREF(__pyx_r);
                              __Pyx_XGIVEREF(__pyx_t_11);
                              __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                              __Pyx_XGIVEREF(__pyx_t_12);
                              __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                              __Pyx_XGIVEREF(__pyx_t_13);
                              __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                              __Pyx_XGIVEREF(__pyx_t_14);
                              __pyx_cur_scope->__pyx_t_3 = __pyx_t_14;
                              __Pyx_XGIVEREF(__pyx_t_15);
                              __pyx_cur_scope->__pyx_t_4 = __pyx_t_15;
                              __Pyx_XGIVEREF(__pyx_t_16);
                              __pyx_cur_scope->__pyx_t_5 = __pyx_t_16;
                              __Pyx_XGIVEREF(__pyx_t_17);
                              __pyx_cur_scope->__pyx_t_6 = __pyx_t_17;
                              __Pyx_XGIVEREF(__pyx_t_18);
                              __pyx_cur_scope->__pyx_t_7 = __pyx_t_18;
                              __Pyx_XGIVEREF(__pyx_t_20);
                              __pyx_cur_scope->__pyx_t_8 = __pyx_t_20;
                              __Pyx_XGIVEREF(__pyx_t_22);
                              __pyx_cur_scope->__pyx_t_9 = __pyx_t_22;
                              __Pyx_XGIVEREF(__pyx_t_23);
                              __pyx_cur_scope->__pyx_t_10 = __pyx_t_23;
                              __Pyx_XGIVEREF(__pyx_t_24);
                              __pyx_cur_scope->__pyx_t_11 = __pyx_t_24;
                              __Pyx_XGIVEREF(__pyx_t_25);
                              __pyx_cur_scope->__pyx_t_12 = __pyx_t_25;
                              __Pyx_XGIVEREF(__pyx_t_37);
                              __pyx_cur_scope->__pyx_t_13 = __pyx_t_37;
                              __Pyx_XGIVEREF(__pyx_r);
                              __Pyx_RefNannyFinishContext();
                              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                              /* return from generator, awaiting value */
                              __pyx_generator->resume_label = 7;
                              return __pyx_r;
                              __pyx_L221_resume_from_await:;
                              __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                              __pyx_cur_scope->__pyx_t_0 = 0;
                              __Pyx_XGOTREF(__pyx_t_11);
                              __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                              __pyx_cur_scope->__pyx_t_1 = 0;
                              __Pyx_XGOTREF(__pyx_t_12);
                              __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                              __pyx_cur_scope->__pyx_t_2 = 0;
                              __Pyx_XGOTREF(__pyx_t_13);
                              __pyx_t_14 = __pyx_cur_scope->__pyx_t_3;
                              __pyx_cur_scope->__pyx_t_3 = 0;
                              __Pyx_XGOTREF(__pyx_t_14);
                              __pyx_t_15 = __pyx_cur_scope->__pyx_t_4;
                              __pyx_cur_scope->__pyx_t_4 = 0;
                              __Pyx_XGOTREF(__pyx_t_15);
                              __pyx_t_16 = __pyx_cur_scope->__pyx_t_5;
                              __pyx_cur_scope->__pyx_t_5 = 0;
                              __Pyx_XGOTREF(__pyx_t_16);
                              __pyx_t_17 = __pyx_cur_scope->__pyx_t_6;
                              __pyx_cur_scope->__pyx_t_6 = 0;
                              __Pyx_XGOTREF(__pyx_t_17);
                              __pyx_t_18 = __pyx_cur_scope->__pyx_t_7;
                              __pyx_cur_scope->__pyx_t_7 = 0;
                              __Pyx_XGOTREF(__pyx_t_18);
                              __pyx_t_20 = __pyx_cur_scope->__pyx_t_8;
                              __pyx_cur_scope->__pyx_t_8 = 0;
                              __Pyx_XGOTREF(__pyx_t_20);
                              __pyx_t_22 = __pyx_cur_scope->__pyx_t_9;
                              __pyx_cur_scope->__pyx_t_9 = 0;
                              __Pyx_XGOTREF(__pyx_t_22);
                              __pyx_t_23 = __pyx_cur_scope->__pyx_t_10;
                              __pyx_cur_scope->__pyx_t_10 = 0;
                              __Pyx_XGOTREF(__pyx_t_23);
                              __pyx_t_24 = __pyx_cur_scope->__pyx_t_11;
                              __pyx_cur_scope->__pyx_t_11 = 0;
                              __Pyx_XGOTREF(__pyx_t_24);
                              __pyx_t_25 = __pyx_cur_scope->__pyx_t_12;
                              __pyx_cur_scope->__pyx_t_12 = 0;
                              __Pyx_XGOTREF(__pyx_t_25);
                              __pyx_t_37 = __pyx_cur_scope->__pyx_t_13;
                              __pyx_cur_scope->__pyx_t_13 = 0;
                              __Pyx_XGOTREF(__pyx_t_37);
                              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4245, __pyx_L211_error)
                            } else if (likely(__pyx_t_19 == PYGEN_RETURN)) {
                              __Pyx_GOTREF(__pyx_r);
                              __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                            } else {
                              __Pyx_XGOTREF(__pyx_r);
                              __PYX_ERR(0, 4245, __pyx_L211_error)
                            }

                            /* "ws_package/controllers/activity_controller.py":4251
 *                                 timeout=DB_OPERATION_TIMEOUT
 *                             )
 *                             logger.info("Deleted %s screenshot database entries.", len(screenshot_ids))             # <<<<<<<<<<<<<<
 * 
 *                         # Delete ActivityInterval entries older than 7 days
*/
                            __pyx_t_8 = NULL;
                            __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4251, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_5);
                            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4251, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_2);
                            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                            __pyx_t_26 = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_screenshot_ids); if (unlikely(__pyx_t_26 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4251, __pyx_L211_error)
                            __pyx_t_5 = PyLong_FromSsize_t(__pyx_t_26); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4251, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_5);
                            __pyx_t_7 = 1;
                            #if CYTHON_UNPACK_METHODS
                            if (unlikely(PyMethod_Check(__pyx_t_2))) {
                              __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2);
                              assert(__pyx_t_8);
                              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
                              __Pyx_INCREF(__pyx_t_8);
                              __Pyx_INCREF(__pyx__function);
                              __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
                              __pyx_t_7 = 0;
                            }
                            #endif
                            {
                              PyObject *__pyx_callargs[3] = {__pyx_t_8, __pyx_mstate_global->__pyx_kp_u_Deleted_s_screenshot_database_en, __pyx_t_5};
                              __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                              if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4251, __pyx_L211_error)
                              __Pyx_GOTREF(__pyx_t_3);
                            }
                            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                            /* "ws_package/controllers/activity_controller.py":4243
 *                     try:
 *                         # Delete screenshots from database (bulk delete is faster)
 *                         if screenshots_to_delete:             # <<<<<<<<<<<<<<
 *                             screenshot_ids = [s['id'] for s in screenshots_to_delete]
 *                             await asyncio.wait_for(
*/
                          }

                          /* "ws_package/controllers/activity_controller.py":4254
 * 
 *                         # Delete ActivityInterval entries older than 7 days
 *                         await asyncio.wait_for(             # <<<<<<<<<<<<<<
 *                             session.execute(delete(ActivityInterval).where(ActivityInterval.start_time < seven_days_ago)),
 *                             timeout=DB_OPERATION_TIMEOUT
*/
                          __pyx_t_2 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4254, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_5);
                          __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_wait_for); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4254, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_8);
                          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                          /* "ws_package/controllers/activity_controller.py":4255
 *                         # Delete ActivityInterval entries older than 7 days
 *                         await asyncio.wait_for(
 *                             session.execute(delete(ActivityInterval).where(ActivityInterval.start_time < seven_days_ago)),             # <<<<<<<<<<<<<<
 *                             timeout=DB_OPERATION_TIMEOUT
 *                         )
*/
                          __pyx_t_9 = __pyx_cur_scope->__pyx_v_session;
                          __Pyx_INCREF(__pyx_t_9);
                          __pyx_t_39 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_48, __pyx_mstate_global->__pyx_n_u_delete); if (unlikely(!__pyx_t_48)) __PYX_ERR(0, 4255, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_48);
                          __Pyx_GetModuleGlobalName(__pyx_t_47, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_47)) __PYX_ERR(0, 4255, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_47);
                          __pyx_t_7 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_48))) {
                            __pyx_t_39 = PyMethod_GET_SELF(__pyx_t_48);
                            assert(__pyx_t_39);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_48);
                            __Pyx_INCREF(__pyx_t_39);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_48, __pyx__function);
                            __pyx_t_7 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_39, __pyx_t_47};
                            __pyx_t_46 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_48, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                            __Pyx_DECREF(__pyx_t_47); __pyx_t_47 = 0;
                            __Pyx_DECREF(__pyx_t_48); __pyx_t_48 = 0;
                            if (unlikely(!__pyx_t_46)) __PYX_ERR(0, 4255, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_46);
                          }
                          __pyx_t_38 = __pyx_t_46;
                          __Pyx_INCREF(__pyx_t_38);
                          __Pyx_GetModuleGlobalName(__pyx_t_48, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_48)) __PYX_ERR(0, 4255, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_48);
                          __pyx_t_47 = __Pyx_PyObject_GetAttrStr(__pyx_t_48, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_47)) __PYX_ERR(0, 4255, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_47);
                          __Pyx_DECREF(__pyx_t_48); __pyx_t_48 = 0;
                          __pyx_t_48 = PyObject_RichCompare(__pyx_t_47, __pyx_cur_scope->__pyx_v_seven_days_ago, Py_LT); __Pyx_XGOTREF(__pyx_t_48); if (unlikely(!__pyx_t_48)) __PYX_ERR(0, 4255, __pyx_L211_error)
                          __Pyx_DECREF(__pyx_t_47); __pyx_t_47 = 0;
                          __pyx_t_7 = 0;
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_38, __pyx_t_48};
                            __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                            __Pyx_DECREF(__pyx_t_48); __pyx_t_48 = 0;
                            __Pyx_DECREF(__pyx_t_46); __pyx_t_46 = 0;
                            if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4255, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_6);
                          }
                          __pyx_t_7 = 0;
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_t_6};
                            __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4255, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_5);
                          }

                          /* "ws_package/controllers/activity_controller.py":4256
 *                         await asyncio.wait_for(
 *                             session.execute(delete(ActivityInterval).where(ActivityInterval.start_time < seven_days_ago)),
 *                             timeout=DB_OPERATION_TIMEOUT             # <<<<<<<<<<<<<<
 *                         )
 *                         logger.info("Deleted old ActivityInterval entries.")
*/
                          __pyx_t_6 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_DB_OPERATION_TIMEOUT); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4256, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_6);
                          __pyx_t_7 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_8))) {
                            __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_8);
                            assert(__pyx_t_2);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
                            __Pyx_INCREF(__pyx_t_2);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
                            __pyx_t_7 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_2, __pyx_t_5};
                            __pyx_t_9 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4254, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_9);
                            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_timeout, __pyx_t_6, __pyx_t_9, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 4254, __pyx_L211_error)
                            __pyx_t_3 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_9);
                            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4254, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_3);
                          }
                          __pyx_t_19 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_3, &__pyx_r);
                          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                          if (likely(__pyx_t_19 == PYGEN_NEXT)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_XGIVEREF(__pyx_t_11);
                            __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                            __Pyx_XGIVEREF(__pyx_t_12);
                            __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                            __Pyx_XGIVEREF(__pyx_t_13);
                            __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                            __Pyx_XGIVEREF(__pyx_t_14);
                            __pyx_cur_scope->__pyx_t_3 = __pyx_t_14;
                            __Pyx_XGIVEREF(__pyx_t_15);
                            __pyx_cur_scope->__pyx_t_4 = __pyx_t_15;
                            __Pyx_XGIVEREF(__pyx_t_16);
                            __pyx_cur_scope->__pyx_t_5 = __pyx_t_16;
                            __Pyx_XGIVEREF(__pyx_t_17);
                            __pyx_cur_scope->__pyx_t_6 = __pyx_t_17;
                            __Pyx_XGIVEREF(__pyx_t_18);
                            __pyx_cur_scope->__pyx_t_7 = __pyx_t_18;
                            __Pyx_XGIVEREF(__pyx_t_20);
                            __pyx_cur_scope->__pyx_t_8 = __pyx_t_20;
                            __Pyx_XGIVEREF(__pyx_t_22);
                            __pyx_cur_scope->__pyx_t_9 = __pyx_t_22;
                            __Pyx_XGIVEREF(__pyx_t_23);
                            __pyx_cur_scope->__pyx_t_10 = __pyx_t_23;
                            __Pyx_XGIVEREF(__pyx_t_24);
                            __pyx_cur_scope->__pyx_t_11 = __pyx_t_24;
                            __Pyx_XGIVEREF(__pyx_t_25);
                            __pyx_cur_scope->__pyx_t_12 = __pyx_t_25;
                            __Pyx_XGIVEREF(__pyx_t_37);
                            __pyx_cur_scope->__pyx_t_13 = __pyx_t_37;
                            __Pyx_XGIVEREF(__pyx_r);
                            __Pyx_RefNannyFinishContext();
                            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                            /* return from generator, awaiting value */
                            __pyx_generator->resume_label = 8;
                            return __pyx_r;
                            __pyx_L222_resume_from_await:;
                            __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                            __pyx_cur_scope->__pyx_t_0 = 0;
                            __Pyx_XGOTREF(__pyx_t_11);
                            __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                            __pyx_cur_scope->__pyx_t_1 = 0;
                            __Pyx_XGOTREF(__pyx_t_12);
                            __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                            __pyx_cur_scope->__pyx_t_2 = 0;
                            __Pyx_XGOTREF(__pyx_t_13);
                            __pyx_t_14 = __pyx_cur_scope->__pyx_t_3;
                            __pyx_cur_scope->__pyx_t_3 = 0;
                            __Pyx_XGOTREF(__pyx_t_14);
                            __pyx_t_15 = __pyx_cur_scope->__pyx_t_4;
                            __pyx_cur_scope->__pyx_t_4 = 0;
                            __Pyx_XGOTREF(__pyx_t_15);
                            __pyx_t_16 = __pyx_cur_scope->__pyx_t_5;
                            __pyx_cur_scope->__pyx_t_5 = 0;
                            __Pyx_XGOTREF(__pyx_t_16);
                            __pyx_t_17 = __pyx_cur_scope->__pyx_t_6;
                            __pyx_cur_scope->__pyx_t_6 = 0;
                            __Pyx_XGOTREF(__pyx_t_17);
                            __pyx_t_18 = __pyx_cur_scope->__pyx_t_7;
                            __pyx_cur_scope->__pyx_t_7 = 0;
                            __Pyx_XGOTREF(__pyx_t_18);
                            __pyx_t_20 = __pyx_cur_scope->__pyx_t_8;
                            __pyx_cur_scope->__pyx_t_8 = 0;
                            __Pyx_XGOTREF(__pyx_t_20);
                            __pyx_t_22 = __pyx_cur_scope->__pyx_t_9;
                            __pyx_cur_scope->__pyx_t_9 = 0;
                            __Pyx_XGOTREF(__pyx_t_22);
                            __pyx_t_23 = __pyx_cur_scope->__pyx_t_10;
                            __pyx_cur_scope->__pyx_t_10 = 0;
                            __Pyx_XGOTREF(__pyx_t_23);
                            __pyx_t_24 = __pyx_cur_scope->__pyx_t_11;
                            __pyx_cur_scope->__pyx_t_11 = 0;
                            __Pyx_XGOTREF(__pyx_t_24);
                            __pyx_t_25 = __pyx_cur_scope->__pyx_t_12;
                            __pyx_cur_scope->__pyx_t_12 = 0;
                            __Pyx_XGOTREF(__pyx_t_25);
                            __pyx_t_37 = __pyx_cur_scope->__pyx_t_13;
                            __pyx_cur_scope->__pyx_t_13 = 0;
                            __Pyx_XGOTREF(__pyx_t_37);
                            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4254, __pyx_L211_error)
                          } else if (likely(__pyx_t_19 == PYGEN_RETURN)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                          } else {
                            __Pyx_XGOTREF(__pyx_r);
                            __PYX_ERR(0, 4254, __pyx_L211_error)
                          }

                          /* "ws_package/controllers/activity_controller.py":4258
 *                             timeout=DB_OPERATION_TIMEOUT
 *                         )
 *                         logger.info("Deleted old ActivityInterval entries.")             # <<<<<<<<<<<<<<
 * 
 *                         # Delete OrgConfigurations entries older than 7 days
*/
                          __pyx_t_8 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4258, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_9);
                          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4258, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_6);
                          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                          __pyx_t_7 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_6))) {
                            __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
                            assert(__pyx_t_8);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                            __Pyx_INCREF(__pyx_t_8);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                            __pyx_t_7 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_mstate_global->__pyx_kp_u_Deleted_old_ActivityInterval_ent};
                            __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4258, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_3);
                          }
                          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                          /* "ws_package/controllers/activity_controller.py":4261
 * 
 *                         # Delete OrgConfigurations entries older than 7 days
 *                         await asyncio.wait_for(             # <<<<<<<<<<<<<<
 *                             session.execute(delete(OrgConfigurations).where(OrgConfigurations.timestamp < seven_days_ago)),
 *                             timeout=DB_OPERATION_TIMEOUT
*/
                          __pyx_t_6 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4261, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_8);
                          __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_wait_for); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4261, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_9);
                          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

                          /* "ws_package/controllers/activity_controller.py":4262
 *                         # Delete OrgConfigurations entries older than 7 days
 *                         await asyncio.wait_for(
 *                             session.execute(delete(OrgConfigurations).where(OrgConfigurations.timestamp < seven_days_ago)),             # <<<<<<<<<<<<<<
 *                             timeout=DB_OPERATION_TIMEOUT
 *                         )
*/
                          __pyx_t_5 = __pyx_cur_scope->__pyx_v_session;
                          __Pyx_INCREF(__pyx_t_5);
                          __pyx_t_38 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_47, __pyx_mstate_global->__pyx_n_u_delete); if (unlikely(!__pyx_t_47)) __PYX_ERR(0, 4262, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_47);
                          __Pyx_GetModuleGlobalName(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_OrgConfigurations); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 4262, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_39);
                          __pyx_t_7 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_47))) {
                            __pyx_t_38 = PyMethod_GET_SELF(__pyx_t_47);
                            assert(__pyx_t_38);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_47);
                            __Pyx_INCREF(__pyx_t_38);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_47, __pyx__function);
                            __pyx_t_7 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_38, __pyx_t_39};
                            __pyx_t_48 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_47, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                            __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                            __Pyx_DECREF(__pyx_t_47); __pyx_t_47 = 0;
                            if (unlikely(!__pyx_t_48)) __PYX_ERR(0, 4262, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_48);
                          }
                          __pyx_t_46 = __pyx_t_48;
                          __Pyx_INCREF(__pyx_t_46);
                          __Pyx_GetModuleGlobalName(__pyx_t_47, __pyx_mstate_global->__pyx_n_u_OrgConfigurations); if (unlikely(!__pyx_t_47)) __PYX_ERR(0, 4262, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_47);
                          __pyx_t_39 = __Pyx_PyObject_GetAttrStr(__pyx_t_47, __pyx_mstate_global->__pyx_n_u_timestamp); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 4262, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_39);
                          __Pyx_DECREF(__pyx_t_47); __pyx_t_47 = 0;
                          __pyx_t_47 = PyObject_RichCompare(__pyx_t_39, __pyx_cur_scope->__pyx_v_seven_days_ago, Py_LT); __Pyx_XGOTREF(__pyx_t_47); if (unlikely(!__pyx_t_47)) __PYX_ERR(0, 4262, __pyx_L211_error)
                          __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                          __pyx_t_7 = 0;
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_46, __pyx_t_47};
                            __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_46); __pyx_t_46 = 0;
                            __Pyx_DECREF(__pyx_t_47); __pyx_t_47 = 0;
                            __Pyx_DECREF(__pyx_t_48); __pyx_t_48 = 0;
                            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4262, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_2);
                          }
                          __pyx_t_7 = 0;
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_2};
                            __pyx_t_8 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                            if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4262, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_8);
                          }

                          /* "ws_package/controllers/activity_controller.py":4263
 *                         await asyncio.wait_for(
 *                             session.execute(delete(OrgConfigurations).where(OrgConfigurations.timestamp < seven_days_ago)),
 *                             timeout=DB_OPERATION_TIMEOUT             # <<<<<<<<<<<<<<
 *                         )
 *                         logger.info("Deleted old OrgConfigurations entries.")
*/
                          __pyx_t_2 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_DB_OPERATION_TIMEOUT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4263, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_2);
                          __pyx_t_7 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_9))) {
                            __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_9);
                            assert(__pyx_t_6);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
                            __Pyx_INCREF(__pyx_t_6);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
                            __pyx_t_7 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_6, __pyx_t_8};
                            __pyx_t_5 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4261, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_5);
                            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_timeout, __pyx_t_2, __pyx_t_5, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 4261, __pyx_L211_error)
                            __pyx_t_3 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_5);
                            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4261, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_3);
                          }
                          __pyx_t_19 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_3, &__pyx_r);
                          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                          if (likely(__pyx_t_19 == PYGEN_NEXT)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_XGIVEREF(__pyx_t_11);
                            __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                            __Pyx_XGIVEREF(__pyx_t_12);
                            __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                            __Pyx_XGIVEREF(__pyx_t_13);
                            __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                            __Pyx_XGIVEREF(__pyx_t_14);
                            __pyx_cur_scope->__pyx_t_3 = __pyx_t_14;
                            __Pyx_XGIVEREF(__pyx_t_15);
                            __pyx_cur_scope->__pyx_t_4 = __pyx_t_15;
                            __Pyx_XGIVEREF(__pyx_t_16);
                            __pyx_cur_scope->__pyx_t_5 = __pyx_t_16;
                            __Pyx_XGIVEREF(__pyx_t_17);
                            __pyx_cur_scope->__pyx_t_6 = __pyx_t_17;
                            __Pyx_XGIVEREF(__pyx_t_18);
                            __pyx_cur_scope->__pyx_t_7 = __pyx_t_18;
                            __Pyx_XGIVEREF(__pyx_t_20);
                            __pyx_cur_scope->__pyx_t_8 = __pyx_t_20;
                            __Pyx_XGIVEREF(__pyx_t_22);
                            __pyx_cur_scope->__pyx_t_9 = __pyx_t_22;
                            __Pyx_XGIVEREF(__pyx_t_23);
                            __pyx_cur_scope->__pyx_t_10 = __pyx_t_23;
                            __Pyx_XGIVEREF(__pyx_t_24);
                            __pyx_cur_scope->__pyx_t_11 = __pyx_t_24;
                            __Pyx_XGIVEREF(__pyx_t_25);
                            __pyx_cur_scope->__pyx_t_12 = __pyx_t_25;
                            __Pyx_XGIVEREF(__pyx_t_37);
                            __pyx_cur_scope->__pyx_t_13 = __pyx_t_37;
                            __Pyx_XGIVEREF(__pyx_r);
                            __Pyx_RefNannyFinishContext();
                            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                            /* return from generator, awaiting value */
                            __pyx_generator->resume_label = 9;
                            return __pyx_r;
                            __pyx_L223_resume_from_await:;
                            __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                            __pyx_cur_scope->__pyx_t_0 = 0;
                            __Pyx_XGOTREF(__pyx_t_11);
                            __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                            __pyx_cur_scope->__pyx_t_1 = 0;
                            __Pyx_XGOTREF(__pyx_t_12);
                            __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                            __pyx_cur_scope->__pyx_t_2 = 0;
                            __Pyx_XGOTREF(__pyx_t_13);
                            __pyx_t_14 = __pyx_cur_scope->__pyx_t_3;
                            __pyx_cur_scope->__pyx_t_3 = 0;
                            __Pyx_XGOTREF(__pyx_t_14);
                            __pyx_t_15 = __pyx_cur_scope->__pyx_t_4;
                            __pyx_cur_scope->__pyx_t_4 = 0;
                            __Pyx_XGOTREF(__pyx_t_15);
                            __pyx_t_16 = __pyx_cur_scope->__pyx_t_5;
                            __pyx_cur_scope->__pyx_t_5 = 0;
                            __Pyx_XGOTREF(__pyx_t_16);
                            __pyx_t_17 = __pyx_cur_scope->__pyx_t_6;
                            __pyx_cur_scope->__pyx_t_6 = 0;
                            __Pyx_XGOTREF(__pyx_t_17);
                            __pyx_t_18 = __pyx_cur_scope->__pyx_t_7;
                            __pyx_cur_scope->__pyx_t_7 = 0;
                            __Pyx_XGOTREF(__pyx_t_18);
                            __pyx_t_20 = __pyx_cur_scope->__pyx_t_8;
                            __pyx_cur_scope->__pyx_t_8 = 0;
                            __Pyx_XGOTREF(__pyx_t_20);
                            __pyx_t_22 = __pyx_cur_scope->__pyx_t_9;
                            __pyx_cur_scope->__pyx_t_9 = 0;
                            __Pyx_XGOTREF(__pyx_t_22);
                            __pyx_t_23 = __pyx_cur_scope->__pyx_t_10;
                            __pyx_cur_scope->__pyx_t_10 = 0;
                            __Pyx_XGOTREF(__pyx_t_23);
                            __pyx_t_24 = __pyx_cur_scope->__pyx_t_11;
                            __pyx_cur_scope->__pyx_t_11 = 0;
                            __Pyx_XGOTREF(__pyx_t_24);
                            __pyx_t_25 = __pyx_cur_scope->__pyx_t_12;
                            __pyx_cur_scope->__pyx_t_12 = 0;
                            __Pyx_XGOTREF(__pyx_t_25);
                            __pyx_t_37 = __pyx_cur_scope->__pyx_t_13;
                            __pyx_cur_scope->__pyx_t_13 = 0;
                            __Pyx_XGOTREF(__pyx_t_37);
                            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4261, __pyx_L211_error)
                          } else if (likely(__pyx_t_19 == PYGEN_RETURN)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                          } else {
                            __Pyx_XGOTREF(__pyx_r);
                            __PYX_ERR(0, 4261, __pyx_L211_error)
                          }

                          /* "ws_package/controllers/activity_controller.py":4265
 *                             timeout=DB_OPERATION_TIMEOUT
 *                         )
 *                         logger.info("Deleted old OrgConfigurations entries.")             # <<<<<<<<<<<<<<
 * 
 *                         # Delete Appmonitor entries older than 7 days
*/
                          __pyx_t_9 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4265, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_5);
                          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4265, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_2);
                          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                          __pyx_t_7 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_2))) {
                            __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2);
                            assert(__pyx_t_9);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
                            __Pyx_INCREF(__pyx_t_9);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
                            __pyx_t_7 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_mstate_global->__pyx_kp_u_Deleted_old_OrgConfigurations_en};
                            __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4265, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_3);
                          }
                          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                          /* "ws_package/controllers/activity_controller.py":4268
 * 
 *                         # Delete Appmonitor entries older than 7 days
 *                         await asyncio.wait_for(             # <<<<<<<<<<<<<<
 *                             session.execute(delete(Appmonitor).where(Appmonitor.timestamp < seven_days_ago)),
 *                             timeout=DB_OPERATION_TIMEOUT
*/
                          __pyx_t_2 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4268, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_9);
                          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_wait_for); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4268, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_5);
                          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

                          /* "ws_package/controllers/activity_controller.py":4269
 *                         # Delete Appmonitor entries older than 7 days
 *                         await asyncio.wait_for(
 *                             session.execute(delete(Appmonitor).where(Appmonitor.timestamp < seven_days_ago)),             # <<<<<<<<<<<<<<
 *                             timeout=DB_OPERATION_TIMEOUT
 *                         )
*/
                          __pyx_t_8 = __pyx_cur_scope->__pyx_v_session;
                          __Pyx_INCREF(__pyx_t_8);
                          __pyx_t_46 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_delete); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 4269, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_39);
                          __Pyx_GetModuleGlobalName(__pyx_t_38, __pyx_mstate_global->__pyx_n_u_Appmonitor); if (unlikely(!__pyx_t_38)) __PYX_ERR(0, 4269, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_38);
                          __pyx_t_7 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_39))) {
                            __pyx_t_46 = PyMethod_GET_SELF(__pyx_t_39);
                            assert(__pyx_t_46);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_39);
                            __Pyx_INCREF(__pyx_t_46);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_39, __pyx__function);
                            __pyx_t_7 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_46, __pyx_t_38};
                            __pyx_t_47 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_39, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_46); __pyx_t_46 = 0;
                            __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0;
                            __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                            if (unlikely(!__pyx_t_47)) __PYX_ERR(0, 4269, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_47);
                          }
                          __pyx_t_48 = __pyx_t_47;
                          __Pyx_INCREF(__pyx_t_48);
                          __Pyx_GetModuleGlobalName(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_Appmonitor); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 4269, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_39);
                          __pyx_t_38 = __Pyx_PyObject_GetAttrStr(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_timestamp); if (unlikely(!__pyx_t_38)) __PYX_ERR(0, 4269, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_38);
                          __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                          __pyx_t_39 = PyObject_RichCompare(__pyx_t_38, __pyx_cur_scope->__pyx_v_seven_days_ago, Py_LT); __Pyx_XGOTREF(__pyx_t_39); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 4269, __pyx_L211_error)
                          __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0;
                          __pyx_t_7 = 0;
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_48, __pyx_t_39};
                            __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_48); __pyx_t_48 = 0;
                            __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                            __Pyx_DECREF(__pyx_t_47); __pyx_t_47 = 0;
                            if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4269, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_6);
                          }
                          __pyx_t_7 = 0;
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_t_6};
                            __pyx_t_9 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                            if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4269, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_9);
                          }

                          /* "ws_package/controllers/activity_controller.py":4270
 *                         await asyncio.wait_for(
 *                             session.execute(delete(Appmonitor).where(Appmonitor.timestamp < seven_days_ago)),
 *                             timeout=DB_OPERATION_TIMEOUT             # <<<<<<<<<<<<<<
 *                         )
 *                         logger.info("Deleted old Appmonitor entries.")
*/
                          __pyx_t_6 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_DB_OPERATION_TIMEOUT); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4270, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_6);
                          __pyx_t_7 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_5))) {
                            __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
                            assert(__pyx_t_2);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                            __Pyx_INCREF(__pyx_t_2);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                            __pyx_t_7 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_2, __pyx_t_9};
                            __pyx_t_8 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4268, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_8);
                            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_timeout, __pyx_t_6, __pyx_t_8, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 4268, __pyx_L211_error)
                            __pyx_t_3 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_8);
                            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4268, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_3);
                          }
                          __pyx_t_19 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_3, &__pyx_r);
                          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                          if (likely(__pyx_t_19 == PYGEN_NEXT)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_XGIVEREF(__pyx_t_11);
                            __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                            __Pyx_XGIVEREF(__pyx_t_12);
                            __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                            __Pyx_XGIVEREF(__pyx_t_13);
                            __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                            __Pyx_XGIVEREF(__pyx_t_14);
                            __pyx_cur_scope->__pyx_t_3 = __pyx_t_14;
                            __Pyx_XGIVEREF(__pyx_t_15);
                            __pyx_cur_scope->__pyx_t_4 = __pyx_t_15;
                            __Pyx_XGIVEREF(__pyx_t_16);
                            __pyx_cur_scope->__pyx_t_5 = __pyx_t_16;
                            __Pyx_XGIVEREF(__pyx_t_17);
                            __pyx_cur_scope->__pyx_t_6 = __pyx_t_17;
                            __Pyx_XGIVEREF(__pyx_t_18);
                            __pyx_cur_scope->__pyx_t_7 = __pyx_t_18;
                            __Pyx_XGIVEREF(__pyx_t_20);
                            __pyx_cur_scope->__pyx_t_8 = __pyx_t_20;
                            __Pyx_XGIVEREF(__pyx_t_22);
                            __pyx_cur_scope->__pyx_t_9 = __pyx_t_22;
                            __Pyx_XGIVEREF(__pyx_t_23);
                            __pyx_cur_scope->__pyx_t_10 = __pyx_t_23;
                            __Pyx_XGIVEREF(__pyx_t_24);
                            __pyx_cur_scope->__pyx_t_11 = __pyx_t_24;
                            __Pyx_XGIVEREF(__pyx_t_25);
                            __pyx_cur_scope->__pyx_t_12 = __pyx_t_25;
                            __Pyx_XGIVEREF(__pyx_t_37);
                            __pyx_cur_scope->__pyx_t_13 = __pyx_t_37;
                            __Pyx_XGIVEREF(__pyx_r);
                            __Pyx_RefNannyFinishContext();
                            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                            /* return from generator, awaiting value */
                            __pyx_generator->resume_label = 10;
                            return __pyx_r;
                            __pyx_L224_resume_from_await:;
                            __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                            __pyx_cur_scope->__pyx_t_0 = 0;
                            __Pyx_XGOTREF(__pyx_t_11);
                            __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                            __pyx_cur_scope->__pyx_t_1 = 0;
                            __Pyx_XGOTREF(__pyx_t_12);
                            __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                            __pyx_cur_scope->__pyx_t_2 = 0;
                            __Pyx_XGOTREF(__pyx_t_13);
                            __pyx_t_14 = __pyx_cur_scope->__pyx_t_3;
                            __pyx_cur_scope->__pyx_t_3 = 0;
                            __Pyx_XGOTREF(__pyx_t_14);
                            __pyx_t_15 = __pyx_cur_scope->__pyx_t_4;
                            __pyx_cur_scope->__pyx_t_4 = 0;
                            __Pyx_XGOTREF(__pyx_t_15);
                            __pyx_t_16 = __pyx_cur_scope->__pyx_t_5;
                            __pyx_cur_scope->__pyx_t_5 = 0;
                            __Pyx_XGOTREF(__pyx_t_16);
                            __pyx_t_17 = __pyx_cur_scope->__pyx_t_6;
                            __pyx_cur_scope->__pyx_t_6 = 0;
                            __Pyx_XGOTREF(__pyx_t_17);
                            __pyx_t_18 = __pyx_cur_scope->__pyx_t_7;
                            __pyx_cur_scope->__pyx_t_7 = 0;
                            __Pyx_XGOTREF(__pyx_t_18);
                            __pyx_t_20 = __pyx_cur_scope->__pyx_t_8;
                            __pyx_cur_scope->__pyx_t_8 = 0;
                            __Pyx_XGOTREF(__pyx_t_20);
                            __pyx_t_22 = __pyx_cur_scope->__pyx_t_9;
                            __pyx_cur_scope->__pyx_t_9 = 0;
                            __Pyx_XGOTREF(__pyx_t_22);
                            __pyx_t_23 = __pyx_cur_scope->__pyx_t_10;
                            __pyx_cur_scope->__pyx_t_10 = 0;
                            __Pyx_XGOTREF(__pyx_t_23);
                            __pyx_t_24 = __pyx_cur_scope->__pyx_t_11;
                            __pyx_cur_scope->__pyx_t_11 = 0;
                            __Pyx_XGOTREF(__pyx_t_24);
                            __pyx_t_25 = __pyx_cur_scope->__pyx_t_12;
                            __pyx_cur_scope->__pyx_t_12 = 0;
                            __Pyx_XGOTREF(__pyx_t_25);
                            __pyx_t_37 = __pyx_cur_scope->__pyx_t_13;
                            __pyx_cur_scope->__pyx_t_13 = 0;
                            __Pyx_XGOTREF(__pyx_t_37);
                            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4268, __pyx_L211_error)
                          } else if (likely(__pyx_t_19 == PYGEN_RETURN)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                          } else {
                            __Pyx_XGOTREF(__pyx_r);
                            __PYX_ERR(0, 4268, __pyx_L211_error)
                          }

                          /* "ws_package/controllers/activity_controller.py":4272
 *                             timeout=DB_OPERATION_TIMEOUT
 *                         )
 *                         logger.info("Deleted old Appmonitor entries.")             # <<<<<<<<<<<<<<
 * 
 *                         # Commit with timeout
*/
                          __pyx_t_5 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4272, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_8);
                          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4272, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_6);
                          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                          __pyx_t_7 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_6))) {
                            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
                            assert(__pyx_t_5);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                            __Pyx_INCREF(__pyx_t_5);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                            __pyx_t_7 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Deleted_old_Appmonitor_entries};
                            __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4272, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_3);
                          }
                          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                          /* "ws_package/controllers/activity_controller.py":4275
 * 
 *                         # Commit with timeout
 *                         await asyncio.wait_for(             # <<<<<<<<<<<<<<
 *                             session.commit(),
 *                             timeout=DB_OPERATION_TIMEOUT
*/
                          __pyx_t_6 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4275, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_5);
                          __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_wait_for); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4275, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_8);
                          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                          /* "ws_package/controllers/activity_controller.py":4276
 *                         # Commit with timeout
 *                         await asyncio.wait_for(
 *                             session.commit(),             # <<<<<<<<<<<<<<
 *                             timeout=DB_OPERATION_TIMEOUT
 *                         )
*/
                          __pyx_t_9 = __pyx_cur_scope->__pyx_v_session;
                          __Pyx_INCREF(__pyx_t_9);
                          __pyx_t_7 = 0;
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_9, NULL};
                            __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_commit, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4276, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_5);
                          }

                          /* "ws_package/controllers/activity_controller.py":4277
 *                         await asyncio.wait_for(
 *                             session.commit(),
 *                             timeout=DB_OPERATION_TIMEOUT             # <<<<<<<<<<<<<<
 *                         )
 *                         logger.info("Successfully deleted old data and screenshots from specified tables.")
*/
                          __pyx_t_9 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_DB_OPERATION_TIMEOUT); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4277, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_9);
                          __pyx_t_7 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_8))) {
                            __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8);
                            assert(__pyx_t_6);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
                            __Pyx_INCREF(__pyx_t_6);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
                            __pyx_t_7 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_6, __pyx_t_5};
                            __pyx_t_2 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4275, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_2);
                            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_timeout, __pyx_t_9, __pyx_t_2, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 4275, __pyx_L211_error)
                            __pyx_t_3 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_2);
                            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4275, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_3);
                          }
                          __pyx_t_19 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_3, &__pyx_r);
                          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                          if (likely(__pyx_t_19 == PYGEN_NEXT)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_XGIVEREF(__pyx_t_11);
                            __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                            __Pyx_XGIVEREF(__pyx_t_12);
                            __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                            __Pyx_XGIVEREF(__pyx_t_13);
                            __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                            __Pyx_XGIVEREF(__pyx_t_14);
                            __pyx_cur_scope->__pyx_t_3 = __pyx_t_14;
                            __Pyx_XGIVEREF(__pyx_t_15);
                            __pyx_cur_scope->__pyx_t_4 = __pyx_t_15;
                            __Pyx_XGIVEREF(__pyx_t_16);
                            __pyx_cur_scope->__pyx_t_5 = __pyx_t_16;
                            __Pyx_XGIVEREF(__pyx_t_17);
                            __pyx_cur_scope->__pyx_t_6 = __pyx_t_17;
                            __Pyx_XGIVEREF(__pyx_t_18);
                            __pyx_cur_scope->__pyx_t_7 = __pyx_t_18;
                            __Pyx_XGIVEREF(__pyx_t_20);
                            __pyx_cur_scope->__pyx_t_8 = __pyx_t_20;
                            __Pyx_XGIVEREF(__pyx_t_22);
                            __pyx_cur_scope->__pyx_t_9 = __pyx_t_22;
                            __Pyx_XGIVEREF(__pyx_t_23);
                            __pyx_cur_scope->__pyx_t_10 = __pyx_t_23;
                            __Pyx_XGIVEREF(__pyx_t_24);
                            __pyx_cur_scope->__pyx_t_11 = __pyx_t_24;
                            __Pyx_XGIVEREF(__pyx_t_25);
                            __pyx_cur_scope->__pyx_t_12 = __pyx_t_25;
                            __Pyx_XGIVEREF(__pyx_t_37);
                            __pyx_cur_scope->__pyx_t_13 = __pyx_t_37;
                            __Pyx_XGIVEREF(__pyx_r);
                            __Pyx_RefNannyFinishContext();
                            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                            /* return from generator, awaiting value */
                            __pyx_generator->resume_label = 11;
                            return __pyx_r;
                            __pyx_L225_resume_from_await:;
                            __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                            __pyx_cur_scope->__pyx_t_0 = 0;
                            __Pyx_XGOTREF(__pyx_t_11);
                            __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                            __pyx_cur_scope->__pyx_t_1 = 0;
                            __Pyx_XGOTREF(__pyx_t_12);
                            __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                            __pyx_cur_scope->__pyx_t_2 = 0;
                            __Pyx_XGOTREF(__pyx_t_13);
                            __pyx_t_14 = __pyx_cur_scope->__pyx_t_3;
                            __pyx_cur_scope->__pyx_t_3 = 0;
                            __Pyx_XGOTREF(__pyx_t_14);
                            __pyx_t_15 = __pyx_cur_scope->__pyx_t_4;
                            __pyx_cur_scope->__pyx_t_4 = 0;
                            __Pyx_XGOTREF(__pyx_t_15);
                            __pyx_t_16 = __pyx_cur_scope->__pyx_t_5;
                            __pyx_cur_scope->__pyx_t_5 = 0;
                            __Pyx_XGOTREF(__pyx_t_16);
                            __pyx_t_17 = __pyx_cur_scope->__pyx_t_6;
                            __pyx_cur_scope->__pyx_t_6 = 0;
                            __Pyx_XGOTREF(__pyx_t_17);
                            __pyx_t_18 = __pyx_cur_scope->__pyx_t_7;
                            __pyx_cur_scope->__pyx_t_7 = 0;
                            __Pyx_XGOTREF(__pyx_t_18);
                            __pyx_t_20 = __pyx_cur_scope->__pyx_t_8;
                            __pyx_cur_scope->__pyx_t_8 = 0;
                            __Pyx_XGOTREF(__pyx_t_20);
                            __pyx_t_22 = __pyx_cur_scope->__pyx_t_9;
                            __pyx_cur_scope->__pyx_t_9 = 0;
                            __Pyx_XGOTREF(__pyx_t_22);
                            __pyx_t_23 = __pyx_cur_scope->__pyx_t_10;
                            __pyx_cur_scope->__pyx_t_10 = 0;
                            __Pyx_XGOTREF(__pyx_t_23);
                            __pyx_t_24 = __pyx_cur_scope->__pyx_t_11;
                            __pyx_cur_scope->__pyx_t_11 = 0;
                            __Pyx_XGOTREF(__pyx_t_24);
                            __pyx_t_25 = __pyx_cur_scope->__pyx_t_12;
                            __pyx_cur_scope->__pyx_t_12 = 0;
                            __Pyx_XGOTREF(__pyx_t_25);
                            __pyx_t_37 = __pyx_cur_scope->__pyx_t_13;
                            __pyx_cur_scope->__pyx_t_13 = 0;
                            __Pyx_XGOTREF(__pyx_t_37);
                            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4275, __pyx_L211_error)
                          } else if (likely(__pyx_t_19 == PYGEN_RETURN)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                          } else {
                            __Pyx_XGOTREF(__pyx_r);
                            __PYX_ERR(0, 4275, __pyx_L211_error)
                          }

                          /* "ws_package/controllers/activity_controller.py":4279
 *                             timeout=DB_OPERATION_TIMEOUT
 *                         )
 *                         logger.info("Successfully deleted old data and screenshots from specified tables.")             # <<<<<<<<<<<<<<
 * 
 *                     except asyncio.TimeoutError:
*/
                          __pyx_t_8 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4279, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_2);
                          __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4279, __pyx_L211_error)
                          __Pyx_GOTREF(__pyx_t_9);
                          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                          __pyx_t_7 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_9))) {
                            __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9);
                            assert(__pyx_t_8);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
                            __Pyx_INCREF(__pyx_t_8);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
                            __pyx_t_7 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_mstate_global->__pyx_kp_u_Successfully_deleted_old_data_an};
                            __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_7, (2-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4279, __pyx_L211_error)
                            __Pyx_GOTREF(__pyx_t_3);
                          }
                          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                          /* "ws_package/controllers/activity_controller.py":4241
 *             with db_lock_manager.write_lock():
 *                 async with async_session() as session:
 *                     try:             # <<<<<<<<<<<<<<
 *                         # Delete screenshots from database (bulk delete is faster)
 *                         if screenshots_to_delete:
*/
                        }
                        __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                        __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                        goto __pyx_L216_try_end;
                        __pyx_L211_error:;
                        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                        __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                        __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                        __Pyx_XDECREF(__pyx_t_46); __pyx_t_46 = 0;
                        __Pyx_XDECREF(__pyx_t_47); __pyx_t_47 = 0;
                        __Pyx_XDECREF(__pyx_t_48); __pyx_t_48 = 0;
                        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

                        /* "ws_package/controllers/activity_controller.py":4281
 *                         logger.info("Successfully deleted old data and screenshots from specified tables.")
 * 
 *                     except asyncio.TimeoutError:             # <<<<<<<<<<<<<<
 *                         logger.error("Database operation timed out after %ss in delete_old_data_and_screenshots", DB_OPERATION_TIMEOUT)
 *                         await session.rollback()
*/
                        __Pyx_ErrFetch(&__pyx_t_3, &__pyx_t_9, &__pyx_t_8);
                        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4281, __pyx_L213_except_error)
                        __Pyx_GOTREF(__pyx_t_2);
                        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_TimeoutError); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4281, __pyx_L213_except_error)
                        __Pyx_GOTREF(__pyx_t_5);
                        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                        __pyx_t_30 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_3, __pyx_t_5);
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                        __Pyx_ErrRestore(__pyx_t_3, __pyx_t_9, __pyx_t_8);
                        __pyx_t_3 = 0; __pyx_t_9 = 0; __pyx_t_8 = 0;
                        if (__pyx_t_30) {
                          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.delete_old_data_and_screenshots", __pyx_clineno, __pyx_lineno, __pyx_filename);
                          if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_3) < 0) __PYX_ERR(0, 4281, __pyx_L213_except_error)
                          __Pyx_XGOTREF(__pyx_t_8);
                          __Pyx_XGOTREF(__pyx_t_9);
                          __Pyx_XGOTREF(__pyx_t_3);

                          /* "ws_package/controllers/activity_controller.py":4282
 * 
 *                     except asyncio.TimeoutError:
 *                         logger.error("Database operation timed out after %ss in delete_old_data_and_screenshots", DB_OPERATION_TIMEOUT)             # <<<<<<<<<<<<<<
 *                         await session.rollback()
 *                     except Exception as e:
*/
                          __pyx_t_2 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4282, __pyx_L213_except_error)
                          __Pyx_GOTREF(__pyx_t_6);
                          __pyx_t_47 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_47)) __PYX_ERR(0, 4282, __pyx_L213_except_error)
                          __Pyx_GOTREF(__pyx_t_47);
                          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                          __pyx_t_6 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_DB_OPERATION_TIMEOUT); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4282, __pyx_L213_except_error)
                          __Pyx_GOTREF(__pyx_t_6);
                          __pyx_t_7 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_47))) {
                            __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_47);
                            assert(__pyx_t_2);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_47);
                            __Pyx_INCREF(__pyx_t_2);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_47, __pyx__function);
                            __pyx_t_7 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Database_operation_timed_out_aft, __pyx_t_6};
                            __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_47, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                            __Pyx_DECREF(__pyx_t_47); __pyx_t_47 = 0;
                            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4282, __pyx_L213_except_error)
                            __Pyx_GOTREF(__pyx_t_5);
                          }
                          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                          /* "ws_package/controllers/activity_controller.py":4283
 *                     except asyncio.TimeoutError:
 *                         logger.error("Database operation timed out after %ss in delete_old_data_and_screenshots", DB_OPERATION_TIMEOUT)
 *                         await session.rollback()             # <<<<<<<<<<<<<<
 *                     except Exception as e:
 *                         logger.error("Error deleting database entries: %s", e, exc_info=True)
*/
                          __pyx_t_47 = __pyx_cur_scope->__pyx_v_session;
                          __Pyx_INCREF(__pyx_t_47);
                          __pyx_t_7 = 0;
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_47, NULL};
                            __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_rollback, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_47); __pyx_t_47 = 0;
                            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4283, __pyx_L213_except_error)
                            __Pyx_GOTREF(__pyx_t_5);
                          }
                          __pyx_t_19 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
                          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                          if (likely(__pyx_t_19 == PYGEN_NEXT)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_XGIVEREF(__pyx_t_3);
                            __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
                            __Pyx_XGIVEREF(__pyx_t_8);
                            __pyx_cur_scope->__pyx_t_1 = __pyx_t_8;
                            __Pyx_XGIVEREF(__pyx_t_9);
                            __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
                            __Pyx_XGIVEREF(__pyx_t_11);
                            __pyx_cur_scope->__pyx_t_3 = __pyx_t_11;
                            __Pyx_XGIVEREF(__pyx_t_12);
                            __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                            __Pyx_XGIVEREF(__pyx_t_13);
                            __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                            __Pyx_XGIVEREF(__pyx_t_14);
                            __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                            __Pyx_XGIVEREF(__pyx_t_15);
                            __pyx_cur_scope->__pyx_t_7 = __pyx_t_15;
                            __Pyx_XGIVEREF(__pyx_t_16);
                            __pyx_cur_scope->__pyx_t_8 = __pyx_t_16;
                            __Pyx_XGIVEREF(__pyx_t_17);
                            __pyx_cur_scope->__pyx_t_9 = __pyx_t_17;
                            __Pyx_XGIVEREF(__pyx_t_18);
                            __pyx_cur_scope->__pyx_t_10 = __pyx_t_18;
                            __Pyx_XGIVEREF(__pyx_t_20);
                            __pyx_cur_scope->__pyx_t_11 = __pyx_t_20;
                            __Pyx_XGIVEREF(__pyx_t_22);
                            __pyx_cur_scope->__pyx_t_12 = __pyx_t_22;
                            __Pyx_XGIVEREF(__pyx_t_23);
                            __pyx_cur_scope->__pyx_t_13 = __pyx_t_23;
                            __Pyx_XGIVEREF(__pyx_t_24);
                            __pyx_cur_scope->__pyx_t_14 = __pyx_t_24;
                            __Pyx_XGIVEREF(__pyx_t_25);
                            __pyx_cur_scope->__pyx_t_15 = __pyx_t_25;
                            __Pyx_XGIVEREF(__pyx_t_37);
                            __pyx_cur_scope->__pyx_t_16 = __pyx_t_37;
                            __Pyx_XGIVEREF(__pyx_r);
                            __Pyx_RefNannyFinishContext();
                            __Pyx_Coroutine_SwapException(__pyx_generator);
                            /* return from generator, awaiting value */
                            __pyx_generator->resume_label = 12;
                            return __pyx_r;
                            __pyx_L228_resume_from_await:;
                            __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
                            __pyx_cur_scope->__pyx_t_0 = 0;
                            __Pyx_XGOTREF(__pyx_t_3);
                            __pyx_t_8 = __pyx_cur_scope->__pyx_t_1;
                            __pyx_cur_scope->__pyx_t_1 = 0;
                            __Pyx_XGOTREF(__pyx_t_8);
                            __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
                            __pyx_cur_scope->__pyx_t_2 = 0;
                            __Pyx_XGOTREF(__pyx_t_9);
                            __pyx_t_11 = __pyx_cur_scope->__pyx_t_3;
                            __pyx_cur_scope->__pyx_t_3 = 0;
                            __Pyx_XGOTREF(__pyx_t_11);
                            __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                            __pyx_cur_scope->__pyx_t_4 = 0;
                            __Pyx_XGOTREF(__pyx_t_12);
                            __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                            __pyx_cur_scope->__pyx_t_5 = 0;
                            __Pyx_XGOTREF(__pyx_t_13);
                            __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                            __pyx_cur_scope->__pyx_t_6 = 0;
                            __Pyx_XGOTREF(__pyx_t_14);
                            __pyx_t_15 = __pyx_cur_scope->__pyx_t_7;
                            __pyx_cur_scope->__pyx_t_7 = 0;
                            __Pyx_XGOTREF(__pyx_t_15);
                            __pyx_t_16 = __pyx_cur_scope->__pyx_t_8;
                            __pyx_cur_scope->__pyx_t_8 = 0;
                            __Pyx_XGOTREF(__pyx_t_16);
                            __pyx_t_17 = __pyx_cur_scope->__pyx_t_9;
                            __pyx_cur_scope->__pyx_t_9 = 0;
                            __Pyx_XGOTREF(__pyx_t_17);
                            __pyx_t_18 = __pyx_cur_scope->__pyx_t_10;
                            __pyx_cur_scope->__pyx_t_10 = 0;
                            __Pyx_XGOTREF(__pyx_t_18);
                            __pyx_t_20 = __pyx_cur_scope->__pyx_t_11;
                            __pyx_cur_scope->__pyx_t_11 = 0;
                            __Pyx_XGOTREF(__pyx_t_20);
                            __pyx_t_22 = __pyx_cur_scope->__pyx_t_12;
                            __pyx_cur_scope->__pyx_t_12 = 0;
                            __Pyx_XGOTREF(__pyx_t_22);
                            __pyx_t_23 = __pyx_cur_scope->__pyx_t_13;
                            __pyx_cur_scope->__pyx_t_13 = 0;
                            __Pyx_XGOTREF(__pyx_t_23);
                            __pyx_t_24 = __pyx_cur_scope->__pyx_t_14;
                            __pyx_cur_scope->__pyx_t_14 = 0;
                            __Pyx_XGOTREF(__pyx_t_24);
                            __pyx_t_25 = __pyx_cur_scope->__pyx_t_15;
                            __pyx_cur_scope->__pyx_t_15 = 0;
                            __Pyx_XGOTREF(__pyx_t_25);
                            __pyx_t_37 = __pyx_cur_scope->__pyx_t_16;
                            __pyx_cur_scope->__pyx_t_16 = 0;
                            __Pyx_XGOTREF(__pyx_t_37);
                            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4283, __pyx_L213_except_error)
                          } else if (likely(__pyx_t_19 == PYGEN_RETURN)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                          } else {
                            __Pyx_XGOTREF(__pyx_r);
                            __PYX_ERR(0, 4283, __pyx_L213_except_error)
                          }
                          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                          goto __pyx_L212_exception_handled;
                        }

                        /* "ws_package/controllers/activity_controller.py":4284
 *                         logger.error("Database operation timed out after %ss in delete_old_data_and_screenshots", DB_OPERATION_TIMEOUT)
 *                         await session.rollback()
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error deleting database entries: %s", e, exc_info=True)
 *                         await session.rollback()
*/
                        __pyx_t_30 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                        if (__pyx_t_30) {
                          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.delete_old_data_and_screenshots", __pyx_clineno, __pyx_lineno, __pyx_filename);
                          if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_9, &__pyx_t_8) < 0) __PYX_ERR(0, 4284, __pyx_L213_except_error)
                          __Pyx_XGOTREF(__pyx_t_3);
                          __Pyx_XGOTREF(__pyx_t_9);
                          __Pyx_XGOTREF(__pyx_t_8);
                          __Pyx_INCREF(__pyx_t_9);
                          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
                          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_9);
                          __Pyx_GIVEREF(__pyx_t_9);
                          /*try:*/ {

                            /* "ws_package/controllers/activity_controller.py":4285
 *                         await session.rollback()
 *                     except Exception as e:
 *                         logger.error("Error deleting database entries: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 *                         await session.rollback()
 * 
*/
                            __pyx_t_47 = NULL;
                            __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4285, __pyx_L234_error)
                            __Pyx_GOTREF(__pyx_t_6);
                            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4285, __pyx_L234_error)
                            __Pyx_GOTREF(__pyx_t_2);
                            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                            __pyx_t_7 = 1;
                            #if CYTHON_UNPACK_METHODS
                            if (unlikely(PyMethod_Check(__pyx_t_2))) {
                              __pyx_t_47 = PyMethod_GET_SELF(__pyx_t_2);
                              assert(__pyx_t_47);
                              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
                              __Pyx_INCREF(__pyx_t_47);
                              __Pyx_INCREF(__pyx__function);
                              __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
                              __pyx_t_7 = 0;
                            }
                            #endif
                            {
                              PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_47, __pyx_mstate_global->__pyx_kp_u_Error_deleting_database_entries, __pyx_cur_scope->__pyx_v_e};
                              __pyx_t_6 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4285, __pyx_L234_error)
                              __Pyx_GOTREF(__pyx_t_6);
                              if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_6, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 4285, __pyx_L234_error)
                              __pyx_t_5 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_6);
                              __Pyx_XDECREF(__pyx_t_47); __pyx_t_47 = 0;
                              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                              if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4285, __pyx_L234_error)
                              __Pyx_GOTREF(__pyx_t_5);
                            }
                            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                            /* "ws_package/controllers/activity_controller.py":4286
 *                     except Exception as e:
 *                         logger.error("Error deleting database entries: %s", e, exc_info=True)
 *                         await session.rollback()             # <<<<<<<<<<<<<<
 * 
 *         except Exception as e:
*/
                            __pyx_t_2 = __pyx_cur_scope->__pyx_v_session;
                            __Pyx_INCREF(__pyx_t_2);
                            __pyx_t_7 = 0;
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
                              __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_rollback, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                              if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4286, __pyx_L234_error)
                              __Pyx_GOTREF(__pyx_t_5);
                            }
                            __pyx_t_19 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
                            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                            if (likely(__pyx_t_19 == PYGEN_NEXT)) {
                              __Pyx_GOTREF(__pyx_r);
                              __Pyx_XGIVEREF(__pyx_t_3);
                              __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
                              __Pyx_XGIVEREF(__pyx_t_8);
                              __pyx_cur_scope->__pyx_t_1 = __pyx_t_8;
                              __Pyx_XGIVEREF(__pyx_t_9);
                              __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
                              __Pyx_XGIVEREF(__pyx_t_11);
                              __pyx_cur_scope->__pyx_t_3 = __pyx_t_11;
                              __Pyx_XGIVEREF(__pyx_t_12);
                              __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                              __Pyx_XGIVEREF(__pyx_t_13);
                              __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                              __Pyx_XGIVEREF(__pyx_t_14);
                              __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                              __Pyx_XGIVEREF(__pyx_t_15);
                              __pyx_cur_scope->__pyx_t_7 = __pyx_t_15;
                              __Pyx_XGIVEREF(__pyx_t_16);
                              __pyx_cur_scope->__pyx_t_8 = __pyx_t_16;
                              __Pyx_XGIVEREF(__pyx_t_17);
                              __pyx_cur_scope->__pyx_t_9 = __pyx_t_17;
                              __Pyx_XGIVEREF(__pyx_t_18);
                              __pyx_cur_scope->__pyx_t_10 = __pyx_t_18;
                              __Pyx_XGIVEREF(__pyx_t_20);
                              __pyx_cur_scope->__pyx_t_11 = __pyx_t_20;
                              __Pyx_XGIVEREF(__pyx_t_22);
                              __pyx_cur_scope->__pyx_t_12 = __pyx_t_22;
                              __Pyx_XGIVEREF(__pyx_t_23);
                              __pyx_cur_scope->__pyx_t_13 = __pyx_t_23;
                              __Pyx_XGIVEREF(__pyx_t_24);
                              __pyx_cur_scope->__pyx_t_14 = __pyx_t_24;
                              __Pyx_XGIVEREF(__pyx_t_25);
                              __pyx_cur_scope->__pyx_t_15 = __pyx_t_25;
                              __Pyx_XGIVEREF(__pyx_t_37);
                              __pyx_cur_scope->__pyx_t_16 = __pyx_t_37;
                              __Pyx_XGIVEREF(__pyx_r);
                              __Pyx_RefNannyFinishContext();
                              __Pyx_Coroutine_SwapException(__pyx_generator);
                              /* return from generator, awaiting value */
                              __pyx_generator->resume_label = 13;
                              return __pyx_r;
                              __pyx_L236_resume_from_await:;
                              __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
                              __pyx_cur_scope->__pyx_t_0 = 0;
                              __Pyx_XGOTREF(__pyx_t_3);
                              __pyx_t_8 = __pyx_cur_scope->__pyx_t_1;
                              __pyx_cur_scope->__pyx_t_1 = 0;
                              __Pyx_XGOTREF(__pyx_t_8);
                              __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
                              __pyx_cur_scope->__pyx_t_2 = 0;
                              __Pyx_XGOTREF(__pyx_t_9);
                              __pyx_t_11 = __pyx_cur_scope->__pyx_t_3;
                              __pyx_cur_scope->__pyx_t_3 = 0;
                              __Pyx_XGOTREF(__pyx_t_11);
                              __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                              __pyx_cur_scope->__pyx_t_4 = 0;
                              __Pyx_XGOTREF(__pyx_t_12);
                              __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                              __pyx_cur_scope->__pyx_t_5 = 0;
                              __Pyx_XGOTREF(__pyx_t_13);
                              __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                              __pyx_cur_scope->__pyx_t_6 = 0;
                              __Pyx_XGOTREF(__pyx_t_14);
                              __pyx_t_15 = __pyx_cur_scope->__pyx_t_7;
                              __pyx_cur_scope->__pyx_t_7 = 0;
                              __Pyx_XGOTREF(__pyx_t_15);
                              __pyx_t_16 = __pyx_cur_scope->__pyx_t_8;
                              __pyx_cur_scope->__pyx_t_8 = 0;
                              __Pyx_XGOTREF(__pyx_t_16);
                              __pyx_t_17 = __pyx_cur_scope->__pyx_t_9;
                              __pyx_cur_scope->__pyx_t_9 = 0;
                              __Pyx_XGOTREF(__pyx_t_17);
                              __pyx_t_18 = __pyx_cur_scope->__pyx_t_10;
                              __pyx_cur_scope->__pyx_t_10 = 0;
                              __Pyx_XGOTREF(__pyx_t_18);
                              __pyx_t_20 = __pyx_cur_scope->__pyx_t_11;
                              __pyx_cur_scope->__pyx_t_11 = 0;
                              __Pyx_XGOTREF(__pyx_t_20);
                              __pyx_t_22 = __pyx_cur_scope->__pyx_t_12;
                              __pyx_cur_scope->__pyx_t_12 = 0;
                              __Pyx_XGOTREF(__pyx_t_22);
                              __pyx_t_23 = __pyx_cur_scope->__pyx_t_13;
                              __pyx_cur_scope->__pyx_t_13 = 0;
                              __Pyx_XGOTREF(__pyx_t_23);
                              __pyx_t_24 = __pyx_cur_scope->__pyx_t_14;
                              __pyx_cur_scope->__pyx_t_14 = 0;
                              __Pyx_XGOTREF(__pyx_t_24);
                              __pyx_t_25 = __pyx_cur_scope->__pyx_t_15;
                              __pyx_cur_scope->__pyx_t_15 = 0;
                              __Pyx_XGOTREF(__pyx_t_25);
                              __pyx_t_37 = __pyx_cur_scope->__pyx_t_16;
                              __pyx_cur_scope->__pyx_t_16 = 0;
                              __Pyx_XGOTREF(__pyx_t_37);
                              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4286, __pyx_L234_error)
                            } else if (likely(__pyx_t_19 == PYGEN_RETURN)) {
                              __Pyx_GOTREF(__pyx_r);
                              __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                            } else {
                              __Pyx_XGOTREF(__pyx_r);
                              __PYX_ERR(0, 4286, __pyx_L234_error)
                            }
                          }

                          /* "ws_package/controllers/activity_controller.py":4284
 *                         logger.error("Database operation timed out after %ss in delete_old_data_and_screenshots", DB_OPERATION_TIMEOUT)
 *                         await session.rollback()
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error deleting database entries: %s", e, exc_info=True)
 *                         await session.rollback()
*/
                          /*finally:*/ {
                            /*normal exit:*/{
                              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                              goto __pyx_L235;
                            }
                            __pyx_L234_error:;
                            /*exception exit:*/{
                              __Pyx_PyThreadState_assign
                              __pyx_t_21 = 0; __pyx_t_36 = 0; __pyx_t_35 = 0; __pyx_t_34 = 0; __pyx_t_33 = 0; __pyx_t_32 = 0;
                              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                              __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                              __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                              __Pyx_XDECREF(__pyx_t_46); __pyx_t_46 = 0;
                              __Pyx_XDECREF(__pyx_t_47); __pyx_t_47 = 0;
                              __Pyx_XDECREF(__pyx_t_48); __pyx_t_48 = 0;
                              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                               __Pyx_ExceptionSwap(&__pyx_t_34, &__pyx_t_33, &__pyx_t_32);
                              if ( unlikely(__Pyx_GetException(&__pyx_t_21, &__pyx_t_36, &__pyx_t_35) < 0)) __Pyx_ErrFetch(&__pyx_t_21, &__pyx_t_36, &__pyx_t_35);
                              __Pyx_XGOTREF(__pyx_t_21);
                              __Pyx_XGOTREF(__pyx_t_36);
                              __Pyx_XGOTREF(__pyx_t_35);
                              __Pyx_XGOTREF(__pyx_t_34);
                              __Pyx_XGOTREF(__pyx_t_33);
                              __Pyx_XGOTREF(__pyx_t_32);
                              __pyx_t_30 = __pyx_lineno; __pyx_t_29 = __pyx_clineno; __pyx_t_49 = __pyx_filename;
                              {
                                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                              }
                              __Pyx_XGIVEREF(__pyx_t_34);
                              __Pyx_XGIVEREF(__pyx_t_33);
                              __Pyx_XGIVEREF(__pyx_t_32);
                              __Pyx_ExceptionReset(__pyx_t_34, __pyx_t_33, __pyx_t_32);
                              __Pyx_XGIVEREF(__pyx_t_21);
                              __Pyx_XGIVEREF(__pyx_t_36);
                              __Pyx_XGIVEREF(__pyx_t_35);
                              __Pyx_ErrRestore(__pyx_t_21, __pyx_t_36, __pyx_t_35);
                              __pyx_t_21 = 0; __pyx_t_36 = 0; __pyx_t_35 = 0; __pyx_t_34 = 0; __pyx_t_33 = 0; __pyx_t_32 = 0;
                              __pyx_lineno = __pyx_t_30; __pyx_clineno = __pyx_t_29; __pyx_filename = __pyx_t_49;
                              goto __pyx_L213_except_error;
                            }
                            __pyx_L235:;
                          }
                          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                          goto __pyx_L212_exception_handled;
                        }
                        goto __pyx_L213_except_error;

                        /* "ws_package/controllers/activity_controller.py":4241
 *             with db_lock_manager.write_lock():
 *                 async with async_session() as session:
 *                     try:             # <<<<<<<<<<<<<<
 *                         # Delete screenshots from database (bulk delete is faster)
 *                         if screenshots_to_delete:
*/
                        __pyx_L213_except_error:;
                        __Pyx_XGIVEREF(__pyx_t_22);
                        __Pyx_XGIVEREF(__pyx_t_25);
                        __Pyx_XGIVEREF(__pyx_t_20);
                        __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_25, __pyx_t_20);
                        goto __pyx_L205_error;
                        __pyx_L212_exception_handled:;
                        __Pyx_XGIVEREF(__pyx_t_22);
                        __Pyx_XGIVEREF(__pyx_t_25);
                        __Pyx_XGIVEREF(__pyx_t_20);
                        __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_25, __pyx_t_20);
                        __pyx_L216_try_end:;
                      }

                      /* "ws_package/controllers/activity_controller.py":4240
 *             # STEP 3: Delete database entries (QUICK, inside lock)
 *             with db_lock_manager.write_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     try:
 *                         # Delete screenshots from database (bulk delete is faster)
*/
                    }
                    __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                    goto __pyx_L210_try_end;
                    __pyx_L205_error:;
                    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                    __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                    __Pyx_XDECREF(__pyx_t_46); __pyx_t_46 = 0;
                    __Pyx_XDECREF(__pyx_t_47); __pyx_t_47 = 0;
                    __Pyx_XDECREF(__pyx_t_48); __pyx_t_48 = 0;
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                    /*except:*/ {
                      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.delete_old_data_and_screenshots", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_3) < 0) __PYX_ERR(0, 4240, __pyx_L207_except_error)
                      __Pyx_XGOTREF(__pyx_t_8);
                      __Pyx_XGOTREF(__pyx_t_9);
                      __Pyx_XGOTREF(__pyx_t_3);
                      __pyx_t_5 = PyTuple_Pack(3, __pyx_t_8, __pyx_t_9, __pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4240, __pyx_L207_except_error)
                      __Pyx_GOTREF(__pyx_t_5);
                      __pyx_t_20 = __Pyx_PyObject_Call(__pyx_t_23, __pyx_t_5, NULL);
                      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 4240, __pyx_L207_except_error)
                      __Pyx_GOTREF(__pyx_t_20);
                      __pyx_t_19 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_20, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                      if (likely(__pyx_t_19 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_8);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_8;
                        __Pyx_XGIVEREF(__pyx_t_9);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_t_20);
                        __pyx_cur_scope->__pyx_t_11 = __pyx_t_20;
                        __Pyx_XGIVEREF(__pyx_t_23);
                        __pyx_cur_scope->__pyx_t_12 = __pyx_t_23;
                        __Pyx_XGIVEREF(__pyx_t_24);
                        __pyx_cur_scope->__pyx_t_13 = __pyx_t_24;
                        __Pyx_XGIVEREF(__pyx_t_37);
                        __pyx_cur_scope->__pyx_t_14 = __pyx_t_37;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_SwapException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 14;
                        return __pyx_r;
                        __pyx_L244_resume_from_await:;
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_8 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_8);
                        __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_9);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        __pyx_t_20 = __pyx_cur_scope->__pyx_t_11;
                        __pyx_cur_scope->__pyx_t_11 = 0;
                        __Pyx_XGOTREF(__pyx_t_20);
                        __pyx_t_23 = __pyx_cur_scope->__pyx_t_12;
                        __pyx_cur_scope->__pyx_t_12 = 0;
                        __Pyx_XGOTREF(__pyx_t_23);
                        __pyx_t_24 = __pyx_cur_scope->__pyx_t_13;
                        __pyx_cur_scope->__pyx_t_13 = 0;
                        __Pyx_XGOTREF(__pyx_t_24);
                        __pyx_t_37 = __pyx_cur_scope->__pyx_t_14;
                        __pyx_cur_scope->__pyx_t_14 = 0;
                        __Pyx_XGOTREF(__pyx_t_37);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4240, __pyx_L207_except_error)
                        __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
                      } else if (likely(__pyx_t_19 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_5 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 4240, __pyx_L207_except_error)
                      }
                      __pyx_t_20 = __pyx_t_5;
                      __pyx_t_5 = 0;
                      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_20);
                      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                      if (__pyx_t_1 < (0)) __PYX_ERR(0, 4240, __pyx_L207_except_error)
                      __pyx_t_4 = (!__pyx_t_1);
                      if (unlikely(__pyx_t_4)) {
                        __Pyx_GIVEREF(__pyx_t_8);
                        __Pyx_GIVEREF(__pyx_t_9);
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __Pyx_ErrRestoreWithState(__pyx_t_8, __pyx_t_9, __pyx_t_3);
                        __pyx_t_8 = 0;  __pyx_t_9 = 0;  __pyx_t_3 = 0; 
                        __PYX_ERR(0, 4240, __pyx_L207_except_error)
                      }
                      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                      goto __pyx_L206_exception_handled;
                    }
                    __pyx_L207_except_error:;
                    __Pyx_XGIVEREF(__pyx_t_37);
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __Pyx_ExceptionReset(__pyx_t_37, __pyx_t_15, __pyx_t_18);
                    goto __pyx_L194_error;
                    __pyx_L206_exception_handled:;
                    __Pyx_XGIVEREF(__pyx_t_37);
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __Pyx_ExceptionReset(__pyx_t_37, __pyx_t_15, __pyx_t_18);
                    __pyx_L210_try_end:;
                  }
                }
                /*finally:*/ {
                  /*normal exit:*/{
                    if (__pyx_t_23) {
                      __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_23, __pyx_mstate_global->__pyx_tuple[7], NULL);
                      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                      if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4240, __pyx_L194_error)
                      __Pyx_GOTREF(__pyx_t_18);
                      __pyx_t_19 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_18, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                      if (likely(__pyx_t_19 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_t_23);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_23;
                        __Pyx_XGIVEREF(__pyx_t_24);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_24;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 15;
                        return __pyx_r;
                        __pyx_L245_resume_from_await:;
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        __pyx_t_23 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_23);
                        __pyx_t_24 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_24);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4240, __pyx_L194_error)
                        __pyx_t_3 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_3);
                      } else if (likely(__pyx_t_19 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_3 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 4240, __pyx_L194_error)
                      }
                      __pyx_t_18 = __pyx_t_3;
                      __pyx_t_3 = 0;
                      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                    }
                    goto __pyx_L204;
                  }
                  __pyx_L204:;
                }
                goto __pyx_L246;
                __pyx_L200_error:;
                __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                goto __pyx_L194_error;
                __pyx_L246:;
              }

              /* "ws_package/controllers/activity_controller.py":4239
 * 
 *             # STEP 3: Delete database entries (QUICK, inside lock)
 *             with db_lock_manager.write_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     try:
*/
            }
            __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
            goto __pyx_L199_try_end;
            __pyx_L194_error:;
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
            __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
            __Pyx_XDECREF(__pyx_t_46); __pyx_t_46 = 0;
            __Pyx_XDECREF(__pyx_t_47); __pyx_t_47 = 0;
            __Pyx_XDECREF(__pyx_t_48); __pyx_t_48 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
            /*except:*/ {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.delete_old_data_and_screenshots", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_9, &__pyx_t_8) < 0) __PYX_ERR(0, 4239, __pyx_L196_except_error)
              __Pyx_XGOTREF(__pyx_t_3);
              __Pyx_XGOTREF(__pyx_t_9);
              __Pyx_XGOTREF(__pyx_t_8);
              __pyx_t_5 = PyTuple_Pack(3, __pyx_t_3, __pyx_t_9, __pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4239, __pyx_L196_except_error)
              __Pyx_GOTREF(__pyx_t_5);
              __pyx_t_23 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_5, NULL);
              __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 4239, __pyx_L196_except_error)
              __Pyx_GOTREF(__pyx_t_23);
              __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_23);
              __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
              if (__pyx_t_4 < (0)) __PYX_ERR(0, 4239, __pyx_L196_except_error)
              __pyx_t_1 = (!__pyx_t_4);
              if (unlikely(__pyx_t_1)) {
                __Pyx_GIVEREF(__pyx_t_3);
                __Pyx_GIVEREF(__pyx_t_9);
                __Pyx_XGIVEREF(__pyx_t_8);
                __Pyx_ErrRestoreWithState(__pyx_t_3, __pyx_t_9, __pyx_t_8);
                __pyx_t_3 = 0;  __pyx_t_9 = 0;  __pyx_t_8 = 0; 
                __PYX_ERR(0, 4239, __pyx_L196_except_error)
              }
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
              __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
              goto __pyx_L195_exception_handled;
            }
            __pyx_L196_except_error:;
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_XGIVEREF(__pyx_t_24);
            __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_14, __pyx_t_24);
            goto __pyx_L9_error;
            __pyx_L195_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_XGIVEREF(__pyx_t_24);
            __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_14, __pyx_t_24);
            __pyx_L199_try_end:;
          }
        }
        /*finally:*/ {
          /*normal exit:*/{
            if (__pyx_t_16) {
              __pyx_t_24 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_mstate_global->__pyx_tuple[7], NULL);
              __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
              if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 4239, __pyx_L9_error)
              __Pyx_GOTREF(__pyx_t_24);
              __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
            }
            goto __pyx_L193;
          }
          __pyx_L193:;
        }
        goto __pyx_L250;
        __pyx_L190_error:;
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
        goto __pyx_L9_error;
        __pyx_L250:;
      }

      /* "ws_package/controllers/activity_controller.py":4157
 *         logger.info("Starting deletion of old data and screenshots.")
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             seven_days_ago = datetime.datetime.now() - datetime.timedelta(days=7)
 * 
*/
    }
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    goto __pyx_L14_try_end;
    __pyx_L9_error:;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
    __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
    __Pyx_XDECREF(__pyx_t_46); __pyx_t_46 = 0;
    __Pyx_XDECREF(__pyx_t_47); __pyx_t_47 = 0;
    __Pyx_XDECREF(__pyx_t_48); __pyx_t_48 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "ws_package/controllers/activity_controller.py":4288
 *                         await session.rollback()
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error in deleting old data and screenshots: %s", e, exc_info=True)
 * 
*/
    __pyx_t_29 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_29) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.delete_old_data_and_screenshots", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_9, &__pyx_t_3) < 0) __PYX_ERR(0, 4288, __pyx_L11_except_error)
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_9);
      __Pyx_GIVEREF(__pyx_t_9);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":4289
 * 
 *         except Exception as e:
 *             logger.error("Error in deleting old data and screenshots: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *     async def start_status_activity(self, user_entity: UserEntity, stop_event):
*/
        __pyx_t_2 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4289, __pyx_L256_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_47 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_47)) __PYX_ERR(0, 4289, __pyx_L256_error)
        __Pyx_GOTREF(__pyx_t_47);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_47))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_47);
          assert(__pyx_t_2);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_47);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_47, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Error_in_deleting_old_data_and_s, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_6 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4289, __pyx_L256_error)
          __Pyx_GOTREF(__pyx_t_6);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_6, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 4289, __pyx_L256_error)
          __pyx_t_5 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_47, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_6);
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_47); __pyx_t_47 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4289, __pyx_L256_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }

      /* "ws_package/controllers/activity_controller.py":4288
 *                         await session.rollback()
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error in deleting old data and screenshots: %s", e, exc_info=True)
 * 
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          goto __pyx_L257;
        }
        __pyx_L256_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_16 = 0; __pyx_t_24 = 0; __pyx_t_14 = 0; __pyx_t_17 = 0; __pyx_t_23 = 0; __pyx_t_18 = 0;
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
          __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
          __Pyx_XDECREF(__pyx_t_46); __pyx_t_46 = 0;
          __Pyx_XDECREF(__pyx_t_47); __pyx_t_47 = 0;
          __Pyx_XDECREF(__pyx_t_48); __pyx_t_48 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_17, &__pyx_t_23, &__pyx_t_18);
          if ( unlikely(__Pyx_GetException(&__pyx_t_16, &__pyx_t_24, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_16, &__pyx_t_24, &__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_16);
          __Pyx_XGOTREF(__pyx_t_24);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_17);
          __Pyx_XGOTREF(__pyx_t_23);
          __Pyx_XGOTREF(__pyx_t_18);
          __pyx_t_29 = __pyx_lineno; __pyx_t_30 = __pyx_clineno; __pyx_t_50 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_23, __pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_16);
          __Pyx_XGIVEREF(__pyx_t_24);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_ErrRestore(__pyx_t_16, __pyx_t_24, __pyx_t_14);
          __pyx_t_16 = 0; __pyx_t_24 = 0; __pyx_t_14 = 0; __pyx_t_17 = 0; __pyx_t_23 = 0; __pyx_t_18 = 0;
          __pyx_lineno = __pyx_t_29; __pyx_clineno = __pyx_t_30; __pyx_filename = __pyx_t_50;
          goto __pyx_L11_except_error;
        }
        __pyx_L257:;
      }
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L10_exception_handled;
    }
    goto __pyx_L11_except_error;

    /* "ws_package/controllers/activity_controller.py":4157
 *         logger.info("Starting deletion of old data and screenshots.")
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             seven_days_ago = datetime.datetime.now() - datetime.timedelta(days=7)
 * 
*/
    __pyx_L11_except_error:;
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_XGIVEREF(__pyx_t_12);
    __Pyx_XGIVEREF(__pyx_t_13);
    __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
    goto __pyx_L1_error;
    __pyx_L13_try_return:;
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_XGIVEREF(__pyx_t_12);
    __Pyx_XGIVEREF(__pyx_t_13);
    __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
    goto __pyx_L0;
    __pyx_L10_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_11);
    __Pyx_XGIVEREF(__pyx_t_12);
    __Pyx_XGIVEREF(__pyx_t_13);
    __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
    __pyx_L14_try_end:;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":4132
 *             yield payload, day_intervals
 * 
 *     async def delete_old_data_and_screenshots(self):             # <<<<<<<<<<<<<<
 *         """
 *         Delete old data and screenshots older than 7 days.
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_38);
  __Pyx_XDECREF(__pyx_t_39);
  __Pyx_XDECREF(__pyx_t_46);
  __Pyx_XDECREF(__pyx_t_47);
  __Pyx_XDECREF(__pyx_t_48);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("delete_old_data_and_screenshots", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_154generator30(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":4291
 *             logger.error("Error in deleting old data and screenshots: %s", e, exc_info=True)
 * 
 *     async def start_status_activity(self, user_entity: UserEntity, stop_event):             # <<<<<<<<<<<<<<
 *         if user_entity is None:
 *             logger.error("start_status_activity called with None user_entity, cannot proceed")
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_153start_status_activity(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_153start_status_activity = {"start_status_activity", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_153start_status_activity, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_153start_status_activity(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_user_entity = 0;
  PyObject *__pyx_v_stop_event = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("start_status_activity (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_user_entity,&__pyx_mstate_global->__pyx_n_u_stop_event,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 4291, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 4291, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 4291, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4291, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "start_status_activity", 0) < (0)) __PYX_ERR(0, 4291, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 3; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("start_status_activity", 1, 3, 3, i); __PYX_ERR(0, 4291, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 3)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4291, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 4291, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 4291, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_user_entity = values[1];
    __pyx_v_stop_event = values[2];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("start_status_activity", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 4291, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.start_status_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_152start_status_activity(__pyx_self, __pyx_v_self, __pyx_v_user_entity, __pyx_v_stop_event);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_152start_status_activity(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity, PyObject *__pyx_v_stop_event) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("start_status_activity", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 4291, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_user_entity = __pyx_v_user_entity;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_user_entity);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_user_entity);
  __pyx_cur_scope->__pyx_v_stop_event = __pyx_v_stop_event;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_stop_event);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_stop_event);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_154generator30, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[50]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_start_status_activity, __pyx_mstate_global->__pyx_n_u_ActivityController_start_status, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 4291, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.start_status_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_154generator30(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  int __pyx_t_1;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  size_t __pyx_t_6;
  __Pyx_PySendResult __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  int __pyx_t_19;
  char const *__pyx_t_20;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  PyObject *__pyx_t_26 = NULL;
  PyObject *(*__pyx_t_27)(PyObject *);
  Py_ssize_t __pyx_t_28;
  char const *__pyx_t_29;
  PyObject *__pyx_t_30 = NULL;
  PyObject *__pyx_t_31 = NULL;
  PyObject *__pyx_t_32 = NULL;
  PyObject *__pyx_t_33[7];
  char const *__pyx_t_34;
  char const *__pyx_t_35;
  char const *__pyx_t_36;
  char const *__pyx_t_37;
  char const *__pyx_t_38;
  PyObject *__pyx_t_39 = NULL;
  char const *__pyx_t_40;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("start_status_activity", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L5_resume_from_await;
    case 2: goto __pyx_L24_resume_from_await;
    case 3: goto __pyx_L39_resume_from_await;
    case 4: goto __pyx_L50_resume_from_await;
    case 5: goto __pyx_L83_resume_from_await;
    case 6: goto __pyx_L146_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 4291, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":4292
 * 
 *     async def start_status_activity(self, user_entity: UserEntity, stop_event):
 *         if user_entity is None:             # <<<<<<<<<<<<<<
 *             logger.error("start_status_activity called with None user_entity, cannot proceed")
 *             return
*/
  __pyx_t_1 = (__pyx_cur_scope->__pyx_v_user_entity == Py_None);
  if (__pyx_t_1) {

    /* "ws_package/controllers/activity_controller.py":4293
 *     async def start_status_activity(self, user_entity: UserEntity, stop_event):
 *         if user_entity is None:
 *             logger.error("start_status_activity called with None user_entity, cannot proceed")             # <<<<<<<<<<<<<<
 *             return
 * 
*/
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4293, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4293, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_6 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
      __pyx_t_6 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_start_status_activity_called_wit};
      __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4293, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

    /* "ws_package/controllers/activity_controller.py":4294
 *         if user_entity is None:
 *             logger.error("start_status_activity called with None user_entity, cannot proceed")
 *             return             # <<<<<<<<<<<<<<
 * 
 *         await self.status_controller.set_cred(user_entity)
*/
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":4292
 * 
 *     async def start_status_activity(self, user_entity: UserEntity, stop_event):
 *         if user_entity is None:             # <<<<<<<<<<<<<<
 *             logger.error("start_status_activity called with None user_entity, cannot proceed")
 *             return
*/
  }

  /* "ws_package/controllers/activity_controller.py":4296
 *             return
 * 
 *         await self.status_controller.set_cred(user_entity)             # <<<<<<<<<<<<<<
 *         # Set org_id from user_entity
 *         self.org_id = user_entity.org_id
*/
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status_controller); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4296, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_5 = __pyx_t_3;
  __Pyx_INCREF(__pyx_t_5);
  __pyx_t_6 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_user_entity};
    __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_set_cred, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4296, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
  }
  __pyx_t_7 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_2, &__pyx_r);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (likely(__pyx_t_7 == PYGEN_NEXT)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_XGIVEREF(__pyx_r);
    __Pyx_RefNannyFinishContext();
    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
    /* return from generator, awaiting value */
    __pyx_generator->resume_label = 1;
    return __pyx_r;
    __pyx_L5_resume_from_await:;
    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4296, __pyx_L1_error)
  } else if (likely(__pyx_t_7 == PYGEN_RETURN)) {
    __Pyx_GOTREF(__pyx_r);
    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
  } else {
    __Pyx_XGOTREF(__pyx_r);
    __PYX_ERR(0, 4296, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":4298
 *         await self.status_controller.set_cred(user_entity)
 *         # Set org_id from user_entity
 *         self.org_id = user_entity.org_id             # <<<<<<<<<<<<<<
 *         # Update org_id in ScreenshotController and its ScreenshotService
 *         self.screenshot_controller.org_id = self.org_id
*/
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_org_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4298, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_org_id, __pyx_t_2) < (0)) __PYX_ERR(0, 4298, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":4300
 *         self.org_id = user_entity.org_id
 *         # Update org_id in ScreenshotController and its ScreenshotService
 *         self.screenshot_controller.org_id = self.org_id             # <<<<<<<<<<<<<<
 *         self.screenshot_controller.screenshot_service.org_id = self.org_id
 *         logger.info("org_id set to: %s for ScreenshotController and ScreenshotService", self.org_id)
*/
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_org_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4300, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4300, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  if (__Pyx_PyObject_SetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_org_id, __pyx_t_2) < (0)) __PYX_ERR(0, 4300, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "ws_package/controllers/activity_controller.py":4301
 *         # Update org_id in ScreenshotController and its ScreenshotService
 *         self.screenshot_controller.org_id = self.org_id
 *         self.screenshot_controller.screenshot_service.org_id = self.org_id             # <<<<<<<<<<<<<<
 *         logger.info("org_id set to: %s for ScreenshotController and ScreenshotService", self.org_id)
 *         logger.info("Setting S3 details for db to server")
*/
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_org_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4301, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4301, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_screenshot_service); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4301, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_PyObject_SetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_org_id, __pyx_t_3) < (0)) __PYX_ERR(0, 4301, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "ws_package/controllers/activity_controller.py":4302
 *         self.screenshot_controller.org_id = self.org_id
 *         self.screenshot_controller.screenshot_service.org_id = self.org_id
 *         logger.info("org_id set to: %s for ScreenshotController and ScreenshotService", self.org_id)             # <<<<<<<<<<<<<<
 *         logger.info("Setting S3 details for db to server")
 * 
*/
  __pyx_t_3 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4302, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4302, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_org_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4302, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_6 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_3);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_6 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_org_id_set_to_s_for_ScreenshotCo, __pyx_t_2};
    __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4302, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "ws_package/controllers/activity_controller.py":4303
 *         self.screenshot_controller.screenshot_service.org_id = self.org_id
 *         logger.info("org_id set to: %s for ScreenshotController and ScreenshotService", self.org_id)
 *         logger.info("Setting S3 details for db to server")             # <<<<<<<<<<<<<<
 * 
 *         # Status check is now only called on app restart and system wake, not in a loop
*/
  __pyx_t_4 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4303, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4303, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_6 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    assert(__pyx_t_4);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
    __pyx_t_6 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Setting_S3_details_for_db_to_ser};
    __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4303, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_5);
  }
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

  /* "ws_package/controllers/activity_controller.py":4307
 *         # Status check is now only called on app restart and system wake, not in a loop
 *         # This thread just keeps running for db_to_server operations
 *         while not stop_event.is_set():             # <<<<<<<<<<<<<<
 *             try:
 *                 try:
*/
  while (1) {
    __pyx_t_3 = __pyx_cur_scope->__pyx_v_stop_event;
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_6 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
      __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_set, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4307, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_5);
    }
    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 4307, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_8 = (!__pyx_t_1);
    if (!__pyx_t_8) break;

    /* "ws_package/controllers/activity_controller.py":4308
 *         # This thread just keeps running for db_to_server operations
 *         while not stop_event.is_set():
 *             try:             # <<<<<<<<<<<<<<
 *                 try:
 *                     await self.db_to_server(user_entity)
*/
    {
      __Pyx_ExceptionSave(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_11);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":4309
 *         while not stop_event.is_set():
 *             try:
 *                 try:             # <<<<<<<<<<<<<<
 *                     await self.db_to_server(user_entity)
 *                 except Exception as e:
*/
        {
          __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_14);
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":4310
 *             try:
 *                 try:
 *                     await self.db_to_server(user_entity)             # <<<<<<<<<<<<<<
 *                 except Exception as e:
 *                     logger.error("Error in db_to_server: %s", e)
*/
            __pyx_t_3 = __pyx_cur_scope->__pyx_v_self;
            __Pyx_INCREF(__pyx_t_3);
            __pyx_t_6 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_user_entity};
              __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_db_to_server, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4310, __pyx_L16_error)
              __Pyx_GOTREF(__pyx_t_5);
            }
            __pyx_t_7 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (likely(__pyx_t_7 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_9);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_9;
              __Pyx_XGIVEREF(__pyx_t_10);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_10;
              __Pyx_XGIVEREF(__pyx_t_11);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_11;
              __Pyx_XGIVEREF(__pyx_t_12);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
              __Pyx_XGIVEREF(__pyx_t_13);
              __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
              __Pyx_XGIVEREF(__pyx_t_14);
              __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 2;
              return __pyx_r;
              __pyx_L24_resume_from_await:;
              __pyx_t_9 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_9);
              __pyx_t_10 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_10);
              __pyx_t_11 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_11);
              __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_12);
              __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
              __pyx_cur_scope->__pyx_t_4 = 0;
              __Pyx_XGOTREF(__pyx_t_13);
              __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
              __pyx_cur_scope->__pyx_t_5 = 0;
              __Pyx_XGOTREF(__pyx_t_14);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4310, __pyx_L16_error)
            } else if (likely(__pyx_t_7 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_DECREF(__pyx_r); __pyx_r = 0;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 4310, __pyx_L16_error)
            }

            /* "ws_package/controllers/activity_controller.py":4309
 *         while not stop_event.is_set():
 *             try:
 *                 try:             # <<<<<<<<<<<<<<
 *                     await self.db_to_server(user_entity)
 *                 except Exception as e:
*/
          }
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          goto __pyx_L23_try_end;
          __pyx_L16_error:;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":4311
 *                 try:
 *                     await self.db_to_server(user_entity)
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Error in db_to_server: %s", e)
 * 
*/
          __pyx_t_15 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
          if (__pyx_t_15) {
            __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.start_status_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_3, &__pyx_t_4) < 0) __PYX_ERR(0, 4311, __pyx_L18_except_error)
            __Pyx_XGOTREF(__pyx_t_5);
            __Pyx_XGOTREF(__pyx_t_3);
            __Pyx_XGOTREF(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_GIVEREF(__pyx_t_3);
            __pyx_cur_scope->__pyx_v_e = __pyx_t_3;
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":4312
 *                     await self.db_to_server(user_entity)
 *                 except Exception as e:
 *                     logger.error("Error in db_to_server: %s", e)             # <<<<<<<<<<<<<<
 * 
 *                 # Sleep for a long time (only wake up for stop_event)
*/
              __pyx_t_16 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4312, __pyx_L30_error)
              __Pyx_GOTREF(__pyx_t_17);
              __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4312, __pyx_L30_error)
              __Pyx_GOTREF(__pyx_t_18);
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
              __pyx_t_6 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_18))) {
                __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_18);
                assert(__pyx_t_16);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_18);
                __Pyx_INCREF(__pyx_t_16);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_18, __pyx__function);
                __pyx_t_6 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_16, __pyx_mstate_global->__pyx_kp_u_Error_in_db_to_server_s, __pyx_cur_scope->__pyx_v_e};
                __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_18, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4312, __pyx_L30_error)
                __Pyx_GOTREF(__pyx_t_2);
              }
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            }

            /* "ws_package/controllers/activity_controller.py":4311
 *                 try:
 *                     await self.db_to_server(user_entity)
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Error in db_to_server: %s", e)
 * 
*/
            /*finally:*/ {
              /*normal exit:*/{
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                goto __pyx_L31;
              }
              __pyx_L30_error:;
              /*exception exit:*/{
                __Pyx_PyThreadState_assign
                __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0;
                __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                 __Pyx_ExceptionSwap(&__pyx_t_24, &__pyx_t_25, &__pyx_t_26);
                if ( unlikely(__Pyx_GetException(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23) < 0)) __Pyx_ErrFetch(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
                __Pyx_XGOTREF(__pyx_t_21);
                __Pyx_XGOTREF(__pyx_t_22);
                __Pyx_XGOTREF(__pyx_t_23);
                __Pyx_XGOTREF(__pyx_t_24);
                __Pyx_XGOTREF(__pyx_t_25);
                __Pyx_XGOTREF(__pyx_t_26);
                __pyx_t_15 = __pyx_lineno; __pyx_t_19 = __pyx_clineno; __pyx_t_20 = __pyx_filename;
                {
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                }
                __Pyx_XGIVEREF(__pyx_t_24);
                __Pyx_XGIVEREF(__pyx_t_25);
                __Pyx_XGIVEREF(__pyx_t_26);
                __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_25, __pyx_t_26);
                __Pyx_XGIVEREF(__pyx_t_21);
                __Pyx_XGIVEREF(__pyx_t_22);
                __Pyx_XGIVEREF(__pyx_t_23);
                __Pyx_ErrRestore(__pyx_t_21, __pyx_t_22, __pyx_t_23);
                __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0;
                __pyx_lineno = __pyx_t_15; __pyx_clineno = __pyx_t_19; __pyx_filename = __pyx_t_20;
                goto __pyx_L18_except_error;
              }
              __pyx_L31:;
            }
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            goto __pyx_L17_exception_handled;
          }
          goto __pyx_L18_except_error;

          /* "ws_package/controllers/activity_controller.py":4309
 *         while not stop_event.is_set():
 *             try:
 *                 try:             # <<<<<<<<<<<<<<
 *                     await self.db_to_server(user_entity)
 *                 except Exception as e:
*/
          __pyx_L18_except_error:;
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
          goto __pyx_L8_error;
          __pyx_L17_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
          __pyx_L23_try_end:;
        }

        /* "ws_package/controllers/activity_controller.py":4316
 *                 # Sleep for a long time (only wake up for stop_event)
 *                 # Status check will be triggered by wake callback or app restart
 *                 total_sleep = 3600  # 1 hour             # <<<<<<<<<<<<<<
 *                 chunk_duration = 600  # 10 minutes per chunk
 *                 chunks = total_sleep // chunk_duration
*/
        __Pyx_INCREF(__pyx_mstate_global->__pyx_int_3600);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_total_sleep);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_total_sleep, __pyx_mstate_global->__pyx_int_3600);
        __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_3600);

        /* "ws_package/controllers/activity_controller.py":4317
 *                 # Status check will be triggered by wake callback or app restart
 *                 total_sleep = 3600  # 1 hour
 *                 chunk_duration = 600  # 10 minutes per chunk             # <<<<<<<<<<<<<<
 *                 chunks = total_sleep // chunk_duration
 *                 for _ in range(chunks):
*/
        __Pyx_INCREF(__pyx_mstate_global->__pyx_int_600);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_chunk_duration);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_chunk_duration, __pyx_mstate_global->__pyx_int_600);
        __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_600);

        /* "ws_package/controllers/activity_controller.py":4318
 *                 total_sleep = 3600  # 1 hour
 *                 chunk_duration = 600  # 10 minutes per chunk
 *                 chunks = total_sleep // chunk_duration             # <<<<<<<<<<<<<<
 *                 for _ in range(chunks):
 *                     if stop_event.is_set():
*/
        __pyx_t_4 = PyNumber_FloorDivide(__pyx_cur_scope->__pyx_v_total_sleep, __pyx_cur_scope->__pyx_v_chunk_duration); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4318, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_chunks);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_chunks, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":4319
 *                 chunk_duration = 600  # 10 minutes per chunk
 *                 chunks = total_sleep // chunk_duration
 *                 for _ in range(chunks):             # <<<<<<<<<<<<<<
 *                     if stop_event.is_set():
 *                         break
*/
        __pyx_t_3 = NULL;
        __pyx_t_6 = 1;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_chunks};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)(&PyRange_Type), __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4319, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __pyx_t_3 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4319, __pyx_L8_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_27 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 4319, __pyx_L8_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        for (;;) {
          {
            __pyx_t_4 = __pyx_t_27(__pyx_t_3);
            if (unlikely(!__pyx_t_4)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 4319, __pyx_L8_error)
                PyErr_Clear();
              }
              break;
            }
          }
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v__);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v__, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_4);
          __pyx_t_4 = 0;

          /* "ws_package/controllers/activity_controller.py":4320
 *                 chunks = total_sleep // chunk_duration
 *                 for _ in range(chunks):
 *                     if stop_event.is_set():             # <<<<<<<<<<<<<<
 *                         break
 *                     await precise_sleep(chunk_duration, stop_event)
*/
          __pyx_t_5 = __pyx_cur_scope->__pyx_v_stop_event;
          __Pyx_INCREF(__pyx_t_5);
          __pyx_t_6 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
            __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_set, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4320, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_4);
          }
          __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 4320, __pyx_L8_error)
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (__pyx_t_8) {

            /* "ws_package/controllers/activity_controller.py":4321
 *                 for _ in range(chunks):
 *                     if stop_event.is_set():
 *                         break             # <<<<<<<<<<<<<<
 *                     await precise_sleep(chunk_duration, stop_event)
 * 
*/
            goto __pyx_L37_break;

            /* "ws_package/controllers/activity_controller.py":4320
 *                 chunks = total_sleep // chunk_duration
 *                 for _ in range(chunks):
 *                     if stop_event.is_set():             # <<<<<<<<<<<<<<
 *                         break
 *                     await precise_sleep(chunk_duration, stop_event)
*/
          }

          /* "ws_package/controllers/activity_controller.py":4322
 *                     if stop_event.is_set():
 *                         break
 *                     await precise_sleep(chunk_duration, stop_event)             # <<<<<<<<<<<<<<
 * 
 *                 if stop_event.is_set():
*/
          __pyx_t_5 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_precise_sleep); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4322, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_6 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
            assert(__pyx_t_5);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
            __pyx_t_6 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_chunk_duration, __pyx_cur_scope->__pyx_v_stop_event};
            __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4322, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_4);
          }
          __pyx_t_7 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (likely(__pyx_t_7 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_3);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
            __Pyx_XGIVEREF(__pyx_t_9);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_9;
            __Pyx_XGIVEREF(__pyx_t_10);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_10;
            __Pyx_XGIVEREF(__pyx_t_11);
            __pyx_cur_scope->__pyx_t_3 = __pyx_t_11;
            __pyx_cur_scope->__pyx_t_6 = __pyx_t_27;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 3;
            return __pyx_r;
            __pyx_L39_resume_from_await:;
            __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_3);
            __pyx_t_9 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_9);
            __pyx_t_10 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_10);
            __pyx_t_11 = __pyx_cur_scope->__pyx_t_3;
            __pyx_cur_scope->__pyx_t_3 = 0;
            __Pyx_XGOTREF(__pyx_t_11);
            __pyx_t_27 = __pyx_cur_scope->__pyx_t_6;
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4322, __pyx_L8_error)
          } else if (likely(__pyx_t_7 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_DECREF(__pyx_r); __pyx_r = 0;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 4322, __pyx_L8_error)
          }

          /* "ws_package/controllers/activity_controller.py":4319
 *                 chunk_duration = 600  # 10 minutes per chunk
 *                 chunks = total_sleep // chunk_duration
 *                 for _ in range(chunks):             # <<<<<<<<<<<<<<
 *                     if stop_event.is_set():
 *                         break
*/
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        goto __pyx_L40_for_end;
        __pyx_L37_break:;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        goto __pyx_L40_for_end;
        __pyx_L40_for_end:;

        /* "ws_package/controllers/activity_controller.py":4324
 *                     await precise_sleep(chunk_duration, stop_event)
 * 
 *                 if stop_event.is_set():             # <<<<<<<<<<<<<<
 *                     break
 * 
*/
        __pyx_t_4 = __pyx_cur_scope->__pyx_v_stop_event;
        __Pyx_INCREF(__pyx_t_4);
        __pyx_t_6 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
          __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_set, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4324, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_3);
        }
        __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 4324, __pyx_L8_error)
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (__pyx_t_8) {

          /* "ws_package/controllers/activity_controller.py":4325
 * 
 *                 if stop_event.is_set():
 *                     break             # <<<<<<<<<<<<<<
 * 
 *                 try:
*/
          goto __pyx_L13_try_break;

          /* "ws_package/controllers/activity_controller.py":4324
 *                     await precise_sleep(chunk_duration, stop_event)
 * 
 *                 if stop_event.is_set():             # <<<<<<<<<<<<<<
 *                     break
 * 
*/
        }

        /* "ws_package/controllers/activity_controller.py":4327
 *                     break
 * 
 *                 try:             # <<<<<<<<<<<<<<
 *                     await self.delete_old_data_and_screenshots()
 * 
*/
        {
          __Pyx_ExceptionSave(&__pyx_t_14, &__pyx_t_13, &__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_12);
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":4328
 * 
 *                 try:
 *                     await self.delete_old_data_and_screenshots()             # <<<<<<<<<<<<<<
 * 
 *                     # Perform periodic log cleanup (works offline, independent of server connectivity)
*/
            __pyx_t_4 = __pyx_cur_scope->__pyx_v_self;
            __Pyx_INCREF(__pyx_t_4);
            __pyx_t_6 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
              __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_delete_old_data_and_screenshots, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4328, __pyx_L42_error)
              __Pyx_GOTREF(__pyx_t_3);
            }
            __pyx_t_7 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_3, &__pyx_r);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            if (likely(__pyx_t_7 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_9);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_9;
              __Pyx_XGIVEREF(__pyx_t_10);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_10;
              __Pyx_XGIVEREF(__pyx_t_11);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_11;
              __Pyx_XGIVEREF(__pyx_t_12);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
              __Pyx_XGIVEREF(__pyx_t_13);
              __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
              __Pyx_XGIVEREF(__pyx_t_14);
              __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 4;
              return __pyx_r;
              __pyx_L50_resume_from_await:;
              __pyx_t_9 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_9);
              __pyx_t_10 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_10);
              __pyx_t_11 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_11);
              __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_12);
              __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
              __pyx_cur_scope->__pyx_t_4 = 0;
              __Pyx_XGOTREF(__pyx_t_13);
              __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
              __pyx_cur_scope->__pyx_t_5 = 0;
              __Pyx_XGOTREF(__pyx_t_14);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4328, __pyx_L42_error)
            } else if (likely(__pyx_t_7 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_DECREF(__pyx_r); __pyx_r = 0;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 4328, __pyx_L42_error)
            }

            /* "ws_package/controllers/activity_controller.py":4331
 * 
 *                     # Perform periodic log cleanup (works offline, independent of server connectivity)
 *                     try:             # <<<<<<<<<<<<<<
 *                         from ws_package.utils.logs import perform_comprehensive_log_cleanup
 *                         cleanup_enabled = config('log_cleanup_enabled', 'System', dtype='bool')
*/
            {
              __Pyx_ExceptionSave(&__pyx_t_26, &__pyx_t_25, &__pyx_t_24);
              __Pyx_XGOTREF(__pyx_t_26);
              __Pyx_XGOTREF(__pyx_t_25);
              __Pyx_XGOTREF(__pyx_t_24);
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":4332
 *                     # Perform periodic log cleanup (works offline, independent of server connectivity)
 *                     try:
 *                         from ws_package.utils.logs import perform_comprehensive_log_cleanup             # <<<<<<<<<<<<<<
 *                         cleanup_enabled = config('log_cleanup_enabled', 'System', dtype='bool')
 *                         if cleanup_enabled is None or cleanup_enabled:
*/
                {
                  PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_perform_comprehensive_log_cleanu};
                  __pyx_t_23 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_utils_logs, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 4332, __pyx_L51_error)
                }
                __pyx_t_3 = __pyx_t_23;
                __Pyx_GOTREF(__pyx_t_3);
                {
                  PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_perform_comprehensive_log_cleanu};
                  __pyx_t_28 = 0; {
                    __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_3, __pyx_imported_names[__pyx_t_28]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4332, __pyx_L51_error)
                    __Pyx_GOTREF(__pyx_t_4);
                    switch (__pyx_t_28) {
                      case 0:
                      __Pyx_INCREF(__pyx_t_4);
                      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_perform_comprehensive_log_cleanup);
                      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_perform_comprehensive_log_cleanup, __pyx_t_4);
                      __Pyx_GIVEREF(__pyx_t_4);
                      break;
                      default:;
                    }
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  }
                }
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                /* "ws_package/controllers/activity_controller.py":4333
 *                     try:
 *                         from ws_package.utils.logs import perform_comprehensive_log_cleanup
 *                         cleanup_enabled = config('log_cleanup_enabled', 'System', dtype='bool')             # <<<<<<<<<<<<<<
 *                         if cleanup_enabled is None or cleanup_enabled:
 *                             perform_comprehensive_log_cleanup()
*/
                __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_config); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4333, __pyx_L51_error)
                __Pyx_GOTREF(__pyx_t_3);
                __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4333, __pyx_L51_error)
                __Pyx_GOTREF(__pyx_t_4);
                if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_dtype, __pyx_mstate_global->__pyx_n_u_bool) < (0)) __PYX_ERR(0, 4333, __pyx_L51_error)
                __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_mstate_global->__pyx_tuple[29], __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4333, __pyx_L51_error)
                __Pyx_GOTREF(__pyx_t_2);
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_cleanup_enabled);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_cleanup_enabled, __pyx_t_2);
                __Pyx_GIVEREF(__pyx_t_2);
                __pyx_t_2 = 0;

                /* "ws_package/controllers/activity_controller.py":4334
 *                         from ws_package.utils.logs import perform_comprehensive_log_cleanup
 *                         cleanup_enabled = config('log_cleanup_enabled', 'System', dtype='bool')
 *                         if cleanup_enabled is None or cleanup_enabled:             # <<<<<<<<<<<<<<
 *                             perform_comprehensive_log_cleanup()
 *                     except Exception as e:
*/
                __pyx_t_1 = (__pyx_cur_scope->__pyx_v_cleanup_enabled == Py_None);
                if (!__pyx_t_1) {
                } else {
                  __pyx_t_8 = __pyx_t_1;
                  goto __pyx_L60_bool_binop_done;
                }
                __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_cleanup_enabled); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 4334, __pyx_L51_error)
                __pyx_t_8 = __pyx_t_1;
                __pyx_L60_bool_binop_done:;
                if (__pyx_t_8) {

                  /* "ws_package/controllers/activity_controller.py":4335
 *                         cleanup_enabled = config('log_cleanup_enabled', 'System', dtype='bool')
 *                         if cleanup_enabled is None or cleanup_enabled:
 *                             perform_comprehensive_log_cleanup()             # <<<<<<<<<<<<<<
 *                     except Exception as e:
 *                         logger.debug("Error during periodic log cleanup (non-fatal): %s", e)
*/
                  __pyx_t_4 = NULL;
                  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_perform_comprehensive_log_cleanup);
                  __pyx_t_3 = __pyx_cur_scope->__pyx_v_perform_comprehensive_log_cleanup; 
                  __pyx_t_6 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_3))) {
                    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
                    assert(__pyx_t_4);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
                    __Pyx_INCREF(__pyx_t_4);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
                    __pyx_t_6 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
                    __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4335, __pyx_L51_error)
                    __Pyx_GOTREF(__pyx_t_2);
                  }
                  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

                  /* "ws_package/controllers/activity_controller.py":4334
 *                         from ws_package.utils.logs import perform_comprehensive_log_cleanup
 *                         cleanup_enabled = config('log_cleanup_enabled', 'System', dtype='bool')
 *                         if cleanup_enabled is None or cleanup_enabled:             # <<<<<<<<<<<<<<
 *                             perform_comprehensive_log_cleanup()
 *                     except Exception as e:
*/
                }

                /* "ws_package/controllers/activity_controller.py":4331
 * 
 *                     # Perform periodic log cleanup (works offline, independent of server connectivity)
 *                     try:             # <<<<<<<<<<<<<<
 *                         from ws_package.utils.logs import perform_comprehensive_log_cleanup
 *                         cleanup_enabled = config('log_cleanup_enabled', 'System', dtype='bool')
*/
              }
              __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
              __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
              goto __pyx_L58_try_end;
              __pyx_L51_error:;
              __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
              __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
              __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

              /* "ws_package/controllers/activity_controller.py":4336
 *                         if cleanup_enabled is None or cleanup_enabled:
 *                             perform_comprehensive_log_cleanup()
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.debug("Error during periodic log cleanup (non-fatal): %s", e)
 * 
*/
              __pyx_t_19 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
              if (__pyx_t_19) {
                __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.start_status_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
                if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4) < 0) __PYX_ERR(0, 4336, __pyx_L53_except_error)
                __Pyx_XGOTREF(__pyx_t_2);
                __Pyx_XGOTREF(__pyx_t_3);
                __Pyx_XGOTREF(__pyx_t_4);
                __Pyx_INCREF(__pyx_t_3);
                __Pyx_GIVEREF(__pyx_t_3);
                __pyx_cur_scope->__pyx_v_e = __pyx_t_3;
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":4337
 *                             perform_comprehensive_log_cleanup()
 *                     except Exception as e:
 *                         logger.debug("Error during periodic log cleanup (non-fatal): %s", e)             # <<<<<<<<<<<<<<
 * 
 *                     if sys.platform == "darwin":
*/
                  __pyx_t_18 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 4337, __pyx_L67_error)
                  __Pyx_GOTREF(__pyx_t_16);
                  __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4337, __pyx_L67_error)
                  __Pyx_GOTREF(__pyx_t_17);
                  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                  __pyx_t_6 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_17))) {
                    __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_17);
                    assert(__pyx_t_18);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
                    __Pyx_INCREF(__pyx_t_18);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
                    __pyx_t_6 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[3] = {__pyx_t_18, __pyx_mstate_global->__pyx_kp_u_Error_during_periodic_log_cleanu, __pyx_cur_scope->__pyx_v_e};
                    __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4337, __pyx_L67_error)
                    __Pyx_GOTREF(__pyx_t_5);
                  }
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                }

                /* "ws_package/controllers/activity_controller.py":4336
 *                         if cleanup_enabled is None or cleanup_enabled:
 *                             perform_comprehensive_log_cleanup()
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.debug("Error during periodic log cleanup (non-fatal): %s", e)
 * 
*/
                /*finally:*/ {
                  /*normal exit:*/{
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    goto __pyx_L68;
                  }
                  __pyx_L67_error:;
                  /*exception exit:*/{
                    __Pyx_PyThreadState_assign
                    __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0;
                    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                     __Pyx_ExceptionSwap(&__pyx_t_30, &__pyx_t_31, &__pyx_t_32);
                    if ( unlikely(__Pyx_GetException(&__pyx_t_23, &__pyx_t_22, &__pyx_t_21) < 0)) __Pyx_ErrFetch(&__pyx_t_23, &__pyx_t_22, &__pyx_t_21);
                    __Pyx_XGOTREF(__pyx_t_23);
                    __Pyx_XGOTREF(__pyx_t_22);
                    __Pyx_XGOTREF(__pyx_t_21);
                    __Pyx_XGOTREF(__pyx_t_30);
                    __Pyx_XGOTREF(__pyx_t_31);
                    __Pyx_XGOTREF(__pyx_t_32);
                    __pyx_t_19 = __pyx_lineno; __pyx_t_15 = __pyx_clineno; __pyx_t_29 = __pyx_filename;
                    {
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    }
                    __Pyx_XGIVEREF(__pyx_t_30);
                    __Pyx_XGIVEREF(__pyx_t_31);
                    __Pyx_XGIVEREF(__pyx_t_32);
                    __Pyx_ExceptionReset(__pyx_t_30, __pyx_t_31, __pyx_t_32);
                    __Pyx_XGIVEREF(__pyx_t_23);
                    __Pyx_XGIVEREF(__pyx_t_22);
                    __Pyx_XGIVEREF(__pyx_t_21);
                    __Pyx_ErrRestore(__pyx_t_23, __pyx_t_22, __pyx_t_21);
                    __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0;
                    __pyx_lineno = __pyx_t_19; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_29;
                    goto __pyx_L53_except_error;
                  }
                  __pyx_L68:;
                }
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                goto __pyx_L52_exception_handled;
              }
              goto __pyx_L53_except_error;

              /* "ws_package/controllers/activity_controller.py":4331
 * 
 *                     # Perform periodic log cleanup (works offline, independent of server connectivity)
 *                     try:             # <<<<<<<<<<<<<<
 *                         from ws_package.utils.logs import perform_comprehensive_log_cleanup
 *                         cleanup_enabled = config('log_cleanup_enabled', 'System', dtype='bool')
*/
              __pyx_L53_except_error:;
              __Pyx_XGIVEREF(__pyx_t_26);
              __Pyx_XGIVEREF(__pyx_t_25);
              __Pyx_XGIVEREF(__pyx_t_24);
              __Pyx_ExceptionReset(__pyx_t_26, __pyx_t_25, __pyx_t_24);
              goto __pyx_L42_error;
              __pyx_L52_exception_handled:;
              __Pyx_XGIVEREF(__pyx_t_26);
              __Pyx_XGIVEREF(__pyx_t_25);
              __Pyx_XGIVEREF(__pyx_t_24);
              __Pyx_ExceptionReset(__pyx_t_26, __pyx_t_25, __pyx_t_24);
              __pyx_L58_try_end:;
            }

            /* "ws_package/controllers/activity_controller.py":4339
 *                         logger.debug("Error during periodic log cleanup (non-fatal): %s", e)
 * 
 *                     if sys.platform == "darwin":             # <<<<<<<<<<<<<<
 *                         logger.info("Sending mac logs to server")
 *                         mac_log = Path.home() / "Library/Application Support/Workstatus/logs/workstatus_error.log"
*/
            __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_sys); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4339, __pyx_L42_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4339, __pyx_L42_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_darwin, Py_EQ)); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 4339, __pyx_L42_error)
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            if (__pyx_t_8) {

              /* "ws_package/controllers/activity_controller.py":4340
 * 
 *                     if sys.platform == "darwin":
 *                         logger.info("Sending mac logs to server")             # <<<<<<<<<<<<<<
 *                         mac_log = Path.home() / "Library/Application Support/Workstatus/logs/workstatus_error.log"
 *                         if mac_log.exists():
*/
              __pyx_t_4 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4340, __pyx_L42_error)
              __Pyx_GOTREF(__pyx_t_2);
              __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4340, __pyx_L42_error)
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              __pyx_t_6 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_5))) {
                __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
                assert(__pyx_t_4);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                __Pyx_INCREF(__pyx_t_4);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                __pyx_t_6 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Sending_mac_logs_to_server};
                __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4340, __pyx_L42_error)
                __Pyx_GOTREF(__pyx_t_3);
              }
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

              /* "ws_package/controllers/activity_controller.py":4341
 *                     if sys.platform == "darwin":
 *                         logger.info("Sending mac logs to server")
 *                         mac_log = Path.home() / "Library/Application Support/Workstatus/logs/workstatus_error.log"             # <<<<<<<<<<<<<<
 *                         if mac_log.exists():
 *                             timestamp = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
*/
              __pyx_t_5 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_Path); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4341, __pyx_L42_error)
              __Pyx_GOTREF(__pyx_t_4);
              __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_home); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4341, __pyx_L42_error)
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __pyx_t_6 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_2))) {
                __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
                assert(__pyx_t_5);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
                __Pyx_INCREF(__pyx_t_5);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
                __pyx_t_6 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4341, __pyx_L42_error)
                __Pyx_GOTREF(__pyx_t_3);
              }
              __pyx_t_2 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Library_Application_Support_Work_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4341, __pyx_L42_error)
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_mac_log);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_mac_log, __pyx_t_2);
              __Pyx_GIVEREF(__pyx_t_2);
              __pyx_t_2 = 0;

              /* "ws_package/controllers/activity_controller.py":4342
 *                         logger.info("Sending mac logs to server")
 *                         mac_log = Path.home() / "Library/Application Support/Workstatus/logs/workstatus_error.log"
 *                         if mac_log.exists():             # <<<<<<<<<<<<<<
 *                             timestamp = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
 *                             s3_key = f"{self.s3_logs_path}{user_entity.org_id}/{user_entity.user_id}/{timestamp}-logs.txt"
*/
              __pyx_t_3 = __pyx_cur_scope->__pyx_v_mac_log;
              __Pyx_INCREF(__pyx_t_3);
              __pyx_t_6 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
                __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_exists, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4342, __pyx_L42_error)
                __Pyx_GOTREF(__pyx_t_2);
              }
              __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 4342, __pyx_L42_error)
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              if (__pyx_t_8) {

                /* "ws_package/controllers/activity_controller.py":4343
 *                         mac_log = Path.home() / "Library/Application Support/Workstatus/logs/workstatus_error.log"
 *                         if mac_log.exists():
 *                             timestamp = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")             # <<<<<<<<<<<<<<
 *                             s3_key = f"{self.s3_logs_path}{user_entity.org_id}/{user_entity.user_id}/{timestamp}-logs.txt"
 * 
*/
                __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4343, __pyx_L42_error)
                __Pyx_GOTREF(__pyx_t_17);
                __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4343, __pyx_L42_error)
                __Pyx_GOTREF(__pyx_t_18);
                __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                __pyx_t_4 = __pyx_t_18;
                __Pyx_INCREF(__pyx_t_4);
                __pyx_t_6 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
                  __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4343, __pyx_L42_error)
                  __Pyx_GOTREF(__pyx_t_5);
                }
                __pyx_t_3 = __pyx_t_5;
                __Pyx_INCREF(__pyx_t_3);
                __pyx_t_6 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Y_m_d__H_M_S};
                  __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strftime, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4343, __pyx_L42_error)
                  __Pyx_GOTREF(__pyx_t_2);
                }
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_timestamp);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_timestamp, __pyx_t_2);
                __Pyx_GIVEREF(__pyx_t_2);
                __pyx_t_2 = 0;

                /* "ws_package/controllers/activity_controller.py":4344
 *                         if mac_log.exists():
 *                             timestamp = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
 *                             s3_key = f"{self.s3_logs_path}{user_entity.org_id}/{user_entity.user_id}/{timestamp}-logs.txt"             # <<<<<<<<<<<<<<
 * 
 *                             try:
*/
                __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_s3_logs_path); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4344, __pyx_L42_error)
                __Pyx_GOTREF(__pyx_t_2);
                __pyx_t_5 = __Pyx_PyObject_FormatSimple(__pyx_t_2, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4344, __pyx_L42_error)
                __Pyx_GOTREF(__pyx_t_5);
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_org_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4344, __pyx_L42_error)
                __Pyx_GOTREF(__pyx_t_2);
                __pyx_t_3 = __Pyx_PyObject_FormatSimple(__pyx_t_2, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4344, __pyx_L42_error)
                __Pyx_GOTREF(__pyx_t_3);
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_user_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4344, __pyx_L42_error)
                __Pyx_GOTREF(__pyx_t_2);
                __pyx_t_18 = __Pyx_PyObject_FormatSimple(__pyx_t_2, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4344, __pyx_L42_error)
                __Pyx_GOTREF(__pyx_t_18);
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                __pyx_t_2 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_timestamp, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4344, __pyx_L42_error)
                __Pyx_GOTREF(__pyx_t_2);
                __pyx_t_33[0] = __pyx_t_5;
                __pyx_t_33[1] = __pyx_t_3;
                __pyx_t_33[2] = __pyx_mstate_global->__pyx_kp_u__9;
                __pyx_t_33[3] = __pyx_t_18;
                __pyx_t_33[4] = __pyx_mstate_global->__pyx_kp_u__9;
                __pyx_t_33[5] = __pyx_t_2;
                __pyx_t_33[6] = __pyx_mstate_global->__pyx_kp_u_logs_txt;
                __pyx_t_4 = __Pyx_PyUnicode_Join(__pyx_t_33, 7, __Pyx_PyUnicode_GET_LENGTH(__pyx_t_5) + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_3) + 1 * 2 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_18) + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_2) + 9, 127 | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_5) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_3) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_18) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_2));
                if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4344, __pyx_L42_error)
                __Pyx_GOTREF(__pyx_t_4);
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_s3_key);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_s3_key, ((PyObject*)__pyx_t_4));
                __Pyx_GIVEREF(__pyx_t_4);
                __pyx_t_4 = 0;

                /* "ws_package/controllers/activity_controller.py":4346
 *                             s3_key = f"{self.s3_logs_path}{user_entity.org_id}/{user_entity.user_id}/{timestamp}-logs.txt"
 * 
 *                             try:             # <<<<<<<<<<<<<<
 *                                 task = asyncio.create_task(
 *                                     self.screenshot_controller.screenshot_service.sync(
*/
                {
                  __Pyx_ExceptionSave(&__pyx_t_24, &__pyx_t_25, &__pyx_t_26);
                  __Pyx_XGOTREF(__pyx_t_24);
                  __Pyx_XGOTREF(__pyx_t_25);
                  __Pyx_XGOTREF(__pyx_t_26);
                  /*try:*/ {

                    /* "ws_package/controllers/activity_controller.py":4347
 * 
 *                             try:
 *                                 task = asyncio.create_task(             # <<<<<<<<<<<<<<
 *                                     self.screenshot_controller.screenshot_service.sync(
 *                                         str(mac_log),
*/
                    __pyx_t_2 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4347, __pyx_L75_error)
                    __Pyx_GOTREF(__pyx_t_18);
                    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_create_task); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4347, __pyx_L75_error)
                    __Pyx_GOTREF(__pyx_t_3);
                    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

                    /* "ws_package/controllers/activity_controller.py":4348
 *                             try:
 *                                 task = asyncio.create_task(
 *                                     self.screenshot_controller.screenshot_service.sync(             # <<<<<<<<<<<<<<
 *                                         str(mac_log),
 *                                         s3_key,
*/
                    __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4348, __pyx_L75_error)
                    __Pyx_GOTREF(__pyx_t_17);
                    __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_screenshot_service); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 4348, __pyx_L75_error)
                    __Pyx_GOTREF(__pyx_t_16);
                    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                    __pyx_t_5 = __pyx_t_16;
                    __Pyx_INCREF(__pyx_t_5);

                    /* "ws_package/controllers/activity_controller.py":4349
 *                                 task = asyncio.create_task(
 *                                     self.screenshot_controller.screenshot_service.sync(
 *                                         str(mac_log),             # <<<<<<<<<<<<<<
 *                                         s3_key,
 *                                         user_entity
*/
                    __pyx_t_17 = __Pyx_PyObject_Unicode(__pyx_cur_scope->__pyx_v_mac_log); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4349, __pyx_L75_error)
                    __Pyx_GOTREF(__pyx_t_17);

                    /* "ws_package/controllers/activity_controller.py":4351
 *                                         str(mac_log),
 *                                         s3_key,
 *                                         user_entity             # <<<<<<<<<<<<<<
 *                                     )
 *                                 )
*/
                    __pyx_t_6 = 0;
                    {
                      PyObject *__pyx_callargs[4] = {__pyx_t_5, __pyx_t_17, __pyx_cur_scope->__pyx_v_s3_key, __pyx_cur_scope->__pyx_v_user_entity};
                      __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_sync, __pyx_callargs+__pyx_t_6, (4-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                      if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4348, __pyx_L75_error)
                      __Pyx_GOTREF(__pyx_t_18);
                    }
                    __pyx_t_6 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_3))) {
                      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
                      assert(__pyx_t_2);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
                      __Pyx_INCREF(__pyx_t_2);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
                      __pyx_t_6 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_18};
                      __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4347, __pyx_L75_error)
                      __Pyx_GOTREF(__pyx_t_4);
                    }
                    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_task);
                    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_task, __pyx_t_4);
                    __Pyx_GIVEREF(__pyx_t_4);
                    __pyx_t_4 = 0;

                    /* "ws_package/controllers/activity_controller.py":4355
 *                                 )
 *                                 # Track task to prevent silent failures
 *                                 self._background_tasks.add(task)             # <<<<<<<<<<<<<<
 *                                 task.add_done_callback(self._background_tasks.discard)
 * 
*/
                    __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_background_tasks); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4355, __pyx_L75_error)
                    __Pyx_GOTREF(__pyx_t_18);
                    __pyx_t_3 = __pyx_t_18;
                    __Pyx_INCREF(__pyx_t_3);
                    __pyx_t_6 = 0;
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_task};
                      __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_add, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4355, __pyx_L75_error)
                      __Pyx_GOTREF(__pyx_t_4);
                    }
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                    /* "ws_package/controllers/activity_controller.py":4356
 *                                 # Track task to prevent silent failures
 *                                 self._background_tasks.add(task)
 *                                 task.add_done_callback(self._background_tasks.discard)             # <<<<<<<<<<<<<<
 * 
 *                                 logs_path = await task
*/
                    __pyx_t_18 = __pyx_cur_scope->__pyx_v_task;
                    __Pyx_INCREF(__pyx_t_18);
                    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_background_tasks); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4356, __pyx_L75_error)
                    __Pyx_GOTREF(__pyx_t_3);
                    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_discard); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4356, __pyx_L75_error)
                    __Pyx_GOTREF(__pyx_t_2);
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __pyx_t_6 = 0;
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_18, __pyx_t_2};
                      __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_add_done_callback, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4356, __pyx_L75_error)
                      __Pyx_GOTREF(__pyx_t_4);
                    }
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                    /* "ws_package/controllers/activity_controller.py":4358
 *                                 task.add_done_callback(self._background_tasks.discard)
 * 
 *                                 logs_path = await task             # <<<<<<<<<<<<<<
 *                                 logger.info("Running push logs")
 *                                 logger.info("Uploaded from: %s", mac_log)
*/
                    __pyx_t_7 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_cur_scope->__pyx_v_task, &__pyx_r);
                    if (likely(__pyx_t_7 == PYGEN_NEXT)) {
                      __Pyx_GOTREF(__pyx_r);
                      __Pyx_XGIVEREF(__pyx_t_9);
                      __pyx_cur_scope->__pyx_t_0 = __pyx_t_9;
                      __Pyx_XGIVEREF(__pyx_t_10);
                      __pyx_cur_scope->__pyx_t_1 = __pyx_t_10;
                      __Pyx_XGIVEREF(__pyx_t_11);
                      __pyx_cur_scope->__pyx_t_2 = __pyx_t_11;
                      __Pyx_XGIVEREF(__pyx_t_12);
                      __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                      __Pyx_XGIVEREF(__pyx_t_13);
                      __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                      __Pyx_XGIVEREF(__pyx_t_14);
                      __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                      __Pyx_XGIVEREF(__pyx_t_24);
                      __pyx_cur_scope->__pyx_t_7 = __pyx_t_24;
                      __Pyx_XGIVEREF(__pyx_t_25);
                      __pyx_cur_scope->__pyx_t_8 = __pyx_t_25;
                      __Pyx_XGIVEREF(__pyx_t_26);
                      __pyx_cur_scope->__pyx_t_9 = __pyx_t_26;
                      __Pyx_XGIVEREF(__pyx_r);
                      __Pyx_RefNannyFinishContext();
                      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                      /* return from generator, awaiting value */
                      __pyx_generator->resume_label = 5;
                      return __pyx_r;
                      __pyx_L83_resume_from_await:;
                      __pyx_t_9 = __pyx_cur_scope->__pyx_t_0;
                      __pyx_cur_scope->__pyx_t_0 = 0;
                      __Pyx_XGOTREF(__pyx_t_9);
                      __pyx_t_10 = __pyx_cur_scope->__pyx_t_1;
                      __pyx_cur_scope->__pyx_t_1 = 0;
                      __Pyx_XGOTREF(__pyx_t_10);
                      __pyx_t_11 = __pyx_cur_scope->__pyx_t_2;
                      __pyx_cur_scope->__pyx_t_2 = 0;
                      __Pyx_XGOTREF(__pyx_t_11);
                      __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                      __pyx_cur_scope->__pyx_t_3 = 0;
                      __Pyx_XGOTREF(__pyx_t_12);
                      __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                      __pyx_cur_scope->__pyx_t_4 = 0;
                      __Pyx_XGOTREF(__pyx_t_13);
                      __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                      __pyx_cur_scope->__pyx_t_5 = 0;
                      __Pyx_XGOTREF(__pyx_t_14);
                      __pyx_t_24 = __pyx_cur_scope->__pyx_t_7;
                      __pyx_cur_scope->__pyx_t_7 = 0;
                      __Pyx_XGOTREF(__pyx_t_24);
                      __pyx_t_25 = __pyx_cur_scope->__pyx_t_8;
                      __pyx_cur_scope->__pyx_t_8 = 0;
                      __Pyx_XGOTREF(__pyx_t_25);
                      __pyx_t_26 = __pyx_cur_scope->__pyx_t_9;
                      __pyx_cur_scope->__pyx_t_9 = 0;
                      __Pyx_XGOTREF(__pyx_t_26);
                      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4358, __pyx_L75_error)
                      __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                    } else if (likely(__pyx_t_7 == PYGEN_RETURN)) {
                      __Pyx_GOTREF(__pyx_r);
                      __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                    } else {
                      __Pyx_XGOTREF(__pyx_r);
                      __PYX_ERR(0, 4358, __pyx_L75_error)
                    }
                    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_logs_path);
                    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_logs_path, __pyx_t_4);
                    __Pyx_GIVEREF(__pyx_t_4);
                    __pyx_t_4 = 0;

                    /* "ws_package/controllers/activity_controller.py":4359
 * 
 *                                 logs_path = await task
 *                                 logger.info("Running push logs")             # <<<<<<<<<<<<<<
 *                                 logger.info("Uploaded from: %s", mac_log)
 *                                 logger.info("Uploaded to: %s", logs_path)
*/
                    __pyx_t_2 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4359, __pyx_L75_error)
                    __Pyx_GOTREF(__pyx_t_18);
                    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4359, __pyx_L75_error)
                    __Pyx_GOTREF(__pyx_t_3);
                    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                    __pyx_t_6 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_3))) {
                      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
                      assert(__pyx_t_2);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
                      __Pyx_INCREF(__pyx_t_2);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
                      __pyx_t_6 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Running_push_logs};
                      __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4359, __pyx_L75_error)
                      __Pyx_GOTREF(__pyx_t_4);
                    }
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                    /* "ws_package/controllers/activity_controller.py":4360
 *                                 logs_path = await task
 *                                 logger.info("Running push logs")
 *                                 logger.info("Uploaded from: %s", mac_log)             # <<<<<<<<<<<<<<
 *                                 logger.info("Uploaded to: %s", logs_path)
 *                             except ValidationError as e:
*/
                    __pyx_t_3 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4360, __pyx_L75_error)
                    __Pyx_GOTREF(__pyx_t_2);
                    __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4360, __pyx_L75_error)
                    __Pyx_GOTREF(__pyx_t_18);
                    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __pyx_t_6 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_18))) {
                      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_18);
                      assert(__pyx_t_3);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_18);
                      __Pyx_INCREF(__pyx_t_3);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_18, __pyx__function);
                      __pyx_t_6 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Uploaded_from_s, __pyx_cur_scope->__pyx_v_mac_log};
                      __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_18, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4360, __pyx_L75_error)
                      __Pyx_GOTREF(__pyx_t_4);
                    }
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                    /* "ws_package/controllers/activity_controller.py":4361
 *                                 logger.info("Running push logs")
 *                                 logger.info("Uploaded from: %s", mac_log)
 *                                 logger.info("Uploaded to: %s", logs_path)             # <<<<<<<<<<<<<<
 *                             except ValidationError as e:
 *                                 logger.error("Screenshot sync validation error for Mac logs: %s", e)
*/
                    __pyx_t_18 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4361, __pyx_L75_error)
                    __Pyx_GOTREF(__pyx_t_3);
                    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4361, __pyx_L75_error)
                    __Pyx_GOTREF(__pyx_t_2);
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __pyx_t_6 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_2))) {
                      __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_2);
                      assert(__pyx_t_18);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
                      __Pyx_INCREF(__pyx_t_18);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
                      __pyx_t_6 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[3] = {__pyx_t_18, __pyx_mstate_global->__pyx_kp_u_Uploaded_to_s, __pyx_cur_scope->__pyx_v_logs_path};
                      __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4361, __pyx_L75_error)
                      __Pyx_GOTREF(__pyx_t_4);
                    }
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                    /* "ws_package/controllers/activity_controller.py":4346
 *                             s3_key = f"{self.s3_logs_path}{user_entity.org_id}/{user_entity.user_id}/{timestamp}-logs.txt"
 * 
 *                             try:             # <<<<<<<<<<<<<<
 *                                 task = asyncio.create_task(
 *                                     self.screenshot_controller.screenshot_service.sync(
*/
                  }
                  __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                  __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                  goto __pyx_L82_try_end;
                  __pyx_L75_error:;
                  __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                  __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                  __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

                  /* "ws_package/controllers/activity_controller.py":4362
 *                                 logger.info("Uploaded from: %s", mac_log)
 *                                 logger.info("Uploaded to: %s", logs_path)
 *                             except ValidationError as e:             # <<<<<<<<<<<<<<
 *                                 logger.error("Screenshot sync validation error for Mac logs: %s", e)
 *                                 logger.error("Context: file=%s, dest=%s", mac_log, s3_key)
*/
                  __Pyx_ErrFetch(&__pyx_t_4, &__pyx_t_2, &__pyx_t_18);
                  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_ValidationError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4362, __pyx_L77_except_error)
                  __Pyx_GOTREF(__pyx_t_3);
                  __pyx_t_15 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_4, __pyx_t_3);
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_ErrRestore(__pyx_t_4, __pyx_t_2, __pyx_t_18);
                  __pyx_t_4 = 0; __pyx_t_2 = 0; __pyx_t_18 = 0;
                  if (__pyx_t_15) {
                    __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.start_status_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
                    if (__Pyx_GetException(&__pyx_t_18, &__pyx_t_2, &__pyx_t_4) < 0) __PYX_ERR(0, 4362, __pyx_L77_except_error)
                    __Pyx_XGOTREF(__pyx_t_18);
                    __Pyx_XGOTREF(__pyx_t_2);
                    __Pyx_XGOTREF(__pyx_t_4);
                    __Pyx_INCREF(__pyx_t_2);
                    __Pyx_GIVEREF(__pyx_t_2);
                    __pyx_cur_scope->__pyx_v_e = __pyx_t_2;
                    /*try:*/ {

                      /* "ws_package/controllers/activity_controller.py":4363
 *                                 logger.info("Uploaded to: %s", logs_path)
 *                             except ValidationError as e:
 *                                 logger.error("Screenshot sync validation error for Mac logs: %s", e)             # <<<<<<<<<<<<<<
 *                                 logger.error("Context: file=%s, dest=%s", mac_log, s3_key)
 *                                 # Continue processing - don't fail the entire operation
*/
                      __pyx_t_16 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4363, __pyx_L89_error)
                      __Pyx_GOTREF(__pyx_t_17);
                      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4363, __pyx_L89_error)
                      __Pyx_GOTREF(__pyx_t_5);
                      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                      __pyx_t_6 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_5))) {
                        __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_5);
                        assert(__pyx_t_16);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                        __Pyx_INCREF(__pyx_t_16);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                        __pyx_t_6 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[3] = {__pyx_t_16, __pyx_mstate_global->__pyx_kp_u_Screenshot_sync_validation_error_2, __pyx_cur_scope->__pyx_v_e};
                        __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4363, __pyx_L89_error)
                        __Pyx_GOTREF(__pyx_t_3);
                      }
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                      /* "ws_package/controllers/activity_controller.py":4364
 *                             except ValidationError as e:
 *                                 logger.error("Screenshot sync validation error for Mac logs: %s", e)
 *                                 logger.error("Context: file=%s, dest=%s", mac_log, s3_key)             # <<<<<<<<<<<<<<
 *                                 # Continue processing - don't fail the entire operation
 *                             except ScreenshotError as e:
*/
                      __pyx_t_5 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 4364, __pyx_L89_error)
                      __Pyx_GOTREF(__pyx_t_16);
                      __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4364, __pyx_L89_error)
                      __Pyx_GOTREF(__pyx_t_17);
                      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                      __pyx_t_6 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_17))) {
                        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_17);
                        assert(__pyx_t_5);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
                        __Pyx_INCREF(__pyx_t_5);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
                        __pyx_t_6 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[4] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Context_file_s_dest_s, __pyx_cur_scope->__pyx_v_mac_log, __pyx_cur_scope->__pyx_v_s3_key};
                        __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_6, (4-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4364, __pyx_L89_error)
                        __Pyx_GOTREF(__pyx_t_3);
                      }
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    }

                    /* "ws_package/controllers/activity_controller.py":4362
 *                                 logger.info("Uploaded from: %s", mac_log)
 *                                 logger.info("Uploaded to: %s", logs_path)
 *                             except ValidationError as e:             # <<<<<<<<<<<<<<
 *                                 logger.error("Screenshot sync validation error for Mac logs: %s", e)
 *                                 logger.error("Context: file=%s, dest=%s", mac_log, s3_key)
*/
                    /*finally:*/ {
                      /*normal exit:*/{
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                        __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                        goto __pyx_L90;
                      }
                      __pyx_L89_error:;
                      /*exception exit:*/{
                        __Pyx_PyThreadState_assign
                        __pyx_t_32 = 0; __pyx_t_31 = 0; __pyx_t_30 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
                        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                         __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
                        if ( unlikely(__Pyx_GetException(&__pyx_t_32, &__pyx_t_31, &__pyx_t_30) < 0)) __Pyx_ErrFetch(&__pyx_t_32, &__pyx_t_31, &__pyx_t_30);
                        __Pyx_XGOTREF(__pyx_t_32);
                        __Pyx_XGOTREF(__pyx_t_31);
                        __Pyx_XGOTREF(__pyx_t_30);
                        __Pyx_XGOTREF(__pyx_t_21);
                        __Pyx_XGOTREF(__pyx_t_22);
                        __Pyx_XGOTREF(__pyx_t_23);
                        __pyx_t_15 = __pyx_lineno; __pyx_t_19 = __pyx_clineno; __pyx_t_34 = __pyx_filename;
                        {
                          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                        }
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __Pyx_XGIVEREF(__pyx_t_22);
                        __Pyx_XGIVEREF(__pyx_t_23);
                        __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_23);
                        __Pyx_XGIVEREF(__pyx_t_32);
                        __Pyx_XGIVEREF(__pyx_t_31);
                        __Pyx_XGIVEREF(__pyx_t_30);
                        __Pyx_ErrRestore(__pyx_t_32, __pyx_t_31, __pyx_t_30);
                        __pyx_t_32 = 0; __pyx_t_31 = 0; __pyx_t_30 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
                        __pyx_lineno = __pyx_t_15; __pyx_clineno = __pyx_t_19; __pyx_filename = __pyx_t_34;
                        goto __pyx_L77_except_error;
                      }
                      __pyx_L90:;
                    }
                    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    goto __pyx_L76_exception_handled;
                  }

                  /* "ws_package/controllers/activity_controller.py":4366
 *                                 logger.error("Context: file=%s, dest=%s", mac_log, s3_key)
 *                                 # Continue processing - don't fail the entire operation
 *                             except ScreenshotError as e:             # <<<<<<<<<<<<<<
 *                                 logger.error("Screenshot sync error for Mac logs: %s", e)
 *                                 logger.error("Context: file=%s, dest=%s", mac_log, s3_key)
*/
                  __Pyx_ErrFetch(&__pyx_t_4, &__pyx_t_2, &__pyx_t_18);
                  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_ScreenshotError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4366, __pyx_L77_except_error)
                  __Pyx_GOTREF(__pyx_t_3);
                  __pyx_t_19 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_4, __pyx_t_3);
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_ErrRestore(__pyx_t_4, __pyx_t_2, __pyx_t_18);
                  __pyx_t_4 = 0; __pyx_t_2 = 0; __pyx_t_18 = 0;
                  if (__pyx_t_19) {
                    __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.start_status_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
                    if (__Pyx_GetException(&__pyx_t_18, &__pyx_t_2, &__pyx_t_4) < 0) __PYX_ERR(0, 4366, __pyx_L77_except_error)
                    __Pyx_XGOTREF(__pyx_t_18);
                    __Pyx_XGOTREF(__pyx_t_2);
                    __Pyx_XGOTREF(__pyx_t_4);
                    __Pyx_INCREF(__pyx_t_2);
                    __Pyx_GIVEREF(__pyx_t_2);
                    __pyx_cur_scope->__pyx_v_e = __pyx_t_2;
                    /*try:*/ {

                      /* "ws_package/controllers/activity_controller.py":4367
 *                                 # Continue processing - don't fail the entire operation
 *                             except ScreenshotError as e:
 *                                 logger.error("Screenshot sync error for Mac logs: %s", e)             # <<<<<<<<<<<<<<
 *                                 logger.error("Context: file=%s, dest=%s", mac_log, s3_key)
 *                                 # Continue processing - don't fail the entire operation
*/
                      __pyx_t_17 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4367, __pyx_L100_error)
                      __Pyx_GOTREF(__pyx_t_5);
                      __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 4367, __pyx_L100_error)
                      __Pyx_GOTREF(__pyx_t_16);
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __pyx_t_6 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_16))) {
                        __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_16);
                        assert(__pyx_t_17);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_16);
                        __Pyx_INCREF(__pyx_t_17);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_16, __pyx__function);
                        __pyx_t_6 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[3] = {__pyx_t_17, __pyx_mstate_global->__pyx_kp_u_Screenshot_sync_error_for_Mac_lo, __pyx_cur_scope->__pyx_v_e};
                        __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_16, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4367, __pyx_L100_error)
                        __Pyx_GOTREF(__pyx_t_3);
                      }
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                      /* "ws_package/controllers/activity_controller.py":4368
 *                             except ScreenshotError as e:
 *                                 logger.error("Screenshot sync error for Mac logs: %s", e)
 *                                 logger.error("Context: file=%s, dest=%s", mac_log, s3_key)             # <<<<<<<<<<<<<<
 *                                 # Continue processing - don't fail the entire operation
 *                             except NetworkError as e:
*/
                      __pyx_t_16 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4368, __pyx_L100_error)
                      __Pyx_GOTREF(__pyx_t_17);
                      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4368, __pyx_L100_error)
                      __Pyx_GOTREF(__pyx_t_5);
                      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                      __pyx_t_6 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_5))) {
                        __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_5);
                        assert(__pyx_t_16);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                        __Pyx_INCREF(__pyx_t_16);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                        __pyx_t_6 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[4] = {__pyx_t_16, __pyx_mstate_global->__pyx_kp_u_Context_file_s_dest_s, __pyx_cur_scope->__pyx_v_mac_log, __pyx_cur_scope->__pyx_v_s3_key};
                        __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_6, (4-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4368, __pyx_L100_error)
                        __Pyx_GOTREF(__pyx_t_3);
                      }
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    }

                    /* "ws_package/controllers/activity_controller.py":4366
 *                                 logger.error("Context: file=%s, dest=%s", mac_log, s3_key)
 *                                 # Continue processing - don't fail the entire operation
 *                             except ScreenshotError as e:             # <<<<<<<<<<<<<<
 *                                 logger.error("Screenshot sync error for Mac logs: %s", e)
 *                                 logger.error("Context: file=%s, dest=%s", mac_log, s3_key)
*/
                    /*finally:*/ {
                      /*normal exit:*/{
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                        __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                        goto __pyx_L101;
                      }
                      __pyx_L100_error:;
                      /*exception exit:*/{
                        __Pyx_PyThreadState_assign
                        __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0;
                        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                         __Pyx_ExceptionSwap(&__pyx_t_30, &__pyx_t_31, &__pyx_t_32);
                        if ( unlikely(__Pyx_GetException(&__pyx_t_23, &__pyx_t_22, &__pyx_t_21) < 0)) __Pyx_ErrFetch(&__pyx_t_23, &__pyx_t_22, &__pyx_t_21);
                        __Pyx_XGOTREF(__pyx_t_23);
                        __Pyx_XGOTREF(__pyx_t_22);
                        __Pyx_XGOTREF(__pyx_t_21);
                        __Pyx_XGOTREF(__pyx_t_30);
                        __Pyx_XGOTREF(__pyx_t_31);
                        __Pyx_XGOTREF(__pyx_t_32);
                        __pyx_t_19 = __pyx_lineno; __pyx_t_15 = __pyx_clineno; __pyx_t_35 = __pyx_filename;
                        {
                          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                        }
                        __Pyx_XGIVEREF(__pyx_t_30);
                        __Pyx_XGIVEREF(__pyx_t_31);
                        __Pyx_XGIVEREF(__pyx_t_32);
                        __Pyx_ExceptionReset(__pyx_t_30, __pyx_t_31, __pyx_t_32);
                        __Pyx_XGIVEREF(__pyx_t_23);
                        __Pyx_XGIVEREF(__pyx_t_22);
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __Pyx_ErrRestore(__pyx_t_23, __pyx_t_22, __pyx_t_21);
                        __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0;
                        __pyx_lineno = __pyx_t_19; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_35;
                        goto __pyx_L77_except_error;
                      }
                      __pyx_L101:;
                    }
                    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    goto __pyx_L76_exception_handled;
                  }

                  /* "ws_package/controllers/activity_controller.py":4370
 *                                 logger.error("Context: file=%s, dest=%s", mac_log, s3_key)
 *                                 # Continue processing - don't fail the entire operation
 *                             except NetworkError as e:             # <<<<<<<<<<<<<<
 *                                 logger.error("Network error during screenshot sync for Mac logs: %s", e)
 *                                 logger.error("Context: file=%s, dest=%s", mac_log, s3_key)
*/
                  __Pyx_ErrFetch(&__pyx_t_4, &__pyx_t_2, &__pyx_t_18);
                  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_NetworkError); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4370, __pyx_L77_except_error)
                  __Pyx_GOTREF(__pyx_t_3);
                  __pyx_t_15 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_4, __pyx_t_3);
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_ErrRestore(__pyx_t_4, __pyx_t_2, __pyx_t_18);
                  __pyx_t_4 = 0; __pyx_t_2 = 0; __pyx_t_18 = 0;
                  if (__pyx_t_15) {
                    __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.start_status_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
                    if (__Pyx_GetException(&__pyx_t_18, &__pyx_t_2, &__pyx_t_4) < 0) __PYX_ERR(0, 4370, __pyx_L77_except_error)
                    __Pyx_XGOTREF(__pyx_t_18);
                    __Pyx_XGOTREF(__pyx_t_2);
                    __Pyx_XGOTREF(__pyx_t_4);
                    __Pyx_INCREF(__pyx_t_2);
                    __Pyx_GIVEREF(__pyx_t_2);
                    __pyx_cur_scope->__pyx_v_e = __pyx_t_2;
                    /*try:*/ {

                      /* "ws_package/controllers/activity_controller.py":4371
 *                                 # Continue processing - don't fail the entire operation
 *                             except NetworkError as e:
 *                                 logger.error("Network error during screenshot sync for Mac logs: %s", e)             # <<<<<<<<<<<<<<
 *                                 logger.error("Context: file=%s, dest=%s", mac_log, s3_key)
 *                                 # Continue processing - don't fail the entire operation
*/
                      __pyx_t_5 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 4371, __pyx_L111_error)
                      __Pyx_GOTREF(__pyx_t_16);
                      __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4371, __pyx_L111_error)
                      __Pyx_GOTREF(__pyx_t_17);
                      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                      __pyx_t_6 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_17))) {
                        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_17);
                        assert(__pyx_t_5);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
                        __Pyx_INCREF(__pyx_t_5);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
                        __pyx_t_6 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Network_error_during_screenshot_2, __pyx_cur_scope->__pyx_v_e};
                        __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4371, __pyx_L111_error)
                        __Pyx_GOTREF(__pyx_t_3);
                      }
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                      /* "ws_package/controllers/activity_controller.py":4372
 *                             except NetworkError as e:
 *                                 logger.error("Network error during screenshot sync for Mac logs: %s", e)
 *                                 logger.error("Context: file=%s, dest=%s", mac_log, s3_key)             # <<<<<<<<<<<<<<
 *                                 # Continue processing - don't fail the entire operation
 *                             except Exception as e:
*/
                      __pyx_t_17 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4372, __pyx_L111_error)
                      __Pyx_GOTREF(__pyx_t_5);
                      __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 4372, __pyx_L111_error)
                      __Pyx_GOTREF(__pyx_t_16);
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __pyx_t_6 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_16))) {
                        __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_16);
                        assert(__pyx_t_17);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_16);
                        __Pyx_INCREF(__pyx_t_17);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_16, __pyx__function);
                        __pyx_t_6 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[4] = {__pyx_t_17, __pyx_mstate_global->__pyx_kp_u_Context_file_s_dest_s, __pyx_cur_scope->__pyx_v_mac_log, __pyx_cur_scope->__pyx_v_s3_key};
                        __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_16, __pyx_callargs+__pyx_t_6, (4-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4372, __pyx_L111_error)
                        __Pyx_GOTREF(__pyx_t_3);
                      }
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    }

                    /* "ws_package/controllers/activity_controller.py":4370
 *                                 logger.error("Context: file=%s, dest=%s", mac_log, s3_key)
 *                                 # Continue processing - don't fail the entire operation
 *                             except NetworkError as e:             # <<<<<<<<<<<<<<
 *                                 logger.error("Network error during screenshot sync for Mac logs: %s", e)
 *                                 logger.error("Context: file=%s, dest=%s", mac_log, s3_key)
*/
                    /*finally:*/ {
                      /*normal exit:*/{
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                        __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                        goto __pyx_L112;
                      }
                      __pyx_L111_error:;
                      /*exception exit:*/{
                        __Pyx_PyThreadState_assign
                        __pyx_t_32 = 0; __pyx_t_31 = 0; __pyx_t_30 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
                        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                         __Pyx_ExceptionSwap(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
                        if ( unlikely(__Pyx_GetException(&__pyx_t_32, &__pyx_t_31, &__pyx_t_30) < 0)) __Pyx_ErrFetch(&__pyx_t_32, &__pyx_t_31, &__pyx_t_30);
                        __Pyx_XGOTREF(__pyx_t_32);
                        __Pyx_XGOTREF(__pyx_t_31);
                        __Pyx_XGOTREF(__pyx_t_30);
                        __Pyx_XGOTREF(__pyx_t_21);
                        __Pyx_XGOTREF(__pyx_t_22);
                        __Pyx_XGOTREF(__pyx_t_23);
                        __pyx_t_15 = __pyx_lineno; __pyx_t_19 = __pyx_clineno; __pyx_t_36 = __pyx_filename;
                        {
                          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                        }
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __Pyx_XGIVEREF(__pyx_t_22);
                        __Pyx_XGIVEREF(__pyx_t_23);
                        __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_23);
                        __Pyx_XGIVEREF(__pyx_t_32);
                        __Pyx_XGIVEREF(__pyx_t_31);
                        __Pyx_XGIVEREF(__pyx_t_30);
                        __Pyx_ErrRestore(__pyx_t_32, __pyx_t_31, __pyx_t_30);
                        __pyx_t_32 = 0; __pyx_t_31 = 0; __pyx_t_30 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0;
                        __pyx_lineno = __pyx_t_15; __pyx_clineno = __pyx_t_19; __pyx_filename = __pyx_t_36;
                        goto __pyx_L77_except_error;
                      }
                      __pyx_L112:;
                    }
                    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    goto __pyx_L76_exception_handled;
                  }

                  /* "ws_package/controllers/activity_controller.py":4374
 *                                 logger.error("Context: file=%s, dest=%s", mac_log, s3_key)
 *                                 # Continue processing - don't fail the entire operation
 *                             except Exception as e:             # <<<<<<<<<<<<<<
 *                                 logger.error("Unexpected error during screenshot sync for Mac logs: %s", e)
 *                                 logger.error("Context: file=%s, dest=%s", mac_log, s3_key)
*/
                  __pyx_t_19 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                  if (__pyx_t_19) {
                    __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.start_status_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
                    if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_2, &__pyx_t_18) < 0) __PYX_ERR(0, 4374, __pyx_L77_except_error)
                    __Pyx_XGOTREF(__pyx_t_4);
                    __Pyx_XGOTREF(__pyx_t_2);
                    __Pyx_XGOTREF(__pyx_t_18);
                    __Pyx_INCREF(__pyx_t_2);
                    __Pyx_GIVEREF(__pyx_t_2);
                    __pyx_cur_scope->__pyx_v_e = __pyx_t_2;
                    /*try:*/ {

                      /* "ws_package/controllers/activity_controller.py":4375
 *                                 # Continue processing - don't fail the entire operation
 *                             except Exception as e:
 *                                 logger.error("Unexpected error during screenshot sync for Mac logs: %s", e)             # <<<<<<<<<<<<<<
 *                                 logger.error("Context: file=%s, dest=%s", mac_log, s3_key)
 *                                 # Continue processing - don't fail the entire operation
*/
                      __pyx_t_16 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4375, __pyx_L122_error)
                      __Pyx_GOTREF(__pyx_t_17);
                      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4375, __pyx_L122_error)
                      __Pyx_GOTREF(__pyx_t_5);
                      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                      __pyx_t_6 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_5))) {
                        __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_5);
                        assert(__pyx_t_16);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                        __Pyx_INCREF(__pyx_t_16);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                        __pyx_t_6 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[3] = {__pyx_t_16, __pyx_mstate_global->__pyx_kp_u_Unexpected_error_during_screensh_2, __pyx_cur_scope->__pyx_v_e};
                        __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4375, __pyx_L122_error)
                        __Pyx_GOTREF(__pyx_t_3);
                      }
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                      /* "ws_package/controllers/activity_controller.py":4376
 *                             except Exception as e:
 *                                 logger.error("Unexpected error during screenshot sync for Mac logs: %s", e)
 *                                 logger.error("Context: file=%s, dest=%s", mac_log, s3_key)             # <<<<<<<<<<<<<<
 *                                 # Continue processing - don't fail the entire operation
 * 
*/
                      __pyx_t_5 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 4376, __pyx_L122_error)
                      __Pyx_GOTREF(__pyx_t_16);
                      __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4376, __pyx_L122_error)
                      __Pyx_GOTREF(__pyx_t_17);
                      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                      __pyx_t_6 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_17))) {
                        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_17);
                        assert(__pyx_t_5);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
                        __Pyx_INCREF(__pyx_t_5);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
                        __pyx_t_6 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[4] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Context_file_s_dest_s, __pyx_cur_scope->__pyx_v_mac_log, __pyx_cur_scope->__pyx_v_s3_key};
                        __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_6, (4-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                        if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4376, __pyx_L122_error)
                        __Pyx_GOTREF(__pyx_t_3);
                      }
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    }

                    /* "ws_package/controllers/activity_controller.py":4374
 *                                 logger.error("Context: file=%s, dest=%s", mac_log, s3_key)
 *                                 # Continue processing - don't fail the entire operation
 *                             except Exception as e:             # <<<<<<<<<<<<<<
 *                                 logger.error("Unexpected error during screenshot sync for Mac logs: %s", e)
 *                                 logger.error("Context: file=%s, dest=%s", mac_log, s3_key)
*/
                    /*finally:*/ {
                      /*normal exit:*/{
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                        __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                        goto __pyx_L123;
                      }
                      __pyx_L122_error:;
                      /*exception exit:*/{
                        __Pyx_PyThreadState_assign
                        __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0;
                        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                         __Pyx_ExceptionSwap(&__pyx_t_30, &__pyx_t_31, &__pyx_t_32);
                        if ( unlikely(__Pyx_GetException(&__pyx_t_23, &__pyx_t_22, &__pyx_t_21) < 0)) __Pyx_ErrFetch(&__pyx_t_23, &__pyx_t_22, &__pyx_t_21);
                        __Pyx_XGOTREF(__pyx_t_23);
                        __Pyx_XGOTREF(__pyx_t_22);
                        __Pyx_XGOTREF(__pyx_t_21);
                        __Pyx_XGOTREF(__pyx_t_30);
                        __Pyx_XGOTREF(__pyx_t_31);
                        __Pyx_XGOTREF(__pyx_t_32);
                        __pyx_t_19 = __pyx_lineno; __pyx_t_15 = __pyx_clineno; __pyx_t_37 = __pyx_filename;
                        {
                          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                        }
                        __Pyx_XGIVEREF(__pyx_t_30);
                        __Pyx_XGIVEREF(__pyx_t_31);
                        __Pyx_XGIVEREF(__pyx_t_32);
                        __Pyx_ExceptionReset(__pyx_t_30, __pyx_t_31, __pyx_t_32);
                        __Pyx_XGIVEREF(__pyx_t_23);
                        __Pyx_XGIVEREF(__pyx_t_22);
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __Pyx_ErrRestore(__pyx_t_23, __pyx_t_22, __pyx_t_21);
                        __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0;
                        __pyx_lineno = __pyx_t_19; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_37;
                        goto __pyx_L77_except_error;
                      }
                      __pyx_L123:;
                    }
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                    goto __pyx_L76_exception_handled;
                  }
                  goto __pyx_L77_except_error;

                  /* "ws_package/controllers/activity_controller.py":4346
 *                             s3_key = f"{self.s3_logs_path}{user_entity.org_id}/{user_entity.user_id}/{timestamp}-logs.txt"
 * 
 *                             try:             # <<<<<<<<<<<<<<
 *                                 task = asyncio.create_task(
 *                                     self.screenshot_controller.screenshot_service.sync(
*/
                  __pyx_L77_except_error:;
                  __Pyx_XGIVEREF(__pyx_t_24);
                  __Pyx_XGIVEREF(__pyx_t_25);
                  __Pyx_XGIVEREF(__pyx_t_26);
                  __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_25, __pyx_t_26);
                  goto __pyx_L42_error;
                  __pyx_L76_exception_handled:;
                  __Pyx_XGIVEREF(__pyx_t_24);
                  __Pyx_XGIVEREF(__pyx_t_25);
                  __Pyx_XGIVEREF(__pyx_t_26);
                  __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_25, __pyx_t_26);
                  __pyx_L82_try_end:;
                }

                /* "ws_package/controllers/activity_controller.py":4380
 * 
 *                             # Clear the log file after successful upload
 *                             mac_log.write_text("")             # <<<<<<<<<<<<<<
 *                             logger.info("Cleared log file: %s", mac_log)
 *                         else:
*/
                __pyx_t_2 = __pyx_cur_scope->__pyx_v_mac_log;
                __Pyx_INCREF(__pyx_t_2);
                __pyx_t_6 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u__2};
                  __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_write_text, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                  if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4380, __pyx_L42_error)
                  __Pyx_GOTREF(__pyx_t_18);
                }
                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

                /* "ws_package/controllers/activity_controller.py":4381
 *                             # Clear the log file after successful upload
 *                             mac_log.write_text("")
 *                             logger.info("Cleared log file: %s", mac_log)             # <<<<<<<<<<<<<<
 *                         else:
 *                             logger.info("Log file %s does not exist, skipping upload.", mac_log)
*/
                __pyx_t_2 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4381, __pyx_L42_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4381, __pyx_L42_error)
                __Pyx_GOTREF(__pyx_t_3);
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                __pyx_t_6 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_3))) {
                  __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
                  assert(__pyx_t_2);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
                  __Pyx_INCREF(__pyx_t_2);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
                  __pyx_t_6 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Cleared_log_file_s, __pyx_cur_scope->__pyx_v_mac_log};
                  __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4381, __pyx_L42_error)
                  __Pyx_GOTREF(__pyx_t_18);
                }
                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

                /* "ws_package/controllers/activity_controller.py":4342
 *                         logger.info("Sending mac logs to server")
 *                         mac_log = Path.home() / "Library/Application Support/Workstatus/logs/workstatus_error.log"
 *                         if mac_log.exists():             # <<<<<<<<<<<<<<
 *                             timestamp = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
 *                             s3_key = f"{self.s3_logs_path}{user_entity.org_id}/{user_entity.user_id}/{timestamp}-logs.txt"
*/
                goto __pyx_L74;
              }

              /* "ws_package/controllers/activity_controller.py":4383
 *                             logger.info("Cleared log file: %s", mac_log)
 *                         else:
 *                             logger.info("Log file %s does not exist, skipping upload.", mac_log)             # <<<<<<<<<<<<<<
 *                     else:
 *                             logger.debug("MAC ErrorLog file does not exist, skipping upload.")
*/
              /*else*/ {
                __pyx_t_3 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4383, __pyx_L42_error)
                __Pyx_GOTREF(__pyx_t_2);
                __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4383, __pyx_L42_error)
                __Pyx_GOTREF(__pyx_t_4);
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                __pyx_t_6 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_4))) {
                  __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
                  assert(__pyx_t_3);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                  __Pyx_INCREF(__pyx_t_3);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                  __pyx_t_6 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Log_file_s_does_not_exist_skippi, __pyx_cur_scope->__pyx_v_mac_log};
                  __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4383, __pyx_L42_error)
                  __Pyx_GOTREF(__pyx_t_18);
                }
                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
              }
              __pyx_L74:;

              /* "ws_package/controllers/activity_controller.py":4339
 *                         logger.debug("Error during periodic log cleanup (non-fatal): %s", e)
 * 
 *                     if sys.platform == "darwin":             # <<<<<<<<<<<<<<
 *                         logger.info("Sending mac logs to server")
 *                         mac_log = Path.home() / "Library/Application Support/Workstatus/logs/workstatus_error.log"
*/
              goto __pyx_L73;
            }

            /* "ws_package/controllers/activity_controller.py":4385
 *                             logger.info("Log file %s does not exist, skipping upload.", mac_log)
 *                     else:
 *                             logger.debug("MAC ErrorLog file does not exist, skipping upload.")             # <<<<<<<<<<<<<<
 *                 except Exception as e:
 *                     logger.exception("Error in uploading MAC logs: %s", e)
*/
            /*else*/ {
              __pyx_t_4 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4385, __pyx_L42_error)
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4385, __pyx_L42_error)
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __pyx_t_6 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_2))) {
                __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
                assert(__pyx_t_4);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
                __Pyx_INCREF(__pyx_t_4);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
                __pyx_t_6 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_MAC_ErrorLog_file_does_not_exist};
                __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4385, __pyx_L42_error)
                __Pyx_GOTREF(__pyx_t_18);
              }
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
            }
            __pyx_L73:;

            /* "ws_package/controllers/activity_controller.py":4327
 *                     break
 * 
 *                 try:             # <<<<<<<<<<<<<<
 *                     await self.delete_old_data_and_screenshots()
 * 
*/
          }
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          goto __pyx_L49_try_end;
          __pyx_L42_error:;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":4386
 *                     else:
 *                             logger.debug("MAC ErrorLog file does not exist, skipping upload.")
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.exception("Error in uploading MAC logs: %s", e)
 * 
*/
          __pyx_t_15 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
          if (__pyx_t_15) {
            __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.start_status_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_18, &__pyx_t_2, &__pyx_t_4) < 0) __PYX_ERR(0, 4386, __pyx_L44_except_error)
            __Pyx_XGOTREF(__pyx_t_18);
            __Pyx_XGOTREF(__pyx_t_2);
            __Pyx_XGOTREF(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_2);
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_2);
            __Pyx_GIVEREF(__pyx_t_2);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":4387
 *                             logger.debug("MAC ErrorLog file does not exist, skipping upload.")
 *                 except Exception as e:
 *                     logger.exception("Error in uploading MAC logs: %s", e)             # <<<<<<<<<<<<<<
 * 
 *             except Exception as e:
*/
              __pyx_t_17 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4387, __pyx_L133_error)
              __Pyx_GOTREF(__pyx_t_5);
              __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_exception); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 4387, __pyx_L133_error)
              __Pyx_GOTREF(__pyx_t_16);
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __pyx_t_6 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_16))) {
                __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_16);
                assert(__pyx_t_17);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_16);
                __Pyx_INCREF(__pyx_t_17);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_16, __pyx__function);
                __pyx_t_6 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_17, __pyx_mstate_global->__pyx_kp_u_Error_in_uploading_MAC_logs_s, __pyx_cur_scope->__pyx_v_e};
                __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_16, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4387, __pyx_L133_error)
                __Pyx_GOTREF(__pyx_t_3);
              }
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            }

            /* "ws_package/controllers/activity_controller.py":4386
 *                     else:
 *                             logger.debug("MAC ErrorLog file does not exist, skipping upload.")
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.exception("Error in uploading MAC logs: %s", e)
 * 
*/
            /*finally:*/ {
              /*normal exit:*/{
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                goto __pyx_L134;
              }
              __pyx_L133_error:;
              /*exception exit:*/{
                __Pyx_PyThreadState_assign
                __pyx_t_26 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_32 = 0; __pyx_t_31 = 0; __pyx_t_30 = 0;
                __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                 __Pyx_ExceptionSwap(&__pyx_t_32, &__pyx_t_31, &__pyx_t_30);
                if ( unlikely(__Pyx_GetException(&__pyx_t_26, &__pyx_t_25, &__pyx_t_24) < 0)) __Pyx_ErrFetch(&__pyx_t_26, &__pyx_t_25, &__pyx_t_24);
                __Pyx_XGOTREF(__pyx_t_26);
                __Pyx_XGOTREF(__pyx_t_25);
                __Pyx_XGOTREF(__pyx_t_24);
                __Pyx_XGOTREF(__pyx_t_32);
                __Pyx_XGOTREF(__pyx_t_31);
                __Pyx_XGOTREF(__pyx_t_30);
                __pyx_t_15 = __pyx_lineno; __pyx_t_19 = __pyx_clineno; __pyx_t_38 = __pyx_filename;
                {
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                }
                __Pyx_XGIVEREF(__pyx_t_32);
                __Pyx_XGIVEREF(__pyx_t_31);
                __Pyx_XGIVEREF(__pyx_t_30);
                __Pyx_ExceptionReset(__pyx_t_32, __pyx_t_31, __pyx_t_30);
                __Pyx_XGIVEREF(__pyx_t_26);
                __Pyx_XGIVEREF(__pyx_t_25);
                __Pyx_XGIVEREF(__pyx_t_24);
                __Pyx_ErrRestore(__pyx_t_26, __pyx_t_25, __pyx_t_24);
                __pyx_t_26 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_32 = 0; __pyx_t_31 = 0; __pyx_t_30 = 0;
                __pyx_lineno = __pyx_t_15; __pyx_clineno = __pyx_t_19; __pyx_filename = __pyx_t_38;
                goto __pyx_L44_except_error;
              }
              __pyx_L134:;
            }
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            goto __pyx_L43_exception_handled;
          }
          goto __pyx_L44_except_error;

          /* "ws_package/controllers/activity_controller.py":4327
 *                     break
 * 
 *                 try:             # <<<<<<<<<<<<<<
 *                     await self.delete_old_data_and_screenshots()
 * 
*/
          __pyx_L44_except_error:;
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12);
          goto __pyx_L8_error;
          __pyx_L43_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12);
          __pyx_L49_try_end:;
        }

        /* "ws_package/controllers/activity_controller.py":4308
 *         # This thread just keeps running for db_to_server operations
 *         while not stop_event.is_set():
 *             try:             # <<<<<<<<<<<<<<
 *                 try:
 *                     await self.db_to_server(user_entity)
*/
      }
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
      goto __pyx_L15_try_end;
      __pyx_L8_error:;
      __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "ws_package/controllers/activity_controller.py":4389
 *                     logger.exception("Error in uploading MAC logs: %s", e)
 * 
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 from ws_package.utils.error_codes import ErrorCode
 *                 logger.error("%s: %s", ErrorCode.STATUS_LOOP_FAILED, e, exc_info=True)
*/
      __pyx_t_19 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
      if (__pyx_t_19) {
        __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.start_status_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
        if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_2, &__pyx_t_18) < 0) __PYX_ERR(0, 4389, __pyx_L10_except_error)
        __Pyx_XGOTREF(__pyx_t_4);
        __Pyx_XGOTREF(__pyx_t_2);
        __Pyx_XGOTREF(__pyx_t_18);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":4390
 * 
 *             except Exception as e:
 *                 from ws_package.utils.error_codes import ErrorCode             # <<<<<<<<<<<<<<
 *                 logger.error("%s: %s", ErrorCode.STATUS_LOOP_FAILED, e, exc_info=True)
 *                 # Continue the loop even if there's an error
*/
          {
            PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ErrorCode};
            __pyx_t_12 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_utils_error_codes, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4390, __pyx_L144_error)
          }
          __pyx_t_3 = __pyx_t_12;
          __Pyx_GOTREF(__pyx_t_3);
          {
            PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ErrorCode};
            __pyx_t_28 = 0; {
              __pyx_t_16 = __Pyx_ImportFrom(__pyx_t_3, __pyx_imported_names[__pyx_t_28]); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 4390, __pyx_L144_error)
              __Pyx_GOTREF(__pyx_t_16);
              switch (__pyx_t_28) {
                case 0:
                __Pyx_INCREF(__pyx_t_16);
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_ErrorCode);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_ErrorCode, __pyx_t_16);
                __Pyx_GIVEREF(__pyx_t_16);
                break;
                default:;
              }
              __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
            }
          }
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

          /* "ws_package/controllers/activity_controller.py":4391
 *             except Exception as e:
 *                 from ws_package.utils.error_codes import ErrorCode
 *                 logger.error("%s: %s", ErrorCode.STATUS_LOOP_FAILED, e, exc_info=True)             # <<<<<<<<<<<<<<
 *                 # Continue the loop even if there's an error
 *                 await asyncio.sleep(5)  # Brief pause before retrying
*/
          __pyx_t_16 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4391, __pyx_L144_error)
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4391, __pyx_L144_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_ErrorCode, __pyx_mstate_global->__pyx_n_u_STATUS_LOOP_FAILED); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4391, __pyx_L144_error)
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_6 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_5))) {
            __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_5);
            assert(__pyx_t_16);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_16);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
            __pyx_t_6 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[4 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_16, __pyx_mstate_global->__pyx_kp_u_s_s, __pyx_t_17, __pyx_cur_scope->__pyx_v_e};
            __pyx_t_39 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 4391, __pyx_L144_error)
            __Pyx_GOTREF(__pyx_t_39);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_39, __pyx_callargs+4, 0) < (0)) __PYX_ERR(0, 4391, __pyx_L144_error)
            __pyx_t_3 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_6, (4-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_39);
            __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4391, __pyx_L144_error)
            __Pyx_GOTREF(__pyx_t_3);
          }
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

          /* "ws_package/controllers/activity_controller.py":4393
 *                 logger.error("%s: %s", ErrorCode.STATUS_LOOP_FAILED, e, exc_info=True)
 *                 # Continue the loop even if there's an error
 *                 await asyncio.sleep(5)  # Brief pause before retrying             # <<<<<<<<<<<<<<
 *                 continue
 * 
*/
          __pyx_t_5 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 4393, __pyx_L144_error)
          __Pyx_GOTREF(__pyx_t_39);
          __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4393, __pyx_L144_error)
          __Pyx_GOTREF(__pyx_t_17);
          __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
          __pyx_t_6 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_17))) {
            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_17);
            assert(__pyx_t_5);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
            __pyx_t_6 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_int_5};
            __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4393, __pyx_L144_error)
            __Pyx_GOTREF(__pyx_t_3);
          }
          __pyx_t_7 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_3, &__pyx_r);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (likely(__pyx_t_7 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_2);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
            __Pyx_XGIVEREF(__pyx_t_4);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_4;
            __Pyx_XGIVEREF(__pyx_t_9);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_9;
            __Pyx_XGIVEREF(__pyx_t_10);
            __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
            __Pyx_XGIVEREF(__pyx_t_11);
            __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
            __Pyx_XGIVEREF(__pyx_t_18);
            __pyx_cur_scope->__pyx_t_5 = __pyx_t_18;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_SwapException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 6;
            return __pyx_r;
            __pyx_L146_resume_from_await:;
            __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_2);
            __pyx_t_4 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_4);
            __pyx_t_9 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_9);
            __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
            __pyx_cur_scope->__pyx_t_3 = 0;
            __Pyx_XGOTREF(__pyx_t_10);
            __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
            __pyx_cur_scope->__pyx_t_4 = 0;
            __Pyx_XGOTREF(__pyx_t_11);
            __pyx_t_18 = __pyx_cur_scope->__pyx_t_5;
            __pyx_cur_scope->__pyx_t_5 = 0;
            __Pyx_XGOTREF(__pyx_t_18);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4393, __pyx_L144_error)
          } else if (likely(__pyx_t_7 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_DECREF(__pyx_r); __pyx_r = 0;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 4393, __pyx_L144_error)
          }

          /* "ws_package/controllers/activity_controller.py":4394
 *                 # Continue the loop even if there's an error
 *                 await asyncio.sleep(5)  # Brief pause before retrying
 *                 continue             # <<<<<<<<<<<<<<
 * 
 *     def set_local_timezone(self, user_entity):
*/
          goto __pyx_L141_continue;
        }

        /* "ws_package/controllers/activity_controller.py":4389
 *                     logger.exception("Error in uploading MAC logs: %s", e)
 * 
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 from ws_package.utils.error_codes import ErrorCode
 *                 logger.error("%s: %s", ErrorCode.STATUS_LOOP_FAILED, e, exc_info=True)
*/
        /*finally:*/ {
          __pyx_L144_error:;
          /*exception exit:*/{
            __Pyx_PyThreadState_assign
            __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0;
            __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
            __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
             __Pyx_ExceptionSwap(&__pyx_t_30, &__pyx_t_31, &__pyx_t_32);
            if ( unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
            __Pyx_XGOTREF(__pyx_t_12);
            __Pyx_XGOTREF(__pyx_t_13);
            __Pyx_XGOTREF(__pyx_t_14);
            __Pyx_XGOTREF(__pyx_t_30);
            __Pyx_XGOTREF(__pyx_t_31);
            __Pyx_XGOTREF(__pyx_t_32);
            __pyx_t_19 = __pyx_lineno; __pyx_t_15 = __pyx_clineno; __pyx_t_40 = __pyx_filename;
            {
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
            }
            __Pyx_XGIVEREF(__pyx_t_30);
            __Pyx_XGIVEREF(__pyx_t_31);
            __Pyx_XGIVEREF(__pyx_t_32);
            __Pyx_ExceptionReset(__pyx_t_30, __pyx_t_31, __pyx_t_32);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_ErrRestore(__pyx_t_12, __pyx_t_13, __pyx_t_14);
            __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0; __pyx_t_32 = 0;
            __pyx_lineno = __pyx_t_19; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_40;
            goto __pyx_L10_except_error;
          }
          __pyx_L141_continue: {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
            goto __pyx_L139_except_continue;
          }
        }
        __pyx_L139_except_continue:;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
        goto __pyx_L14_try_continue;
      }
      goto __pyx_L10_except_error;

      /* "ws_package/controllers/activity_controller.py":4308
 *         # This thread just keeps running for db_to_server operations
 *         while not stop_event.is_set():
 *             try:             # <<<<<<<<<<<<<<
 *                 try:
 *                     await self.db_to_server(user_entity)
*/
      __pyx_L10_except_error:;
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      goto __pyx_L1_error;
      __pyx_L13_try_break:;
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      goto __pyx_L7_break;
      __pyx_L14_try_continue:;
      __Pyx_XGIVEREF(__pyx_t_9);
      __Pyx_XGIVEREF(__pyx_t_10);
      __Pyx_XGIVEREF(__pyx_t_11);
      __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
      goto __pyx_L6_continue;
      __pyx_L15_try_end:;
    }
    __pyx_L6_continue:;
  }
  __pyx_L7_break:;
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":4291
 *             logger.error("Error in deleting old data and screenshots: %s", e, exc_info=True)
 * 
 *     async def start_status_activity(self, user_entity: UserEntity, stop_event):             # <<<<<<<<<<<<<<
 *         if user_entity is None:
 *             logger.error("start_status_activity called with None user_entity, cannot proceed")
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_39);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("start_status_activity", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":4396
 *                 continue
 * 
 *     def set_local_timezone(self, user_entity):             # <<<<<<<<<<<<<<
 *         """Set local_timezone from user_entity, fallback to system timezone if not available."""
 *         self.timezone_manager.set_local_timezone(user_entity)
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_156set_local_timezone(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_155set_local_timezone, "Set local_timezone from user_entity, fallback to system timezone if not available.");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_156set_local_timezone = {"set_local_timezone", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_156set_local_timezone, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_155set_local_timezone};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_156set_local_timezone(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_user_entity = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("set_local_timezone (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_user_entity,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 4396, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 4396, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4396, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "set_local_timezone", 0) < (0)) __PYX_ERR(0, 4396, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("set_local_timezone", 1, 2, 2, i); __PYX_ERR(0, 4396, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4396, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 4396, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_user_entity = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("set_local_timezone", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 4396, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.set_local_timezone", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_155set_local_timezone(__pyx_self, __pyx_v_self, __pyx_v_user_entity);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_155set_local_timezone(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  size_t __pyx_t_4;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("set_local_timezone", 0);

  /* "ws_package/controllers/activity_controller.py":4398
 *     def set_local_timezone(self, user_entity):
 *         """Set local_timezone from user_entity, fallback to system timezone if not available."""
 *         self.timezone_manager.set_local_timezone(user_entity)             # <<<<<<<<<<<<<<
 * 
 *     async def db_to_server(self, user_entity: UserEntity):
*/
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_timezone_manager); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4398, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __pyx_t_3;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_4 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_v_user_entity};
    __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_set_local_timezone, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4398, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":4396
 *                 continue
 * 
 *     def set_local_timezone(self, user_entity):             # <<<<<<<<<<<<<<
 *         """Set local_timezone from user_entity, fallback to system timezone if not available."""
 *         self.timezone_manager.set_local_timezone(user_entity)
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.set_local_timezone", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_159generator31(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":4400
 *         self.timezone_manager.set_local_timezone(user_entity)
 * 
 *     async def db_to_server(self, user_entity: UserEntity):             # <<<<<<<<<<<<<<
 *         logger.info("Running db to server")
 *         if getattr(sys, 'frozen', False) and platform.system() == "Linux":
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_158db_to_server(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_158db_to_server = {"db_to_server", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_158db_to_server, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_158db_to_server(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_user_entity = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("db_to_server (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_user_entity,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 4400, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 4400, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4400, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "db_to_server", 0) < (0)) __PYX_ERR(0, 4400, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("db_to_server", 1, 2, 2, i); __PYX_ERR(0, 4400, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4400, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 4400, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_user_entity = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("db_to_server", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 4400, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.db_to_server", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_157db_to_server(__pyx_self, __pyx_v_self, __pyx_v_user_entity);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_157db_to_server(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("db_to_server", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 4400, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_user_entity = __pyx_v_user_entity;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_user_entity);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_user_entity);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_159generator31, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[51]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_db_to_server, __pyx_mstate_global->__pyx_n_u_ActivityController_db_to_server, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 4400, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.db_to_server", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_159generator31(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  int __pyx_t_6;
  int __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11[7];
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  __Pyx_PySendResult __pyx_t_19;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  int __pyx_t_26;
  int __pyx_t_27;
  char const *__pyx_t_28;
  PyObject *__pyx_t_29 = NULL;
  PyObject *__pyx_t_30 = NULL;
  PyObject *__pyx_t_31 = NULL;
  char const *__pyx_t_32;
  char const *__pyx_t_33;
  char const *__pyx_t_34;
  char const *__pyx_t_35;
  char const *__pyx_t_36;
  char const *__pyx_t_37;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("db_to_server", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L28_resume_from_await;
    case 2: goto __pyx_L84_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 4400, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":4401
 * 
 *     async def db_to_server(self, user_entity: UserEntity):
 *         logger.info("Running db to server")             # <<<<<<<<<<<<<<
 *         if getattr(sys, 'frozen', False) and platform.system() == "Linux":
 *             script_path = Path(sys.executable).resolve()
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4401, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4401, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Running_db_to_server};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4401, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":4402
 *     async def db_to_server(self, user_entity: UserEntity):
 *         logger.info("Running db to server")
 *         if getattr(sys, 'frozen', False) and platform.system() == "Linux":             # <<<<<<<<<<<<<<
 *             script_path = Path(sys.executable).resolve()
 *             target_directory = script_path.parents[0]
*/
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_sys); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_GetAttr3(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_frozen, Py_False); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 4402, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_7) {
  } else {
    __pyx_t_6 = __pyx_t_7;
    goto __pyx_L5_bool_binop_done;
  }
  __pyx_t_1 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_system); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4402, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
    assert(__pyx_t_1);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
    __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4402, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  }
  __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_Linux, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 4402, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_6 = __pyx_t_7;
  __pyx_L5_bool_binop_done:;
  if (__pyx_t_6) {

    /* "ws_package/controllers/activity_controller.py":4403
 *         logger.info("Running db to server")
 *         if getattr(sys, 'frozen', False) and platform.system() == "Linux":
 *             script_path = Path(sys.executable).resolve()             # <<<<<<<<<<<<<<
 *             target_directory = script_path.parents[0]
 *             database_dir = target_directory / "ws_monitor.db"
*/
    __pyx_t_2 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_Path); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4403, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_sys); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4403, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_executable); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4403, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_8))) {
      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_8);
      assert(__pyx_t_2);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_10};
      __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4403, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __pyx_t_3 = __pyx_t_1;
    __Pyx_INCREF(__pyx_t_3);
    __pyx_t_5 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
      __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_resolve, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4403, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_cur_scope->__pyx_v_script_path = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "ws_package/controllers/activity_controller.py":4404
 *         if getattr(sys, 'frozen', False) and platform.system() == "Linux":
 *             script_path = Path(sys.executable).resolve()
 *             target_directory = script_path.parents[0]             # <<<<<<<<<<<<<<
 *             database_dir = target_directory / "ws_monitor.db"
 *         elif getattr(sys, 'frozen', False) and platform.system() == "Windows":
*/
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_script_path, __pyx_mstate_global->__pyx_n_u_parents); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4404, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4404, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_v_target_directory = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "ws_package/controllers/activity_controller.py":4405
 *             script_path = Path(sys.executable).resolve()
 *             target_directory = script_path.parents[0]
 *             database_dir = target_directory / "ws_monitor.db"             # <<<<<<<<<<<<<<
 *         elif getattr(sys, 'frozen', False) and platform.system() == "Windows":
 *             script_path = Path(sys.executable).resolve()
*/
    __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_cur_scope->__pyx_v_target_directory, __pyx_mstate_global->__pyx_kp_u_ws_monitor_db); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4405, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_v_database_dir = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "ws_package/controllers/activity_controller.py":4402
 *     async def db_to_server(self, user_entity: UserEntity):
 *         logger.info("Running db to server")
 *         if getattr(sys, 'frozen', False) and platform.system() == "Linux":             # <<<<<<<<<<<<<<
 *             script_path = Path(sys.executable).resolve()
 *             target_directory = script_path.parents[0]
*/
    goto __pyx_L4;
  }

  /* "ws_package/controllers/activity_controller.py":4406
 *             target_directory = script_path.parents[0]
 *             database_dir = target_directory / "ws_monitor.db"
 *         elif getattr(sys, 'frozen', False) and platform.system() == "Windows":             # <<<<<<<<<<<<<<
 *             script_path = Path(sys.executable).resolve()
 *             target_directory = script_path.parents[0]
*/
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_sys); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_GetAttr3(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_frozen, Py_False); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 4406, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_7) {
  } else {
    __pyx_t_6 = __pyx_t_7;
    goto __pyx_L7_bool_binop_done;
  }
  __pyx_t_1 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_system); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_8))) {
    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_8);
    assert(__pyx_t_1);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
    __Pyx_INCREF(__pyx_t_1);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
    __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4406, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  }
  __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_Windows, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 4406, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_6 = __pyx_t_7;
  __pyx_L7_bool_binop_done:;
  if (__pyx_t_6) {

    /* "ws_package/controllers/activity_controller.py":4407
 *             database_dir = target_directory / "ws_monitor.db"
 *         elif getattr(sys, 'frozen', False) and platform.system() == "Windows":
 *             script_path = Path(sys.executable).resolve()             # <<<<<<<<<<<<<<
 *             target_directory = script_path.parents[0]
 *             database_dir = target_directory / "ws_monitor.db"
*/
    __pyx_t_3 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_Path); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4407, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_sys); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4407, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_executable); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4407, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_9);
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10);
      assert(__pyx_t_3);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_3);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_9};
      __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4407, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __pyx_t_8 = __pyx_t_1;
    __Pyx_INCREF(__pyx_t_8);
    __pyx_t_5 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
      __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_resolve, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4407, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
    }
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_cur_scope->__pyx_v_script_path = __pyx_t_4;
    __pyx_t_4 = 0;

    /* "ws_package/controllers/activity_controller.py":4408
 *         elif getattr(sys, 'frozen', False) and platform.system() == "Windows":
 *             script_path = Path(sys.executable).resolve()
 *             target_directory = script_path.parents[0]             # <<<<<<<<<<<<<<
 *             database_dir = target_directory / "ws_monitor.db"
 *         elif getattr(sys, 'frozen', False) and sys.platform == "darwin":
*/
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_script_path, __pyx_mstate_global->__pyx_n_u_parents); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4408, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_OwnStrongReference); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4408, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_v_target_directory = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "ws_package/controllers/activity_controller.py":4409
 *             script_path = Path(sys.executable).resolve()
 *             target_directory = script_path.parents[0]
 *             database_dir = target_directory / "ws_monitor.db"             # <<<<<<<<<<<<<<
 *         elif getattr(sys, 'frozen', False) and sys.platform == "darwin":
 *             database_dir = Path.home() / "Library/Application Support/Workstatus/ws_monitor.db"
*/
    __pyx_t_1 = __Pyx_PyNumber_Divide(__pyx_cur_scope->__pyx_v_target_directory, __pyx_mstate_global->__pyx_kp_u_ws_monitor_db); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4409, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __Pyx_GIVEREF(__pyx_t_1);
    __pyx_cur_scope->__pyx_v_database_dir = __pyx_t_1;
    __pyx_t_1 = 0;

    /* "ws_package/controllers/activity_controller.py":4406
 *             target_directory = script_path.parents[0]
 *             database_dir = target_directory / "ws_monitor.db"
 *         elif getattr(sys, 'frozen', False) and platform.system() == "Windows":             # <<<<<<<<<<<<<<
 *             script_path = Path(sys.executable).resolve()
 *             target_directory = script_path.parents[0]
*/
    goto __pyx_L4;
  }

  /* "ws_package/controllers/activity_controller.py":4410
 *             target_directory = script_path.parents[0]
 *             database_dir = target_directory / "ws_monitor.db"
 *         elif getattr(sys, 'frozen', False) and sys.platform == "darwin":             # <<<<<<<<<<<<<<
 *             database_dir = Path.home() / "Library/Application Support/Workstatus/ws_monitor.db"
 *         else:
*/
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_sys); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4410, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_GetAttr3(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_frozen, Py_False); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4410, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 4410, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__pyx_t_7) {
  } else {
    __pyx_t_6 = __pyx_t_7;
    goto __pyx_L9_bool_binop_done;
  }
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_sys); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4410, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4410, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_darwin, Py_EQ)); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 4410, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_6 = __pyx_t_7;
  __pyx_L9_bool_binop_done:;
  if (__pyx_t_6) {

    /* "ws_package/controllers/activity_controller.py":4411
 *             database_dir = target_directory / "ws_monitor.db"
 *         elif getattr(sys, 'frozen', False) and sys.platform == "darwin":
 *             database_dir = Path.home() / "Library/Application Support/Workstatus/ws_monitor.db"             # <<<<<<<<<<<<<<
 *         else:
 *             return
*/
    __pyx_t_4 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_Path); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4411, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_home); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4411, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10);
      assert(__pyx_t_4);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
      __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4411, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_1);
    }
    __pyx_t_10 = __Pyx_PyNumber_Divide(__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Library_Application_Support_Work_3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4411, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_GIVEREF(__pyx_t_10);
    __pyx_cur_scope->__pyx_v_database_dir = __pyx_t_10;
    __pyx_t_10 = 0;

    /* "ws_package/controllers/activity_controller.py":4410
 *             target_directory = script_path.parents[0]
 *             database_dir = target_directory / "ws_monitor.db"
 *         elif getattr(sys, 'frozen', False) and sys.platform == "darwin":             # <<<<<<<<<<<<<<
 *             database_dir = Path.home() / "Library/Application Support/Workstatus/ws_monitor.db"
 *         else:
*/
    goto __pyx_L4;
  }

  /* "ws_package/controllers/activity_controller.py":4413
 *             database_dir = Path.home() / "Library/Application Support/Workstatus/ws_monitor.db"
 *         else:
 *             return             # <<<<<<<<<<<<<<
 *         timestamp_db = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
 *         dt_obj = datetime.datetime.strptime(timestamp_db, "%Y-%m-%d_%H-%M-%S")
*/
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;
  }
  __pyx_L4:;

  /* "ws_package/controllers/activity_controller.py":4414
 *         else:
 *             return
 *         timestamp_db = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")             # <<<<<<<<<<<<<<
 *         dt_obj = datetime.datetime.strptime(timestamp_db, "%Y-%m-%d_%H-%M-%S")
 *         unix_timestamp = int(time.mktime(dt_obj.timetuple()))
*/
  __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __pyx_t_8 = __pyx_t_3;
  __Pyx_INCREF(__pyx_t_8);
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
    __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4414, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  }
  __pyx_t_1 = __pyx_t_4;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Y_m_d__H_M_S};
    __pyx_t_10 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strftime, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4414, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
  }
  __Pyx_GIVEREF(__pyx_t_10);
  __pyx_cur_scope->__pyx_v_timestamp_db = __pyx_t_10;
  __pyx_t_10 = 0;

  /* "ws_package/controllers/activity_controller.py":4415
 *             return
 *         timestamp_db = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
 *         dt_obj = datetime.datetime.strptime(timestamp_db, "%Y-%m-%d_%H-%M-%S")             # <<<<<<<<<<<<<<
 *         unix_timestamp = int(time.mktime(dt_obj.timetuple()))
 *         database_server = f"database/{user_entity.org_id}/{user_entity.user_id}/{unix_timestamp}.db"
*/
  __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4415, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_4 = __pyx_t_3;
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_timestamp_db, __pyx_mstate_global->__pyx_kp_u_Y_m_d__H_M_S};
    __pyx_t_10 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strptime, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4415, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
  }
  __Pyx_GIVEREF(__pyx_t_10);
  __pyx_cur_scope->__pyx_v_dt_obj = __pyx_t_10;
  __pyx_t_10 = 0;

  /* "ws_package/controllers/activity_controller.py":4416
 *         timestamp_db = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
 *         dt_obj = datetime.datetime.strptime(timestamp_db, "%Y-%m-%d_%H-%M-%S")
 *         unix_timestamp = int(time.mktime(dt_obj.timetuple()))             # <<<<<<<<<<<<<<
 *         database_server = f"database/{user_entity.org_id}/{user_entity.user_id}/{unix_timestamp}.db"
 * 
*/
  __pyx_t_3 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_time); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_mktime); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_8 = __pyx_cur_scope->__pyx_v_dt_obj;
  __Pyx_INCREF(__pyx_t_8);
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
    __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_timetuple, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4416, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  }
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_1))) {
    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
    assert(__pyx_t_3);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
    __Pyx_INCREF(__pyx_t_3);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_4};
    __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4416, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
  }
  __pyx_t_1 = __Pyx_PyNumber_Int(__pyx_t_10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4416, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_unix_timestamp = ((PyObject*)__pyx_t_1);
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":4417
 *         dt_obj = datetime.datetime.strptime(timestamp_db, "%Y-%m-%d_%H-%M-%S")
 *         unix_timestamp = int(time.mktime(dt_obj.timetuple()))
 *         database_server = f"database/{user_entity.org_id}/{user_entity.user_id}/{unix_timestamp}.db"             # <<<<<<<<<<<<<<
 * 
 *         if not database_dir.exists():
*/
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_org_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_10 = __Pyx_PyObject_FormatSimple(__pyx_t_1, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_10);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_user_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_4 = __Pyx_PyObject_FormatSimple(__pyx_t_1, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __pyx_t_1 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_unix_timestamp, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_11[0] = __pyx_mstate_global->__pyx_kp_u_database;
  __pyx_t_11[1] = __pyx_t_10;
  __pyx_t_11[2] = __pyx_mstate_global->__pyx_kp_u__9;
  __pyx_t_11[3] = __pyx_t_4;
  __pyx_t_11[4] = __pyx_mstate_global->__pyx_kp_u__9;
  __pyx_t_11[5] = __pyx_t_1;
  __pyx_t_11[6] = __pyx_mstate_global->__pyx_kp_u_db;
  __pyx_t_3 = __Pyx_PyUnicode_Join(__pyx_t_11, 7, 9 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_10) + 1 * 2 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_4) + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_1) + 3, 127 | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_10) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_4) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_1));
  if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4417, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_database_server = ((PyObject*)__pyx_t_3);
  __pyx_t_3 = 0;

  /* "ws_package/controllers/activity_controller.py":4419
 *         database_server = f"database/{user_entity.org_id}/{user_entity.user_id}/{unix_timestamp}.db"
 * 
 *         if not database_dir.exists():             # <<<<<<<<<<<<<<
 *             logger.error("Database file not found for upload: %s", database_dir)
 *             return
*/
  __pyx_t_1 = __pyx_cur_scope->__pyx_v_database_dir;
  __Pyx_INCREF(__pyx_t_1);
  __pyx_t_5 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
    __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_exists, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4419, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  }
  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 4419, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_7 = (!__pyx_t_6);
  if (__pyx_t_7) {

    /* "ws_package/controllers/activity_controller.py":4420
 * 
 *         if not database_dir.exists():
 *             logger.error("Database file not found for upload: %s", database_dir)             # <<<<<<<<<<<<<<
 *             return
 * 
*/
    __pyx_t_1 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4420, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4420, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_10);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_10))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_10);
      assert(__pyx_t_1);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Database_file_not_found_for_uplo, __pyx_cur_scope->__pyx_v_database_dir};
      __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4420, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "ws_package/controllers/activity_controller.py":4421
 *         if not database_dir.exists():
 *             logger.error("Database file not found for upload: %s", database_dir)
 *             return             # <<<<<<<<<<<<<<
 * 
 *         try:
*/
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":4419
 *         database_server = f"database/{user_entity.org_id}/{user_entity.user_id}/{unix_timestamp}.db"
 * 
 *         if not database_dir.exists():             # <<<<<<<<<<<<<<
 *             logger.error("Database file not found for upload: %s", database_dir)
 *             return
*/
  }

  /* "ws_package/controllers/activity_controller.py":4423
 *             return
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             # Use safe file copy that coordinates with database locks
 *             temp_file = None
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
    __Pyx_XGOTREF(__pyx_t_12);
    __Pyx_XGOTREF(__pyx_t_13);
    __Pyx_XGOTREF(__pyx_t_14);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":4425
 *         try:
 *             # Use safe file copy that coordinates with database locks
 *             temp_file = None             # <<<<<<<<<<<<<<
 * 
 *             # Create copy under database write lock to ensure consistency
*/
      __Pyx_INCREF(Py_None);
      __Pyx_GIVEREF(Py_None);
      __pyx_cur_scope->__pyx_v_temp_file = Py_None;

      /* "ws_package/controllers/activity_controller.py":4428
 * 
 *             # Create copy under database write lock to ensure consistency
 *             with db_lock_manager.write_lock(timeout=60.0):             # <<<<<<<<<<<<<<
 *                 # Wait for any pending transactions
 *                 await asyncio.sleep(0.2)  # Allow any pending operations to complete
*/
      /*with:*/ {
        __pyx_t_10 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4428, __pyx_L12_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_write_lock); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4428, __pyx_L12_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_5 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
          assert(__pyx_t_10);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
          __pyx_t_5 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_10, NULL};
          __pyx_t_1 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4428, __pyx_L12_error)
          __Pyx_GOTREF(__pyx_t_1);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_timeout, __pyx_mstate_global->__pyx_float_60_0, __pyx_t_1, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 4428, __pyx_L12_error)
          __pyx_t_3 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_1);
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4428, __pyx_L12_error)
          __Pyx_GOTREF(__pyx_t_3);
        }
        __pyx_t_15 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4428, __pyx_L12_error)
        __Pyx_GOTREF(__pyx_t_15);
        __pyx_t_1 = NULL;
        __pyx_t_10 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4428, __pyx_L18_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_5 = 1;
        #if CYTHON_UNPACK_METHODS
        if (likely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_10);
          assert(__pyx_t_1);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
          __pyx_t_5 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4428, __pyx_L18_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        /*try:*/ {
          {
            __Pyx_ExceptionSave(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
            __Pyx_XGOTREF(__pyx_t_16);
            __Pyx_XGOTREF(__pyx_t_17);
            __Pyx_XGOTREF(__pyx_t_18);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":4430
 *             with db_lock_manager.write_lock(timeout=60.0):
 *                 # Wait for any pending transactions
 *                 await asyncio.sleep(0.2)  # Allow any pending operations to complete             # <<<<<<<<<<<<<<
 * 
 *                 # Create temporary copy safely
*/
              __pyx_t_4 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4430, __pyx_L22_error)
              __Pyx_GOTREF(__pyx_t_10);
              __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4430, __pyx_L22_error)
              __Pyx_GOTREF(__pyx_t_1);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              __pyx_t_5 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_1))) {
                __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
                assert(__pyx_t_4);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
                __Pyx_INCREF(__pyx_t_4);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
                __pyx_t_5 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_float_0_2};
                __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4430, __pyx_L22_error)
                __Pyx_GOTREF(__pyx_t_3);
              }
              __pyx_t_19 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_3, &__pyx_r);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              if (likely(__pyx_t_19 == PYGEN_NEXT)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_XGIVEREF(__pyx_t_12);
                __pyx_cur_scope->__pyx_t_0 = __pyx_t_12;
                __Pyx_XGIVEREF(__pyx_t_13);
                __pyx_cur_scope->__pyx_t_1 = __pyx_t_13;
                __Pyx_XGIVEREF(__pyx_t_14);
                __pyx_cur_scope->__pyx_t_2 = __pyx_t_14;
                __Pyx_XGIVEREF(__pyx_t_15);
                __pyx_cur_scope->__pyx_t_3 = __pyx_t_15;
                __Pyx_XGIVEREF(__pyx_t_16);
                __pyx_cur_scope->__pyx_t_4 = __pyx_t_16;
                __Pyx_XGIVEREF(__pyx_t_17);
                __pyx_cur_scope->__pyx_t_5 = __pyx_t_17;
                __Pyx_XGIVEREF(__pyx_t_18);
                __pyx_cur_scope->__pyx_t_6 = __pyx_t_18;
                __Pyx_XGIVEREF(__pyx_r);
                __Pyx_RefNannyFinishContext();
                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                /* return from generator, awaiting value */
                __pyx_generator->resume_label = 1;
                return __pyx_r;
                __pyx_L28_resume_from_await:;
                __pyx_t_12 = __pyx_cur_scope->__pyx_t_0;
                __pyx_cur_scope->__pyx_t_0 = 0;
                __Pyx_XGOTREF(__pyx_t_12);
                __pyx_t_13 = __pyx_cur_scope->__pyx_t_1;
                __pyx_cur_scope->__pyx_t_1 = 0;
                __Pyx_XGOTREF(__pyx_t_13);
                __pyx_t_14 = __pyx_cur_scope->__pyx_t_2;
                __pyx_cur_scope->__pyx_t_2 = 0;
                __Pyx_XGOTREF(__pyx_t_14);
                __pyx_t_15 = __pyx_cur_scope->__pyx_t_3;
                __pyx_cur_scope->__pyx_t_3 = 0;
                __Pyx_XGOTREF(__pyx_t_15);
                __pyx_t_16 = __pyx_cur_scope->__pyx_t_4;
                __pyx_cur_scope->__pyx_t_4 = 0;
                __Pyx_XGOTREF(__pyx_t_16);
                __pyx_t_17 = __pyx_cur_scope->__pyx_t_5;
                __pyx_cur_scope->__pyx_t_5 = 0;
                __Pyx_XGOTREF(__pyx_t_17);
                __pyx_t_18 = __pyx_cur_scope->__pyx_t_6;
                __pyx_cur_scope->__pyx_t_6 = 0;
                __Pyx_XGOTREF(__pyx_t_18);
                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4430, __pyx_L22_error)
              } else if (likely(__pyx_t_19 == PYGEN_RETURN)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_DECREF(__pyx_r); __pyx_r = 0;
              } else {
                __Pyx_XGOTREF(__pyx_r);
                __PYX_ERR(0, 4430, __pyx_L22_error)
              }

              /* "ws_package/controllers/activity_controller.py":4433
 * 
 *                 # Create temporary copy safely
 *                 temp_file = None             # <<<<<<<<<<<<<<
 *                 temp_file_path = None
 *                 try:
*/
              __Pyx_INCREF(Py_None);
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_temp_file);
              __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_temp_file, Py_None);
              __Pyx_GIVEREF(Py_None);

              /* "ws_package/controllers/activity_controller.py":4434
 *                 # Create temporary copy safely
 *                 temp_file = None
 *                 temp_file_path = None             # <<<<<<<<<<<<<<
 *                 try:
 *                     temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.db')
*/
              __Pyx_INCREF(Py_None);
              __Pyx_GIVEREF(Py_None);
              __pyx_cur_scope->__pyx_v_temp_file_path = Py_None;

              /* "ws_package/controllers/activity_controller.py":4435
 *                 temp_file = None
 *                 temp_file_path = None
 *                 try:             # <<<<<<<<<<<<<<
 *                     temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.db')
 *                     temp_file_path = temp_file.name
*/
              {
                __Pyx_ExceptionSave(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
                __Pyx_XGOTREF(__pyx_t_20);
                __Pyx_XGOTREF(__pyx_t_21);
                __Pyx_XGOTREF(__pyx_t_22);
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":4436
 *                 temp_file_path = None
 *                 try:
 *                     temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.db')             # <<<<<<<<<<<<<<
 *                     temp_file_path = temp_file.name
 *                     temp_file.close()
*/
                  __pyx_t_1 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_tempfile); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4436, __pyx_L29_error)
                  __Pyx_GOTREF(__pyx_t_4);
                  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_NamedTemporaryFile); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4436, __pyx_L29_error)
                  __Pyx_GOTREF(__pyx_t_10);
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __pyx_t_5 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_10))) {
                    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_10);
                    assert(__pyx_t_1);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
                    __Pyx_INCREF(__pyx_t_1);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
                    __pyx_t_5 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 2 : 0)] = {__pyx_t_1, NULL};
                    __pyx_t_4 = __Pyx_MakeVectorcallBuilderKwds(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4436, __pyx_L29_error)
                    __Pyx_GOTREF(__pyx_t_4);
                    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_delete, Py_False, __pyx_t_4, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 4436, __pyx_L29_error)
                    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_suffix, __pyx_mstate_global->__pyx_kp_u_db, __pyx_t_4, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 4436, __pyx_L29_error)
                    __pyx_t_3 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_4);
                    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4436, __pyx_L29_error)
                    __Pyx_GOTREF(__pyx_t_3);
                  }
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_temp_file);
                  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_temp_file, __pyx_t_3);
                  __Pyx_GIVEREF(__pyx_t_3);
                  __pyx_t_3 = 0;

                  /* "ws_package/controllers/activity_controller.py":4437
 *                 try:
 *                     temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.db')
 *                     temp_file_path = temp_file.name             # <<<<<<<<<<<<<<
 *                     temp_file.close()
 * 
*/
                  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_temp_file, __pyx_mstate_global->__pyx_n_u_name); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4437, __pyx_L29_error)
                  __Pyx_GOTREF(__pyx_t_3);
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_temp_file_path);
                  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_temp_file_path, __pyx_t_3);
                  __Pyx_GIVEREF(__pyx_t_3);
                  __pyx_t_3 = 0;

                  /* "ws_package/controllers/activity_controller.py":4438
 *                     temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.db')
 *                     temp_file_path = temp_file.name
 *                     temp_file.close()             # <<<<<<<<<<<<<<
 * 
 *                     logger.info("Creating safe database copy for upload: %s", temp_file_path)
*/
                  __pyx_t_10 = __pyx_cur_scope->__pyx_v_temp_file;
                  __Pyx_INCREF(__pyx_t_10);
                  __pyx_t_5 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_10, NULL};
                    __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_close, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4438, __pyx_L29_error)
                    __Pyx_GOTREF(__pyx_t_3);
                  }
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                  /* "ws_package/controllers/activity_controller.py":4440
 *                     temp_file.close()
 * 
 *                     logger.info("Creating safe database copy for upload: %s", temp_file_path)             # <<<<<<<<<<<<<<
 *                     shutil.copy2(str(database_dir), temp_file_path)
 * 
*/
                  __pyx_t_10 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4440, __pyx_L29_error)
                  __Pyx_GOTREF(__pyx_t_4);
                  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4440, __pyx_L29_error)
                  __Pyx_GOTREF(__pyx_t_1);
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __pyx_t_5 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_1))) {
                    __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_1);
                    assert(__pyx_t_10);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
                    __Pyx_INCREF(__pyx_t_10);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
                    __pyx_t_5 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[3] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Creating_safe_database_copy_for, __pyx_cur_scope->__pyx_v_temp_file_path};
                    __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4440, __pyx_L29_error)
                    __Pyx_GOTREF(__pyx_t_3);
                  }
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                  /* "ws_package/controllers/activity_controller.py":4441
 * 
 *                     logger.info("Creating safe database copy for upload: %s", temp_file_path)
 *                     shutil.copy2(str(database_dir), temp_file_path)             # <<<<<<<<<<<<<<
 * 
 *                     # Verify copy integrity
*/
                  __pyx_t_1 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_shutil); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4441, __pyx_L29_error)
                  __Pyx_GOTREF(__pyx_t_10);
                  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_copy2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4441, __pyx_L29_error)
                  __Pyx_GOTREF(__pyx_t_4);
                  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                  __pyx_t_10 = __Pyx_PyObject_Unicode(__pyx_cur_scope->__pyx_v_database_dir); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4441, __pyx_L29_error)
                  __Pyx_GOTREF(__pyx_t_10);
                  __pyx_t_5 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_4))) {
                    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
                    assert(__pyx_t_1);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                    __Pyx_INCREF(__pyx_t_1);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                    __pyx_t_5 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_t_10, __pyx_cur_scope->__pyx_v_temp_file_path};
                    __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4441, __pyx_L29_error)
                    __Pyx_GOTREF(__pyx_t_3);
                  }
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                  /* "ws_package/controllers/activity_controller.py":4444
 * 
 *                     # Verify copy integrity
 *                     original_size = database_dir.stat().st_size             # <<<<<<<<<<<<<<
 *                     copy_size = Path(temp_file_path).stat().st_size
 * 
*/
                  __pyx_t_4 = __pyx_cur_scope->__pyx_v_database_dir;
                  __Pyx_INCREF(__pyx_t_4);
                  __pyx_t_5 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
                    __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_stat, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4444, __pyx_L29_error)
                    __Pyx_GOTREF(__pyx_t_3);
                  }
                  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_st_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4444, __pyx_L29_error)
                  __Pyx_GOTREF(__pyx_t_4);
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_GIVEREF(__pyx_t_4);
                  __pyx_cur_scope->__pyx_v_original_size = __pyx_t_4;
                  __pyx_t_4 = 0;

                  /* "ws_package/controllers/activity_controller.py":4445
 *                     # Verify copy integrity
 *                     original_size = database_dir.stat().st_size
 *                     copy_size = Path(temp_file_path).stat().st_size             # <<<<<<<<<<<<<<
 * 
 *                     if original_size != copy_size:
*/
                  __pyx_t_1 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_Path); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4445, __pyx_L29_error)
                  __Pyx_GOTREF(__pyx_t_8);
                  __pyx_t_5 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_8))) {
                    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_8);
                    assert(__pyx_t_1);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
                    __Pyx_INCREF(__pyx_t_1);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
                    __pyx_t_5 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_cur_scope->__pyx_v_temp_file_path};
                    __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                    if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4445, __pyx_L29_error)
                    __Pyx_GOTREF(__pyx_t_10);
                  }
                  __pyx_t_3 = __pyx_t_10;
                  __Pyx_INCREF(__pyx_t_3);
                  __pyx_t_5 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
                    __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_stat, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4445, __pyx_L29_error)
                    __Pyx_GOTREF(__pyx_t_4);
                  }
                  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_st_size); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4445, __pyx_L29_error)
                  __Pyx_GOTREF(__pyx_t_10);
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_GIVEREF(__pyx_t_10);
                  __pyx_cur_scope->__pyx_v_copy_size = __pyx_t_10;
                  __pyx_t_10 = 0;

                  /* "ws_package/controllers/activity_controller.py":4447
 *                     copy_size = Path(temp_file_path).stat().st_size
 * 
 *                     if original_size != copy_size:             # <<<<<<<<<<<<<<
 *                         logger.error("Database copy size mismatch: %s vs %s", original_size, copy_size)
 *                         if temp_file_path and os.path.exists(temp_file_path):
*/
                  __pyx_t_10 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_original_size, __pyx_cur_scope->__pyx_v_copy_size, Py_NE); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4447, __pyx_L29_error)
                  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 4447, __pyx_L29_error)
                  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                  if (__pyx_t_7) {

                    /* "ws_package/controllers/activity_controller.py":4448
 * 
 *                     if original_size != copy_size:
 *                         logger.error("Database copy size mismatch: %s vs %s", original_size, copy_size)             # <<<<<<<<<<<<<<
 *                         if temp_file_path and os.path.exists(temp_file_path):
 *                             try:
*/
                    __pyx_t_4 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4448, __pyx_L29_error)
                    __Pyx_GOTREF(__pyx_t_3);
                    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4448, __pyx_L29_error)
                    __Pyx_GOTREF(__pyx_t_8);
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __pyx_t_5 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_8))) {
                      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8);
                      assert(__pyx_t_4);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
                      __Pyx_INCREF(__pyx_t_4);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
                      __pyx_t_5 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[4] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Database_copy_size_mismatch_s_vs, __pyx_cur_scope->__pyx_v_original_size, __pyx_cur_scope->__pyx_v_copy_size};
                      __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_5, (4-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                      if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4448, __pyx_L29_error)
                      __Pyx_GOTREF(__pyx_t_10);
                    }
                    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

                    /* "ws_package/controllers/activity_controller.py":4449
 *                     if original_size != copy_size:
 *                         logger.error("Database copy size mismatch: %s vs %s", original_size, copy_size)
 *                         if temp_file_path and os.path.exists(temp_file_path):             # <<<<<<<<<<<<<<
 *                             try:
 *                                 os.unlink(temp_file_path)
*/
                    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_temp_file_path); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 4449, __pyx_L29_error)
                    if (__pyx_t_6) {
                    } else {
                      __pyx_t_7 = __pyx_t_6;
                      goto __pyx_L37_bool_binop_done;
                    }
                    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_os); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4449, __pyx_L29_error)
                    __Pyx_GOTREF(__pyx_t_4);
                    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_path); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4449, __pyx_L29_error)
                    __Pyx_GOTREF(__pyx_t_3);
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __pyx_t_8 = __pyx_t_3;
                    __Pyx_INCREF(__pyx_t_8);
                    __pyx_t_5 = 0;
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_cur_scope->__pyx_v_temp_file_path};
                      __pyx_t_10 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_exists, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                      if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4449, __pyx_L29_error)
                      __Pyx_GOTREF(__pyx_t_10);
                    }
                    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 4449, __pyx_L29_error)
                    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                    __pyx_t_7 = __pyx_t_6;
                    __pyx_L37_bool_binop_done:;
                    if (__pyx_t_7) {

                      /* "ws_package/controllers/activity_controller.py":4450
 *                         logger.error("Database copy size mismatch: %s vs %s", original_size, copy_size)
 *                         if temp_file_path and os.path.exists(temp_file_path):
 *                             try:             # <<<<<<<<<<<<<<
 *                                 os.unlink(temp_file_path)
 *                             except Exception:
*/
                      {
                        __Pyx_ExceptionSave(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25);
                        __Pyx_XGOTREF(__pyx_t_23);
                        __Pyx_XGOTREF(__pyx_t_24);
                        __Pyx_XGOTREF(__pyx_t_25);
                        /*try:*/ {

                          /* "ws_package/controllers/activity_controller.py":4451
 *                         if temp_file_path and os.path.exists(temp_file_path):
 *                             try:
 *                                 os.unlink(temp_file_path)             # <<<<<<<<<<<<<<
 *                             except Exception:
 *                                 pass
*/
                          __pyx_t_3 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_os); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4451, __pyx_L39_error)
                          __Pyx_GOTREF(__pyx_t_8);
                          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_unlink); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4451, __pyx_L39_error)
                          __Pyx_GOTREF(__pyx_t_4);
                          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                          __pyx_t_5 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_4))) {
                            __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
                            assert(__pyx_t_3);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                            __Pyx_INCREF(__pyx_t_3);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                            __pyx_t_5 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_temp_file_path};
                            __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                            if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4451, __pyx_L39_error)
                            __Pyx_GOTREF(__pyx_t_10);
                          }
                          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

                          /* "ws_package/controllers/activity_controller.py":4450
 *                         logger.error("Database copy size mismatch: %s vs %s", original_size, copy_size)
 *                         if temp_file_path and os.path.exists(temp_file_path):
 *                             try:             # <<<<<<<<<<<<<<
 *                                 os.unlink(temp_file_path)
 *                             except Exception:
*/
                        }
                        __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                        goto __pyx_L44_try_end;
                        __pyx_L39_error:;
                        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

                        /* "ws_package/controllers/activity_controller.py":4452
 *                             try:
 *                                 os.unlink(temp_file_path)
 *                             except Exception:             # <<<<<<<<<<<<<<
 *                                 pass
 *                         return
*/
                        __pyx_t_26 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                        if (__pyx_t_26) {
                          __Pyx_ErrRestore(0,0,0);
                          goto __pyx_L40_exception_handled;
                        }
                        goto __pyx_L41_except_error;

                        /* "ws_package/controllers/activity_controller.py":4450
 *                         logger.error("Database copy size mismatch: %s vs %s", original_size, copy_size)
 *                         if temp_file_path and os.path.exists(temp_file_path):
 *                             try:             # <<<<<<<<<<<<<<
 *                                 os.unlink(temp_file_path)
 *                             except Exception:
*/
                        __pyx_L41_except_error:;
                        __Pyx_XGIVEREF(__pyx_t_23);
                        __Pyx_XGIVEREF(__pyx_t_24);
                        __Pyx_XGIVEREF(__pyx_t_25);
                        __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_24, __pyx_t_25);
                        goto __pyx_L29_error;
                        __pyx_L40_exception_handled:;
                        __Pyx_XGIVEREF(__pyx_t_23);
                        __Pyx_XGIVEREF(__pyx_t_24);
                        __Pyx_XGIVEREF(__pyx_t_25);
                        __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_24, __pyx_t_25);
                        __pyx_L44_try_end:;
                      }

                      /* "ws_package/controllers/activity_controller.py":4449
 *                     if original_size != copy_size:
 *                         logger.error("Database copy size mismatch: %s vs %s", original_size, copy_size)
 *                         if temp_file_path and os.path.exists(temp_file_path):             # <<<<<<<<<<<<<<
 *                             try:
 *                                 os.unlink(temp_file_path)
*/
                    }

                    /* "ws_package/controllers/activity_controller.py":4454
 *                             except Exception:
 *                                 pass
 *                         return             # <<<<<<<<<<<<<<
 * 
 *                 except Exception as copy_error:
*/
                    __Pyx_XDECREF(__pyx_r);
                    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
                    goto __pyx_L33_try_return;

                    /* "ws_package/controllers/activity_controller.py":4447
 *                     copy_size = Path(temp_file_path).stat().st_size
 * 
 *                     if original_size != copy_size:             # <<<<<<<<<<<<<<
 *                         logger.error("Database copy size mismatch: %s vs %s", original_size, copy_size)
 *                         if temp_file_path and os.path.exists(temp_file_path):
*/
                  }

                  /* "ws_package/controllers/activity_controller.py":4435
 *                 temp_file = None
 *                 temp_file_path = None
 *                 try:             # <<<<<<<<<<<<<<
 *                     temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.db')
 *                     temp_file_path = temp_file.name
*/
                }
                __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                goto __pyx_L34_try_end;
                __pyx_L29_error:;
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

                /* "ws_package/controllers/activity_controller.py":4456
 *                         return
 * 
 *                 except Exception as copy_error:             # <<<<<<<<<<<<<<
 *                     logger.error("Error creating database copy: %s", copy_error)
 *                     if temp_file_path and os.path.exists(temp_file_path):
*/
                __pyx_t_26 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                if (__pyx_t_26) {
                  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.db_to_server", __pyx_clineno, __pyx_lineno, __pyx_filename);
                  if (__Pyx_GetException(&__pyx_t_10, &__pyx_t_4, &__pyx_t_3) < 0) __PYX_ERR(0, 4456, __pyx_L31_except_error)
                  __Pyx_XGOTREF(__pyx_t_10);
                  __Pyx_XGOTREF(__pyx_t_4);
                  __Pyx_XGOTREF(__pyx_t_3);
                  __Pyx_INCREF(__pyx_t_4);
                  __Pyx_GIVEREF(__pyx_t_4);
                  __pyx_cur_scope->__pyx_v_copy_error = __pyx_t_4;
                  /*try:*/ {

                    /* "ws_package/controllers/activity_controller.py":4457
 * 
 *                 except Exception as copy_error:
 *                     logger.error("Error creating database copy: %s", copy_error)             # <<<<<<<<<<<<<<
 *                     if temp_file_path and os.path.exists(temp_file_path):
 *                         try:
*/
                    __pyx_t_1 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4457, __pyx_L52_error)
                    __Pyx_GOTREF(__pyx_t_9);
                    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4457, __pyx_L52_error)
                    __Pyx_GOTREF(__pyx_t_2);
                    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                    __pyx_t_5 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_2))) {
                      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
                      assert(__pyx_t_1);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
                      __Pyx_INCREF(__pyx_t_1);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
                      __pyx_t_5 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Error_creating_database_copy_s, __pyx_cur_scope->__pyx_v_copy_error};
                      __pyx_t_8 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                      if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4457, __pyx_L52_error)
                      __Pyx_GOTREF(__pyx_t_8);
                    }
                    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

                    /* "ws_package/controllers/activity_controller.py":4458
 *                 except Exception as copy_error:
 *                     logger.error("Error creating database copy: %s", copy_error)
 *                     if temp_file_path and os.path.exists(temp_file_path):             # <<<<<<<<<<<<<<
 *                         try:
 *                             os.unlink(temp_file_path)
*/
                    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_temp_file_path); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 4458, __pyx_L52_error)
                    if (__pyx_t_6) {
                    } else {
                      __pyx_t_7 = __pyx_t_6;
                      goto __pyx_L55_bool_binop_done;
                    }
                    __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_os); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4458, __pyx_L52_error)
                    __Pyx_GOTREF(__pyx_t_1);
                    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_path); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4458, __pyx_L52_error)
                    __Pyx_GOTREF(__pyx_t_9);
                    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __pyx_t_2 = __pyx_t_9;
                    __Pyx_INCREF(__pyx_t_2);
                    __pyx_t_5 = 0;
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_temp_file_path};
                      __pyx_t_8 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_exists, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                      if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4458, __pyx_L52_error)
                      __Pyx_GOTREF(__pyx_t_8);
                    }
                    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 4458, __pyx_L52_error)
                    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                    __pyx_t_7 = __pyx_t_6;
                    __pyx_L55_bool_binop_done:;
                    if (__pyx_t_7) {

                      /* "ws_package/controllers/activity_controller.py":4459
 *                     logger.error("Error creating database copy: %s", copy_error)
 *                     if temp_file_path and os.path.exists(temp_file_path):
 *                         try:             # <<<<<<<<<<<<<<
 *                             os.unlink(temp_file_path)
 *                         except Exception:
*/
                      {
                        __Pyx_ExceptionSave(&__pyx_t_25, &__pyx_t_24, &__pyx_t_23);
                        __Pyx_XGOTREF(__pyx_t_25);
                        __Pyx_XGOTREF(__pyx_t_24);
                        __Pyx_XGOTREF(__pyx_t_23);
                        /*try:*/ {

                          /* "ws_package/controllers/activity_controller.py":4460
 *                     if temp_file_path and os.path.exists(temp_file_path):
 *                         try:
 *                             os.unlink(temp_file_path)             # <<<<<<<<<<<<<<
 *                         except Exception:
 *                             pass
*/
                          __pyx_t_9 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4460, __pyx_L57_error)
                          __Pyx_GOTREF(__pyx_t_2);
                          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_unlink); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4460, __pyx_L57_error)
                          __Pyx_GOTREF(__pyx_t_1);
                          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                          __pyx_t_5 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_1))) {
                            __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
                            assert(__pyx_t_9);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
                            __Pyx_INCREF(__pyx_t_9);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
                            __pyx_t_5 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_cur_scope->__pyx_v_temp_file_path};
                            __pyx_t_8 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                            if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4460, __pyx_L57_error)
                            __Pyx_GOTREF(__pyx_t_8);
                          }
                          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

                          /* "ws_package/controllers/activity_controller.py":4459
 *                     logger.error("Error creating database copy: %s", copy_error)
 *                     if temp_file_path and os.path.exists(temp_file_path):
 *                         try:             # <<<<<<<<<<<<<<
 *                             os.unlink(temp_file_path)
 *                         except Exception:
*/
                        }
                        __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                        __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                        goto __pyx_L64_try_end;
                        __pyx_L57_error:;
                        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

                        /* "ws_package/controllers/activity_controller.py":4461
 *                         try:
 *                             os.unlink(temp_file_path)
 *                         except Exception:             # <<<<<<<<<<<<<<
 *                             pass
 *                     return
*/
                        __pyx_t_26 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                        if (__pyx_t_26) {
                          __Pyx_ErrRestore(0,0,0);
                          goto __pyx_L58_exception_handled;
                        }
                        goto __pyx_L59_except_error;

                        /* "ws_package/controllers/activity_controller.py":4459
 *                     logger.error("Error creating database copy: %s", copy_error)
 *                     if temp_file_path and os.path.exists(temp_file_path):
 *                         try:             # <<<<<<<<<<<<<<
 *                             os.unlink(temp_file_path)
 *                         except Exception:
*/
                        __pyx_L59_except_error:;
                        __Pyx_XGIVEREF(__pyx_t_25);
                        __Pyx_XGIVEREF(__pyx_t_24);
                        __Pyx_XGIVEREF(__pyx_t_23);
                        __Pyx_ExceptionReset(__pyx_t_25, __pyx_t_24, __pyx_t_23);
                        goto __pyx_L52_error;
                        __pyx_L58_exception_handled:;
                        __Pyx_XGIVEREF(__pyx_t_25);
                        __Pyx_XGIVEREF(__pyx_t_24);
                        __Pyx_XGIVEREF(__pyx_t_23);
                        __Pyx_ExceptionReset(__pyx_t_25, __pyx_t_24, __pyx_t_23);
                        __pyx_L64_try_end:;
                      }

                      /* "ws_package/controllers/activity_controller.py":4458
 *                 except Exception as copy_error:
 *                     logger.error("Error creating database copy: %s", copy_error)
 *                     if temp_file_path and os.path.exists(temp_file_path):             # <<<<<<<<<<<<<<
 *                         try:
 *                             os.unlink(temp_file_path)
*/
                    }

                    /* "ws_package/controllers/activity_controller.py":4463
 *                         except Exception:
 *                             pass
 *                     return             # <<<<<<<<<<<<<<
 * 
 *             # Upload the copy (outside the lock to avoid blocking database operations)
*/
                    __Pyx_XDECREF(__pyx_r);
                    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                    goto __pyx_L51_return;
                  }

                  /* "ws_package/controllers/activity_controller.py":4456
 *                         return
 * 
 *                 except Exception as copy_error:             # <<<<<<<<<<<<<<
 *                     logger.error("Error creating database copy: %s", copy_error)
 *                     if temp_file_path and os.path.exists(temp_file_path):
*/
                  /*finally:*/ {
                    __pyx_L52_error:;
                    /*exception exit:*/{
                      __Pyx_PyThreadState_assign
                      __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_29 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0;
                      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                       __Pyx_ExceptionSwap(&__pyx_t_29, &__pyx_t_30, &__pyx_t_31);
                      if ( unlikely(__Pyx_GetException(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25) < 0)) __Pyx_ErrFetch(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25);
                      __Pyx_XGOTREF(__pyx_t_23);
                      __Pyx_XGOTREF(__pyx_t_24);
                      __Pyx_XGOTREF(__pyx_t_25);
                      __Pyx_XGOTREF(__pyx_t_29);
                      __Pyx_XGOTREF(__pyx_t_30);
                      __Pyx_XGOTREF(__pyx_t_31);
                      __pyx_t_26 = __pyx_lineno; __pyx_t_27 = __pyx_clineno; __pyx_t_28 = __pyx_filename;
                      {
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_copy_error);
                        __Pyx_DECREF(__pyx_cur_scope->__pyx_v_copy_error); __pyx_cur_scope->__pyx_v_copy_error = 0;
                      }
                      __Pyx_XGIVEREF(__pyx_t_29);
                      __Pyx_XGIVEREF(__pyx_t_30);
                      __Pyx_XGIVEREF(__pyx_t_31);
                      __Pyx_ExceptionReset(__pyx_t_29, __pyx_t_30, __pyx_t_31);
                      __Pyx_XGIVEREF(__pyx_t_23);
                      __Pyx_XGIVEREF(__pyx_t_24);
                      __Pyx_XGIVEREF(__pyx_t_25);
                      __Pyx_ErrRestore(__pyx_t_23, __pyx_t_24, __pyx_t_25);
                      __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_29 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0;
                      __pyx_lineno = __pyx_t_26; __pyx_clineno = __pyx_t_27; __pyx_filename = __pyx_t_28;
                      goto __pyx_L31_except_error;
                    }
                    __pyx_L51_return: {
                      __pyx_t_31 = __pyx_r;
                      __pyx_r = 0;
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_copy_error);
                      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_copy_error); __pyx_cur_scope->__pyx_v_copy_error = 0;
                      __pyx_r = __pyx_t_31;
                      __pyx_t_31 = 0;
                      goto __pyx_L32_except_return;
                    }
                  }
                }
                goto __pyx_L31_except_error;

                /* "ws_package/controllers/activity_controller.py":4435
 *                 temp_file = None
 *                 temp_file_path = None
 *                 try:             # <<<<<<<<<<<<<<
 *                     temp_file = tempfile.NamedTemporaryFile(delete=False, suffix='.db')
 *                     temp_file_path = temp_file.name
*/
                __pyx_L31_except_error:;
                __Pyx_XGIVEREF(__pyx_t_20);
                __Pyx_XGIVEREF(__pyx_t_21);
                __Pyx_XGIVEREF(__pyx_t_22);
                __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22);
                goto __pyx_L22_error;
                __pyx_L33_try_return:;
                __Pyx_XGIVEREF(__pyx_t_20);
                __Pyx_XGIVEREF(__pyx_t_21);
                __Pyx_XGIVEREF(__pyx_t_22);
                __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22);
                goto __pyx_L26_try_return;
                __pyx_L32_except_return:;
                __Pyx_XGIVEREF(__pyx_t_20);
                __Pyx_XGIVEREF(__pyx_t_21);
                __Pyx_XGIVEREF(__pyx_t_22);
                __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22);
                goto __pyx_L26_try_return;
                __pyx_L34_try_end:;
              }

              /* "ws_package/controllers/activity_controller.py":4428
 * 
 *             # Create copy under database write lock to ensure consistency
 *             with db_lock_manager.write_lock(timeout=60.0):             # <<<<<<<<<<<<<<
 *                 # Wait for any pending transactions
 *                 await asyncio.sleep(0.2)  # Allow any pending operations to complete
*/
            }
            __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
            __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            goto __pyx_L27_try_end;
            __pyx_L22_error:;
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
            /*except:*/ {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.db_to_server", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_4, &__pyx_t_10) < 0) __PYX_ERR(0, 4428, __pyx_L24_except_error)
              __Pyx_XGOTREF(__pyx_t_3);
              __Pyx_XGOTREF(__pyx_t_4);
              __Pyx_XGOTREF(__pyx_t_10);
              __pyx_t_8 = PyTuple_Pack(3, __pyx_t_3, __pyx_t_4, __pyx_t_10); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4428, __pyx_L24_except_error)
              __Pyx_GOTREF(__pyx_t_8);
              __pyx_t_22 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_8, NULL);
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
              if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 4428, __pyx_L24_except_error)
              __Pyx_GOTREF(__pyx_t_22);
              __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_22);
              __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
              if (__pyx_t_7 < (0)) __PYX_ERR(0, 4428, __pyx_L24_except_error)
              __pyx_t_6 = (!__pyx_t_7);
              if (unlikely(__pyx_t_6)) {
                __Pyx_GIVEREF(__pyx_t_3);
                __Pyx_GIVEREF(__pyx_t_4);
                __Pyx_XGIVEREF(__pyx_t_10);
                __Pyx_ErrRestoreWithState(__pyx_t_3, __pyx_t_4, __pyx_t_10);
                __pyx_t_3 = 0;  __pyx_t_4 = 0;  __pyx_t_10 = 0; 
                __PYX_ERR(0, 4428, __pyx_L24_except_error)
              }
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
              goto __pyx_L23_exception_handled;
            }
            __pyx_L24_except_error:;
            __Pyx_XGIVEREF(__pyx_t_16);
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
            goto __pyx_L12_error;
            __pyx_L26_try_return:;
            __Pyx_XGIVEREF(__pyx_t_16);
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
            goto __pyx_L19_return;
            __pyx_L23_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_16);
            __Pyx_XGIVEREF(__pyx_t_17);
            __Pyx_XGIVEREF(__pyx_t_18);
            __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
            __pyx_L27_try_end:;
          }
        }
        /*finally:*/ {
          /*normal exit:*/{
            if (__pyx_t_15) {
              __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_mstate_global->__pyx_tuple[7], NULL);
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4428, __pyx_L12_error)
              __Pyx_GOTREF(__pyx_t_18);
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
            }
            goto __pyx_L21;
          }
          __pyx_L19_return: {
            __pyx_t_18 = __pyx_r;
            __pyx_r = 0;
            if (__pyx_t_15) {
              __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_mstate_global->__pyx_tuple[7], NULL);
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4428, __pyx_L12_error)
              __Pyx_GOTREF(__pyx_t_17);
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            }
            __pyx_r = __pyx_t_18;
            __pyx_t_18 = 0;
            goto __pyx_L16_try_return;
          }
          __pyx_L21:;
        }
        goto __pyx_L74;
        __pyx_L18_error:;
        __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
        goto __pyx_L12_error;
        __pyx_L74:;
      }

      /* "ws_package/controllers/activity_controller.py":4466
 * 
 *             # Upload the copy (outside the lock to avoid blocking database operations)
 *             if temp_file_path and os.path.exists(temp_file_path):             # <<<<<<<<<<<<<<
 *                 try:
 *                     result = await self.screenshot_controller.screenshot_service.sync(
*/
      if (unlikely(!__pyx_cur_scope->__pyx_v_temp_file_path)) { __Pyx_RaiseUnboundLocalError("temp_file_path"); __PYX_ERR(0, 4466, __pyx_L12_error) }
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_temp_file_path); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 4466, __pyx_L12_error)
      if (__pyx_t_7) {
      } else {
        __pyx_t_6 = __pyx_t_7;
        goto __pyx_L76_bool_binop_done;
      }
      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4466, __pyx_L12_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_path); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4466, __pyx_L12_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_4 = __pyx_t_8;
      __Pyx_INCREF(__pyx_t_4);
      if (unlikely(!__pyx_cur_scope->__pyx_v_temp_file_path)) { __Pyx_RaiseUnboundLocalError("temp_file_path"); __PYX_ERR(0, 4466, __pyx_L12_error) }
      __pyx_t_5 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_temp_file_path};
        __pyx_t_10 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_exists, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4466, __pyx_L12_error)
        __Pyx_GOTREF(__pyx_t_10);
      }
      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 4466, __pyx_L12_error)
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_6 = __pyx_t_7;
      __pyx_L76_bool_binop_done:;
      if (__pyx_t_6) {

        /* "ws_package/controllers/activity_controller.py":4467
 *             # Upload the copy (outside the lock to avoid blocking database operations)
 *             if temp_file_path and os.path.exists(temp_file_path):
 *                 try:             # <<<<<<<<<<<<<<
 *                     result = await self.screenshot_controller.screenshot_service.sync(
 *                         temp_file_path,
*/
        {
          __Pyx_ExceptionSave(&__pyx_t_15, &__pyx_t_18, &__pyx_t_17);
          __Pyx_XGOTREF(__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_18);
          __Pyx_XGOTREF(__pyx_t_17);
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":4468
 *             if temp_file_path and os.path.exists(temp_file_path):
 *                 try:
 *                     result = await self.screenshot_controller.screenshot_service.sync(             # <<<<<<<<<<<<<<
 *                         temp_file_path,
 *                         database_server,
*/
            __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4468, __pyx_L78_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_screenshot_service); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4468, __pyx_L78_error)
            __Pyx_GOTREF(__pyx_t_3);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __pyx_t_8 = __pyx_t_3;
            __Pyx_INCREF(__pyx_t_8);

            /* "ws_package/controllers/activity_controller.py":4469
 *                 try:
 *                     result = await self.screenshot_controller.screenshot_service.sync(
 *                         temp_file_path,             # <<<<<<<<<<<<<<
 *                         database_server,
 *                         user_entity
*/
            if (unlikely(!__pyx_cur_scope->__pyx_v_temp_file_path)) { __Pyx_RaiseUnboundLocalError("temp_file_path"); __PYX_ERR(0, 4469, __pyx_L78_error) }

            /* "ws_package/controllers/activity_controller.py":4471
 *                         temp_file_path,
 *                         database_server,
 *                         user_entity             # <<<<<<<<<<<<<<
 *                     )
 * 
*/
            __pyx_t_5 = 0;
            {
              PyObject *__pyx_callargs[4] = {__pyx_t_8, __pyx_cur_scope->__pyx_v_temp_file_path, __pyx_cur_scope->__pyx_v_database_server, __pyx_cur_scope->__pyx_v_user_entity};
              __pyx_t_10 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_sync, __pyx_callargs+__pyx_t_5, (4-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4468, __pyx_L78_error)
              __Pyx_GOTREF(__pyx_t_10);
            }
            __pyx_t_19 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_10, &__pyx_r);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            if (likely(__pyx_t_19 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_12);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_12;
              __Pyx_XGIVEREF(__pyx_t_13);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_13;
              __Pyx_XGIVEREF(__pyx_t_14);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_14;
              __Pyx_XGIVEREF(__pyx_t_15);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_15;
              __Pyx_XGIVEREF(__pyx_t_17);
              __pyx_cur_scope->__pyx_t_4 = __pyx_t_17;
              __Pyx_XGIVEREF(__pyx_t_18);
              __pyx_cur_scope->__pyx_t_5 = __pyx_t_18;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 2;
              return __pyx_r;
              __pyx_L84_resume_from_await:;
              __pyx_t_12 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_12);
              __pyx_t_13 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_13);
              __pyx_t_14 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_14);
              __pyx_t_15 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_15);
              __pyx_t_17 = __pyx_cur_scope->__pyx_t_4;
              __pyx_cur_scope->__pyx_t_4 = 0;
              __Pyx_XGOTREF(__pyx_t_17);
              __pyx_t_18 = __pyx_cur_scope->__pyx_t_5;
              __pyx_cur_scope->__pyx_t_5 = 0;
              __Pyx_XGOTREF(__pyx_t_18);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4468, __pyx_L78_error)
              __pyx_t_10 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_10);
            } else if (likely(__pyx_t_19 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __pyx_t_10 = __pyx_r; __pyx_r = NULL;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 4468, __pyx_L78_error)
            }
            __Pyx_GIVEREF(__pyx_t_10);
            __pyx_cur_scope->__pyx_v_result = __pyx_t_10;
            __pyx_t_10 = 0;

            /* "ws_package/controllers/activity_controller.py":4475
 * 
 *                     # Clean up temp file after upload
 *                     try:             # <<<<<<<<<<<<<<
 *                         os.unlink(temp_file_path)
 *                         logger.debug("Cleaned up temporary database copy: %s", temp_file_path)
*/
            {
              __Pyx_ExceptionSave(&__pyx_t_16, &__pyx_t_22, &__pyx_t_21);
              __Pyx_XGOTREF(__pyx_t_16);
              __Pyx_XGOTREF(__pyx_t_22);
              __Pyx_XGOTREF(__pyx_t_21);
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":4476
 *                     # Clean up temp file after upload
 *                     try:
 *                         os.unlink(temp_file_path)             # <<<<<<<<<<<<<<
 *                         logger.debug("Cleaned up temporary database copy: %s", temp_file_path)
 *                     except Exception as e:
*/
                __pyx_t_3 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_os); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4476, __pyx_L85_error)
                __Pyx_GOTREF(__pyx_t_8);
                __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_unlink); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4476, __pyx_L85_error)
                __Pyx_GOTREF(__pyx_t_4);
                __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                if (unlikely(!__pyx_cur_scope->__pyx_v_temp_file_path)) { __Pyx_RaiseUnboundLocalError("temp_file_path"); __PYX_ERR(0, 4476, __pyx_L85_error) }
                __pyx_t_5 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_4))) {
                  __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
                  assert(__pyx_t_3);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                  __Pyx_INCREF(__pyx_t_3);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                  __pyx_t_5 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_temp_file_path};
                  __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4476, __pyx_L85_error)
                  __Pyx_GOTREF(__pyx_t_10);
                }
                __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

                /* "ws_package/controllers/activity_controller.py":4477
 *                     try:
 *                         os.unlink(temp_file_path)
 *                         logger.debug("Cleaned up temporary database copy: %s", temp_file_path)             # <<<<<<<<<<<<<<
 *                     except Exception as e:
 *                         logger.warning("Failed to clean up temp file: %s", e)
*/
                __pyx_t_4 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4477, __pyx_L85_error)
                __Pyx_GOTREF(__pyx_t_3);
                __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4477, __pyx_L85_error)
                __Pyx_GOTREF(__pyx_t_8);
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                if (unlikely(!__pyx_cur_scope->__pyx_v_temp_file_path)) { __Pyx_RaiseUnboundLocalError("temp_file_path"); __PYX_ERR(0, 4477, __pyx_L85_error) }
                __pyx_t_5 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_8))) {
                  __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8);
                  assert(__pyx_t_4);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
                  __Pyx_INCREF(__pyx_t_4);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
                  __pyx_t_5 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Cleaned_up_temporary_database_co, __pyx_cur_scope->__pyx_v_temp_file_path};
                  __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                  if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4477, __pyx_L85_error)
                  __Pyx_GOTREF(__pyx_t_10);
                }
                __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

                /* "ws_package/controllers/activity_controller.py":4475
 * 
 *                     # Clean up temp file after upload
 *                     try:             # <<<<<<<<<<<<<<
 *                         os.unlink(temp_file_path)
 *                         logger.debug("Cleaned up temporary database copy: %s", temp_file_path)
*/
              }
              __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
              __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
              __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
              goto __pyx_L90_try_end;
              __pyx_L85_error:;
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
              __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

              /* "ws_package/controllers/activity_controller.py":4478
 *                         os.unlink(temp_file_path)
 *                         logger.debug("Cleaned up temporary database copy: %s", temp_file_path)
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.warning("Failed to clean up temp file: %s", e)
 * 
*/
              __pyx_t_27 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
              if (__pyx_t_27) {
                __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.db_to_server", __pyx_clineno, __pyx_lineno, __pyx_filename);
                if (__Pyx_GetException(&__pyx_t_10, &__pyx_t_8, &__pyx_t_4) < 0) __PYX_ERR(0, 4478, __pyx_L87_except_error)
                __Pyx_XGOTREF(__pyx_t_10);
                __Pyx_XGOTREF(__pyx_t_8);
                __Pyx_XGOTREF(__pyx_t_4);
                __Pyx_INCREF(__pyx_t_8);
                __Pyx_GIVEREF(__pyx_t_8);
                __pyx_cur_scope->__pyx_v_e = __pyx_t_8;
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":4479
 *                         logger.debug("Cleaned up temporary database copy: %s", temp_file_path)
 *                     except Exception as e:
 *                         logger.warning("Failed to clean up temp file: %s", e)             # <<<<<<<<<<<<<<
 * 
 *                     if self.screenshot_controller.is_link(result):
*/
                  __pyx_t_1 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4479, __pyx_L96_error)
                  __Pyx_GOTREF(__pyx_t_9);
                  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4479, __pyx_L96_error)
                  __Pyx_GOTREF(__pyx_t_2);
                  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                  __pyx_t_5 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_2))) {
                    __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
                    assert(__pyx_t_1);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
                    __Pyx_INCREF(__pyx_t_1);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
                    __pyx_t_5 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Failed_to_clean_up_temp_file_s, __pyx_cur_scope->__pyx_v_e};
                    __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4479, __pyx_L96_error)
                    __Pyx_GOTREF(__pyx_t_3);
                  }
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                }

                /* "ws_package/controllers/activity_controller.py":4478
 *                         os.unlink(temp_file_path)
 *                         logger.debug("Cleaned up temporary database copy: %s", temp_file_path)
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.warning("Failed to clean up temp file: %s", e)
 * 
*/
                /*finally:*/ {
                  /*normal exit:*/{
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    goto __pyx_L97;
                  }
                  __pyx_L96_error:;
                  /*exception exit:*/{
                    __Pyx_PyThreadState_assign
                    __pyx_t_20 = 0; __pyx_t_31 = 0; __pyx_t_30 = 0; __pyx_t_29 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0;
                    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                     __Pyx_ExceptionSwap(&__pyx_t_29, &__pyx_t_25, &__pyx_t_24);
                    if ( unlikely(__Pyx_GetException(&__pyx_t_20, &__pyx_t_31, &__pyx_t_30) < 0)) __Pyx_ErrFetch(&__pyx_t_20, &__pyx_t_31, &__pyx_t_30);
                    __Pyx_XGOTREF(__pyx_t_20);
                    __Pyx_XGOTREF(__pyx_t_31);
                    __Pyx_XGOTREF(__pyx_t_30);
                    __Pyx_XGOTREF(__pyx_t_29);
                    __Pyx_XGOTREF(__pyx_t_25);
                    __Pyx_XGOTREF(__pyx_t_24);
                    __pyx_t_27 = __pyx_lineno; __pyx_t_26 = __pyx_clineno; __pyx_t_32 = __pyx_filename;
                    {
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    }
                    __Pyx_XGIVEREF(__pyx_t_29);
                    __Pyx_XGIVEREF(__pyx_t_25);
                    __Pyx_XGIVEREF(__pyx_t_24);
                    __Pyx_ExceptionReset(__pyx_t_29, __pyx_t_25, __pyx_t_24);
                    __Pyx_XGIVEREF(__pyx_t_20);
                    __Pyx_XGIVEREF(__pyx_t_31);
                    __Pyx_XGIVEREF(__pyx_t_30);
                    __Pyx_ErrRestore(__pyx_t_20, __pyx_t_31, __pyx_t_30);
                    __pyx_t_20 = 0; __pyx_t_31 = 0; __pyx_t_30 = 0; __pyx_t_29 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0;
                    __pyx_lineno = __pyx_t_27; __pyx_clineno = __pyx_t_26; __pyx_filename = __pyx_t_32;
                    goto __pyx_L87_except_error;
                  }
                  __pyx_L97:;
                }
                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                goto __pyx_L86_exception_handled;
              }
              goto __pyx_L87_except_error;

              /* "ws_package/controllers/activity_controller.py":4475
 * 
 *                     # Clean up temp file after upload
 *                     try:             # <<<<<<<<<<<<<<
 *                         os.unlink(temp_file_path)
 *                         logger.debug("Cleaned up temporary database copy: %s", temp_file_path)
*/
              __pyx_L87_except_error:;
              __Pyx_XGIVEREF(__pyx_t_16);
              __Pyx_XGIVEREF(__pyx_t_22);
              __Pyx_XGIVEREF(__pyx_t_21);
              __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_22, __pyx_t_21);
              goto __pyx_L78_error;
              __pyx_L86_exception_handled:;
              __Pyx_XGIVEREF(__pyx_t_16);
              __Pyx_XGIVEREF(__pyx_t_22);
              __Pyx_XGIVEREF(__pyx_t_21);
              __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_22, __pyx_t_21);
              __pyx_L90_try_end:;
            }

            /* "ws_package/controllers/activity_controller.py":4481
 *                         logger.warning("Failed to clean up temp file: %s", e)
 * 
 *                     if self.screenshot_controller.is_link(result):             # <<<<<<<<<<<<<<
 *                         logger.info("Database uploaded successfully: %s", result)
 *                     else:
*/
            __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4481, __pyx_L78_error)
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_8 = __pyx_t_10;
            __Pyx_INCREF(__pyx_t_8);
            __pyx_t_5 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_cur_scope->__pyx_v_result};
              __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_link, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4481, __pyx_L78_error)
              __Pyx_GOTREF(__pyx_t_4);
            }
            __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 4481, __pyx_L78_error)
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (__pyx_t_6) {

              /* "ws_package/controllers/activity_controller.py":4482
 * 
 *                     if self.screenshot_controller.is_link(result):
 *                         logger.info("Database uploaded successfully: %s", result)             # <<<<<<<<<<<<<<
 *                     else:
 *                         logger.error("Database upload failed: %s", result)
*/
              __pyx_t_10 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4482, __pyx_L78_error)
              __Pyx_GOTREF(__pyx_t_8);
              __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4482, __pyx_L78_error)
              __Pyx_GOTREF(__pyx_t_3);
              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
              __pyx_t_5 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_3))) {
                __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_3);
                assert(__pyx_t_10);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
                __Pyx_INCREF(__pyx_t_10);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
                __pyx_t_5 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Database_uploaded_successfully_s, __pyx_cur_scope->__pyx_v_result};
                __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4482, __pyx_L78_error)
                __Pyx_GOTREF(__pyx_t_4);
              }
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

              /* "ws_package/controllers/activity_controller.py":4481
 *                         logger.warning("Failed to clean up temp file: %s", e)
 * 
 *                     if self.screenshot_controller.is_link(result):             # <<<<<<<<<<<<<<
 *                         logger.info("Database uploaded successfully: %s", result)
 *                     else:
*/
              goto __pyx_L102;
            }

            /* "ws_package/controllers/activity_controller.py":4484
 *                         logger.info("Database uploaded successfully: %s", result)
 *                     else:
 *                         logger.error("Database upload failed: %s", result)             # <<<<<<<<<<<<<<
 *                 except Exception as upload_error:
 *                     logger.error("Error uploading database copy: %s", upload_error)
*/
            /*else*/ {
              __pyx_t_3 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4484, __pyx_L78_error)
              __Pyx_GOTREF(__pyx_t_10);
              __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4484, __pyx_L78_error)
              __Pyx_GOTREF(__pyx_t_8);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              __pyx_t_5 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_8))) {
                __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_8);
                assert(__pyx_t_3);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
                __Pyx_INCREF(__pyx_t_3);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
                __pyx_t_5 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Database_upload_failed_s, __pyx_cur_scope->__pyx_v_result};
                __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4484, __pyx_L78_error)
                __Pyx_GOTREF(__pyx_t_4);
              }
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            }
            __pyx_L102:;

            /* "ws_package/controllers/activity_controller.py":4467
 *             # Upload the copy (outside the lock to avoid blocking database operations)
 *             if temp_file_path and os.path.exists(temp_file_path):
 *                 try:             # <<<<<<<<<<<<<<
 *                     result = await self.screenshot_controller.screenshot_service.sync(
 *                         temp_file_path,
*/
          }
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          goto __pyx_L83_try_end;
          __pyx_L78_error:;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

          /* "ws_package/controllers/activity_controller.py":4485
 *                     else:
 *                         logger.error("Database upload failed: %s", result)
 *                 except Exception as upload_error:             # <<<<<<<<<<<<<<
 *                     logger.error("Error uploading database copy: %s", upload_error)
 *                     # Clean up temp file on upload error
*/
          __pyx_t_26 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
          if (__pyx_t_26) {
            __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.db_to_server", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_8, &__pyx_t_3) < 0) __PYX_ERR(0, 4485, __pyx_L80_except_error)
            __Pyx_XGOTREF(__pyx_t_4);
            __Pyx_XGOTREF(__pyx_t_8);
            __Pyx_XGOTREF(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_8);
            __Pyx_GIVEREF(__pyx_t_8);
            __pyx_cur_scope->__pyx_v_upload_error = __pyx_t_8;
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":4486
 *                         logger.error("Database upload failed: %s", result)
 *                 except Exception as upload_error:
 *                     logger.error("Error uploading database copy: %s", upload_error)             # <<<<<<<<<<<<<<
 *                     # Clean up temp file on upload error
 *                     try:
*/
              __pyx_t_2 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4486, __pyx_L108_error)
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4486, __pyx_L108_error)
              __Pyx_GOTREF(__pyx_t_9);
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __pyx_t_5 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_9))) {
                __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_9);
                assert(__pyx_t_2);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
                __Pyx_INCREF(__pyx_t_2);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
                __pyx_t_5 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Error_uploading_database_copy_s, __pyx_cur_scope->__pyx_v_upload_error};
                __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4486, __pyx_L108_error)
                __Pyx_GOTREF(__pyx_t_10);
              }
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

              /* "ws_package/controllers/activity_controller.py":4488
 *                     logger.error("Error uploading database copy: %s", upload_error)
 *                     # Clean up temp file on upload error
 *                     try:             # <<<<<<<<<<<<<<
 *                         if os.path.exists(temp_file.name):
 *                             os.unlink(temp_file.name)
*/
              {
                __Pyx_ExceptionSave(&__pyx_t_21, &__pyx_t_22, &__pyx_t_16);
                __Pyx_XGOTREF(__pyx_t_21);
                __Pyx_XGOTREF(__pyx_t_22);
                __Pyx_XGOTREF(__pyx_t_16);
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":4489
 *                     # Clean up temp file on upload error
 *                     try:
 *                         if os.path.exists(temp_file.name):             # <<<<<<<<<<<<<<
 *                             os.unlink(temp_file.name)
 *                     except Exception:
*/
                  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4489, __pyx_L110_error)
                  __Pyx_GOTREF(__pyx_t_2);
                  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_path); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4489, __pyx_L110_error)
                  __Pyx_GOTREF(__pyx_t_1);
                  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                  __pyx_t_9 = __pyx_t_1;
                  __Pyx_INCREF(__pyx_t_9);
                  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_temp_file, __pyx_mstate_global->__pyx_n_u_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4489, __pyx_L110_error)
                  __Pyx_GOTREF(__pyx_t_2);
                  __pyx_t_5 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_t_2};
                    __pyx_t_10 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_exists, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                    if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4489, __pyx_L110_error)
                    __Pyx_GOTREF(__pyx_t_10);
                  }
                  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 4489, __pyx_L110_error)
                  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                  if (__pyx_t_6) {

                    /* "ws_package/controllers/activity_controller.py":4490
 *                     try:
 *                         if os.path.exists(temp_file.name):
 *                             os.unlink(temp_file.name)             # <<<<<<<<<<<<<<
 *                     except Exception:
 *                         pass
*/
                    __pyx_t_1 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4490, __pyx_L110_error)
                    __Pyx_GOTREF(__pyx_t_2);
                    __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_unlink); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4490, __pyx_L110_error)
                    __Pyx_GOTREF(__pyx_t_9);
                    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_temp_file, __pyx_mstate_global->__pyx_n_u_name); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4490, __pyx_L110_error)
                    __Pyx_GOTREF(__pyx_t_2);
                    __pyx_t_5 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_9))) {
                      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_9);
                      assert(__pyx_t_1);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
                      __Pyx_INCREF(__pyx_t_1);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
                      __pyx_t_5 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_t_2};
                      __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                      if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4490, __pyx_L110_error)
                      __Pyx_GOTREF(__pyx_t_10);
                    }
                    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

                    /* "ws_package/controllers/activity_controller.py":4489
 *                     # Clean up temp file on upload error
 *                     try:
 *                         if os.path.exists(temp_file.name):             # <<<<<<<<<<<<<<
 *                             os.unlink(temp_file.name)
 *                     except Exception:
*/
                  }

                  /* "ws_package/controllers/activity_controller.py":4488
 *                     logger.error("Error uploading database copy: %s", upload_error)
 *                     # Clean up temp file on upload error
 *                     try:             # <<<<<<<<<<<<<<
 *                         if os.path.exists(temp_file.name):
 *                             os.unlink(temp_file.name)
*/
                }
                __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                goto __pyx_L117_try_end;
                __pyx_L110_error:;
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

                /* "ws_package/controllers/activity_controller.py":4491
 *                         if os.path.exists(temp_file.name):
 *                             os.unlink(temp_file.name)
 *                     except Exception:             # <<<<<<<<<<<<<<
 *                         pass
 *             else:
*/
                __pyx_t_26 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                if (__pyx_t_26) {
                  __Pyx_ErrRestore(0,0,0);
                  goto __pyx_L111_exception_handled;
                }
                goto __pyx_L112_except_error;

                /* "ws_package/controllers/activity_controller.py":4488
 *                     logger.error("Error uploading database copy: %s", upload_error)
 *                     # Clean up temp file on upload error
 *                     try:             # <<<<<<<<<<<<<<
 *                         if os.path.exists(temp_file.name):
 *                             os.unlink(temp_file.name)
*/
                __pyx_L112_except_error:;
                __Pyx_XGIVEREF(__pyx_t_21);
                __Pyx_XGIVEREF(__pyx_t_22);
                __Pyx_XGIVEREF(__pyx_t_16);
                __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_16);
                goto __pyx_L108_error;
                __pyx_L111_exception_handled:;
                __Pyx_XGIVEREF(__pyx_t_21);
                __Pyx_XGIVEREF(__pyx_t_22);
                __Pyx_XGIVEREF(__pyx_t_16);
                __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_16);
                __pyx_L117_try_end:;
              }
            }

            /* "ws_package/controllers/activity_controller.py":4485
 *                     else:
 *                         logger.error("Database upload failed: %s", result)
 *                 except Exception as upload_error:             # <<<<<<<<<<<<<<
 *                     logger.error("Error uploading database copy: %s", upload_error)
 *                     # Clean up temp file on upload error
*/
            /*finally:*/ {
              /*normal exit:*/{
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_upload_error);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_upload_error); __pyx_cur_scope->__pyx_v_upload_error = 0;
                goto __pyx_L109;
              }
              __pyx_L108_error:;
              /*exception exit:*/{
                __Pyx_PyThreadState_assign
                __pyx_t_16 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_29 = 0;
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                 __Pyx_ExceptionSwap(&__pyx_t_24, &__pyx_t_25, &__pyx_t_29);
                if ( unlikely(__Pyx_GetException(&__pyx_t_16, &__pyx_t_22, &__pyx_t_21) < 0)) __Pyx_ErrFetch(&__pyx_t_16, &__pyx_t_22, &__pyx_t_21);
                __Pyx_XGOTREF(__pyx_t_16);
                __Pyx_XGOTREF(__pyx_t_22);
                __Pyx_XGOTREF(__pyx_t_21);
                __Pyx_XGOTREF(__pyx_t_24);
                __Pyx_XGOTREF(__pyx_t_25);
                __Pyx_XGOTREF(__pyx_t_29);
                __pyx_t_26 = __pyx_lineno; __pyx_t_27 = __pyx_clineno; __pyx_t_33 = __pyx_filename;
                {
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_upload_error);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_upload_error); __pyx_cur_scope->__pyx_v_upload_error = 0;
                }
                __Pyx_XGIVEREF(__pyx_t_24);
                __Pyx_XGIVEREF(__pyx_t_25);
                __Pyx_XGIVEREF(__pyx_t_29);
                __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_25, __pyx_t_29);
                __Pyx_XGIVEREF(__pyx_t_16);
                __Pyx_XGIVEREF(__pyx_t_22);
                __Pyx_XGIVEREF(__pyx_t_21);
                __Pyx_ErrRestore(__pyx_t_16, __pyx_t_22, __pyx_t_21);
                __pyx_t_16 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_29 = 0;
                __pyx_lineno = __pyx_t_26; __pyx_clineno = __pyx_t_27; __pyx_filename = __pyx_t_33;
                goto __pyx_L80_except_error;
              }
              __pyx_L109:;
            }
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            goto __pyx_L79_exception_handled;
          }
          goto __pyx_L80_except_error;

          /* "ws_package/controllers/activity_controller.py":4467
 *             # Upload the copy (outside the lock to avoid blocking database operations)
 *             if temp_file_path and os.path.exists(temp_file_path):
 *                 try:             # <<<<<<<<<<<<<<
 *                     result = await self.screenshot_controller.screenshot_service.sync(
 *                         temp_file_path,
*/
          __pyx_L80_except_error:;
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_18, __pyx_t_17);
          goto __pyx_L12_error;
          __pyx_L79_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_18, __pyx_t_17);
          __pyx_L83_try_end:;
        }

        /* "ws_package/controllers/activity_controller.py":4466
 * 
 *             # Upload the copy (outside the lock to avoid blocking database operations)
 *             if temp_file_path and os.path.exists(temp_file_path):             # <<<<<<<<<<<<<<
 *                 try:
 *                     result = await self.screenshot_controller.screenshot_service.sync(
*/
        goto __pyx_L75;
      }

      /* "ws_package/controllers/activity_controller.py":4494
 *                         pass
 *             else:
 *                 logger.error("Temporary database file not available for upload")             # <<<<<<<<<<<<<<
 * 
 *         except ValidationError as e:
*/
      /*else*/ {
        __pyx_t_8 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4494, __pyx_L12_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4494, __pyx_L12_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_5 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_10);
          assert(__pyx_t_8);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
          __pyx_t_5 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_mstate_global->__pyx_kp_u_Temporary_database_file_not_avai};
          __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4494, __pyx_L12_error)
          __Pyx_GOTREF(__pyx_t_3);
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      }
      __pyx_L75:;

      /* "ws_package/controllers/activity_controller.py":4423
 *             return
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             # Use safe file copy that coordinates with database locks
 *             temp_file = None
*/
    }
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    goto __pyx_L17_try_end;
    __pyx_L12_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "ws_package/controllers/activity_controller.py":4496
 *                 logger.error("Temporary database file not available for upload")
 * 
 *         except ValidationError as e:             # <<<<<<<<<<<<<<
 *             logger.error("Screenshot sync validation error for database: %s", e)
 *             logger.error("Context: file=%s, dest=%s", database_dir, database_server)
*/
    __Pyx_ErrFetch(&__pyx_t_3, &__pyx_t_10, &__pyx_t_8);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_ValidationError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4496, __pyx_L14_except_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_27 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_3, __pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_ErrRestore(__pyx_t_3, __pyx_t_10, __pyx_t_8);
    __pyx_t_3 = 0; __pyx_t_10 = 0; __pyx_t_8 = 0;
    if (__pyx_t_27) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.db_to_server", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_10, &__pyx_t_3) < 0) __PYX_ERR(0, 4496, __pyx_L14_except_error)
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_10);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":4497
 * 
 *         except ValidationError as e:
 *             logger.error("Screenshot sync validation error for database: %s", e)             # <<<<<<<<<<<<<<
 *             logger.error("Context: file=%s, dest=%s", database_dir, database_server)
 *             # Continue processing - don't fail the entire operation
*/
        __pyx_t_9 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4497, __pyx_L130_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4497, __pyx_L130_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_5 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
          assert(__pyx_t_9);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
          __pyx_t_5 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_9, __pyx_mstate_global->__pyx_kp_u_Screenshot_sync_validation_error_3, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4497, __pyx_L130_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":4498
 *         except ValidationError as e:
 *             logger.error("Screenshot sync validation error for database: %s", e)
 *             logger.error("Context: file=%s, dest=%s", database_dir, database_server)             # <<<<<<<<<<<<<<
 *             # Continue processing - don't fail the entire operation
 *         except ScreenshotError as e:
*/
        __pyx_t_1 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4498, __pyx_L130_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4498, __pyx_L130_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_5 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
          assert(__pyx_t_1);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
          __pyx_t_5 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[4] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Context_file_s_dest_s, __pyx_cur_scope->__pyx_v_database_dir, __pyx_cur_scope->__pyx_v_database_server};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_5, (4-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4498, __pyx_L130_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }

      /* "ws_package/controllers/activity_controller.py":4496
 *                 logger.error("Temporary database file not available for upload")
 * 
 *         except ValidationError as e:             # <<<<<<<<<<<<<<
 *             logger.error("Screenshot sync validation error for database: %s", e)
 *             logger.error("Context: file=%s, dest=%s", database_dir, database_server)
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          goto __pyx_L131;
        }
        __pyx_L130_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_15 = 0; __pyx_t_29 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_29, &__pyx_t_25, &__pyx_t_24);
          if ( unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_15) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_17);
          __Pyx_XGOTREF(__pyx_t_18);
          __Pyx_XGOTREF(__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_29);
          __Pyx_XGOTREF(__pyx_t_25);
          __Pyx_XGOTREF(__pyx_t_24);
          __pyx_t_27 = __pyx_lineno; __pyx_t_26 = __pyx_clineno; __pyx_t_34 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_29);
          __Pyx_XGIVEREF(__pyx_t_25);
          __Pyx_XGIVEREF(__pyx_t_24);
          __Pyx_ExceptionReset(__pyx_t_29, __pyx_t_25, __pyx_t_24);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_ErrRestore(__pyx_t_17, __pyx_t_18, __pyx_t_15);
          __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_15 = 0; __pyx_t_29 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0;
          __pyx_lineno = __pyx_t_27; __pyx_clineno = __pyx_t_26; __pyx_filename = __pyx_t_34;
          goto __pyx_L14_except_error;
        }
        __pyx_L131:;
      }
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L13_exception_handled;
    }

    /* "ws_package/controllers/activity_controller.py":4500
 *             logger.error("Context: file=%s, dest=%s", database_dir, database_server)
 *             # Continue processing - don't fail the entire operation
 *         except ScreenshotError as e:             # <<<<<<<<<<<<<<
 *             logger.error("Screenshot sync error for database: %s", e)
 *             logger.error("Context: file=%s, dest=%s", database_dir, database_server)
*/
    __Pyx_ErrFetch(&__pyx_t_3, &__pyx_t_10, &__pyx_t_8);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_ScreenshotError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4500, __pyx_L14_except_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_26 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_3, __pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_ErrRestore(__pyx_t_3, __pyx_t_10, __pyx_t_8);
    __pyx_t_3 = 0; __pyx_t_10 = 0; __pyx_t_8 = 0;
    if (__pyx_t_26) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.db_to_server", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_10, &__pyx_t_3) < 0) __PYX_ERR(0, 4500, __pyx_L14_except_error)
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_10);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":4501
 *             # Continue processing - don't fail the entire operation
 *         except ScreenshotError as e:
 *             logger.error("Screenshot sync error for database: %s", e)             # <<<<<<<<<<<<<<
 *             logger.error("Context: file=%s, dest=%s", database_dir, database_server)
 *             # Continue processing - don't fail the entire operation
*/
        __pyx_t_2 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4501, __pyx_L141_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4501, __pyx_L141_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_5 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_9);
          assert(__pyx_t_2);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
          __pyx_t_5 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Screenshot_sync_error_for_databa, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4501, __pyx_L141_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":4502
 *         except ScreenshotError as e:
 *             logger.error("Screenshot sync error for database: %s", e)
 *             logger.error("Context: file=%s, dest=%s", database_dir, database_server)             # <<<<<<<<<<<<<<
 *             # Continue processing - don't fail the entire operation
 *         except NetworkError as e:
*/
        __pyx_t_9 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4502, __pyx_L141_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4502, __pyx_L141_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_5 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
          assert(__pyx_t_9);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
          __pyx_t_5 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[4] = {__pyx_t_9, __pyx_mstate_global->__pyx_kp_u_Context_file_s_dest_s, __pyx_cur_scope->__pyx_v_database_dir, __pyx_cur_scope->__pyx_v_database_server};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_5, (4-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4502, __pyx_L141_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }

      /* "ws_package/controllers/activity_controller.py":4500
 *             logger.error("Context: file=%s, dest=%s", database_dir, database_server)
 *             # Continue processing - don't fail the entire operation
 *         except ScreenshotError as e:             # <<<<<<<<<<<<<<
 *             logger.error("Screenshot sync error for database: %s", e)
 *             logger.error("Context: file=%s, dest=%s", database_dir, database_server)
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          goto __pyx_L142;
        }
        __pyx_L141_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_29 = 0; __pyx_t_15 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_18, &__pyx_t_17);
          if ( unlikely(__Pyx_GetException(&__pyx_t_24, &__pyx_t_25, &__pyx_t_29) < 0)) __Pyx_ErrFetch(&__pyx_t_24, &__pyx_t_25, &__pyx_t_29);
          __Pyx_XGOTREF(__pyx_t_24);
          __Pyx_XGOTREF(__pyx_t_25);
          __Pyx_XGOTREF(__pyx_t_29);
          __Pyx_XGOTREF(__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_18);
          __Pyx_XGOTREF(__pyx_t_17);
          __pyx_t_26 = __pyx_lineno; __pyx_t_27 = __pyx_clineno; __pyx_t_35 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_18, __pyx_t_17);
          __Pyx_XGIVEREF(__pyx_t_24);
          __Pyx_XGIVEREF(__pyx_t_25);
          __Pyx_XGIVEREF(__pyx_t_29);
          __Pyx_ErrRestore(__pyx_t_24, __pyx_t_25, __pyx_t_29);
          __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_29 = 0; __pyx_t_15 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0;
          __pyx_lineno = __pyx_t_26; __pyx_clineno = __pyx_t_27; __pyx_filename = __pyx_t_35;
          goto __pyx_L14_except_error;
        }
        __pyx_L142:;
      }
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L13_exception_handled;
    }

    /* "ws_package/controllers/activity_controller.py":4504
 *             logger.error("Context: file=%s, dest=%s", database_dir, database_server)
 *             # Continue processing - don't fail the entire operation
 *         except NetworkError as e:             # <<<<<<<<<<<<<<
 *             logger.error("Network error during screenshot sync for database: %s", e)
 *             logger.error("Context: file=%s, dest=%s", database_dir, database_server)
*/
    __Pyx_ErrFetch(&__pyx_t_3, &__pyx_t_10, &__pyx_t_8);
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_NetworkError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4504, __pyx_L14_except_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_27 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_3, __pyx_t_4);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_ErrRestore(__pyx_t_3, __pyx_t_10, __pyx_t_8);
    __pyx_t_3 = 0; __pyx_t_10 = 0; __pyx_t_8 = 0;
    if (__pyx_t_27) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.db_to_server", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_10, &__pyx_t_3) < 0) __PYX_ERR(0, 4504, __pyx_L14_except_error)
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_3);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_10);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":4505
 *             # Continue processing - don't fail the entire operation
 *         except NetworkError as e:
 *             logger.error("Network error during screenshot sync for database: %s", e)             # <<<<<<<<<<<<<<
 *             logger.error("Context: file=%s, dest=%s", database_dir, database_server)
 *             # Continue processing - don't fail the entire operation
*/
        __pyx_t_1 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4505, __pyx_L152_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4505, __pyx_L152_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_5 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
          assert(__pyx_t_1);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
          __pyx_t_5 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Network_error_during_screenshot_3, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4505, __pyx_L152_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":4506
 *         except NetworkError as e:
 *             logger.error("Network error during screenshot sync for database: %s", e)
 *             logger.error("Context: file=%s, dest=%s", database_dir, database_server)             # <<<<<<<<<<<<<<
 *             # Continue processing - don't fail the entire operation
 *         except Exception as e:
*/
        __pyx_t_2 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4506, __pyx_L152_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4506, __pyx_L152_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_5 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_9);
          assert(__pyx_t_2);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
          __pyx_t_5 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[4] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Context_file_s_dest_s, __pyx_cur_scope->__pyx_v_database_dir, __pyx_cur_scope->__pyx_v_database_server};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_5, (4-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4506, __pyx_L152_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }

      /* "ws_package/controllers/activity_controller.py":4504
 *             logger.error("Context: file=%s, dest=%s", database_dir, database_server)
 *             # Continue processing - don't fail the entire operation
 *         except NetworkError as e:             # <<<<<<<<<<<<<<
 *             logger.error("Network error during screenshot sync for database: %s", e)
 *             logger.error("Context: file=%s, dest=%s", database_dir, database_server)
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          goto __pyx_L153;
        }
        __pyx_L152_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_15 = 0; __pyx_t_29 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_29, &__pyx_t_25, &__pyx_t_24);
          if ( unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_15) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_17);
          __Pyx_XGOTREF(__pyx_t_18);
          __Pyx_XGOTREF(__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_29);
          __Pyx_XGOTREF(__pyx_t_25);
          __Pyx_XGOTREF(__pyx_t_24);
          __pyx_t_27 = __pyx_lineno; __pyx_t_26 = __pyx_clineno; __pyx_t_36 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_29);
          __Pyx_XGIVEREF(__pyx_t_25);
          __Pyx_XGIVEREF(__pyx_t_24);
          __Pyx_ExceptionReset(__pyx_t_29, __pyx_t_25, __pyx_t_24);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_ErrRestore(__pyx_t_17, __pyx_t_18, __pyx_t_15);
          __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_15 = 0; __pyx_t_29 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0;
          __pyx_lineno = __pyx_t_27; __pyx_clineno = __pyx_t_26; __pyx_filename = __pyx_t_36;
          goto __pyx_L14_except_error;
        }
        __pyx_L153:;
      }
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      goto __pyx_L13_exception_handled;
    }

    /* "ws_package/controllers/activity_controller.py":4508
 *             logger.error("Context: file=%s, dest=%s", database_dir, database_server)
 *             # Continue processing - don't fail the entire operation
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error in database upload: %s", e, exc_info=True)
 *             # Continue processing - don't fail the entire operation
*/
    __pyx_t_26 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_26) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.db_to_server", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_10, &__pyx_t_8) < 0) __PYX_ERR(0, 4508, __pyx_L14_except_error)
      __Pyx_XGOTREF(__pyx_t_3);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_10);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":4509
 *             # Continue processing - don't fail the entire operation
 *         except Exception as e:
 *             logger.error("Error in database upload: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 *             # Continue processing - don't fail the entire operation
 * 
*/
        __pyx_t_9 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4509, __pyx_L163_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4509, __pyx_L163_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_5 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_1);
          assert(__pyx_t_9);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
          __pyx_t_5 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_9, __pyx_mstate_global->__pyx_kp_u_Error_in_database_upload_s, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_2 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4509, __pyx_L163_error)
          __Pyx_GOTREF(__pyx_t_2);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_2, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 4509, __pyx_L163_error)
          __pyx_t_4 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_2);
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4509, __pyx_L163_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }

      /* "ws_package/controllers/activity_controller.py":4508
 *             logger.error("Context: file=%s, dest=%s", database_dir, database_server)
 *             # Continue processing - don't fail the entire operation
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error in database upload: %s", e, exc_info=True)
 *             # Continue processing - don't fail the entire operation
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          goto __pyx_L164;
        }
        __pyx_L163_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_29 = 0; __pyx_t_15 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_18, &__pyx_t_17);
          if ( unlikely(__Pyx_GetException(&__pyx_t_24, &__pyx_t_25, &__pyx_t_29) < 0)) __Pyx_ErrFetch(&__pyx_t_24, &__pyx_t_25, &__pyx_t_29);
          __Pyx_XGOTREF(__pyx_t_24);
          __Pyx_XGOTREF(__pyx_t_25);
          __Pyx_XGOTREF(__pyx_t_29);
          __Pyx_XGOTREF(__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_18);
          __Pyx_XGOTREF(__pyx_t_17);
          __pyx_t_26 = __pyx_lineno; __pyx_t_27 = __pyx_clineno; __pyx_t_37 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_18, __pyx_t_17);
          __Pyx_XGIVEREF(__pyx_t_24);
          __Pyx_XGIVEREF(__pyx_t_25);
          __Pyx_XGIVEREF(__pyx_t_29);
          __Pyx_ErrRestore(__pyx_t_24, __pyx_t_25, __pyx_t_29);
          __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_29 = 0; __pyx_t_15 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0;
          __pyx_lineno = __pyx_t_26; __pyx_clineno = __pyx_t_27; __pyx_filename = __pyx_t_37;
          goto __pyx_L14_except_error;
        }
        __pyx_L164:;
      }
      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
      goto __pyx_L13_exception_handled;
    }
    goto __pyx_L14_except_error;

    /* "ws_package/controllers/activity_controller.py":4423
 *             return
 * 
 *         try:             # <<<<<<<<<<<<<<
 *             # Use safe file copy that coordinates with database locks
 *             temp_file = None
*/
    __pyx_L14_except_error:;
    __Pyx_XGIVEREF(__pyx_t_12);
    __Pyx_XGIVEREF(__pyx_t_13);
    __Pyx_XGIVEREF(__pyx_t_14);
    __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
    goto __pyx_L1_error;
    __pyx_L16_try_return:;
    __Pyx_XGIVEREF(__pyx_t_12);
    __Pyx_XGIVEREF(__pyx_t_13);
    __Pyx_XGIVEREF(__pyx_t_14);
    __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
    goto __pyx_L0;
    __pyx_L13_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_12);
    __Pyx_XGIVEREF(__pyx_t_13);
    __Pyx_XGIVEREF(__pyx_t_14);
    __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
    __pyx_L17_try_end:;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":4400
 *         self.timezone_manager.set_local_timezone(user_entity)
 * 
 *     async def db_to_server(self, user_entity: UserEntity):             # <<<<<<<<<<<<<<
 *         logger.info("Running db to server")
 *         if getattr(sys, 'frozen', False) and platform.system() == "Linux":
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_10);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("db_to_server", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_162generator32(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":4512
 *             # Continue processing - don't fail the entire operation
 * 
 *     async def getting_unsent_interval(self, user_entity: UserEntity):             # <<<<<<<<<<<<<<
 *         """Return unsent (``is_uploaded=False``) non-break activity intervals eligible for upload.
 * 
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_161getting_unsent_interval(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_160getting_unsent_interval, "Return unsent (``is_uploaded=False``) non-break activity intervals eligible for upload.\n\n        Eligible intervals are those that belong to a session OTHER than the\n        currently active one.  Two cases are covered:\n\n        1. **Previous-day intervals** \342\200\224 any date before today.\n        2. **Same-day previous-session intervals** \342\200\224 today's date but a counter\n           value strictly less than the current session counter.  These are\n           intervals from a tracking session that ended earlier today (e.g.,\n           user tracked 9\342\200\22310 am, stopped, restarted at 11 am).  The original\n           query excluded today entirely, permanently orphaning these records.\n\n        Intervals from the current session (``counter == current_session_counter``)\n        are intentionally excluded \342\200\224 the active push loop handles those.\n        Break intervals (``is_break != 0``) are excluded \342\200\224 they are handled by\n        ``process_break_interval``.\n\n        Results are grouped by date + counter so we never mix sessions in a\n        single payload.  We return the oldest eligible group first.\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_161getting_unsent_interval = {"getting_unsent_interval", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_161getting_unsent_interval, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_160getting_unsent_interval};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_161getting_unsent_interval(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  CYTHON_UNUSED PyObject *__pyx_v_user_entity = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getting_unsent_interval (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_user_entity,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 4512, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 4512, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4512, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "getting_unsent_interval", 0) < (0)) __PYX_ERR(0, 4512, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("getting_unsent_interval", 1, 2, 2, i); __PYX_ERR(0, 4512, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4512, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 4512, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_user_entity = values[1];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("getting_unsent_interval", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 4512, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.getting_unsent_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_160getting_unsent_interval(__pyx_self, __pyx_v_self, __pyx_v_user_entity);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_160getting_unsent_interval(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_user_entity) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("getting_unsent_interval", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 4512, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_user_entity = __pyx_v_user_entity;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_user_entity);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_user_entity);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_162generator32, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[52]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_getting_unsent_interval, __pyx_mstate_global->__pyx_n_u_ActivityController_getting_unsen, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 4512, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.getting_unsent_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_162generator32(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_PySendResult __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  PyObject *__pyx_t_26 = NULL;
  PyObject *__pyx_t_27 = NULL;
  PyObject *__pyx_t_28 = NULL;
  PyObject *__pyx_t_29 = NULL;
  PyObject *__pyx_t_30 = NULL;
  PyObject *__pyx_t_31 = NULL;
  PyObject *__pyx_t_32 = NULL;
  PyObject *__pyx_t_33 = NULL;
  int __pyx_t_34;
  int __pyx_t_35;
  Py_ssize_t __pyx_t_36;
  int __pyx_t_37;
  int __pyx_t_38;
  char const *__pyx_t_39;
  PyObject *__pyx_t_40 = NULL;
  PyObject *__pyx_t_41 = NULL;
  PyObject *__pyx_t_42 = NULL;
  PyObject *__pyx_t_43 = NULL;
  PyObject *__pyx_t_44 = NULL;
  PyObject *__pyx_t_45 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("getting_unsent_interval", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L15_resume_from_await;
    case 2: goto __pyx_L31_resume_from_await;
    case 3: goto __pyx_L34_resume_from_await;
    case 4: goto __pyx_L51_resume_from_await;
    case 5: goto __pyx_L52_resume_from_await;
    case 6: goto __pyx_L53_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 4512, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":4533
 *         single payload.  We return the oldest eligible group first.
 *         """
 *         DB_OPERATION_TIMEOUT = 5.0             # <<<<<<<<<<<<<<
 * 
 *         logger.info("Running unsent intervals check (excluding current session and break intervals)")
*/
  __pyx_cur_scope->__pyx_v_DB_OPERATION_TIMEOUT = 5.0;

  /* "ws_package/controllers/activity_controller.py":4535
 *         DB_OPERATION_TIMEOUT = 5.0
 * 
 *         logger.info("Running unsent intervals check (excluding current session and break intervals)")             # <<<<<<<<<<<<<<
 *         today = date.today()
 *         current_counter = self.last_count + 1
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4535, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4535, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Running_unsent_intervals_check_e};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4535, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":4536
 * 
 *         logger.info("Running unsent intervals check (excluding current session and break intervals)")
 *         today = date.today()             # <<<<<<<<<<<<<<
 *         current_counter = self.last_count + 1
 * 
*/
  __pyx_t_4 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_date); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4536, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_today); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4536, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
    assert(__pyx_t_4);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_4);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4536, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_GIVEREF(__pyx_t_1);
  __pyx_cur_scope->__pyx_v_today = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":4537
 *         logger.info("Running unsent intervals check (excluding current session and break intervals)")
 *         today = date.today()
 *         current_counter = self.last_count + 1             # <<<<<<<<<<<<<<
 * 
 *         with db_lock_manager.read_lock():
*/
  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4537, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_1);
  __pyx_t_3 = __Pyx_PyLong_AddObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4537, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_GIVEREF(__pyx_t_3);
  __pyx_cur_scope->__pyx_v_current_counter = __pyx_t_3;
  __pyx_t_3 = 0;

  /* "ws_package/controllers/activity_controller.py":4539
 *         current_counter = self.last_count + 1
 * 
 *         with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *             async with async_session() as session:
 *                 try:
*/
  /*with:*/ {
    __pyx_t_1 = NULL;
    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4539, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4539, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (unlikely(PyMethod_Check(__pyx_t_2))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
      assert(__pyx_t_1);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
      __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4539, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __pyx_t_6 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4539, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_1 = NULL;
    __pyx_t_4 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4539, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_4);
    __pyx_t_5 = 1;
    #if CYTHON_UNPACK_METHODS
    if (likely(PyMethod_Check(__pyx_t_4))) {
      __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
      assert(__pyx_t_1);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
      __pyx_t_5 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
      __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4539, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_2);
    }
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    /*try:*/ {
      {
        __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
        __Pyx_XGOTREF(__pyx_t_7);
        __Pyx_XGOTREF(__pyx_t_8);
        __Pyx_XGOTREF(__pyx_t_9);
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":4540
 * 
 *         with db_lock_manager.read_lock():
 *             async with async_session() as session:             # <<<<<<<<<<<<<<
 *                 try:
 *                     # Find the oldest eligible interval.
*/
          /*with:*/ {
            __pyx_t_2 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4540, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_5 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_4))) {
              __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
              assert(__pyx_t_2);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
              __Pyx_INCREF(__pyx_t_2);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
              __pyx_t_5 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
              __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4540, __pyx_L8_error)
              __Pyx_GOTREF(__pyx_t_3);
            }
            __pyx_t_10 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4540, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_2 = NULL;
            __pyx_t_1 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4540, __pyx_L14_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_5 = 1;
            #if CYTHON_UNPACK_METHODS
            if (likely(PyMethod_Check(__pyx_t_1))) {
              __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
              assert(__pyx_t_2);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
              __Pyx_INCREF(__pyx_t_2);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
              __pyx_t_5 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
              __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4540, __pyx_L14_error)
              __Pyx_GOTREF(__pyx_t_4);
            }
            __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (likely(__pyx_t_11 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_3);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
              __Pyx_XGIVEREF(__pyx_t_6);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
              __Pyx_XGIVEREF(__pyx_t_7);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
              __Pyx_XGIVEREF(__pyx_t_8);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_8;
              __Pyx_XGIVEREF(__pyx_t_9);
              __pyx_cur_scope->__pyx_t_4 = __pyx_t_9;
              __Pyx_XGIVEREF(__pyx_t_10);
              __pyx_cur_scope->__pyx_t_5 = __pyx_t_10;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 1;
              return __pyx_r;
              __pyx_L15_resume_from_await:;
              __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_3);
              __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_6);
              __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_7);
              __pyx_t_8 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_8);
              __pyx_t_9 = __pyx_cur_scope->__pyx_t_4;
              __pyx_cur_scope->__pyx_t_4 = 0;
              __Pyx_XGOTREF(__pyx_t_9);
              __pyx_t_10 = __pyx_cur_scope->__pyx_t_5;
              __pyx_cur_scope->__pyx_t_5 = 0;
              __Pyx_XGOTREF(__pyx_t_10);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4540, __pyx_L14_error)
              __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
            } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __pyx_t_4 = __pyx_r; __pyx_r = NULL;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 4540, __pyx_L14_error)
            }
            __pyx_t_1 = __pyx_t_4;
            __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            /*try:*/ {
              {
                __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
                __Pyx_XGOTREF(__pyx_t_12);
                __Pyx_XGOTREF(__pyx_t_13);
                __Pyx_XGOTREF(__pyx_t_14);
                /*try:*/ {
                  __Pyx_GIVEREF(__pyx_t_1);
                  __pyx_cur_scope->__pyx_v_session = __pyx_t_1;
                  __pyx_t_1 = 0;

                  /* "ws_package/controllers/activity_controller.py":4541
 *         with db_lock_manager.read_lock():
 *             async with async_session() as session:
 *                 try:             # <<<<<<<<<<<<<<
 *                     # Find the oldest eligible interval.
 *                     # Eligible = (any previous day) OR (today but earlier session counter).
*/
                  {
                    __Pyx_ExceptionSave(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
                    __Pyx_XGOTREF(__pyx_t_15);
                    __Pyx_XGOTREF(__pyx_t_16);
                    __Pyx_XGOTREF(__pyx_t_17);
                    /*try:*/ {

                      /* "ws_package/controllers/activity_controller.py":4544
 *                     # Find the oldest eligible interval.
 *                     # Eligible = (any previous day) OR (today but earlier session counter).
 *                     first_entry = await asyncio.wait_for(             # <<<<<<<<<<<<<<
 *                         session.scalar(
 *                             select(ActivityInterval)
*/
                      __pyx_t_3 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4544, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_wait_for); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4544, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_2);
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                      /* "ws_package/controllers/activity_controller.py":4545
 *                     # Eligible = (any previous day) OR (today but earlier session counter).
 *                     first_entry = await asyncio.wait_for(
 *                         session.scalar(             # <<<<<<<<<<<<<<
 *                             select(ActivityInterval)
 *                             .where(ActivityInterval.is_uploaded.is_(False))
*/
                      __pyx_t_18 = __pyx_cur_scope->__pyx_v_session;
                      __Pyx_INCREF(__pyx_t_18);

                      /* "ws_package/controllers/activity_controller.py":4546
 *                     first_entry = await asyncio.wait_for(
 *                         session.scalar(
 *                             select(ActivityInterval)             # <<<<<<<<<<<<<<
 *                             .where(ActivityInterval.is_uploaded.is_(False))
 *                             .where(ActivityInterval.is_break == 0)
*/
                      __pyx_t_30 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_31, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_31)) __PYX_ERR(0, 4546, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_31);
                      __Pyx_GetModuleGlobalName(__pyx_t_32, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 4546, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_32);
                      __pyx_t_5 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_31))) {
                        __pyx_t_30 = PyMethod_GET_SELF(__pyx_t_31);
                        assert(__pyx_t_30);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_31);
                        __Pyx_INCREF(__pyx_t_30);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_31, __pyx__function);
                        __pyx_t_5 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_30, __pyx_t_32};
                        __pyx_t_29 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_31, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_30); __pyx_t_30 = 0;
                        __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0;
                        __Pyx_DECREF(__pyx_t_31); __pyx_t_31 = 0;
                        if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 4546, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_29);
                      }
                      __pyx_t_28 = __pyx_t_29;
                      __Pyx_INCREF(__pyx_t_28);

                      /* "ws_package/controllers/activity_controller.py":4547
 *                         session.scalar(
 *                             select(ActivityInterval)
 *                             .where(ActivityInterval.is_uploaded.is_(False))             # <<<<<<<<<<<<<<
 *                             .where(ActivityInterval.is_break == 0)
 *                             .where(
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_30, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 4547, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_30);
                      __pyx_t_33 = __Pyx_PyObject_GetAttrStr(__pyx_t_30, __pyx_mstate_global->__pyx_n_u_is_uploaded); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 4547, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_33);
                      __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
                      __pyx_t_32 = __pyx_t_33;
                      __Pyx_INCREF(__pyx_t_32);
                      __pyx_t_5 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_32, Py_False};
                        __pyx_t_31 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_32); __pyx_t_32 = 0;
                        __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                        if (unlikely(!__pyx_t_31)) __PYX_ERR(0, 4547, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_31);
                      }
                      __pyx_t_5 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_28, __pyx_t_31};
                        __pyx_t_27 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
                        __Pyx_DECREF(__pyx_t_31); __pyx_t_31 = 0;
                        __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
                        if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 4547, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_27);
                      }
                      __pyx_t_26 = __pyx_t_27;
                      __Pyx_INCREF(__pyx_t_26);

                      /* "ws_package/controllers/activity_controller.py":4548
 *                             select(ActivityInterval)
 *                             .where(ActivityInterval.is_uploaded.is_(False))
 *                             .where(ActivityInterval.is_break == 0)             # <<<<<<<<<<<<<<
 *                             .where(
 *                                 or_(
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_29, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 4548, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_29);
                      __pyx_t_31 = __Pyx_PyObject_GetAttrStr(__pyx_t_29, __pyx_mstate_global->__pyx_n_u_is_break); if (unlikely(!__pyx_t_31)) __PYX_ERR(0, 4548, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_31);
                      __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
                      __pyx_t_29 = __Pyx_PyLong_EqObjC(__pyx_t_31, __pyx_mstate_global->__pyx_int_0, 0, 0); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 4548, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_29);
                      __Pyx_DECREF(__pyx_t_31); __pyx_t_31 = 0;
                      __pyx_t_5 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_26, __pyx_t_29};
                        __pyx_t_25 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                        __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
                        __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                        if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 4548, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_25);
                      }
                      __pyx_t_24 = __pyx_t_25;
                      __Pyx_INCREF(__pyx_t_24);

                      /* "ws_package/controllers/activity_controller.py":4550
 *                             .where(ActivityInterval.is_break == 0)
 *                             .where(
 *                                 or_(             # <<<<<<<<<<<<<<
 *                                     func.date(ActivityInterval.start_time) != today,
 *                                     ActivityInterval.counter < current_counter,
*/
                      __pyx_t_29 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_or); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 4550, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_26);

                      /* "ws_package/controllers/activity_controller.py":4551
 *                             .where(
 *                                 or_(
 *                                     func.date(ActivityInterval.start_time) != today,             # <<<<<<<<<<<<<<
 *                                     ActivityInterval.counter < current_counter,
 *                                 )
*/
                      __pyx_t_28 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_func_2); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 4551, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_33);
                      __pyx_t_32 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_date); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 4551, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_32);
                      __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                      __Pyx_GetModuleGlobalName(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 4551, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_33);
                      __pyx_t_30 = __Pyx_PyObject_GetAttrStr(__pyx_t_33, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 4551, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_30);
                      __Pyx_DECREF(__pyx_t_33); __pyx_t_33 = 0;
                      __pyx_t_5 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_32))) {
                        __pyx_t_28 = PyMethod_GET_SELF(__pyx_t_32);
                        assert(__pyx_t_28);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_32);
                        __Pyx_INCREF(__pyx_t_28);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_32, __pyx__function);
                        __pyx_t_5 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_28, __pyx_t_30};
                        __pyx_t_31 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_32, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
                        __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
                        __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0;
                        if (unlikely(!__pyx_t_31)) __PYX_ERR(0, 4551, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_31);
                      }
                      __pyx_t_32 = PyObject_RichCompare(__pyx_t_31, __pyx_cur_scope->__pyx_v_today, Py_NE); __Pyx_XGOTREF(__pyx_t_32); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 4551, __pyx_L25_error)
                      __Pyx_DECREF(__pyx_t_31); __pyx_t_31 = 0;

                      /* "ws_package/controllers/activity_controller.py":4552
 *                                 or_(
 *                                     func.date(ActivityInterval.start_time) != today,
 *                                     ActivityInterval.counter < current_counter,             # <<<<<<<<<<<<<<
 *                                 )
 *                             )
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_31, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_31)) __PYX_ERR(0, 4552, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_31);
                      __pyx_t_30 = __Pyx_PyObject_GetAttrStr(__pyx_t_31, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 4552, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_30);
                      __Pyx_DECREF(__pyx_t_31); __pyx_t_31 = 0;
                      __pyx_t_31 = PyObject_RichCompare(__pyx_t_30, __pyx_cur_scope->__pyx_v_current_counter, Py_LT); __Pyx_XGOTREF(__pyx_t_31); if (unlikely(!__pyx_t_31)) __PYX_ERR(0, 4552, __pyx_L25_error)
                      __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
                      __pyx_t_5 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_26))) {
                        __pyx_t_29 = PyMethod_GET_SELF(__pyx_t_26);
                        assert(__pyx_t_29);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_26);
                        __Pyx_INCREF(__pyx_t_29);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_26, __pyx__function);
                        __pyx_t_5 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[3] = {__pyx_t_29, __pyx_t_32, __pyx_t_31};
                        __pyx_t_27 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_26, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_29); __pyx_t_29 = 0;
                        __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0;
                        __Pyx_DECREF(__pyx_t_31); __pyx_t_31 = 0;
                        __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                        if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 4550, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_27);
                      }
                      __pyx_t_5 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_24, __pyx_t_27};
                        __pyx_t_23 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                        if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 4549, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_23);
                      }
                      __pyx_t_22 = __pyx_t_23;
                      __Pyx_INCREF(__pyx_t_22);

                      /* "ws_package/controllers/activity_controller.py":4555
 *                                 )
 *                             )
 *                             .order_by(ActivityInterval.start_time.asc())             # <<<<<<<<<<<<<<
 *                             .limit(1)
 *                         ),
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 4555, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_24);
                      __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 4555, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_26);
                      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                      __pyx_t_27 = __pyx_t_26;
                      __Pyx_INCREF(__pyx_t_27);
                      __pyx_t_5 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_27, NULL};
                        __pyx_t_25 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_asc, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                        __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                        if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 4555, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_25);
                      }
                      __pyx_t_5 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_22, __pyx_t_25};
                        __pyx_t_21 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_order_by, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 4555, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_21);
                      }
                      __pyx_t_20 = __pyx_t_21;
                      __Pyx_INCREF(__pyx_t_20);
                      __pyx_t_5 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_20, __pyx_mstate_global->__pyx_int_1};
                        __pyx_t_19 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_limit, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 4556, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_19);
                      }
                      __pyx_t_5 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_18, __pyx_t_19};
                        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalar, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4545, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_4);
                      }

                      /* "ws_package/controllers/activity_controller.py":4558
 *                             .limit(1)
 *                         ),
 *                         timeout=DB_OPERATION_TIMEOUT,             # <<<<<<<<<<<<<<
 *                     )
 * 
*/
                      __pyx_t_19 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_DB_OPERATION_TIMEOUT); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 4558, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_19);
                      __pyx_t_5 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_2))) {
                        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
                        assert(__pyx_t_3);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
                        __Pyx_INCREF(__pyx_t_3);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
                        __pyx_t_5 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_3, __pyx_t_4};
                        __pyx_t_18 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4544, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_18);
                        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_timeout, __pyx_t_19, __pyx_t_18, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 4544, __pyx_L25_error)
                        __pyx_t_1 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_18);
                        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4544, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_1);
                      }
                      __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                      if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_6);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
                        __Pyx_XGIVEREF(__pyx_t_7);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
                        __Pyx_XGIVEREF(__pyx_t_8);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
                        __Pyx_XGIVEREF(__pyx_t_9);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 2;
                        return __pyx_r;
                        __pyx_L31_resume_from_await:;
                        __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_6);
                        __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_7);
                        __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_8);
                        __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_9);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4544, __pyx_L25_error)
                        __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
                      } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_1 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 4544, __pyx_L25_error)
                      }
                      __Pyx_GIVEREF(__pyx_t_1);
                      __pyx_cur_scope->__pyx_v_first_entry = __pyx_t_1;
                      __pyx_t_1 = 0;

                      /* "ws_package/controllers/activity_controller.py":4561
 *                     )
 * 
 *                     if not first_entry:             # <<<<<<<<<<<<<<
 *                         logger.info("No unsent non-break intervals found from previous sessions")
 *                         return []
*/
                      __pyx_t_34 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_first_entry); if (unlikely((__pyx_t_34 < 0))) __PYX_ERR(0, 4561, __pyx_L25_error)
                      __pyx_t_35 = (!__pyx_t_34);
                      if (__pyx_t_35) {

                        /* "ws_package/controllers/activity_controller.py":4562
 * 
 *                     if not first_entry:
 *                         logger.info("No unsent non-break intervals found from previous sessions")             # <<<<<<<<<<<<<<
 *                         return []
 * 
*/
                        __pyx_t_2 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4562, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_18);
                        __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 4562, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_19);
                        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                        __pyx_t_5 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_19))) {
                          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_19);
                          assert(__pyx_t_2);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_19);
                          __Pyx_INCREF(__pyx_t_2);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_19, __pyx__function);
                          __pyx_t_5 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_No_unsent_non_break_intervals_fo};
                          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_19, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4562, __pyx_L25_error)
                          __Pyx_GOTREF(__pyx_t_1);
                        }
                        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

                        /* "ws_package/controllers/activity_controller.py":4563
 *                     if not first_entry:
 *                         logger.info("No unsent non-break intervals found from previous sessions")
 *                         return []             # <<<<<<<<<<<<<<
 * 
 *                     first_date = first_entry.start_time.date()
*/
                        __Pyx_XDECREF(__pyx_r);
                        __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4563, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_1);
                        __pyx_r = __pyx_t_1;
                        __pyx_t_1 = 0;
                        goto __pyx_L29_try_return;

                        /* "ws_package/controllers/activity_controller.py":4561
 *                     )
 * 
 *                     if not first_entry:             # <<<<<<<<<<<<<<
 *                         logger.info("No unsent non-break intervals found from previous sessions")
 *                         return []
*/
                      }

                      /* "ws_package/controllers/activity_controller.py":4565
 *                         return []
 * 
 *                     first_date = first_entry.start_time.date()             # <<<<<<<<<<<<<<
 *                     first_entry_counter = getattr(first_entry, 'counter', None)
 *                     logger.info(
*/
                      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_first_entry, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4565, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_2);
                      __pyx_t_19 = __pyx_t_2;
                      __Pyx_INCREF(__pyx_t_19);
                      __pyx_t_5 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_19, NULL};
                        __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_date, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4565, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_1);
                      }
                      __Pyx_GIVEREF(__pyx_t_1);
                      __pyx_cur_scope->__pyx_v_first_date = __pyx_t_1;
                      __pyx_t_1 = 0;

                      /* "ws_package/controllers/activity_controller.py":4566
 * 
 *                     first_date = first_entry.start_time.date()
 *                     first_entry_counter = getattr(first_entry, 'counter', None)             # <<<<<<<<<<<<<<
 *                     logger.info(
 *                         "Found unsent non-break intervals from %s (counter=%s)",
*/
                      __pyx_t_1 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_first_entry, __pyx_mstate_global->__pyx_n_u_counter, Py_None); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4566, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_1);
                      __Pyx_GIVEREF(__pyx_t_1);
                      __pyx_cur_scope->__pyx_v_first_entry_counter = __pyx_t_1;
                      __pyx_t_1 = 0;

                      /* "ws_package/controllers/activity_controller.py":4567
 *                     first_date = first_entry.start_time.date()
 *                     first_entry_counter = getattr(first_entry, 'counter', None)
 *                     logger.info(             # <<<<<<<<<<<<<<
 *                         "Found unsent non-break intervals from %s (counter=%s)",
 *                         first_date, first_entry_counter,
*/
                      __pyx_t_2 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 4567, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_19);
                      __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4567, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_18);
                      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;

                      /* "ws_package/controllers/activity_controller.py":4569
 *                     logger.info(
 *                         "Found unsent non-break intervals from %s (counter=%s)",
 *                         first_date, first_entry_counter,             # <<<<<<<<<<<<<<
 *                     )
 * 
*/
                      __pyx_t_5 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_18))) {
                        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_18);
                        assert(__pyx_t_2);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_18);
                        __Pyx_INCREF(__pyx_t_2);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_18, __pyx__function);
                        __pyx_t_5 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[4] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Found_unsent_non_break_intervals, __pyx_cur_scope->__pyx_v_first_date, __pyx_cur_scope->__pyx_v_first_entry_counter};
                        __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_18, __pyx_callargs+__pyx_t_5, (4-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4567, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_1);
                      }
                      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

                      /* "ws_package/controllers/activity_controller.py":4574
 *                     # Fetch all intervals for that date+counter group.
 *                     query = (
 *                         select(ActivityInterval)             # <<<<<<<<<<<<<<
 *                         .where(ActivityInterval.is_uploaded.is_(False))
 *                         .where(ActivityInterval.is_break == 0)
*/
                      __pyx_t_25 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 4574, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __Pyx_GetModuleGlobalName(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 4574, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_26);
                      __pyx_t_5 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_22))) {
                        __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_22);
                        assert(__pyx_t_25);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_22);
                        __Pyx_INCREF(__pyx_t_25);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_22, __pyx__function);
                        __pyx_t_5 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_25, __pyx_t_26};
                        __pyx_t_23 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_22, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                        __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 4574, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_23);
                      }
                      __pyx_t_20 = __pyx_t_23;
                      __Pyx_INCREF(__pyx_t_20);

                      /* "ws_package/controllers/activity_controller.py":4575
 *                     query = (
 *                         select(ActivityInterval)
 *                         .where(ActivityInterval.is_uploaded.is_(False))             # <<<<<<<<<<<<<<
 *                         .where(ActivityInterval.is_break == 0)
 *                         .where(func.date(ActivityInterval.start_time) == first_date)
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 4575, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_25);
                      __pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_is_uploaded); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 4575, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_27);
                      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                      __pyx_t_26 = __pyx_t_27;
                      __Pyx_INCREF(__pyx_t_26);
                      __pyx_t_5 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_26, Py_False};
                        __pyx_t_22 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                        __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                        if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 4575, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_22);
                      }
                      __pyx_t_5 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_20, __pyx_t_22};
                        __pyx_t_21 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 4575, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_21);
                      }
                      __pyx_t_3 = __pyx_t_21;
                      __Pyx_INCREF(__pyx_t_3);

                      /* "ws_package/controllers/activity_controller.py":4576
 *                         select(ActivityInterval)
 *                         .where(ActivityInterval.is_uploaded.is_(False))
 *                         .where(ActivityInterval.is_break == 0)             # <<<<<<<<<<<<<<
 *                         .where(func.date(ActivityInterval.start_time) == first_date)
 *                         .order_by(ActivityInterval.start_time.asc())
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 4576, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_23);
                      __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_is_break); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 4576, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                      __pyx_t_23 = __Pyx_PyLong_EqObjC(__pyx_t_22, __pyx_mstate_global->__pyx_int_0, 0, 0); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 4576, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_23);
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                      __pyx_t_5 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_23};
                        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4576, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_4);
                      }
                      __pyx_t_19 = __pyx_t_4;
                      __Pyx_INCREF(__pyx_t_19);

                      /* "ws_package/controllers/activity_controller.py":4577
 *                         .where(ActivityInterval.is_uploaded.is_(False))
 *                         .where(ActivityInterval.is_break == 0)
 *                         .where(func.date(ActivityInterval.start_time) == first_date)             # <<<<<<<<<<<<<<
 *                         .order_by(ActivityInterval.start_time.asc())
 *                     )
*/
                      __pyx_t_23 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_func_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4577, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_3);
                      __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_date); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 4577, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                      __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4577, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_3);
                      __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 4577, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_20);
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                      __pyx_t_5 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_22))) {
                        __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_22);
                        assert(__pyx_t_23);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_22);
                        __Pyx_INCREF(__pyx_t_23);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_22, __pyx__function);
                        __pyx_t_5 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_23, __pyx_t_20};
                        __pyx_t_21 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_22, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 4577, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_21);
                      }
                      __pyx_t_22 = PyObject_RichCompare(__pyx_t_21, __pyx_cur_scope->__pyx_v_first_date, Py_EQ); __Pyx_XGOTREF(__pyx_t_22); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 4577, __pyx_L25_error)
                      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                      __pyx_t_5 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_19, __pyx_t_22};
                        __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4577, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_2);
                      }
                      __pyx_t_18 = __pyx_t_2;
                      __Pyx_INCREF(__pyx_t_18);

                      /* "ws_package/controllers/activity_controller.py":4578
 *                         .where(ActivityInterval.is_break == 0)
 *                         .where(func.date(ActivityInterval.start_time) == first_date)
 *                         .order_by(ActivityInterval.start_time.asc())             # <<<<<<<<<<<<<<
 *                     )
 *                     if first_entry_counter is not None:
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 4578, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_19);
                      __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 4578, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                      __pyx_t_22 = __pyx_t_21;
                      __Pyx_INCREF(__pyx_t_22);
                      __pyx_t_5 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_22, NULL};
                        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_asc, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4578, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_4);
                      }
                      __pyx_t_5 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_18, __pyx_t_4};
                        __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_order_by, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4578, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_1);
                      }
                      __Pyx_GIVEREF(__pyx_t_1);
                      __pyx_cur_scope->__pyx_v_query = __pyx_t_1;
                      __pyx_t_1 = 0;

                      /* "ws_package/controllers/activity_controller.py":4580
 *                         .order_by(ActivityInterval.start_time.asc())
 *                     )
 *                     if first_entry_counter is not None:             # <<<<<<<<<<<<<<
 *                         query = query.where(ActivityInterval.counter == first_entry_counter)
 *                         logger.info(
*/
                      __pyx_t_35 = (__pyx_cur_scope->__pyx_v_first_entry_counter != Py_None);
                      if (__pyx_t_35) {

                        /* "ws_package/controllers/activity_controller.py":4581
 *                     )
 *                     if first_entry_counter is not None:
 *                         query = query.where(ActivityInterval.counter == first_entry_counter)             # <<<<<<<<<<<<<<
 *                         logger.info(
 *                             "Filtering by counter=%s to keep session intervals together",
*/
                        __pyx_t_2 = __pyx_cur_scope->__pyx_v_query;
                        __Pyx_INCREF(__pyx_t_2);
                        __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4581, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_4);
                        __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4581, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_18);
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __pyx_t_4 = PyObject_RichCompare(__pyx_t_18, __pyx_cur_scope->__pyx_v_first_entry_counter, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4581, __pyx_L25_error)
                        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                        __pyx_t_5 = 0;
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_4};
                          __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4581, __pyx_L25_error)
                          __Pyx_GOTREF(__pyx_t_1);
                        }
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_query);
                        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_query, __pyx_t_1);
                        __Pyx_GIVEREF(__pyx_t_1);
                        __pyx_t_1 = 0;

                        /* "ws_package/controllers/activity_controller.py":4582
 *                     if first_entry_counter is not None:
 *                         query = query.where(ActivityInterval.counter == first_entry_counter)
 *                         logger.info(             # <<<<<<<<<<<<<<
 *                             "Filtering by counter=%s to keep session intervals together",
 *                             first_entry_counter,
*/
                        __pyx_t_4 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4582, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_2);
                        __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4582, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_18);
                        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

                        /* "ws_package/controllers/activity_controller.py":4584
 *                         logger.info(
 *                             "Filtering by counter=%s to keep session intervals together",
 *                             first_entry_counter,             # <<<<<<<<<<<<<<
 *                         )
 * 
*/
                        __pyx_t_5 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_18))) {
                          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_18);
                          assert(__pyx_t_4);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_18);
                          __Pyx_INCREF(__pyx_t_4);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_18, __pyx__function);
                          __pyx_t_5 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Filtering_by_counter_s_to_keep_s, __pyx_cur_scope->__pyx_v_first_entry_counter};
                          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_18, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4582, __pyx_L25_error)
                          __Pyx_GOTREF(__pyx_t_1);
                        }
                        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

                        /* "ws_package/controllers/activity_controller.py":4580
 *                         .order_by(ActivityInterval.start_time.asc())
 *                     )
 *                     if first_entry_counter is not None:             # <<<<<<<<<<<<<<
 *                         query = query.where(ActivityInterval.counter == first_entry_counter)
 *                         logger.info(
*/
                      }

                      /* "ws_package/controllers/activity_controller.py":4587
 *                         )
 * 
 *                     result = await asyncio.wait_for(             # <<<<<<<<<<<<<<
 *                         session.scalars(query),
 *                         timeout=DB_OPERATION_TIMEOUT,
*/
                      __pyx_t_18 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4587, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_wait_for); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4587, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_2);
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                      /* "ws_package/controllers/activity_controller.py":4588
 * 
 *                     result = await asyncio.wait_for(
 *                         session.scalars(query),             # <<<<<<<<<<<<<<
 *                         timeout=DB_OPERATION_TIMEOUT,
 *                     )
*/
                      __pyx_t_21 = __pyx_cur_scope->__pyx_v_session;
                      __Pyx_INCREF(__pyx_t_21);
                      __pyx_t_5 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_21, __pyx_cur_scope->__pyx_v_query};
                        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalars, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4588, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_4);
                      }

                      /* "ws_package/controllers/activity_controller.py":4589
 *                     result = await asyncio.wait_for(
 *                         session.scalars(query),
 *                         timeout=DB_OPERATION_TIMEOUT,             # <<<<<<<<<<<<<<
 *                     )
 *                     intervals = result.all()
*/
                      __pyx_t_21 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_DB_OPERATION_TIMEOUT); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 4589, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __pyx_t_5 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_2))) {
                        __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_2);
                        assert(__pyx_t_18);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
                        __Pyx_INCREF(__pyx_t_18);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
                        __pyx_t_5 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_18, __pyx_t_4};
                        __pyx_t_22 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 4587, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_22);
                        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_timeout, __pyx_t_21, __pyx_t_22, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 4587, __pyx_L25_error)
                        __pyx_t_1 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_22);
                        __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4587, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_1);
                      }
                      __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                      if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_6);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
                        __Pyx_XGIVEREF(__pyx_t_7);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
                        __Pyx_XGIVEREF(__pyx_t_8);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
                        __Pyx_XGIVEREF(__pyx_t_9);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 3;
                        return __pyx_r;
                        __pyx_L34_resume_from_await:;
                        __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_6);
                        __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_7);
                        __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_8);
                        __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_9);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4587, __pyx_L25_error)
                        __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
                      } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_1 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 4587, __pyx_L25_error)
                      }
                      __Pyx_GIVEREF(__pyx_t_1);
                      __pyx_cur_scope->__pyx_v_result = __pyx_t_1;
                      __pyx_t_1 = 0;

                      /* "ws_package/controllers/activity_controller.py":4591
 *                         timeout=DB_OPERATION_TIMEOUT,
 *                     )
 *                     intervals = result.all()             # <<<<<<<<<<<<<<
 *                     logger.info(
 *                         "Retrieved %d unsent non-break interval(s) from %s (counter=%s)",
*/
                      __pyx_t_2 = __pyx_cur_scope->__pyx_v_result;
                      __Pyx_INCREF(__pyx_t_2);
                      __pyx_t_5 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
                        __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_all, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4591, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_1);
                      }
                      __Pyx_GIVEREF(__pyx_t_1);
                      __pyx_cur_scope->__pyx_v_intervals = __pyx_t_1;
                      __pyx_t_1 = 0;

                      /* "ws_package/controllers/activity_controller.py":4592
 *                     )
 *                     intervals = result.all()
 *                     logger.info(             # <<<<<<<<<<<<<<
 *                         "Retrieved %d unsent non-break interval(s) from %s (counter=%s)",
 *                         len(intervals), first_date, first_entry_counter,
*/
                      __pyx_t_2 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 4592, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 4592, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;

                      /* "ws_package/controllers/activity_controller.py":4594
 *                     logger.info(
 *                         "Retrieved %d unsent non-break interval(s) from %s (counter=%s)",
 *                         len(intervals), first_date, first_entry_counter,             # <<<<<<<<<<<<<<
 *                     )
 *                     return intervals
*/
                      __pyx_t_36 = PyObject_Length(__pyx_cur_scope->__pyx_v_intervals); if (unlikely(__pyx_t_36 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4594, __pyx_L25_error)
                      __pyx_t_22 = PyLong_FromSsize_t(__pyx_t_36); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 4594, __pyx_L25_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __pyx_t_5 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_21))) {
                        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_21);
                        assert(__pyx_t_2);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_21);
                        __Pyx_INCREF(__pyx_t_2);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_21, __pyx__function);
                        __pyx_t_5 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[5] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Retrieved_d_unsent_non_break_int, __pyx_t_22, __pyx_cur_scope->__pyx_v_first_date, __pyx_cur_scope->__pyx_v_first_entry_counter};
                        __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_21, __pyx_callargs+__pyx_t_5, (5-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4592, __pyx_L25_error)
                        __Pyx_GOTREF(__pyx_t_1);
                      }
                      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

                      /* "ws_package/controllers/activity_controller.py":4596
 *                         len(intervals), first_date, first_entry_counter,
 *                     )
 *                     return intervals             # <<<<<<<<<<<<<<
 * 
 *                 except asyncio.TimeoutError:
*/
                      __Pyx_XDECREF(__pyx_r);
                      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_intervals);
                      __pyx_r = __pyx_cur_scope->__pyx_v_intervals;
                      goto __pyx_L29_try_return;

                      /* "ws_package/controllers/activity_controller.py":4541
 *         with db_lock_manager.read_lock():
 *             async with async_session() as session:
 *                 try:             # <<<<<<<<<<<<<<
 *                     # Find the oldest eligible interval.
 *                     # Eligible = (any previous day) OR (today but earlier session counter).
*/
                    }
                    __pyx_L25_error:;
                    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                    __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                    __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                    __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                    __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
                    __Pyx_XDECREF(__pyx_t_29); __pyx_t_29 = 0;
                    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                    __Pyx_XDECREF(__pyx_t_30); __pyx_t_30 = 0;
                    __Pyx_XDECREF(__pyx_t_31); __pyx_t_31 = 0;
                    __Pyx_XDECREF(__pyx_t_32); __pyx_t_32 = 0;
                    __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

                    /* "ws_package/controllers/activity_controller.py":4598
 *                     return intervals
 * 
 *                 except asyncio.TimeoutError:             # <<<<<<<<<<<<<<
 *                     logger.error(
 *                         "Database query timed out after %ss in getting_unsent_interval",
*/
                    __Pyx_ErrFetch(&__pyx_t_1, &__pyx_t_21, &__pyx_t_22);
                    __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4598, __pyx_L27_except_error)
                    __Pyx_GOTREF(__pyx_t_2);
                    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_TimeoutError); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4598, __pyx_L27_except_error)
                    __Pyx_GOTREF(__pyx_t_4);
                    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                    __pyx_t_37 = __Pyx_PyErr_GivenExceptionMatches(__pyx_t_1, __pyx_t_4);
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_ErrRestore(__pyx_t_1, __pyx_t_21, __pyx_t_22);
                    __pyx_t_1 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0;
                    if (__pyx_t_37) {
                      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.getting_unsent_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_22, &__pyx_t_21, &__pyx_t_1) < 0) __PYX_ERR(0, 4598, __pyx_L27_except_error)
                      __Pyx_XGOTREF(__pyx_t_22);
                      __Pyx_XGOTREF(__pyx_t_21);
                      __Pyx_XGOTREF(__pyx_t_1);

                      /* "ws_package/controllers/activity_controller.py":4599
 * 
 *                 except asyncio.TimeoutError:
 *                     logger.error(             # <<<<<<<<<<<<<<
 *                         "Database query timed out after %ss in getting_unsent_interval",
 *                         DB_OPERATION_TIMEOUT,
*/
                      __pyx_t_2 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4599, __pyx_L27_except_error)
                      __Pyx_GOTREF(__pyx_t_18);
                      __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 4599, __pyx_L27_except_error)
                      __Pyx_GOTREF(__pyx_t_19);
                      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

                      /* "ws_package/controllers/activity_controller.py":4601
 *                     logger.error(
 *                         "Database query timed out after %ss in getting_unsent_interval",
 *                         DB_OPERATION_TIMEOUT,             # <<<<<<<<<<<<<<
 *                     )
 *                     return []
*/
                      __pyx_t_18 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_DB_OPERATION_TIMEOUT); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4601, __pyx_L27_except_error)
                      __Pyx_GOTREF(__pyx_t_18);
                      __pyx_t_5 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_19))) {
                        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_19);
                        assert(__pyx_t_2);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_19);
                        __Pyx_INCREF(__pyx_t_2);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_19, __pyx__function);
                        __pyx_t_5 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Database_query_timed_out_after_s_5, __pyx_t_18};
                        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_19, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4599, __pyx_L27_except_error)
                        __Pyx_GOTREF(__pyx_t_4);
                      }
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                      /* "ws_package/controllers/activity_controller.py":4603
 *                         DB_OPERATION_TIMEOUT,
 *                     )
 *                     return []             # <<<<<<<<<<<<<<
 *                 except Exception as e:
 *                     logger.error("Error getting unsent intervals: %s", e)
*/
                      __Pyx_XDECREF(__pyx_r);
                      __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4603, __pyx_L27_except_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __pyx_r = __pyx_t_4;
                      __pyx_t_4 = 0;
                      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                      goto __pyx_L28_except_return;
                    }

                    /* "ws_package/controllers/activity_controller.py":4604
 *                     )
 *                     return []
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Error getting unsent intervals: %s", e)
 *                     return []
*/
                    __pyx_t_37 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                    if (__pyx_t_37) {
                      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.getting_unsent_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_21, &__pyx_t_22) < 0) __PYX_ERR(0, 4604, __pyx_L27_except_error)
                      __Pyx_XGOTREF(__pyx_t_1);
                      __Pyx_XGOTREF(__pyx_t_21);
                      __Pyx_XGOTREF(__pyx_t_22);
                      __Pyx_INCREF(__pyx_t_21);
                      __Pyx_GIVEREF(__pyx_t_21);
                      __pyx_cur_scope->__pyx_v_e = __pyx_t_21;
                      /*try:*/ {

                        /* "ws_package/controllers/activity_controller.py":4605
 *                     return []
 *                 except Exception as e:
 *                     logger.error("Error getting unsent intervals: %s", e)             # <<<<<<<<<<<<<<
 *                     return []
 * 
*/
                        __pyx_t_19 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4605, __pyx_L42_error)
                        __Pyx_GOTREF(__pyx_t_18);
                        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4605, __pyx_L42_error)
                        __Pyx_GOTREF(__pyx_t_2);
                        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                        __pyx_t_5 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_2))) {
                          __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_2);
                          assert(__pyx_t_19);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
                          __Pyx_INCREF(__pyx_t_19);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
                          __pyx_t_5 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[3] = {__pyx_t_19, __pyx_mstate_global->__pyx_kp_u_Error_getting_unsent_intervals_s, __pyx_cur_scope->__pyx_v_e};
                          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4605, __pyx_L42_error)
                          __Pyx_GOTREF(__pyx_t_4);
                        }
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                        /* "ws_package/controllers/activity_controller.py":4606
 *                 except Exception as e:
 *                     logger.error("Error getting unsent intervals: %s", e)
 *                     return []             # <<<<<<<<<<<<<<
 * 
 *     async def sending_unsent_intervals(self, start, prev_day_unsent, user_entity: UserEntity):
*/
                        __Pyx_XDECREF(__pyx_r);
                        __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4606, __pyx_L42_error)
                        __Pyx_GOTREF(__pyx_t_4);
                        __pyx_r = __pyx_t_4;
                        __pyx_t_4 = 0;
                        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        goto __pyx_L41_return;
                      }

                      /* "ws_package/controllers/activity_controller.py":4604
 *                     )
 *                     return []
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Error getting unsent intervals: %s", e)
 *                     return []
*/
                      /*finally:*/ {
                        __pyx_L42_error:;
                        /*exception exit:*/{
                          __Pyx_PyThreadState_assign
                          __pyx_t_40 = 0; __pyx_t_41 = 0; __pyx_t_42 = 0; __pyx_t_43 = 0; __pyx_t_44 = 0; __pyx_t_45 = 0;
                          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                          __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                          __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                          __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                          __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                          __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                          __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                          __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
                          __Pyx_XDECREF(__pyx_t_29); __pyx_t_29 = 0;
                          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                          __Pyx_XDECREF(__pyx_t_30); __pyx_t_30 = 0;
                          __Pyx_XDECREF(__pyx_t_31); __pyx_t_31 = 0;
                          __Pyx_XDECREF(__pyx_t_32); __pyx_t_32 = 0;
                          __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                           __Pyx_ExceptionSwap(&__pyx_t_43, &__pyx_t_44, &__pyx_t_45);
                          if ( unlikely(__Pyx_GetException(&__pyx_t_40, &__pyx_t_41, &__pyx_t_42) < 0)) __Pyx_ErrFetch(&__pyx_t_40, &__pyx_t_41, &__pyx_t_42);
                          __Pyx_XGOTREF(__pyx_t_40);
                          __Pyx_XGOTREF(__pyx_t_41);
                          __Pyx_XGOTREF(__pyx_t_42);
                          __Pyx_XGOTREF(__pyx_t_43);
                          __Pyx_XGOTREF(__pyx_t_44);
                          __Pyx_XGOTREF(__pyx_t_45);
                          __pyx_t_37 = __pyx_lineno; __pyx_t_38 = __pyx_clineno; __pyx_t_39 = __pyx_filename;
                          {
                            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                          }
                          __Pyx_XGIVEREF(__pyx_t_43);
                          __Pyx_XGIVEREF(__pyx_t_44);
                          __Pyx_XGIVEREF(__pyx_t_45);
                          __Pyx_ExceptionReset(__pyx_t_43, __pyx_t_44, __pyx_t_45);
                          __Pyx_XGIVEREF(__pyx_t_40);
                          __Pyx_XGIVEREF(__pyx_t_41);
                          __Pyx_XGIVEREF(__pyx_t_42);
                          __Pyx_ErrRestore(__pyx_t_40, __pyx_t_41, __pyx_t_42);
                          __pyx_t_40 = 0; __pyx_t_41 = 0; __pyx_t_42 = 0; __pyx_t_43 = 0; __pyx_t_44 = 0; __pyx_t_45 = 0;
                          __pyx_lineno = __pyx_t_37; __pyx_clineno = __pyx_t_38; __pyx_filename = __pyx_t_39;
                          goto __pyx_L27_except_error;
                        }
                        __pyx_L41_return: {
                          __pyx_t_45 = __pyx_r;
                          __pyx_r = 0;
                          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                          __pyx_r = __pyx_t_45;
                          __pyx_t_45 = 0;
                          goto __pyx_L28_except_return;
                        }
                      }
                    }
                    goto __pyx_L27_except_error;

                    /* "ws_package/controllers/activity_controller.py":4541
 *         with db_lock_manager.read_lock():
 *             async with async_session() as session:
 *                 try:             # <<<<<<<<<<<<<<
 *                     # Find the oldest eligible interval.
 *                     # Eligible = (any previous day) OR (today but earlier session counter).
*/
                    __pyx_L27_except_error:;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
                    goto __pyx_L19_error;
                    __pyx_L29_try_return:;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
                    goto __pyx_L23_try_return;
                    __pyx_L28_except_return:;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
                    goto __pyx_L23_try_return;
                  }

                  /* "ws_package/controllers/activity_controller.py":4540
 * 
 *         with db_lock_manager.read_lock():
 *             async with async_session() as session:             # <<<<<<<<<<<<<<
 *                 try:
 *                     # Find the oldest eligible interval.
*/
                }
                __pyx_L19_error:;
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
                __Pyx_XDECREF(__pyx_t_29); __pyx_t_29 = 0;
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_XDECREF(__pyx_t_30); __pyx_t_30 = 0;
                __Pyx_XDECREF(__pyx_t_31); __pyx_t_31 = 0;
                __Pyx_XDECREF(__pyx_t_32); __pyx_t_32 = 0;
                __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                /*except:*/ {
                  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.getting_unsent_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
                  if (__Pyx_GetException(&__pyx_t_22, &__pyx_t_21, &__pyx_t_1) < 0) __PYX_ERR(0, 4540, __pyx_L21_except_error)
                  __Pyx_XGOTREF(__pyx_t_22);
                  __Pyx_XGOTREF(__pyx_t_21);
                  __Pyx_XGOTREF(__pyx_t_1);
                  __pyx_t_4 = PyTuple_Pack(3, __pyx_t_22, __pyx_t_21, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4540, __pyx_L21_except_error)
                  __Pyx_GOTREF(__pyx_t_4);
                  __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_4, NULL);
                  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4540, __pyx_L21_except_error)
                  __Pyx_GOTREF(__pyx_t_17);
                  __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_17, &__pyx_r);
                  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                  if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_XGIVEREF(__pyx_t_1);
                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                    __Pyx_XGIVEREF(__pyx_t_6);
                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
                    __Pyx_XGIVEREF(__pyx_t_7);
                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
                    __Pyx_XGIVEREF(__pyx_t_8);
                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_8;
                    __Pyx_XGIVEREF(__pyx_t_9);
                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_9;
                    __Pyx_XGIVEREF(__pyx_t_10);
                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_10;
                    __Pyx_XGIVEREF(__pyx_t_12);
                    __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
                    __Pyx_XGIVEREF(__pyx_t_13);
                    __pyx_cur_scope->__pyx_t_7 = __pyx_t_13;
                    __Pyx_XGIVEREF(__pyx_t_14);
                    __pyx_cur_scope->__pyx_t_8 = __pyx_t_14;
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __pyx_cur_scope->__pyx_t_9 = __pyx_t_17;
                    __Pyx_XGIVEREF(__pyx_t_21);
                    __pyx_cur_scope->__pyx_t_10 = __pyx_t_21;
                    __Pyx_XGIVEREF(__pyx_t_22);
                    __pyx_cur_scope->__pyx_t_11 = __pyx_t_22;
                    __Pyx_XGIVEREF(__pyx_r);
                    __Pyx_RefNannyFinishContext();
                    __Pyx_Coroutine_SwapException(__pyx_generator);
                    /* return from generator, awaiting value */
                    __pyx_generator->resume_label = 4;
                    return __pyx_r;
                    __pyx_L51_resume_from_await:;
                    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                    __pyx_cur_scope->__pyx_t_0 = 0;
                    __Pyx_XGOTREF(__pyx_t_1);
                    __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
                    __pyx_cur_scope->__pyx_t_1 = 0;
                    __Pyx_XGOTREF(__pyx_t_6);
                    __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
                    __pyx_cur_scope->__pyx_t_2 = 0;
                    __Pyx_XGOTREF(__pyx_t_7);
                    __pyx_t_8 = __pyx_cur_scope->__pyx_t_3;
                    __pyx_cur_scope->__pyx_t_3 = 0;
                    __Pyx_XGOTREF(__pyx_t_8);
                    __pyx_t_9 = __pyx_cur_scope->__pyx_t_4;
                    __pyx_cur_scope->__pyx_t_4 = 0;
                    __Pyx_XGOTREF(__pyx_t_9);
                    __pyx_t_10 = __pyx_cur_scope->__pyx_t_5;
                    __pyx_cur_scope->__pyx_t_5 = 0;
                    __Pyx_XGOTREF(__pyx_t_10);
                    __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
                    __pyx_cur_scope->__pyx_t_6 = 0;
                    __Pyx_XGOTREF(__pyx_t_12);
                    __pyx_t_13 = __pyx_cur_scope->__pyx_t_7;
                    __pyx_cur_scope->__pyx_t_7 = 0;
                    __Pyx_XGOTREF(__pyx_t_13);
                    __pyx_t_14 = __pyx_cur_scope->__pyx_t_8;
                    __pyx_cur_scope->__pyx_t_8 = 0;
                    __Pyx_XGOTREF(__pyx_t_14);
                    __pyx_t_17 = __pyx_cur_scope->__pyx_t_9;
                    __pyx_cur_scope->__pyx_t_9 = 0;
                    __Pyx_XGOTREF(__pyx_t_17);
                    __pyx_t_21 = __pyx_cur_scope->__pyx_t_10;
                    __pyx_cur_scope->__pyx_t_10 = 0;
                    __Pyx_XGOTREF(__pyx_t_21);
                    __pyx_t_22 = __pyx_cur_scope->__pyx_t_11;
                    __pyx_cur_scope->__pyx_t_11 = 0;
                    __Pyx_XGOTREF(__pyx_t_22);
                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4540, __pyx_L21_except_error)
                    __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                  } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                    __Pyx_GOTREF(__pyx_r);
                    __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                  } else {
                    __Pyx_XGOTREF(__pyx_r);
                    __PYX_ERR(0, 4540, __pyx_L21_except_error)
                  }
                  __pyx_t_17 = __pyx_t_4;
                  __pyx_t_4 = 0;
                  __pyx_t_35 = __Pyx_PyObject_IsTrue(__pyx_t_17);
                  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                  if (__pyx_t_35 < (0)) __PYX_ERR(0, 4540, __pyx_L21_except_error)
                  __pyx_t_34 = (!__pyx_t_35);
                  if (unlikely(__pyx_t_34)) {
                    __Pyx_GIVEREF(__pyx_t_22);
                    __Pyx_GIVEREF(__pyx_t_21);
                    __Pyx_XGIVEREF(__pyx_t_1);
                    __Pyx_ErrRestoreWithState(__pyx_t_22, __pyx_t_21, __pyx_t_1);
                    __pyx_t_22 = 0;  __pyx_t_21 = 0;  __pyx_t_1 = 0; 
                    __PYX_ERR(0, 4540, __pyx_L21_except_error)
                  }
                  __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                  __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                  goto __pyx_L20_exception_handled;
                }
                __pyx_L21_except_error:;
                __Pyx_XGIVEREF(__pyx_t_12);
                __Pyx_XGIVEREF(__pyx_t_13);
                __Pyx_XGIVEREF(__pyx_t_14);
                __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
                goto __pyx_L8_error;
                __pyx_L23_try_return:;
                __Pyx_XGIVEREF(__pyx_t_12);
                __Pyx_XGIVEREF(__pyx_t_13);
                __Pyx_XGIVEREF(__pyx_t_14);
                __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
                goto __pyx_L16_return;
                __pyx_L20_exception_handled:;
                __Pyx_XGIVEREF(__pyx_t_12);
                __Pyx_XGIVEREF(__pyx_t_13);
                __Pyx_XGIVEREF(__pyx_t_14);
                __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
              }
            }
            /*finally:*/ {
              /*normal exit:*/{
                if (__pyx_t_10) {
                  __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_mstate_global->__pyx_tuple[7], NULL);
                  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                  if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4540, __pyx_L8_error)
                  __Pyx_GOTREF(__pyx_t_14);
                  __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_14, &__pyx_r);
                  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                  if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_XGIVEREF(__pyx_t_6);
                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
                    __Pyx_XGIVEREF(__pyx_t_7);
                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
                    __Pyx_XGIVEREF(__pyx_t_8);
                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
                    __Pyx_XGIVEREF(__pyx_t_9);
                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
                    __Pyx_XGIVEREF(__pyx_t_10);
                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                    __Pyx_XGIVEREF(__pyx_t_14);
                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                    __Pyx_XGIVEREF(__pyx_r);
                    __Pyx_RefNannyFinishContext();
                    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                    /* return from generator, awaiting value */
                    __pyx_generator->resume_label = 5;
                    return __pyx_r;
                    __pyx_L52_resume_from_await:;
                    __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
                    __pyx_cur_scope->__pyx_t_0 = 0;
                    __Pyx_XGOTREF(__pyx_t_6);
                    __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
                    __pyx_cur_scope->__pyx_t_1 = 0;
                    __Pyx_XGOTREF(__pyx_t_7);
                    __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
                    __pyx_cur_scope->__pyx_t_2 = 0;
                    __Pyx_XGOTREF(__pyx_t_8);
                    __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
                    __pyx_cur_scope->__pyx_t_3 = 0;
                    __Pyx_XGOTREF(__pyx_t_9);
                    __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                    __pyx_cur_scope->__pyx_t_4 = 0;
                    __Pyx_XGOTREF(__pyx_t_10);
                    __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                    __pyx_cur_scope->__pyx_t_5 = 0;
                    __Pyx_XGOTREF(__pyx_t_14);
                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4540, __pyx_L8_error)
                    __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
                  } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                    __Pyx_GOTREF(__pyx_r);
                    __pyx_t_1 = __pyx_r; __pyx_r = NULL;
                  } else {
                    __Pyx_XGOTREF(__pyx_r);
                    __PYX_ERR(0, 4540, __pyx_L8_error)
                  }
                  __pyx_t_14 = __pyx_t_1;
                  __pyx_t_1 = 0;
                  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                }
                goto __pyx_L18;
              }
              __pyx_L16_return: {
                __pyx_t_14 = __pyx_r;
                __pyx_r = 0;
                if (__pyx_t_10) {
                  __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_mstate_global->__pyx_tuple[7], NULL);
                  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                  if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4540, __pyx_L8_error)
                  __Pyx_GOTREF(__pyx_t_13);
                  __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_13, &__pyx_r);
                  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                  if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_XGIVEREF(__pyx_t_6);
                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
                    __Pyx_XGIVEREF(__pyx_t_7);
                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
                    __Pyx_XGIVEREF(__pyx_t_8);
                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
                    __Pyx_XGIVEREF(__pyx_t_9);
                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
                    __Pyx_XGIVEREF(__pyx_t_10);
                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                    __Pyx_XGIVEREF(__pyx_t_13);
                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                    __Pyx_XGIVEREF(__pyx_t_14);
                    __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                    __Pyx_XGIVEREF(__pyx_r);
                    __Pyx_RefNannyFinishContext();
                    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                    /* return from generator, awaiting value */
                    __pyx_generator->resume_label = 6;
                    return __pyx_r;
                    __pyx_L53_resume_from_await:;
                    __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
                    __pyx_cur_scope->__pyx_t_0 = 0;
                    __Pyx_XGOTREF(__pyx_t_6);
                    __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
                    __pyx_cur_scope->__pyx_t_1 = 0;
                    __Pyx_XGOTREF(__pyx_t_7);
                    __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
                    __pyx_cur_scope->__pyx_t_2 = 0;
                    __Pyx_XGOTREF(__pyx_t_8);
                    __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
                    __pyx_cur_scope->__pyx_t_3 = 0;
                    __Pyx_XGOTREF(__pyx_t_9);
                    __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                    __pyx_cur_scope->__pyx_t_4 = 0;
                    __Pyx_XGOTREF(__pyx_t_10);
                    __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                    __pyx_cur_scope->__pyx_t_5 = 0;
                    __Pyx_XGOTREF(__pyx_t_13);
                    __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                    __pyx_cur_scope->__pyx_t_6 = 0;
                    __Pyx_XGOTREF(__pyx_t_14);
                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4540, __pyx_L8_error)
                    __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
                  } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                    __Pyx_GOTREF(__pyx_r);
                    __pyx_t_1 = __pyx_r; __pyx_r = NULL;
                  } else {
                    __Pyx_XGOTREF(__pyx_r);
                    __PYX_ERR(0, 4540, __pyx_L8_error)
                  }
                  __pyx_t_13 = __pyx_t_1;
                  __pyx_t_1 = 0;
                  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                }
                __pyx_r = __pyx_t_14;
                __pyx_t_14 = 0;
                goto __pyx_L12_try_return;
              }
              __pyx_L18:;
            }
            goto __pyx_L54;
            __pyx_L14_error:;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            goto __pyx_L8_error;
            __pyx_L54:;
          }

          /* "ws_package/controllers/activity_controller.py":4539
 *         current_counter = self.last_count + 1
 * 
 *         with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *             async with async_session() as session:
 *                 try:
*/
        }
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L13_try_end;
        __pyx_L8_error:;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
        __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
        __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
        __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
        __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
        __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
        __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
        __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
        __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
        __Pyx_XDECREF(__pyx_t_28); __pyx_t_28 = 0;
        __Pyx_XDECREF(__pyx_t_29); __pyx_t_29 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_30); __pyx_t_30 = 0;
        __Pyx_XDECREF(__pyx_t_31); __pyx_t_31 = 0;
        __Pyx_XDECREF(__pyx_t_32); __pyx_t_32 = 0;
        __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        /*except:*/ {
          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.getting_unsent_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_21, &__pyx_t_22) < 0) __PYX_ERR(0, 4539, __pyx_L10_except_error)
          __Pyx_XGOTREF(__pyx_t_1);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_22);
          __pyx_t_4 = PyTuple_Pack(3, __pyx_t_1, __pyx_t_21, __pyx_t_22); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4539, __pyx_L10_except_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, NULL);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4539, __pyx_L10_except_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_34 = __Pyx_PyObject_IsTrue(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (__pyx_t_34 < (0)) __PYX_ERR(0, 4539, __pyx_L10_except_error)
          __pyx_t_35 = (!__pyx_t_34);
          if (unlikely(__pyx_t_35)) {
            __Pyx_GIVEREF(__pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_21);
            __Pyx_XGIVEREF(__pyx_t_22);
            __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_21, __pyx_t_22);
            __pyx_t_1 = 0;  __pyx_t_21 = 0;  __pyx_t_22 = 0; 
            __PYX_ERR(0, 4539, __pyx_L10_except_error)
          }
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
          __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
          goto __pyx_L9_exception_handled;
        }
        __pyx_L10_except_error:;
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
        goto __pyx_L1_error;
        __pyx_L12_try_return:;
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
        goto __pyx_L5_return;
        __pyx_L9_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
        __pyx_L13_try_end:;
      }
    }
    /*finally:*/ {
      /*normal exit:*/{
        if (__pyx_t_6) {
          __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_mstate_global->__pyx_tuple[7], NULL);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4539, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        }
        goto __pyx_L7;
      }
      __pyx_L5_return: {
        __pyx_t_9 = __pyx_r;
        __pyx_r = 0;
        if (__pyx_t_6) {
          __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_mstate_global->__pyx_tuple[7], NULL);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4539, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        }
        __pyx_r = __pyx_t_9;
        __pyx_t_9 = 0;
        goto __pyx_L0;
      }
      __pyx_L7:;
    }
    goto __pyx_L58;
    __pyx_L4_error:;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L1_error;
    __pyx_L58:;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":4512
 *             # Continue processing - don't fail the entire operation
 * 
 *     async def getting_unsent_interval(self, user_entity: UserEntity):             # <<<<<<<<<<<<<<
 *         """Return unsent (``is_uploaded=False``) non-break activity intervals eligible for upload.
 * 
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_XDECREF(__pyx_t_23);
  __Pyx_XDECREF(__pyx_t_24);
  __Pyx_XDECREF(__pyx_t_25);
  __Pyx_XDECREF(__pyx_t_26);
  __Pyx_XDECREF(__pyx_t_27);
  __Pyx_XDECREF(__pyx_t_28);
  __Pyx_XDECREF(__pyx_t_29);
  __Pyx_XDECREF(__pyx_t_30);
  __Pyx_XDECREF(__pyx_t_31);
  __Pyx_XDECREF(__pyx_t_32);
  __Pyx_XDECREF(__pyx_t_33);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("getting_unsent_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_165generator33(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":4608
 *                     return []
 * 
 *     async def sending_unsent_intervals(self, start, prev_day_unsent, user_entity: UserEntity):             # <<<<<<<<<<<<<<
 *         logger.info("Sending previous day unsent intervals")
 *         try:
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_164sending_unsent_intervals(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_164sending_unsent_intervals = {"sending_unsent_intervals", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_164sending_unsent_intervals, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_164sending_unsent_intervals(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_start = 0;
  PyObject *__pyx_v_prev_day_unsent = 0;
  PyObject *__pyx_v_user_entity = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[4] = {0,0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sending_unsent_intervals (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_start,&__pyx_mstate_global->__pyx_n_u_prev_day_unsent,&__pyx_mstate_global->__pyx_n_u_user_entity,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 4608, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  4:
        values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 4608, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 4608, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 4608, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4608, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "sending_unsent_intervals", 0) < (0)) __PYX_ERR(0, 4608, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 4; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("sending_unsent_intervals", 1, 4, 4, i); __PYX_ERR(0, 4608, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 4)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4608, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 4608, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 4608, __pyx_L3_error)
      values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 4608, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_start = values[1];
    __pyx_v_prev_day_unsent = values[2];
    __pyx_v_user_entity = values[3];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("sending_unsent_intervals", 1, 4, 4, __pyx_nargs); __PYX_ERR(0, 4608, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.sending_unsent_intervals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_163sending_unsent_intervals(__pyx_self, __pyx_v_self, __pyx_v_start, __pyx_v_prev_day_unsent, __pyx_v_user_entity);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_163sending_unsent_intervals(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_start, PyObject *__pyx_v_prev_day_unsent, PyObject *__pyx_v_user_entity) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sending_unsent_intervals", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 4608, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_start = __pyx_v_start;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_start);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_start);
  __pyx_cur_scope->__pyx_v_prev_day_unsent = __pyx_v_prev_day_unsent;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_prev_day_unsent);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_prev_day_unsent);
  __pyx_cur_scope->__pyx_v_user_entity = __pyx_v_user_entity;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_user_entity);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_user_entity);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_165generator33, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[53]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_sending_unsent_intervals, __pyx_mstate_global->__pyx_n_u_ActivityController_sending_unsen, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 4608, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.sending_unsent_intervals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_165generator33(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_t_10;
  Py_ssize_t __pyx_t_11;
  PyObject *(*__pyx_t_12)(PyObject *);
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  __Pyx_PySendResult __pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_t_18;
  int __pyx_t_19;
  Py_ssize_t __pyx_t_20;
  int __pyx_t_21;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  int __pyx_t_24;
  char const *__pyx_t_25;
  PyObject *__pyx_t_26 = NULL;
  PyObject *__pyx_t_27 = NULL;
  PyObject *__pyx_t_28 = NULL;
  PyObject *__pyx_t_29 = NULL;
  PyObject *__pyx_t_30 = NULL;
  PyObject *__pyx_t_31 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sending_unsent_intervals", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L19_resume_from_await;
    case 2: goto __pyx_L20_resume_from_await;
    case 3: goto __pyx_L40_resume_from_await;
    case 4: goto __pyx_L45_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 4608, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":4609
 * 
 *     async def sending_unsent_intervals(self, start, prev_day_unsent, user_entity: UserEntity):
 *         logger.info("Sending previous day unsent intervals")             # <<<<<<<<<<<<<<
 *         try:
 *             # Handle both single entity and list/iterable
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4609, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4609, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Sending_previous_day_unsent_inte};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4609, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":4610
 *     async def sending_unsent_intervals(self, start, prev_day_unsent, user_entity: UserEntity):
 *         logger.info("Sending previous day unsent intervals")
 *         try:             # <<<<<<<<<<<<<<
 *             # Handle both single entity and list/iterable
 *             if not prev_day_unsent:
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
    __Pyx_XGOTREF(__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_7);
    __Pyx_XGOTREF(__pyx_t_8);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":4612
 *         try:
 *             # Handle both single entity and list/iterable
 *             if not prev_day_unsent:             # <<<<<<<<<<<<<<
 *                 logger.info("No unsent intervals to send")
 *                 return
*/
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_prev_day_unsent); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4612, __pyx_L4_error)
      __pyx_t_10 = (!__pyx_t_9);
      if (__pyx_t_10) {

        /* "ws_package/controllers/activity_controller.py":4613
 *             # Handle both single entity and list/iterable
 *             if not prev_day_unsent:
 *                 logger.info("No unsent intervals to send")             # <<<<<<<<<<<<<<
 *                 return
 * 
*/
        __pyx_t_4 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4613, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4613, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_5 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
          assert(__pyx_t_4);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
          __pyx_t_5 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_No_unsent_intervals_to_send};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4613, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":4614
 *             if not prev_day_unsent:
 *                 logger.info("No unsent intervals to send")
 *                 return             # <<<<<<<<<<<<<<
 * 
 *             # Convert single entity to list if needed
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
        goto __pyx_L8_try_return;

        /* "ws_package/controllers/activity_controller.py":4612
 *         try:
 *             # Handle both single entity and list/iterable
 *             if not prev_day_unsent:             # <<<<<<<<<<<<<<
 *                 logger.info("No unsent intervals to send")
 *                 return
*/
      }

      /* "ws_package/controllers/activity_controller.py":4617
 * 
 *             # Convert single entity to list if needed
 *             if not isinstance(prev_day_unsent, (list, tuple)):             # <<<<<<<<<<<<<<
 *                 prev_day_unsent = [prev_day_unsent]
 *             elif len(prev_day_unsent) == 0:
*/
      __pyx_t_9 = PyList_Check(__pyx_cur_scope->__pyx_v_prev_day_unsent); 
      if (!__pyx_t_9) {
      } else {
        __pyx_t_10 = __pyx_t_9;
        goto __pyx_L12_bool_binop_done;
      }
      __pyx_t_9 = PyTuple_Check(__pyx_cur_scope->__pyx_v_prev_day_unsent); 
      __pyx_t_10 = __pyx_t_9;
      __pyx_L12_bool_binop_done:;
      __pyx_t_9 = (!__pyx_t_10);
      if (__pyx_t_9) {

        /* "ws_package/controllers/activity_controller.py":4618
 *             # Convert single entity to list if needed
 *             if not isinstance(prev_day_unsent, (list, tuple)):
 *                 prev_day_unsent = [prev_day_unsent]             # <<<<<<<<<<<<<<
 *             elif len(prev_day_unsent) == 0:
 *                 logger.info("No unsent intervals to send")
*/
        __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4618, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_prev_day_unsent);
        __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_prev_day_unsent);
        if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_cur_scope->__pyx_v_prev_day_unsent) != (0)) __PYX_ERR(0, 4618, __pyx_L4_error);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_prev_day_unsent);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_prev_day_unsent, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":4617
 * 
 *             # Convert single entity to list if needed
 *             if not isinstance(prev_day_unsent, (list, tuple)):             # <<<<<<<<<<<<<<
 *                 prev_day_unsent = [prev_day_unsent]
 *             elif len(prev_day_unsent) == 0:
*/
        goto __pyx_L11;
      }

      /* "ws_package/controllers/activity_controller.py":4619
 *             if not isinstance(prev_day_unsent, (list, tuple)):
 *                 prev_day_unsent = [prev_day_unsent]
 *             elif len(prev_day_unsent) == 0:             # <<<<<<<<<<<<<<
 *                 logger.info("No unsent intervals to send")
 *                 return
*/
      __pyx_t_11 = PyObject_Length(__pyx_cur_scope->__pyx_v_prev_day_unsent); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4619, __pyx_L4_error)
      __pyx_t_9 = (__pyx_t_11 == 0);
      if (__pyx_t_9) {

        /* "ws_package/controllers/activity_controller.py":4620
 *                 prev_day_unsent = [prev_day_unsent]
 *             elif len(prev_day_unsent) == 0:
 *                 logger.info("No unsent intervals to send")             # <<<<<<<<<<<<<<
 *                 return
 * 
*/
        __pyx_t_3 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4620, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4620, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_5 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
          assert(__pyx_t_3);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
          __pyx_t_5 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_No_unsent_intervals_to_send};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4620, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":4621
 *             elif len(prev_day_unsent) == 0:
 *                 logger.info("No unsent intervals to send")
 *                 return             # <<<<<<<<<<<<<<
 * 
 *             payload = []
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
        goto __pyx_L8_try_return;

        /* "ws_package/controllers/activity_controller.py":4619
 *             if not isinstance(prev_day_unsent, (list, tuple)):
 *                 prev_day_unsent = [prev_day_unsent]
 *             elif len(prev_day_unsent) == 0:             # <<<<<<<<<<<<<<
 *                 logger.info("No unsent intervals to send")
 *                 return
*/
      }
      __pyx_L11:;

      /* "ws_package/controllers/activity_controller.py":4623
 *                 return
 * 
 *             payload = []             # <<<<<<<<<<<<<<
 *             for interval in prev_day_unsent:
 *                 # convert into dict payload
*/
      __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4623, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_cur_scope->__pyx_v_payload = ((PyObject*)__pyx_t_1);
      __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":4624
 * 
 *             payload = []
 *             for interval in prev_day_unsent:             # <<<<<<<<<<<<<<
 *                 # convert into dict payload
 *                 # Handle both database model (has id) and entity (might not have id)
*/
      if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_prev_day_unsent)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_prev_day_unsent)) {
        __pyx_t_1 = __pyx_cur_scope->__pyx_v_prev_day_unsent; __Pyx_INCREF(__pyx_t_1);
        __pyx_t_11 = 0;
        __pyx_t_12 = NULL;
      } else {
        __pyx_t_11 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_prev_day_unsent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4624, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_12 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4624, __pyx_L4_error)
      }
      for (;;) {
        if (likely(!__pyx_t_12)) {
          if (likely(PyList_CheckExact(__pyx_t_1))) {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
              #if !CYTHON_ASSUME_SAFE_SIZE
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4624, __pyx_L4_error)
              #endif
              if (__pyx_t_11 >= __pyx_temp) break;
            }
            __pyx_t_2 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_1, __pyx_t_11, __Pyx_ReferenceSharing_OwnStrongReference);
            ++__pyx_t_11;
          } else {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1);
              #if !CYTHON_ASSUME_SAFE_SIZE
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4624, __pyx_L4_error)
              #endif
              if (__pyx_t_11 >= __pyx_temp) break;
            }
            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
            __pyx_t_2 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_11));
            #else
            __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_11);
            #endif
            ++__pyx_t_11;
          }
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4624, __pyx_L4_error)
        } else {
          __pyx_t_2 = __pyx_t_12(__pyx_t_1);
          if (unlikely(!__pyx_t_2)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 4624, __pyx_L4_error)
              PyErr_Clear();
            }
            break;
          }
        }
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        __pyx_t_2 = 0;

        /* "ws_package/controllers/activity_controller.py":4627
 *                 # convert into dict payload
 *                 # Handle both database model (has id) and entity (might not have id)
 *                 interval_id = getattr(interval, 'id', None)             # <<<<<<<<<<<<<<
 *                 if interval_id is None:
 *                     logger.warning("Interval missing id attribute: %s, skipping...", interval)
*/
        __pyx_t_2 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4627, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval_id);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval_id, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        __pyx_t_2 = 0;

        /* "ws_package/controllers/activity_controller.py":4628
 *                 # Handle both database model (has id) and entity (might not have id)
 *                 interval_id = getattr(interval, 'id', None)
 *                 if interval_id is None:             # <<<<<<<<<<<<<<
 *                     logger.warning("Interval missing id attribute: %s, skipping...", interval)
 *                     continue
*/
        __pyx_t_9 = (__pyx_cur_scope->__pyx_v_interval_id == Py_None);
        if (__pyx_t_9) {

          /* "ws_package/controllers/activity_controller.py":4629
 *                 interval_id = getattr(interval, 'id', None)
 *                 if interval_id is None:
 *                     logger.warning("Interval missing id attribute: %s, skipping...", interval)             # <<<<<<<<<<<<<<
 *                     continue
 * 
*/
          __pyx_t_3 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4629, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4629, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_5 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_13))) {
            __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_13);
            assert(__pyx_t_3);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
            __pyx_t_5 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Interval_missing_id_attribute_s, __pyx_cur_scope->__pyx_v_interval};
            __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4629, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_2);
          }
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":4630
 *                 if interval_id is None:
 *                     logger.warning("Interval missing id attribute: %s, skipping...", interval)
 *                     continue             # <<<<<<<<<<<<<<
 * 
 *                 interval_payload = {
*/
          goto __pyx_L14_continue;

          /* "ws_package/controllers/activity_controller.py":4628
 *                 # Handle both database model (has id) and entity (might not have id)
 *                 interval_id = getattr(interval, 'id', None)
 *                 if interval_id is None:             # <<<<<<<<<<<<<<
 *                     logger.warning("Interval missing id attribute: %s, skipping...", interval)
 *                     continue
*/
        }

        /* "ws_package/controllers/activity_controller.py":4633
 * 
 *                 interval_payload = {
 *                     "Entry": getattr(interval, 'id', None) or 0,             # <<<<<<<<<<<<<<
 *                     "from": interval.start_time.strftime("%Y-%m-%d %H:%M:%S"),
 *                     "to": interval.end_time.strftime("%Y-%m-%d %H:%M:%S"),
*/
        __pyx_t_2 = __Pyx_PyDict_NewPresized(14); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4633, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_3 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4633, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4633, __pyx_L4_error)
        if (!__pyx_t_9) {
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else {
          __Pyx_INCREF(__pyx_t_3);
          __pyx_t_13 = __pyx_t_3;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          goto __pyx_L17_bool_binop_done;
        }
        __pyx_t_3 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4633, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_13 = __pyx_t_3;
        __pyx_t_3 = 0;
        __pyx_L17_bool_binop_done:;
        if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_Entry, __pyx_t_13) < (0)) __PYX_ERR(0, 4633, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

        /* "ws_package/controllers/activity_controller.py":4634
 *                 interval_payload = {
 *                     "Entry": getattr(interval, 'id', None) or 0,
 *                     "from": interval.start_time.strftime("%Y-%m-%d %H:%M:%S"),             # <<<<<<<<<<<<<<
 *                     "to": interval.end_time.strftime("%Y-%m-%d %H:%M:%S"),
 *                     "screenUrl": await self.ss(interval.start_time, interval.end_time, user_entity),
*/
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4634, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_3 = __pyx_t_4;
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_5 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Y_m_d_H_M_S};
          __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strftime, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4634, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_13);
        }
        if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_from, __pyx_t_13) < (0)) __PYX_ERR(0, 4633, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

        /* "ws_package/controllers/activity_controller.py":4635
 *                     "Entry": getattr(interval, 'id', None) or 0,
 *                     "from": interval.start_time.strftime("%Y-%m-%d %H:%M:%S"),
 *                     "to": interval.end_time.strftime("%Y-%m-%d %H:%M:%S"),             # <<<<<<<<<<<<<<
 *                     "screenUrl": await self.ss(interval.start_time, interval.end_time, user_entity),
 *                     "activityLevel": self._get_activity_level_from_interval(interval),
*/
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4635, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __pyx_t_3;
        __Pyx_INCREF(__pyx_t_4);
        __pyx_t_5 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Y_m_d_H_M_S};
          __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strftime, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4635, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_13);
        }
        if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_to, __pyx_t_13) < (0)) __PYX_ERR(0, 4633, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

        /* "ws_package/controllers/activity_controller.py":4636
 *                     "from": interval.start_time.strftime("%Y-%m-%d %H:%M:%S"),
 *                     "to": interval.end_time.strftime("%Y-%m-%d %H:%M:%S"),
 *                     "screenUrl": await self.ss(interval.start_time, interval.end_time, user_entity),             # <<<<<<<<<<<<<<
 *                     "activityLevel": self._get_activity_level_from_interval(interval),
 *                     "appAndUrls": await self.activity_service.get_apps_urls(
*/
        __pyx_t_3 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_3);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4636, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4636, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_5 = 0;
        {
          PyObject *__pyx_callargs[4] = {__pyx_t_3, __pyx_t_4, __pyx_t_14, __pyx_cur_scope->__pyx_v_user_entity};
          __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_ss, __pyx_callargs+__pyx_t_5, (4-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4636, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_13);
        }
        __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_13, &__pyx_r);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        if (likely(__pyx_t_15 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_1);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
          __Pyx_XGIVEREF(__pyx_t_2);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
          __Pyx_XGIVEREF(__pyx_t_6);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_6;
          __Pyx_XGIVEREF(__pyx_t_7);
          __pyx_cur_scope->__pyx_t_3 = __pyx_t_7;
          __Pyx_XGIVEREF(__pyx_t_8);
          __pyx_cur_scope->__pyx_t_4 = __pyx_t_8;
          __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
          __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 1;
          return __pyx_r;
          __pyx_L19_resume_from_await:;
          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_1);
          __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_2);
          __pyx_t_6 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_6);
          __pyx_t_7 = __pyx_cur_scope->__pyx_t_3;
          __pyx_cur_scope->__pyx_t_3 = 0;
          __Pyx_XGOTREF(__pyx_t_7);
          __pyx_t_8 = __pyx_cur_scope->__pyx_t_4;
          __pyx_cur_scope->__pyx_t_4 = 0;
          __Pyx_XGOTREF(__pyx_t_8);
          __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
          __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4636, __pyx_L4_error)
          __pyx_t_13 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_13);
        } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __pyx_t_13 = __pyx_r; __pyx_r = NULL;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 4636, __pyx_L4_error)
        }
        if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_screenUrl, __pyx_t_13) < (0)) __PYX_ERR(0, 4633, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

        /* "ws_package/controllers/activity_controller.py":4637
 *                     "to": interval.end_time.strftime("%Y-%m-%d %H:%M:%S"),
 *                     "screenUrl": await self.ss(interval.start_time, interval.end_time, user_entity),
 *                     "activityLevel": self._get_activity_level_from_interval(interval),             # <<<<<<<<<<<<<<
 *                     "appAndUrls": await self.activity_service.get_apps_urls(
 *                         interval.start_time,
*/
        __pyx_t_14 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_14);
        __pyx_t_5 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_14, __pyx_cur_scope->__pyx_v_interval};
          __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_activity_level_from_interva, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4637, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_13);
        }
        if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_activityLevel, __pyx_t_13) < (0)) __PYX_ERR(0, 4633, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

        /* "ws_package/controllers/activity_controller.py":4638
 *                     "screenUrl": await self.ss(interval.start_time, interval.end_time, user_entity),
 *                     "activityLevel": self._get_activity_level_from_interval(interval),
 *                     "appAndUrls": await self.activity_service.get_apps_urls(             # <<<<<<<<<<<<<<
 *                         interval.start_time,
 *                         interval.end_time,
*/
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4638, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_14 = __pyx_t_4;
        __Pyx_INCREF(__pyx_t_14);

        /* "ws_package/controllers/activity_controller.py":4639
 *                     "activityLevel": self._get_activity_level_from_interval(interval),
 *                     "appAndUrls": await self.activity_service.get_apps_urls(
 *                         interval.start_time,             # <<<<<<<<<<<<<<
 *                         interval.end_time,
 *                         self.appandurlstatus
*/
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4639, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_3);

        /* "ws_package/controllers/activity_controller.py":4640
 *                     "appAndUrls": await self.activity_service.get_apps_urls(
 *                         interval.start_time,
 *                         interval.end_time,             # <<<<<<<<<<<<<<
 *                         self.appandurlstatus
 *                     ),
*/
        __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 4640, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_16);

        /* "ws_package/controllers/activity_controller.py":4641
 *                         interval.start_time,
 *                         interval.end_time,
 *                         self.appandurlstatus             # <<<<<<<<<<<<<<
 *                     ),
 *                     "deviceType": self.get_os_type_caps(),
*/
        __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4641, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_5 = 0;
        {
          PyObject *__pyx_callargs[4] = {__pyx_t_14, __pyx_t_3, __pyx_t_16, __pyx_t_17};
          __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_apps_urls, __pyx_callargs+__pyx_t_5, (4-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4638, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_13);
        }
        __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_13, &__pyx_r);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        if (likely(__pyx_t_15 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_1);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
          __Pyx_XGIVEREF(__pyx_t_2);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
          __Pyx_XGIVEREF(__pyx_t_6);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_6;
          __Pyx_XGIVEREF(__pyx_t_7);
          __pyx_cur_scope->__pyx_t_3 = __pyx_t_7;
          __Pyx_XGIVEREF(__pyx_t_8);
          __pyx_cur_scope->__pyx_t_4 = __pyx_t_8;
          __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
          __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 2;
          return __pyx_r;
          __pyx_L20_resume_from_await:;
          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_1);
          __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_2);
          __pyx_t_6 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_6);
          __pyx_t_7 = __pyx_cur_scope->__pyx_t_3;
          __pyx_cur_scope->__pyx_t_3 = 0;
          __Pyx_XGOTREF(__pyx_t_7);
          __pyx_t_8 = __pyx_cur_scope->__pyx_t_4;
          __pyx_cur_scope->__pyx_t_4 = 0;
          __Pyx_XGOTREF(__pyx_t_8);
          __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
          __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4638, __pyx_L4_error)
          __pyx_t_13 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_13);
        } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __pyx_t_13 = __pyx_r; __pyx_r = NULL;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 4638, __pyx_L4_error)
        }
        if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_appAndUrls, __pyx_t_13) < (0)) __PYX_ERR(0, 4633, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

        /* "ws_package/controllers/activity_controller.py":4643
 *                         self.appandurlstatus
 *                     ),
 *                     "deviceType": self.get_os_type_caps(),             # <<<<<<<<<<<<<<
 *                     "os_type": self.get_os_type_caps(),
 *                     "note": None,
*/
        __pyx_t_4 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_4);
        __pyx_t_5 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
          __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type_caps, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4643, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_13);
        }
        if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_deviceType, __pyx_t_13) < (0)) __PYX_ERR(0, 4633, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

        /* "ws_package/controllers/activity_controller.py":4644
 *                     ),
 *                     "deviceType": self.get_os_type_caps(),
 *                     "os_type": self.get_os_type_caps(),             # <<<<<<<<<<<<<<
 *                     "note": None,
 *                     "idle_note_url": None,
*/
        __pyx_t_4 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_4);
        __pyx_t_5 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
          __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type_caps, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4644, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_13);
        }
        if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_os_type, __pyx_t_13) < (0)) __PYX_ERR(0, 4633, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

        /* "ws_package/controllers/activity_controller.py":4645
 *                     "deviceType": self.get_os_type_caps(),
 *                     "os_type": self.get_os_type_caps(),
 *                     "note": None,             # <<<<<<<<<<<<<<
 *                     "idle_note_url": None,
 *                     "idleInterval": None,
*/
        if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_note, Py_None) < (0)) __PYX_ERR(0, 4633, __pyx_L4_error)

        /* "ws_package/controllers/activity_controller.py":4646
 *                     "os_type": self.get_os_type_caps(),
 *                     "note": None,
 *                     "idle_note_url": None,             # <<<<<<<<<<<<<<
 *                     "idleInterval": None,
 *                     "location": LocationEntity(long="null", lat="null").model_dump(),
*/
        if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_idle_note_url, Py_None) < (0)) __PYX_ERR(0, 4633, __pyx_L4_error)

        /* "ws_package/controllers/activity_controller.py":4647
 *                     "note": None,
 *                     "idle_note_url": None,
 *                     "idleInterval": None,             # <<<<<<<<<<<<<<
 *                     "location": LocationEntity(long="null", lat="null").model_dump(),
 *                     "interval_time_db": int(self.interval / 60),
*/
        if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_idleInterval, Py_None) < (0)) __PYX_ERR(0, 4633, __pyx_L4_error)

        /* "ws_package/controllers/activity_controller.py":4648
 *                     "idle_note_url": None,
 *                     "idleInterval": None,
 *                     "location": LocationEntity(long="null", lat="null").model_dump(),             # <<<<<<<<<<<<<<
 *                     "interval_time_db": int(self.interval / 60),
 *                     "has_on_demand_screenshot": getattr(interval, "has_on_demand_screenshot", False),
*/
        __pyx_t_16 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_LocationEntity); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4648, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_5 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_3);
          assert(__pyx_t_16);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_16);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
          __pyx_t_5 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 2 : 0)] = {__pyx_t_16, NULL};
          __pyx_t_14 = __Pyx_MakeVectorcallBuilderKwds(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4648, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_14);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_long, __pyx_mstate_global->__pyx_n_u_null, __pyx_t_14, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 4648, __pyx_L4_error)
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_lat, __pyx_mstate_global->__pyx_n_u_null, __pyx_t_14, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 4648, __pyx_L4_error)
          __pyx_t_17 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_14);
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4648, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_17);
        }
        __pyx_t_4 = __pyx_t_17;
        __Pyx_INCREF(__pyx_t_4);
        __pyx_t_5 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
          __pyx_t_13 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_model_dump, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4648, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_13);
        }
        if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_location, __pyx_t_13) < (0)) __PYX_ERR(0, 4633, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

        /* "ws_package/controllers/activity_controller.py":4649
 *                     "idleInterval": None,
 *                     "location": LocationEntity(long="null", lat="null").model_dump(),
 *                     "interval_time_db": int(self.interval / 60),             # <<<<<<<<<<<<<<
 *                     "has_on_demand_screenshot": getattr(interval, "has_on_demand_screenshot", False),
 *                 }
*/
        __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4649, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_17 = __Pyx_PyLong_TrueDivideObjC(__pyx_t_13, __pyx_mstate_global->__pyx_int_60, 60, 0, 0); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4649, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_17);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_13 = __Pyx_PyNumber_Int(__pyx_t_17); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4649, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_interval_time_db, __pyx_t_13) < (0)) __PYX_ERR(0, 4633, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

        /* "ws_package/controllers/activity_controller.py":4650
 *                     "location": LocationEntity(long="null", lat="null").model_dump(),
 *                     "interval_time_db": int(self.interval / 60),
 *                     "has_on_demand_screenshot": getattr(interval, "has_on_demand_screenshot", False),             # <<<<<<<<<<<<<<
 *                 }
 *                 payload.append(interval_payload)
*/
        __pyx_t_13 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_has_on_demand_screenshot, Py_False); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4650, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_13);
        if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_has_on_demand_screenshot, __pyx_t_13) < (0)) __PYX_ERR(0, 4633, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval_payload);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval_payload, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        __pyx_t_2 = 0;

        /* "ws_package/controllers/activity_controller.py":4652
 *                     "has_on_demand_screenshot": getattr(interval, "has_on_demand_screenshot", False),
 *                 }
 *                 payload.append(interval_payload)             # <<<<<<<<<<<<<<
 * 
 *             # Use current project/task IDs if set, otherwise fallback to defaults
*/
        __pyx_t_18 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_payload, __pyx_cur_scope->__pyx_v_interval_payload); if (unlikely(__pyx_t_18 == ((int)-1))) __PYX_ERR(0, 4652, __pyx_L4_error)

        /* "ws_package/controllers/activity_controller.py":4624
 * 
 *             payload = []
 *             for interval in prev_day_unsent:             # <<<<<<<<<<<<<<
 *                 # convert into dict payload
 *                 # Handle both database model (has id) and entity (might not have id)
*/
        __pyx_L14_continue:;
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":4655
 * 
 *             # Use current project/task IDs if set, otherwise fallback to defaults
 *             project_id = self.current_project_id if self.current_project_id else "1001"             # <<<<<<<<<<<<<<
 *             task_id = self.current_task_id if self.current_task_id else "0"
 *             if not self.current_project_id:
*/
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_project_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4655, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4655, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__pyx_t_9) {
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_project_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4655, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = __pyx_t_2;
        __pyx_t_2 = 0;
      } else {
        __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_1001);
        __pyx_t_1 = __pyx_mstate_global->__pyx_kp_u_1001;
      }
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_cur_scope->__pyx_v_project_id = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":4656
 *             # Use current project/task IDs if set, otherwise fallback to defaults
 *             project_id = self.current_project_id if self.current_project_id else "1001"
 *             task_id = self.current_task_id if self.current_task_id else "0"             # <<<<<<<<<<<<<<
 *             if not self.current_project_id:
 *                 logger.warning(
*/
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_task_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4656, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4656, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__pyx_t_9) {
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_task_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4656, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_1 = __pyx_t_2;
        __pyx_t_2 = 0;
      } else {
        __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_0);
        __pyx_t_1 = __pyx_mstate_global->__pyx_kp_u_0;
      }
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_cur_scope->__pyx_v_task_id = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":4657
 *             project_id = self.current_project_id if self.current_project_id else "1001"
 *             task_id = self.current_task_id if self.current_task_id else "0"
 *             if not self.current_project_id:             # <<<<<<<<<<<<<<
 *                 logger.warning(
 *                     "No project selected in Python  using fallback project_id=%s. "
*/
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_project_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4657, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4657, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_10 = (!__pyx_t_9);
      if (__pyx_t_10) {

        /* "ws_package/controllers/activity_controller.py":4658
 *             task_id = self.current_task_id if self.current_task_id else "0"
 *             if not self.current_project_id:
 *                 logger.warning(             # <<<<<<<<<<<<<<
 *                     "No project selected in Python  using fallback project_id=%s. "
 *                     "Ensure Electron sends set_project_task before start_activity_monitoring.",
*/
        __pyx_t_2 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4658, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4658, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_17);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

        /* "ws_package/controllers/activity_controller.py":4661
 *                     "No project selected in Python  using fallback project_id=%s. "
 *                     "Ensure Electron sends set_project_task before start_activity_monitoring.",
 *                     project_id,             # <<<<<<<<<<<<<<
 *                 )
 * 
*/
        __pyx_t_5 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_17))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_17);
          assert(__pyx_t_2);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
          __pyx_t_5 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_No_project_selected_in_Python_us, __pyx_cur_scope->__pyx_v_project_id};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4658, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":4657
 *             project_id = self.current_project_id if self.current_project_id else "1001"
 *             task_id = self.current_task_id if self.current_task_id else "0"
 *             if not self.current_project_id:             # <<<<<<<<<<<<<<
 *                 logger.warning(
 *                     "No project selected in Python  using fallback project_id=%s. "
*/
      }

      /* "ws_package/controllers/activity_controller.py":4665
 * 
 *             final_payload = [{
 *                 "projectId": project_id,             # <<<<<<<<<<<<<<
 *                 "start": start.strftime("%Y-%m-%d %H:%M:%S"),
 *                 "stop": None,
*/
      __pyx_t_1 = __Pyx_PyDict_NewPresized(18); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4665, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_1);
      if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_projectId, __pyx_cur_scope->__pyx_v_project_id) < (0)) __PYX_ERR(0, 4665, __pyx_L4_error)

      /* "ws_package/controllers/activity_controller.py":4666
 *             final_payload = [{
 *                 "projectId": project_id,
 *                 "start": start.strftime("%Y-%m-%d %H:%M:%S"),             # <<<<<<<<<<<<<<
 *                 "stop": None,
 *                 "selfi_id": None,
*/
      __pyx_t_2 = __pyx_cur_scope->__pyx_v_start;
      __Pyx_INCREF(__pyx_t_2);
      __pyx_t_5 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Y_m_d_H_M_S};
        __pyx_t_17 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strftime, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4666, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_17);
      }
      if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_start, __pyx_t_17) < (0)) __PYX_ERR(0, 4665, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

      /* "ws_package/controllers/activity_controller.py":4667
 *                 "projectId": project_id,
 *                 "start": start.strftime("%Y-%m-%d %H:%M:%S"),
 *                 "stop": None,             # <<<<<<<<<<<<<<
 *                 "selfi_id": None,
 *                 "timezone": self._normalize_timezone(str(self.timezone_manager.local_timezone) if self.timezone_manager.local_timezone else str(self.get_system_timezone())),
*/
      if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_stop, Py_None) < (0)) __PYX_ERR(0, 4665, __pyx_L4_error)

      /* "ws_package/controllers/activity_controller.py":4668
 *                 "start": start.strftime("%Y-%m-%d %H:%M:%S"),
 *                 "stop": None,
 *                 "selfi_id": None,             # <<<<<<<<<<<<<<
 *                 "timezone": self._normalize_timezone(str(self.timezone_manager.local_timezone) if self.timezone_manager.local_timezone else str(self.get_system_timezone())),
 *                 "break_id": None,
*/
      if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_selfi_id, Py_None) < (0)) __PYX_ERR(0, 4665, __pyx_L4_error)

      /* "ws_package/controllers/activity_controller.py":4669
 *                 "stop": None,
 *                 "selfi_id": None,
 *                 "timezone": self._normalize_timezone(str(self.timezone_manager.local_timezone) if self.timezone_manager.local_timezone else str(self.get_system_timezone())),             # <<<<<<<<<<<<<<
 *                 "break_id": None,
 *                 "deviceType": self.get_os_type_caps(),
*/
      __pyx_t_2 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_2);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_timezone_manager); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4669, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_local_timezone); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4669, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 4669, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_10) {
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_timezone_manager); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4669, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_local_timezone); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4669, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_3 = __Pyx_PyObject_Unicode(__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4669, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_13 = __pyx_t_3;
        __pyx_t_3 = 0;
      } else {
        __pyx_t_4 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_4);
        __pyx_t_5 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
          __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_system_timezone, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4669, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_3);
        }
        __pyx_t_4 = __Pyx_PyObject_Unicode(__pyx_t_3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4669, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_13 = __pyx_t_4;
        __pyx_t_4 = 0;
      }
      __pyx_t_5 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_13};
        __pyx_t_17 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_normalize_timezone, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4669, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_17);
      }
      if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_timezone, __pyx_t_17) < (0)) __PYX_ERR(0, 4665, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

      /* "ws_package/controllers/activity_controller.py":4670
 *                 "selfi_id": None,
 *                 "timezone": self._normalize_timezone(str(self.timezone_manager.local_timezone) if self.timezone_manager.local_timezone else str(self.get_system_timezone())),
 *                 "break_id": None,             # <<<<<<<<<<<<<<
 *                 "deviceType": self.get_os_type_caps(),
 *                 "os_type": self.get_os_type_caps(),
*/
      if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_break_id, Py_None) < (0)) __PYX_ERR(0, 4665, __pyx_L4_error)

      /* "ws_package/controllers/activity_controller.py":4671
 *                 "timezone": self._normalize_timezone(str(self.timezone_manager.local_timezone) if self.timezone_manager.local_timezone else str(self.get_system_timezone())),
 *                 "break_id": None,
 *                 "deviceType": self.get_os_type_caps(),             # <<<<<<<<<<<<<<
 *                 "os_type": self.get_os_type_caps(),
 *                 "selfiVerification": True,
*/
      __pyx_t_13 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_13);
      __pyx_t_5 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_13, NULL};
        __pyx_t_17 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type_caps, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4671, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_17);
      }
      if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_deviceType, __pyx_t_17) < (0)) __PYX_ERR(0, 4665, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

      /* "ws_package/controllers/activity_controller.py":4672
 *                 "break_id": None,
 *                 "deviceType": self.get_os_type_caps(),
 *                 "os_type": self.get_os_type_caps(),             # <<<<<<<<<<<<<<
 *                 "selfiVerification": True,
 *                 "intervals": payload,
*/
      __pyx_t_13 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_13);
      __pyx_t_5 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_13, NULL};
        __pyx_t_17 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type_caps, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4672, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_17);
      }
      if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_os_type, __pyx_t_17) < (0)) __PYX_ERR(0, 4665, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

      /* "ws_package/controllers/activity_controller.py":4673
 *                 "deviceType": self.get_os_type_caps(),
 *                 "os_type": self.get_os_type_caps(),
 *                 "selfiVerification": True,             # <<<<<<<<<<<<<<
 *                 "intervals": payload,
 *                 "time_type": "1",
*/
      if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_selfiVerification, Py_True) < (0)) __PYX_ERR(0, 4665, __pyx_L4_error)

      /* "ws_package/controllers/activity_controller.py":4674
 *                 "os_type": self.get_os_type_caps(),
 *                 "selfiVerification": True,
 *                 "intervals": payload,             # <<<<<<<<<<<<<<
 *                 "time_type": "1",
 *                 "interval_time": int(self.interval / 60),
*/
      if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_intervals, __pyx_cur_scope->__pyx_v_payload) < (0)) __PYX_ERR(0, 4665, __pyx_L4_error)
      if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_time_type, __pyx_mstate_global->__pyx_kp_u_1) < (0)) __PYX_ERR(0, 4665, __pyx_L4_error)

      /* "ws_package/controllers/activity_controller.py":4676
 *                 "intervals": payload,
 *                 "time_type": "1",
 *                 "interval_time": int(self.interval / 60),             # <<<<<<<<<<<<<<
 *                 "source_type": "4",
 *                 "org_id": str(user_entity.org_id),
*/
      __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4676, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_13 = __Pyx_PyLong_TrueDivideObjC(__pyx_t_17, __pyx_mstate_global->__pyx_int_60, 60, 0, 0); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4676, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      __pyx_t_17 = __Pyx_PyNumber_Int(__pyx_t_13); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4676, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_interval_time, __pyx_t_17) < (0)) __PYX_ERR(0, 4665, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_source_type, __pyx_mstate_global->__pyx_kp_u_4) < (0)) __PYX_ERR(0, 4665, __pyx_L4_error)

      /* "ws_package/controllers/activity_controller.py":4678
 *                 "interval_time": int(self.interval / 60),
 *                 "source_type": "4",
 *                 "org_id": str(user_entity.org_id),             # <<<<<<<<<<<<<<
 *                 "todo_id": task_id,
 *                 "deviceId": self.system_unique_id,
*/
      __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_org_id); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4678, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_13 = __Pyx_PyObject_Unicode(__pyx_t_17); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4678, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_org_id, __pyx_t_13) < (0)) __PYX_ERR(0, 4665, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

      /* "ws_package/controllers/activity_controller.py":4679
 *                 "source_type": "4",
 *                 "org_id": str(user_entity.org_id),
 *                 "todo_id": task_id,             # <<<<<<<<<<<<<<
 *                 "deviceId": self.system_unique_id,
 *                 "ip_address": str(get_ip()),
*/
      if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_todo_id, __pyx_cur_scope->__pyx_v_task_id) < (0)) __PYX_ERR(0, 4665, __pyx_L4_error)

      /* "ws_package/controllers/activity_controller.py":4680
 *                 "org_id": str(user_entity.org_id),
 *                 "todo_id": task_id,
 *                 "deviceId": self.system_unique_id,             # <<<<<<<<<<<<<<
 *                 "ip_address": str(get_ip()),
 *                 "os_version": get_os_version()
*/
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_system_unique_id); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4680, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_13);
      if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_deviceId, __pyx_t_13) < (0)) __PYX_ERR(0, 4665, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

      /* "ws_package/controllers/activity_controller.py":4681
 *                 "todo_id": task_id,
 *                 "deviceId": self.system_unique_id,
 *                 "ip_address": str(get_ip()),             # <<<<<<<<<<<<<<
 *                 "os_version": get_os_version()
 *             }]
*/
      __pyx_t_17 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_get_ip); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4681, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_5 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_2);
        assert(__pyx_t_17);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_17);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
        __pyx_t_5 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_17, NULL};
        __pyx_t_13 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4681, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_13);
      }
      __pyx_t_2 = __Pyx_PyObject_Unicode(__pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4681, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_ip_address, __pyx_t_2) < (0)) __PYX_ERR(0, 4665, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "ws_package/controllers/activity_controller.py":4682
 *                 "deviceId": self.system_unique_id,
 *                 "ip_address": str(get_ip()),
 *                 "os_version": get_os_version()             # <<<<<<<<<<<<<<
 *             }]
 * 
*/
      __pyx_t_13 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_get_os_version); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4682, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_5 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_17))) {
        __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_17);
        assert(__pyx_t_13);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
        __Pyx_INCREF(__pyx_t_13);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
        __pyx_t_5 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_13, NULL};
        __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4682, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_2);
      }
      if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_os_version, __pyx_t_2) < (0)) __PYX_ERR(0, 4665, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "ws_package/controllers/activity_controller.py":4664
 *                 )
 * 
 *             final_payload = [{             # <<<<<<<<<<<<<<
 *                 "projectId": project_id,
 *                 "start": start.strftime("%Y-%m-%d %H:%M:%S"),
*/
      __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4664, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_1);
      if (__Pyx_PyList_SET_ITEM(__pyx_t_2, 0, __pyx_t_1) != (0)) __PYX_ERR(0, 4664, __pyx_L4_error);
      __pyx_t_1 = 0;
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_cur_scope->__pyx_v_final_payload = ((PyObject*)__pyx_t_2);
      __pyx_t_2 = 0;

      /* "ws_package/controllers/activity_controller.py":4685
 *             }]
 * 
 *             logger.info("Generated payload for previous day with %s intervals", len(prev_day_unsent))             # <<<<<<<<<<<<<<
 * 
 *             # Headers for the activity log api - matching the working curl command
*/
      __pyx_t_1 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4685, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4685, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      __pyx_t_11 = PyObject_Length(__pyx_cur_scope->__pyx_v_prev_day_unsent); if (unlikely(__pyx_t_11 == ((Py_ssize_t)-1))) __PYX_ERR(0, 4685, __pyx_L4_error)
      __pyx_t_17 = PyLong_FromSsize_t(__pyx_t_11); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4685, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_5 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_13))) {
        __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_13);
        assert(__pyx_t_1);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
        __Pyx_INCREF(__pyx_t_1);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
        __pyx_t_5 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Generated_payload_for_previous_d, __pyx_t_17};
        __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4685, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_2);
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "ws_package/controllers/activity_controller.py":4688
 * 
 *             # Headers for the activity log api - matching the working curl command
 *             sd_token = user_entity.sd_token             # <<<<<<<<<<<<<<
 *             org_id = user_entity.org_id
 *             user_id = user_entity.user_id
*/
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_sd_token); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4688, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_cur_scope->__pyx_v_sd_token = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "ws_package/controllers/activity_controller.py":4689
 *             # Headers for the activity log api - matching the working curl command
 *             sd_token = user_entity.sd_token
 *             org_id = user_entity.org_id             # <<<<<<<<<<<<<<
 *             user_id = user_entity.user_id
 *             self.activity_service.headers = {
*/
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_org_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4689, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_cur_scope->__pyx_v_org_id = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "ws_package/controllers/activity_controller.py":4690
 *             sd_token = user_entity.sd_token
 *             org_id = user_entity.org_id
 *             user_id = user_entity.user_id             # <<<<<<<<<<<<<<
 *             self.activity_service.headers = {
 *                 'SDToken': str(sd_token),
*/
      __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_user_id); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4690, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_cur_scope->__pyx_v_user_id = __pyx_t_2;
      __pyx_t_2 = 0;

      /* "ws_package/controllers/activity_controller.py":4692
 *             user_id = user_entity.user_id
 *             self.activity_service.headers = {
 *                 'SDToken': str(sd_token),             # <<<<<<<<<<<<<<
 *                 'OrgID': str(org_id),
 *                 'UserID': str(user_id),
*/
      __pyx_t_2 = __Pyx_PyDict_NewPresized(8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4692, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_13 = __Pyx_PyObject_Unicode(__pyx_cur_scope->__pyx_v_sd_token); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4692, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_13);
      if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_SDToken, __pyx_t_13) < (0)) __PYX_ERR(0, 4692, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

      /* "ws_package/controllers/activity_controller.py":4693
 *             self.activity_service.headers = {
 *                 'SDToken': str(sd_token),
 *                 'OrgID': str(org_id),             # <<<<<<<<<<<<<<
 *                 'UserID': str(user_id),
 *                 'DeviceID': self.system_unique_id,
*/
      __pyx_t_13 = __Pyx_PyObject_Unicode(__pyx_cur_scope->__pyx_v_org_id); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4693, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_13);
      if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_OrgID, __pyx_t_13) < (0)) __PYX_ERR(0, 4692, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

      /* "ws_package/controllers/activity_controller.py":4694
 *                 'SDToken': str(sd_token),
 *                 'OrgID': str(org_id),
 *                 'UserID': str(user_id),             # <<<<<<<<<<<<<<
 *                 'DeviceID': self.system_unique_id,
 *                 'Authorization': f'Bearer {sd_token}',
*/
      __pyx_t_13 = __Pyx_PyObject_Unicode(__pyx_cur_scope->__pyx_v_user_id); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4694, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_13);
      if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_UserID, __pyx_t_13) < (0)) __PYX_ERR(0, 4692, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

      /* "ws_package/controllers/activity_controller.py":4695
 *                 'OrgID': str(org_id),
 *                 'UserID': str(user_id),
 *                 'DeviceID': self.system_unique_id,             # <<<<<<<<<<<<<<
 *                 'Authorization': f'Bearer {sd_token}',
 *                 'Content-Type': 'application/json',
*/
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_system_unique_id); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4695, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_13);
      if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_DeviceID, __pyx_t_13) < (0)) __PYX_ERR(0, 4692, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

      /* "ws_package/controllers/activity_controller.py":4696
 *                 'UserID': str(user_id),
 *                 'DeviceID': self.system_unique_id,
 *                 'Authorization': f'Bearer {sd_token}',             # <<<<<<<<<<<<<<
 *                 'Content-Type': 'application/json',
 *                 'Accept': 'application/json',
*/
      __pyx_t_13 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_sd_token, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4696, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_17 = __Pyx_PyUnicode_Concat(__pyx_mstate_global->__pyx_kp_u_Bearer, __pyx_t_13); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4696, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_Authorization, __pyx_t_17) < (0)) __PYX_ERR(0, 4692, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Content_Type, __pyx_mstate_global->__pyx_kp_u_application_json) < (0)) __PYX_ERR(0, 4692, __pyx_L4_error)
      if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_Accept, __pyx_mstate_global->__pyx_kp_u_application_json) < (0)) __PYX_ERR(0, 4692, __pyx_L4_error)

      /* "ws_package/controllers/activity_controller.py":4699
 *                 'Content-Type': 'application/json',
 *                 'Accept': 'application/json',
 *                 'deviceType': self.get_os_type_caps(),             # <<<<<<<<<<<<<<
 *             }
 * 
*/
      __pyx_t_13 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_13);
      __pyx_t_5 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_13, NULL};
        __pyx_t_17 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type_caps, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4699, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_17);
      }
      if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_deviceType, __pyx_t_17) < (0)) __PYX_ERR(0, 4692, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

      /* "ws_package/controllers/activity_controller.py":4691
 *             org_id = user_entity.org_id
 *             user_id = user_entity.user_id
 *             self.activity_service.headers = {             # <<<<<<<<<<<<<<
 *                 'SDToken': str(sd_token),
 *                 'OrgID': str(org_id),
*/
      __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 4691, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_17);
      if (__Pyx_PyObject_SetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_headers, __pyx_t_2) < (0)) __PYX_ERR(0, 4691, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

      /* "ws_package/controllers/activity_controller.py":4702
 *             }
 * 
 *             for response in final_payload:             # <<<<<<<<<<<<<<
 *                 if not response or not isinstance(response, dict):
 *                     logger.info("No interval found %s", [response])
*/
      __pyx_t_17 = __pyx_cur_scope->__pyx_v_final_payload; __Pyx_INCREF(__pyx_t_17);
      __pyx_t_11 = 0;
      for (;;) {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_17);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4702, __pyx_L4_error)
          #endif
          if (__pyx_t_11 >= __pyx_temp) break;
        }
        __pyx_t_2 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_17, __pyx_t_11, __Pyx_ReferenceSharing_OwnStrongReference);
        ++__pyx_t_11;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4702, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_response);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_response, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        __pyx_t_2 = 0;

        /* "ws_package/controllers/activity_controller.py":4703
 * 
 *             for response in final_payload:
 *                 if not response or not isinstance(response, dict):             # <<<<<<<<<<<<<<
 *                     logger.info("No interval found %s", [response])
 *                     continue
*/
        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_response); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4703, __pyx_L4_error)
        __pyx_t_19 = (!__pyx_t_9);
        if (!__pyx_t_19) {
        } else {
          __pyx_t_10 = __pyx_t_19;
          goto __pyx_L26_bool_binop_done;
        }
        __pyx_t_19 = PyDict_Check(__pyx_cur_scope->__pyx_v_response); 
        __pyx_t_9 = (!__pyx_t_19);
        __pyx_t_10 = __pyx_t_9;
        __pyx_L26_bool_binop_done:;
        if (__pyx_t_10) {

          /* "ws_package/controllers/activity_controller.py":4704
 *             for response in final_payload:
 *                 if not response or not isinstance(response, dict):
 *                     logger.info("No interval found %s", [response])             # <<<<<<<<<<<<<<
 *                     continue
 * 
*/
          __pyx_t_13 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4704, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4704, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4704, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_INCREF(__pyx_cur_scope->__pyx_v_response);
          __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_response);
          if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_cur_scope->__pyx_v_response) != (0)) __PYX_ERR(0, 4704, __pyx_L4_error);
          __pyx_t_5 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_4))) {
            __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_4);
            assert(__pyx_t_13);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
            __pyx_t_5 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_No_interval_found_s, __pyx_t_1};
            __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4704, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_2);
          }
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":4705
 *                 if not response or not isinstance(response, dict):
 *                     logger.info("No interval found %s", [response])
 *                     continue             # <<<<<<<<<<<<<<
 * 
 *                 _response = self.activity_service.push_activity_logs([response])
*/
          goto __pyx_L23_continue;

          /* "ws_package/controllers/activity_controller.py":4703
 * 
 *             for response in final_payload:
 *                 if not response or not isinstance(response, dict):             # <<<<<<<<<<<<<<
 *                     logger.info("No interval found %s", [response])
 *                     continue
*/
        }

        /* "ws_package/controllers/activity_controller.py":4707
 *                     continue
 * 
 *                 _response = self.activity_service.push_activity_logs([response])             # <<<<<<<<<<<<<<
 *                 logger.info("Response: %s", _response)
 * 
*/
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4707, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_4 = __pyx_t_1;
        __Pyx_INCREF(__pyx_t_4);
        __pyx_t_13 = PyList_New(1); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4707, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_response);
        __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_response);
        if (__Pyx_PyList_SET_ITEM(__pyx_t_13, 0, __pyx_cur_scope->__pyx_v_response) != (0)) __PYX_ERR(0, 4707, __pyx_L4_error);
        __pyx_t_5 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_13};
          __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_push_activity_logs, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4707, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_2);
        }
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v__response);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v__response, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        __pyx_t_2 = 0;

        /* "ws_package/controllers/activity_controller.py":4708
 * 
 *                 _response = self.activity_service.push_activity_logs([response])
 *                 logger.info("Response: %s", _response)             # <<<<<<<<<<<<<<
 * 
 *                 if _response is None:
*/
        __pyx_t_1 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4708, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4708, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_5 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
          assert(__pyx_t_1);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
          __pyx_t_5 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Response_s, __pyx_cur_scope->__pyx_v__response};
          __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4708, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_2);
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "ws_package/controllers/activity_controller.py":4710
 *                 logger.info("Response: %s", _response)
 * 
 *                 if _response is None:             # <<<<<<<<<<<<<<
 *                     logger.error("No response received from server for unsent intervals")
 *                     continue
*/
        __pyx_t_10 = (__pyx_cur_scope->__pyx_v__response == Py_None);
        if (__pyx_t_10) {

          /* "ws_package/controllers/activity_controller.py":4711
 * 
 *                 if _response is None:
 *                     logger.error("No response received from server for unsent intervals")             # <<<<<<<<<<<<<<
 *                     continue
 * 
*/
          __pyx_t_4 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4711, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4711, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_13);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_5 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_13))) {
            __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_13);
            assert(__pyx_t_4);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
            __pyx_t_5 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_No_response_received_from_server};
            __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4711, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_2);
          }
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":4712
 *                 if _response is None:
 *                     logger.error("No response received from server for unsent intervals")
 *                     continue             # <<<<<<<<<<<<<<
 * 
 *                 if _response and _response.get("message") == "Token is Expired":
*/
          goto __pyx_L23_continue;

          /* "ws_package/controllers/activity_controller.py":4710
 *                 logger.info("Response: %s", _response)
 * 
 *                 if _response is None:             # <<<<<<<<<<<<<<
 *                     logger.error("No response received from server for unsent intervals")
 *                     continue
*/
        }

        /* "ws_package/controllers/activity_controller.py":4714
 *                     continue
 * 
 *                 if _response and _response.get("message") == "Token is Expired":             # <<<<<<<<<<<<<<
 *                     logger.info("Token is Expired")
 *                     self._send_subscription_expired_popup(_response)
*/
        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v__response); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4714, __pyx_L4_error)
        if (__pyx_t_9) {
        } else {
          __pyx_t_10 = __pyx_t_9;
          goto __pyx_L30_bool_binop_done;
        }
        __pyx_t_13 = __pyx_cur_scope->__pyx_v__response;
        __Pyx_INCREF(__pyx_t_13);
        __pyx_t_5 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_mstate_global->__pyx_n_u_message};
          __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4714, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_2);
        }
        __pyx_t_9 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Token_is_Expired, Py_EQ)); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4714, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_10 = __pyx_t_9;
        __pyx_L30_bool_binop_done:;
        if (__pyx_t_10) {

          /* "ws_package/controllers/activity_controller.py":4715
 * 
 *                 if _response and _response.get("message") == "Token is Expired":
 *                     logger.info("Token is Expired")             # <<<<<<<<<<<<<<
 *                     self._send_subscription_expired_popup(_response)
 *                     self.status = False
*/
          __pyx_t_13 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4715, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4715, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_5 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_1))) {
            __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_1);
            assert(__pyx_t_13);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_13);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
            __pyx_t_5 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Token_is_Expired};
            __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4715, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_2);
          }
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":4716
 *                 if _response and _response.get("message") == "Token is Expired":
 *                     logger.info("Token is Expired")
 *                     self._send_subscription_expired_popup(_response)             # <<<<<<<<<<<<<<
 *                     self.status = False
 * 
*/
          __pyx_t_1 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_1);
          __pyx_t_5 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_cur_scope->__pyx_v__response};
            __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_send_subscription_expired_popup, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4716, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_2);
          }
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":4717
 *                     logger.info("Token is Expired")
 *                     self._send_subscription_expired_popup(_response)
 *                     self.status = False             # <<<<<<<<<<<<<<
 * 
 *                 elif _response and (
*/
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status, Py_False) < (0)) __PYX_ERR(0, 4717, __pyx_L4_error)

          /* "ws_package/controllers/activity_controller.py":4714
 *                     continue
 * 
 *                 if _response and _response.get("message") == "Token is Expired":             # <<<<<<<<<<<<<<
 *                     logger.info("Token is Expired")
 *                     self._send_subscription_expired_popup(_response)
*/
          goto __pyx_L29;
        }

        /* "ws_package/controllers/activity_controller.py":4719
 *                     self.status = False
 * 
 *                 elif _response and (             # <<<<<<<<<<<<<<
 *                     _response.get("planStatus") != "active"
 *                     or _response.get("isdeleted") == 1
*/
        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v__response); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4719, __pyx_L4_error)
        if (__pyx_t_9) {
        } else {
          __pyx_t_10 = __pyx_t_9;
          goto __pyx_L32_bool_binop_done;
        }

        /* "ws_package/controllers/activity_controller.py":4720
 * 
 *                 elif _response and (
 *                     _response.get("planStatus") != "active"             # <<<<<<<<<<<<<<
 *                     or _response.get("isdeleted") == 1
 *                     or _response.get("isdeactivated") == 1
*/
        __pyx_t_1 = __pyx_cur_scope->__pyx_v__response;
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_5 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_n_u_planStatus};
          __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4720, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_2);
        }
        __pyx_t_9 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_active, Py_NE)); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4720, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (!__pyx_t_9) {
        } else {
          __pyx_t_10 = __pyx_t_9;
          goto __pyx_L32_bool_binop_done;
        }

        /* "ws_package/controllers/activity_controller.py":4721
 *                 elif _response and (
 *                     _response.get("planStatus") != "active"
 *                     or _response.get("isdeleted") == 1             # <<<<<<<<<<<<<<
 *                     or _response.get("isdeactivated") == 1
 *                 ):
*/
        __pyx_t_1 = __pyx_cur_scope->__pyx_v__response;
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_5 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_n_u_isdeleted};
          __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4721, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_2);
        }
        __pyx_t_9 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_2, __pyx_mstate_global->__pyx_int_1, 1, 0)); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4721, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (!__pyx_t_9) {
        } else {
          __pyx_t_10 = __pyx_t_9;
          goto __pyx_L32_bool_binop_done;
        }

        /* "ws_package/controllers/activity_controller.py":4722
 *                     _response.get("planStatus") != "active"
 *                     or _response.get("isdeleted") == 1
 *                     or _response.get("isdeactivated") == 1             # <<<<<<<<<<<<<<
 *                 ):
 *                     logger.error("Either plan status Deactivated, user deleted or user deactivated")
*/
        __pyx_t_1 = __pyx_cur_scope->__pyx_v__response;
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_5 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_n_u_isdeactivated};
          __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4722, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_2);
        }
        __pyx_t_9 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_2, __pyx_mstate_global->__pyx_int_1, 1, 0)); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4722, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_10 = __pyx_t_9;
        __pyx_L32_bool_binop_done:;

        /* "ws_package/controllers/activity_controller.py":4719
 *                     self.status = False
 * 
 *                 elif _response and (             # <<<<<<<<<<<<<<
 *                     _response.get("planStatus") != "active"
 *                     or _response.get("isdeleted") == 1
*/
        if (__pyx_t_10) {

          /* "ws_package/controllers/activity_controller.py":4724
 *                     or _response.get("isdeactivated") == 1
 *                 ):
 *                     logger.error("Either plan status Deactivated, user deleted or user deactivated")             # <<<<<<<<<<<<<<
 *                     self._send_subscription_expired_popup(_response)
 *                     self.status = False
*/
          __pyx_t_1 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4724, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4724, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          __pyx_t_5 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_4))) {
            __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_4);
            assert(__pyx_t_1);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
            __pyx_t_5 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Either_plan_status_Deactivated_u_2};
            __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4724, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_2);
          }
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":4725
 *                 ):
 *                     logger.error("Either plan status Deactivated, user deleted or user deactivated")
 *                     self._send_subscription_expired_popup(_response)             # <<<<<<<<<<<<<<
 *                     self.status = False
 * 
*/
          __pyx_t_4 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_4);
          __pyx_t_5 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_cur_scope->__pyx_v__response};
            __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_send_subscription_expired_popup, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4725, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_2);
          }
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":4726
 *                     logger.error("Either plan status Deactivated, user deleted or user deactivated")
 *                     self._send_subscription_expired_popup(_response)
 *                     self.status = False             # <<<<<<<<<<<<<<
 * 
 *                 elif _response and _response.get("planStatus") == "active":
*/
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status, Py_False) < (0)) __PYX_ERR(0, 4726, __pyx_L4_error)

          /* "ws_package/controllers/activity_controller.py":4719
 *                     self.status = False
 * 
 *                 elif _response and (             # <<<<<<<<<<<<<<
 *                     _response.get("planStatus") != "active"
 *                     or _response.get("isdeleted") == 1
*/
          goto __pyx_L29;
        }

        /* "ws_package/controllers/activity_controller.py":4728
 *                     self.status = False
 * 
 *                 elif _response and _response.get("planStatus") == "active":             # <<<<<<<<<<<<<<
 *                     # update intervals - use the original intervals from prev_day_unsent
 *                     for interval in prev_day_unsent:
*/
        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v__response); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4728, __pyx_L4_error)
        if (__pyx_t_9) {
        } else {
          __pyx_t_10 = __pyx_t_9;
          goto __pyx_L36_bool_binop_done;
        }
        __pyx_t_4 = __pyx_cur_scope->__pyx_v__response;
        __Pyx_INCREF(__pyx_t_4);
        __pyx_t_5 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_n_u_planStatus};
          __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4728, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_2);
        }
        __pyx_t_9 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_active, Py_EQ)); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4728, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_10 = __pyx_t_9;
        __pyx_L36_bool_binop_done:;
        if (__pyx_t_10) {

          /* "ws_package/controllers/activity_controller.py":4730
 *                 elif _response and _response.get("planStatus") == "active":
 *                     # update intervals - use the original intervals from prev_day_unsent
 *                     for interval in prev_day_unsent:             # <<<<<<<<<<<<<<
 *                         await self.activity_service.update_activity_interval(interval)
 * 
*/
          if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_prev_day_unsent)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_prev_day_unsent)) {
            __pyx_t_2 = __pyx_cur_scope->__pyx_v_prev_day_unsent; __Pyx_INCREF(__pyx_t_2);
            __pyx_t_20 = 0;
            __pyx_t_12 = NULL;
          } else {
            __pyx_t_20 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_prev_day_unsent); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4730, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_12 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4730, __pyx_L4_error)
          }
          for (;;) {
            if (likely(!__pyx_t_12)) {
              if (likely(PyList_CheckExact(__pyx_t_2))) {
                {
                  Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2);
                  #if !CYTHON_ASSUME_SAFE_SIZE
                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4730, __pyx_L4_error)
                  #endif
                  if (__pyx_t_20 >= __pyx_temp) break;
                }
                __pyx_t_4 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_2, __pyx_t_20, __Pyx_ReferenceSharing_OwnStrongReference);
                ++__pyx_t_20;
              } else {
                {
                  Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_2);
                  #if !CYTHON_ASSUME_SAFE_SIZE
                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4730, __pyx_L4_error)
                  #endif
                  if (__pyx_t_20 >= __pyx_temp) break;
                }
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_4 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_20));
                #else
                __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_2, __pyx_t_20);
                #endif
                ++__pyx_t_20;
              }
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4730, __pyx_L4_error)
            } else {
              __pyx_t_4 = __pyx_t_12(__pyx_t_2);
              if (unlikely(!__pyx_t_4)) {
                PyObject* exc_type = PyErr_Occurred();
                if (exc_type) {
                  if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 4730, __pyx_L4_error)
                  PyErr_Clear();
                }
                break;
              }
            }
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_4);
            __pyx_t_4 = 0;

            /* "ws_package/controllers/activity_controller.py":4731
 *                     # update intervals - use the original intervals from prev_day_unsent
 *                     for interval in prev_day_unsent:
 *                         await self.activity_service.update_activity_interval(interval)             # <<<<<<<<<<<<<<
 * 
 *                     # update screenshots - use the intervals from the payload
*/
            __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4731, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_13);
            __pyx_t_1 = __pyx_t_13;
            __Pyx_INCREF(__pyx_t_1);
            __pyx_t_5 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_cur_scope->__pyx_v_interval};
              __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_update_activity_interval, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4731, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_4);
            }
            __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (likely(__pyx_t_15 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_2);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
              __Pyx_XGIVEREF(__pyx_t_6);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
              __Pyx_XGIVEREF(__pyx_t_7);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
              __Pyx_XGIVEREF(__pyx_t_8);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_8;
              __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
              __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
              __Pyx_XGIVEREF(__pyx_t_17);
              __pyx_cur_scope->__pyx_t_4 = __pyx_t_17;
              __pyx_cur_scope->__pyx_t_7 = __pyx_t_20;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 3;
              return __pyx_r;
              __pyx_L40_resume_from_await:;
              __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_2);
              __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_6);
              __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_7);
              __pyx_t_8 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_8);
              __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
              __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
              __pyx_t_17 = __pyx_cur_scope->__pyx_t_4;
              __pyx_cur_scope->__pyx_t_4 = 0;
              __Pyx_XGOTREF(__pyx_t_17);
              __pyx_t_20 = __pyx_cur_scope->__pyx_t_7;
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4731, __pyx_L4_error)
            } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_DECREF(__pyx_r); __pyx_r = 0;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 4731, __pyx_L4_error)
            }

            /* "ws_package/controllers/activity_controller.py":4730
 *                 elif _response and _response.get("planStatus") == "active":
 *                     # update intervals - use the original intervals from prev_day_unsent
 *                     for interval in prev_day_unsent:             # <<<<<<<<<<<<<<
 *                         await self.activity_service.update_activity_interval(interval)
 * 
*/
          }
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":4734
 * 
 *                     # update screenshots - use the intervals from the payload
 *                     for interval_payload in payload:             # <<<<<<<<<<<<<<
 *                         screen_url = interval_payload.get("screenUrl")
 *                         if screen_url:
*/
          __pyx_t_2 = __pyx_cur_scope->__pyx_v_payload; __Pyx_INCREF(__pyx_t_2);
          __pyx_t_20 = 0;
          for (;;) {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2);
              #if !CYTHON_ASSUME_SAFE_SIZE
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4734, __pyx_L4_error)
              #endif
              if (__pyx_t_20 >= __pyx_temp) break;
            }
            __pyx_t_4 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_2, __pyx_t_20, __Pyx_ReferenceSharing_OwnStrongReference);
            ++__pyx_t_20;
            if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4734, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval_payload);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval_payload, __pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_4);
            __pyx_t_4 = 0;

            /* "ws_package/controllers/activity_controller.py":4735
 *                     # update screenshots - use the intervals from the payload
 *                     for interval_payload in payload:
 *                         screen_url = interval_payload.get("screenUrl")             # <<<<<<<<<<<<<<
 *                         if screen_url:
 *                             await self.screenshot_controller.update_screenshots(screen_url, self.last_count + 1)
*/
            __pyx_t_13 = __pyx_cur_scope->__pyx_v_interval_payload;
            __Pyx_INCREF(__pyx_t_13);
            __pyx_t_5 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_mstate_global->__pyx_n_u_screenUrl};
              __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4735, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_4);
            }
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_screen_url);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_screen_url, __pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_4);
            __pyx_t_4 = 0;

            /* "ws_package/controllers/activity_controller.py":4736
 *                     for interval_payload in payload:
 *                         screen_url = interval_payload.get("screenUrl")
 *                         if screen_url:             # <<<<<<<<<<<<<<
 *                             await self.screenshot_controller.update_screenshots(screen_url, self.last_count + 1)
 * 
*/
            __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_screen_url); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 4736, __pyx_L4_error)
            if (__pyx_t_10) {

              /* "ws_package/controllers/activity_controller.py":4737
 *                         screen_url = interval_payload.get("screenUrl")
 *                         if screen_url:
 *                             await self.screenshot_controller.update_screenshots(screen_url, self.last_count + 1)             # <<<<<<<<<<<<<<
 * 
 *         except Exception as e:
*/
              __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4737, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_t_13 = __pyx_t_1;
              __Pyx_INCREF(__pyx_t_13);
              __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4737, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_14 = __Pyx_PyLong_AddObjC(__pyx_t_3, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4737, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_14);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __pyx_t_5 = 0;
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_13, __pyx_cur_scope->__pyx_v_screen_url, __pyx_t_14};
                __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_update_screenshots, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4737, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_4);
              }
              __pyx_t_15 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              if (likely(__pyx_t_15 == PYGEN_NEXT)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_XGIVEREF(__pyx_t_2);
                __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
                __Pyx_XGIVEREF(__pyx_t_6);
                __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
                __Pyx_XGIVEREF(__pyx_t_7);
                __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
                __Pyx_XGIVEREF(__pyx_t_8);
                __pyx_cur_scope->__pyx_t_3 = __pyx_t_8;
                __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
                __Pyx_XGIVEREF(__pyx_t_17);
                __pyx_cur_scope->__pyx_t_4 = __pyx_t_17;
                __pyx_cur_scope->__pyx_t_7 = __pyx_t_20;
                __Pyx_XGIVEREF(__pyx_r);
                __Pyx_RefNannyFinishContext();
                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                /* return from generator, awaiting value */
                __pyx_generator->resume_label = 4;
                return __pyx_r;
                __pyx_L45_resume_from_await:;
                __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
                __pyx_cur_scope->__pyx_t_0 = 0;
                __Pyx_XGOTREF(__pyx_t_2);
                __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
                __pyx_cur_scope->__pyx_t_1 = 0;
                __Pyx_XGOTREF(__pyx_t_6);
                __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
                __pyx_cur_scope->__pyx_t_2 = 0;
                __Pyx_XGOTREF(__pyx_t_7);
                __pyx_t_8 = __pyx_cur_scope->__pyx_t_3;
                __pyx_cur_scope->__pyx_t_3 = 0;
                __Pyx_XGOTREF(__pyx_t_8);
                __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
                __pyx_t_17 = __pyx_cur_scope->__pyx_t_4;
                __pyx_cur_scope->__pyx_t_4 = 0;
                __Pyx_XGOTREF(__pyx_t_17);
                __pyx_t_20 = __pyx_cur_scope->__pyx_t_7;
                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4737, __pyx_L4_error)
              } else if (likely(__pyx_t_15 == PYGEN_RETURN)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_DECREF(__pyx_r); __pyx_r = 0;
              } else {
                __Pyx_XGOTREF(__pyx_r);
                __PYX_ERR(0, 4737, __pyx_L4_error)
              }

              /* "ws_package/controllers/activity_controller.py":4736
 *                     for interval_payload in payload:
 *                         screen_url = interval_payload.get("screenUrl")
 *                         if screen_url:             # <<<<<<<<<<<<<<
 *                             await self.screenshot_controller.update_screenshots(screen_url, self.last_count + 1)
 * 
*/
            }

            /* "ws_package/controllers/activity_controller.py":4734
 * 
 *                     # update screenshots - use the intervals from the payload
 *                     for interval_payload in payload:             # <<<<<<<<<<<<<<
 *                         screen_url = interval_payload.get("screenUrl")
 *                         if screen_url:
*/
          }
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":4728
 *                     self.status = False
 * 
 *                 elif _response and _response.get("planStatus") == "active":             # <<<<<<<<<<<<<<
 *                     # update intervals - use the original intervals from prev_day_unsent
 *                     for interval in prev_day_unsent:
*/
        }
        __pyx_L29:;

        /* "ws_package/controllers/activity_controller.py":4702
 *             }
 * 
 *             for response in final_payload:             # <<<<<<<<<<<<<<
 *                 if not response or not isinstance(response, dict):
 *                     logger.info("No interval found %s", [response])
*/
        __pyx_L23_continue:;
      }
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

      /* "ws_package/controllers/activity_controller.py":4610
 *     async def sending_unsent_intervals(self, start, prev_day_unsent, user_entity: UserEntity):
 *         logger.info("Sending previous day unsent intervals")
 *         try:             # <<<<<<<<<<<<<<
 *             # Handle both single entity and list/iterable
 *             if not prev_day_unsent:
*/
    }
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    goto __pyx_L9_try_end;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;

    /* "ws_package/controllers/activity_controller.py":4739
 *                             await self.screenshot_controller.update_screenshots(screen_url, self.last_count + 1)
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Cannot send previous day unsent intervals: %s", e)
 *             logger.error("Exception type: %s", type(e).__name__)
*/
    __pyx_t_21 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_21) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.sending_unsent_intervals", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_17, &__pyx_t_2, &__pyx_t_4) < 0) __PYX_ERR(0, 4739, __pyx_L6_except_error)
      __Pyx_XGOTREF(__pyx_t_17);
      __Pyx_XGOTREF(__pyx_t_2);
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_2);
      __Pyx_GIVEREF(__pyx_t_2);
      __pyx_cur_scope->__pyx_v_e = __pyx_t_2;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":4740
 * 
 *         except Exception as e:
 *             logger.error("Cannot send previous day unsent intervals: %s", e)             # <<<<<<<<<<<<<<
 *             logger.error("Exception type: %s", type(e).__name__)
 * 
*/
        __pyx_t_14 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4740, __pyx_L53_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4740, __pyx_L53_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_5 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_3);
          assert(__pyx_t_14);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_14);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
          __pyx_t_5 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_14, __pyx_mstate_global->__pyx_kp_u_Cannot_send_previous_day_unsent, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4740, __pyx_L53_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":4741
 *         except Exception as e:
 *             logger.error("Cannot send previous day unsent intervals: %s", e)
 *             logger.error("Exception type: %s", type(e).__name__)             # <<<<<<<<<<<<<<
 * 
 *             logger.error("Traceback: %s", traceback.format_exc())
*/
        __pyx_t_3 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4741, __pyx_L53_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4741, __pyx_L53_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_14 = __Pyx_PyObject_GetAttrStr(((PyObject *)Py_TYPE(__pyx_cur_scope->__pyx_v_e)), __pyx_mstate_global->__pyx_n_u_name_2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4741, __pyx_L53_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_5 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_13))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_13);
          assert(__pyx_t_3);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
          __pyx_t_5 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_Exception_type_s, __pyx_t_14};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4741, __pyx_L53_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":4743
 *             logger.error("Exception type: %s", type(e).__name__)
 * 
 *             logger.error("Traceback: %s", traceback.format_exc())             # <<<<<<<<<<<<<<
 * 
 *     def log_system_resources(self):
*/
        __pyx_t_13 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4743, __pyx_L53_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4743, __pyx_L53_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_16 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_traceback); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 4743, __pyx_L53_error)
        __Pyx_GOTREF(__pyx_t_22);
        __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_format_exc); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 4743, __pyx_L53_error)
        __Pyx_GOTREF(__pyx_t_23);
        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
        __pyx_t_5 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_23))) {
          __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_23);
          assert(__pyx_t_16);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_23);
          __Pyx_INCREF(__pyx_t_16);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_23, __pyx__function);
          __pyx_t_5 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_16, NULL};
          __pyx_t_14 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_23, __pyx_callargs+__pyx_t_5, (1-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
          if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4743, __pyx_L53_error)
          __Pyx_GOTREF(__pyx_t_14);
        }
        __pyx_t_5 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_3);
          assert(__pyx_t_13);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
          __pyx_t_5 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Traceback_s, __pyx_t_14};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_5, (3-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4743, __pyx_L53_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      }

      /* "ws_package/controllers/activity_controller.py":4739
 *                             await self.screenshot_controller.update_screenshots(screen_url, self.last_count + 1)
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Cannot send previous day unsent intervals: %s", e)
 *             logger.error("Exception type: %s", type(e).__name__)
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          goto __pyx_L54;
        }
        __pyx_L53_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_29, &__pyx_t_30, &__pyx_t_31);
          if ( unlikely(__Pyx_GetException(&__pyx_t_26, &__pyx_t_27, &__pyx_t_28) < 0)) __Pyx_ErrFetch(&__pyx_t_26, &__pyx_t_27, &__pyx_t_28);
          __Pyx_XGOTREF(__pyx_t_26);
          __Pyx_XGOTREF(__pyx_t_27);
          __Pyx_XGOTREF(__pyx_t_28);
          __Pyx_XGOTREF(__pyx_t_29);
          __Pyx_XGOTREF(__pyx_t_30);
          __Pyx_XGOTREF(__pyx_t_31);
          __pyx_t_21 = __pyx_lineno; __pyx_t_24 = __pyx_clineno; __pyx_t_25 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_29);
          __Pyx_XGIVEREF(__pyx_t_30);
          __Pyx_XGIVEREF(__pyx_t_31);
          __Pyx_ExceptionReset(__pyx_t_29, __pyx_t_30, __pyx_t_31);
          __Pyx_XGIVEREF(__pyx_t_26);
          __Pyx_XGIVEREF(__pyx_t_27);
          __Pyx_XGIVEREF(__pyx_t_28);
          __Pyx_ErrRestore(__pyx_t_26, __pyx_t_27, __pyx_t_28);
          __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0;
          __pyx_lineno = __pyx_t_21; __pyx_clineno = __pyx_t_24; __pyx_filename = __pyx_t_25;
          goto __pyx_L6_except_error;
        }
        __pyx_L54:;
      }
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L5_exception_handled;
    }
    goto __pyx_L6_except_error;

    /* "ws_package/controllers/activity_controller.py":4610
 *     async def sending_unsent_intervals(self, start, prev_day_unsent, user_entity: UserEntity):
 *         logger.info("Sending previous day unsent intervals")
 *         try:             # <<<<<<<<<<<<<<
 *             # Handle both single entity and list/iterable
 *             if not prev_day_unsent:
*/
    __pyx_L6_except_error:;
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
    goto __pyx_L1_error;
    __pyx_L8_try_return:;
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
    goto __pyx_L0;
    __pyx_L5_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
    __pyx_L9_try_end:;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":4608
 *                     return []
 * 
 *     async def sending_unsent_intervals(self, start, prev_day_unsent, user_entity: UserEntity):             # <<<<<<<<<<<<<<
 *         logger.info("Sending previous day unsent intervals")
 *         try:
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_XDECREF(__pyx_t_23);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("sending_unsent_intervals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":4745
 *             logger.error("Traceback: %s", traceback.format_exc())
 * 
 *     def log_system_resources(self):             # <<<<<<<<<<<<<<
 *         """Log CPU and memory usage at every interval"""
 *         try:
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_167log_system_resources(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_166log_system_resources, "Log CPU and memory usage at every interval");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_167log_system_resources = {"log_system_resources", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_167log_system_resources, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_166log_system_resources};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_167log_system_resources(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[1] = {0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("log_system_resources (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 4745, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4745, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "log_system_resources", 0) < (0)) __PYX_ERR(0, 4745, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("log_system_resources", 1, 1, 1, i); __PYX_ERR(0, 4745, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 1)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4745, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("log_system_resources", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 4745, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.log_system_resources", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_166log_system_resources(__pyx_self, __pyx_v_self);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_166log_system_resources(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_v_memory_info = NULL;
  PyObject *__pyx_v_memory_mb = NULL;
  PyObject *__pyx_v_memory_percent = NULL;
  PyObject *__pyx_v_cpu_percent = NULL;
  PyObject *__pyx_v_system_cpu_percent = NULL;
  PyObject *__pyx_v_thread_count = NULL;
  PyObject *__pyx_v_fd_count = NULL;
  PyObject *__pyx_v_e = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  size_t __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  int __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_t_16;
  char const *__pyx_t_17;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("log_system_resources", 0);

  /* "ws_package/controllers/activity_controller.py":4747
 *     def log_system_resources(self):
 *         """Log CPU and memory usage at every interval"""
 *         try:             # <<<<<<<<<<<<<<
 *             # Get memory usage
 *             memory_info = self.process.memory_info()
*/
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":4749
 *         try:
 *             # Get memory usage
 *             memory_info = self.process.memory_info()             # <<<<<<<<<<<<<<
 *             memory_mb = memory_info.rss / 1024 / 1024
 *             memory_percent = self.process.memory_percent()
*/
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_process); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4749, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = __pyx_t_6;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_7 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_memory_info, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4749, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_v_memory_info = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":4750
 *             # Get memory usage
 *             memory_info = self.process.memory_info()
 *             memory_mb = memory_info.rss / 1024 / 1024             # <<<<<<<<<<<<<<
 *             memory_percent = self.process.memory_percent()
 * 
*/
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_memory_info, __pyx_mstate_global->__pyx_n_u_rss); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4750, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = __Pyx_PyLong_TrueDivideObjC(__pyx_t_4, __pyx_mstate_global->__pyx_int_1024, 0x400, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4750, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyLong_TrueDivideObjC(__pyx_t_6, __pyx_mstate_global->__pyx_int_1024, 0x400, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4750, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_v_memory_mb = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":4751
 *             memory_info = self.process.memory_info()
 *             memory_mb = memory_info.rss / 1024 / 1024
 *             memory_percent = self.process.memory_percent()             # <<<<<<<<<<<<<<
 * 
 *             # Get CPU usage
*/
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_process); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4751, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __pyx_t_5;
      __Pyx_INCREF(__pyx_t_6);
      __pyx_t_7 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_memory_percent, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4751, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_v_memory_percent = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":4754
 * 
 *             # Get CPU usage
 *             cpu_percent = self.process.cpu_percent()             # <<<<<<<<<<<<<<
 * 
 *             # Get system-wide CPU usage (non-blocking to prevent memory leaks)
*/
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_process); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4754, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = __pyx_t_6;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_7 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_cpu_percent, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4754, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_v_cpu_percent = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":4757
 * 
 *             # Get system-wide CPU usage (non-blocking to prevent memory leaks)
 *             system_cpu_percent = psutil.cpu_percent()  # Non-blocking call             # <<<<<<<<<<<<<<
 * 
 *             # Get thread count
*/
      __pyx_t_6 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_psutil); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4757, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_cpu_percent); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4757, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_7 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8);
        assert(__pyx_t_6);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
        __pyx_t_7 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4757, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_v_system_cpu_percent = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":4760
 * 
 *             # Get thread count
 *             thread_count = self.process.num_threads()             # <<<<<<<<<<<<<<
 * 
 *             # Get file descriptors (Unix-like systems)
*/
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_process); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4760, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = __pyx_t_6;
      __Pyx_INCREF(__pyx_t_8);
      __pyx_t_7 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_num_threads, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4760, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_v_thread_count = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":4763
 * 
 *             # Get file descriptors (Unix-like systems)
 *             try:             # <<<<<<<<<<<<<<
 *                 fd_count = self.process.num_fds()
 *             except (AttributeError, psutil.AccessDenied):
*/
      {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_ExceptionSave(&__pyx_t_9, &__pyx_t_10, &__pyx_t_11);
        __Pyx_XGOTREF(__pyx_t_9);
        __Pyx_XGOTREF(__pyx_t_10);
        __Pyx_XGOTREF(__pyx_t_11);
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":4764
 *             # Get file descriptors (Unix-like systems)
 *             try:
 *                 fd_count = self.process.num_fds()             # <<<<<<<<<<<<<<
 *             except (AttributeError, psutil.AccessDenied):
 *                 fd_count = "N/A"
*/
          __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_process); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4764, __pyx_L9_error)
          __Pyx_GOTREF(__pyx_t_8);
          __pyx_t_6 = __pyx_t_8;
          __Pyx_INCREF(__pyx_t_6);
          __pyx_t_7 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
            __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_num_fds, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4764, __pyx_L9_error)
            __Pyx_GOTREF(__pyx_t_4);
          }
          __pyx_v_fd_count = __pyx_t_4;
          __pyx_t_4 = 0;

          /* "ws_package/controllers/activity_controller.py":4763
 * 
 *             # Get file descriptors (Unix-like systems)
 *             try:             # <<<<<<<<<<<<<<
 *                 fd_count = self.process.num_fds()
 *             except (AttributeError, psutil.AccessDenied):
*/
        }
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L14_try_end;
        __pyx_L9_error:;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

        /* "ws_package/controllers/activity_controller.py":4765
 *             try:
 *                 fd_count = self.process.num_fds()
 *             except (AttributeError, psutil.AccessDenied):             # <<<<<<<<<<<<<<
 *                 fd_count = "N/A"
 * 
*/
        __Pyx_ErrFetch(&__pyx_t_4, &__pyx_t_8, &__pyx_t_6);
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_psutil); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4765, __pyx_L11_except_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_AccessDenied); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4765, __pyx_L11_except_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_13 = __Pyx_PyErr_GivenExceptionMatches2(__pyx_t_4, ((PyObject *)(((PyTypeObject*)PyExc_AttributeError))), __pyx_t_12);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_ErrRestore(__pyx_t_4, __pyx_t_8, __pyx_t_6);
        __pyx_t_4 = 0; __pyx_t_8 = 0; __pyx_t_6 = 0;
        if (__pyx_t_13) {
          __Pyx_ErrRestore(0,0,0);

          /* "ws_package/controllers/activity_controller.py":4766
 *                 fd_count = self.process.num_fds()
 *             except (AttributeError, psutil.AccessDenied):
 *                 fd_count = "N/A"             # <<<<<<<<<<<<<<
 * 
 *             logger.info(
*/
          __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_N_A);
          __Pyx_XDECREF_SET(__pyx_v_fd_count, __pyx_mstate_global->__pyx_kp_u_N_A);
          goto __pyx_L10_exception_handled;
        }
        goto __pyx_L11_except_error;

        /* "ws_package/controllers/activity_controller.py":4763
 * 
 *             # Get file descriptors (Unix-like systems)
 *             try:             # <<<<<<<<<<<<<<
 *                 fd_count = self.process.num_fds()
 *             except (AttributeError, psutil.AccessDenied):
*/
        __pyx_L11_except_error:;
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
        goto __pyx_L3_error;
        __pyx_L10_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_XGIVEREF(__pyx_t_10);
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_ExceptionReset(__pyx_t_9, __pyx_t_10, __pyx_t_11);
        __pyx_L14_try_end:;
      }

      /* "ws_package/controllers/activity_controller.py":4768
 *                 fd_count = "N/A"
 * 
 *             logger.info(             # <<<<<<<<<<<<<<
 *                 "[SYSTEM_RESOURCES] Memory: %.2fMB (%.1f%%), CPU: %.1f%% (System: %.1f%%), Threads: %s, FDs: %s",
 *                 memory_mb, memory_percent, cpu_percent, system_cpu_percent, thread_count, fd_count)
*/
      __pyx_t_8 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4768, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4768, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":4770
 *             logger.info(
 *                 "[SYSTEM_RESOURCES] Memory: %.2fMB (%.1f%%), CPU: %.1f%% (System: %.1f%%), Threads: %s, FDs: %s",
 *                 memory_mb, memory_percent, cpu_percent, system_cpu_percent, thread_count, fd_count)             # <<<<<<<<<<<<<<
 * 
 *             self._memory_check_counter += 1
*/
      __pyx_t_7 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_12))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_12);
        assert(__pyx_t_8);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
        __pyx_t_7 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[8] = {__pyx_t_8, __pyx_mstate_global->__pyx_kp_u_SYSTEM_RESOURCES_Memory_2fMB_1f, __pyx_v_memory_mb, __pyx_v_memory_percent, __pyx_v_cpu_percent, __pyx_v_system_cpu_percent, __pyx_v_thread_count, __pyx_v_fd_count};
        __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_7, (8-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4768, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_6);
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":4772
 *                 memory_mb, memory_percent, cpu_percent, system_cpu_percent, thread_count, fd_count)
 * 
 *             self._memory_check_counter += 1             # <<<<<<<<<<<<<<
 * 
 *             return {
*/
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_memory_check_counter); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4772, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_12 = __Pyx_PyLong_AddObjC(__pyx_t_6, __pyx_mstate_global->__pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4772, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_memory_check_counter, __pyx_t_12) < (0)) __PYX_ERR(0, 4772, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

      /* "ws_package/controllers/activity_controller.py":4774
 *             self._memory_check_counter += 1
 * 
 *             return {             # <<<<<<<<<<<<<<
 *                 'memory_mb': memory_mb,
 *                 'memory_percent': memory_percent,
*/
      __Pyx_XDECREF(__pyx_r);

      /* "ws_package/controllers/activity_controller.py":4775
 * 
 *             return {
 *                 'memory_mb': memory_mb,             # <<<<<<<<<<<<<<
 *                 'memory_percent': memory_percent,
 *                 'cpu_percent': cpu_percent,
*/
      __pyx_t_12 = __Pyx_PyDict_NewPresized(6); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4775, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_12);
      if (PyDict_SetItem(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_memory_mb, __pyx_v_memory_mb) < (0)) __PYX_ERR(0, 4775, __pyx_L3_error)

      /* "ws_package/controllers/activity_controller.py":4776
 *             return {
 *                 'memory_mb': memory_mb,
 *                 'memory_percent': memory_percent,             # <<<<<<<<<<<<<<
 *                 'cpu_percent': cpu_percent,
 *                 'system_cpu_percent': system_cpu_percent,
*/
      if (PyDict_SetItem(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_memory_percent, __pyx_v_memory_percent) < (0)) __PYX_ERR(0, 4775, __pyx_L3_error)

      /* "ws_package/controllers/activity_controller.py":4777
 *                 'memory_mb': memory_mb,
 *                 'memory_percent': memory_percent,
 *                 'cpu_percent': cpu_percent,             # <<<<<<<<<<<<<<
 *                 'system_cpu_percent': system_cpu_percent,
 *                 'thread_count': thread_count,
*/
      if (PyDict_SetItem(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_cpu_percent, __pyx_v_cpu_percent) < (0)) __PYX_ERR(0, 4775, __pyx_L3_error)

      /* "ws_package/controllers/activity_controller.py":4778
 *                 'memory_percent': memory_percent,
 *                 'cpu_percent': cpu_percent,
 *                 'system_cpu_percent': system_cpu_percent,             # <<<<<<<<<<<<<<
 *                 'thread_count': thread_count,
 *                 'fd_count': fd_count
*/
      if (PyDict_SetItem(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_system_cpu_percent, __pyx_v_system_cpu_percent) < (0)) __PYX_ERR(0, 4775, __pyx_L3_error)

      /* "ws_package/controllers/activity_controller.py":4779
 *                 'cpu_percent': cpu_percent,
 *                 'system_cpu_percent': system_cpu_percent,
 *                 'thread_count': thread_count,             # <<<<<<<<<<<<<<
 *                 'fd_count': fd_count
 *             }
*/
      if (PyDict_SetItem(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_thread_count, __pyx_v_thread_count) < (0)) __PYX_ERR(0, 4775, __pyx_L3_error)

      /* "ws_package/controllers/activity_controller.py":4780
 *                 'system_cpu_percent': system_cpu_percent,
 *                 'thread_count': thread_count,
 *                 'fd_count': fd_count             # <<<<<<<<<<<<<<
 *             }
 *         except Exception as e:
*/
      if (PyDict_SetItem(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_fd_count, __pyx_v_fd_count) < (0)) __PYX_ERR(0, 4775, __pyx_L3_error)
      __pyx_r = __pyx_t_12;
      __pyx_t_12 = 0;
      goto __pyx_L7_try_return;

      /* "ws_package/controllers/activity_controller.py":4747
 *     def log_system_resources(self):
 *         """Log CPU and memory usage at every interval"""
 *         try:             # <<<<<<<<<<<<<<
 *             # Get memory usage
 *             memory_info = self.process.memory_info()
*/
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "ws_package/controllers/activity_controller.py":4782
 *                 'fd_count': fd_count
 *             }
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error logging system resources: %s", e)
 *             return None
*/
    __pyx_t_13 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_13) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.log_system_resources", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_12, &__pyx_t_6, &__pyx_t_8) < 0) __PYX_ERR(0, 4782, __pyx_L5_except_error)
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_INCREF(__pyx_t_6);
      __pyx_v_e = __pyx_t_6;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":4783
 *             }
 *         except Exception as e:
 *             logger.error("Error logging system resources: %s", e)             # <<<<<<<<<<<<<<
 *             return None
 * 
*/
        __pyx_t_5 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 4783, __pyx_L22_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4783, __pyx_L22_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_15))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_15);
          assert(__pyx_t_5);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Error_logging_system_resources_s, __pyx_v_e};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4783, __pyx_L22_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":4784
 *         except Exception as e:
 *             logger.error("Error logging system resources: %s", e)
 *             return None             # <<<<<<<<<<<<<<
 * 
 *     def check_memory_usage(self):
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        goto __pyx_L21_return;
      }

      /* "ws_package/controllers/activity_controller.py":4782
 *                 'fd_count': fd_count
 *             }
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error logging system resources: %s", e)
 *             return None
*/
      /*finally:*/ {
        __pyx_L22_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_9 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20);
          if ( unlikely(__Pyx_GetException(&__pyx_t_11, &__pyx_t_10, &__pyx_t_9) < 0)) __Pyx_ErrFetch(&__pyx_t_11, &__pyx_t_10, &__pyx_t_9);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_9);
          __Pyx_XGOTREF(__pyx_t_18);
          __Pyx_XGOTREF(__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_20);
          __pyx_t_13 = __pyx_lineno; __pyx_t_16 = __pyx_clineno; __pyx_t_17 = __pyx_filename;
          {
            __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_9);
          __Pyx_ErrRestore(__pyx_t_11, __pyx_t_10, __pyx_t_9);
          __pyx_t_11 = 0; __pyx_t_10 = 0; __pyx_t_9 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
          __pyx_lineno = __pyx_t_13; __pyx_clineno = __pyx_t_16; __pyx_filename = __pyx_t_17;
          goto __pyx_L5_except_error;
        }
        __pyx_L21_return: {
          __pyx_t_20 = __pyx_r;
          __pyx_r = 0;
          __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
          __pyx_r = __pyx_t_20;
          __pyx_t_20 = 0;
          goto __pyx_L6_except_return;
        }
      }
    }
    goto __pyx_L5_except_error;

    /* "ws_package/controllers/activity_controller.py":4747
 *     def log_system_resources(self):
 *         """Log CPU and memory usage at every interval"""
 *         try:             # <<<<<<<<<<<<<<
 *             # Get memory usage
 *             memory_info = self.process.memory_info()
*/
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }

  /* "ws_package/controllers/activity_controller.py":4745
 *             logger.error("Traceback: %s", traceback.format_exc())
 * 
 *     def log_system_resources(self):             # <<<<<<<<<<<<<<
 *         """Log CPU and memory usage at every interval"""
 *         try:
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.log_system_resources", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_memory_info);
  __Pyx_XDECREF(__pyx_v_memory_mb);
  __Pyx_XDECREF(__pyx_v_memory_percent);
  __Pyx_XDECREF(__pyx_v_cpu_percent);
  __Pyx_XDECREF(__pyx_v_system_cpu_percent);
  __Pyx_XDECREF(__pyx_v_thread_count);
  __Pyx_XDECREF(__pyx_v_fd_count);
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":4786
 *             return None
 * 
 *     def check_memory_usage(self):             # <<<<<<<<<<<<<<
 *         """Check if memory usage is approaching limits"""
 *         try:
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_169check_memory_usage(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_168check_memory_usage, "Check if memory usage is approaching limits");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_169check_memory_usage = {"check_memory_usage", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_169check_memory_usage, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_168check_memory_usage};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_169check_memory_usage(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[1] = {0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("check_memory_usage (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 4786, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4786, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "check_memory_usage", 0) < (0)) __PYX_ERR(0, 4786, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("check_memory_usage", 1, 1, 1, i); __PYX_ERR(0, 4786, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 1)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4786, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("check_memory_usage", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 4786, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.check_memory_usage", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_168check_memory_usage(__pyx_self, __pyx_v_self);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_168check_memory_usage(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_v_memory_info = NULL;
  PyObject *__pyx_v_memory_mb = NULL;
  PyObject *__pyx_v_e = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  size_t __pyx_t_7;
  int __pyx_t_8;
  PyObject *__pyx_t_9 = NULL;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  char const *__pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("check_memory_usage", 0);

  /* "ws_package/controllers/activity_controller.py":4788
 *     def check_memory_usage(self):
 *         """Check if memory usage is approaching limits"""
 *         try:             # <<<<<<<<<<<<<<
 *             memory_info = self.process.memory_info()
 *             memory_mb = memory_info.rss / 1024 / 1024
*/
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":4789
 *         """Check if memory usage is approaching limits"""
 *         try:
 *             memory_info = self.process.memory_info()             # <<<<<<<<<<<<<<
 *             memory_mb = memory_info.rss / 1024 / 1024
 * 
*/
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_process); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4789, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = __pyx_t_6;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_7 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_memory_info, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4789, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_v_memory_info = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":4790
 *         try:
 *             memory_info = self.process.memory_info()
 *             memory_mb = memory_info.rss / 1024 / 1024             # <<<<<<<<<<<<<<
 * 
 *             if memory_mb > self.memory_limit_mb:
*/
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_memory_info, __pyx_mstate_global->__pyx_n_u_rss); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4790, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = __Pyx_PyLong_TrueDivideObjC(__pyx_t_4, __pyx_mstate_global->__pyx_int_1024, 0x400, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4790, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_4 = __Pyx_PyLong_TrueDivideObjC(__pyx_t_6, __pyx_mstate_global->__pyx_int_1024, 0x400, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4790, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_v_memory_mb = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":4792
 *             memory_mb = memory_info.rss / 1024 / 1024
 * 
 *             if memory_mb > self.memory_limit_mb:             # <<<<<<<<<<<<<<
 *                 logger.warning("[MEMORY_WARNING] Memory usage high: %sMB (limit: %sMB)", memory_mb, self.memory_limit_mb)
 *                 return True  # Memory warning triggered
*/
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_memory_limit_mb); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4792, __pyx_L3_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = PyObject_RichCompare(__pyx_v_memory_mb, __pyx_t_4, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4792, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 4792, __pyx_L3_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (__pyx_t_8) {

        /* "ws_package/controllers/activity_controller.py":4793
 * 
 *             if memory_mb > self.memory_limit_mb:
 *                 logger.warning("[MEMORY_WARNING] Memory usage high: %sMB (limit: %sMB)", memory_mb, self.memory_limit_mb)             # <<<<<<<<<<<<<<
 *                 return True  # Memory warning triggered
 * 
*/
        __pyx_t_4 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4793, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4793, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_memory_limit_mb); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4793, __pyx_L3_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_9);
          assert(__pyx_t_4);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[4] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_MEMORY_WARNING_Memory_usage_hig, __pyx_v_memory_mb, __pyx_t_5};
          __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_7, (4-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4793, __pyx_L3_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "ws_package/controllers/activity_controller.py":4794
 *             if memory_mb > self.memory_limit_mb:
 *                 logger.warning("[MEMORY_WARNING] Memory usage high: %sMB (limit: %sMB)", memory_mb, self.memory_limit_mb)
 *                 return True  # Memory warning triggered             # <<<<<<<<<<<<<<
 * 
 *             return False
*/
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_True);
        __pyx_r = Py_True;
        goto __pyx_L7_try_return;

        /* "ws_package/controllers/activity_controller.py":4792
 *             memory_mb = memory_info.rss / 1024 / 1024
 * 
 *             if memory_mb > self.memory_limit_mb:             # <<<<<<<<<<<<<<
 *                 logger.warning("[MEMORY_WARNING] Memory usage high: %sMB (limit: %sMB)", memory_mb, self.memory_limit_mb)
 *                 return True  # Memory warning triggered
*/
      }

      /* "ws_package/controllers/activity_controller.py":4796
 *                 return True  # Memory warning triggered
 * 
 *             return False             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             logger.error("Error checking memory usage: %s", e)
*/
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_False);
      __pyx_r = Py_False;
      goto __pyx_L7_try_return;

      /* "ws_package/controllers/activity_controller.py":4788
 *     def check_memory_usage(self):
 *         """Check if memory usage is approaching limits"""
 *         try:             # <<<<<<<<<<<<<<
 *             memory_info = self.process.memory_info()
 *             memory_mb = memory_info.rss / 1024 / 1024
*/
    }
    __pyx_L3_error:;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "ws_package/controllers/activity_controller.py":4797
 * 
 *             return False
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error checking memory usage: %s", e)
 *             return False
*/
    __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_10) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.check_memory_usage", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_9, &__pyx_t_5) < 0) __PYX_ERR(0, 4797, __pyx_L5_except_error)
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_9);
      __pyx_v_e = __pyx_t_9;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":4798
 *             return False
 *         except Exception as e:
 *             logger.error("Error checking memory usage: %s", e)             # <<<<<<<<<<<<<<
 *             return False
 * 
*/
        __pyx_t_11 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 4798, __pyx_L15_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 4798, __pyx_L15_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_7 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_13))) {
          __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_13);
          assert(__pyx_t_11);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
          __pyx_t_7 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_11, __pyx_mstate_global->__pyx_kp_u_Error_checking_memory_usage_s, __pyx_v_e};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_7, (3-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4798, __pyx_L15_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":4799
 *         except Exception as e:
 *             logger.error("Error checking memory usage: %s", e)
 *             return False             # <<<<<<<<<<<<<<
 * 
 *     def _finalize_work_stop_time(
*/
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_False);
        __pyx_r = Py_False;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L14_return;
      }

      /* "ws_package/controllers/activity_controller.py":4797
 * 
 *             return False
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error checking memory usage: %s", e)
 *             return False
*/
      /*finally:*/ {
        __pyx_L15_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_declare
          __Pyx_PyThreadState_assign
          __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21);
          if ( unlikely(__Pyx_GetException(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18) < 0)) __Pyx_ErrFetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
          __Pyx_XGOTREF(__pyx_t_16);
          __Pyx_XGOTREF(__pyx_t_17);
          __Pyx_XGOTREF(__pyx_t_18);
          __Pyx_XGOTREF(__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_21);
          __pyx_t_10 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_15 = __pyx_filename;
          {
            __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_16);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_ErrRestore(__pyx_t_16, __pyx_t_17, __pyx_t_18);
          __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0;
          __pyx_lineno = __pyx_t_10; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_15;
          goto __pyx_L5_except_error;
        }
        __pyx_L14_return: {
          __pyx_t_21 = __pyx_r;
          __pyx_r = 0;
          __Pyx_DECREF(__pyx_v_e); __pyx_v_e = 0;
          __pyx_r = __pyx_t_21;
          __pyx_t_21 = 0;
          goto __pyx_L6_except_return;
        }
      }
    }
    goto __pyx_L5_except_error;

    /* "ws_package/controllers/activity_controller.py":4788
 *     def check_memory_usage(self):
 *         """Check if memory usage is approaching limits"""
 *         try:             # <<<<<<<<<<<<<<
 *             memory_info = self.process.memory_info()
 *             memory_mb = memory_info.rss / 1024 / 1024
*/
    __pyx_L5_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L7_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L6_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }

  /* "ws_package/controllers/activity_controller.py":4786
 *             return None
 * 
 *     def check_memory_usage(self):             # <<<<<<<<<<<<<<
 *         """Check if memory usage is approaching limits"""
 *         try:
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.check_memory_usage", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_memory_info);
  __Pyx_XDECREF(__pyx_v_memory_mb);
  __Pyx_XDECREF(__pyx_v_e);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":4801
 *             return False
 * 
 *     def _finalize_work_stop_time(             # <<<<<<<<<<<<<<
 *         self,
 *         last_interval=None,
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_171_finalize_work_stop_time(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_170_finalize_work_stop_time, "Set work-segment stop from last regular interval end (not processing clock).");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_171_finalize_work_stop_time = {"_finalize_work_stop_time", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_171_finalize_work_stop_time, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_170_finalize_work_stop_time};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_171_finalize_work_stop_time(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_last_interval = 0;
  PyObject *__pyx_v_intervals = 0;
  PyObject *__pyx_v_fallback_end = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[4] = {0,0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_finalize_work_stop_time (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_last_interval,&__pyx_mstate_global->__pyx_n_u_intervals,&__pyx_mstate_global->__pyx_n_u_fallback_end,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 4801, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  4:
        values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 4801, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 4801, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 4801, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4801, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_finalize_work_stop_time", 0) < (0)) __PYX_ERR(0, 4801, __pyx_L3_error)

      /* "ws_package/controllers/activity_controller.py":4803
 *     def _finalize_work_stop_time(
 *         self,
 *         last_interval=None,             # <<<<<<<<<<<<<<
 *         intervals=None,
 *         fallback_end: Optional[datetime.datetime] = None,
*/
      if (!values[1]) values[1] = __Pyx_NewRef(((PyObject *)Py_None));

      /* "ws_package/controllers/activity_controller.py":4804
 *         self,
 *         last_interval=None,
 *         intervals=None,             # <<<<<<<<<<<<<<
 *         fallback_end: Optional[datetime.datetime] = None,
 *     ) -> datetime.datetime:
*/
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject *)Py_None));

      /* "ws_package/controllers/activity_controller.py":4805
 *         last_interval=None,
 *         intervals=None,
 *         fallback_end: Optional[datetime.datetime] = None,             # <<<<<<<<<<<<<<
 *     ) -> datetime.datetime:
 *         """Set work-segment stop from last regular interval end (not processing clock)."""
*/
      if (!values[3]) values[3] = __Pyx_NewRef(((PyObject *)Py_None));
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_finalize_work_stop_time", 0, 1, 4, i); __PYX_ERR(0, 4801, __pyx_L3_error) }
      }
    } else {
      switch (__pyx_nargs) {
        case  4:
        values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 4801, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 4801, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 4801, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4801, __pyx_L3_error)
        break;
        default: goto __pyx_L5_argtuple_error;
      }

      /* "ws_package/controllers/activity_controller.py":4803
 *     def _finalize_work_stop_time(
 *         self,
 *         last_interval=None,             # <<<<<<<<<<<<<<
 *         intervals=None,
 *         fallback_end: Optional[datetime.datetime] = None,
*/
      if (!values[1]) values[1] = __Pyx_NewRef(((PyObject *)Py_None));

      /* "ws_package/controllers/activity_controller.py":4804
 *         self,
 *         last_interval=None,
 *         intervals=None,             # <<<<<<<<<<<<<<
 *         fallback_end: Optional[datetime.datetime] = None,
 *     ) -> datetime.datetime:
*/
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject *)Py_None));

      /* "ws_package/controllers/activity_controller.py":4805
 *         last_interval=None,
 *         intervals=None,
 *         fallback_end: Optional[datetime.datetime] = None,             # <<<<<<<<<<<<<<
 *     ) -> datetime.datetime:
 *         """Set work-segment stop from last regular interval end (not processing clock)."""
*/
      if (!values[3]) values[3] = __Pyx_NewRef(((PyObject *)Py_None));
    }
    __pyx_v_self = values[0];
    __pyx_v_last_interval = values[1];
    __pyx_v_intervals = values[2];
    __pyx_v_fallback_end = values[3];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_finalize_work_stop_time", 0, 1, 4, __pyx_nargs); __PYX_ERR(0, 4801, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._finalize_work_stop_time", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_170_finalize_work_stop_time(__pyx_self, __pyx_v_self, __pyx_v_last_interval, __pyx_v_intervals, __pyx_v_fallback_end);

  /* "ws_package/controllers/activity_controller.py":4801
 *             return False
 * 
 *     def _finalize_work_stop_time(             # <<<<<<<<<<<<<<
 *         self,
 *         last_interval=None,
*/

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_170_finalize_work_stop_time(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_last_interval, PyObject *__pyx_v_intervals, PyObject *__pyx_v_fallback_end) {
  PyObject *__pyx_v_candidate = NULL;
  PyObject *__pyx_v_iv = NULL;
  PyObject *__pyx_v_is_break = NULL;
  PyObject *__pyx_v_et = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  Py_ssize_t __pyx_t_4;
  PyObject *(*__pyx_t_5)(PyObject *);
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  size_t __pyx_t_9;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_finalize_work_stop_time", 0);

  /* "ws_package/controllers/activity_controller.py":4808
 *     ) -> datetime.datetime:
 *         """Set work-segment stop from last regular interval end (not processing clock)."""
 *         candidate: Optional[datetime.datetime] = None             # <<<<<<<<<<<<<<
 *         if last_interval is not None and getattr(last_interval, 'end_time', None):
 *             candidate = last_interval.end_time
*/
  __Pyx_INCREF(Py_None);
  __pyx_v_candidate = Py_None;

  /* "ws_package/controllers/activity_controller.py":4809
 *         """Set work-segment stop from last regular interval end (not processing clock)."""
 *         candidate: Optional[datetime.datetime] = None
 *         if last_interval is not None and getattr(last_interval, 'end_time', None):             # <<<<<<<<<<<<<<
 *             candidate = last_interval.end_time
 *         if intervals:
*/
  __pyx_t_2 = (__pyx_v_last_interval != Py_None);
  if (__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_3 = __Pyx_GetAttr3(__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_end_time, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4809, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 4809, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "ws_package/controllers/activity_controller.py":4810
 *         candidate: Optional[datetime.datetime] = None
 *         if last_interval is not None and getattr(last_interval, 'end_time', None):
 *             candidate = last_interval.end_time             # <<<<<<<<<<<<<<
 *         if intervals:
 *             for iv in intervals:
*/
    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4810, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
    __Pyx_DECREF_SET(__pyx_v_candidate, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "ws_package/controllers/activity_controller.py":4809
 *         """Set work-segment stop from last regular interval end (not processing clock)."""
 *         candidate: Optional[datetime.datetime] = None
 *         if last_interval is not None and getattr(last_interval, 'end_time', None):             # <<<<<<<<<<<<<<
 *             candidate = last_interval.end_time
 *         if intervals:
*/
  }

  /* "ws_package/controllers/activity_controller.py":4811
 *         if last_interval is not None and getattr(last_interval, 'end_time', None):
 *             candidate = last_interval.end_time
 *         if intervals:             # <<<<<<<<<<<<<<
 *             for iv in intervals:
 *                 is_break = getattr(iv, 'is_break', 0) or 0
*/
  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_intervals); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 4811, __pyx_L1_error)
  if (__pyx_t_1) {

    /* "ws_package/controllers/activity_controller.py":4812
 *             candidate = last_interval.end_time
 *         if intervals:
 *             for iv in intervals:             # <<<<<<<<<<<<<<
 *                 is_break = getattr(iv, 'is_break', 0) or 0
 *                 if is_break not in (0, None, False):
*/
    if (likely(PyList_CheckExact(__pyx_v_intervals)) || PyTuple_CheckExact(__pyx_v_intervals)) {
      __pyx_t_3 = __pyx_v_intervals; __Pyx_INCREF(__pyx_t_3);
      __pyx_t_4 = 0;
      __pyx_t_5 = NULL;
    } else {
      __pyx_t_4 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_intervals); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4812, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_5 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4812, __pyx_L1_error)
    }
    for (;;) {
      if (likely(!__pyx_t_5)) {
        if (likely(PyList_CheckExact(__pyx_t_3))) {
          {
            Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_3);
            #if !CYTHON_ASSUME_SAFE_SIZE
            if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4812, __pyx_L1_error)
            #endif
            if (__pyx_t_4 >= __pyx_temp) break;
          }
          __pyx_t_6 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_3, __pyx_t_4, __Pyx_ReferenceSharing_OwnStrongReference);
          ++__pyx_t_4;
        } else {
          {
            Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_3);
            #if !CYTHON_ASSUME_SAFE_SIZE
            if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 4812, __pyx_L1_error)
            #endif
            if (__pyx_t_4 >= __pyx_temp) break;
          }
          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
          __pyx_t_6 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_4));
          #else
          __pyx_t_6 = __Pyx_PySequence_ITEM(__pyx_t_3, __pyx_t_4);
          #endif
          ++__pyx_t_4;
        }
        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4812, __pyx_L1_error)
      } else {
        __pyx_t_6 = __pyx_t_5(__pyx_t_3);
        if (unlikely(!__pyx_t_6)) {
          PyObject* exc_type = PyErr_Occurred();
          if (exc_type) {
            if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 4812, __pyx_L1_error)
            PyErr_Clear();
          }
          break;
        }
      }
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_XDECREF_SET(__pyx_v_iv, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":4813
 *         if intervals:
 *             for iv in intervals:
 *                 is_break = getattr(iv, 'is_break', 0) or 0             # <<<<<<<<<<<<<<
 *                 if is_break not in (0, None, False):
 *                     continue
*/
      __pyx_t_7 = __Pyx_GetAttr3(__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_is_break, __pyx_mstate_global->__pyx_int_0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4813, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 4813, __pyx_L1_error)
      if (!__pyx_t_1) {
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      } else {
        __Pyx_INCREF(__pyx_t_7);
        __pyx_t_6 = __pyx_t_7;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L9_bool_binop_done;
      }
      __pyx_t_7 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4813, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = __pyx_t_7;
      __pyx_t_7 = 0;
      __pyx_L9_bool_binop_done:;
      __Pyx_XDECREF_SET(__pyx_v_is_break, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":4814
 *             for iv in intervals:
 *                 is_break = getattr(iv, 'is_break', 0) or 0
 *                 if is_break not in (0, None, False):             # <<<<<<<<<<<<<<
 *                     continue
 *                 et = getattr(iv, 'end_time', None)
*/
      __Pyx_INCREF(__pyx_v_is_break);
      __pyx_t_6 = __pyx_v_is_break;
      __pyx_t_2 = (__Pyx_PyLong_BoolNeObjC(__pyx_t_6, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 4814, __pyx_L1_error)
      if (__pyx_t_2) {
      } else {
        __pyx_t_1 = __pyx_t_2;
        goto __pyx_L12_bool_binop_done;
      }
      __pyx_t_7 = PyObject_RichCompare(__pyx_t_6, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4814, __pyx_L1_error)
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 4814, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (__pyx_t_2) {
      } else {
        __pyx_t_1 = __pyx_t_2;
        goto __pyx_L12_bool_binop_done;
      }
      __pyx_t_7 = PyObject_RichCompare(__pyx_t_6, Py_False, Py_NE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4814, __pyx_L1_error)
      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_2 < 0))) __PYX_ERR(0, 4814, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_1 = __pyx_t_2;
      __pyx_L12_bool_binop_done:;
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_2 = __pyx_t_1;
      if (__pyx_t_2) {

        /* "ws_package/controllers/activity_controller.py":4815
 *                 is_break = getattr(iv, 'is_break', 0) or 0
 *                 if is_break not in (0, None, False):
 *                     continue             # <<<<<<<<<<<<<<
 *                 et = getattr(iv, 'end_time', None)
 *                 if et is not None and (candidate is None or et > candidate):
*/
        goto __pyx_L7_continue;

        /* "ws_package/controllers/activity_controller.py":4814
 *             for iv in intervals:
 *                 is_break = getattr(iv, 'is_break', 0) or 0
 *                 if is_break not in (0, None, False):             # <<<<<<<<<<<<<<
 *                     continue
 *                 et = getattr(iv, 'end_time', None)
*/
      }

      /* "ws_package/controllers/activity_controller.py":4816
 *                 if is_break not in (0, None, False):
 *                     continue
 *                 et = getattr(iv, 'end_time', None)             # <<<<<<<<<<<<<<
 *                 if et is not None and (candidate is None or et > candidate):
 *                     candidate = et
*/
      __pyx_t_6 = __Pyx_GetAttr3(__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_end_time, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4816, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_XDECREF_SET(__pyx_v_et, __pyx_t_6);
      __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":4817
 *                     continue
 *                 et = getattr(iv, 'end_time', None)
 *                 if et is not None and (candidate is None or et > candidate):             # <<<<<<<<<<<<<<
 *                     candidate = et
 *         if candidate is None and fallback_end is not None:
*/
      __pyx_t_1 = (__pyx_v_et != Py_None);
      if (__pyx_t_1) {
      } else {
        __pyx_t_2 = __pyx_t_1;
        goto __pyx_L16_bool_binop_done;
      }
      __pyx_t_1 = (__pyx_v_candidate == Py_None);
      if (!__pyx_t_1) {
      } else {
        __pyx_t_2 = __pyx_t_1;
        goto __pyx_L16_bool_binop_done;
      }
      __pyx_t_6 = PyObject_RichCompare(__pyx_v_et, __pyx_v_candidate, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4817, __pyx_L1_error)
      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_1 < 0))) __PYX_ERR(0, 4817, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_2 = __pyx_t_1;
      __pyx_L16_bool_binop_done:;
      if (__pyx_t_2) {

        /* "ws_package/controllers/activity_controller.py":4818
 *                 et = getattr(iv, 'end_time', None)
 *                 if et is not None and (candidate is None or et > candidate):
 *                     candidate = et             # <<<<<<<<<<<<<<
 *         if candidate is None and fallback_end is not None:
 *             candidate = fallback_end
*/
        __Pyx_INCREF(__pyx_v_et);
        __Pyx_DECREF_SET(__pyx_v_candidate, __pyx_v_et);

        /* "ws_package/controllers/activity_controller.py":4817
 *                     continue
 *                 et = getattr(iv, 'end_time', None)
 *                 if et is not None and (candidate is None or et > candidate):             # <<<<<<<<<<<<<<
 *                     candidate = et
 *         if candidate is None and fallback_end is not None:
*/
      }

      /* "ws_package/controllers/activity_controller.py":4812
 *             candidate = last_interval.end_time
 *         if intervals:
 *             for iv in intervals:             # <<<<<<<<<<<<<<
 *                 is_break = getattr(iv, 'is_break', 0) or 0
 *                 if is_break not in (0, None, False):
*/
      __pyx_L7_continue:;
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "ws_package/controllers/activity_controller.py":4811
 *         if last_interval is not None and getattr(last_interval, 'end_time', None):
 *             candidate = last_interval.end_time
 *         if intervals:             # <<<<<<<<<<<<<<
 *             for iv in intervals:
 *                 is_break = getattr(iv, 'is_break', 0) or 0
*/
  }

  /* "ws_package/controllers/activity_controller.py":4819
 *                 if et is not None and (candidate is None or et > candidate):
 *                     candidate = et
 *         if candidate is None and fallback_end is not None:             # <<<<<<<<<<<<<<
 *             candidate = fallback_end
 *         if candidate is None:
*/
  __pyx_t_1 = (__pyx_v_candidate == Py_None);
  if (__pyx_t_1) {
  } else {
    __pyx_t_2 = __pyx_t_1;
    goto __pyx_L21_bool_binop_done;
  }
  __pyx_t_1 = (__pyx_v_fallback_end != Py_None);
  __pyx_t_2 = __pyx_t_1;
  __pyx_L21_bool_binop_done:;
  if (__pyx_t_2) {

    /* "ws_package/controllers/activity_controller.py":4820
 *                     candidate = et
 *         if candidate is None and fallback_end is not None:
 *             candidate = fallback_end             # <<<<<<<<<<<<<<
 *         if candidate is None:
 *             candidate = datetime.datetime.now()
*/
    __Pyx_INCREF(__pyx_v_fallback_end);
    __Pyx_DECREF_SET(__pyx_v_candidate, __pyx_v_fallback_end);

    /* "ws_package/controllers/activity_controller.py":4819
 *                 if et is not None and (candidate is None or et > candidate):
 *                     candidate = et
 *         if candidate is None and fallback_end is not None:             # <<<<<<<<<<<<<<
 *             candidate = fallback_end
 *         if candidate is None:
*/
  }

  /* "ws_package/controllers/activity_controller.py":4821
 *         if candidate is None and fallback_end is not None:
 *             candidate = fallback_end
 *         if candidate is None:             # <<<<<<<<<<<<<<
 *             candidate = datetime.datetime.now()
 *         self._last_work_stop_time = candidate.replace(microsecond=0)
*/
  __pyx_t_2 = (__pyx_v_candidate == Py_None);
  if (__pyx_t_2) {

    /* "ws_package/controllers/activity_controller.py":4822
 *             candidate = fallback_end
 *         if candidate is None:
 *             candidate = datetime.datetime.now()             # <<<<<<<<<<<<<<
 *         self._last_work_stop_time = candidate.replace(microsecond=0)
 *         return self._last_work_stop_time
*/
    __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4822, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4822, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_6 = __pyx_t_8;
    __Pyx_INCREF(__pyx_t_6);
    __pyx_t_9 = 0;
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
      __pyx_t_3 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_9, (1-__pyx_t_9) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4822, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_DECREF_SET(__pyx_v_candidate, __pyx_t_3);
    __pyx_t_3 = 0;

    /* "ws_package/controllers/activity_controller.py":4821
 *         if candidate is None and fallback_end is not None:
 *             candidate = fallback_end
 *         if candidate is None:             # <<<<<<<<<<<<<<
 *             candidate = datetime.datetime.now()
 *         self._last_work_stop_time = candidate.replace(microsecond=0)
*/
  }

  /* "ws_package/controllers/activity_controller.py":4823
 *         if candidate is None:
 *             candidate = datetime.datetime.now()
 *         self._last_work_stop_time = candidate.replace(microsecond=0)             # <<<<<<<<<<<<<<
 *         return self._last_work_stop_time
 * 
*/
  __pyx_t_8 = __pyx_v_candidate;
  __Pyx_INCREF(__pyx_t_8);
  __pyx_t_9 = 0;
  {
    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_8, NULL};
    __pyx_t_6 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4823, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_6, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 4823, __pyx_L1_error)
    __pyx_t_3 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_9, (1-__pyx_t_9) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4823, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_3);
  }
  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_work_stop_time, __pyx_t_3) < (0)) __PYX_ERR(0, 4823, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

  /* "ws_package/controllers/activity_controller.py":4824
 *             candidate = datetime.datetime.now()
 *         self._last_work_stop_time = candidate.replace(microsecond=0)
 *         return self._last_work_stop_time             # <<<<<<<<<<<<<<
 * 
 *     def _break_start_after_work_stop(self) -> datetime.datetime:
*/
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_work_stop_time); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4824, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_r = __pyx_t_3;
  __pyx_t_3 = 0;
  goto __pyx_L0;

  /* "ws_package/controllers/activity_controller.py":4801
 *             return False
 * 
 *     def _finalize_work_stop_time(             # <<<<<<<<<<<<<<
 *         self,
 *         last_interval=None,
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._finalize_work_stop_time", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_candidate);
  __Pyx_XDECREF(__pyx_v_iv);
  __Pyx_XDECREF(__pyx_v_is_break);
  __Pyx_XDECREF(__pyx_v_et);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":4826
 *         return self._last_work_stop_time
 * 
 *     def _break_start_after_work_stop(self) -> datetime.datetime:             # <<<<<<<<<<<<<<
 *         """Break session must start strictly after work stop (work_stop + 1 second)."""
 *         work_stop = self._last_work_stop_time or datetime.datetime.now()
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_173_break_start_after_work_stop(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_172_break_start_after_work_stop, "Break session must start strictly after work stop (work_stop + 1 second).");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_173_break_start_after_work_stop = {"_break_start_after_work_stop", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_173_break_start_after_work_stop, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_172_break_start_after_work_stop};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_173_break_start_after_work_stop(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[1] = {0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_break_start_after_work_stop (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 4826, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4826, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_break_start_after_work_stop", 0) < (0)) __PYX_ERR(0, 4826, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_break_start_after_work_stop", 1, 1, 1, i); __PYX_ERR(0, 4826, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 1)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4826, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_break_start_after_work_stop", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 4826, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._break_start_after_work_stop", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_172_break_start_after_work_stop(__pyx_self, __pyx_v_self);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_172_break_start_after_work_stop(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  PyObject *__pyx_v_work_stop = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  int __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  size_t __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_break_start_after_work_stop", 0);

  /* "ws_package/controllers/activity_controller.py":4828
 *     def _break_start_after_work_stop(self) -> datetime.datetime:
 *         """Break session must start strictly after work stop (work_stop + 1 second)."""
 *         work_stop = self._last_work_stop_time or datetime.datetime.now()             # <<<<<<<<<<<<<<
 *         return work_stop.replace(microsecond=0) + datetime.timedelta(seconds=1)
 * 
*/
  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_work_stop_time); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4828, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 < 0))) __PYX_ERR(0, 4828, __pyx_L1_error)
  if (!__pyx_t_3) {
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  } else {
    __Pyx_INCREF(__pyx_t_2);
    __pyx_t_1 = __pyx_t_2;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L3_bool_binop_done;
  }
  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4828, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4828, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_6);
  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
  __pyx_t_4 = __pyx_t_6;
  __Pyx_INCREF(__pyx_t_4);
  __pyx_t_7 = 0;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
    __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4828, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
  }
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_1 = __pyx_t_2;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_L3_bool_binop_done:;
  __pyx_v_work_stop = __pyx_t_1;
  __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":4829
 *         """Break session must start strictly after work stop (work_stop + 1 second)."""
 *         work_stop = self._last_work_stop_time or datetime.datetime.now()
 *         return work_stop.replace(microsecond=0) + datetime.timedelta(seconds=1)             # <<<<<<<<<<<<<<
 * 
 *     async def last_api_call(
*/
  __Pyx_XDECREF(__pyx_r);
  __pyx_t_2 = __pyx_v_work_stop;
  __Pyx_INCREF(__pyx_t_2);
  __pyx_t_7 = 0;
  {
    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_2, NULL};
    __pyx_t_6 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4829, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_6, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 4829, __pyx_L1_error)
    __pyx_t_1 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_6);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4829, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4829, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_timedelta); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4829, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_7 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_5))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_5);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
    __pyx_t_7 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_2, NULL};
    __pyx_t_4 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4829, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_seconds, __pyx_mstate_global->__pyx_int_1, __pyx_t_4, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 4829, __pyx_L1_error)
    __pyx_t_6 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_7, (1-__pyx_t_7) | (__pyx_t_7*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_4);
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4829, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
  }
  __pyx_t_5 = PyNumber_Add(__pyx_t_1, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4829, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_5);
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
  __pyx_r = __pyx_t_5;
  __pyx_t_5 = 0;
  goto __pyx_L0;

  /* "ws_package/controllers/activity_controller.py":4826
 *         return self._last_work_stop_time
 * 
 *     def _break_start_after_work_stop(self) -> datetime.datetime:             # <<<<<<<<<<<<<<
 *         """Break session must start strictly after work stop (work_stop + 1 second)."""
 *         work_stop = self._last_work_stop_time or datetime.datetime.now()
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._break_start_after_work_stop", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_work_stop);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_176generator34(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":4831
 *         return work_stop.replace(microsecond=0) + datetime.timedelta(seconds=1)
 * 
 *     async def last_api_call(             # <<<<<<<<<<<<<<
 *         self,
 *         user_entity: UserEntity,
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_175last_api_call(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_174last_api_call, "Save last activity interval to DB (serialized with project switch).");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_175last_api_call = {"last_api_call", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_175last_api_call, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_174last_api_call};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_175last_api_call(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_user_entity = 0;
  int __pyx_v_keep_idle_time;
  PyObject *__pyx_v_close_time = 0;
  PyObject *__pyx_v_payload_project_id = 0;
  PyObject *__pyx_v_payload_task_id = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[6] = {0,0,0,0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("last_api_call (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_user_entity,&__pyx_mstate_global->__pyx_n_u_keep_idle_time,&__pyx_mstate_global->__pyx_n_u_close_time,&__pyx_mstate_global->__pyx_n_u_payload_project_id,&__pyx_mstate_global->__pyx_n_u_payload_task_id,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 4831, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 4831, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 4831, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4831, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "last_api_call", 0) < (0)) __PYX_ERR(0, 4831, __pyx_L3_error)

      /* "ws_package/controllers/activity_controller.py":4836
 *         keep_idle_time: bool = True,
 *         *,
 *         close_time: Optional[datetime.datetime] = None,             # <<<<<<<<<<<<<<
 *         payload_project_id: Optional[str] = None,
 *         payload_task_id: Optional[str] = None,
*/
      if (!values[3]) values[3] = __Pyx_NewRef(((PyObject *)Py_None));

      /* "ws_package/controllers/activity_controller.py":4837
 *         *,
 *         close_time: Optional[datetime.datetime] = None,
 *         payload_project_id: Optional[str] = None,             # <<<<<<<<<<<<<<
 *         payload_task_id: Optional[str] = None,
 *     ):
*/
      if (!values[4]) values[4] = __Pyx_NewRef(((PyObject*)Py_None));

      /* "ws_package/controllers/activity_controller.py":4838
 *         close_time: Optional[datetime.datetime] = None,
 *         payload_project_id: Optional[str] = None,
 *         payload_task_id: Optional[str] = None,             # <<<<<<<<<<<<<<
 *     ):
 *         """Save last activity interval to DB (serialized with project switch)."""
*/
      if (!values[5]) values[5] = __Pyx_NewRef(((PyObject*)Py_None));
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("last_api_call", 0, 2, 3, i); __PYX_ERR(0, 4831, __pyx_L3_error) }
      }
    } else {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 4831, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 4831, __pyx_L3_error)
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4831, __pyx_L3_error)
        break;
        default: goto __pyx_L5_argtuple_error;
      }

      /* "ws_package/controllers/activity_controller.py":4836
 *         keep_idle_time: bool = True,
 *         *,
 *         close_time: Optional[datetime.datetime] = None,             # <<<<<<<<<<<<<<
 *         payload_project_id: Optional[str] = None,
 *         payload_task_id: Optional[str] = None,
*/
      if (!values[3]) values[3] = __Pyx_NewRef(((PyObject *)Py_None));

      /* "ws_package/controllers/activity_controller.py":4837
 *         *,
 *         close_time: Optional[datetime.datetime] = None,
 *         payload_project_id: Optional[str] = None,             # <<<<<<<<<<<<<<
 *         payload_task_id: Optional[str] = None,
 *     ):
*/
      if (!values[4]) values[4] = __Pyx_NewRef(((PyObject*)Py_None));

      /* "ws_package/controllers/activity_controller.py":4838
 *         close_time: Optional[datetime.datetime] = None,
 *         payload_project_id: Optional[str] = None,
 *         payload_task_id: Optional[str] = None,             # <<<<<<<<<<<<<<
 *     ):
 *         """Save last activity interval to DB (serialized with project switch)."""
*/
      if (!values[5]) values[5] = __Pyx_NewRef(((PyObject*)Py_None));
    }
    __pyx_v_self = values[0];
    __pyx_v_user_entity = values[1];
    if (values[2]) {
      __pyx_v_keep_idle_time = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_keep_idle_time == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 4834, __pyx_L3_error)
    } else {

      /* "ws_package/controllers/activity_controller.py":4834
 *         self,
 *         user_entity: UserEntity,
 *         keep_idle_time: bool = True,             # <<<<<<<<<<<<<<
 *         *,
 *         close_time: Optional[datetime.datetime] = None,
*/
      __pyx_v_keep_idle_time = ((int)((int)1));
    }
    __pyx_v_close_time = values[3];
    __pyx_v_payload_project_id = ((PyObject*)values[4]);
    __pyx_v_payload_task_id = ((PyObject*)values[5]);
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("last_api_call", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 4831, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.last_api_call", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_payload_project_id), (&PyUnicode_Type), 1, "payload_project_id", 2))) __PYX_ERR(0, 4837, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_payload_task_id), (&PyUnicode_Type), 1, "payload_task_id", 2))) __PYX_ERR(0, 4838, __pyx_L1_error)
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_174last_api_call(__pyx_self, __pyx_v_self, __pyx_v_user_entity, __pyx_v_keep_idle_time, __pyx_v_close_time, __pyx_v_payload_project_id, __pyx_v_payload_task_id);

  /* "ws_package/controllers/activity_controller.py":4831
 *         return work_stop.replace(microsecond=0) + datetime.timedelta(seconds=1)
 * 
 *     async def last_api_call(             # <<<<<<<<<<<<<<
 *         self,
 *         user_entity: UserEntity,
*/

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  goto __pyx_L7_cleaned_up;
  __pyx_L0:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __pyx_L7_cleaned_up:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_174last_api_call(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity, int __pyx_v_keep_idle_time, PyObject *__pyx_v_close_time, PyObject *__pyx_v_payload_project_id, PyObject *__pyx_v_payload_task_id) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("last_api_call", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 4831, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_user_entity = __pyx_v_user_entity;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_user_entity);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_user_entity);
  __pyx_cur_scope->__pyx_v_keep_idle_time = __pyx_v_keep_idle_time;
  __pyx_cur_scope->__pyx_v_close_time = __pyx_v_close_time;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_close_time);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_close_time);
  __pyx_cur_scope->__pyx_v_payload_project_id = __pyx_v_payload_project_id;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_payload_project_id);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_payload_project_id);
  __pyx_cur_scope->__pyx_v_payload_task_id = __pyx_v_payload_task_id;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_payload_task_id);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_payload_task_id);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_176generator34, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[54]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_last_api_call, __pyx_mstate_global->__pyx_n_u_ActivityController_last_api_call, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 4831, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.last_api_call", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_176generator34(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  size_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_PySendResult __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  int __pyx_t_13;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("last_api_call", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L14_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 4831, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":4841
 *     ):
 *         """Save last activity interval to DB (serialized with project switch)."""
 *         with self._session_close_lock:             # <<<<<<<<<<<<<<
 *             return await self._last_api_call_impl(
 *                 user_entity,
*/
  /*with:*/ {
    __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_session_close_lock); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4841, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_2 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4841, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_2);
    __pyx_t_4 = NULL;
    __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4841, __pyx_L4_error)
    __Pyx_GOTREF(__pyx_t_5);
    __pyx_t_6 = 1;
    #if CYTHON_UNPACK_METHODS
    if (likely(PyMethod_Check(__pyx_t_5))) {
      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
      assert(__pyx_t_4);
      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_INCREF(__pyx__function);
      __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
      __pyx_t_6 = 0;
    }
    #endif
    {
      PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
      __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4841, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_3);
    }
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
    /*try:*/ {
      {
        __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
        __Pyx_XGOTREF(__pyx_t_7);
        __Pyx_XGOTREF(__pyx_t_8);
        __Pyx_XGOTREF(__pyx_t_9);
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":4842
 *         """Save last activity interval to DB (serialized with project switch)."""
 *         with self._session_close_lock:
 *             return await self._last_api_call_impl(             # <<<<<<<<<<<<<<
 *                 user_entity,
 *                 keep_idle_time=keep_idle_time,
*/
          __Pyx_XDECREF(__pyx_r);
          __pyx_t_3 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_3);

          /* "ws_package/controllers/activity_controller.py":4844
 *             return await self._last_api_call_impl(
 *                 user_entity,
 *                 keep_idle_time=keep_idle_time,             # <<<<<<<<<<<<<<
 *                 close_time=close_time,
 *                 payload_project_id=payload_project_id,
*/
          __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_cur_scope->__pyx_v_keep_idle_time); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4844, __pyx_L8_error)
          __Pyx_GOTREF(__pyx_t_5);

          /* "ws_package/controllers/activity_controller.py":4847
 *                 close_time=close_time,
 *                 payload_project_id=payload_project_id,
 *                 payload_task_id=payload_task_id,             # <<<<<<<<<<<<<<
 *             )
 * 
*/
          __pyx_t_6 = 0;
          {
            PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 4 : 0)] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_user_entity};
            __pyx_t_4 = __Pyx_MakeVectorcallBuilderKwds(4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4842, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_4);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_keep_idle_time, __pyx_t_5, __pyx_t_4, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 4842, __pyx_L8_error)
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_close_time, __pyx_cur_scope->__pyx_v_close_time, __pyx_t_4, __pyx_callargs+2, 1) < (0)) __PYX_ERR(0, 4842, __pyx_L8_error)
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_payload_project_id, __pyx_cur_scope->__pyx_v_payload_project_id, __pyx_t_4, __pyx_callargs+2, 2) < (0)) __PYX_ERR(0, 4842, __pyx_L8_error)
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_payload_task_id, __pyx_cur_scope->__pyx_v_payload_task_id, __pyx_t_4, __pyx_callargs+2, 3) < (0)) __PYX_ERR(0, 4842, __pyx_L8_error)
            __pyx_t_1 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_last_api_call_impl, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_4);
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4842, __pyx_L8_error)
            __Pyx_GOTREF(__pyx_t_1);
          }
          __pyx_t_10 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (likely(__pyx_t_10 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_2);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
            __Pyx_XGIVEREF(__pyx_t_7);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
            __Pyx_XGIVEREF(__pyx_t_8);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
            __Pyx_XGIVEREF(__pyx_t_9);
            __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 1;
            return __pyx_r;
            __pyx_L14_resume_from_await:;
            __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_2);
            __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_7);
            __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_8);
            __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
            __pyx_cur_scope->__pyx_t_3 = 0;
            __Pyx_XGOTREF(__pyx_t_9);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4842, __pyx_L8_error)
            __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
          } else if (likely(__pyx_t_10 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __pyx_t_1 = __pyx_r; __pyx_r = NULL;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 4842, __pyx_L8_error)
          }
          __pyx_r = __pyx_t_1;
          __pyx_t_1 = 0;
          goto __pyx_L12_try_return;

          /* "ws_package/controllers/activity_controller.py":4841
 *     ):
 *         """Save last activity interval to DB (serialized with project switch)."""
 *         with self._session_close_lock:             # <<<<<<<<<<<<<<
 *             return await self._last_api_call_impl(
 *                 user_entity,
*/
        }
        __pyx_L8_error:;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        /*except:*/ {
          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.last_api_call", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_4, &__pyx_t_5) < 0) __PYX_ERR(0, 4841, __pyx_L10_except_error)
          __Pyx_XGOTREF(__pyx_t_1);
          __Pyx_XGOTREF(__pyx_t_4);
          __Pyx_XGOTREF(__pyx_t_5);
          __pyx_t_3 = PyTuple_Pack(3, __pyx_t_1, __pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 4841, __pyx_L10_except_error)
          __Pyx_GOTREF(__pyx_t_3);
          __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 4841, __pyx_L10_except_error)
          __Pyx_GOTREF(__pyx_t_11);
          __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_11);
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (__pyx_t_12 < (0)) __PYX_ERR(0, 4841, __pyx_L10_except_error)
          __pyx_t_13 = (!__pyx_t_12);
          if (unlikely(__pyx_t_13)) {
            __Pyx_GIVEREF(__pyx_t_1);
            __Pyx_GIVEREF(__pyx_t_4);
            __Pyx_XGIVEREF(__pyx_t_5);
            __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_4, __pyx_t_5);
            __pyx_t_1 = 0;  __pyx_t_4 = 0;  __pyx_t_5 = 0; 
            __PYX_ERR(0, 4841, __pyx_L10_except_error)
          }
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          goto __pyx_L9_exception_handled;
        }
        __pyx_L10_except_error:;
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
        goto __pyx_L1_error;
        __pyx_L12_try_return:;
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
        goto __pyx_L5_return;
        __pyx_L9_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_7);
        __Pyx_XGIVEREF(__pyx_t_8);
        __Pyx_XGIVEREF(__pyx_t_9);
        __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
      }
    }
    /*finally:*/ {
      /*normal exit:*/{
        if (__pyx_t_2) {
          __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_mstate_global->__pyx_tuple[7], NULL);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 4841, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_9);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        }
        goto __pyx_L7;
      }
      __pyx_L5_return: {
        __pyx_t_9 = __pyx_r;
        __pyx_r = 0;
        if (__pyx_t_2) {
          __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_mstate_global->__pyx_tuple[7], NULL);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4841, __pyx_L1_error)
          __Pyx_GOTREF(__pyx_t_8);
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        }
        __pyx_r = __pyx_t_9;
        __pyx_t_9 = 0;
        goto __pyx_L0;
      }
      __pyx_L7:;
    }
    goto __pyx_L18;
    __pyx_L4_error:;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    goto __pyx_L1_error;
    __pyx_L18:;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":4831
 *         return work_stop.replace(microsecond=0) + datetime.timedelta(seconds=1)
 * 
 *     async def last_api_call(             # <<<<<<<<<<<<<<
 *         self,
 *         user_entity: UserEntity,
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("last_api_call", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_179generator35(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":4850
 *             )
 * 
 *     async def _last_api_call_impl(             # <<<<<<<<<<<<<<
 *         self,
 *         user_entity: UserEntity,
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_178_last_api_call_impl(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_177_last_api_call_impl, "Internal implementation of last_api_call (caller must hold _session_close_lock).");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_178_last_api_call_impl = {"_last_api_call_impl", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_178_last_api_call_impl, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_177_last_api_call_impl};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_178_last_api_call_impl(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_user_entity = 0;
  int __pyx_v_keep_idle_time;
  PyObject *__pyx_v_close_time = 0;
  PyObject *__pyx_v_payload_project_id = 0;
  PyObject *__pyx_v_payload_task_id = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[6] = {0,0,0,0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_last_api_call_impl (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_user_entity,&__pyx_mstate_global->__pyx_n_u_keep_idle_time,&__pyx_mstate_global->__pyx_n_u_close_time,&__pyx_mstate_global->__pyx_n_u_payload_project_id,&__pyx_mstate_global->__pyx_n_u_payload_task_id,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 4850, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 4850, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 4850, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4850, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_last_api_call_impl", 0) < (0)) __PYX_ERR(0, 4850, __pyx_L3_error)

      /* "ws_package/controllers/activity_controller.py":4855
 *         keep_idle_time: bool = True,
 *         *,
 *         close_time: Optional[datetime.datetime] = None,             # <<<<<<<<<<<<<<
 *         payload_project_id: Optional[str] = None,
 *         payload_task_id: Optional[str] = None,
*/
      if (!values[3]) values[3] = __Pyx_NewRef(((PyObject *)Py_None));

      /* "ws_package/controllers/activity_controller.py":4856
 *         *,
 *         close_time: Optional[datetime.datetime] = None,
 *         payload_project_id: Optional[str] = None,             # <<<<<<<<<<<<<<
 *         payload_task_id: Optional[str] = None,
 *     ):
*/
      if (!values[4]) values[4] = __Pyx_NewRef(((PyObject*)Py_None));

      /* "ws_package/controllers/activity_controller.py":4857
 *         close_time: Optional[datetime.datetime] = None,
 *         payload_project_id: Optional[str] = None,
 *         payload_task_id: Optional[str] = None,             # <<<<<<<<<<<<<<
 *     ):
 *         """Internal implementation of last_api_call (caller must hold _session_close_lock)."""
*/
      if (!values[5]) values[5] = __Pyx_NewRef(((PyObject*)Py_None));
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_last_api_call_impl", 0, 2, 3, i); __PYX_ERR(0, 4850, __pyx_L3_error) }
      }
    } else {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 4850, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 4850, __pyx_L3_error)
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 4850, __pyx_L3_error)
        break;
        default: goto __pyx_L5_argtuple_error;
      }

      /* "ws_package/controllers/activity_controller.py":4855
 *         keep_idle_time: bool = True,
 *         *,
 *         close_time: Optional[datetime.datetime] = None,             # <<<<<<<<<<<<<<
 *         payload_project_id: Optional[str] = None,
 *         payload_task_id: Optional[str] = None,
*/
      if (!values[3]) values[3] = __Pyx_NewRef(((PyObject *)Py_None));

      /* "ws_package/controllers/activity_controller.py":4856
 *         *,
 *         close_time: Optional[datetime.datetime] = None,
 *         payload_project_id: Optional[str] = None,             # <<<<<<<<<<<<<<
 *         payload_task_id: Optional[str] = None,
 *     ):
*/
      if (!values[4]) values[4] = __Pyx_NewRef(((PyObject*)Py_None));

      /* "ws_package/controllers/activity_controller.py":4857
 *         close_time: Optional[datetime.datetime] = None,
 *         payload_project_id: Optional[str] = None,
 *         payload_task_id: Optional[str] = None,             # <<<<<<<<<<<<<<
 *     ):
 *         """Internal implementation of last_api_call (caller must hold _session_close_lock)."""
*/
      if (!values[5]) values[5] = __Pyx_NewRef(((PyObject*)Py_None));
    }
    __pyx_v_self = values[0];
    __pyx_v_user_entity = values[1];
    if (values[2]) {
      __pyx_v_keep_idle_time = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_keep_idle_time == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 4853, __pyx_L3_error)
    } else {

      /* "ws_package/controllers/activity_controller.py":4853
 *         self,
 *         user_entity: UserEntity,
 *         keep_idle_time: bool = True,             # <<<<<<<<<<<<<<
 *         *,
 *         close_time: Optional[datetime.datetime] = None,
*/
      __pyx_v_keep_idle_time = ((int)((int)1));
    }
    __pyx_v_close_time = values[3];
    __pyx_v_payload_project_id = ((PyObject*)values[4]);
    __pyx_v_payload_task_id = ((PyObject*)values[5]);
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_last_api_call_impl", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 4850, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_payload_project_id), (&PyUnicode_Type), 1, "payload_project_id", 2))) __PYX_ERR(0, 4856, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_payload_task_id), (&PyUnicode_Type), 1, "payload_task_id", 2))) __PYX_ERR(0, 4857, __pyx_L1_error)
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_177_last_api_call_impl(__pyx_self, __pyx_v_self, __pyx_v_user_entity, __pyx_v_keep_idle_time, __pyx_v_close_time, __pyx_v_payload_project_id, __pyx_v_payload_task_id);

  /* "ws_package/controllers/activity_controller.py":4850
 *             )
 * 
 *     async def _last_api_call_impl(             # <<<<<<<<<<<<<<
 *         self,
 *         user_entity: UserEntity,
*/

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  goto __pyx_L7_cleaned_up;
  __pyx_L0:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __pyx_L7_cleaned_up:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_6generator64(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":5173
 *                         # This handles datetime precision differences between saved and queried intervals
 *                         last_interval_found = any(
 *                             datetime_matches(getattr(interval, 'start_time', None), last_interval.start_time) and             # <<<<<<<<<<<<<<
 *                             datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                             getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
*/

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_4genexpr(PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 5173, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl *) __pyx_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  __pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_6generator64, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[55]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_genexpr, __pyx_mstate_global->__pyx_n_u_ActivityController__last_api_cal, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 5173, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_6generator64(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5173, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":5176
 *                             datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                             getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
 *                             for interval in intervals             # <<<<<<<<<<<<<<
 *                         )
 *                         if last_interval_found:
*/
  if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 5176, __pyx_L1_error) }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1);
    __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_genexpr_arg_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5176, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5176, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5176, __pyx_L1_error)
          #endif
          if (__pyx_t_2 >= __pyx_temp) break;
        }
        __pyx_t_4 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_1, __pyx_t_2, __Pyx_ReferenceSharing_OwnStrongReference);
        ++__pyx_t_2;
      } else {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5176, __pyx_L1_error)
          #endif
          if (__pyx_t_2 >= __pyx_temp) break;
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2));
        #else
        __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2);
        #endif
        ++__pyx_t_2;
      }
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5176, __pyx_L1_error)
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 5176, __pyx_L1_error)
          PyErr_Clear();
        }
        break;
      }
    }
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;

    /* "ws_package/controllers/activity_controller.py":5173
 *                         # This handles datetime precision differences between saved and queried intervals
 *                         last_interval_found = any(
 *                             datetime_matches(getattr(interval, 'start_time', None), last_interval.start_time) and             # <<<<<<<<<<<<<<
 *                             datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                             getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
*/
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_datetime_matches)) { __Pyx_RaiseClosureNameError("datetime_matches"); __PYX_ERR(0, 5173, __pyx_L1_error) }
    __pyx_t_4 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_start_time, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5173, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval)) { __Pyx_RaiseClosureNameError("last_interval"); __PYX_ERR(0, 5173, __pyx_L1_error) }
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5173, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5173, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_4);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4) != (0)) __PYX_ERR(0, 5173, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_6);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6) != (0)) __PYX_ERR(0, 5173, __pyx_L1_error);
    __pyx_t_4 = 0;
    __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_datetime_matches, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5173, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 5173, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_8) {
    } else {
      __pyx_t_5 = __pyx_t_8;
      goto __pyx_L7_bool_binop_done;
    }

    /* "ws_package/controllers/activity_controller.py":5174
 *                         last_interval_found = any(
 *                             datetime_matches(getattr(interval, 'start_time', None), last_interval.start_time) and
 *                             datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and             # <<<<<<<<<<<<<<
 *                             getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
 *                             for interval in intervals
*/
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_datetime_matches)) { __Pyx_RaiseClosureNameError("datetime_matches"); __PYX_ERR(0, 5174, __pyx_L1_error) }
    __pyx_t_6 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5174, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval)) { __Pyx_RaiseClosureNameError("last_interval"); __PYX_ERR(0, 5174, __pyx_L1_error) }
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5174, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5174, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6) != (0)) __PYX_ERR(0, 5174, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_7);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_7) != (0)) __PYX_ERR(0, 5174, __pyx_L1_error);
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_datetime_matches, __pyx_t_4, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5174, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 5174, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (__pyx_t_8) {
    } else {
      __pyx_t_5 = __pyx_t_8;
      goto __pyx_L7_bool_binop_done;
    }

    /* "ws_package/controllers/activity_controller.py":5175
 *                             datetime_matches(getattr(interval, 'start_time', None), last_interval.start_time) and
 *                             datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                             getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)             # <<<<<<<<<<<<<<
 *                             for interval in intervals
 *                         )
*/
    __pyx_t_7 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_counter, Py_None); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5175, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval)) { __Pyx_RaiseClosureNameError("last_interval"); __PYX_ERR(0, 5175, __pyx_L1_error) }
    __pyx_t_4 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval;
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_6 = __Pyx_GetAttr3(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_counter, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5175, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_RichCompare(__pyx_t_7, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5175, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 5175, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = __pyx_t_8;
    __pyx_L7_bool_binop_done:;

    /* "ws_package/controllers/activity_controller.py":5173
 *                         # This handles datetime precision differences between saved and queried intervals
 *                         last_interval_found = any(
 *                             datetime_matches(getattr(interval, 'start_time', None), last_interval.start_time) and             # <<<<<<<<<<<<<<
 *                             datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                             getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
*/
    if (__pyx_t_5) {

      /* "ws_package/controllers/activity_controller.py":5172
 *                         # Check if last_interval is in the results using tolerance-based comparison
 *                         # This handles datetime precision differences between saved and queried intervals
 *                         last_interval_found = any(             # <<<<<<<<<<<<<<
 *                             datetime_matches(getattr(interval, 'start_time', None), last_interval.start_time) and
 *                             datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and
*/
      __Pyx_XDECREF(__pyx_r);

      /* "ws_package/controllers/activity_controller.py":5173
 *                         # This handles datetime precision differences between saved and queried intervals
 *                         last_interval_found = any(
 *                             datetime_matches(getattr(interval, 'start_time', None), last_interval.start_time) and             # <<<<<<<<<<<<<<
 *                             datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                             getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
*/
      __Pyx_INCREF(Py_True);
      __pyx_r = Py_True;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }

    /* "ws_package/controllers/activity_controller.py":5176
 *                             datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                             getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
 *                             for interval in intervals             # <<<<<<<<<<<<<<
 *                         )
 *                         if last_interval_found:
*/
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  /*else*/ {

    /* "ws_package/controllers/activity_controller.py":5172
 *                         # Check if last_interval is in the results using tolerance-based comparison
 *                         # This handles datetime precision differences between saved and queried intervals
 *                         last_interval_found = any(             # <<<<<<<<<<<<<<
 *                             datetime_matches(getattr(interval, 'start_time', None), last_interval.start_time) and
 *                             datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and
*/
    __Pyx_XDECREF(__pyx_r);

    /* "ws_package/controllers/activity_controller.py":5173
 *                         # This handles datetime precision differences between saved and queried intervals
 *                         last_interval_found = any(
 *                             datetime_matches(getattr(interval, 'start_time', None), last_interval.start_time) and             # <<<<<<<<<<<<<<
 *                             datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                             getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
*/
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_9generator65(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":5258
 *                                 # Check if last_interval is already in the list (might have been added by another process)
 *                                 already_in_list = any(
 *                                     datetime_matches(getattr(interval, 'start_time', None), last_interval.start_time) and             # <<<<<<<<<<<<<<
 *                                     datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                                     getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
*/

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_7genexpr(PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 5258, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl *) __pyx_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  __pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_9generator65, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[56]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_genexpr, __pyx_mstate_global->__pyx_n_u_ActivityController__last_api_cal, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 5258, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_9generator65(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5258, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":5261
 *                                     datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                                     getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
 *                                     for interval in intervals             # <<<<<<<<<<<<<<
 *                                 )
 * 
*/
  if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 5261, __pyx_L1_error) }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1);
    __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_genexpr_arg_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5261, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5261, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5261, __pyx_L1_error)
          #endif
          if (__pyx_t_2 >= __pyx_temp) break;
        }
        __pyx_t_4 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_1, __pyx_t_2, __Pyx_ReferenceSharing_OwnStrongReference);
        ++__pyx_t_2;
      } else {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5261, __pyx_L1_error)
          #endif
          if (__pyx_t_2 >= __pyx_temp) break;
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2));
        #else
        __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2);
        #endif
        ++__pyx_t_2;
      }
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5261, __pyx_L1_error)
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 5261, __pyx_L1_error)
          PyErr_Clear();
        }
        break;
      }
    }
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;

    /* "ws_package/controllers/activity_controller.py":5258
 *                                 # Check if last_interval is already in the list (might have been added by another process)
 *                                 already_in_list = any(
 *                                     datetime_matches(getattr(interval, 'start_time', None), last_interval.start_time) and             # <<<<<<<<<<<<<<
 *                                     datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                                     getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
*/
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_datetime_matches)) { __Pyx_RaiseClosureNameError("datetime_matches"); __PYX_ERR(0, 5258, __pyx_L1_error) }
    __pyx_t_4 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_start_time, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5258, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval)) { __Pyx_RaiseClosureNameError("last_interval"); __PYX_ERR(0, 5258, __pyx_L1_error) }
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5258, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5258, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_4);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4) != (0)) __PYX_ERR(0, 5258, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_6);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6) != (0)) __PYX_ERR(0, 5258, __pyx_L1_error);
    __pyx_t_4 = 0;
    __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_datetime_matches, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5258, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 5258, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_8) {
    } else {
      __pyx_t_5 = __pyx_t_8;
      goto __pyx_L7_bool_binop_done;
    }

    /* "ws_package/controllers/activity_controller.py":5259
 *                                 already_in_list = any(
 *                                     datetime_matches(getattr(interval, 'start_time', None), last_interval.start_time) and
 *                                     datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and             # <<<<<<<<<<<<<<
 *                                     getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
 *                                     for interval in intervals
*/
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_datetime_matches)) { __Pyx_RaiseClosureNameError("datetime_matches"); __PYX_ERR(0, 5259, __pyx_L1_error) }
    __pyx_t_6 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5259, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval)) { __Pyx_RaiseClosureNameError("last_interval"); __PYX_ERR(0, 5259, __pyx_L1_error) }
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5259, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5259, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6) != (0)) __PYX_ERR(0, 5259, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_7);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_7) != (0)) __PYX_ERR(0, 5259, __pyx_L1_error);
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_datetime_matches, __pyx_t_4, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5259, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 5259, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (__pyx_t_8) {
    } else {
      __pyx_t_5 = __pyx_t_8;
      goto __pyx_L7_bool_binop_done;
    }

    /* "ws_package/controllers/activity_controller.py":5260
 *                                     datetime_matches(getattr(interval, 'start_time', None), last_interval.start_time) and
 *                                     datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                                     getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)             # <<<<<<<<<<<<<<
 *                                     for interval in intervals
 *                                 )
*/
    __pyx_t_7 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_counter, Py_None); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5260, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval)) { __Pyx_RaiseClosureNameError("last_interval"); __PYX_ERR(0, 5260, __pyx_L1_error) }
    __pyx_t_4 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval;
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_6 = __Pyx_GetAttr3(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_counter, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5260, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_RichCompare(__pyx_t_7, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5260, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 5260, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = __pyx_t_8;
    __pyx_L7_bool_binop_done:;

    /* "ws_package/controllers/activity_controller.py":5258
 *                                 # Check if last_interval is already in the list (might have been added by another process)
 *                                 already_in_list = any(
 *                                     datetime_matches(getattr(interval, 'start_time', None), last_interval.start_time) and             # <<<<<<<<<<<<<<
 *                                     datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                                     getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
*/
    if (__pyx_t_5) {

      /* "ws_package/controllers/activity_controller.py":5257
 * 
 *                                 # Check if last_interval is already in the list (might have been added by another process)
 *                                 already_in_list = any(             # <<<<<<<<<<<<<<
 *                                     datetime_matches(getattr(interval, 'start_time', None), last_interval.start_time) and
 *                                     datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and
*/
      __Pyx_XDECREF(__pyx_r);

      /* "ws_package/controllers/activity_controller.py":5258
 *                                 # Check if last_interval is already in the list (might have been added by another process)
 *                                 already_in_list = any(
 *                                     datetime_matches(getattr(interval, 'start_time', None), last_interval.start_time) and             # <<<<<<<<<<<<<<
 *                                     datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                                     getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
*/
      __Pyx_INCREF(Py_True);
      __pyx_r = Py_True;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }

    /* "ws_package/controllers/activity_controller.py":5261
 *                                     datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                                     getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
 *                                     for interval in intervals             # <<<<<<<<<<<<<<
 *                                 )
 * 
*/
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  /*else*/ {

    /* "ws_package/controllers/activity_controller.py":5257
 * 
 *                                 # Check if last_interval is already in the list (might have been added by another process)
 *                                 already_in_list = any(             # <<<<<<<<<<<<<<
 *                                     datetime_matches(getattr(interval, 'start_time', None), last_interval.start_time) and
 *                                     datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and
*/
    __Pyx_XDECREF(__pyx_r);

    /* "ws_package/controllers/activity_controller.py":5258
 *                                 # Check if last_interval is already in the list (might have been added by another process)
 *                                 already_in_list = any(
 *                                     datetime_matches(getattr(interval, 'start_time', None), last_interval.start_time) and             # <<<<<<<<<<<<<<
 *                                     datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                                     getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
*/
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_12generator66(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":5299
 * 
 *                     last_interval_in_list = any(
 *                         datetime_matches_final(getattr(interval, 'start_time', None), last_interval.start_time) and             # <<<<<<<<<<<<<<
 *                         datetime_matches_final(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                         getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
*/

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_10genexpr(PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 5299, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl *) __pyx_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  __pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_12generator66, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[57]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_genexpr, __pyx_mstate_global->__pyx_n_u_ActivityController__last_api_cal, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 5299, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_12generator66(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5299, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":5302
 *                         datetime_matches_final(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                         getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
 *                         for interval in intervals             # <<<<<<<<<<<<<<
 *                     )
 *                     if last_interval_in_list:
*/
  if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 5302, __pyx_L1_error) }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1);
    __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_genexpr_arg_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5302, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5302, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5302, __pyx_L1_error)
          #endif
          if (__pyx_t_2 >= __pyx_temp) break;
        }
        __pyx_t_4 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_1, __pyx_t_2, __Pyx_ReferenceSharing_OwnStrongReference);
        ++__pyx_t_2;
      } else {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5302, __pyx_L1_error)
          #endif
          if (__pyx_t_2 >= __pyx_temp) break;
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2));
        #else
        __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2);
        #endif
        ++__pyx_t_2;
      }
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5302, __pyx_L1_error)
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 5302, __pyx_L1_error)
          PyErr_Clear();
        }
        break;
      }
    }
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;

    /* "ws_package/controllers/activity_controller.py":5299
 * 
 *                     last_interval_in_list = any(
 *                         datetime_matches_final(getattr(interval, 'start_time', None), last_interval.start_time) and             # <<<<<<<<<<<<<<
 *                         datetime_matches_final(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                         getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
*/
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_datetime_matches_final)) { __Pyx_RaiseClosureNameError("datetime_matches_final"); __PYX_ERR(0, 5299, __pyx_L1_error) }
    __pyx_t_4 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_start_time, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5299, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval)) { __Pyx_RaiseClosureNameError("last_interval"); __PYX_ERR(0, 5299, __pyx_L1_error) }
    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5299, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5299, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_GIVEREF(__pyx_t_4);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4) != (0)) __PYX_ERR(0, 5299, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_6);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6) != (0)) __PYX_ERR(0, 5299, __pyx_L1_error);
    __pyx_t_4 = 0;
    __pyx_t_6 = 0;
    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_datetime_matches_final, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5299, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 5299, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    if (__pyx_t_8) {
    } else {
      __pyx_t_5 = __pyx_t_8;
      goto __pyx_L7_bool_binop_done;
    }

    /* "ws_package/controllers/activity_controller.py":5300
 *                     last_interval_in_list = any(
 *                         datetime_matches_final(getattr(interval, 'start_time', None), last_interval.start_time) and
 *                         datetime_matches_final(getattr(interval, 'end_time', None), last_interval.end_time) and             # <<<<<<<<<<<<<<
 *                         getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
 *                         for interval in intervals
*/
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_datetime_matches_final)) { __Pyx_RaiseClosureNameError("datetime_matches_final"); __PYX_ERR(0, 5300, __pyx_L1_error) }
    __pyx_t_6 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5300, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval)) { __Pyx_RaiseClosureNameError("last_interval"); __PYX_ERR(0, 5300, __pyx_L1_error) }
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5300, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5300, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_6);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6) != (0)) __PYX_ERR(0, 5300, __pyx_L1_error);
    __Pyx_GIVEREF(__pyx_t_7);
    if (__Pyx_PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_7) != (0)) __PYX_ERR(0, 5300, __pyx_L1_error);
    __pyx_t_6 = 0;
    __pyx_t_7 = 0;
    __pyx_t_7 = __Pyx_PyObject_Call(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_datetime_matches_final, __pyx_t_4, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5300, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 5300, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    if (__pyx_t_8) {
    } else {
      __pyx_t_5 = __pyx_t_8;
      goto __pyx_L7_bool_binop_done;
    }

    /* "ws_package/controllers/activity_controller.py":5301
 *                         datetime_matches_final(getattr(interval, 'start_time', None), last_interval.start_time) and
 *                         datetime_matches_final(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                         getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)             # <<<<<<<<<<<<<<
 *                         for interval in intervals
 *                     )
*/
    __pyx_t_7 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_counter, Py_None); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5301, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval)) { __Pyx_RaiseClosureNameError("last_interval"); __PYX_ERR(0, 5301, __pyx_L1_error) }
    __pyx_t_4 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval;
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_6 = __Pyx_GetAttr3(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_counter, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5301, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_4 = PyObject_RichCompare(__pyx_t_7, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5301, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 5301, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __pyx_t_5 = __pyx_t_8;
    __pyx_L7_bool_binop_done:;

    /* "ws_package/controllers/activity_controller.py":5299
 * 
 *                     last_interval_in_list = any(
 *                         datetime_matches_final(getattr(interval, 'start_time', None), last_interval.start_time) and             # <<<<<<<<<<<<<<
 *                         datetime_matches_final(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                         getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
*/
    if (__pyx_t_5) {

      /* "ws_package/controllers/activity_controller.py":5298
 *                             return False
 * 
 *                     last_interval_in_list = any(             # <<<<<<<<<<<<<<
 *                         datetime_matches_final(getattr(interval, 'start_time', None), last_interval.start_time) and
 *                         datetime_matches_final(getattr(interval, 'end_time', None), last_interval.end_time) and
*/
      __Pyx_XDECREF(__pyx_r);

      /* "ws_package/controllers/activity_controller.py":5299
 * 
 *                     last_interval_in_list = any(
 *                         datetime_matches_final(getattr(interval, 'start_time', None), last_interval.start_time) and             # <<<<<<<<<<<<<<
 *                         datetime_matches_final(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                         getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
*/
      __Pyx_INCREF(Py_True);
      __pyx_r = Py_True;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }

    /* "ws_package/controllers/activity_controller.py":5302
 *                         datetime_matches_final(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                         getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
 *                         for interval in intervals             # <<<<<<<<<<<<<<
 *                     )
 *                     if last_interval_in_list:
*/
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  /*else*/ {

    /* "ws_package/controllers/activity_controller.py":5298
 *                             return False
 * 
 *                     last_interval_in_list = any(             # <<<<<<<<<<<<<<
 *                         datetime_matches_final(getattr(interval, 'start_time', None), last_interval.start_time) and
 *                         datetime_matches_final(getattr(interval, 'end_time', None), last_interval.end_time) and
*/
    __Pyx_XDECREF(__pyx_r);

    /* "ws_package/controllers/activity_controller.py":5299
 * 
 *                     last_interval_in_list = any(
 *                         datetime_matches_final(getattr(interval, 'start_time', None), last_interval.start_time) and             # <<<<<<<<<<<<<<
 *                         datetime_matches_final(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                         getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
*/
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_15generator67(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":5472
 *                 # Verify last_interval was actually sent by checking if it's in the original intervals list
 *                 last_interval_was_sent = any(
 *                     (hasattr(interval, 'start_time') and hasattr(last_interval, 'start_time') and             # <<<<<<<<<<<<<<
 *                      hasattr(interval, 'end_time') and hasattr(last_interval, 'end_time') and
 *                      hasattr(interval, 'counter') and hasattr(last_interval, 'counter') and
*/

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_13genexpr(PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 5472, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl *) __pyx_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  __pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_15generator67, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[58]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_genexpr, __pyx_mstate_global->__pyx_n_u_ActivityController__last_api_cal, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 5472, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_15generator67(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5472, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":5478
 *                      interval.end_time == last_interval.end_time and
 *                      interval.counter == last_interval.counter)
 *                     for interval in intervals             # <<<<<<<<<<<<<<
 *                 ) if intervals else False
 * 
*/
  if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 5478, __pyx_L1_error) }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1);
    __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_genexpr_arg_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5478, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5478, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5478, __pyx_L1_error)
          #endif
          if (__pyx_t_2 >= __pyx_temp) break;
        }
        __pyx_t_4 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_1, __pyx_t_2, __Pyx_ReferenceSharing_OwnStrongReference);
        ++__pyx_t_2;
      } else {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5478, __pyx_L1_error)
          #endif
          if (__pyx_t_2 >= __pyx_temp) break;
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2));
        #else
        __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2);
        #endif
        ++__pyx_t_2;
      }
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5478, __pyx_L1_error)
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 5478, __pyx_L1_error)
          PyErr_Clear();
        }
        break;
      }
    }
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;

    /* "ws_package/controllers/activity_controller.py":5472
 *                 # Verify last_interval was actually sent by checking if it's in the original intervals list
 *                 last_interval_was_sent = any(
 *                     (hasattr(interval, 'start_time') and hasattr(last_interval, 'start_time') and             # <<<<<<<<<<<<<<
 *                      hasattr(interval, 'end_time') and hasattr(last_interval, 'end_time') and
 *                      hasattr(interval, 'counter') and hasattr(last_interval, 'counter') and
*/
    __pyx_t_6 = __Pyx_HasAttr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 5472, __pyx_L1_error)
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L7_bool_binop_done;
    }
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval)) { __Pyx_RaiseClosureNameError("last_interval"); __PYX_ERR(0, 5472, __pyx_L1_error) }
    __pyx_t_4 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval;
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_6 = __Pyx_HasAttr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 5472, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L7_bool_binop_done;
    }

    /* "ws_package/controllers/activity_controller.py":5473
 *                 last_interval_was_sent = any(
 *                     (hasattr(interval, 'start_time') and hasattr(last_interval, 'start_time') and
 *                      hasattr(interval, 'end_time') and hasattr(last_interval, 'end_time') and             # <<<<<<<<<<<<<<
 *                      hasattr(interval, 'counter') and hasattr(last_interval, 'counter') and
 *                      interval.start_time == last_interval.start_time and
*/
    __pyx_t_6 = __Pyx_HasAttr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 5473, __pyx_L1_error)
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L7_bool_binop_done;
    }
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval)) { __Pyx_RaiseClosureNameError("last_interval"); __PYX_ERR(0, 5473, __pyx_L1_error) }
    __pyx_t_4 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval;
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_6 = __Pyx_HasAttr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 5473, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L7_bool_binop_done;
    }

    /* "ws_package/controllers/activity_controller.py":5474
 *                     (hasattr(interval, 'start_time') and hasattr(last_interval, 'start_time') and
 *                      hasattr(interval, 'end_time') and hasattr(last_interval, 'end_time') and
 *                      hasattr(interval, 'counter') and hasattr(last_interval, 'counter') and             # <<<<<<<<<<<<<<
 *                      interval.start_time == last_interval.start_time and
 *                      interval.end_time == last_interval.end_time and
*/
    __pyx_t_6 = __Pyx_HasAttr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 5474, __pyx_L1_error)
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L7_bool_binop_done;
    }
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval)) { __Pyx_RaiseClosureNameError("last_interval"); __PYX_ERR(0, 5474, __pyx_L1_error) }
    __pyx_t_4 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval;
    __Pyx_INCREF(__pyx_t_4);
    __pyx_t_6 = __Pyx_HasAttr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 5474, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L7_bool_binop_done;
    }

    /* "ws_package/controllers/activity_controller.py":5475
 *                      hasattr(interval, 'end_time') and hasattr(last_interval, 'end_time') and
 *                      hasattr(interval, 'counter') and hasattr(last_interval, 'counter') and
 *                      interval.start_time == last_interval.start_time and             # <<<<<<<<<<<<<<
 *                      interval.end_time == last_interval.end_time and
 *                      interval.counter == last_interval.counter)
*/
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5475, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval)) { __Pyx_RaiseClosureNameError("last_interval"); __PYX_ERR(0, 5475, __pyx_L1_error) }
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5475, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = PyObject_RichCompare(__pyx_t_4, __pyx_t_7, Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 5475, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 5475, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L7_bool_binop_done;
    }

    /* "ws_package/controllers/activity_controller.py":5476
 *                      hasattr(interval, 'counter') and hasattr(last_interval, 'counter') and
 *                      interval.start_time == last_interval.start_time and
 *                      interval.end_time == last_interval.end_time and             # <<<<<<<<<<<<<<
 *                      interval.counter == last_interval.counter)
 *                     for interval in intervals
*/
    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 5476, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_8);
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval)) { __Pyx_RaiseClosureNameError("last_interval"); __PYX_ERR(0, 5476, __pyx_L1_error) }
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5476, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_4 = PyObject_RichCompare(__pyx_t_8, __pyx_t_7, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5476, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 5476, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (__pyx_t_6) {
    } else {
      __pyx_t_5 = __pyx_t_6;
      goto __pyx_L7_bool_binop_done;
    }

    /* "ws_package/controllers/activity_controller.py":5477
 *                      interval.start_time == last_interval.start_time and
 *                      interval.end_time == last_interval.end_time and
 *                      interval.counter == last_interval.counter)             # <<<<<<<<<<<<<<
 *                     for interval in intervals
 *                 ) if intervals else False
*/
    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5477, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval)) { __Pyx_RaiseClosureNameError("last_interval"); __PYX_ERR(0, 5477, __pyx_L1_error) }
    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_outer_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5477, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_7);
    __pyx_t_8 = PyObject_RichCompare(__pyx_t_4, __pyx_t_7, Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 5477, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 5477, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    __pyx_t_5 = __pyx_t_6;
    __pyx_L7_bool_binop_done:;

    /* "ws_package/controllers/activity_controller.py":5472
 *                 # Verify last_interval was actually sent by checking if it's in the original intervals list
 *                 last_interval_was_sent = any(
 *                     (hasattr(interval, 'start_time') and hasattr(last_interval, 'start_time') and             # <<<<<<<<<<<<<<
 *                      hasattr(interval, 'end_time') and hasattr(last_interval, 'end_time') and
 *                      hasattr(interval, 'counter') and hasattr(last_interval, 'counter') and
*/
    if (__pyx_t_5) {

      /* "ws_package/controllers/activity_controller.py":5471
 *                 logger.info("Last interval was not updated in any batch - explicitly updating it now")
 *                 # Verify last_interval was actually sent by checking if it's in the original intervals list
 *                 last_interval_was_sent = any(             # <<<<<<<<<<<<<<
 *                     (hasattr(interval, 'start_time') and hasattr(last_interval, 'start_time') and
 *                      hasattr(interval, 'end_time') and hasattr(last_interval, 'end_time') and
*/
      __Pyx_XDECREF(__pyx_r);

      /* "ws_package/controllers/activity_controller.py":5472
 *                 # Verify last_interval was actually sent by checking if it's in the original intervals list
 *                 last_interval_was_sent = any(
 *                     (hasattr(interval, 'start_time') and hasattr(last_interval, 'start_time') and             # <<<<<<<<<<<<<<
 *                      hasattr(interval, 'end_time') and hasattr(last_interval, 'end_time') and
 *                      hasattr(interval, 'counter') and hasattr(last_interval, 'counter') and
*/
      __Pyx_INCREF(Py_True);
      __pyx_r = Py_True;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }

    /* "ws_package/controllers/activity_controller.py":5478
 *                      interval.end_time == last_interval.end_time and
 *                      interval.counter == last_interval.counter)
 *                     for interval in intervals             # <<<<<<<<<<<<<<
 *                 ) if intervals else False
 * 
*/
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  /*else*/ {

    /* "ws_package/controllers/activity_controller.py":5471
 *                 logger.info("Last interval was not updated in any batch - explicitly updating it now")
 *                 # Verify last_interval was actually sent by checking if it's in the original intervals list
 *                 last_interval_was_sent = any(             # <<<<<<<<<<<<<<
 *                     (hasattr(interval, 'start_time') and hasattr(last_interval, 'start_time') and
 *                      hasattr(interval, 'end_time') and hasattr(last_interval, 'end_time') and
*/
    __Pyx_XDECREF(__pyx_r);

    /* "ws_package/controllers/activity_controller.py":5472
 *                 # Verify last_interval was actually sent by checking if it's in the original intervals list
 *                 last_interval_was_sent = any(
 *                     (hasattr(interval, 'start_time') and hasattr(last_interval, 'start_time') and             # <<<<<<<<<<<<<<
 *                      hasattr(interval, 'end_time') and hasattr(last_interval, 'end_time') and
 *                      hasattr(interval, 'counter') and hasattr(last_interval, 'counter') and
*/
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":4850
 *             )
 * 
 *     async def _last_api_call_impl(             # <<<<<<<<<<<<<<
 *         self,
 *         user_entity: UserEntity,
*/

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_177_last_api_call_impl(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity, int __pyx_v_keep_idle_time, PyObject *__pyx_v_close_time, PyObject *__pyx_v_payload_project_id, PyObject *__pyx_v_payload_task_id) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl *__pyx_cur_scope;
  PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_6generator64 = 0;
  PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_9generator65 = 0;
  PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_12generator66 = 0;
  PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_15generator67 = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_last_api_call_impl", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 4850, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_user_entity = __pyx_v_user_entity;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_user_entity);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_user_entity);
  __pyx_cur_scope->__pyx_v_keep_idle_time = __pyx_v_keep_idle_time;
  __pyx_cur_scope->__pyx_v_close_time = __pyx_v_close_time;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_close_time);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_close_time);
  __pyx_cur_scope->__pyx_v_payload_project_id = __pyx_v_payload_project_id;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_payload_project_id);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_payload_project_id);
  __pyx_cur_scope->__pyx_v_payload_task_id = __pyx_v_payload_task_id;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_payload_task_id);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_payload_task_id);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_179generator35, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[59]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_last_api_call_impl, __pyx_mstate_global->__pyx_n_u_ActivityController__last_api_cal_2, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 4850, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XDECREF(__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_6generator64);
  __Pyx_XDECREF(__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_9generator65);
  __Pyx_XDECREF(__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_12generator66);
  __Pyx_XDECREF(__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_15generator67);
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":5158
 * 
 *                 # Helper function to compare datetimes with tolerance (1 second) to handle precision differences
 *                 def datetime_matches(dt1, dt2, tolerance_seconds=1.0):             # <<<<<<<<<<<<<<
 *                     """Check if two datetimes match within tolerance"""
 *                     if dt1 is None or dt2 is None:
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_1datetime_matches(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_datetime_matches, "Check if two datetimes match within tolerance");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_1datetime_matches = {"datetime_matches", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_1datetime_matches, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_datetime_matches};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_1datetime_matches(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_dt1 = 0;
  PyObject *__pyx_v_dt2 = 0;
  PyObject *__pyx_v_tolerance_seconds = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("datetime_matches (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_dt1,&__pyx_mstate_global->__pyx_n_u_dt2,&__pyx_mstate_global->__pyx_n_u_tolerance_seconds,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 5158, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 5158, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 5158, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 5158, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "datetime_matches", 0) < (0)) __PYX_ERR(0, 5158, __pyx_L3_error)
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject *)((PyObject*)__pyx_mstate_global->__pyx_float_1_0)));
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("datetime_matches", 0, 2, 3, i); __PYX_ERR(0, 5158, __pyx_L3_error) }
      }
    } else {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 5158, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 5158, __pyx_L3_error)
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 5158, __pyx_L3_error)
        break;
        default: goto __pyx_L5_argtuple_error;
      }
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject *)((PyObject*)__pyx_mstate_global->__pyx_float_1_0)));
    }
    __pyx_v_dt1 = values[0];
    __pyx_v_dt2 = values[1];
    __pyx_v_tolerance_seconds = values[2];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("datetime_matches", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 5158, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl.datetime_matches", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_datetime_matches(__pyx_self, __pyx_v_dt1, __pyx_v_dt2, __pyx_v_tolerance_seconds);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_datetime_matches(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dt1, PyObject *__pyx_v_dt2, PyObject *__pyx_v_tolerance_seconds) {
  PyObject *__pyx_v_time_diff = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  size_t __pyx_t_9;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("datetime_matches", 0);

  /* "ws_package/controllers/activity_controller.py":5160
 *                 def datetime_matches(dt1, dt2, tolerance_seconds=1.0):
 *                     """Check if two datetimes match within tolerance"""
 *                     if dt1 is None or dt2 is None:             # <<<<<<<<<<<<<<
 *                         return False
 *                     try:
*/
  __pyx_t_2 = (__pyx_v_dt1 == Py_None);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = (__pyx_v_dt2 == Py_None);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "ws_package/controllers/activity_controller.py":5161
 *                     """Check if two datetimes match within tolerance"""
 *                     if dt1 is None or dt2 is None:
 *                         return False             # <<<<<<<<<<<<<<
 *                     try:
 *                         time_diff = abs((dt1 - dt2).total_seconds())
*/
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":5160
 *                 def datetime_matches(dt1, dt2, tolerance_seconds=1.0):
 *                     """Check if two datetimes match within tolerance"""
 *                     if dt1 is None or dt2 is None:             # <<<<<<<<<<<<<<
 *                         return False
 *                     try:
*/
  }

  /* "ws_package/controllers/activity_controller.py":5162
 *                     if dt1 is None or dt2 is None:
 *                         return False
 *                     try:             # <<<<<<<<<<<<<<
 *                         time_diff = abs((dt1 - dt2).total_seconds())
 *                         return time_diff <= tolerance_seconds
*/
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":5163
 *                         return False
 *                     try:
 *                         time_diff = abs((dt1 - dt2).total_seconds())             # <<<<<<<<<<<<<<
 *                         return time_diff <= tolerance_seconds
 *                     except Exception:
*/
      __pyx_t_8 = PyNumber_Subtract(__pyx_v_dt1, __pyx_v_dt2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 5163, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_7 = __pyx_t_8;
      __Pyx_INCREF(__pyx_t_7);
      __pyx_t_9 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
        __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_total_seconds, __pyx_callargs+__pyx_t_9, (1-__pyx_t_9) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5163, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_6);
      }
      __pyx_t_8 = __Pyx_PyNumber_Absolute(__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 5163, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_v_time_diff = __pyx_t_8;
      __pyx_t_8 = 0;

      /* "ws_package/controllers/activity_controller.py":5164
 *                     try:
 *                         time_diff = abs((dt1 - dt2).total_seconds())
 *                         return time_diff <= tolerance_seconds             # <<<<<<<<<<<<<<
 *                     except Exception:
 *                         return False
*/
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_8 = PyObject_RichCompare(__pyx_v_time_diff, __pyx_v_tolerance_seconds, Py_LE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 5164, __pyx_L6_error)
      __pyx_r = __pyx_t_8;
      __pyx_t_8 = 0;
      goto __pyx_L10_try_return;

      /* "ws_package/controllers/activity_controller.py":5162
 *                     if dt1 is None or dt2 is None:
 *                         return False
 *                     try:             # <<<<<<<<<<<<<<
 *                         time_diff = abs((dt1 - dt2).total_seconds())
 *                         return time_diff <= tolerance_seconds
*/
    }
    __pyx_L6_error:;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "ws_package/controllers/activity_controller.py":5165
 *                         time_diff = abs((dt1 - dt2).total_seconds())
 *                         return time_diff <= tolerance_seconds
 *                     except Exception:             # <<<<<<<<<<<<<<
 *                         return False
 * 
*/
    __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_10) {
      __Pyx_ErrRestore(0,0,0);

      /* "ws_package/controllers/activity_controller.py":5166
 *                         return time_diff <= tolerance_seconds
 *                     except Exception:
 *                         return False             # <<<<<<<<<<<<<<
 * 
 *                 for attempt in range(max_retries):
*/
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_False);
      __pyx_r = Py_False;
      goto __pyx_L9_except_return;
    }
    goto __pyx_L8_except_error;

    /* "ws_package/controllers/activity_controller.py":5162
 *                     if dt1 is None or dt2 is None:
 *                         return False
 *                     try:             # <<<<<<<<<<<<<<
 *                         time_diff = abs((dt1 - dt2).total_seconds())
 *                         return time_diff <= tolerance_seconds
*/
    __pyx_L8_except_error:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L10_try_return:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L0;
    __pyx_L9_except_return:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L0;
  }

  /* "ws_package/controllers/activity_controller.py":5158
 * 
 *                 # Helper function to compare datetimes with tolerance (1 second) to handle precision differences
 *                 def datetime_matches(dt1, dt2, tolerance_seconds=1.0):             # <<<<<<<<<<<<<<
 *                     """Check if two datetimes match within tolerance"""
 *                     if dt1 is None or dt2 is None:
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl.datetime_matches", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_time_diff);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":5289
 *                 if intervals:
 *                     # Final check if last interval is in results (using tolerance-based comparison)
 *                     def datetime_matches_final(dt1, dt2, tolerance_seconds=1.0):             # <<<<<<<<<<<<<<
 *                         if dt1 is None or dt2 is None:
 *                             return False
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_3datetime_matches_final(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_3datetime_matches_final = {"datetime_matches_final", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_3datetime_matches_final, __Pyx_METH_FASTCALL|METH_KEYWORDS, 0};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_3datetime_matches_final(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_dt1 = 0;
  PyObject *__pyx_v_dt2 = 0;
  PyObject *__pyx_v_tolerance_seconds = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("datetime_matches_final (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_dt1,&__pyx_mstate_global->__pyx_n_u_dt2,&__pyx_mstate_global->__pyx_n_u_tolerance_seconds,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 5289, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 5289, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 5289, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 5289, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "datetime_matches_final", 0) < (0)) __PYX_ERR(0, 5289, __pyx_L3_error)
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject *)((PyObject*)__pyx_mstate_global->__pyx_float_1_0)));
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("datetime_matches_final", 0, 2, 3, i); __PYX_ERR(0, 5289, __pyx_L3_error) }
      }
    } else {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 5289, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 5289, __pyx_L3_error)
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 5289, __pyx_L3_error)
        break;
        default: goto __pyx_L5_argtuple_error;
      }
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject *)((PyObject*)__pyx_mstate_global->__pyx_float_1_0)));
    }
    __pyx_v_dt1 = values[0];
    __pyx_v_dt2 = values[1];
    __pyx_v_tolerance_seconds = values[2];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("datetime_matches_final", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 5289, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl.datetime_matches_final", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_2datetime_matches_final(__pyx_self, __pyx_v_dt1, __pyx_v_dt2, __pyx_v_tolerance_seconds);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_2datetime_matches_final(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_dt1, PyObject *__pyx_v_dt2, PyObject *__pyx_v_tolerance_seconds) {
  PyObject *__pyx_v_time_diff = NULL;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_t_1;
  int __pyx_t_2;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  size_t __pyx_t_9;
  int __pyx_t_10;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("datetime_matches_final", 0);

  /* "ws_package/controllers/activity_controller.py":5290
 *                     # Final check if last interval is in results (using tolerance-based comparison)
 *                     def datetime_matches_final(dt1, dt2, tolerance_seconds=1.0):
 *                         if dt1 is None or dt2 is None:             # <<<<<<<<<<<<<<
 *                             return False
 *                         try:
*/
  __pyx_t_2 = (__pyx_v_dt1 == Py_None);
  if (!__pyx_t_2) {
  } else {
    __pyx_t_1 = __pyx_t_2;
    goto __pyx_L4_bool_binop_done;
  }
  __pyx_t_2 = (__pyx_v_dt2 == Py_None);
  __pyx_t_1 = __pyx_t_2;
  __pyx_L4_bool_binop_done:;
  if (__pyx_t_1) {

    /* "ws_package/controllers/activity_controller.py":5291
 *                     def datetime_matches_final(dt1, dt2, tolerance_seconds=1.0):
 *                         if dt1 is None or dt2 is None:
 *                             return False             # <<<<<<<<<<<<<<
 *                         try:
 *                             time_diff = abs((dt1 - dt2).total_seconds())
*/
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":5290
 *                     # Final check if last interval is in results (using tolerance-based comparison)
 *                     def datetime_matches_final(dt1, dt2, tolerance_seconds=1.0):
 *                         if dt1 is None or dt2 is None:             # <<<<<<<<<<<<<<
 *                             return False
 *                         try:
*/
  }

  /* "ws_package/controllers/activity_controller.py":5292
 *                         if dt1 is None or dt2 is None:
 *                             return False
 *                         try:             # <<<<<<<<<<<<<<
 *                             time_diff = abs((dt1 - dt2).total_seconds())
 *                             return time_diff <= tolerance_seconds
*/
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_t_5);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":5293
 *                             return False
 *                         try:
 *                             time_diff = abs((dt1 - dt2).total_seconds())             # <<<<<<<<<<<<<<
 *                             return time_diff <= tolerance_seconds
 *                         except Exception:
*/
      __pyx_t_8 = PyNumber_Subtract(__pyx_v_dt1, __pyx_v_dt2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 5293, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_7 = __pyx_t_8;
      __Pyx_INCREF(__pyx_t_7);
      __pyx_t_9 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
        __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_total_seconds, __pyx_callargs+__pyx_t_9, (1-__pyx_t_9) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5293, __pyx_L6_error)
        __Pyx_GOTREF(__pyx_t_6);
      }
      __pyx_t_8 = __Pyx_PyNumber_Absolute(__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 5293, __pyx_L6_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_v_time_diff = __pyx_t_8;
      __pyx_t_8 = 0;

      /* "ws_package/controllers/activity_controller.py":5294
 *                         try:
 *                             time_diff = abs((dt1 - dt2).total_seconds())
 *                             return time_diff <= tolerance_seconds             # <<<<<<<<<<<<<<
 *                         except Exception:
 *                             return False
*/
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_8 = PyObject_RichCompare(__pyx_v_time_diff, __pyx_v_tolerance_seconds, Py_LE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 5294, __pyx_L6_error)
      __pyx_r = __pyx_t_8;
      __pyx_t_8 = 0;
      goto __pyx_L10_try_return;

      /* "ws_package/controllers/activity_controller.py":5292
 *                         if dt1 is None or dt2 is None:
 *                             return False
 *                         try:             # <<<<<<<<<<<<<<
 *                             time_diff = abs((dt1 - dt2).total_seconds())
 *                             return time_diff <= tolerance_seconds
*/
    }
    __pyx_L6_error:;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "ws_package/controllers/activity_controller.py":5295
 *                             time_diff = abs((dt1 - dt2).total_seconds())
 *                             return time_diff <= tolerance_seconds
 *                         except Exception:             # <<<<<<<<<<<<<<
 *                             return False
 * 
*/
    __pyx_t_10 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_10) {
      __Pyx_ErrRestore(0,0,0);

      /* "ws_package/controllers/activity_controller.py":5296
 *                             return time_diff <= tolerance_seconds
 *                         except Exception:
 *                             return False             # <<<<<<<<<<<<<<
 * 
 *                     last_interval_in_list = any(
*/
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_False);
      __pyx_r = Py_False;
      goto __pyx_L9_except_return;
    }
    goto __pyx_L8_except_error;

    /* "ws_package/controllers/activity_controller.py":5292
 *                         if dt1 is None or dt2 is None:
 *                             return False
 *                         try:             # <<<<<<<<<<<<<<
 *                             time_diff = abs((dt1 - dt2).total_seconds())
 *                             return time_diff <= tolerance_seconds
*/
    __pyx_L8_except_error:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L1_error;
    __pyx_L10_try_return:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L0;
    __pyx_L9_except_return:;
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_XGIVEREF(__pyx_t_4);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
    goto __pyx_L0;
  }

  /* "ws_package/controllers/activity_controller.py":5289
 *                 if intervals:
 *                     # Final check if last interval is in results (using tolerance-based comparison)
 *                     def datetime_matches_final(dt1, dt2, tolerance_seconds=1.0):             # <<<<<<<<<<<<<<
 *                         if dt1 is None or dt2 is None:
 *                             return False
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl.datetime_matches_final", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XDECREF(__pyx_v_time_diff);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":4850
 *             )
 * 
 *     async def _last_api_call_impl(             # <<<<<<<<<<<<<<
 *         self,
 *         user_entity: UserEntity,
*/

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_179generator35(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  size_t __pyx_t_8;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  __Pyx_PySendResult __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  PyObject *__pyx_t_26 = NULL;
  PyObject *__pyx_t_27 = NULL;
  int __pyx_t_28;
  double __pyx_t_29;
  PyObject *__pyx_t_30 = NULL;
  int __pyx_t_31;
  int __pyx_t_32;
  char const *__pyx_t_33;
  char const *__pyx_t_34;
  PyObject *(*__pyx_t_35)(PyObject *);
  PyObject *__pyx_t_36 = NULL;
  PyObject *__pyx_t_37 = NULL;
  PyObject *__pyx_t_38 = NULL;
  PyObject *__pyx_t_39 = NULL;
  PyObject *__pyx_t_40 = NULL;
  PyObject *__pyx_t_41 = NULL;
  char const *__pyx_t_42;
  char const *__pyx_t_43;
  char const *__pyx_t_44;
  Py_ssize_t __pyx_t_45;
  PyObject *(*__pyx_t_46)(PyObject *);
  int __pyx_t_47;
  char const *__pyx_t_48;
  char const *__pyx_t_49;
  int __pyx_t_50;
  char const *__pyx_t_51;
  PyObject *__pyx_t_52 = NULL;
  char const *__pyx_t_53;
  char const *__pyx_t_54;
  PyObject *__pyx_t_55 = NULL;
  char const *__pyx_t_56;
  Py_ssize_t __pyx_t_57;
  char const *__pyx_t_58;
  char const *__pyx_t_59;
  char const *__pyx_t_60;
  char const *__pyx_t_61;
  char const *__pyx_t_62;
  char const *__pyx_t_63;
  char const *__pyx_t_64;
  char const *__pyx_t_65;
  PyObject *__pyx_t_66 = NULL;
  PyObject *__pyx_t_67 = NULL;
  PyObject *__pyx_t_68 = NULL;
  PyObject *__pyx_t_69 = NULL;
  PyObject *__pyx_t_70 = NULL;
  char const *__pyx_t_71;
  char const *__pyx_t_72;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_last_api_call_impl", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L11_resume_from_await;
    case 2: goto __pyx_L12_resume_from_await;
    case 3: goto __pyx_L31_resume_from_await;
    case 4: goto __pyx_L41_resume_from_await;
    case 5: goto __pyx_L60_resume_from_await;
    case 6: goto __pyx_L61_resume_from_await;
    case 7: goto __pyx_L102_resume_from_await;
    case 8: goto __pyx_L116_resume_from_await;
    case 9: goto __pyx_L120_resume_from_await;
    case 10: goto __pyx_L121_resume_from_await;
    case 11: goto __pyx_L122_resume_from_await;
    case 12: goto __pyx_L130_resume_from_await;
    case 13: goto __pyx_L131_resume_from_await;
    case 14: goto __pyx_L158_resume_from_await;
    case 15: goto __pyx_L172_resume_from_await;
    case 16: goto __pyx_L179_resume_from_await;
    case 17: goto __pyx_L180_resume_from_await;
    case 18: goto __pyx_L181_resume_from_await;
    case 19: goto __pyx_L199_resume_from_await;
    case 20: goto __pyx_L221_resume_from_await;
    case 21: goto __pyx_L222_resume_from_await;
    case 22: goto __pyx_L234_resume_from_await;
    case 23: goto __pyx_L244_resume_from_await;
    case 24: goto __pyx_L245_resume_from_await;
    case 25: goto __pyx_L331_resume_from_await;
    case 26: goto __pyx_L374_resume_from_await;
    case 27: goto __pyx_L388_resume_from_await;
    case 28: goto __pyx_L395_resume_from_await;
    case 29: goto __pyx_L396_resume_from_await;
    case 30: goto __pyx_L419_resume_from_await;
    case 31: goto __pyx_L444_resume_from_await;
    case 32: goto __pyx_L448_resume_from_await;
    case 33: goto __pyx_L489_resume_from_await;
    case 34: goto __pyx_L503_resume_from_await;
    case 35: goto __pyx_L507_resume_from_await;
    case 36: goto __pyx_L511_resume_from_await;
    case 37: goto __pyx_L512_resume_from_await;
    case 38: goto __pyx_L519_resume_from_await;
    case 39: goto __pyx_L520_resume_from_await;
    case 40: goto __pyx_L536_resume_from_await;
    case 41: goto __pyx_L565_resume_from_await;
    case 42: goto __pyx_L575_resume_from_await;
    case 43: goto __pyx_L579_resume_from_await;
    case 44: goto __pyx_L580_resume_from_await;
    case 45: goto __pyx_L589_resume_from_await;
    case 46: goto __pyx_L609_resume_from_await;
    case 47: goto __pyx_L623_resume_from_await;
    case 48: goto __pyx_L625_resume_from_await;
    case 49: goto __pyx_L629_resume_from_await;
    case 50: goto __pyx_L630_resume_from_await;
    case 51: goto __pyx_L653_resume_from_await;
    case 52: goto __pyx_L655_resume_from_await;
    case 53: goto __pyx_L676_resume_from_await;
    case 54: goto __pyx_L678_resume_from_await;
    case 55: goto __pyx_L724_resume_from_await;
    case 56: goto __pyx_L738_resume_from_await;
    case 57: goto __pyx_L746_resume_from_await;
    case 58: goto __pyx_L747_resume_from_await;
    case 59: goto __pyx_L773_resume_from_await;
    case 60: goto __pyx_L793_resume_from_await;
    case 61: goto __pyx_L795_resume_from_await;
    case 62: goto __pyx_L816_resume_from_await;
    case 63: goto __pyx_L828_resume_from_await;
    case 64: goto __pyx_L838_resume_from_await;
    case 65: goto __pyx_L853_resume_from_await;
    case 66: goto __pyx_L866_resume_from_await;
    case 67: goto __pyx_L867_resume_from_await;
    case 68: goto __pyx_L871_resume_from_await;
    case 69: goto __pyx_L872_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 4850, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":4860
 *     ):
 *         """Internal implementation of last_api_call (caller must hold _session_close_lock)."""
 *         try:             # <<<<<<<<<<<<<<
 *             logger.info(
 *                 "=== last_api_call STARTED (keep_idle_time=%s, close_time=%s, project_override=%s) ===",
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":4861
 *         """Internal implementation of last_api_call (caller must hold _session_close_lock)."""
 *         try:
 *             logger.info(             # <<<<<<<<<<<<<<
 *                 "=== last_api_call STARTED (keep_idle_time=%s, close_time=%s, project_override=%s) ===",
 *                 keep_idle_time,
*/
      __pyx_t_5 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4861, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4861, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":4863
 *             logger.info(
 *                 "=== last_api_call STARTED (keep_idle_time=%s, close_time=%s, project_override=%s) ===",
 *                 keep_idle_time,             # <<<<<<<<<<<<<<
 *                 close_time,
 *                 payload_project_id,
*/
      __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_cur_scope->__pyx_v_keep_idle_time); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4863, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);

      /* "ws_package/controllers/activity_controller.py":4865
 *                 keep_idle_time,
 *                 close_time,
 *                 payload_project_id,             # <<<<<<<<<<<<<<
 *             )
 *             logger.info("User entity: %s", user_entity.user_id if user_entity else 'None')
*/
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_5);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[5] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_last_api_call_STARTED_keep_idle, __pyx_t_6, __pyx_cur_scope->__pyx_v_close_time, __pyx_cur_scope->__pyx_v_payload_project_id};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4861, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":4867
 *                 payload_project_id,
 *             )
 *             logger.info("User entity: %s", user_entity.user_id if user_entity else 'None')             # <<<<<<<<<<<<<<
 *             logger.info("Getting last activity interval")
 * 
*/
      __pyx_t_7 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4867, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4867, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_user_entity); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4867, __pyx_L4_error)
      if (__pyx_t_9) {
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_user_id); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4867, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_6 = __pyx_t_10;
        __pyx_t_10 = 0;
      } else {
        __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_None);
        __pyx_t_6 = __pyx_mstate_global->__pyx_n_u_None;
      }
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
        assert(__pyx_t_7);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_User_entity_s, __pyx_t_6};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4867, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":4868
 *             )
 *             logger.info("User entity: %s", user_entity.user_id if user_entity else 'None')
 *             logger.info("Getting last activity interval")             # <<<<<<<<<<<<<<
 * 
 *             trimmed_partial = None
*/
      __pyx_t_5 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4868, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4868, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_5);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Getting_last_activity_interval};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4868, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":4870
 *             logger.info("Getting last activity interval")
 * 
 *             trimmed_partial = None             # <<<<<<<<<<<<<<
 *             if close_time is not None:
 *                 trimmed_partial = await self._trim_open_partial_at_project_switch(close_time)
*/
      __Pyx_INCREF(Py_None);
      __Pyx_GIVEREF(Py_None);
      __pyx_cur_scope->__pyx_v_trimmed_partial = Py_None;

      /* "ws_package/controllers/activity_controller.py":4871
 * 
 *             trimmed_partial = None
 *             if close_time is not None:             # <<<<<<<<<<<<<<
 *                 trimmed_partial = await self._trim_open_partial_at_project_switch(close_time)
 * 
*/
      __pyx_t_9 = (__pyx_cur_scope->__pyx_v_close_time != Py_None);
      if (__pyx_t_9) {

        /* "ws_package/controllers/activity_controller.py":4872
 *             trimmed_partial = None
 *             if close_time is not None:
 *                 trimmed_partial = await self._trim_open_partial_at_project_switch(close_time)             # <<<<<<<<<<<<<<
 * 
 *             # Scope to current session counter so post-gap intervals (reassigned or not)
*/
        __pyx_t_7 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_7);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_cur_scope->__pyx_v_close_time};
          __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_trim_open_partial_at_project_sw, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4872, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (likely(__pyx_t_11 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_1);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
          __Pyx_XGIVEREF(__pyx_t_2);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
          __Pyx_XGIVEREF(__pyx_t_3);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 1;
          return __pyx_r;
          __pyx_L11_resume_from_await:;
          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_1);
          __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_2);
          __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_3);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4872, __pyx_L4_error)
          __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
        } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __pyx_t_4 = __pyx_r; __pyx_r = NULL;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 4872, __pyx_L4_error)
        }
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_trimmed_partial);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_trimmed_partial, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":4871
 * 
 *             trimmed_partial = None
 *             if close_time is not None:             # <<<<<<<<<<<<<<
 *                 trimmed_partial = await self._trim_open_partial_at_project_switch(close_time)
 * 
*/
      }

      /* "ws_package/controllers/activity_controller.py":4876
 *             # Scope to current session counter so post-gap intervals (reassigned or not)
 *             # do not become the "last" end when closing after a long sleep gap.
 *             current_session_counter_for_last = self.last_count + 1             # <<<<<<<<<<<<<<
 *             last_interval_end = await self.activity_service.get_last_activity_interval(
 *                 counter=current_session_counter_for_last
*/
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4876, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = __Pyx_PyLong_AddObjC(__pyx_t_4, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4876, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GIVEREF(__pyx_t_7);
      __pyx_cur_scope->__pyx_v_current_session_counter_for_last = __pyx_t_7;
      __pyx_t_7 = 0;

      /* "ws_package/controllers/activity_controller.py":4877
 *             # do not become the "last" end when closing after a long sleep gap.
 *             current_session_counter_for_last = self.last_count + 1
 *             last_interval_end = await self.activity_service.get_last_activity_interval(             # <<<<<<<<<<<<<<
 *                 counter=current_session_counter_for_last
 *             )
*/
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4877, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = __pyx_t_5;
      __Pyx_INCREF(__pyx_t_4);

      /* "ws_package/controllers/activity_controller.py":4878
 *             current_session_counter_for_last = self.last_count + 1
 *             last_interval_end = await self.activity_service.get_last_activity_interval(
 *                 counter=current_session_counter_for_last             # <<<<<<<<<<<<<<
 *             )
 * 
*/
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_4, NULL};
        __pyx_t_6 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4877, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_counter, __pyx_cur_scope->__pyx_v_current_session_counter_for_last, __pyx_t_6, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 4877, __pyx_L4_error)
        __pyx_t_7 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_get_last_activity_interval, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_6);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4877, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
      }
      __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7, &__pyx_r);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (likely(__pyx_t_11 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
        __Pyx_XGIVEREF(__pyx_t_2);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
        __Pyx_XGIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 2;
        return __pyx_r;
        __pyx_L12_resume_from_await:;
        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_1);
        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_2);
        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_3);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4877, __pyx_L4_error)
        __pyx_t_7 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_7);
      } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __pyx_t_7 = __pyx_r; __pyx_r = NULL;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 4877, __pyx_L4_error)
      }
      __Pyx_GIVEREF(__pyx_t_7);
      __pyx_cur_scope->__pyx_v_last_interval_end = __pyx_t_7;
      __pyx_t_7 = 0;

      /* "ws_package/controllers/activity_controller.py":4883
 *             # NEW: Check if the last interval is a sleep interval (long gap with zero activity)
 *             # If so, don't create a new interval from sleep end to wake-up time
 *             is_sleep_interval = False             # <<<<<<<<<<<<<<
 *             if last_interval_end:
 *                 try:
*/
      __pyx_cur_scope->__pyx_v_is_sleep_interval = 0;

      /* "ws_package/controllers/activity_controller.py":4884
 *             # If so, don't create a new interval from sleep end to wake-up time
 *             is_sleep_interval = False
 *             if last_interval_end:             # <<<<<<<<<<<<<<
 *                 try:
 *                     # Get the actual last interval to check its duration and activity
*/
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval_end); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4884, __pyx_L4_error)
      if (__pyx_t_9) {

        /* "ws_package/controllers/activity_controller.py":4885
 *             is_sleep_interval = False
 *             if last_interval_end:
 *                 try:             # <<<<<<<<<<<<<<
 *                     # Get the actual last interval to check its duration and activity
 *                     with db_lock_manager.read_lock():
*/
        {
          __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_14);
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":4887
 *                 try:
 *                     # Get the actual last interval to check its duration and activity
 *                     with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                         async with async_session() as session:
 * 
*/
            /*with:*/ {
              __pyx_t_5 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4887, __pyx_L14_error)
              __Pyx_GOTREF(__pyx_t_6);
              __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4887, __pyx_L14_error)
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_4))) {
                __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
                assert(__pyx_t_5);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                __Pyx_INCREF(__pyx_t_5);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4887, __pyx_L14_error)
                __Pyx_GOTREF(__pyx_t_7);
              }
              __pyx_t_15 = __Pyx_PyObject_LookupSpecial(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4887, __pyx_L14_error)
              __Pyx_GOTREF(__pyx_t_15);
              __pyx_t_5 = NULL;
              __pyx_t_6 = __Pyx_PyObject_LookupSpecial(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4887, __pyx_L20_error)
              __Pyx_GOTREF(__pyx_t_6);
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (likely(PyMethod_Check(__pyx_t_6))) {
                __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
                assert(__pyx_t_5);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                __Pyx_INCREF(__pyx_t_5);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4887, __pyx_L20_error)
                __Pyx_GOTREF(__pyx_t_4);
              }
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              /*try:*/ {
                {
                  __Pyx_ExceptionSave(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
                  __Pyx_XGOTREF(__pyx_t_16);
                  __Pyx_XGOTREF(__pyx_t_17);
                  __Pyx_XGOTREF(__pyx_t_18);
                  /*try:*/ {

                    /* "ws_package/controllers/activity_controller.py":4888
 *                     # Get the actual last interval to check its duration and activity
 *                     with db_lock_manager.read_lock():
 *                         async with async_session() as session:             # <<<<<<<<<<<<<<
 * 
 *                             query = (
*/
                    /*with:*/ {
                      __pyx_t_4 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4888, __pyx_L24_error)
                      __Pyx_GOTREF(__pyx_t_6);
                      __pyx_t_8 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_6))) {
                        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
                        assert(__pyx_t_4);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                        __Pyx_INCREF(__pyx_t_4);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                        __pyx_t_8 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
                        __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4888, __pyx_L24_error)
                        __Pyx_GOTREF(__pyx_t_7);
                      }
                      __pyx_t_19 = __Pyx_PyObject_LookupSpecial(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 4888, __pyx_L24_error)
                      __Pyx_GOTREF(__pyx_t_19);
                      __pyx_t_4 = NULL;
                      __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4888, __pyx_L30_error)
                      __Pyx_GOTREF(__pyx_t_5);
                      __pyx_t_8 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (likely(PyMethod_Check(__pyx_t_5))) {
                        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
                        assert(__pyx_t_4);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                        __Pyx_INCREF(__pyx_t_4);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                        __pyx_t_8 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
                        __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4888, __pyx_L30_error)
                        __Pyx_GOTREF(__pyx_t_6);
                      }
                      __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_6, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                      if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_7);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_7;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_t_19);
                        __pyx_cur_scope->__pyx_t_11 = __pyx_t_19;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 3;
                        return __pyx_r;
                        __pyx_L31_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_7 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_7);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        __pyx_t_19 = __pyx_cur_scope->__pyx_t_11;
                        __pyx_cur_scope->__pyx_t_11 = 0;
                        __Pyx_XGOTREF(__pyx_t_19);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4888, __pyx_L30_error)
                        __pyx_t_6 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_6);
                      } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_6 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 4888, __pyx_L30_error)
                      }
                      __pyx_t_5 = __pyx_t_6;
                      __pyx_t_6 = 0;
                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                      /*try:*/ {
                        {
                          __Pyx_ExceptionSave(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
                          __Pyx_XGOTREF(__pyx_t_20);
                          __Pyx_XGOTREF(__pyx_t_21);
                          __Pyx_XGOTREF(__pyx_t_22);
                          /*try:*/ {
                            __Pyx_GIVEREF(__pyx_t_5);
                            __pyx_cur_scope->__pyx_v_session = __pyx_t_5;
                            __pyx_t_5 = 0;

                            /* "ws_package/controllers/activity_controller.py":4891
 * 
 *                             query = (
 *                                 select(ActivityInterval)             # <<<<<<<<<<<<<<
 *                                 .where(ActivityInterval.counter == current_session_counter_for_last)
 *                                 .order_by(desc(ActivityInterval.id))
*/
                            __pyx_t_25 = NULL;
                            __Pyx_GetModuleGlobalName(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 4891, __pyx_L35_error)
                            __Pyx_GOTREF(__pyx_t_26);
                            __Pyx_GetModuleGlobalName(__pyx_t_27, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 4891, __pyx_L35_error)
                            __Pyx_GOTREF(__pyx_t_27);
                            __pyx_t_8 = 1;
                            #if CYTHON_UNPACK_METHODS
                            if (unlikely(PyMethod_Check(__pyx_t_26))) {
                              __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_26);
                              assert(__pyx_t_25);
                              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_26);
                              __Pyx_INCREF(__pyx_t_25);
                              __Pyx_INCREF(__pyx__function);
                              __Pyx_DECREF_SET(__pyx_t_26, __pyx__function);
                              __pyx_t_8 = 0;
                            }
                            #endif
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_25, __pyx_t_27};
                              __pyx_t_24 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_26, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                              __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                              __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                              if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 4891, __pyx_L35_error)
                              __Pyx_GOTREF(__pyx_t_24);
                            }
                            __pyx_t_23 = __pyx_t_24;
                            __Pyx_INCREF(__pyx_t_23);

                            /* "ws_package/controllers/activity_controller.py":4892
 *                             query = (
 *                                 select(ActivityInterval)
 *                                 .where(ActivityInterval.counter == current_session_counter_for_last)             # <<<<<<<<<<<<<<
 *                                 .order_by(desc(ActivityInterval.id))
 *                                 .limit(1)
*/
                            __Pyx_GetModuleGlobalName(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 4892, __pyx_L35_error)
                            __Pyx_GOTREF(__pyx_t_26);
                            __pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 4892, __pyx_L35_error)
                            __Pyx_GOTREF(__pyx_t_27);
                            __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                            __pyx_t_26 = PyObject_RichCompare(__pyx_t_27, __pyx_cur_scope->__pyx_v_current_session_counter_for_last, Py_EQ); __Pyx_XGOTREF(__pyx_t_26); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 4892, __pyx_L35_error)
                            __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                            __pyx_t_8 = 0;
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_23, __pyx_t_26};
                              __pyx_t_10 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                              __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                              __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                              if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4892, __pyx_L35_error)
                              __Pyx_GOTREF(__pyx_t_10);
                            }
                            __pyx_t_4 = __pyx_t_10;
                            __Pyx_INCREF(__pyx_t_4);

                            /* "ws_package/controllers/activity_controller.py":4893
 *                                 select(ActivityInterval)
 *                                 .where(ActivityInterval.counter == current_session_counter_for_last)
 *                                 .order_by(desc(ActivityInterval.id))             # <<<<<<<<<<<<<<
 *                                 .limit(1)
 *                             )
*/
                            __pyx_t_26 = NULL;
                            __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_desc); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 4893, __pyx_L35_error)
                            __Pyx_GOTREF(__pyx_t_23);
                            __Pyx_GetModuleGlobalName(__pyx_t_27, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 4893, __pyx_L35_error)
                            __Pyx_GOTREF(__pyx_t_27);
                            __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_27, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 4893, __pyx_L35_error)
                            __Pyx_GOTREF(__pyx_t_25);
                            __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                            __pyx_t_8 = 1;
                            #if CYTHON_UNPACK_METHODS
                            if (unlikely(PyMethod_Check(__pyx_t_23))) {
                              __pyx_t_26 = PyMethod_GET_SELF(__pyx_t_23);
                              assert(__pyx_t_26);
                              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_23);
                              __Pyx_INCREF(__pyx_t_26);
                              __Pyx_INCREF(__pyx__function);
                              __Pyx_DECREF_SET(__pyx_t_23, __pyx__function);
                              __pyx_t_8 = 0;
                            }
                            #endif
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_26, __pyx_t_25};
                              __pyx_t_24 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_23, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                              __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                              __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                              if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 4893, __pyx_L35_error)
                              __Pyx_GOTREF(__pyx_t_24);
                            }
                            __pyx_t_8 = 0;
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_24};
                              __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_order_by, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                              __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                              if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4893, __pyx_L35_error)
                              __Pyx_GOTREF(__pyx_t_6);
                            }
                            __pyx_t_7 = __pyx_t_6;
                            __Pyx_INCREF(__pyx_t_7);
                            __pyx_t_8 = 0;
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_mstate_global->__pyx_int_1};
                              __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_limit, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                              if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4894, __pyx_L35_error)
                              __Pyx_GOTREF(__pyx_t_5);
                            }
                            __Pyx_GIVEREF(__pyx_t_5);
                            __pyx_cur_scope->__pyx_v_query = __pyx_t_5;
                            __pyx_t_5 = 0;

                            /* "ws_package/controllers/activity_controller.py":4896
 *                                 .limit(1)
 *                             )
 *                             result = await session.execute(query)             # <<<<<<<<<<<<<<
 *                             last_interval_obj = result.scalar_one_or_none()
 * 
*/
                            __pyx_t_6 = __pyx_cur_scope->__pyx_v_session;
                            __Pyx_INCREF(__pyx_t_6);
                            __pyx_t_8 = 0;
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_cur_scope->__pyx_v_query};
                              __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                              if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4896, __pyx_L35_error)
                              __Pyx_GOTREF(__pyx_t_5);
                            }
                            __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
                            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                            if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                              __Pyx_GOTREF(__pyx_r);
                              __Pyx_XGIVEREF(__pyx_t_1);
                              __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                              __Pyx_XGIVEREF(__pyx_t_2);
                              __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                              __Pyx_XGIVEREF(__pyx_t_3);
                              __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                              __Pyx_XGIVEREF(__pyx_t_12);
                              __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                              __Pyx_XGIVEREF(__pyx_t_13);
                              __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                              __Pyx_XGIVEREF(__pyx_t_14);
                              __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                              __Pyx_XGIVEREF(__pyx_t_15);
                              __pyx_cur_scope->__pyx_t_6 = __pyx_t_15;
                              __Pyx_XGIVEREF(__pyx_t_16);
                              __pyx_cur_scope->__pyx_t_7 = __pyx_t_16;
                              __Pyx_XGIVEREF(__pyx_t_17);
                              __pyx_cur_scope->__pyx_t_8 = __pyx_t_17;
                              __Pyx_XGIVEREF(__pyx_t_18);
                              __pyx_cur_scope->__pyx_t_9 = __pyx_t_18;
                              __Pyx_XGIVEREF(__pyx_t_19);
                              __pyx_cur_scope->__pyx_t_10 = __pyx_t_19;
                              __Pyx_XGIVEREF(__pyx_t_20);
                              __pyx_cur_scope->__pyx_t_11 = __pyx_t_20;
                              __Pyx_XGIVEREF(__pyx_t_21);
                              __pyx_cur_scope->__pyx_t_12 = __pyx_t_21;
                              __Pyx_XGIVEREF(__pyx_t_22);
                              __pyx_cur_scope->__pyx_t_13 = __pyx_t_22;
                              __Pyx_XGIVEREF(__pyx_r);
                              __Pyx_RefNannyFinishContext();
                              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                              /* return from generator, awaiting value */
                              __pyx_generator->resume_label = 4;
                              return __pyx_r;
                              __pyx_L41_resume_from_await:;
                              __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                              __pyx_cur_scope->__pyx_t_0 = 0;
                              __Pyx_XGOTREF(__pyx_t_1);
                              __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                              __pyx_cur_scope->__pyx_t_1 = 0;
                              __Pyx_XGOTREF(__pyx_t_2);
                              __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                              __pyx_cur_scope->__pyx_t_2 = 0;
                              __Pyx_XGOTREF(__pyx_t_3);
                              __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                              __pyx_cur_scope->__pyx_t_3 = 0;
                              __Pyx_XGOTREF(__pyx_t_12);
                              __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                              __pyx_cur_scope->__pyx_t_4 = 0;
                              __Pyx_XGOTREF(__pyx_t_13);
                              __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                              __pyx_cur_scope->__pyx_t_5 = 0;
                              __Pyx_XGOTREF(__pyx_t_14);
                              __pyx_t_15 = __pyx_cur_scope->__pyx_t_6;
                              __pyx_cur_scope->__pyx_t_6 = 0;
                              __Pyx_XGOTREF(__pyx_t_15);
                              __pyx_t_16 = __pyx_cur_scope->__pyx_t_7;
                              __pyx_cur_scope->__pyx_t_7 = 0;
                              __Pyx_XGOTREF(__pyx_t_16);
                              __pyx_t_17 = __pyx_cur_scope->__pyx_t_8;
                              __pyx_cur_scope->__pyx_t_8 = 0;
                              __Pyx_XGOTREF(__pyx_t_17);
                              __pyx_t_18 = __pyx_cur_scope->__pyx_t_9;
                              __pyx_cur_scope->__pyx_t_9 = 0;
                              __Pyx_XGOTREF(__pyx_t_18);
                              __pyx_t_19 = __pyx_cur_scope->__pyx_t_10;
                              __pyx_cur_scope->__pyx_t_10 = 0;
                              __Pyx_XGOTREF(__pyx_t_19);
                              __pyx_t_20 = __pyx_cur_scope->__pyx_t_11;
                              __pyx_cur_scope->__pyx_t_11 = 0;
                              __Pyx_XGOTREF(__pyx_t_20);
                              __pyx_t_21 = __pyx_cur_scope->__pyx_t_12;
                              __pyx_cur_scope->__pyx_t_12 = 0;
                              __Pyx_XGOTREF(__pyx_t_21);
                              __pyx_t_22 = __pyx_cur_scope->__pyx_t_13;
                              __pyx_cur_scope->__pyx_t_13 = 0;
                              __Pyx_XGOTREF(__pyx_t_22);
                              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4896, __pyx_L35_error)
                              __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
                            } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                              __Pyx_GOTREF(__pyx_r);
                              __pyx_t_5 = __pyx_r; __pyx_r = NULL;
                            } else {
                              __Pyx_XGOTREF(__pyx_r);
                              __PYX_ERR(0, 4896, __pyx_L35_error)
                            }
                            __Pyx_GIVEREF(__pyx_t_5);
                            __pyx_cur_scope->__pyx_v_result = __pyx_t_5;
                            __pyx_t_5 = 0;

                            /* "ws_package/controllers/activity_controller.py":4897
 *                             )
 *                             result = await session.execute(query)
 *                             last_interval_obj = result.scalar_one_or_none()             # <<<<<<<<<<<<<<
 * 
 *                             if last_interval_obj and last_interval_obj.end_time == last_interval_end:
*/
                            __pyx_t_6 = __pyx_cur_scope->__pyx_v_result;
                            __Pyx_INCREF(__pyx_t_6);
                            __pyx_t_8 = 0;
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
                              __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalar_one_or_none, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                              if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4897, __pyx_L35_error)
                              __Pyx_GOTREF(__pyx_t_5);
                            }
                            __Pyx_GIVEREF(__pyx_t_5);
                            __pyx_cur_scope->__pyx_v_last_interval_obj = __pyx_t_5;
                            __pyx_t_5 = 0;

                            /* "ws_package/controllers/activity_controller.py":4899
 *                             last_interval_obj = result.scalar_one_or_none()
 * 
 *                             if last_interval_obj and last_interval_obj.end_time == last_interval_end:             # <<<<<<<<<<<<<<
 *                                 gap_seconds = (last_interval_obj.end_time - last_interval_obj.start_time).total_seconds()
 *                                 # Check if it's a long interval (>= 1 hour) with zero activity (sleep pattern)
*/
                            __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval_obj); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 4899, __pyx_L35_error)
                            if (__pyx_t_28) {
                            } else {
                              __pyx_t_9 = __pyx_t_28;
                              goto __pyx_L43_bool_binop_done;
                            }
                            __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval_obj, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4899, __pyx_L35_error)
                            __Pyx_GOTREF(__pyx_t_5);
                            __pyx_t_6 = PyObject_RichCompare(__pyx_t_5, __pyx_cur_scope->__pyx_v_last_interval_end, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4899, __pyx_L35_error)
                            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                            __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 4899, __pyx_L35_error)
                            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                            __pyx_t_9 = __pyx_t_28;
                            __pyx_L43_bool_binop_done:;
                            if (__pyx_t_9) {

                              /* "ws_package/controllers/activity_controller.py":4900
 * 
 *                             if last_interval_obj and last_interval_obj.end_time == last_interval_end:
 *                                 gap_seconds = (last_interval_obj.end_time - last_interval_obj.start_time).total_seconds()             # <<<<<<<<<<<<<<
 *                                 # Check if it's a long interval (>= 1 hour) with zero activity (sleep pattern)
 *                                 if gap_seconds >= 3600:  # 1 hour
*/
                              __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval_obj, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4900, __pyx_L35_error)
                              __Pyx_GOTREF(__pyx_t_7);
                              __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval_obj, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4900, __pyx_L35_error)
                              __Pyx_GOTREF(__pyx_t_10);
                              __pyx_t_24 = PyNumber_Subtract(__pyx_t_7, __pyx_t_10); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 4900, __pyx_L35_error)
                              __Pyx_GOTREF(__pyx_t_24);
                              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                              __pyx_t_5 = __pyx_t_24;
                              __Pyx_INCREF(__pyx_t_5);
                              __pyx_t_8 = 0;
                              {
                                PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                                __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_total_seconds, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                                __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                                if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4900, __pyx_L35_error)
                                __Pyx_GOTREF(__pyx_t_6);
                              }
                              __Pyx_GIVEREF(__pyx_t_6);
                              __pyx_cur_scope->__pyx_v_gap_seconds = __pyx_t_6;
                              __pyx_t_6 = 0;

                              /* "ws_package/controllers/activity_controller.py":4902
 *                                 gap_seconds = (last_interval_obj.end_time - last_interval_obj.start_time).total_seconds()
 *                                 # Check if it's a long interval (>= 1 hour) with zero activity (sleep pattern)
 *                                 if gap_seconds >= 3600:  # 1 hour             # <<<<<<<<<<<<<<
 *                                     activity_level = last_interval_obj.activityLevel
 *                                     if activity_level:
*/
                              __pyx_t_6 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_gap_seconds, __pyx_mstate_global->__pyx_int_3600, Py_GE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4902, __pyx_L35_error)
                              __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4902, __pyx_L35_error)
                              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                              if (__pyx_t_9) {

                                /* "ws_package/controllers/activity_controller.py":4903
 *                                 # Check if it's a long interval (>= 1 hour) with zero activity (sleep pattern)
 *                                 if gap_seconds >= 3600:  # 1 hour
 *                                     activity_level = last_interval_obj.activityLevel             # <<<<<<<<<<<<<<
 *                                     if activity_level:
 *                                         keyboard = float(activity_level.get('keyboard', 0) or 0)
*/
                                __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval_obj, __pyx_mstate_global->__pyx_n_u_activityLevel); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4903, __pyx_L35_error)
                                __Pyx_GOTREF(__pyx_t_6);
                                __Pyx_GIVEREF(__pyx_t_6);
                                __pyx_cur_scope->__pyx_v_activity_level = __pyx_t_6;
                                __pyx_t_6 = 0;

                                /* "ws_package/controllers/activity_controller.py":4904
 *                                 if gap_seconds >= 3600:  # 1 hour
 *                                     activity_level = last_interval_obj.activityLevel
 *                                     if activity_level:             # <<<<<<<<<<<<<<
 *                                         keyboard = float(activity_level.get('keyboard', 0) or 0)
 *                                         mouse = float(activity_level.get('mouse', 0) or 0)
*/
                                __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_activity_level); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4904, __pyx_L35_error)
                                if (__pyx_t_9) {

                                  /* "ws_package/controllers/activity_controller.py":4905
 *                                     activity_level = last_interval_obj.activityLevel
 *                                     if activity_level:
 *                                         keyboard = float(activity_level.get('keyboard', 0) or 0)             # <<<<<<<<<<<<<<
 *                                         mouse = float(activity_level.get('mouse', 0) or 0)
 *                                         average = float(activity_level.get('average', 0) or 0)
*/
                                  __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activity_level, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 4905, __pyx_L35_error)
                                  __Pyx_GOTREF(__pyx_t_24);
                                  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_24, __pyx_mstate_global->__pyx_tuple[15], NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4905, __pyx_L35_error)
                                  __Pyx_GOTREF(__pyx_t_5);
                                  __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                                  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4905, __pyx_L35_error)
                                  if (!__pyx_t_9) {
                                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                                  } else {
                                    __Pyx_INCREF(__pyx_t_5);
                                    __pyx_t_6 = __pyx_t_5;
                                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                                    goto __pyx_L47_bool_binop_done;
                                  }
                                  __pyx_t_5 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4905, __pyx_L35_error)
                                  __Pyx_GOTREF(__pyx_t_5);
                                  __pyx_t_6 = __pyx_t_5;
                                  __pyx_t_5 = 0;
                                  __pyx_L47_bool_binop_done:;
                                  __pyx_t_29 = __Pyx_PyObject_AsDouble(__pyx_t_6); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_29, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 4905, __pyx_L35_error)
                                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                                  __pyx_cur_scope->__pyx_v_keyboard = __pyx_t_29;

                                  /* "ws_package/controllers/activity_controller.py":4906
 *                                     if activity_level:
 *                                         keyboard = float(activity_level.get('keyboard', 0) or 0)
 *                                         mouse = float(activity_level.get('mouse', 0) or 0)             # <<<<<<<<<<<<<<
 *                                         average = float(activity_level.get('average', 0) or 0)
 *                                         if keyboard == 0.0 and mouse == 0.0 and average == 0.0:
*/
                                  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activity_level, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4906, __pyx_L35_error)
                                  __Pyx_GOTREF(__pyx_t_5);
                                  __pyx_t_24 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_mstate_global->__pyx_tuple[16], NULL); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 4906, __pyx_L35_error)
                                  __Pyx_GOTREF(__pyx_t_24);
                                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                                  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_24); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4906, __pyx_L35_error)
                                  if (!__pyx_t_9) {
                                    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                                  } else {
                                    __Pyx_INCREF(__pyx_t_24);
                                    __pyx_t_6 = __pyx_t_24;
                                    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                                    goto __pyx_L49_bool_binop_done;
                                  }
                                  __pyx_t_24 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 4906, __pyx_L35_error)
                                  __Pyx_GOTREF(__pyx_t_24);
                                  __pyx_t_6 = __pyx_t_24;
                                  __pyx_t_24 = 0;
                                  __pyx_L49_bool_binop_done:;
                                  __pyx_t_29 = __Pyx_PyObject_AsDouble(__pyx_t_6); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_29, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 4906, __pyx_L35_error)
                                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                                  __pyx_cur_scope->__pyx_v_mouse = __pyx_t_29;

                                  /* "ws_package/controllers/activity_controller.py":4907
 *                                         keyboard = float(activity_level.get('keyboard', 0) or 0)
 *                                         mouse = float(activity_level.get('mouse', 0) or 0)
 *                                         average = float(activity_level.get('average', 0) or 0)             # <<<<<<<<<<<<<<
 *                                         if keyboard == 0.0 and mouse == 0.0 and average == 0.0:
 *                                             is_sleep_interval = True
*/
                                  __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activity_level, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 4907, __pyx_L35_error)
                                  __Pyx_GOTREF(__pyx_t_24);
                                  __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_24, __pyx_mstate_global->__pyx_tuple[17], NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4907, __pyx_L35_error)
                                  __Pyx_GOTREF(__pyx_t_5);
                                  __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                                  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4907, __pyx_L35_error)
                                  if (!__pyx_t_9) {
                                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                                  } else {
                                    __Pyx_INCREF(__pyx_t_5);
                                    __pyx_t_6 = __pyx_t_5;
                                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                                    goto __pyx_L51_bool_binop_done;
                                  }
                                  __pyx_t_5 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4907, __pyx_L35_error)
                                  __Pyx_GOTREF(__pyx_t_5);
                                  __pyx_t_6 = __pyx_t_5;
                                  __pyx_t_5 = 0;
                                  __pyx_L51_bool_binop_done:;
                                  __pyx_t_29 = __Pyx_PyObject_AsDouble(__pyx_t_6); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_29, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 4907, __pyx_L35_error)
                                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                                  __pyx_cur_scope->__pyx_v_average = __pyx_t_29;

                                  /* "ws_package/controllers/activity_controller.py":4908
 *                                         mouse = float(activity_level.get('mouse', 0) or 0)
 *                                         average = float(activity_level.get('average', 0) or 0)
 *                                         if keyboard == 0.0 and mouse == 0.0 and average == 0.0:             # <<<<<<<<<<<<<<
 *                                             is_sleep_interval = True
 *                                             logger.info("[SleepInterval] Last interval is a sleep interval (%s hours) - skipping last interval creation to prevent sending wake-up time as 'stop'", gap_seconds/3600)
*/
                                  __pyx_t_28 = (__pyx_cur_scope->__pyx_v_keyboard == 0.0);
                                  if (__pyx_t_28) {
                                  } else {
                                    __pyx_t_9 = __pyx_t_28;
                                    goto __pyx_L54_bool_binop_done;
                                  }
                                  __pyx_t_28 = (__pyx_cur_scope->__pyx_v_mouse == 0.0);
                                  if (__pyx_t_28) {
                                  } else {
                                    __pyx_t_9 = __pyx_t_28;
                                    goto __pyx_L54_bool_binop_done;
                                  }
                                  __pyx_t_28 = (__pyx_cur_scope->__pyx_v_average == 0.0);
                                  __pyx_t_9 = __pyx_t_28;
                                  __pyx_L54_bool_binop_done:;
                                  if (__pyx_t_9) {

                                    /* "ws_package/controllers/activity_controller.py":4909
 *                                         average = float(activity_level.get('average', 0) or 0)
 *                                         if keyboard == 0.0 and mouse == 0.0 and average == 0.0:
 *                                             is_sleep_interval = True             # <<<<<<<<<<<<<<
 *                                             logger.info("[SleepInterval] Last interval is a sleep interval (%s hours) - skipping last interval creation to prevent sending wake-up time as 'stop'", gap_seconds/3600)
 *                 except Exception as e:
*/
                                    __pyx_cur_scope->__pyx_v_is_sleep_interval = 1;

                                    /* "ws_package/controllers/activity_controller.py":4910
 *                                         if keyboard == 0.0 and mouse == 0.0 and average == 0.0:
 *                                             is_sleep_interval = True
 *                                             logger.info("[SleepInterval] Last interval is a sleep interval (%s hours) - skipping last interval creation to prevent sending wake-up time as 'stop'", gap_seconds/3600)             # <<<<<<<<<<<<<<
 *                 except Exception as e:
 *                     logger.debug("Could not check if last interval is sleep interval: %s", e)
*/
                                    __pyx_t_5 = NULL;
                                    __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 4910, __pyx_L35_error)
                                    __Pyx_GOTREF(__pyx_t_24);
                                    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4910, __pyx_L35_error)
                                    __Pyx_GOTREF(__pyx_t_10);
                                    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                                    __pyx_t_24 = __Pyx_PyLong_TrueDivideObjC(__pyx_cur_scope->__pyx_v_gap_seconds, __pyx_mstate_global->__pyx_int_3600, 0xE10, 0, 0); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 4910, __pyx_L35_error)
                                    __Pyx_GOTREF(__pyx_t_24);
                                    __pyx_t_8 = 1;
                                    #if CYTHON_UNPACK_METHODS
                                    if (unlikely(PyMethod_Check(__pyx_t_10))) {
                                      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_10);
                                      assert(__pyx_t_5);
                                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
                                      __Pyx_INCREF(__pyx_t_5);
                                      __Pyx_INCREF(__pyx__function);
                                      __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
                                      __pyx_t_8 = 0;
                                    }
                                    #endif
                                    {
                                      PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_SleepInterval_Last_interval_is, __pyx_t_24};
                                      __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                                      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                                      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                                      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 4910, __pyx_L35_error)
                                      __Pyx_GOTREF(__pyx_t_6);
                                    }
                                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

                                    /* "ws_package/controllers/activity_controller.py":4908
 *                                         mouse = float(activity_level.get('mouse', 0) or 0)
 *                                         average = float(activity_level.get('average', 0) or 0)
 *                                         if keyboard == 0.0 and mouse == 0.0 and average == 0.0:             # <<<<<<<<<<<<<<
 *                                             is_sleep_interval = True
 *                                             logger.info("[SleepInterval] Last interval is a sleep interval (%s hours) - skipping last interval creation to prevent sending wake-up time as 'stop'", gap_seconds/3600)
*/
                                  }

                                  /* "ws_package/controllers/activity_controller.py":4904
 *                                 if gap_seconds >= 3600:  # 1 hour
 *                                     activity_level = last_interval_obj.activityLevel
 *                                     if activity_level:             # <<<<<<<<<<<<<<
 *                                         keyboard = float(activity_level.get('keyboard', 0) or 0)
 *                                         mouse = float(activity_level.get('mouse', 0) or 0)
*/
                                }

                                /* "ws_package/controllers/activity_controller.py":4902
 *                                 gap_seconds = (last_interval_obj.end_time - last_interval_obj.start_time).total_seconds()
 *                                 # Check if it's a long interval (>= 1 hour) with zero activity (sleep pattern)
 *                                 if gap_seconds >= 3600:  # 1 hour             # <<<<<<<<<<<<<<
 *                                     activity_level = last_interval_obj.activityLevel
 *                                     if activity_level:
*/
                              }

                              /* "ws_package/controllers/activity_controller.py":4899
 *                             last_interval_obj = result.scalar_one_or_none()
 * 
 *                             if last_interval_obj and last_interval_obj.end_time == last_interval_end:             # <<<<<<<<<<<<<<
 *                                 gap_seconds = (last_interval_obj.end_time - last_interval_obj.start_time).total_seconds()
 *                                 # Check if it's a long interval (>= 1 hour) with zero activity (sleep pattern)
*/
                            }

                            /* "ws_package/controllers/activity_controller.py":4888
 *                     # Get the actual last interval to check its duration and activity
 *                     with db_lock_manager.read_lock():
 *                         async with async_session() as session:             # <<<<<<<<<<<<<<
 * 
 *                             query = (
*/
                          }
                          __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                          __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                          __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                          goto __pyx_L40_try_end;
                          __pyx_L35_error:;
                          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                          __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                          __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                          __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                          __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                          /*except:*/ {
                            __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
                            if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_10, &__pyx_t_24) < 0) __PYX_ERR(0, 4888, __pyx_L37_except_error)
                            __Pyx_XGOTREF(__pyx_t_6);
                            __Pyx_XGOTREF(__pyx_t_10);
                            __Pyx_XGOTREF(__pyx_t_24);
                            __pyx_t_5 = PyTuple_Pack(3, __pyx_t_6, __pyx_t_10, __pyx_t_24); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4888, __pyx_L37_except_error)
                            __Pyx_GOTREF(__pyx_t_5);
                            __pyx_t_30 = __Pyx_PyObject_Call(__pyx_t_19, __pyx_t_5, NULL);
                            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                            if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 4888, __pyx_L37_except_error)
                            __Pyx_GOTREF(__pyx_t_30);
                            __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_30, &__pyx_r);
                            __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
                            if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                              __Pyx_GOTREF(__pyx_r);
                              __Pyx_XGIVEREF(__pyx_t_1);
                              __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                              __Pyx_XGIVEREF(__pyx_t_2);
                              __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                              __Pyx_XGIVEREF(__pyx_t_3);
                              __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                              __Pyx_XGIVEREF(__pyx_t_6);
                              __pyx_cur_scope->__pyx_t_3 = __pyx_t_6;
                              __Pyx_XGIVEREF(__pyx_t_10);
                              __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                              __Pyx_XGIVEREF(__pyx_t_12);
                              __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                              __Pyx_XGIVEREF(__pyx_t_13);
                              __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                              __Pyx_XGIVEREF(__pyx_t_14);
                              __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                              __Pyx_XGIVEREF(__pyx_t_15);
                              __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                              __Pyx_XGIVEREF(__pyx_t_16);
                              __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                              __Pyx_XGIVEREF(__pyx_t_17);
                              __pyx_cur_scope->__pyx_t_10 = __pyx_t_17;
                              __Pyx_XGIVEREF(__pyx_t_18);
                              __pyx_cur_scope->__pyx_t_11 = __pyx_t_18;
                              __Pyx_XGIVEREF(__pyx_t_19);
                              __pyx_cur_scope->__pyx_t_12 = __pyx_t_19;
                              __Pyx_XGIVEREF(__pyx_t_20);
                              __pyx_cur_scope->__pyx_t_13 = __pyx_t_20;
                              __Pyx_XGIVEREF(__pyx_t_21);
                              __pyx_cur_scope->__pyx_t_14 = __pyx_t_21;
                              __Pyx_XGIVEREF(__pyx_t_22);
                              __pyx_cur_scope->__pyx_t_15 = __pyx_t_22;
                              __Pyx_XGIVEREF(__pyx_t_24);
                              __pyx_cur_scope->__pyx_t_16 = __pyx_t_24;
                              __Pyx_XGIVEREF(__pyx_t_30);
                              __pyx_cur_scope->__pyx_t_17 = __pyx_t_30;
                              __Pyx_XGIVEREF(__pyx_r);
                              __Pyx_RefNannyFinishContext();
                              __Pyx_Coroutine_SwapException(__pyx_generator);
                              /* return from generator, awaiting value */
                              __pyx_generator->resume_label = 5;
                              return __pyx_r;
                              __pyx_L60_resume_from_await:;
                              __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                              __pyx_cur_scope->__pyx_t_0 = 0;
                              __Pyx_XGOTREF(__pyx_t_1);
                              __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                              __pyx_cur_scope->__pyx_t_1 = 0;
                              __Pyx_XGOTREF(__pyx_t_2);
                              __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                              __pyx_cur_scope->__pyx_t_2 = 0;
                              __Pyx_XGOTREF(__pyx_t_3);
                              __pyx_t_6 = __pyx_cur_scope->__pyx_t_3;
                              __pyx_cur_scope->__pyx_t_3 = 0;
                              __Pyx_XGOTREF(__pyx_t_6);
                              __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                              __pyx_cur_scope->__pyx_t_4 = 0;
                              __Pyx_XGOTREF(__pyx_t_10);
                              __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                              __pyx_cur_scope->__pyx_t_5 = 0;
                              __Pyx_XGOTREF(__pyx_t_12);
                              __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                              __pyx_cur_scope->__pyx_t_6 = 0;
                              __Pyx_XGOTREF(__pyx_t_13);
                              __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                              __pyx_cur_scope->__pyx_t_7 = 0;
                              __Pyx_XGOTREF(__pyx_t_14);
                              __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                              __pyx_cur_scope->__pyx_t_8 = 0;
                              __Pyx_XGOTREF(__pyx_t_15);
                              __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                              __pyx_cur_scope->__pyx_t_9 = 0;
                              __Pyx_XGOTREF(__pyx_t_16);
                              __pyx_t_17 = __pyx_cur_scope->__pyx_t_10;
                              __pyx_cur_scope->__pyx_t_10 = 0;
                              __Pyx_XGOTREF(__pyx_t_17);
                              __pyx_t_18 = __pyx_cur_scope->__pyx_t_11;
                              __pyx_cur_scope->__pyx_t_11 = 0;
                              __Pyx_XGOTREF(__pyx_t_18);
                              __pyx_t_19 = __pyx_cur_scope->__pyx_t_12;
                              __pyx_cur_scope->__pyx_t_12 = 0;
                              __Pyx_XGOTREF(__pyx_t_19);
                              __pyx_t_20 = __pyx_cur_scope->__pyx_t_13;
                              __pyx_cur_scope->__pyx_t_13 = 0;
                              __Pyx_XGOTREF(__pyx_t_20);
                              __pyx_t_21 = __pyx_cur_scope->__pyx_t_14;
                              __pyx_cur_scope->__pyx_t_14 = 0;
                              __Pyx_XGOTREF(__pyx_t_21);
                              __pyx_t_22 = __pyx_cur_scope->__pyx_t_15;
                              __pyx_cur_scope->__pyx_t_15 = 0;
                              __Pyx_XGOTREF(__pyx_t_22);
                              __pyx_t_24 = __pyx_cur_scope->__pyx_t_16;
                              __pyx_cur_scope->__pyx_t_16 = 0;
                              __Pyx_XGOTREF(__pyx_t_24);
                              __pyx_t_30 = __pyx_cur_scope->__pyx_t_17;
                              __pyx_cur_scope->__pyx_t_17 = 0;
                              __Pyx_XGOTREF(__pyx_t_30);
                              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4888, __pyx_L37_except_error)
                              __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
                            } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                              __Pyx_GOTREF(__pyx_r);
                              __pyx_t_5 = __pyx_r; __pyx_r = NULL;
                            } else {
                              __Pyx_XGOTREF(__pyx_r);
                              __PYX_ERR(0, 4888, __pyx_L37_except_error)
                            }
                            __pyx_t_30 = __pyx_t_5;
                            __pyx_t_5 = 0;
                            __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_30);
                            __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
                            if (__pyx_t_9 < (0)) __PYX_ERR(0, 4888, __pyx_L37_except_error)
                            __pyx_t_28 = (!__pyx_t_9);
                            if (unlikely(__pyx_t_28)) {
                              __Pyx_GIVEREF(__pyx_t_6);
                              __Pyx_GIVEREF(__pyx_t_10);
                              __Pyx_XGIVEREF(__pyx_t_24);
                              __Pyx_ErrRestoreWithState(__pyx_t_6, __pyx_t_10, __pyx_t_24);
                              __pyx_t_6 = 0;  __pyx_t_10 = 0;  __pyx_t_24 = 0; 
                              __PYX_ERR(0, 4888, __pyx_L37_except_error)
                            }
                            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                            __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                            goto __pyx_L36_exception_handled;
                          }
                          __pyx_L37_except_error:;
                          __Pyx_XGIVEREF(__pyx_t_20);
                          __Pyx_XGIVEREF(__pyx_t_21);
                          __Pyx_XGIVEREF(__pyx_t_22);
                          __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22);
                          goto __pyx_L24_error;
                          __pyx_L36_exception_handled:;
                          __Pyx_XGIVEREF(__pyx_t_20);
                          __Pyx_XGIVEREF(__pyx_t_21);
                          __Pyx_XGIVEREF(__pyx_t_22);
                          __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22);
                          __pyx_L40_try_end:;
                        }
                      }
                      /*finally:*/ {
                        /*normal exit:*/{
                          if (__pyx_t_19) {
                            __pyx_t_22 = __Pyx_PyObject_Call(__pyx_t_19, __pyx_mstate_global->__pyx_tuple[7], NULL);
                            __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                            if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 4888, __pyx_L24_error)
                            __Pyx_GOTREF(__pyx_t_22);
                            __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_22, &__pyx_r);
                            __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                            if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                              __Pyx_GOTREF(__pyx_r);
                              __Pyx_XGIVEREF(__pyx_t_1);
                              __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                              __Pyx_XGIVEREF(__pyx_t_2);
                              __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                              __Pyx_XGIVEREF(__pyx_t_3);
                              __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                              __Pyx_XGIVEREF(__pyx_t_12);
                              __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                              __Pyx_XGIVEREF(__pyx_t_13);
                              __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                              __Pyx_XGIVEREF(__pyx_t_14);
                              __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                              __Pyx_XGIVEREF(__pyx_t_15);
                              __pyx_cur_scope->__pyx_t_6 = __pyx_t_15;
                              __Pyx_XGIVEREF(__pyx_t_16);
                              __pyx_cur_scope->__pyx_t_7 = __pyx_t_16;
                              __Pyx_XGIVEREF(__pyx_t_17);
                              __pyx_cur_scope->__pyx_t_8 = __pyx_t_17;
                              __Pyx_XGIVEREF(__pyx_t_18);
                              __pyx_cur_scope->__pyx_t_9 = __pyx_t_18;
                              __Pyx_XGIVEREF(__pyx_t_19);
                              __pyx_cur_scope->__pyx_t_10 = __pyx_t_19;
                              __Pyx_XGIVEREF(__pyx_t_22);
                              __pyx_cur_scope->__pyx_t_11 = __pyx_t_22;
                              __Pyx_XGIVEREF(__pyx_r);
                              __Pyx_RefNannyFinishContext();
                              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                              /* return from generator, awaiting value */
                              __pyx_generator->resume_label = 6;
                              return __pyx_r;
                              __pyx_L61_resume_from_await:;
                              __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                              __pyx_cur_scope->__pyx_t_0 = 0;
                              __Pyx_XGOTREF(__pyx_t_1);
                              __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                              __pyx_cur_scope->__pyx_t_1 = 0;
                              __Pyx_XGOTREF(__pyx_t_2);
                              __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                              __pyx_cur_scope->__pyx_t_2 = 0;
                              __Pyx_XGOTREF(__pyx_t_3);
                              __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                              __pyx_cur_scope->__pyx_t_3 = 0;
                              __Pyx_XGOTREF(__pyx_t_12);
                              __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                              __pyx_cur_scope->__pyx_t_4 = 0;
                              __Pyx_XGOTREF(__pyx_t_13);
                              __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                              __pyx_cur_scope->__pyx_t_5 = 0;
                              __Pyx_XGOTREF(__pyx_t_14);
                              __pyx_t_15 = __pyx_cur_scope->__pyx_t_6;
                              __pyx_cur_scope->__pyx_t_6 = 0;
                              __Pyx_XGOTREF(__pyx_t_15);
                              __pyx_t_16 = __pyx_cur_scope->__pyx_t_7;
                              __pyx_cur_scope->__pyx_t_7 = 0;
                              __Pyx_XGOTREF(__pyx_t_16);
                              __pyx_t_17 = __pyx_cur_scope->__pyx_t_8;
                              __pyx_cur_scope->__pyx_t_8 = 0;
                              __Pyx_XGOTREF(__pyx_t_17);
                              __pyx_t_18 = __pyx_cur_scope->__pyx_t_9;
                              __pyx_cur_scope->__pyx_t_9 = 0;
                              __Pyx_XGOTREF(__pyx_t_18);
                              __pyx_t_19 = __pyx_cur_scope->__pyx_t_10;
                              __pyx_cur_scope->__pyx_t_10 = 0;
                              __Pyx_XGOTREF(__pyx_t_19);
                              __pyx_t_22 = __pyx_cur_scope->__pyx_t_11;
                              __pyx_cur_scope->__pyx_t_11 = 0;
                              __Pyx_XGOTREF(__pyx_t_22);
                              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 4888, __pyx_L24_error)
                              __pyx_t_24 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_24);
                            } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                              __Pyx_GOTREF(__pyx_r);
                              __pyx_t_24 = __pyx_r; __pyx_r = NULL;
                            } else {
                              __Pyx_XGOTREF(__pyx_r);
                              __PYX_ERR(0, 4888, __pyx_L24_error)
                            }
                            __pyx_t_22 = __pyx_t_24;
                            __pyx_t_24 = 0;
                            __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                          }
                          goto __pyx_L34;
                        }
                        __pyx_L34:;
                      }
                      goto __pyx_L62;
                      __pyx_L30_error:;
                      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                      goto __pyx_L24_error;
                      __pyx_L62:;
                    }

                    /* "ws_package/controllers/activity_controller.py":4887
 *                 try:
 *                     # Get the actual last interval to check its duration and activity
 *                     with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                         async with async_session() as session:
 * 
*/
                  }
                  __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                  __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                  __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                  goto __pyx_L29_try_end;
                  __pyx_L24_error:;
                  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                  __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                  __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                  __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                  /*except:*/ {
                    __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
                    if (__Pyx_GetException(&__pyx_t_24, &__pyx_t_10, &__pyx_t_6) < 0) __PYX_ERR(0, 4887, __pyx_L26_except_error)
                    __Pyx_XGOTREF(__pyx_t_24);
                    __Pyx_XGOTREF(__pyx_t_10);
                    __Pyx_XGOTREF(__pyx_t_6);
                    __pyx_t_5 = PyTuple_Pack(3, __pyx_t_24, __pyx_t_10, __pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4887, __pyx_L26_except_error)
                    __Pyx_GOTREF(__pyx_t_5);
                    __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_5, NULL);
                    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                    if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 4887, __pyx_L26_except_error)
                    __Pyx_GOTREF(__pyx_t_19);
                    __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_19);
                    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                    if (__pyx_t_28 < (0)) __PYX_ERR(0, 4887, __pyx_L26_except_error)
                    __pyx_t_9 = (!__pyx_t_28);
                    if (unlikely(__pyx_t_9)) {
                      __Pyx_GIVEREF(__pyx_t_24);
                      __Pyx_GIVEREF(__pyx_t_10);
                      __Pyx_XGIVEREF(__pyx_t_6);
                      __Pyx_ErrRestoreWithState(__pyx_t_24, __pyx_t_10, __pyx_t_6);
                      __pyx_t_24 = 0;  __pyx_t_10 = 0;  __pyx_t_6 = 0; 
                      __PYX_ERR(0, 4887, __pyx_L26_except_error)
                    }
                    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                    goto __pyx_L25_exception_handled;
                  }
                  __pyx_L26_except_error:;
                  __Pyx_XGIVEREF(__pyx_t_16);
                  __Pyx_XGIVEREF(__pyx_t_17);
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
                  goto __pyx_L14_error;
                  __pyx_L25_exception_handled:;
                  __Pyx_XGIVEREF(__pyx_t_16);
                  __Pyx_XGIVEREF(__pyx_t_17);
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
                  __pyx_L29_try_end:;
                }
              }
              /*finally:*/ {
                /*normal exit:*/{
                  if (__pyx_t_15) {
                    __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_mstate_global->__pyx_tuple[7], NULL);
                    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                    if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 4887, __pyx_L14_error)
                    __Pyx_GOTREF(__pyx_t_18);
                    __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                  }
                  goto __pyx_L23;
                }
                __pyx_L23:;
              }
              goto __pyx_L66;
              __pyx_L20_error:;
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              goto __pyx_L14_error;
              __pyx_L66:;
            }

            /* "ws_package/controllers/activity_controller.py":4885
 *             is_sleep_interval = False
 *             if last_interval_end:
 *                 try:             # <<<<<<<<<<<<<<
 *                     # Get the actual last interval to check its duration and activity
 *                     with db_lock_manager.read_lock():
*/
          }
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          goto __pyx_L19_try_end;
          __pyx_L14_error:;
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
          __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
          __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
          __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "ws_package/controllers/activity_controller.py":4911
 *                                             is_sleep_interval = True
 *                                             logger.info("[SleepInterval] Last interval is a sleep interval (%s hours) - skipping last interval creation to prevent sending wake-up time as 'stop'", gap_seconds/3600)
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.debug("Could not check if last interval is sleep interval: %s", e)
 *                     # Continue with normal flow if check fails (fail-safe)
*/
          __pyx_t_31 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
          if (__pyx_t_31) {
            __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_10, &__pyx_t_24) < 0) __PYX_ERR(0, 4911, __pyx_L16_except_error)
            __Pyx_XGOTREF(__pyx_t_6);
            __Pyx_XGOTREF(__pyx_t_10);
            __Pyx_XGOTREF(__pyx_t_24);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_GIVEREF(__pyx_t_10);
            __pyx_cur_scope->__pyx_v_e = __pyx_t_10;
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":4912
 *                                             logger.info("[SleepInterval] Last interval is a sleep interval (%s hours) - skipping last interval creation to prevent sending wake-up time as 'stop'", gap_seconds/3600)
 *                 except Exception as e:
 *                     logger.debug("Could not check if last interval is sleep interval: %s", e)             # <<<<<<<<<<<<<<
 *                     # Continue with normal flow if check fails (fail-safe)
 * 
*/
              __pyx_t_7 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4912, __pyx_L72_error)
              __Pyx_GOTREF(__pyx_t_4);
              __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 4912, __pyx_L72_error)
              __Pyx_GOTREF(__pyx_t_23);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_23))) {
                __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_23);
                assert(__pyx_t_7);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_23);
                __Pyx_INCREF(__pyx_t_7);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_23, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Could_not_check_if_last_interval, __pyx_cur_scope->__pyx_v_e};
                __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_23, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4912, __pyx_L72_error)
                __Pyx_GOTREF(__pyx_t_5);
              }
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            }

            /* "ws_package/controllers/activity_controller.py":4911
 *                                             is_sleep_interval = True
 *                                             logger.info("[SleepInterval] Last interval is a sleep interval (%s hours) - skipping last interval creation to prevent sending wake-up time as 'stop'", gap_seconds/3600)
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.debug("Could not check if last interval is sleep interval: %s", e)
 *                     # Continue with normal flow if check fails (fail-safe)
*/
            /*finally:*/ {
              /*normal exit:*/{
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                goto __pyx_L73;
              }
              __pyx_L72_error:;
              /*exception exit:*/{
                __Pyx_PyThreadState_assign
                __pyx_t_15 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0; __pyx_t_16 = 0; __pyx_t_19 = 0; __pyx_t_22 = 0;
                __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                 __Pyx_ExceptionSwap(&__pyx_t_16, &__pyx_t_19, &__pyx_t_22);
                if ( unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_18, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_18, &__pyx_t_17);
                __Pyx_XGOTREF(__pyx_t_15);
                __Pyx_XGOTREF(__pyx_t_18);
                __Pyx_XGOTREF(__pyx_t_17);
                __Pyx_XGOTREF(__pyx_t_16);
                __Pyx_XGOTREF(__pyx_t_19);
                __Pyx_XGOTREF(__pyx_t_22);
                __pyx_t_31 = __pyx_lineno; __pyx_t_32 = __pyx_clineno; __pyx_t_33 = __pyx_filename;
                {
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                }
                __Pyx_XGIVEREF(__pyx_t_16);
                __Pyx_XGIVEREF(__pyx_t_19);
                __Pyx_XGIVEREF(__pyx_t_22);
                __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_19, __pyx_t_22);
                __Pyx_XGIVEREF(__pyx_t_15);
                __Pyx_XGIVEREF(__pyx_t_18);
                __Pyx_XGIVEREF(__pyx_t_17);
                __Pyx_ErrRestore(__pyx_t_15, __pyx_t_18, __pyx_t_17);
                __pyx_t_15 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0; __pyx_t_16 = 0; __pyx_t_19 = 0; __pyx_t_22 = 0;
                __pyx_lineno = __pyx_t_31; __pyx_clineno = __pyx_t_32; __pyx_filename = __pyx_t_33;
                goto __pyx_L16_except_error;
              }
              __pyx_L73:;
            }
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
            goto __pyx_L15_exception_handled;
          }
          goto __pyx_L16_except_error;

          /* "ws_package/controllers/activity_controller.py":4885
 *             is_sleep_interval = False
 *             if last_interval_end:
 *                 try:             # <<<<<<<<<<<<<<
 *                     # Get the actual last interval to check its duration and activity
 *                     with db_lock_manager.read_lock():
*/
          __pyx_L16_except_error:;
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
          goto __pyx_L4_error;
          __pyx_L15_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
          __pyx_L19_try_end:;
        }

        /* "ws_package/controllers/activity_controller.py":4884
 *             # If so, don't create a new interval from sleep end to wake-up time
 *             is_sleep_interval = False
 *             if last_interval_end:             # <<<<<<<<<<<<<<
 *                 try:
 *                     # Get the actual last interval to check its duration and activity
*/
      }

      /* "ws_package/controllers/activity_controller.py":4915
 *                     # Continue with normal flow if check fails (fail-safe)
 * 
 *             end_date = (close_time or datetime.datetime.now()).replace(microsecond=0)             # <<<<<<<<<<<<<<
 * 
 *             # Ensure start_date always exists (prevents UnboundLocalError on sleep-gap skip)
*/
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_close_time); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4915, __pyx_L4_error)
      if (!__pyx_t_9) {
      } else {
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_close_time);
        __pyx_t_6 = __pyx_cur_scope->__pyx_v_close_time;
        goto __pyx_L78_bool_binop_done;
      }
      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 4915, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4915, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_23 = __pyx_t_4;
      __Pyx_INCREF(__pyx_t_23);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_23, NULL};
        __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4915, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
      }
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_6 = __pyx_t_5;
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_L78_bool_binop_done:;
      __pyx_t_10 = __pyx_t_6;
      __Pyx_INCREF(__pyx_t_10);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_10, NULL};
        __pyx_t_5 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4915, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_microsecond, __pyx_mstate_global->__pyx_int_0, __pyx_t_5, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 4915, __pyx_L4_error)
        __pyx_t_24 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_replace, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_5);
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 4915, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_24);
      }
      __Pyx_GIVEREF(__pyx_t_24);
      __pyx_cur_scope->__pyx_v_end_date = __pyx_t_24;
      __pyx_t_24 = 0;

      /* "ws_package/controllers/activity_controller.py":4918
 * 
 *             # Ensure start_date always exists (prevents UnboundLocalError on sleep-gap skip)
 *             start_date: datetime.datetime | None = None             # <<<<<<<<<<<<<<
 *             last_interval = None
 *             last_interval_id = None
*/
      __Pyx_INCREF(Py_None);
      __Pyx_GIVEREF(Py_None);
      __pyx_cur_scope->__pyx_v_start_date = Py_None;

      /* "ws_package/controllers/activity_controller.py":4919
 *             # Ensure start_date always exists (prevents UnboundLocalError on sleep-gap skip)
 *             start_date: datetime.datetime | None = None
 *             last_interval = None             # <<<<<<<<<<<<<<
 *             last_interval_id = None
 *             trimmed_partial_used = False
*/
      __Pyx_INCREF(Py_None);
      __Pyx_GIVEREF(Py_None);
      __pyx_cur_scope->__pyx_v_last_interval = Py_None;

      /* "ws_package/controllers/activity_controller.py":4920
 *             start_date: datetime.datetime | None = None
 *             last_interval = None
 *             last_interval_id = None             # <<<<<<<<<<<<<<
 *             trimmed_partial_used = False
 * 
*/
      __Pyx_INCREF(Py_None);
      __Pyx_GIVEREF(Py_None);
      __pyx_cur_scope->__pyx_v_last_interval_id = Py_None;

      /* "ws_package/controllers/activity_controller.py":4921
 *             last_interval = None
 *             last_interval_id = None
 *             trimmed_partial_used = False             # <<<<<<<<<<<<<<
 * 
 *             if trimmed_partial is not None:
*/
      __pyx_cur_scope->__pyx_v_trimmed_partial_used = 0;

      /* "ws_package/controllers/activity_controller.py":4923
 *             trimmed_partial_used = False
 * 
 *             if trimmed_partial is not None:             # <<<<<<<<<<<<<<
 *                 last_interval = trimmed_partial
 *                 last_interval_id = getattr(trimmed_partial, "id", None)
*/
      __pyx_t_9 = (__pyx_cur_scope->__pyx_v_trimmed_partial != Py_None);
      if (__pyx_t_9) {

        /* "ws_package/controllers/activity_controller.py":4924
 * 
 *             if trimmed_partial is not None:
 *                 last_interval = trimmed_partial             # <<<<<<<<<<<<<<
 *                 last_interval_id = getattr(trimmed_partial, "id", None)
 *                 time_diff_seconds = 0
*/
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_trimmed_partial);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_last_interval);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_last_interval, __pyx_cur_scope->__pyx_v_trimmed_partial);
        __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_trimmed_partial);

        /* "ws_package/controllers/activity_controller.py":4925
 *             if trimmed_partial is not None:
 *                 last_interval = trimmed_partial
 *                 last_interval_id = getattr(trimmed_partial, "id", None)             # <<<<<<<<<<<<<<
 *                 time_diff_seconds = 0
 *                 trimmed_partial_used = True
*/
        __pyx_t_24 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_trimmed_partial, __pyx_mstate_global->__pyx_n_u_id, Py_None); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 4925, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_24);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_last_interval_id);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_last_interval_id, __pyx_t_24);
        __Pyx_GIVEREF(__pyx_t_24);
        __pyx_t_24 = 0;

        /* "ws_package/controllers/activity_controller.py":4926
 *                 last_interval = trimmed_partial
 *                 last_interval_id = getattr(trimmed_partial, "id", None)
 *                 time_diff_seconds = 0             # <<<<<<<<<<<<<<
 *                 trimmed_partial_used = True
 *                 logger.info(
*/
        __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
        __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_0);
        __pyx_cur_scope->__pyx_v_time_diff_seconds = __pyx_mstate_global->__pyx_int_0;

        /* "ws_package/controllers/activity_controller.py":4927
 *                 last_interval_id = getattr(trimmed_partial, "id", None)
 *                 time_diff_seconds = 0
 *                 trimmed_partial_used = True             # <<<<<<<<<<<<<<
 *                 logger.info(
 *                     "Project switch close: using trimmed partial %s to %s (id=%s)  "
*/
        __pyx_cur_scope->__pyx_v_trimmed_partial_used = 1;

        /* "ws_package/controllers/activity_controller.py":4928
 *                 time_diff_seconds = 0
 *                 trimmed_partial_used = True
 *                 logger.info(             # <<<<<<<<<<<<<<
 *                     "Project switch close: using trimmed partial %s to %s (id=%s)  "
 *                     "not creating a duplicate closing interval",
*/
        __pyx_t_6 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4928, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4928, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":4931
 *                     "Project switch close: using trimmed partial %s to %s (id=%s)  "
 *                     "not creating a duplicate closing interval",
 *                     trimmed_partial.start_time,             # <<<<<<<<<<<<<<
 *                     trimmed_partial.end_time,
 *                     last_interval_id,
*/
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_trimmed_partial, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4931, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);

        /* "ws_package/controllers/activity_controller.py":4932
 *                     "not creating a duplicate closing interval",
 *                     trimmed_partial.start_time,
 *                     trimmed_partial.end_time,             # <<<<<<<<<<<<<<
 *                     last_interval_id,
 *                 )
*/
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_trimmed_partial, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4932, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);

        /* "ws_package/controllers/activity_controller.py":4933
 *                     trimmed_partial.start_time,
 *                     trimmed_partial.end_time,
 *                     last_interval_id,             # <<<<<<<<<<<<<<
 *                 )
 * 
*/
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_10);
          assert(__pyx_t_6);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[5] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Project_switch_close_using_trimm, __pyx_t_5, __pyx_t_4, __pyx_cur_scope->__pyx_v_last_interval_id};
          __pyx_t_24 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 4928, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_24);
        }
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;

        /* "ws_package/controllers/activity_controller.py":4923
 *             trimmed_partial_used = False
 * 
 *             if trimmed_partial is not None:             # <<<<<<<<<<<<<<
 *                 last_interval = trimmed_partial
 *                 last_interval_id = getattr(trimmed_partial, "id", None)
*/
        goto __pyx_L80;
      }

      /* "ws_package/controllers/activity_controller.py":4937
 * 
 *             # If last interval is a sleep interval, skip creating a new interval
 *             elif is_sleep_interval:             # <<<<<<<<<<<<<<
 *                 logger.info("[SleepInterval] Skipping last interval creation - last interval was a sleep interval ending at %s", last_interval_end)
 *                 last_interval = None
*/
      if (__pyx_cur_scope->__pyx_v_is_sleep_interval) {

        /* "ws_package/controllers/activity_controller.py":4938
 *             # If last interval is a sleep interval, skip creating a new interval
 *             elif is_sleep_interval:
 *                 logger.info("[SleepInterval] Skipping last interval creation - last interval was a sleep interval ending at %s", last_interval_end)             # <<<<<<<<<<<<<<
 *                 last_interval = None
 *                 last_interval_id = None
*/
        __pyx_t_10 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4938, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4938, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5);
          assert(__pyx_t_10);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_SleepInterval_Skipping_last_int, __pyx_cur_scope->__pyx_v_last_interval_end};
          __pyx_t_24 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 4938, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_24);
        }
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;

        /* "ws_package/controllers/activity_controller.py":4939
 *             elif is_sleep_interval:
 *                 logger.info("[SleepInterval] Skipping last interval creation - last interval was a sleep interval ending at %s", last_interval_end)
 *                 last_interval = None             # <<<<<<<<<<<<<<
 *                 last_interval_id = None
 *                 # Skip the interval creation logic and go directly to sending unsent intervals
*/
        __Pyx_INCREF(Py_None);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_last_interval);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_last_interval, Py_None);
        __Pyx_GIVEREF(Py_None);

        /* "ws_package/controllers/activity_controller.py":4940
 *                 logger.info("[SleepInterval] Skipping last interval creation - last interval was a sleep interval ending at %s", last_interval_end)
 *                 last_interval = None
 *                 last_interval_id = None             # <<<<<<<<<<<<<<
 *                 # Skip the interval creation logic and go directly to sending unsent intervals
 *                 # Set time_diff_seconds to 0 to skip the interval creation block
*/
        __Pyx_INCREF(Py_None);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_last_interval_id);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_last_interval_id, Py_None);
        __Pyx_GIVEREF(Py_None);

        /* "ws_package/controllers/activity_controller.py":4943
 *                 # Skip the interval creation logic and go directly to sending unsent intervals
 *                 # Set time_diff_seconds to 0 to skip the interval creation block
 *                 time_diff_seconds = 0             # <<<<<<<<<<<<<<
 *             else:
 *                 # Determine start_date for the last interval
*/
        __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
        __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_0);
        __pyx_cur_scope->__pyx_v_time_diff_seconds = __pyx_mstate_global->__pyx_int_0;

        /* "ws_package/controllers/activity_controller.py":4937
 * 
 *             # If last interval is a sleep interval, skip creating a new interval
 *             elif is_sleep_interval:             # <<<<<<<<<<<<<<
 *                 logger.info("[SleepInterval] Skipping last interval creation - last interval was a sleep interval ending at %s", last_interval_end)
 *                 last_interval = None
*/
        goto __pyx_L80;
      }

      /* "ws_package/controllers/activity_controller.py":4946
 *             else:
 *                 # Determine start_date for the last interval
 *                 if last_interval_end is None:             # <<<<<<<<<<<<<<
 *                     # No previous interval exists - use session start_date
 *                     if self.start_date:
*/
      /*else*/ {
        __pyx_t_9 = (__pyx_cur_scope->__pyx_v_last_interval_end == Py_None);
        if (__pyx_t_9) {

          /* "ws_package/controllers/activity_controller.py":4948
 *                 if last_interval_end is None:
 *                     # No previous interval exists - use session start_date
 *                     if self.start_date:             # <<<<<<<<<<<<<<
 *                         start_date = self.start_date
 *                         logger.info("No previous interval found, using session start_date: %s", start_date)
*/
          __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_start_date); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 4948, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_24);
          __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_24); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4948, __pyx_L4_error)
          __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
          if (__pyx_t_9) {

            /* "ws_package/controllers/activity_controller.py":4949
 *                     # No previous interval exists - use session start_date
 *                     if self.start_date:
 *                         start_date = self.start_date             # <<<<<<<<<<<<<<
 *                         logger.info("No previous interval found, using session start_date: %s", start_date)
 *                     else:
*/
            __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_start_date); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 4949, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_24);
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_start_date);
            __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_start_date, __pyx_t_24);
            __Pyx_GIVEREF(__pyx_t_24);
            __pyx_t_24 = 0;

            /* "ws_package/controllers/activity_controller.py":4950
 *                     if self.start_date:
 *                         start_date = self.start_date
 *                         logger.info("No previous interval found, using session start_date: %s", start_date)             # <<<<<<<<<<<<<<
 *                     else:
 *                         # Fallback: use current time minus 1 minute (shouldn't happen, but safety check)
*/
            __pyx_t_5 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4950, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4950, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_4))) {
              __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
              assert(__pyx_t_5);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
              __Pyx_INCREF(__pyx_t_5);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_No_previous_interval_found_using, __pyx_cur_scope->__pyx_v_start_date};
              __pyx_t_24 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 4950, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_24);
            }
            __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;

            /* "ws_package/controllers/activity_controller.py":4948
 *                 if last_interval_end is None:
 *                     # No previous interval exists - use session start_date
 *                     if self.start_date:             # <<<<<<<<<<<<<<
 *                         start_date = self.start_date
 *                         logger.info("No previous interval found, using session start_date: %s", start_date)
*/
            goto __pyx_L82;
          }

          /* "ws_package/controllers/activity_controller.py":4953
 *                     else:
 *                         # Fallback: use current time minus 1 minute (shouldn't happen, but safety check)
 *                         start_date = end_date - datetime.timedelta(minutes=1)             # <<<<<<<<<<<<<<
 *                         logger.warning("No previous interval and no session start_date - using fallback: %s", start_date)
 *                 else:
*/
          /*else*/ {
            __pyx_t_4 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4953, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_timedelta); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4953, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_10))) {
              __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10);
              assert(__pyx_t_4);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
              __Pyx_INCREF(__pyx_t_4);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_4, NULL};
              __pyx_t_5 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4953, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_5);
              if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_minutes, __pyx_mstate_global->__pyx_int_1, __pyx_t_5, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 4953, __pyx_L4_error)
              __pyx_t_24 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_5);
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 4953, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_24);
            }
            __pyx_t_10 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_end_date, __pyx_t_24); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4953, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_start_date);
            __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_start_date, __pyx_t_10);
            __Pyx_GIVEREF(__pyx_t_10);
            __pyx_t_10 = 0;

            /* "ws_package/controllers/activity_controller.py":4954
 *                         # Fallback: use current time minus 1 minute (shouldn't happen, but safety check)
 *                         start_date = end_date - datetime.timedelta(minutes=1)
 *                         logger.warning("No previous interval and no session start_date - using fallback: %s", start_date)             # <<<<<<<<<<<<<<
 *                 else:
 *                     # Use last interval's end_time as start_date for final interval
*/
            __pyx_t_24 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4954, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4954, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_4))) {
              __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_4);
              assert(__pyx_t_24);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
              __Pyx_INCREF(__pyx_t_24);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_24, __pyx_mstate_global->__pyx_kp_u_No_previous_interval_and_no_sess, __pyx_cur_scope->__pyx_v_start_date};
              __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4954, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_10);
            }
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          }
          __pyx_L82:;

          /* "ws_package/controllers/activity_controller.py":4946
 *             else:
 *                 # Determine start_date for the last interval
 *                 if last_interval_end is None:             # <<<<<<<<<<<<<<
 *                     # No previous interval exists - use session start_date
 *                     if self.start_date:
*/
          goto __pyx_L81;
        }

        /* "ws_package/controllers/activity_controller.py":4957
 *                 else:
 *                     # Use last interval's end_time as start_date for final interval
 *                     start_date = last_interval_end             # <<<<<<<<<<<<<<
 *                     logger.info("Using last interval end_time as start_date: %s", start_date)
 * 
*/
        /*else*/ {
          __Pyx_INCREF(__pyx_cur_scope->__pyx_v_last_interval_end);
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_start_date);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_last_interval_end);
          __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_last_interval_end);

          /* "ws_package/controllers/activity_controller.py":4958
 *                     # Use last interval's end_time as start_date for final interval
 *                     start_date = last_interval_end
 *                     logger.info("Using last interval end_time as start_date: %s", start_date)             # <<<<<<<<<<<<<<
 * 
 *                 # Ensure start_date is valid and before end_date
*/
          __pyx_t_4 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 4958, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_24);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4958, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_5))) {
            __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
            assert(__pyx_t_4);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Using_last_interval_end_time_as, __pyx_cur_scope->__pyx_v_start_date};
            __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4958, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_10);
          }
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        }
        __pyx_L81:;

        /* "ws_package/controllers/activity_controller.py":4961
 * 
 *                 # Ensure start_date is valid and before end_date
 *                 if not start_date:             # <<<<<<<<<<<<<<
 *                     logger.error("start_date is None - cannot create last interval. last_interval_end=%s, self.start_date=%s", last_interval_end, self.start_date)
 *                     return
*/
        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_start_date); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4961, __pyx_L4_error)
        __pyx_t_28 = (!__pyx_t_9);
        if (__pyx_t_28) {

          /* "ws_package/controllers/activity_controller.py":4962
 *                 # Ensure start_date is valid and before end_date
 *                 if not start_date:
 *                     logger.error("start_date is None - cannot create last interval. last_interval_end=%s, self.start_date=%s", last_interval_end, self.start_date)             # <<<<<<<<<<<<<<
 *                     return
 * 
*/
          __pyx_t_5 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4962, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 4962, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_24);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_start_date); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4962, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_24))) {
            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_24);
            assert(__pyx_t_5);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_24);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_24, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[4] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_start_date_is_None_cannot_create, __pyx_cur_scope->__pyx_v_last_interval_end, __pyx_t_4};
            __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_24, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
            if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4962, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_10);
          }
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

          /* "ws_package/controllers/activity_controller.py":4963
 *                 if not start_date:
 *                     logger.error("start_date is None - cannot create last interval. last_interval_end=%s, self.start_date=%s", last_interval_end, self.start_date)
 *                     return             # <<<<<<<<<<<<<<
 * 
 *                 # If start_date is equal to or after end_date, adjust start_date to be 1 second before end_date
*/
          __Pyx_XDECREF(__pyx_r);
          __pyx_r = Py_None; __Pyx_INCREF(Py_None);
          goto __pyx_L8_try_return;

          /* "ws_package/controllers/activity_controller.py":4961
 * 
 *                 # Ensure start_date is valid and before end_date
 *                 if not start_date:             # <<<<<<<<<<<<<<
 *                     logger.error("start_date is None - cannot create last interval. last_interval_end=%s, self.start_date=%s", last_interval_end, self.start_date)
 *                     return
*/
        }

        /* "ws_package/controllers/activity_controller.py":4966
 * 
 *                 # If start_date is equal to or after end_date, adjust start_date to be 1 second before end_date
 *                 if start_date >= end_date:             # <<<<<<<<<<<<<<
 *                     logger.warning("start_date (%s) >= end_date (%s) - adjusting start_date to be 1 second before end_date", start_date, end_date)
 *                     start_date = end_date - datetime.timedelta(seconds=1)
*/
        __pyx_t_10 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date, Py_GE); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4966, __pyx_L4_error)
        __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 4966, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (__pyx_t_28) {

          /* "ws_package/controllers/activity_controller.py":4967
 *                 # If start_date is equal to or after end_date, adjust start_date to be 1 second before end_date
 *                 if start_date >= end_date:
 *                     logger.warning("start_date (%s) >= end_date (%s) - adjusting start_date to be 1 second before end_date", start_date, end_date)             # <<<<<<<<<<<<<<
 *                     start_date = end_date - datetime.timedelta(seconds=1)
 * 
*/
          __pyx_t_24 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4967, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4967, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_5))) {
            __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_5);
            assert(__pyx_t_24);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_24);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[4] = {__pyx_t_24, __pyx_mstate_global->__pyx_kp_u_start_date_s_end_date_s_adjustin, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
            __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4967, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_10);
          }
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

          /* "ws_package/controllers/activity_controller.py":4968
 *                 if start_date >= end_date:
 *                     logger.warning("start_date (%s) >= end_date (%s) - adjusting start_date to be 1 second before end_date", start_date, end_date)
 *                     start_date = end_date - datetime.timedelta(seconds=1)             # <<<<<<<<<<<<<<
 * 
 *                 time_diff_seconds = (end_date - start_date).total_seconds()
*/
          __pyx_t_5 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 4968, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_24);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_timedelta); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4968, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_4))) {
            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
            assert(__pyx_t_5);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_5, NULL};
            __pyx_t_24 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 4968, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_24);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_seconds, __pyx_mstate_global->__pyx_int_1, __pyx_t_24, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 4968, __pyx_L4_error)
            __pyx_t_10 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_24);
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4968, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_10);
          }
          __pyx_t_4 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_end_date, __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4968, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_start_date);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_start_date, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_4);
          __pyx_t_4 = 0;

          /* "ws_package/controllers/activity_controller.py":4966
 * 
 *                 # If start_date is equal to or after end_date, adjust start_date to be 1 second before end_date
 *                 if start_date >= end_date:             # <<<<<<<<<<<<<<
 *                     logger.warning("start_date (%s) >= end_date (%s) - adjusting start_date to be 1 second before end_date", start_date, end_date)
 *                     start_date = end_date - datetime.timedelta(seconds=1)
*/
        }

        /* "ws_package/controllers/activity_controller.py":4970
 *                     start_date = end_date - datetime.timedelta(seconds=1)
 * 
 *                 time_diff_seconds = (end_date - start_date).total_seconds()             # <<<<<<<<<<<<<<
 *                 logger.info("Creating last interval: start_date=%s, end_date=%s, status=%s, time_diff=%s seconds", start_date, end_date, self.status, time_diff_seconds)
 * 
*/
        __pyx_t_24 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_end_date, __pyx_cur_scope->__pyx_v_start_date); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 4970, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_24);
        __pyx_t_10 = __pyx_t_24;
        __Pyx_INCREF(__pyx_t_10);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_10, NULL};
          __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_total_seconds, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4970, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_GIVEREF(__pyx_t_4);
        __pyx_cur_scope->__pyx_v_time_diff_seconds = __pyx_t_4;
        __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":4971
 * 
 *                 time_diff_seconds = (end_date - start_date).total_seconds()
 *                 logger.info("Creating last interval: start_date=%s, end_date=%s, status=%s, time_diff=%s seconds", start_date, end_date, self.status, time_diff_seconds)             # <<<<<<<<<<<<<<
 * 
 *             # Skip creating interval for very small gaps (<= 5 seconds) to avoid unnecessary small intervals
*/
        __pyx_t_24 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4971, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4971, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4971, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_5);
          assert(__pyx_t_24);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_24);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[6] = {__pyx_t_24, __pyx_mstate_global->__pyx_kp_u_Creating_last_interval_start_dat, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date, __pyx_t_10, __pyx_cur_scope->__pyx_v_time_diff_seconds};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (6-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4971, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      __pyx_L80:;

      /* "ws_package/controllers/activity_controller.py":4975
 *             # Skip creating interval for very small gaps (<= 5 seconds) to avoid unnecessary small intervals
 *             # These gaps are typically just processing time between last interval save and stop_event call
 *             if trimmed_partial_used:             # <<<<<<<<<<<<<<
 *                 pass
 *             elif time_diff_seconds > 0 and time_diff_seconds <= 10:
*/
      if (__pyx_cur_scope->__pyx_v_trimmed_partial_used) {
        goto __pyx_L85;
      }

      /* "ws_package/controllers/activity_controller.py":4977
 *             if trimmed_partial_used:
 *                 pass
 *             elif time_diff_seconds > 0 and time_diff_seconds <= 10:             # <<<<<<<<<<<<<<
 *                 logger.info("Skipping last interval creation for small gap (%ss) - this is normal processing time, not actual activity", time_diff_seconds)
 *                 last_interval = None
*/
      __pyx_t_4 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_time_diff_seconds, __pyx_mstate_global->__pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4977, __pyx_L4_error)
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4977, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_9) {
      } else {
        __pyx_t_28 = __pyx_t_9;
        goto __pyx_L86_bool_binop_done;
      }
      __pyx_t_4 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_time_diff_seconds, __pyx_mstate_global->__pyx_int_10, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4977, __pyx_L4_error)
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4977, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_28 = __pyx_t_9;
      __pyx_L86_bool_binop_done:;
      if (__pyx_t_28) {

        /* "ws_package/controllers/activity_controller.py":4978
 *                 pass
 *             elif time_diff_seconds > 0 and time_diff_seconds <= 10:
 *                 logger.info("Skipping last interval creation for small gap (%ss) - this is normal processing time, not actual activity", time_diff_seconds)             # <<<<<<<<<<<<<<
 *                 last_interval = None
 *                 last_interval_id = None
*/
        __pyx_t_5 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4978, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 4978, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_24);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_24))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_24);
          assert(__pyx_t_5);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_24);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_24, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Skipping_last_interval_creation, __pyx_cur_scope->__pyx_v_time_diff_seconds};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_24, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4978, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":4979
 *             elif time_diff_seconds > 0 and time_diff_seconds <= 10:
 *                 logger.info("Skipping last interval creation for small gap (%ss) - this is normal processing time, not actual activity", time_diff_seconds)
 *                 last_interval = None             # <<<<<<<<<<<<<<
 *                 last_interval_id = None
 *             # Always create the last interval if we have valid dates and gap is significant
*/
        __Pyx_INCREF(Py_None);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_last_interval);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_last_interval, Py_None);
        __Pyx_GIVEREF(Py_None);

        /* "ws_package/controllers/activity_controller.py":4980
 *                 logger.info("Skipping last interval creation for small gap (%ss) - this is normal processing time, not actual activity", time_diff_seconds)
 *                 last_interval = None
 *                 last_interval_id = None             # <<<<<<<<<<<<<<
 *             # Always create the last interval if we have valid dates and gap is significant
 *             elif not trimmed_partial_used and time_diff_seconds > 10:
*/
        __Pyx_INCREF(Py_None);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_last_interval_id);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_last_interval_id, Py_None);
        __Pyx_GIVEREF(Py_None);

        /* "ws_package/controllers/activity_controller.py":4977
 *             if trimmed_partial_used:
 *                 pass
 *             elif time_diff_seconds > 0 and time_diff_seconds <= 10:             # <<<<<<<<<<<<<<
 *                 logger.info("Skipping last interval creation for small gap (%ss) - this is normal processing time, not actual activity", time_diff_seconds)
 *                 last_interval = None
*/
        goto __pyx_L85;
      }

      /* "ws_package/controllers/activity_controller.py":4982
 *                 last_interval_id = None
 *             # Always create the last interval if we have valid dates and gap is significant
 *             elif not trimmed_partial_used and time_diff_seconds > 10:             # <<<<<<<<<<<<<<
 *                 logger.info("Save last activity interval to DB (from %s to %s - actual stop time, duration: %ss)", start_date, end_date, time_diff_seconds)
 *                 # CRITICAL FIX FOR WINDOWS: Check if break has started (break_id is set)
*/
      __pyx_t_9 = (!__pyx_cur_scope->__pyx_v_trimmed_partial_used);
      if (__pyx_t_9) {
      } else {
        __pyx_t_28 = __pyx_t_9;
        goto __pyx_L88_bool_binop_done;
      }
      __pyx_t_4 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_time_diff_seconds, __pyx_mstate_global->__pyx_int_10, Py_GT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4982, __pyx_L4_error)
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4982, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_28 = __pyx_t_9;
      __pyx_L88_bool_binop_done:;
      if (__pyx_t_28) {

        /* "ws_package/controllers/activity_controller.py":4983
 *             # Always create the last interval if we have valid dates and gap is significant
 *             elif not trimmed_partial_used and time_diff_seconds > 10:
 *                 logger.info("Save last activity interval to DB (from %s to %s - actual stop time, duration: %ss)", start_date, end_date, time_diff_seconds)             # <<<<<<<<<<<<<<
 *                 # CRITICAL FIX FOR WINDOWS: Check if break has started (break_id is set)
 *                 # If break has started and interval starts before break start, save the regular part with is_uploaded=False
*/
        __pyx_t_24 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 4983, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4983, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_10);
          assert(__pyx_t_24);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_24);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[5] = {__pyx_t_24, __pyx_mstate_global->__pyx_kp_u_Save_last_activity_interval_to_D, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date, __pyx_cur_scope->__pyx_v_time_diff_seconds};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4983, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":4987
 *                 # If break has started and interval starts before break start, save the regular part with is_uploaded=False
 *                 # so it can be uploaded by break_start_event
 *                 current_break_id = getattr(self, 'break_id', 0) or 0             # <<<<<<<<<<<<<<
 *                 break_start_time = getattr(self, 'break_start_time', None)
 * 
*/
        __pyx_t_10 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_break_id, __pyx_mstate_global->__pyx_int_0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4987, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 4987, __pyx_L4_error)
        if (!__pyx_t_28) {
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        } else {
          __Pyx_INCREF(__pyx_t_10);
          __pyx_t_4 = __pyx_t_10;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          goto __pyx_L90_bool_binop_done;
        }
        __pyx_t_10 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 4987, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_4 = __pyx_t_10;
        __pyx_t_10 = 0;
        __pyx_L90_bool_binop_done:;
        __Pyx_GIVEREF(__pyx_t_4);
        __pyx_cur_scope->__pyx_v_current_break_id = __pyx_t_4;
        __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":4988
 *                 # so it can be uploaded by break_start_event
 *                 current_break_id = getattr(self, 'break_id', 0) or 0
 *                 break_start_time = getattr(self, 'break_start_time', None)             # <<<<<<<<<<<<<<
 * 
 *                 # Determine if this interval should be marked as uploaded or not
*/
        __pyx_t_4 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_break_start_time, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4988, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        __pyx_cur_scope->__pyx_v_break_start_time = __pyx_t_4;
        __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":4991
 * 
 *                 # Determine if this interval should be marked as uploaded or not
 *                 should_upload = False             # <<<<<<<<<<<<<<
 *                 interval_end_date = end_date  # Default to original end_date
 * 
*/
        __pyx_cur_scope->__pyx_v_should_upload = 0;

        /* "ws_package/controllers/activity_controller.py":4992
 *                 # Determine if this interval should be marked as uploaded or not
 *                 should_upload = False
 *                 interval_end_date = end_date  # Default to original end_date             # <<<<<<<<<<<<<<
 * 
 *                 if current_break_id != 0 and break_start_time:
*/
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_end_date);
        __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_end_date);
        __pyx_cur_scope->__pyx_v_interval_end_date = __pyx_cur_scope->__pyx_v_end_date;

        /* "ws_package/controllers/activity_controller.py":4994
 *                 interval_end_date = end_date  # Default to original end_date
 * 
 *                 if current_break_id != 0 and break_start_time:             # <<<<<<<<<<<<<<
 *                     # Break has started - check if this interval overlaps with pre-break time
 *                     if start_date < break_start_time:
*/
        __pyx_t_9 = (__Pyx_PyLong_BoolNeObjC(__pyx_cur_scope->__pyx_v_current_break_id, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4994, __pyx_L4_error)
        if (__pyx_t_9) {
        } else {
          __pyx_t_28 = __pyx_t_9;
          goto __pyx_L93_bool_binop_done;
        }
        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_break_start_time); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 4994, __pyx_L4_error)
        __pyx_t_28 = __pyx_t_9;
        __pyx_L93_bool_binop_done:;
        if (__pyx_t_28) {

          /* "ws_package/controllers/activity_controller.py":4996
 *                 if current_break_id != 0 and break_start_time:
 *                     # Break has started - check if this interval overlaps with pre-break time
 *                     if start_date < break_start_time:             # <<<<<<<<<<<<<<
 *                         # Interval starts before break - save only the part before break start as regular interval
 *                         # This ensures the regular part is uploaded, and break part is handled separately
*/
          __pyx_t_4 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_break_start_time, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4996, __pyx_L4_error)
          __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 4996, __pyx_L4_error)
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (__pyx_t_28) {

            /* "ws_package/controllers/activity_controller.py":4999
 *                         # Interval starts before break - save only the part before break start as regular interval
 *                         # This ensures the regular part is uploaded, and break part is handled separately
 *                         interval_end_date = break_start_time             # <<<<<<<<<<<<<<
 *                         should_upload = True
 *                         logger.info("[Windows Break Fix] Break has started (break_id=%s, break_start_time=%s)", current_break_id, break_start_time)
*/
            __Pyx_INCREF(__pyx_cur_scope->__pyx_v_break_start_time);
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_interval_end_date);
            __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_interval_end_date, __pyx_cur_scope->__pyx_v_break_start_time);
            __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_break_start_time);

            /* "ws_package/controllers/activity_controller.py":5000
 *                         # This ensures the regular part is uploaded, and break part is handled separately
 *                         interval_end_date = break_start_time
 *                         should_upload = True             # <<<<<<<<<<<<<<
 *                         logger.info("[Windows Break Fix] Break has started (break_id=%s, break_start_time=%s)", current_break_id, break_start_time)
 *                         logger.info("[Windows Break Fix] Interval starts at %s (before break start) - saving regular part from %s to %s with is_uploaded=False", start_date, start_date, interval_end_date)
*/
            __pyx_cur_scope->__pyx_v_should_upload = 1;

            /* "ws_package/controllers/activity_controller.py":5001
 *                         interval_end_date = break_start_time
 *                         should_upload = True
 *                         logger.info("[Windows Break Fix] Break has started (break_id=%s, break_start_time=%s)", current_break_id, break_start_time)             # <<<<<<<<<<<<<<
 *                         logger.info("[Windows Break Fix] Interval starts at %s (before break start) - saving regular part from %s to %s with is_uploaded=False", start_date, start_date, interval_end_date)
 *                         logger.info("[Windows Break Fix] Part from %s to %s will be handled as break interval", break_start_time, end_date)
*/
            __pyx_t_10 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5001, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_24);
            __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5001, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_5))) {
              __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5);
              assert(__pyx_t_10);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
              __Pyx_INCREF(__pyx_t_10);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[4] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Windows_Break_Fix_Break_has_sta, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_cur_scope->__pyx_v_break_start_time};
              __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5001, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_4);
            }
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

            /* "ws_package/controllers/activity_controller.py":5002
 *                         should_upload = True
 *                         logger.info("[Windows Break Fix] Break has started (break_id=%s, break_start_time=%s)", current_break_id, break_start_time)
 *                         logger.info("[Windows Break Fix] Interval starts at %s (before break start) - saving regular part from %s to %s with is_uploaded=False", start_date, start_date, interval_end_date)             # <<<<<<<<<<<<<<
 *                         logger.info("[Windows Break Fix] Part from %s to %s will be handled as break interval", break_start_time, end_date)
 *                     elif end_date <= break_start_time:
*/
            __pyx_t_5 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5002, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5002, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_24);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_24))) {
              __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_24);
              assert(__pyx_t_5);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_24);
              __Pyx_INCREF(__pyx_t_5);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_24, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[5] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Windows_Break_Fix_Interval_star, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_interval_end_date};
              __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_24, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5002, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_4);
            }
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

            /* "ws_package/controllers/activity_controller.py":5003
 *                         logger.info("[Windows Break Fix] Break has started (break_id=%s, break_start_time=%s)", current_break_id, break_start_time)
 *                         logger.info("[Windows Break Fix] Interval starts at %s (before break start) - saving regular part from %s to %s with is_uploaded=False", start_date, start_date, interval_end_date)
 *                         logger.info("[Windows Break Fix] Part from %s to %s will be handled as break interval", break_start_time, end_date)             # <<<<<<<<<<<<<<
 *                     elif end_date <= break_start_time:
 *                         # Interval ends before or at break start - it's a regular interval that should be uploaded
*/
            __pyx_t_24 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5003, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5003, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_10))) {
              __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_10);
              assert(__pyx_t_24);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
              __Pyx_INCREF(__pyx_t_24);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[4] = {__pyx_t_24, __pyx_mstate_global->__pyx_kp_u_Windows_Break_Fix_Part_from_s_t, __pyx_cur_scope->__pyx_v_break_start_time, __pyx_cur_scope->__pyx_v_end_date};
              __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5003, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_4);
            }
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

            /* "ws_package/controllers/activity_controller.py":4996
 *                 if current_break_id != 0 and break_start_time:
 *                     # Break has started - check if this interval overlaps with pre-break time
 *                     if start_date < break_start_time:             # <<<<<<<<<<<<<<
 *                         # Interval starts before break - save only the part before break start as regular interval
 *                         # This ensures the regular part is uploaded, and break part is handled separately
*/
            goto __pyx_L95;
          }

          /* "ws_package/controllers/activity_controller.py":5004
 *                         logger.info("[Windows Break Fix] Interval starts at %s (before break start) - saving regular part from %s to %s with is_uploaded=False", start_date, start_date, interval_end_date)
 *                         logger.info("[Windows Break Fix] Part from %s to %s will be handled as break interval", break_start_time, end_date)
 *                     elif end_date <= break_start_time:             # <<<<<<<<<<<<<<
 *                         # Interval ends before or at break start - it's a regular interval that should be uploaded
 *                         should_upload = True
*/
          __pyx_t_4 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_end_date, __pyx_cur_scope->__pyx_v_break_start_time, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5004, __pyx_L4_error)
          __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5004, __pyx_L4_error)
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (__pyx_t_28) {

            /* "ws_package/controllers/activity_controller.py":5006
 *                     elif end_date <= break_start_time:
 *                         # Interval ends before or at break start - it's a regular interval that should be uploaded
 *                         should_upload = True             # <<<<<<<<<<<<<<
 *                         logger.info("[Windows Break Fix] Break has started (break_id=%s, break_start_time=%s)", current_break_id, break_start_time)
 *                         logger.info("[Windows Break Fix] Interval ends at %s (before break start) - saving with is_uploaded=False so it can be uploaded", end_date)
*/
            __pyx_cur_scope->__pyx_v_should_upload = 1;

            /* "ws_package/controllers/activity_controller.py":5007
 *                         # Interval ends before or at break start - it's a regular interval that should be uploaded
 *                         should_upload = True
 *                         logger.info("[Windows Break Fix] Break has started (break_id=%s, break_start_time=%s)", current_break_id, break_start_time)             # <<<<<<<<<<<<<<
 *                         logger.info("[Windows Break Fix] Interval ends at %s (before break start) - saving with is_uploaded=False so it can be uploaded", end_date)
 *                     else:
*/
            __pyx_t_10 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5007, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_24);
            __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5007, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_5))) {
              __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5);
              assert(__pyx_t_10);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
              __Pyx_INCREF(__pyx_t_10);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[4] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Windows_Break_Fix_Break_has_sta, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_cur_scope->__pyx_v_break_start_time};
              __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5007, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_4);
            }
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

            /* "ws_package/controllers/activity_controller.py":5008
 *                         should_upload = True
 *                         logger.info("[Windows Break Fix] Break has started (break_id=%s, break_start_time=%s)", current_break_id, break_start_time)
 *                         logger.info("[Windows Break Fix] Interval ends at %s (before break start) - saving with is_uploaded=False so it can be uploaded", end_date)             # <<<<<<<<<<<<<<
 *                     else:
 *                         # Interval starts at or after break start - it's a break interval (shouldn't happen in last_api_call, but handle it)
*/
            __pyx_t_5 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5008, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5008, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_24);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_24))) {
              __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_24);
              assert(__pyx_t_5);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_24);
              __Pyx_INCREF(__pyx_t_5);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_24, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Windows_Break_Fix_Interval_ends, __pyx_cur_scope->__pyx_v_end_date};
              __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_24, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5008, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_4);
            }
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

            /* "ws_package/controllers/activity_controller.py":5004
 *                         logger.info("[Windows Break Fix] Interval starts at %s (before break start) - saving regular part from %s to %s with is_uploaded=False", start_date, start_date, interval_end_date)
 *                         logger.info("[Windows Break Fix] Part from %s to %s will be handled as break interval", break_start_time, end_date)
 *                     elif end_date <= break_start_time:             # <<<<<<<<<<<<<<
 *                         # Interval ends before or at break start - it's a regular interval that should be uploaded
 *                         should_upload = True
*/
            goto __pyx_L95;
          }

          /* "ws_package/controllers/activity_controller.py":5011
 *                     else:
 *                         # Interval starts at or after break start - it's a break interval (shouldn't happen in last_api_call, but handle it)
 *                         logger.warning("[Windows Break Fix] Interval starts at %s >= break_start_time %s - this shouldn't happen in last_api_call", start_date, break_start_time)             # <<<<<<<<<<<<<<
 * 
 *                 # Get actual activity level/percentage for the interval being saved (start_date to interval_end_date)
*/
          /*else*/ {
            __pyx_t_24 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5011, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5011, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_10))) {
              __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_10);
              assert(__pyx_t_24);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
              __Pyx_INCREF(__pyx_t_24);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[4] = {__pyx_t_24, __pyx_mstate_global->__pyx_kp_u_Windows_Break_Fix_Interval_star_2, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_break_start_time};
              __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5011, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_4);
            }
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          }
          __pyx_L95:;

          /* "ws_package/controllers/activity_controller.py":4994
 *                 interval_end_date = end_date  # Default to original end_date
 * 
 *                 if current_break_id != 0 and break_start_time:             # <<<<<<<<<<<<<<
 *                     # Break has started - check if this interval overlaps with pre-break time
 *                     if start_date < break_start_time:
*/
        }

        /* "ws_package/controllers/activity_controller.py":5016
 *                 # This retrieves activity percentage from activity_percentage table or cache
 *                 # Must be done AFTER break handling to ensure we get activity for the correct time range
 *                 try:             # <<<<<<<<<<<<<<
 *                     activityLevel = await self.get_activity_level_from_db(start_date, interval_end_date)
 *                     logger.info("Retrieved activity level for last interval (%s to %s): mouse=%s, keyboard=%s, average=%s", start_date, interval_end_date, activityLevel.get('mouse', '0.0'), activityLevel.get('keyboard', '0.0'), activityLevel.get('average', '0.0'))
*/
        {
          __Pyx_ExceptionSave(&__pyx_t_14, &__pyx_t_13, &__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_12);
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":5017
 *                 # Must be done AFTER break handling to ensure we get activity for the correct time range
 *                 try:
 *                     activityLevel = await self.get_activity_level_from_db(start_date, interval_end_date)             # <<<<<<<<<<<<<<
 *                     logger.info("Retrieved activity level for last interval (%s to %s): mouse=%s, keyboard=%s, average=%s", start_date, interval_end_date, activityLevel.get('mouse', '0.0'), activityLevel.get('keyboard', '0.0'), activityLevel.get('average', '0.0'))
 *                 except Exception as e:
*/
            __pyx_t_10 = __pyx_cur_scope->__pyx_v_self;
            __Pyx_INCREF(__pyx_t_10);
            __pyx_t_8 = 0;
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_10, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_interval_end_date};
              __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_activity_level_from_db, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5017, __pyx_L96_error)
              __Pyx_GOTREF(__pyx_t_4);
            }
            __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (likely(__pyx_t_11 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_1);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
              __Pyx_XGIVEREF(__pyx_t_2);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
              __Pyx_XGIVEREF(__pyx_t_3);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
              __Pyx_XGIVEREF(__pyx_t_12);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
              __Pyx_XGIVEREF(__pyx_t_13);
              __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
              __Pyx_XGIVEREF(__pyx_t_14);
              __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 7;
              return __pyx_r;
              __pyx_L102_resume_from_await:;
              __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_1);
              __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_2);
              __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_3);
              __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_12);
              __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
              __pyx_cur_scope->__pyx_t_4 = 0;
              __Pyx_XGOTREF(__pyx_t_13);
              __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
              __pyx_cur_scope->__pyx_t_5 = 0;
              __Pyx_XGOTREF(__pyx_t_14);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5017, __pyx_L96_error)
              __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
            } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __pyx_t_4 = __pyx_r; __pyx_r = NULL;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 5017, __pyx_L96_error)
            }
            __Pyx_GIVEREF(__pyx_t_4);
            __pyx_cur_scope->__pyx_v_activityLevel = __pyx_t_4;
            __pyx_t_4 = 0;

            /* "ws_package/controllers/activity_controller.py":5018
 *                 try:
 *                     activityLevel = await self.get_activity_level_from_db(start_date, interval_end_date)
 *                     logger.info("Retrieved activity level for last interval (%s to %s): mouse=%s, keyboard=%s, average=%s", start_date, interval_end_date, activityLevel.get('mouse', '0.0'), activityLevel.get('keyboard', '0.0'), activityLevel.get('average', '0.0'))             # <<<<<<<<<<<<<<
 *                 except Exception as e:
 *                     logger.error("Error retrieving activity level for last interval: %s", e, exc_info=True)
*/
            __pyx_t_10 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5018, __pyx_L96_error)
            __Pyx_GOTREF(__pyx_t_24);
            __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5018, __pyx_L96_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
            __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activityLevel, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5018, __pyx_L96_error)
            __Pyx_GOTREF(__pyx_t_24);
            __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_24, __pyx_mstate_global->__pyx_tuple[25], NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5018, __pyx_L96_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
            __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activityLevel, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5018, __pyx_L96_error)
            __Pyx_GOTREF(__pyx_t_24);
            __pyx_t_23 = __Pyx_PyObject_Call(__pyx_t_24, __pyx_mstate_global->__pyx_tuple[24], NULL); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5018, __pyx_L96_error)
            __Pyx_GOTREF(__pyx_t_23);
            __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
            __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activityLevel, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5018, __pyx_L96_error)
            __Pyx_GOTREF(__pyx_t_24);
            __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_24, __pyx_mstate_global->__pyx_tuple[26], NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5018, __pyx_L96_error)
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_5))) {
              __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5);
              assert(__pyx_t_10);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
              __Pyx_INCREF(__pyx_t_10);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[7] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Retrieved_activity_level_for_las, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_interval_end_date, __pyx_t_6, __pyx_t_23, __pyx_t_7};
              __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (7-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5018, __pyx_L96_error)
              __Pyx_GOTREF(__pyx_t_4);
            }
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

            /* "ws_package/controllers/activity_controller.py":5016
 *                 # This retrieves activity percentage from activity_percentage table or cache
 *                 # Must be done AFTER break handling to ensure we get activity for the correct time range
 *                 try:             # <<<<<<<<<<<<<<
 *                     activityLevel = await self.get_activity_level_from_db(start_date, interval_end_date)
 *                     logger.info("Retrieved activity level for last interval (%s to %s): mouse=%s, keyboard=%s, average=%s", start_date, interval_end_date, activityLevel.get('mouse', '0.0'), activityLevel.get('keyboard', '0.0'), activityLevel.get('average', '0.0'))
*/
          }
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          goto __pyx_L101_try_end;
          __pyx_L96_error:;
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
          __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
          __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
          __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "ws_package/controllers/activity_controller.py":5019
 *                     activityLevel = await self.get_activity_level_from_db(start_date, interval_end_date)
 *                     logger.info("Retrieved activity level for last interval (%s to %s): mouse=%s, keyboard=%s, average=%s", start_date, interval_end_date, activityLevel.get('mouse', '0.0'), activityLevel.get('keyboard', '0.0'), activityLevel.get('average', '0.0'))
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Error retrieving activity level for last interval: %s", e, exc_info=True)
 *                     # Fallback to zeros if retrieval fails
*/
          __pyx_t_32 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
          if (__pyx_t_32) {
            __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_7) < 0) __PYX_ERR(0, 5019, __pyx_L98_except_error)
            __Pyx_XGOTREF(__pyx_t_4);
            __Pyx_XGOTREF(__pyx_t_5);
            __Pyx_XGOTREF(__pyx_t_7);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_GIVEREF(__pyx_t_5);
            __pyx_cur_scope->__pyx_v_e = __pyx_t_5;
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":5020
 *                     logger.info("Retrieved activity level for last interval (%s to %s): mouse=%s, keyboard=%s, average=%s", start_date, interval_end_date, activityLevel.get('mouse', '0.0'), activityLevel.get('keyboard', '0.0'), activityLevel.get('average', '0.0'))
 *                 except Exception as e:
 *                     logger.error("Error retrieving activity level for last interval: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 *                     # Fallback to zeros if retrieval fails
 *                     activityLevel = {'mouse': '0.0', 'average': '0.0', 'keyboard': '0.0'}
*/
              __pyx_t_6 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5020, __pyx_L108_error)
              __Pyx_GOTREF(__pyx_t_10);
              __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5020, __pyx_L108_error)
              __Pyx_GOTREF(__pyx_t_24);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_24))) {
                __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_24);
                assert(__pyx_t_6);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_24);
                __Pyx_INCREF(__pyx_t_6);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_24, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Error_retrieving_activity_level, __pyx_cur_scope->__pyx_v_e};
                __pyx_t_10 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5020, __pyx_L108_error)
                __Pyx_GOTREF(__pyx_t_10);
                if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_10, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 5020, __pyx_L108_error)
                __pyx_t_23 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_24, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_10);
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5020, __pyx_L108_error)
                __Pyx_GOTREF(__pyx_t_23);
              }
              __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

              /* "ws_package/controllers/activity_controller.py":5022
 *                     logger.error("Error retrieving activity level for last interval: %s", e, exc_info=True)
 *                     # Fallback to zeros if retrieval fails
 *                     activityLevel = {'mouse': '0.0', 'average': '0.0', 'keyboard': '0.0'}             # <<<<<<<<<<<<<<
 *                     logger.warning("Using fallback activity level (zeros) for last interval due to error")
 * 
*/
              __pyx_t_23 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5022, __pyx_L108_error)
              __Pyx_GOTREF(__pyx_t_23);
              if (PyDict_SetItem(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_mouse, __pyx_mstate_global->__pyx_kp_u_0_0) < (0)) __PYX_ERR(0, 5022, __pyx_L108_error)
              if (PyDict_SetItem(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_average, __pyx_mstate_global->__pyx_kp_u_0_0) < (0)) __PYX_ERR(0, 5022, __pyx_L108_error)
              if (PyDict_SetItem(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_keyboard, __pyx_mstate_global->__pyx_kp_u_0_0) < (0)) __PYX_ERR(0, 5022, __pyx_L108_error)
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_activityLevel);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_activityLevel, __pyx_t_23);
              __Pyx_GIVEREF(__pyx_t_23);
              __pyx_t_23 = 0;

              /* "ws_package/controllers/activity_controller.py":5023
 *                     # Fallback to zeros if retrieval fails
 *                     activityLevel = {'mouse': '0.0', 'average': '0.0', 'keyboard': '0.0'}
 *                     logger.warning("Using fallback activity level (zeros) for last interval due to error")             # <<<<<<<<<<<<<<
 * 
 *                 # Last API call is never a break, so break_id=0 (will be saved as is_break=0)
*/
              __pyx_t_24 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5023, __pyx_L108_error)
              __Pyx_GOTREF(__pyx_t_10);
              __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5023, __pyx_L108_error)
              __Pyx_GOTREF(__pyx_t_6);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_6))) {
                __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_6);
                assert(__pyx_t_24);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                __Pyx_INCREF(__pyx_t_24);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_24, __pyx_mstate_global->__pyx_kp_u_Using_fallback_activity_level_ze};
                __pyx_t_23 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5023, __pyx_L108_error)
                __Pyx_GOTREF(__pyx_t_23);
              }
              __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
            }

            /* "ws_package/controllers/activity_controller.py":5019
 *                     activityLevel = await self.get_activity_level_from_db(start_date, interval_end_date)
 *                     logger.info("Retrieved activity level for last interval (%s to %s): mouse=%s, keyboard=%s, average=%s", start_date, interval_end_date, activityLevel.get('mouse', '0.0'), activityLevel.get('keyboard', '0.0'), activityLevel.get('average', '0.0'))
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Error retrieving activity level for last interval: %s", e, exc_info=True)
 *                     # Fallback to zeros if retrieval fails
*/
            /*finally:*/ {
              /*normal exit:*/{
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                goto __pyx_L109;
              }
              __pyx_L108_error:;
              /*exception exit:*/{
                __Pyx_PyThreadState_assign
                __pyx_t_22 = 0; __pyx_t_19 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_15 = 0;
                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                 __Pyx_ExceptionSwap(&__pyx_t_17, &__pyx_t_18, &__pyx_t_15);
                if ( unlikely(__Pyx_GetException(&__pyx_t_22, &__pyx_t_19, &__pyx_t_16) < 0)) __Pyx_ErrFetch(&__pyx_t_22, &__pyx_t_19, &__pyx_t_16);
                __Pyx_XGOTREF(__pyx_t_22);
                __Pyx_XGOTREF(__pyx_t_19);
                __Pyx_XGOTREF(__pyx_t_16);
                __Pyx_XGOTREF(__pyx_t_17);
                __Pyx_XGOTREF(__pyx_t_18);
                __Pyx_XGOTREF(__pyx_t_15);
                __pyx_t_32 = __pyx_lineno; __pyx_t_31 = __pyx_clineno; __pyx_t_34 = __pyx_filename;
                {
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                }
                __Pyx_XGIVEREF(__pyx_t_17);
                __Pyx_XGIVEREF(__pyx_t_18);
                __Pyx_XGIVEREF(__pyx_t_15);
                __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_15);
                __Pyx_XGIVEREF(__pyx_t_22);
                __Pyx_XGIVEREF(__pyx_t_19);
                __Pyx_XGIVEREF(__pyx_t_16);
                __Pyx_ErrRestore(__pyx_t_22, __pyx_t_19, __pyx_t_16);
                __pyx_t_22 = 0; __pyx_t_19 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_15 = 0;
                __pyx_lineno = __pyx_t_32; __pyx_clineno = __pyx_t_31; __pyx_filename = __pyx_t_34;
                goto __pyx_L98_except_error;
              }
              __pyx_L109:;
            }
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            goto __pyx_L97_exception_handled;
          }
          goto __pyx_L98_except_error;

          /* "ws_package/controllers/activity_controller.py":5016
 *                 # This retrieves activity percentage from activity_percentage table or cache
 *                 # Must be done AFTER break handling to ensure we get activity for the correct time range
 *                 try:             # <<<<<<<<<<<<<<
 *                     activityLevel = await self.get_activity_level_from_db(start_date, interval_end_date)
 *                     logger.info("Retrieved activity level for last interval (%s to %s): mouse=%s, keyboard=%s, average=%s", start_date, interval_end_date, activityLevel.get('mouse', '0.0'), activityLevel.get('keyboard', '0.0'), activityLevel.get('average', '0.0'))
*/
          __pyx_L98_except_error:;
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12);
          goto __pyx_L4_error;
          __pyx_L97_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12);
          __pyx_L101_try_end:;
        }

        /* "ws_package/controllers/activity_controller.py":5027
 *                 # Last API call is never a break, so break_id=0 (will be saved as is_break=0)
 *                 # Set is_idle: True if popup is active AND interval has zero activity (both activityLevel and activity_percentage)
 *                 popup_is_active = self._idle_popup_active and self._idle_popup_triggered_at is not None             # <<<<<<<<<<<<<<
 *                 has_zero_activity = await self._has_zero_activity_for_interval(start_date, interval_end_date)
 *                 is_idle = popup_is_active and has_zero_activity
*/
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_active); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5027, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5027, __pyx_L4_error)
        if (__pyx_t_28) {
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        } else {
          __Pyx_INCREF(__pyx_t_5);
          __pyx_t_7 = __pyx_t_5;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          goto __pyx_L114_bool_binop_done;
        }
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_triggered_at); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5027, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_28 = (__pyx_t_5 != Py_None);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_t_28); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5027, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_7 = __pyx_t_5;
        __pyx_t_5 = 0;
        __pyx_L114_bool_binop_done:;
        __Pyx_GIVEREF(__pyx_t_7);
        __pyx_cur_scope->__pyx_v_popup_is_active = __pyx_t_7;
        __pyx_t_7 = 0;

        /* "ws_package/controllers/activity_controller.py":5028
 *                 # Set is_idle: True if popup is active AND interval has zero activity (both activityLevel and activity_percentage)
 *                 popup_is_active = self._idle_popup_active and self._idle_popup_triggered_at is not None
 *                 has_zero_activity = await self._has_zero_activity_for_interval(start_date, interval_end_date)             # <<<<<<<<<<<<<<
 *                 is_idle = popup_is_active and has_zero_activity
 * 
*/
        __pyx_t_5 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_5);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_interval_end_date};
          __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_has_zero_activity_for_interval, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5028, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7, &__pyx_r);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (likely(__pyx_t_11 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_1);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
          __Pyx_XGIVEREF(__pyx_t_2);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
          __Pyx_XGIVEREF(__pyx_t_3);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 8;
          return __pyx_r;
          __pyx_L116_resume_from_await:;
          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_1);
          __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_2);
          __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_3);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5028, __pyx_L4_error)
          __pyx_t_7 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_7);
        } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __pyx_t_7 = __pyx_r; __pyx_r = NULL;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 5028, __pyx_L4_error)
        }
        __Pyx_GIVEREF(__pyx_t_7);
        __pyx_cur_scope->__pyx_v_has_zero_activity = __pyx_t_7;
        __pyx_t_7 = 0;

        /* "ws_package/controllers/activity_controller.py":5029
 *                 popup_is_active = self._idle_popup_active and self._idle_popup_triggered_at is not None
 *                 has_zero_activity = await self._has_zero_activity_for_interval(start_date, interval_end_date)
 *                 is_idle = popup_is_active and has_zero_activity             # <<<<<<<<<<<<<<
 * 
 *                 # Ensure interval_end_date is valid (after start_date)
*/
        __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_popup_is_active); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5029, __pyx_L4_error)
        if (__pyx_t_28) {
        } else {
          __Pyx_INCREF(__pyx_cur_scope->__pyx_v_popup_is_active);
          __pyx_t_7 = __pyx_cur_scope->__pyx_v_popup_is_active;
          goto __pyx_L117_bool_binop_done;
        }
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_has_zero_activity);
        __pyx_t_7 = __pyx_cur_scope->__pyx_v_has_zero_activity;
        __pyx_L117_bool_binop_done:;
        __Pyx_GIVEREF(__pyx_t_7);
        __pyx_cur_scope->__pyx_v_is_idle = __pyx_t_7;
        __pyx_t_7 = 0;

        /* "ws_package/controllers/activity_controller.py":5032
 * 
 *                 # Ensure interval_end_date is valid (after start_date)
 *                 if interval_end_date <= start_date:             # <<<<<<<<<<<<<<
 *                     logger.warning("[Windows Break Fix] interval_end_date (%s) <= start_date (%s) - skipping interval creation", interval_end_date, start_date)
 *                     last_interval = None
*/
        __pyx_t_7 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_interval_end_date, __pyx_cur_scope->__pyx_v_start_date, Py_LE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5032, __pyx_L4_error)
        __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5032, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (__pyx_t_28) {

          /* "ws_package/controllers/activity_controller.py":5033
 *                 # Ensure interval_end_date is valid (after start_date)
 *                 if interval_end_date <= start_date:
 *                     logger.warning("[Windows Break Fix] interval_end_date (%s) <= start_date (%s) - skipping interval creation", interval_end_date, start_date)             # <<<<<<<<<<<<<<
 *                     last_interval = None
 *                     last_interval_id = None
*/
          __pyx_t_5 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5033, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5033, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_23);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_23))) {
            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_23);
            assert(__pyx_t_5);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_23);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_23, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[4] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Windows_Break_Fix_interval_end, __pyx_cur_scope->__pyx_v_interval_end_date, __pyx_cur_scope->__pyx_v_start_date};
            __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_23, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
            if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5033, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_7);
          }
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "ws_package/controllers/activity_controller.py":5034
 *                 if interval_end_date <= start_date:
 *                     logger.warning("[Windows Break Fix] interval_end_date (%s) <= start_date (%s) - skipping interval creation", interval_end_date, start_date)
 *                     last_interval = None             # <<<<<<<<<<<<<<
 *                     last_interval_id = None
 *                 elif should_upload:
*/
          __Pyx_INCREF(Py_None);
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_last_interval);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_last_interval, Py_None);
          __Pyx_GIVEREF(Py_None);

          /* "ws_package/controllers/activity_controller.py":5035
 *                     logger.warning("[Windows Break Fix] interval_end_date (%s) <= start_date (%s) - skipping interval creation", interval_end_date, start_date)
 *                     last_interval = None
 *                     last_interval_id = None             # <<<<<<<<<<<<<<
 *                 elif should_upload:
 *                     # Save with is_uploaded=False so it can be uploaded by break_start_event
*/
          __Pyx_INCREF(Py_None);
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_last_interval_id);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_last_interval_id, Py_None);
          __Pyx_GIVEREF(Py_None);

          /* "ws_package/controllers/activity_controller.py":5032
 * 
 *                 # Ensure interval_end_date is valid (after start_date)
 *                 if interval_end_date <= start_date:             # <<<<<<<<<<<<<<
 *                     logger.warning("[Windows Break Fix] interval_end_date (%s) <= start_date (%s) - skipping interval creation", interval_end_date, start_date)
 *                     last_interval = None
*/
          goto __pyx_L119;
        }

        /* "ws_package/controllers/activity_controller.py":5036
 *                     last_interval = None
 *                     last_interval_id = None
 *                 elif should_upload:             # <<<<<<<<<<<<<<
 *                     # Save with is_uploaded=False so it can be uploaded by break_start_event
 *                     last_interval = await self.activity_service.save_activity_log(activityLevel, start_date, interval_end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)
*/
        if (__pyx_cur_scope->__pyx_v_should_upload) {

          /* "ws_package/controllers/activity_controller.py":5038
 *                 elif should_upload:
 *                     # Save with is_uploaded=False so it can be uploaded by break_start_event
 *                     last_interval = await self.activity_service.save_activity_log(activityLevel, start_date, interval_end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)             # <<<<<<<<<<<<<<
 *                     logger.info("[Windows Break Fix] Last interval saved with is_uploaded=False (will be uploaded by break_start_event): start_time=%s, end_time=%s, is_break=0", last_interval.start_time if last_interval else 'None', last_interval.end_time if last_interval else 'None')
 *                 elif not keep_idle_time:
*/
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5038, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_23 = __pyx_t_5;
          __Pyx_INCREF(__pyx_t_23);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5038, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_6 = __Pyx_PyLong_AddObjC(__pyx_t_4, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5038, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_24 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_24);
          __pyx_t_8 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_24, NULL};
            __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_today_weekday, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
            if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5038, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_4);
          }
          __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_has_on_demand); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5038, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_24);
          __pyx_t_8 = 0;
          {
            PyObject *__pyx_callargs[6 + ((CYTHON_VECTORCALL) ? 3 : 0)] = {__pyx_t_23, __pyx_cur_scope->__pyx_v_activityLevel, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_interval_end_date, __pyx_t_6, __pyx_t_4};
            __pyx_t_10 = __Pyx_MakeVectorcallBuilderKwds(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5038, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_10);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_break_id, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_t_10, __pyx_callargs+6, 0) < (0)) __PYX_ERR(0, 5038, __pyx_L4_error)
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_is_idle, __pyx_cur_scope->__pyx_v_is_idle, __pyx_t_10, __pyx_callargs+6, 1) < (0)) __PYX_ERR(0, 5038, __pyx_L4_error)
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_has_on_demand_screenshot, __pyx_t_24, __pyx_t_10, __pyx_callargs+6, 2) < (0)) __PYX_ERR(0, 5038, __pyx_L4_error)
            __pyx_t_7 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_save_activity_log, __pyx_callargs+__pyx_t_8, (6-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_10);
            __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5038, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_7);
          }
          __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7, &__pyx_r);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (likely(__pyx_t_11 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_1);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
            __Pyx_XGIVEREF(__pyx_t_2);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
            __Pyx_XGIVEREF(__pyx_t_3);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 9;
            return __pyx_r;
            __pyx_L120_resume_from_await:;
            __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_1);
            __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_2);
            __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_3);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5038, __pyx_L4_error)
            __pyx_t_7 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_7);
          } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __pyx_t_7 = __pyx_r; __pyx_r = NULL;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 5038, __pyx_L4_error)
          }
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_last_interval);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_last_interval, __pyx_t_7);
          __Pyx_GIVEREF(__pyx_t_7);
          __pyx_t_7 = 0;

          /* "ws_package/controllers/activity_controller.py":5039
 *                     # Save with is_uploaded=False so it can be uploaded by break_start_event
 *                     last_interval = await self.activity_service.save_activity_log(activityLevel, start_date, interval_end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)
 *                     logger.info("[Windows Break Fix] Last interval saved with is_uploaded=False (will be uploaded by break_start_event): start_time=%s, end_time=%s, is_break=0", last_interval.start_time if last_interval else 'None', last_interval.end_time if last_interval else 'None')             # <<<<<<<<<<<<<<
 *                 elif not keep_idle_time:
 *                     # CRITICAL FIX: If keep_idle_time is False, we must discard this interval (not upload it)
*/
          __pyx_t_5 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5039, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5039, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_24);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5039, __pyx_L4_error)
          if (__pyx_t_28) {
            __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5039, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_10 = __pyx_t_4;
            __pyx_t_4 = 0;
          } else {
            __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_None);
            __pyx_t_10 = __pyx_mstate_global->__pyx_n_u_None;
          }
          __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5039, __pyx_L4_error)
          if (__pyx_t_28) {
            __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5039, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_4 = __pyx_t_6;
            __pyx_t_6 = 0;
          } else {
            __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_None);
            __pyx_t_4 = __pyx_mstate_global->__pyx_n_u_None;
          }
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_24))) {
            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_24);
            assert(__pyx_t_5);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_24);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_24, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[4] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Windows_Break_Fix_Last_interval, __pyx_t_10, __pyx_t_4};
            __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_24, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
            if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5039, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_7);
          }
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "ws_package/controllers/activity_controller.py":5036
 *                     last_interval = None
 *                     last_interval_id = None
 *                 elif should_upload:             # <<<<<<<<<<<<<<
 *                     # Save with is_uploaded=False so it can be uploaded by break_start_event
 *                     last_interval = await self.activity_service.save_activity_log(activityLevel, start_date, interval_end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)
*/
          goto __pyx_L119;
        }

        /* "ws_package/controllers/activity_controller.py":5040
 *                     last_interval = await self.activity_service.save_activity_log(activityLevel, start_date, interval_end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)
 *                     logger.info("[Windows Break Fix] Last interval saved with is_uploaded=False (will be uploaded by break_start_event): start_time=%s, end_time=%s, is_break=0", last_interval.start_time if last_interval else 'None', last_interval.end_time if last_interval else 'None')
 *                 elif not keep_idle_time:             # <<<<<<<<<<<<<<
 *                     # CRITICAL FIX: If keep_idle_time is False, we must discard this interval (not upload it)
 *                     # We save it with is_uploaded=True so it's marked as handled/uploaded locally, but won't be sent to server
*/
        __pyx_t_28 = (!__pyx_cur_scope->__pyx_v_keep_idle_time);
        if (__pyx_t_28) {

          /* "ws_package/controllers/activity_controller.py":5044
 *                     # We save it with is_uploaded=True so it's marked as handled/uploaded locally, but won't be sent to server
 *                     # We also ensure it's NOT added to the manual send list later
 *                     last_interval = await self.activity_service.save_first_activity_log(activityLevel, start_date, interval_end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)             # <<<<<<<<<<<<<<
 *                     logger.info("Last interval saved with is_uploaded=True (keep_idle_time=False): start_time=%s, end_time=%s, is_break=0", last_interval.start_time if last_interval else 'None', last_interval.end_time if last_interval else 'None')
 *                 else:
*/
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5044, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_24 = __pyx_t_4;
          __Pyx_INCREF(__pyx_t_24);
          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5044, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_5 = __Pyx_PyLong_AddObjC(__pyx_t_10, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5044, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_6 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_6);
          __pyx_t_8 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
            __pyx_t_10 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_today_weekday, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5044, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_10);
          }
          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_has_on_demand); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5044, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_8 = 0;
          {
            PyObject *__pyx_callargs[6 + ((CYTHON_VECTORCALL) ? 3 : 0)] = {__pyx_t_24, __pyx_cur_scope->__pyx_v_activityLevel, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_interval_end_date, __pyx_t_5, __pyx_t_10};
            __pyx_t_23 = __Pyx_MakeVectorcallBuilderKwds(3); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5044, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_23);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_break_id, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_t_23, __pyx_callargs+6, 0) < (0)) __PYX_ERR(0, 5044, __pyx_L4_error)
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_is_idle, __pyx_cur_scope->__pyx_v_is_idle, __pyx_t_23, __pyx_callargs+6, 1) < (0)) __PYX_ERR(0, 5044, __pyx_L4_error)
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_has_on_demand_screenshot, __pyx_t_6, __pyx_t_23, __pyx_callargs+6, 2) < (0)) __PYX_ERR(0, 5044, __pyx_L4_error)
            __pyx_t_7 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_save_first_activity_log, __pyx_callargs+__pyx_t_8, (6-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_23);
            __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5044, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_7);
          }
          __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7, &__pyx_r);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (likely(__pyx_t_11 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_1);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
            __Pyx_XGIVEREF(__pyx_t_2);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
            __Pyx_XGIVEREF(__pyx_t_3);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 10;
            return __pyx_r;
            __pyx_L121_resume_from_await:;
            __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_1);
            __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_2);
            __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_3);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5044, __pyx_L4_error)
            __pyx_t_7 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_7);
          } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __pyx_t_7 = __pyx_r; __pyx_r = NULL;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 5044, __pyx_L4_error)
          }
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_last_interval);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_last_interval, __pyx_t_7);
          __Pyx_GIVEREF(__pyx_t_7);
          __pyx_t_7 = 0;

          /* "ws_package/controllers/activity_controller.py":5045
 *                     # We also ensure it's NOT added to the manual send list later
 *                     last_interval = await self.activity_service.save_first_activity_log(activityLevel, start_date, interval_end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)
 *                     logger.info("Last interval saved with is_uploaded=True (keep_idle_time=False): start_time=%s, end_time=%s, is_break=0", last_interval.start_time if last_interval else 'None', last_interval.end_time if last_interval else 'None')             # <<<<<<<<<<<<<<
 *                 else:
 *                     # Normal case (stop button click): save with is_uploaded=False so the last partial interval
*/
          __pyx_t_4 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5045, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_23);
          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5045, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
          __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5045, __pyx_L4_error)
          if (__pyx_t_28) {
            __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5045, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_23 = __pyx_t_10;
            __pyx_t_10 = 0;
          } else {
            __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_None);
            __pyx_t_23 = __pyx_mstate_global->__pyx_n_u_None;
          }
          __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5045, __pyx_L4_error)
          if (__pyx_t_28) {
            __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5045, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_10 = __pyx_t_5;
            __pyx_t_5 = 0;
          } else {
            __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_None);
            __pyx_t_10 = __pyx_mstate_global->__pyx_n_u_None;
          }
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_6))) {
            __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
            assert(__pyx_t_4);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[4] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Last_interval_saved_with_is_uplo, __pyx_t_23, __pyx_t_10};
            __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5045, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_7);
          }
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "ws_package/controllers/activity_controller.py":5040
 *                     last_interval = await self.activity_service.save_activity_log(activityLevel, start_date, interval_end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)
 *                     logger.info("[Windows Break Fix] Last interval saved with is_uploaded=False (will be uploaded by break_start_event): start_time=%s, end_time=%s, is_break=0", last_interval.start_time if last_interval else 'None', last_interval.end_time if last_interval else 'None')
 *                 elif not keep_idle_time:             # <<<<<<<<<<<<<<
 *                     # CRITICAL FIX: If keep_idle_time is False, we must discard this interval (not upload it)
 *                     # We save it with is_uploaded=True so it's marked as handled/uploaded locally, but won't be sent to server
*/
          goto __pyx_L119;
        }

        /* "ws_package/controllers/activity_controller.py":5050
 *                     # (e.g. 10:50-10:54) is included in the unsent query and synced to the server.
 *                     # Do NOT use save_first_activity_log here - that marks is_uploaded=True and the interval would never be sent.
 *                     last_interval = await self.activity_service.save_activity_log(activityLevel, start_date, interval_end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)             # <<<<<<<<<<<<<<
 *                     logger.info("Last interval saved with is_uploaded=False (stop button - will be synced): start_time=%s, end_time=%s, is_break=0", last_interval.start_time if last_interval else 'None', last_interval.end_time if last_interval else 'None')
 *                 logger.info("Last interval saved: start_time=%s, end_time=%s, is_uploaded=%s, counter=%s", last_interval.start_time if last_interval else 'None', last_interval.end_time if last_interval else 'None', last_interval.is_uploaded if last_interval else 'None', last_interval.counter if last_interval else 'None')
*/
        /*else*/ {
          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5050, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_6 = __pyx_t_10;
          __Pyx_INCREF(__pyx_t_6);
          __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5050, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_23);
          __pyx_t_4 = __Pyx_PyLong_AddObjC(__pyx_t_23, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5050, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
          __pyx_t_5 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_5);
          __pyx_t_8 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
            __pyx_t_23 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_today_weekday, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5050, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_23);
          }
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_has_on_demand); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5050, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_8 = 0;
          {
            PyObject *__pyx_callargs[6 + ((CYTHON_VECTORCALL) ? 3 : 0)] = {__pyx_t_6, __pyx_cur_scope->__pyx_v_activityLevel, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_interval_end_date, __pyx_t_4, __pyx_t_23};
            __pyx_t_24 = __Pyx_MakeVectorcallBuilderKwds(3); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5050, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_24);
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_break_id, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_t_24, __pyx_callargs+6, 0) < (0)) __PYX_ERR(0, 5050, __pyx_L4_error)
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_is_idle, __pyx_cur_scope->__pyx_v_is_idle, __pyx_t_24, __pyx_callargs+6, 1) < (0)) __PYX_ERR(0, 5050, __pyx_L4_error)
            if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_has_on_demand_screenshot, __pyx_t_5, __pyx_t_24, __pyx_callargs+6, 2) < (0)) __PYX_ERR(0, 5050, __pyx_L4_error)
            __pyx_t_7 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_save_activity_log, __pyx_callargs+__pyx_t_8, (6-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_24);
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5050, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_7);
          }
          __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7, &__pyx_r);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (likely(__pyx_t_11 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_1);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
            __Pyx_XGIVEREF(__pyx_t_2);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
            __Pyx_XGIVEREF(__pyx_t_3);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 11;
            return __pyx_r;
            __pyx_L122_resume_from_await:;
            __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_1);
            __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_2);
            __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_3);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5050, __pyx_L4_error)
            __pyx_t_7 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_7);
          } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __pyx_t_7 = __pyx_r; __pyx_r = NULL;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 5050, __pyx_L4_error)
          }
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_last_interval);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_last_interval, __pyx_t_7);
          __Pyx_GIVEREF(__pyx_t_7);
          __pyx_t_7 = 0;

          /* "ws_package/controllers/activity_controller.py":5051
 *                     # Do NOT use save_first_activity_log here - that marks is_uploaded=True and the interval would never be sent.
 *                     last_interval = await self.activity_service.save_activity_log(activityLevel, start_date, interval_end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)
 *                     logger.info("Last interval saved with is_uploaded=False (stop button - will be synced): start_time=%s, end_time=%s, is_break=0", last_interval.start_time if last_interval else 'None', last_interval.end_time if last_interval else 'None')             # <<<<<<<<<<<<<<
 *                 logger.info("Last interval saved: start_time=%s, end_time=%s, is_uploaded=%s, counter=%s", last_interval.start_time if last_interval else 'None', last_interval.end_time if last_interval else 'None', last_interval.is_uploaded if last_interval else 'None', last_interval.counter if last_interval else 'None')
 *                 self.has_on_demand = False
*/
          __pyx_t_10 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5051, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_24);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5051, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
          __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5051, __pyx_L4_error)
          if (__pyx_t_28) {
            __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5051, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_23);
            __pyx_t_24 = __pyx_t_23;
            __pyx_t_23 = 0;
          } else {
            __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_None);
            __pyx_t_24 = __pyx_mstate_global->__pyx_n_u_None;
          }
          __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5051, __pyx_L4_error)
          if (__pyx_t_28) {
            __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5051, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_23 = __pyx_t_4;
            __pyx_t_4 = 0;
          } else {
            __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_None);
            __pyx_t_23 = __pyx_mstate_global->__pyx_n_u_None;
          }
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_5))) {
            __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5);
            assert(__pyx_t_10);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[4] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Last_interval_saved_with_is_uplo_2, __pyx_t_24, __pyx_t_23};
            __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5051, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_7);
          }
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        }
        __pyx_L119:;

        /* "ws_package/controllers/activity_controller.py":5052
 *                     last_interval = await self.activity_service.save_activity_log(activityLevel, start_date, interval_end_date, self.last_count+1, self.get_today_weekday(), break_id=current_break_id, is_idle=is_idle, has_on_demand_screenshot=self.has_on_demand)
 *                     logger.info("Last interval saved with is_uploaded=False (stop button - will be synced): start_time=%s, end_time=%s, is_break=0", last_interval.start_time if last_interval else 'None', last_interval.end_time if last_interval else 'None')
 *                 logger.info("Last interval saved: start_time=%s, end_time=%s, is_uploaded=%s, counter=%s", last_interval.start_time if last_interval else 'None', last_interval.end_time if last_interval else 'None', last_interval.is_uploaded if last_interval else 'None', last_interval.counter if last_interval else 'None')             # <<<<<<<<<<<<<<
 *                 self.has_on_demand = False
 *                 # Flush immediately to ensure last interval is committed before sending to server
*/
        __pyx_t_5 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5052, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_23);
        __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5052, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_24);
        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
        __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5052, __pyx_L4_error)
        if (__pyx_t_28) {
          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5052, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_23 = __pyx_t_10;
          __pyx_t_10 = 0;
        } else {
          __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_None);
          __pyx_t_23 = __pyx_mstate_global->__pyx_n_u_None;
        }
        __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5052, __pyx_L4_error)
        if (__pyx_t_28) {
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5052, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_10 = __pyx_t_4;
          __pyx_t_4 = 0;
        } else {
          __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_None);
          __pyx_t_10 = __pyx_mstate_global->__pyx_n_u_None;
        }
        __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5052, __pyx_L4_error)
        if (__pyx_t_28) {
          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_is_uploaded); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5052, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_4 = __pyx_t_6;
          __pyx_t_6 = 0;
        } else {
          __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_None);
          __pyx_t_4 = __pyx_mstate_global->__pyx_n_u_None;
        }
        __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5052, __pyx_L4_error)
        if (__pyx_t_28) {
          __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5052, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_25);
          __pyx_t_6 = __pyx_t_25;
          __pyx_t_25 = 0;
        } else {
          __Pyx_INCREF(__pyx_mstate_global->__pyx_n_u_None);
          __pyx_t_6 = __pyx_mstate_global->__pyx_n_u_None;
        }
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_24))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_24);
          assert(__pyx_t_5);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_24);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_24, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[6] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Last_interval_saved_start_time_s, __pyx_t_23, __pyx_t_10, __pyx_t_4, __pyx_t_6};
          __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_24, __pyx_callargs+__pyx_t_8, (6-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5052, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "ws_package/controllers/activity_controller.py":5053
 *                     logger.info("Last interval saved with is_uploaded=False (stop button - will be synced): start_time=%s, end_time=%s, is_break=0", last_interval.start_time if last_interval else 'None', last_interval.end_time if last_interval else 'None')
 *                 logger.info("Last interval saved: start_time=%s, end_time=%s, is_uploaded=%s, counter=%s", last_interval.start_time if last_interval else 'None', last_interval.end_time if last_interval else 'None', last_interval.is_uploaded if last_interval else 'None', last_interval.counter if last_interval else 'None')
 *                 self.has_on_demand = False             # <<<<<<<<<<<<<<
 *                 # Flush immediately to ensure last interval is committed before sending to server
 *                 try:
*/
        if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_has_on_demand, Py_False) < (0)) __PYX_ERR(0, 5053, __pyx_L4_error)

        /* "ws_package/controllers/activity_controller.py":5055
 *                 self.has_on_demand = False
 *                 # Flush immediately to ensure last interval is committed before sending to server
 *                 try:             # <<<<<<<<<<<<<<
 *                     # Check if there are items in the queue before processing
 *                     activity_queue_size = db_write_queue.get_queue_size(WriteOperationType.ACTIVITY_INTERVAL)
*/
        {
          __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_14);
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":5057
 *                 try:
 *                     # Check if there are items in the queue before processing
 *                     activity_queue_size = db_write_queue.get_queue_size(WriteOperationType.ACTIVITY_INTERVAL)             # <<<<<<<<<<<<<<
 *                     total_queue_size = db_write_queue.get_total_queue_size()
 *                     logger.info("Queue status before flush: ACTIVITY_INTERVAL=%s, Total=%s", activity_queue_size, total_queue_size)
*/
            __pyx_t_24 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_db_write_queue); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5057, __pyx_L123_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_get_queue_size); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5057, __pyx_L123_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_WriteOperationType); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5057, __pyx_L123_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_ACTIVITY_INTERVAL); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5057, __pyx_L123_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_4))) {
              __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_4);
              assert(__pyx_t_24);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
              __Pyx_INCREF(__pyx_t_24);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_24, __pyx_t_10};
              __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5057, __pyx_L123_error)
              __Pyx_GOTREF(__pyx_t_7);
            }
            __Pyx_GIVEREF(__pyx_t_7);
            __pyx_cur_scope->__pyx_v_activity_queue_size = __pyx_t_7;
            __pyx_t_7 = 0;

            /* "ws_package/controllers/activity_controller.py":5058
 *                     # Check if there are items in the queue before processing
 *                     activity_queue_size = db_write_queue.get_queue_size(WriteOperationType.ACTIVITY_INTERVAL)
 *                     total_queue_size = db_write_queue.get_total_queue_size()             # <<<<<<<<<<<<<<
 *                     logger.info("Queue status before flush: ACTIVITY_INTERVAL=%s, Total=%s", activity_queue_size, total_queue_size)
 * 
*/
            __pyx_t_4 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_db_write_queue); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5058, __pyx_L123_error)
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_get_total_queue_size); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5058, __pyx_L123_error)
            __Pyx_GOTREF(__pyx_t_24);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_24))) {
              __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_24);
              assert(__pyx_t_4);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_24);
              __Pyx_INCREF(__pyx_t_4);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_24, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
              __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_24, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
              if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5058, __pyx_L123_error)
              __Pyx_GOTREF(__pyx_t_7);
            }
            __Pyx_GIVEREF(__pyx_t_7);
            __pyx_cur_scope->__pyx_v_total_queue_size = __pyx_t_7;
            __pyx_t_7 = 0;

            /* "ws_package/controllers/activity_controller.py":5059
 *                     activity_queue_size = db_write_queue.get_queue_size(WriteOperationType.ACTIVITY_INTERVAL)
 *                     total_queue_size = db_write_queue.get_total_queue_size()
 *                     logger.info("Queue status before flush: ACTIVITY_INTERVAL=%s, Total=%s", activity_queue_size, total_queue_size)             # <<<<<<<<<<<<<<
 * 
 *                     if total_queue_size > 0:
*/
            __pyx_t_24 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5059, __pyx_L123_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5059, __pyx_L123_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_10))) {
              __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_10);
              assert(__pyx_t_24);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
              __Pyx_INCREF(__pyx_t_24);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[4] = {__pyx_t_24, __pyx_mstate_global->__pyx_kp_u_Queue_status_before_flush_ACTIVI, __pyx_cur_scope->__pyx_v_activity_queue_size, __pyx_cur_scope->__pyx_v_total_queue_size};
              __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5059, __pyx_L123_error)
              __Pyx_GOTREF(__pyx_t_7);
            }
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

            /* "ws_package/controllers/activity_controller.py":5061
 *                     logger.info("Queue status before flush: ACTIVITY_INTERVAL=%s, Total=%s", activity_queue_size, total_queue_size)
 * 
 *                     if total_queue_size > 0:             # <<<<<<<<<<<<<<
 *                         logger.info("Processing %s pending queue items immediately...", total_queue_size)
 *                         processed_count = await db_writer_service.process_immediately()
*/
            __pyx_t_7 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_total_queue_size, __pyx_mstate_global->__pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5061, __pyx_L123_error)
            __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5061, __pyx_L123_error)
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            if (__pyx_t_28) {

              /* "ws_package/controllers/activity_controller.py":5062
 * 
 *                     if total_queue_size > 0:
 *                         logger.info("Processing %s pending queue items immediately...", total_queue_size)             # <<<<<<<<<<<<<<
 *                         processed_count = await db_writer_service.process_immediately()
 *                         logger.info("Flushed %s queued database writes - last interval committed to database", processed_count)
*/
              __pyx_t_10 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5062, __pyx_L123_error)
              __Pyx_GOTREF(__pyx_t_24);
              __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5062, __pyx_L123_error)
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_4))) {
                __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
                assert(__pyx_t_10);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                __Pyx_INCREF(__pyx_t_10);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Processing_s_pending_queue_items, __pyx_cur_scope->__pyx_v_total_queue_size};
                __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5062, __pyx_L123_error)
                __Pyx_GOTREF(__pyx_t_7);
              }
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

              /* "ws_package/controllers/activity_controller.py":5063
 *                     if total_queue_size > 0:
 *                         logger.info("Processing %s pending queue items immediately...", total_queue_size)
 *                         processed_count = await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 *                         logger.info("Flushed %s queued database writes - last interval committed to database", processed_count)
 *                     else:
*/
              __pyx_t_4 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5063, __pyx_L123_error)
              __Pyx_GOTREF(__pyx_t_10);
              __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5063, __pyx_L123_error)
              __Pyx_GOTREF(__pyx_t_24);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_24))) {
                __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_24);
                assert(__pyx_t_4);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_24);
                __Pyx_INCREF(__pyx_t_4);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_24, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
                __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_24, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5063, __pyx_L123_error)
                __Pyx_GOTREF(__pyx_t_7);
              }
              __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7, &__pyx_r);
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_XGIVEREF(__pyx_t_1);
                __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                __Pyx_XGIVEREF(__pyx_t_2);
                __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                __Pyx_XGIVEREF(__pyx_t_3);
                __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                __Pyx_XGIVEREF(__pyx_t_12);
                __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                __Pyx_XGIVEREF(__pyx_t_13);
                __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                __Pyx_XGIVEREF(__pyx_t_14);
                __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                __Pyx_XGIVEREF(__pyx_r);
                __Pyx_RefNannyFinishContext();
                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                /* return from generator, awaiting value */
                __pyx_generator->resume_label = 12;
                return __pyx_r;
                __pyx_L130_resume_from_await:;
                __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                __pyx_cur_scope->__pyx_t_0 = 0;
                __Pyx_XGOTREF(__pyx_t_1);
                __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                __pyx_cur_scope->__pyx_t_1 = 0;
                __Pyx_XGOTREF(__pyx_t_2);
                __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                __pyx_cur_scope->__pyx_t_2 = 0;
                __Pyx_XGOTREF(__pyx_t_3);
                __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                __pyx_cur_scope->__pyx_t_3 = 0;
                __Pyx_XGOTREF(__pyx_t_12);
                __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                __pyx_cur_scope->__pyx_t_4 = 0;
                __Pyx_XGOTREF(__pyx_t_13);
                __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                __pyx_cur_scope->__pyx_t_5 = 0;
                __Pyx_XGOTREF(__pyx_t_14);
                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5063, __pyx_L123_error)
                __pyx_t_7 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_7);
              } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                __Pyx_GOTREF(__pyx_r);
                __pyx_t_7 = __pyx_r; __pyx_r = NULL;
              } else {
                __Pyx_XGOTREF(__pyx_r);
                __PYX_ERR(0, 5063, __pyx_L123_error)
              }
              __Pyx_GIVEREF(__pyx_t_7);
              __pyx_cur_scope->__pyx_v_processed_count = __pyx_t_7;
              __pyx_t_7 = 0;

              /* "ws_package/controllers/activity_controller.py":5064
 *                         logger.info("Processing %s pending queue items immediately...", total_queue_size)
 *                         processed_count = await db_writer_service.process_immediately()
 *                         logger.info("Flushed %s queued database writes - last interval committed to database", processed_count)             # <<<<<<<<<<<<<<
 *                     else:
 *                         logger.info("No items in queue - last interval already processed")
*/
              __pyx_t_24 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5064, __pyx_L123_error)
              __Pyx_GOTREF(__pyx_t_4);
              __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5064, __pyx_L123_error)
              __Pyx_GOTREF(__pyx_t_10);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_10))) {
                __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_10);
                assert(__pyx_t_24);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
                __Pyx_INCREF(__pyx_t_24);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_24, __pyx_mstate_global->__pyx_kp_u_Flushed_s_queued_database_writes_2, __pyx_cur_scope->__pyx_v_processed_count};
                __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5064, __pyx_L123_error)
                __Pyx_GOTREF(__pyx_t_7);
              }
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

              /* "ws_package/controllers/activity_controller.py":5061
 *                     logger.info("Queue status before flush: ACTIVITY_INTERVAL=%s, Total=%s", activity_queue_size, total_queue_size)
 * 
 *                     if total_queue_size > 0:             # <<<<<<<<<<<<<<
 *                         logger.info("Processing %s pending queue items immediately...", total_queue_size)
 *                         processed_count = await db_writer_service.process_immediately()
*/
              goto __pyx_L129;
            }

            /* "ws_package/controllers/activity_controller.py":5066
 *                         logger.info("Flushed %s queued database writes - last interval committed to database", processed_count)
 *                     else:
 *                         logger.info("No items in queue - last interval already processed")             # <<<<<<<<<<<<<<
 * 
 *                     # Give database time to ensure commit is fully visible (1 second delay)
*/
            /*else*/ {
              __pyx_t_10 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5066, __pyx_L123_error)
              __Pyx_GOTREF(__pyx_t_24);
              __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5066, __pyx_L123_error)
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_4))) {
                __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_4);
                assert(__pyx_t_10);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                __Pyx_INCREF(__pyx_t_10);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_No_items_in_queue_last_interval};
                __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5066, __pyx_L123_error)
                __Pyx_GOTREF(__pyx_t_7);
              }
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            }
            __pyx_L129:;

            /* "ws_package/controllers/activity_controller.py":5069
 * 
 *                     # Give database time to ensure commit is fully visible (1 second delay)
 *                     logger.info("Waiting 1 second for database commit to be fully visible...")             # <<<<<<<<<<<<<<
 *                     await asyncio.sleep(1.0)
 * 
*/
            __pyx_t_4 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5069, __pyx_L123_error)
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5069, __pyx_L123_error)
            __Pyx_GOTREF(__pyx_t_24);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_24))) {
              __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_24);
              assert(__pyx_t_4);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_24);
              __Pyx_INCREF(__pyx_t_4);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_24, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Waiting_1_second_for_database_co};
              __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_24, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
              if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5069, __pyx_L123_error)
              __Pyx_GOTREF(__pyx_t_7);
            }
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

            /* "ws_package/controllers/activity_controller.py":5070
 *                     # Give database time to ensure commit is fully visible (1 second delay)
 *                     logger.info("Waiting 1 second for database commit to be fully visible...")
 *                     await asyncio.sleep(1.0)             # <<<<<<<<<<<<<<
 * 
 *                     # CRITICAL: Verify the last interval is actually in the database with an ID
*/
            __pyx_t_24 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5070, __pyx_L123_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5070, __pyx_L123_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_10))) {
              __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_10);
              assert(__pyx_t_24);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
              __Pyx_INCREF(__pyx_t_24);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_24, __pyx_mstate_global->__pyx_float_1_0};
              __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5070, __pyx_L123_error)
              __Pyx_GOTREF(__pyx_t_7);
            }
            __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7, &__pyx_r);
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            if (likely(__pyx_t_11 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_1);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
              __Pyx_XGIVEREF(__pyx_t_2);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
              __Pyx_XGIVEREF(__pyx_t_3);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
              __Pyx_XGIVEREF(__pyx_t_12);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
              __Pyx_XGIVEREF(__pyx_t_13);
              __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
              __Pyx_XGIVEREF(__pyx_t_14);
              __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 13;
              return __pyx_r;
              __pyx_L131_resume_from_await:;
              __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_1);
              __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_2);
              __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_3);
              __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_12);
              __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
              __pyx_cur_scope->__pyx_t_4 = 0;
              __Pyx_XGOTREF(__pyx_t_13);
              __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
              __pyx_cur_scope->__pyx_t_5 = 0;
              __Pyx_XGOTREF(__pyx_t_14);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5070, __pyx_L123_error)
            } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_DECREF(__pyx_r); __pyx_r = 0;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 5070, __pyx_L123_error)
            }

            /* "ws_package/controllers/activity_controller.py":5074
 *                     # CRITICAL: Verify the last interval is actually in the database with an ID
 *                     # This ensures the interval exists before we try to query for it
 *                     if last_interval:             # <<<<<<<<<<<<<<
 *                         max_verification_retries = 5
 *                         verification_delay = 0.5
*/
            __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5074, __pyx_L123_error)
            if (__pyx_t_28) {

              /* "ws_package/controllers/activity_controller.py":5075
 *                     # This ensures the interval exists before we try to query for it
 *                     if last_interval:
 *                         max_verification_retries = 5             # <<<<<<<<<<<<<<
 *                         verification_delay = 0.5
 *                         interval_verified = False
*/
              __Pyx_INCREF(__pyx_mstate_global->__pyx_int_5);
              __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_5);
              __pyx_cur_scope->__pyx_v_max_verification_retries = __pyx_mstate_global->__pyx_int_5;

              /* "ws_package/controllers/activity_controller.py":5076
 *                     if last_interval:
 *                         max_verification_retries = 5
 *                         verification_delay = 0.5             # <<<<<<<<<<<<<<
 *                         interval_verified = False
 * 
*/
              __pyx_cur_scope->__pyx_v_verification_delay = 0.5;

              /* "ws_package/controllers/activity_controller.py":5077
 *                         max_verification_retries = 5
 *                         verification_delay = 0.5
 *                         interval_verified = False             # <<<<<<<<<<<<<<
 * 
 *                         for verify_attempt in range(max_verification_retries):
*/
              __pyx_cur_scope->__pyx_v_interval_verified = 0;

              /* "ws_package/controllers/activity_controller.py":5079
 *                         interval_verified = False
 * 
 *                         for verify_attempt in range(max_verification_retries):             # <<<<<<<<<<<<<<
 *                             try:
 *                                 with db_lock_manager.read_lock():
*/
              __pyx_t_10 = NULL;
              __pyx_t_8 = 1;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_cur_scope->__pyx_v_max_verification_retries};
                __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)(&PyRange_Type), __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5079, __pyx_L123_error)
                __Pyx_GOTREF(__pyx_t_7);
              }
              __pyx_t_10 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5079, __pyx_L123_error)
              __Pyx_GOTREF(__pyx_t_10);
              __pyx_t_35 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_10); if (unlikely(!__pyx_t_35)) __PYX_ERR(0, 5079, __pyx_L123_error)
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              for (;;) {
                {
                  __pyx_t_7 = __pyx_t_35(__pyx_t_10);
                  if (unlikely(!__pyx_t_7)) {
                    PyObject* exc_type = PyErr_Occurred();
                    if (exc_type) {
                      if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 5079, __pyx_L123_error)
                      PyErr_Clear();
                    }
                    break;
                  }
                }
                __Pyx_GOTREF(__pyx_t_7);
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_verify_attempt);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_verify_attempt, __pyx_t_7);
                __Pyx_GIVEREF(__pyx_t_7);
                __pyx_t_7 = 0;

                /* "ws_package/controllers/activity_controller.py":5080
 * 
 *                         for verify_attempt in range(max_verification_retries):
 *                             try:             # <<<<<<<<<<<<<<
 *                                 with db_lock_manager.read_lock():
 *                                     async with async_session() as session:
*/
                {
                  __Pyx_ExceptionSave(&__pyx_t_15, &__pyx_t_18, &__pyx_t_17);
                  __Pyx_XGOTREF(__pyx_t_15);
                  __Pyx_XGOTREF(__pyx_t_18);
                  __Pyx_XGOTREF(__pyx_t_17);
                  /*try:*/ {

                    /* "ws_package/controllers/activity_controller.py":5081
 *                         for verify_attempt in range(max_verification_retries):
 *                             try:
 *                                 with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                                     async with async_session() as session:
 *                                         # Query for the interval by matching start_time, end_time, and counter
*/
                    /*with:*/ {
                      __pyx_t_24 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5081, __pyx_L135_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5081, __pyx_L135_error)
                      __Pyx_GOTREF(__pyx_t_6);
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __pyx_t_8 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_6))) {
                        __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_6);
                        assert(__pyx_t_24);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                        __Pyx_INCREF(__pyx_t_24);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                        __pyx_t_8 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_24, NULL};
                        __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5081, __pyx_L135_error)
                        __Pyx_GOTREF(__pyx_t_7);
                      }
                      __pyx_t_16 = __Pyx_PyObject_LookupSpecial(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 5081, __pyx_L135_error)
                      __Pyx_GOTREF(__pyx_t_16);
                      __pyx_t_24 = NULL;
                      __pyx_t_4 = __Pyx_PyObject_LookupSpecial(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5081, __pyx_L143_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __pyx_t_8 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (likely(PyMethod_Check(__pyx_t_4))) {
                        __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_4);
                        assert(__pyx_t_24);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                        __Pyx_INCREF(__pyx_t_24);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                        __pyx_t_8 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_24, NULL};
                        __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5081, __pyx_L143_error)
                        __Pyx_GOTREF(__pyx_t_6);
                      }
                      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                      /*try:*/ {
                        {
                          __Pyx_ExceptionSave(&__pyx_t_19, &__pyx_t_22, &__pyx_t_21);
                          __Pyx_XGOTREF(__pyx_t_19);
                          __Pyx_XGOTREF(__pyx_t_22);
                          __Pyx_XGOTREF(__pyx_t_21);
                          /*try:*/ {

                            /* "ws_package/controllers/activity_controller.py":5082
 *                             try:
 *                                 with db_lock_manager.read_lock():
 *                                     async with async_session() as session:             # <<<<<<<<<<<<<<
 *                                         # Query for the interval by matching start_time, end_time, and counter
 *                                         query = select(ActivityInterval).where(
*/
                            /*with:*/ {
                              __pyx_t_6 = NULL;
                              __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5082, __pyx_L149_error)
                              __Pyx_GOTREF(__pyx_t_4);
                              __pyx_t_8 = 1;
                              #if CYTHON_UNPACK_METHODS
                              if (unlikely(PyMethod_Check(__pyx_t_4))) {
                                __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
                                assert(__pyx_t_6);
                                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                                __Pyx_INCREF(__pyx_t_6);
                                __Pyx_INCREF(__pyx__function);
                                __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                                __pyx_t_8 = 0;
                              }
                              #endif
                              {
                                PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
                                __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5082, __pyx_L149_error)
                                __Pyx_GOTREF(__pyx_t_7);
                              }
                              __pyx_t_20 = __Pyx_PyObject_LookupSpecial(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 5082, __pyx_L149_error)
                              __Pyx_GOTREF(__pyx_t_20);
                              __pyx_t_6 = NULL;
                              __pyx_t_24 = __Pyx_PyObject_LookupSpecial(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5082, __pyx_L157_error)
                              __Pyx_GOTREF(__pyx_t_24);
                              __pyx_t_8 = 1;
                              #if CYTHON_UNPACK_METHODS
                              if (likely(PyMethod_Check(__pyx_t_24))) {
                                __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_24);
                                assert(__pyx_t_6);
                                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_24);
                                __Pyx_INCREF(__pyx_t_6);
                                __Pyx_INCREF(__pyx__function);
                                __Pyx_DECREF_SET(__pyx_t_24, __pyx__function);
                                __pyx_t_8 = 0;
                              }
                              #endif
                              {
                                PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
                                __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_24, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                                __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                                if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5082, __pyx_L157_error)
                                __Pyx_GOTREF(__pyx_t_4);
                              }
                              __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
                              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                              if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                __Pyx_GOTREF(__pyx_r);
                                __Pyx_XGIVEREF(__pyx_t_1);
                                __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                __Pyx_XGIVEREF(__pyx_t_2);
                                __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                __Pyx_XGIVEREF(__pyx_t_3);
                                __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                __Pyx_XGIVEREF(__pyx_t_7);
                                __pyx_cur_scope->__pyx_t_3 = __pyx_t_7;
                                __Pyx_XGIVEREF(__pyx_t_10);
                                __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                                __Pyx_XGIVEREF(__pyx_t_12);
                                __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                                __Pyx_XGIVEREF(__pyx_t_13);
                                __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                                __Pyx_XGIVEREF(__pyx_t_14);
                                __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                                __Pyx_XGIVEREF(__pyx_t_15);
                                __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                                __Pyx_XGIVEREF(__pyx_t_16);
                                __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                                __Pyx_XGIVEREF(__pyx_t_17);
                                __pyx_cur_scope->__pyx_t_10 = __pyx_t_17;
                                __Pyx_XGIVEREF(__pyx_t_18);
                                __pyx_cur_scope->__pyx_t_11 = __pyx_t_18;
                                __Pyx_XGIVEREF(__pyx_t_19);
                                __pyx_cur_scope->__pyx_t_12 = __pyx_t_19;
                                __Pyx_XGIVEREF(__pyx_t_20);
                                __pyx_cur_scope->__pyx_t_13 = __pyx_t_20;
                                __Pyx_XGIVEREF(__pyx_t_21);
                                __pyx_cur_scope->__pyx_t_14 = __pyx_t_21;
                                __Pyx_XGIVEREF(__pyx_t_22);
                                __pyx_cur_scope->__pyx_t_15 = __pyx_t_22;
                                __pyx_cur_scope->__pyx_t_18 = __pyx_t_35;
                                __Pyx_XGIVEREF(__pyx_r);
                                __Pyx_RefNannyFinishContext();
                                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                                /* return from generator, awaiting value */
                                __pyx_generator->resume_label = 14;
                                return __pyx_r;
                                __pyx_L158_resume_from_await:;
                                __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                __pyx_cur_scope->__pyx_t_0 = 0;
                                __Pyx_XGOTREF(__pyx_t_1);
                                __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                __pyx_cur_scope->__pyx_t_1 = 0;
                                __Pyx_XGOTREF(__pyx_t_2);
                                __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                __pyx_cur_scope->__pyx_t_2 = 0;
                                __Pyx_XGOTREF(__pyx_t_3);
                                __pyx_t_7 = __pyx_cur_scope->__pyx_t_3;
                                __pyx_cur_scope->__pyx_t_3 = 0;
                                __Pyx_XGOTREF(__pyx_t_7);
                                __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                                __pyx_cur_scope->__pyx_t_4 = 0;
                                __Pyx_XGOTREF(__pyx_t_10);
                                __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                                __pyx_cur_scope->__pyx_t_5 = 0;
                                __Pyx_XGOTREF(__pyx_t_12);
                                __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                                __pyx_cur_scope->__pyx_t_6 = 0;
                                __Pyx_XGOTREF(__pyx_t_13);
                                __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                                __pyx_cur_scope->__pyx_t_7 = 0;
                                __Pyx_XGOTREF(__pyx_t_14);
                                __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                                __pyx_cur_scope->__pyx_t_8 = 0;
                                __Pyx_XGOTREF(__pyx_t_15);
                                __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                                __pyx_cur_scope->__pyx_t_9 = 0;
                                __Pyx_XGOTREF(__pyx_t_16);
                                __pyx_t_17 = __pyx_cur_scope->__pyx_t_10;
                                __pyx_cur_scope->__pyx_t_10 = 0;
                                __Pyx_XGOTREF(__pyx_t_17);
                                __pyx_t_18 = __pyx_cur_scope->__pyx_t_11;
                                __pyx_cur_scope->__pyx_t_11 = 0;
                                __Pyx_XGOTREF(__pyx_t_18);
                                __pyx_t_19 = __pyx_cur_scope->__pyx_t_12;
                                __pyx_cur_scope->__pyx_t_12 = 0;
                                __Pyx_XGOTREF(__pyx_t_19);
                                __pyx_t_20 = __pyx_cur_scope->__pyx_t_13;
                                __pyx_cur_scope->__pyx_t_13 = 0;
                                __Pyx_XGOTREF(__pyx_t_20);
                                __pyx_t_21 = __pyx_cur_scope->__pyx_t_14;
                                __pyx_cur_scope->__pyx_t_14 = 0;
                                __Pyx_XGOTREF(__pyx_t_21);
                                __pyx_t_22 = __pyx_cur_scope->__pyx_t_15;
                                __pyx_cur_scope->__pyx_t_15 = 0;
                                __Pyx_XGOTREF(__pyx_t_22);
                                __pyx_t_35 = __pyx_cur_scope->__pyx_t_18;
                                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5082, __pyx_L157_error)
                                __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                              } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                __Pyx_GOTREF(__pyx_r);
                                __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                              } else {
                                __Pyx_XGOTREF(__pyx_r);
                                __PYX_ERR(0, 5082, __pyx_L157_error)
                              }
                              __pyx_t_24 = __pyx_t_4;
                              __pyx_t_4 = 0;
                              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                              /*try:*/ {
                                {
                                  __Pyx_ExceptionSave(&__pyx_t_30, &__pyx_t_36, &__pyx_t_37);
                                  __Pyx_XGOTREF(__pyx_t_30);
                                  __Pyx_XGOTREF(__pyx_t_36);
                                  __Pyx_XGOTREF(__pyx_t_37);
                                  /*try:*/ {
                                    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_session);
                                    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_session, __pyx_t_24);
                                    __Pyx_GIVEREF(__pyx_t_24);
                                    __pyx_t_24 = 0;

                                    /* "ws_package/controllers/activity_controller.py":5084
 *                                     async with async_session() as session:
 *                                         # Query for the interval by matching start_time, end_time, and counter
 *                                         query = select(ActivityInterval).where(             # <<<<<<<<<<<<<<
 *                                             ActivityInterval.start_time == last_interval.start_time,
 *                                             ActivityInterval.end_time == last_interval.end_time,
*/
                                    __pyx_t_26 = NULL;
                                    __Pyx_GetModuleGlobalName(__pyx_t_27, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 5084, __pyx_L164_error)
                                    __Pyx_GOTREF(__pyx_t_27);
                                    __Pyx_GetModuleGlobalName(__pyx_t_38, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_38)) __PYX_ERR(0, 5084, __pyx_L164_error)
                                    __Pyx_GOTREF(__pyx_t_38);
                                    __pyx_t_8 = 1;
                                    #if CYTHON_UNPACK_METHODS
                                    if (unlikely(PyMethod_Check(__pyx_t_27))) {
                                      __pyx_t_26 = PyMethod_GET_SELF(__pyx_t_27);
                                      assert(__pyx_t_26);
                                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_27);
                                      __Pyx_INCREF(__pyx_t_26);
                                      __Pyx_INCREF(__pyx__function);
                                      __Pyx_DECREF_SET(__pyx_t_27, __pyx__function);
                                      __pyx_t_8 = 0;
                                    }
                                    #endif
                                    {
                                      PyObject *__pyx_callargs[2] = {__pyx_t_26, __pyx_t_38};
                                      __pyx_t_25 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_27, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                      __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                                      __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0;
                                      __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                                      if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5084, __pyx_L164_error)
                                      __Pyx_GOTREF(__pyx_t_25);
                                    }
                                    __pyx_t_5 = __pyx_t_25;
                                    __Pyx_INCREF(__pyx_t_5);

                                    /* "ws_package/controllers/activity_controller.py":5085
 *                                         # Query for the interval by matching start_time, end_time, and counter
 *                                         query = select(ActivityInterval).where(
 *                                             ActivityInterval.start_time == last_interval.start_time,             # <<<<<<<<<<<<<<
 *                                             ActivityInterval.end_time == last_interval.end_time,
 *                                             ActivityInterval.counter == last_interval.counter
*/
                                    __Pyx_GetModuleGlobalName(__pyx_t_27, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 5085, __pyx_L164_error)
                                    __Pyx_GOTREF(__pyx_t_27);
                                    __pyx_t_38 = __Pyx_PyObject_GetAttrStr(__pyx_t_27, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_38)) __PYX_ERR(0, 5085, __pyx_L164_error)
                                    __Pyx_GOTREF(__pyx_t_38);
                                    __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                                    __pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 5085, __pyx_L164_error)
                                    __Pyx_GOTREF(__pyx_t_27);
                                    __pyx_t_26 = PyObject_RichCompare(__pyx_t_38, __pyx_t_27, Py_EQ); __Pyx_XGOTREF(__pyx_t_26); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5085, __pyx_L164_error)
                                    __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0;
                                    __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;

                                    /* "ws_package/controllers/activity_controller.py":5086
 *                                         query = select(ActivityInterval).where(
 *                                             ActivityInterval.start_time == last_interval.start_time,
 *                                             ActivityInterval.end_time == last_interval.end_time,             # <<<<<<<<<<<<<<
 *                                             ActivityInterval.counter == last_interval.counter
 *                                         ).order_by(ActivityInterval.id.desc()).limit(1)
*/
                                    __Pyx_GetModuleGlobalName(__pyx_t_27, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 5086, __pyx_L164_error)
                                    __Pyx_GOTREF(__pyx_t_27);
                                    __pyx_t_38 = __Pyx_PyObject_GetAttrStr(__pyx_t_27, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_38)) __PYX_ERR(0, 5086, __pyx_L164_error)
                                    __Pyx_GOTREF(__pyx_t_38);
                                    __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                                    __pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 5086, __pyx_L164_error)
                                    __Pyx_GOTREF(__pyx_t_27);
                                    __pyx_t_39 = PyObject_RichCompare(__pyx_t_38, __pyx_t_27, Py_EQ); __Pyx_XGOTREF(__pyx_t_39); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5086, __pyx_L164_error)
                                    __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0;
                                    __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;

                                    /* "ws_package/controllers/activity_controller.py":5087
 *                                             ActivityInterval.start_time == last_interval.start_time,
 *                                             ActivityInterval.end_time == last_interval.end_time,
 *                                             ActivityInterval.counter == last_interval.counter             # <<<<<<<<<<<<<<
 *                                         ).order_by(ActivityInterval.id.desc()).limit(1)
 * 
*/
                                    __Pyx_GetModuleGlobalName(__pyx_t_27, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 5087, __pyx_L164_error)
                                    __Pyx_GOTREF(__pyx_t_27);
                                    __pyx_t_38 = __Pyx_PyObject_GetAttrStr(__pyx_t_27, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_38)) __PYX_ERR(0, 5087, __pyx_L164_error)
                                    __Pyx_GOTREF(__pyx_t_38);
                                    __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                                    __pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 5087, __pyx_L164_error)
                                    __Pyx_GOTREF(__pyx_t_27);
                                    __pyx_t_40 = PyObject_RichCompare(__pyx_t_38, __pyx_t_27, Py_EQ); __Pyx_XGOTREF(__pyx_t_40); if (unlikely(!__pyx_t_40)) __PYX_ERR(0, 5087, __pyx_L164_error)
                                    __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0;
                                    __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                                    __pyx_t_8 = 0;
                                    {
                                      PyObject *__pyx_callargs[4] = {__pyx_t_5, __pyx_t_26, __pyx_t_39, __pyx_t_40};
                                      __pyx_t_23 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                                      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                                      __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                                      __Pyx_DECREF(__pyx_t_40); __pyx_t_40 = 0;
                                      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                                      if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5084, __pyx_L164_error)
                                      __Pyx_GOTREF(__pyx_t_23);
                                    }
                                    __pyx_t_6 = __pyx_t_23;
                                    __Pyx_INCREF(__pyx_t_6);

                                    /* "ws_package/controllers/activity_controller.py":5088
 *                                             ActivityInterval.end_time == last_interval.end_time,
 *                                             ActivityInterval.counter == last_interval.counter
 *                                         ).order_by(ActivityInterval.id.desc()).limit(1)             # <<<<<<<<<<<<<<
 * 
 *                                         result = await session.execute(query)
*/
                                    __Pyx_GetModuleGlobalName(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5088, __pyx_L164_error)
                                    __Pyx_GOTREF(__pyx_t_39);
                                    __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5088, __pyx_L164_error)
                                    __Pyx_GOTREF(__pyx_t_26);
                                    __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                                    __pyx_t_40 = __pyx_t_26;
                                    __Pyx_INCREF(__pyx_t_40);
                                    __pyx_t_8 = 0;
                                    {
                                      PyObject *__pyx_callargs[2] = {__pyx_t_40, NULL};
                                      __pyx_t_25 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_desc, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                      __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                                      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                                      if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5088, __pyx_L164_error)
                                      __Pyx_GOTREF(__pyx_t_25);
                                    }
                                    __pyx_t_8 = 0;
                                    {
                                      PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_25};
                                      __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_order_by, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                                      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                                      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                                      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5088, __pyx_L164_error)
                                      __Pyx_GOTREF(__pyx_t_4);
                                    }
                                    __pyx_t_7 = __pyx_t_4;
                                    __Pyx_INCREF(__pyx_t_7);
                                    __pyx_t_8 = 0;
                                    {
                                      PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_mstate_global->__pyx_int_1};
                                      __pyx_t_24 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_limit, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                      if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5088, __pyx_L164_error)
                                      __Pyx_GOTREF(__pyx_t_24);
                                    }
                                    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_query);
                                    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_query, __pyx_t_24);
                                    __Pyx_GIVEREF(__pyx_t_24);
                                    __pyx_t_24 = 0;

                                    /* "ws_package/controllers/activity_controller.py":5090
 *                                         ).order_by(ActivityInterval.id.desc()).limit(1)
 * 
 *                                         result = await session.execute(query)             # <<<<<<<<<<<<<<
 *                                         db_interval = result.scalar_one_or_none()
 * 
*/
                                    __pyx_t_4 = __pyx_cur_scope->__pyx_v_session;
                                    __Pyx_INCREF(__pyx_t_4);
                                    __pyx_t_8 = 0;
                                    {
                                      PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_query};
                                      __pyx_t_24 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                                      if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5090, __pyx_L164_error)
                                      __Pyx_GOTREF(__pyx_t_24);
                                    }
                                    __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_24, &__pyx_r);
                                    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                                    if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                      __Pyx_GOTREF(__pyx_r);
                                      __Pyx_XGIVEREF(__pyx_t_1);
                                      __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                      __Pyx_XGIVEREF(__pyx_t_2);
                                      __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                      __Pyx_XGIVEREF(__pyx_t_3);
                                      __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                      __Pyx_XGIVEREF(__pyx_t_10);
                                      __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                                      __Pyx_XGIVEREF(__pyx_t_12);
                                      __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                                      __Pyx_XGIVEREF(__pyx_t_13);
                                      __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                                      __Pyx_XGIVEREF(__pyx_t_14);
                                      __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                                      __Pyx_XGIVEREF(__pyx_t_15);
                                      __pyx_cur_scope->__pyx_t_7 = __pyx_t_15;
                                      __Pyx_XGIVEREF(__pyx_t_16);
                                      __pyx_cur_scope->__pyx_t_8 = __pyx_t_16;
                                      __Pyx_XGIVEREF(__pyx_t_17);
                                      __pyx_cur_scope->__pyx_t_9 = __pyx_t_17;
                                      __Pyx_XGIVEREF(__pyx_t_18);
                                      __pyx_cur_scope->__pyx_t_10 = __pyx_t_18;
                                      __Pyx_XGIVEREF(__pyx_t_19);
                                      __pyx_cur_scope->__pyx_t_11 = __pyx_t_19;
                                      __Pyx_XGIVEREF(__pyx_t_20);
                                      __pyx_cur_scope->__pyx_t_12 = __pyx_t_20;
                                      __Pyx_XGIVEREF(__pyx_t_21);
                                      __pyx_cur_scope->__pyx_t_13 = __pyx_t_21;
                                      __Pyx_XGIVEREF(__pyx_t_22);
                                      __pyx_cur_scope->__pyx_t_14 = __pyx_t_22;
                                      __Pyx_XGIVEREF(__pyx_t_30);
                                      __pyx_cur_scope->__pyx_t_15 = __pyx_t_30;
                                      __pyx_cur_scope->__pyx_t_18 = __pyx_t_35;
                                      __Pyx_XGIVEREF(__pyx_t_36);
                                      __pyx_cur_scope->__pyx_t_16 = __pyx_t_36;
                                      __Pyx_XGIVEREF(__pyx_t_37);
                                      __pyx_cur_scope->__pyx_t_17 = __pyx_t_37;
                                      __Pyx_XGIVEREF(__pyx_r);
                                      __Pyx_RefNannyFinishContext();
                                      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                                      /* return from generator, awaiting value */
                                      __pyx_generator->resume_label = 15;
                                      return __pyx_r;
                                      __pyx_L172_resume_from_await:;
                                      __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                      __pyx_cur_scope->__pyx_t_0 = 0;
                                      __Pyx_XGOTREF(__pyx_t_1);
                                      __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                      __pyx_cur_scope->__pyx_t_1 = 0;
                                      __Pyx_XGOTREF(__pyx_t_2);
                                      __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                      __pyx_cur_scope->__pyx_t_2 = 0;
                                      __Pyx_XGOTREF(__pyx_t_3);
                                      __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                                      __pyx_cur_scope->__pyx_t_3 = 0;
                                      __Pyx_XGOTREF(__pyx_t_10);
                                      __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                                      __pyx_cur_scope->__pyx_t_4 = 0;
                                      __Pyx_XGOTREF(__pyx_t_12);
                                      __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                                      __pyx_cur_scope->__pyx_t_5 = 0;
                                      __Pyx_XGOTREF(__pyx_t_13);
                                      __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                                      __pyx_cur_scope->__pyx_t_6 = 0;
                                      __Pyx_XGOTREF(__pyx_t_14);
                                      __pyx_t_15 = __pyx_cur_scope->__pyx_t_7;
                                      __pyx_cur_scope->__pyx_t_7 = 0;
                                      __Pyx_XGOTREF(__pyx_t_15);
                                      __pyx_t_16 = __pyx_cur_scope->__pyx_t_8;
                                      __pyx_cur_scope->__pyx_t_8 = 0;
                                      __Pyx_XGOTREF(__pyx_t_16);
                                      __pyx_t_17 = __pyx_cur_scope->__pyx_t_9;
                                      __pyx_cur_scope->__pyx_t_9 = 0;
                                      __Pyx_XGOTREF(__pyx_t_17);
                                      __pyx_t_18 = __pyx_cur_scope->__pyx_t_10;
                                      __pyx_cur_scope->__pyx_t_10 = 0;
                                      __Pyx_XGOTREF(__pyx_t_18);
                                      __pyx_t_19 = __pyx_cur_scope->__pyx_t_11;
                                      __pyx_cur_scope->__pyx_t_11 = 0;
                                      __Pyx_XGOTREF(__pyx_t_19);
                                      __pyx_t_20 = __pyx_cur_scope->__pyx_t_12;
                                      __pyx_cur_scope->__pyx_t_12 = 0;
                                      __Pyx_XGOTREF(__pyx_t_20);
                                      __pyx_t_21 = __pyx_cur_scope->__pyx_t_13;
                                      __pyx_cur_scope->__pyx_t_13 = 0;
                                      __Pyx_XGOTREF(__pyx_t_21);
                                      __pyx_t_22 = __pyx_cur_scope->__pyx_t_14;
                                      __pyx_cur_scope->__pyx_t_14 = 0;
                                      __Pyx_XGOTREF(__pyx_t_22);
                                      __pyx_t_30 = __pyx_cur_scope->__pyx_t_15;
                                      __pyx_cur_scope->__pyx_t_15 = 0;
                                      __Pyx_XGOTREF(__pyx_t_30);
                                      __pyx_t_35 = __pyx_cur_scope->__pyx_t_18;
                                      __pyx_t_36 = __pyx_cur_scope->__pyx_t_16;
                                      __pyx_cur_scope->__pyx_t_16 = 0;
                                      __Pyx_XGOTREF(__pyx_t_36);
                                      __pyx_t_37 = __pyx_cur_scope->__pyx_t_17;
                                      __pyx_cur_scope->__pyx_t_17 = 0;
                                      __Pyx_XGOTREF(__pyx_t_37);
                                      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5090, __pyx_L164_error)
                                      __pyx_t_24 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_24);
                                    } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                      __Pyx_GOTREF(__pyx_r);
                                      __pyx_t_24 = __pyx_r; __pyx_r = NULL;
                                    } else {
                                      __Pyx_XGOTREF(__pyx_r);
                                      __PYX_ERR(0, 5090, __pyx_L164_error)
                                    }
                                    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_result);
                                    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_result, __pyx_t_24);
                                    __Pyx_GIVEREF(__pyx_t_24);
                                    __pyx_t_24 = 0;

                                    /* "ws_package/controllers/activity_controller.py":5091
 * 
 *                                         result = await session.execute(query)
 *                                         db_interval = result.scalar_one_or_none()             # <<<<<<<<<<<<<<
 * 
 *                                         if db_interval and db_interval.id:
*/
                                    __pyx_t_4 = __pyx_cur_scope->__pyx_v_result;
                                    __Pyx_INCREF(__pyx_t_4);
                                    __pyx_t_8 = 0;
                                    {
                                      PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
                                      __pyx_t_24 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalar_one_or_none, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                                      if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5091, __pyx_L164_error)
                                      __Pyx_GOTREF(__pyx_t_24);
                                    }
                                    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_db_interval);
                                    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_db_interval, __pyx_t_24);
                                    __Pyx_GIVEREF(__pyx_t_24);
                                    __pyx_t_24 = 0;

                                    /* "ws_package/controllers/activity_controller.py":5093
 *                                         db_interval = result.scalar_one_or_none()
 * 
 *                                         if db_interval and db_interval.id:             # <<<<<<<<<<<<<<
 *                                             # Found the interval in database with an ID - store it separately
 *                                             last_interval_id = db_interval.id
*/
                                    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_db_interval); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 5093, __pyx_L164_error)
                                    if (__pyx_t_9) {
                                    } else {
                                      __pyx_t_28 = __pyx_t_9;
                                      goto __pyx_L174_bool_binop_done;
                                    }
                                    __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_db_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5093, __pyx_L164_error)
                                    __Pyx_GOTREF(__pyx_t_24);
                                    __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_24); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 5093, __pyx_L164_error)
                                    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                                    __pyx_t_28 = __pyx_t_9;
                                    __pyx_L174_bool_binop_done:;
                                    if (__pyx_t_28) {

                                      /* "ws_package/controllers/activity_controller.py":5095
 *                                         if db_interval and db_interval.id:
 *                                             # Found the interval in database with an ID - store it separately
 *                                             last_interval_id = db_interval.id             # <<<<<<<<<<<<<<
 *                                             interval_verified = True
 *                                             logger.info(" Verified last interval in database: id=%s, start_time=%s, end_time=%s, counter=%s", db_interval.id, db_interval.start_time, db_interval.end_time, db_interval.counter)
*/
                                      __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_db_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5095, __pyx_L164_error)
                                      __Pyx_GOTREF(__pyx_t_24);
                                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_last_interval_id);
                                      __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_last_interval_id, __pyx_t_24);
                                      __Pyx_GIVEREF(__pyx_t_24);
                                      __pyx_t_24 = 0;

                                      /* "ws_package/controllers/activity_controller.py":5096
 *                                             # Found the interval in database with an ID - store it separately
 *                                             last_interval_id = db_interval.id
 *                                             interval_verified = True             # <<<<<<<<<<<<<<
 *                                             logger.info(" Verified last interval in database: id=%s, start_time=%s, end_time=%s, counter=%s", db_interval.id, db_interval.start_time, db_interval.end_time, db_interval.counter)
 *                                             break
*/
                                      __pyx_cur_scope->__pyx_v_interval_verified = 1;

                                      /* "ws_package/controllers/activity_controller.py":5097
 *                                             last_interval_id = db_interval.id
 *                                             interval_verified = True
 *                                             logger.info(" Verified last interval in database: id=%s, start_time=%s, end_time=%s, counter=%s", db_interval.id, db_interval.start_time, db_interval.end_time, db_interval.counter)             # <<<<<<<<<<<<<<
 *                                             break
 *                             except Exception as verify_error:
*/
                                      __pyx_t_4 = NULL;
                                      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5097, __pyx_L164_error)
                                      __Pyx_GOTREF(__pyx_t_7);
                                      __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5097, __pyx_L164_error)
                                      __Pyx_GOTREF(__pyx_t_23);
                                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                                      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_db_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5097, __pyx_L164_error)
                                      __Pyx_GOTREF(__pyx_t_7);
                                      __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_db_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5097, __pyx_L164_error)
                                      __Pyx_GOTREF(__pyx_t_25);
                                      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_db_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5097, __pyx_L164_error)
                                      __Pyx_GOTREF(__pyx_t_6);
                                      __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_db_interval, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5097, __pyx_L164_error)
                                      __Pyx_GOTREF(__pyx_t_26);
                                      __pyx_t_8 = 1;
                                      #if CYTHON_UNPACK_METHODS
                                      if (unlikely(PyMethod_Check(__pyx_t_23))) {
                                        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_23);
                                        assert(__pyx_t_4);
                                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_23);
                                        __Pyx_INCREF(__pyx_t_4);
                                        __Pyx_INCREF(__pyx__function);
                                        __Pyx_DECREF_SET(__pyx_t_23, __pyx__function);
                                        __pyx_t_8 = 0;
                                      }
                                      #endif
                                      {
                                        PyObject *__pyx_callargs[6] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Verified_last_interval_in_datab, __pyx_t_7, __pyx_t_25, __pyx_t_6, __pyx_t_26};
                                        __pyx_t_24 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_23, __pyx_callargs+__pyx_t_8, (6-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                                        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                                        __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                                        if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5097, __pyx_L164_error)
                                        __Pyx_GOTREF(__pyx_t_24);
                                      }
                                      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;

                                      /* "ws_package/controllers/activity_controller.py":5098
 *                                             interval_verified = True
 *                                             logger.info(" Verified last interval in database: id=%s, start_time=%s, end_time=%s, counter=%s", db_interval.id, db_interval.start_time, db_interval.end_time, db_interval.counter)
 *                                             break             # <<<<<<<<<<<<<<
 *                             except Exception as verify_error:
 *                                 logger.warning("Error verifying last interval in database (attempt %s/%s): %s", verify_attempt + 1, max_verification_retries, verify_error)
*/
                                      goto __pyx_L169_try_break;

                                      /* "ws_package/controllers/activity_controller.py":5093
 *                                         db_interval = result.scalar_one_or_none()
 * 
 *                                         if db_interval and db_interval.id:             # <<<<<<<<<<<<<<
 *                                             # Found the interval in database with an ID - store it separately
 *                                             last_interval_id = db_interval.id
*/
                                    }

                                    /* "ws_package/controllers/activity_controller.py":5082
 *                             try:
 *                                 with db_lock_manager.read_lock():
 *                                     async with async_session() as session:             # <<<<<<<<<<<<<<
 *                                         # Query for the interval by matching start_time, end_time, and counter
 *                                         query = select(ActivityInterval).where(
*/
                                  }
                                  __Pyx_XDECREF(__pyx_t_30); __pyx_t_30 = 0;
                                  __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                                  __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                                  goto __pyx_L171_try_end;
                                  __pyx_L164_error:;
                                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                                  __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                                  __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                                  __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                                  __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                                  __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                                  __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                                  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                                  /*except:*/ {
                                    __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
                                    if (__Pyx_GetException(&__pyx_t_24, &__pyx_t_23, &__pyx_t_26) < 0) __PYX_ERR(0, 5082, __pyx_L166_except_error)
                                    __Pyx_XGOTREF(__pyx_t_24);
                                    __Pyx_XGOTREF(__pyx_t_23);
                                    __Pyx_XGOTREF(__pyx_t_26);
                                    __pyx_t_6 = PyTuple_Pack(3, __pyx_t_24, __pyx_t_23, __pyx_t_26); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5082, __pyx_L166_except_error)
                                    __Pyx_GOTREF(__pyx_t_6);
                                    __pyx_t_41 = __Pyx_PyObject_Call(__pyx_t_20, __pyx_t_6, NULL);
                                    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                                    if (unlikely(!__pyx_t_41)) __PYX_ERR(0, 5082, __pyx_L166_except_error)
                                    __Pyx_GOTREF(__pyx_t_41);
                                    __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_41, &__pyx_r);
                                    __Pyx_DECREF(__pyx_t_41); __pyx_t_41 = 0;
                                    if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                      __Pyx_GOTREF(__pyx_r);
                                      __Pyx_XGIVEREF(__pyx_t_1);
                                      __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                      __Pyx_XGIVEREF(__pyx_t_2);
                                      __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                      __Pyx_XGIVEREF(__pyx_t_3);
                                      __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                      __Pyx_XGIVEREF(__pyx_t_10);
                                      __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                                      __Pyx_XGIVEREF(__pyx_t_12);
                                      __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                                      __Pyx_XGIVEREF(__pyx_t_13);
                                      __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                                      __Pyx_XGIVEREF(__pyx_t_14);
                                      __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                                      __Pyx_XGIVEREF(__pyx_t_15);
                                      __pyx_cur_scope->__pyx_t_7 = __pyx_t_15;
                                      __Pyx_XGIVEREF(__pyx_t_16);
                                      __pyx_cur_scope->__pyx_t_8 = __pyx_t_16;
                                      __Pyx_XGIVEREF(__pyx_t_17);
                                      __pyx_cur_scope->__pyx_t_9 = __pyx_t_17;
                                      __Pyx_XGIVEREF(__pyx_t_18);
                                      __pyx_cur_scope->__pyx_t_10 = __pyx_t_18;
                                      __Pyx_XGIVEREF(__pyx_t_19);
                                      __pyx_cur_scope->__pyx_t_11 = __pyx_t_19;
                                      __Pyx_XGIVEREF(__pyx_t_20);
                                      __pyx_cur_scope->__pyx_t_12 = __pyx_t_20;
                                      __Pyx_XGIVEREF(__pyx_t_21);
                                      __pyx_cur_scope->__pyx_t_13 = __pyx_t_21;
                                      __Pyx_XGIVEREF(__pyx_t_22);
                                      __pyx_cur_scope->__pyx_t_14 = __pyx_t_22;
                                      __Pyx_XGIVEREF(__pyx_t_23);
                                      __pyx_cur_scope->__pyx_t_15 = __pyx_t_23;
                                      __Pyx_XGIVEREF(__pyx_t_24);
                                      __pyx_cur_scope->__pyx_t_16 = __pyx_t_24;
                                      __Pyx_XGIVEREF(__pyx_t_26);
                                      __pyx_cur_scope->__pyx_t_17 = __pyx_t_26;
                                      __Pyx_XGIVEREF(__pyx_t_30);
                                      __pyx_cur_scope->__pyx_t_19 = __pyx_t_30;
                                      __pyx_cur_scope->__pyx_t_18 = __pyx_t_35;
                                      __Pyx_XGIVEREF(__pyx_t_36);
                                      __pyx_cur_scope->__pyx_t_20 = __pyx_t_36;
                                      __Pyx_XGIVEREF(__pyx_t_37);
                                      __pyx_cur_scope->__pyx_t_21 = __pyx_t_37;
                                      __Pyx_XGIVEREF(__pyx_t_41);
                                      __pyx_cur_scope->__pyx_t_22 = __pyx_t_41;
                                      __Pyx_XGIVEREF(__pyx_r);
                                      __Pyx_RefNannyFinishContext();
                                      __Pyx_Coroutine_SwapException(__pyx_generator);
                                      /* return from generator, awaiting value */
                                      __pyx_generator->resume_label = 16;
                                      return __pyx_r;
                                      __pyx_L179_resume_from_await:;
                                      __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                      __pyx_cur_scope->__pyx_t_0 = 0;
                                      __Pyx_XGOTREF(__pyx_t_1);
                                      __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                      __pyx_cur_scope->__pyx_t_1 = 0;
                                      __Pyx_XGOTREF(__pyx_t_2);
                                      __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                      __pyx_cur_scope->__pyx_t_2 = 0;
                                      __Pyx_XGOTREF(__pyx_t_3);
                                      __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                                      __pyx_cur_scope->__pyx_t_3 = 0;
                                      __Pyx_XGOTREF(__pyx_t_10);
                                      __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                                      __pyx_cur_scope->__pyx_t_4 = 0;
                                      __Pyx_XGOTREF(__pyx_t_12);
                                      __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                                      __pyx_cur_scope->__pyx_t_5 = 0;
                                      __Pyx_XGOTREF(__pyx_t_13);
                                      __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                                      __pyx_cur_scope->__pyx_t_6 = 0;
                                      __Pyx_XGOTREF(__pyx_t_14);
                                      __pyx_t_15 = __pyx_cur_scope->__pyx_t_7;
                                      __pyx_cur_scope->__pyx_t_7 = 0;
                                      __Pyx_XGOTREF(__pyx_t_15);
                                      __pyx_t_16 = __pyx_cur_scope->__pyx_t_8;
                                      __pyx_cur_scope->__pyx_t_8 = 0;
                                      __Pyx_XGOTREF(__pyx_t_16);
                                      __pyx_t_17 = __pyx_cur_scope->__pyx_t_9;
                                      __pyx_cur_scope->__pyx_t_9 = 0;
                                      __Pyx_XGOTREF(__pyx_t_17);
                                      __pyx_t_18 = __pyx_cur_scope->__pyx_t_10;
                                      __pyx_cur_scope->__pyx_t_10 = 0;
                                      __Pyx_XGOTREF(__pyx_t_18);
                                      __pyx_t_19 = __pyx_cur_scope->__pyx_t_11;
                                      __pyx_cur_scope->__pyx_t_11 = 0;
                                      __Pyx_XGOTREF(__pyx_t_19);
                                      __pyx_t_20 = __pyx_cur_scope->__pyx_t_12;
                                      __pyx_cur_scope->__pyx_t_12 = 0;
                                      __Pyx_XGOTREF(__pyx_t_20);
                                      __pyx_t_21 = __pyx_cur_scope->__pyx_t_13;
                                      __pyx_cur_scope->__pyx_t_13 = 0;
                                      __Pyx_XGOTREF(__pyx_t_21);
                                      __pyx_t_22 = __pyx_cur_scope->__pyx_t_14;
                                      __pyx_cur_scope->__pyx_t_14 = 0;
                                      __Pyx_XGOTREF(__pyx_t_22);
                                      __pyx_t_23 = __pyx_cur_scope->__pyx_t_15;
                                      __pyx_cur_scope->__pyx_t_15 = 0;
                                      __Pyx_XGOTREF(__pyx_t_23);
                                      __pyx_t_24 = __pyx_cur_scope->__pyx_t_16;
                                      __pyx_cur_scope->__pyx_t_16 = 0;
                                      __Pyx_XGOTREF(__pyx_t_24);
                                      __pyx_t_26 = __pyx_cur_scope->__pyx_t_17;
                                      __pyx_cur_scope->__pyx_t_17 = 0;
                                      __Pyx_XGOTREF(__pyx_t_26);
                                      __pyx_t_30 = __pyx_cur_scope->__pyx_t_19;
                                      __pyx_cur_scope->__pyx_t_19 = 0;
                                      __Pyx_XGOTREF(__pyx_t_30);
                                      __pyx_t_35 = __pyx_cur_scope->__pyx_t_18;
                                      __pyx_t_36 = __pyx_cur_scope->__pyx_t_20;
                                      __pyx_cur_scope->__pyx_t_20 = 0;
                                      __Pyx_XGOTREF(__pyx_t_36);
                                      __pyx_t_37 = __pyx_cur_scope->__pyx_t_21;
                                      __pyx_cur_scope->__pyx_t_21 = 0;
                                      __Pyx_XGOTREF(__pyx_t_37);
                                      __pyx_t_41 = __pyx_cur_scope->__pyx_t_22;
                                      __pyx_cur_scope->__pyx_t_22 = 0;
                                      __Pyx_XGOTREF(__pyx_t_41);
                                      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5082, __pyx_L166_except_error)
                                      __pyx_t_6 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_6);
                                    } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                      __Pyx_GOTREF(__pyx_r);
                                      __pyx_t_6 = __pyx_r; __pyx_r = NULL;
                                    } else {
                                      __Pyx_XGOTREF(__pyx_r);
                                      __PYX_ERR(0, 5082, __pyx_L166_except_error)
                                    }
                                    __pyx_t_41 = __pyx_t_6;
                                    __pyx_t_6 = 0;
                                    __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_41);
                                    __Pyx_DECREF(__pyx_t_41); __pyx_t_41 = 0;
                                    if (__pyx_t_28 < (0)) __PYX_ERR(0, 5082, __pyx_L166_except_error)
                                    __pyx_t_9 = (!__pyx_t_28);
                                    if (unlikely(__pyx_t_9)) {
                                      __Pyx_GIVEREF(__pyx_t_24);
                                      __Pyx_GIVEREF(__pyx_t_23);
                                      __Pyx_XGIVEREF(__pyx_t_26);
                                      __Pyx_ErrRestoreWithState(__pyx_t_24, __pyx_t_23, __pyx_t_26);
                                      __pyx_t_24 = 0;  __pyx_t_23 = 0;  __pyx_t_26 = 0; 
                                      __PYX_ERR(0, 5082, __pyx_L166_except_error)
                                    }
                                    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                                    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                                    __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                                    goto __pyx_L165_exception_handled;
                                  }
                                  __pyx_L166_except_error:;
                                  __Pyx_XGIVEREF(__pyx_t_30);
                                  __Pyx_XGIVEREF(__pyx_t_36);
                                  __Pyx_XGIVEREF(__pyx_t_37);
                                  __Pyx_ExceptionReset(__pyx_t_30, __pyx_t_36, __pyx_t_37);
                                  goto __pyx_L149_error;
                                  __pyx_L169_try_break:;
                                  __Pyx_XGIVEREF(__pyx_t_30);
                                  __Pyx_XGIVEREF(__pyx_t_36);
                                  __Pyx_XGIVEREF(__pyx_t_37);
                                  __Pyx_ExceptionReset(__pyx_t_30, __pyx_t_36, __pyx_t_37);
                                  goto __pyx_L160_break;
                                  __pyx_L165_exception_handled:;
                                  __Pyx_XGIVEREF(__pyx_t_30);
                                  __Pyx_XGIVEREF(__pyx_t_36);
                                  __Pyx_XGIVEREF(__pyx_t_37);
                                  __Pyx_ExceptionReset(__pyx_t_30, __pyx_t_36, __pyx_t_37);
                                  __pyx_L171_try_end:;
                                }
                              }
                              /*finally:*/ {
                                /*normal exit:*/{
                                  if (__pyx_t_20) {
                                    __pyx_t_37 = __Pyx_PyObject_Call(__pyx_t_20, __pyx_mstate_global->__pyx_tuple[7], NULL);
                                    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                                    if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 5082, __pyx_L149_error)
                                    __Pyx_GOTREF(__pyx_t_37);
                                    __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_37, &__pyx_r);
                                    __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                                    if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                      __Pyx_GOTREF(__pyx_r);
                                      __Pyx_XGIVEREF(__pyx_t_1);
                                      __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                      __Pyx_XGIVEREF(__pyx_t_2);
                                      __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                      __Pyx_XGIVEREF(__pyx_t_3);
                                      __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                      __Pyx_XGIVEREF(__pyx_t_10);
                                      __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                                      __Pyx_XGIVEREF(__pyx_t_12);
                                      __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                                      __Pyx_XGIVEREF(__pyx_t_13);
                                      __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                                      __Pyx_XGIVEREF(__pyx_t_14);
                                      __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                                      __Pyx_XGIVEREF(__pyx_t_15);
                                      __pyx_cur_scope->__pyx_t_7 = __pyx_t_15;
                                      __Pyx_XGIVEREF(__pyx_t_16);
                                      __pyx_cur_scope->__pyx_t_8 = __pyx_t_16;
                                      __Pyx_XGIVEREF(__pyx_t_17);
                                      __pyx_cur_scope->__pyx_t_9 = __pyx_t_17;
                                      __Pyx_XGIVEREF(__pyx_t_18);
                                      __pyx_cur_scope->__pyx_t_10 = __pyx_t_18;
                                      __Pyx_XGIVEREF(__pyx_t_19);
                                      __pyx_cur_scope->__pyx_t_11 = __pyx_t_19;
                                      __Pyx_XGIVEREF(__pyx_t_20);
                                      __pyx_cur_scope->__pyx_t_12 = __pyx_t_20;
                                      __Pyx_XGIVEREF(__pyx_t_21);
                                      __pyx_cur_scope->__pyx_t_13 = __pyx_t_21;
                                      __Pyx_XGIVEREF(__pyx_t_22);
                                      __pyx_cur_scope->__pyx_t_14 = __pyx_t_22;
                                      __pyx_cur_scope->__pyx_t_18 = __pyx_t_35;
                                      __Pyx_XGIVEREF(__pyx_t_37);
                                      __pyx_cur_scope->__pyx_t_15 = __pyx_t_37;
                                      __Pyx_XGIVEREF(__pyx_r);
                                      __Pyx_RefNannyFinishContext();
                                      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                                      /* return from generator, awaiting value */
                                      __pyx_generator->resume_label = 17;
                                      return __pyx_r;
                                      __pyx_L180_resume_from_await:;
                                      __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                      __pyx_cur_scope->__pyx_t_0 = 0;
                                      __Pyx_XGOTREF(__pyx_t_1);
                                      __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                      __pyx_cur_scope->__pyx_t_1 = 0;
                                      __Pyx_XGOTREF(__pyx_t_2);
                                      __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                      __pyx_cur_scope->__pyx_t_2 = 0;
                                      __Pyx_XGOTREF(__pyx_t_3);
                                      __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                                      __pyx_cur_scope->__pyx_t_3 = 0;
                                      __Pyx_XGOTREF(__pyx_t_10);
                                      __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                                      __pyx_cur_scope->__pyx_t_4 = 0;
                                      __Pyx_XGOTREF(__pyx_t_12);
                                      __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                                      __pyx_cur_scope->__pyx_t_5 = 0;
                                      __Pyx_XGOTREF(__pyx_t_13);
                                      __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                                      __pyx_cur_scope->__pyx_t_6 = 0;
                                      __Pyx_XGOTREF(__pyx_t_14);
                                      __pyx_t_15 = __pyx_cur_scope->__pyx_t_7;
                                      __pyx_cur_scope->__pyx_t_7 = 0;
                                      __Pyx_XGOTREF(__pyx_t_15);
                                      __pyx_t_16 = __pyx_cur_scope->__pyx_t_8;
                                      __pyx_cur_scope->__pyx_t_8 = 0;
                                      __Pyx_XGOTREF(__pyx_t_16);
                                      __pyx_t_17 = __pyx_cur_scope->__pyx_t_9;
                                      __pyx_cur_scope->__pyx_t_9 = 0;
                                      __Pyx_XGOTREF(__pyx_t_17);
                                      __pyx_t_18 = __pyx_cur_scope->__pyx_t_10;
                                      __pyx_cur_scope->__pyx_t_10 = 0;
                                      __Pyx_XGOTREF(__pyx_t_18);
                                      __pyx_t_19 = __pyx_cur_scope->__pyx_t_11;
                                      __pyx_cur_scope->__pyx_t_11 = 0;
                                      __Pyx_XGOTREF(__pyx_t_19);
                                      __pyx_t_20 = __pyx_cur_scope->__pyx_t_12;
                                      __pyx_cur_scope->__pyx_t_12 = 0;
                                      __Pyx_XGOTREF(__pyx_t_20);
                                      __pyx_t_21 = __pyx_cur_scope->__pyx_t_13;
                                      __pyx_cur_scope->__pyx_t_13 = 0;
                                      __Pyx_XGOTREF(__pyx_t_21);
                                      __pyx_t_22 = __pyx_cur_scope->__pyx_t_14;
                                      __pyx_cur_scope->__pyx_t_14 = 0;
                                      __Pyx_XGOTREF(__pyx_t_22);
                                      __pyx_t_35 = __pyx_cur_scope->__pyx_t_18;
                                      __pyx_t_37 = __pyx_cur_scope->__pyx_t_15;
                                      __pyx_cur_scope->__pyx_t_15 = 0;
                                      __Pyx_XGOTREF(__pyx_t_37);
                                      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5082, __pyx_L149_error)
                                      __pyx_t_26 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_26);
                                    } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                      __Pyx_GOTREF(__pyx_r);
                                      __pyx_t_26 = __pyx_r; __pyx_r = NULL;
                                    } else {
                                      __Pyx_XGOTREF(__pyx_r);
                                      __PYX_ERR(0, 5082, __pyx_L149_error)
                                    }
                                    __pyx_t_37 = __pyx_t_26;
                                    __pyx_t_26 = 0;
                                    __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                                  }
                                  goto __pyx_L163;
                                }
                                __pyx_L160_break: {
                                  if (__pyx_t_20) {
                                    __pyx_t_37 = __Pyx_PyObject_Call(__pyx_t_20, __pyx_mstate_global->__pyx_tuple[7], NULL);
                                    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                                    if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 5082, __pyx_L149_error)
                                    __Pyx_GOTREF(__pyx_t_37);
                                    __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_37, &__pyx_r);
                                    __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                                    if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                      __Pyx_GOTREF(__pyx_r);
                                      __Pyx_XGIVEREF(__pyx_t_1);
                                      __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                      __Pyx_XGIVEREF(__pyx_t_2);
                                      __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                      __Pyx_XGIVEREF(__pyx_t_3);
                                      __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                      __Pyx_XGIVEREF(__pyx_t_10);
                                      __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                                      __Pyx_XGIVEREF(__pyx_t_12);
                                      __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                                      __Pyx_XGIVEREF(__pyx_t_13);
                                      __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                                      __Pyx_XGIVEREF(__pyx_t_14);
                                      __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                                      __Pyx_XGIVEREF(__pyx_t_15);
                                      __pyx_cur_scope->__pyx_t_7 = __pyx_t_15;
                                      __Pyx_XGIVEREF(__pyx_t_16);
                                      __pyx_cur_scope->__pyx_t_8 = __pyx_t_16;
                                      __Pyx_XGIVEREF(__pyx_t_17);
                                      __pyx_cur_scope->__pyx_t_9 = __pyx_t_17;
                                      __Pyx_XGIVEREF(__pyx_t_18);
                                      __pyx_cur_scope->__pyx_t_10 = __pyx_t_18;
                                      __Pyx_XGIVEREF(__pyx_t_19);
                                      __pyx_cur_scope->__pyx_t_11 = __pyx_t_19;
                                      __Pyx_XGIVEREF(__pyx_t_20);
                                      __pyx_cur_scope->__pyx_t_12 = __pyx_t_20;
                                      __Pyx_XGIVEREF(__pyx_t_21);
                                      __pyx_cur_scope->__pyx_t_13 = __pyx_t_21;
                                      __Pyx_XGIVEREF(__pyx_t_22);
                                      __pyx_cur_scope->__pyx_t_14 = __pyx_t_22;
                                      __pyx_cur_scope->__pyx_t_18 = __pyx_t_35;
                                      __Pyx_XGIVEREF(__pyx_t_37);
                                      __pyx_cur_scope->__pyx_t_15 = __pyx_t_37;
                                      __Pyx_XGIVEREF(__pyx_r);
                                      __Pyx_RefNannyFinishContext();
                                      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                                      /* return from generator, awaiting value */
                                      __pyx_generator->resume_label = 18;
                                      return __pyx_r;
                                      __pyx_L181_resume_from_await:;
                                      __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                      __pyx_cur_scope->__pyx_t_0 = 0;
                                      __Pyx_XGOTREF(__pyx_t_1);
                                      __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                      __pyx_cur_scope->__pyx_t_1 = 0;
                                      __Pyx_XGOTREF(__pyx_t_2);
                                      __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                      __pyx_cur_scope->__pyx_t_2 = 0;
                                      __Pyx_XGOTREF(__pyx_t_3);
                                      __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                                      __pyx_cur_scope->__pyx_t_3 = 0;
                                      __Pyx_XGOTREF(__pyx_t_10);
                                      __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                                      __pyx_cur_scope->__pyx_t_4 = 0;
                                      __Pyx_XGOTREF(__pyx_t_12);
                                      __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                                      __pyx_cur_scope->__pyx_t_5 = 0;
                                      __Pyx_XGOTREF(__pyx_t_13);
                                      __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                                      __pyx_cur_scope->__pyx_t_6 = 0;
                                      __Pyx_XGOTREF(__pyx_t_14);
                                      __pyx_t_15 = __pyx_cur_scope->__pyx_t_7;
                                      __pyx_cur_scope->__pyx_t_7 = 0;
                                      __Pyx_XGOTREF(__pyx_t_15);
                                      __pyx_t_16 = __pyx_cur_scope->__pyx_t_8;
                                      __pyx_cur_scope->__pyx_t_8 = 0;
                                      __Pyx_XGOTREF(__pyx_t_16);
                                      __pyx_t_17 = __pyx_cur_scope->__pyx_t_9;
                                      __pyx_cur_scope->__pyx_t_9 = 0;
                                      __Pyx_XGOTREF(__pyx_t_17);
                                      __pyx_t_18 = __pyx_cur_scope->__pyx_t_10;
                                      __pyx_cur_scope->__pyx_t_10 = 0;
                                      __Pyx_XGOTREF(__pyx_t_18);
                                      __pyx_t_19 = __pyx_cur_scope->__pyx_t_11;
                                      __pyx_cur_scope->__pyx_t_11 = 0;
                                      __Pyx_XGOTREF(__pyx_t_19);
                                      __pyx_t_20 = __pyx_cur_scope->__pyx_t_12;
                                      __pyx_cur_scope->__pyx_t_12 = 0;
                                      __Pyx_XGOTREF(__pyx_t_20);
                                      __pyx_t_21 = __pyx_cur_scope->__pyx_t_13;
                                      __pyx_cur_scope->__pyx_t_13 = 0;
                                      __Pyx_XGOTREF(__pyx_t_21);
                                      __pyx_t_22 = __pyx_cur_scope->__pyx_t_14;
                                      __pyx_cur_scope->__pyx_t_14 = 0;
                                      __Pyx_XGOTREF(__pyx_t_22);
                                      __pyx_t_35 = __pyx_cur_scope->__pyx_t_18;
                                      __pyx_t_37 = __pyx_cur_scope->__pyx_t_15;
                                      __pyx_cur_scope->__pyx_t_15 = 0;
                                      __Pyx_XGOTREF(__pyx_t_37);
                                      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5082, __pyx_L149_error)
                                      __pyx_t_26 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_26);
                                    } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                      __Pyx_GOTREF(__pyx_r);
                                      __pyx_t_26 = __pyx_r; __pyx_r = NULL;
                                    } else {
                                      __Pyx_XGOTREF(__pyx_r);
                                      __PYX_ERR(0, 5082, __pyx_L149_error)
                                    }
                                    __pyx_t_37 = __pyx_t_26;
                                    __pyx_t_26 = 0;
                                    __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                                  }
                                  goto __pyx_L154_try_break;
                                }
                                __pyx_L163:;
                              }
                              goto __pyx_L182;
                              __pyx_L157_error:;
                              __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                              goto __pyx_L149_error;
                              __pyx_L182:;
                            }

                            /* "ws_package/controllers/activity_controller.py":5081
 *                         for verify_attempt in range(max_verification_retries):
 *                             try:
 *                                 with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                                     async with async_session() as session:
 *                                         # Query for the interval by matching start_time, end_time, and counter
*/
                          }
                          __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                          __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                          __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                          goto __pyx_L156_try_end;
                          __pyx_L149_error:;
                          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                          __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                          __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                          __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                          __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                          __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                          __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                          __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                          /*except:*/ {
                            __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
                            if (__Pyx_GetException(&__pyx_t_26, &__pyx_t_23, &__pyx_t_24) < 0) __PYX_ERR(0, 5081, __pyx_L151_except_error)
                            __Pyx_XGOTREF(__pyx_t_26);
                            __Pyx_XGOTREF(__pyx_t_23);
                            __Pyx_XGOTREF(__pyx_t_24);
                            __pyx_t_6 = PyTuple_Pack(3, __pyx_t_26, __pyx_t_23, __pyx_t_24); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5081, __pyx_L151_except_error)
                            __Pyx_GOTREF(__pyx_t_6);
                            __pyx_t_20 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_6, NULL);
                            __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                            if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 5081, __pyx_L151_except_error)
                            __Pyx_GOTREF(__pyx_t_20);
                            __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_20);
                            __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                            if (__pyx_t_9 < (0)) __PYX_ERR(0, 5081, __pyx_L151_except_error)
                            __pyx_t_28 = (!__pyx_t_9);
                            if (unlikely(__pyx_t_28)) {
                              __Pyx_GIVEREF(__pyx_t_26);
                              __Pyx_GIVEREF(__pyx_t_23);
                              __Pyx_XGIVEREF(__pyx_t_24);
                              __Pyx_ErrRestoreWithState(__pyx_t_26, __pyx_t_23, __pyx_t_24);
                              __pyx_t_26 = 0;  __pyx_t_23 = 0;  __pyx_t_24 = 0; 
                              __PYX_ERR(0, 5081, __pyx_L151_except_error)
                            }
                            __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                            __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                            __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                            goto __pyx_L150_exception_handled;
                          }
                          __pyx_L151_except_error:;
                          __Pyx_XGIVEREF(__pyx_t_19);
                          __Pyx_XGIVEREF(__pyx_t_22);
                          __Pyx_XGIVEREF(__pyx_t_21);
                          __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_22, __pyx_t_21);
                          goto __pyx_L135_error;
                          __pyx_L154_try_break:;
                          __Pyx_XGIVEREF(__pyx_t_19);
                          __Pyx_XGIVEREF(__pyx_t_22);
                          __Pyx_XGIVEREF(__pyx_t_21);
                          __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_22, __pyx_t_21);
                          goto __pyx_L145_break;
                          __pyx_L150_exception_handled:;
                          __Pyx_XGIVEREF(__pyx_t_19);
                          __Pyx_XGIVEREF(__pyx_t_22);
                          __Pyx_XGIVEREF(__pyx_t_21);
                          __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_22, __pyx_t_21);
                          __pyx_L156_try_end:;
                        }
                      }
                      /*finally:*/ {
                        /*normal exit:*/{
                          if (__pyx_t_16) {
                            __pyx_t_21 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_mstate_global->__pyx_tuple[7], NULL);
                            __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                            if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 5081, __pyx_L135_error)
                            __Pyx_GOTREF(__pyx_t_21);
                            __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                          }
                          goto __pyx_L148;
                        }
                        __pyx_L145_break: {
                          if (__pyx_t_16) {
                            __pyx_t_21 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_mstate_global->__pyx_tuple[7], NULL);
                            __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                            if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 5081, __pyx_L135_error)
                            __Pyx_GOTREF(__pyx_t_21);
                            __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                          }
                          goto __pyx_L140_try_break;
                        }
                        __pyx_L148:;
                      }
                      goto __pyx_L186;
                      __pyx_L143_error:;
                      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                      goto __pyx_L135_error;
                      __pyx_L186:;
                    }

                    /* "ws_package/controllers/activity_controller.py":5080
 * 
 *                         for verify_attempt in range(max_verification_retries):
 *                             try:             # <<<<<<<<<<<<<<
 *                                 with db_lock_manager.read_lock():
 *                                     async with async_session() as session:
*/
                  }
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                  __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                  goto __pyx_L142_try_end;
                  __pyx_L135_error:;
                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                  __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                  __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                  __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                  __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                  __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

                  /* "ws_package/controllers/activity_controller.py":5099
 *                                             logger.info(" Verified last interval in database: id=%s, start_time=%s, end_time=%s, counter=%s", db_interval.id, db_interval.start_time, db_interval.end_time, db_interval.counter)
 *                                             break
 *                             except Exception as verify_error:             # <<<<<<<<<<<<<<
 *                                 logger.warning("Error verifying last interval in database (attempt %s/%s): %s", verify_attempt + 1, max_verification_retries, verify_error)
 * 
*/
                  __pyx_t_31 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                  if (__pyx_t_31) {
                    __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
                    if (__Pyx_GetException(&__pyx_t_24, &__pyx_t_23, &__pyx_t_26) < 0) __PYX_ERR(0, 5099, __pyx_L137_except_error)
                    __Pyx_XGOTREF(__pyx_t_24);
                    __Pyx_XGOTREF(__pyx_t_23);
                    __Pyx_XGOTREF(__pyx_t_26);
                    __Pyx_INCREF(__pyx_t_23);
                    __Pyx_GIVEREF(__pyx_t_23);
                    __pyx_cur_scope->__pyx_v_verify_error = __pyx_t_23;
                    /*try:*/ {

                      /* "ws_package/controllers/activity_controller.py":5100
 *                                             break
 *                             except Exception as verify_error:
 *                                 logger.warning("Error verifying last interval in database (attempt %s/%s): %s", verify_attempt + 1, max_verification_retries, verify_error)             # <<<<<<<<<<<<<<
 * 
 *                             if verify_attempt < max_verification_retries - 1:
*/
                      __pyx_t_25 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5100, __pyx_L192_error)
                      __Pyx_GOTREF(__pyx_t_7);
                      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5100, __pyx_L192_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                      __pyx_t_7 = __Pyx_PyLong_AddObjC(__pyx_cur_scope->__pyx_v_verify_attempt, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5100, __pyx_L192_error)
                      __Pyx_GOTREF(__pyx_t_7);
                      __pyx_t_8 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_4))) {
                        __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_4);
                        assert(__pyx_t_25);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                        __Pyx_INCREF(__pyx_t_25);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                        __pyx_t_8 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[5] = {__pyx_t_25, __pyx_mstate_global->__pyx_kp_u_Error_verifying_last_interval_in, __pyx_t_7, __pyx_cur_scope->__pyx_v_max_verification_retries, __pyx_cur_scope->__pyx_v_verify_error};
                        __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5100, __pyx_L192_error)
                        __Pyx_GOTREF(__pyx_t_6);
                      }
                      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    }

                    /* "ws_package/controllers/activity_controller.py":5099
 *                                             logger.info(" Verified last interval in database: id=%s, start_time=%s, end_time=%s, counter=%s", db_interval.id, db_interval.start_time, db_interval.end_time, db_interval.counter)
 *                                             break
 *                             except Exception as verify_error:             # <<<<<<<<<<<<<<
 *                                 logger.warning("Error verifying last interval in database (attempt %s/%s): %s", verify_attempt + 1, max_verification_retries, verify_error)
 * 
*/
                    /*finally:*/ {
                      /*normal exit:*/{
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_verify_error);
                        __Pyx_DECREF(__pyx_cur_scope->__pyx_v_verify_error); __pyx_cur_scope->__pyx_v_verify_error = 0;
                        goto __pyx_L193;
                      }
                      __pyx_L192_error:;
                      /*exception exit:*/{
                        __Pyx_PyThreadState_assign
                        __pyx_t_16 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_37 = 0;
                        __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                        __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                        __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                        __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                         __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_20, &__pyx_t_37);
                        if ( unlikely(__Pyx_GetException(&__pyx_t_16, &__pyx_t_21, &__pyx_t_22) < 0)) __Pyx_ErrFetch(&__pyx_t_16, &__pyx_t_21, &__pyx_t_22);
                        __Pyx_XGOTREF(__pyx_t_16);
                        __Pyx_XGOTREF(__pyx_t_21);
                        __Pyx_XGOTREF(__pyx_t_22);
                        __Pyx_XGOTREF(__pyx_t_19);
                        __Pyx_XGOTREF(__pyx_t_20);
                        __Pyx_XGOTREF(__pyx_t_37);
                        __pyx_t_31 = __pyx_lineno; __pyx_t_32 = __pyx_clineno; __pyx_t_42 = __pyx_filename;
                        {
                          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_verify_error);
                          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_verify_error); __pyx_cur_scope->__pyx_v_verify_error = 0;
                        }
                        __Pyx_XGIVEREF(__pyx_t_19);
                        __Pyx_XGIVEREF(__pyx_t_20);
                        __Pyx_XGIVEREF(__pyx_t_37);
                        __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_37);
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __Pyx_XGIVEREF(__pyx_t_22);
                        __Pyx_ErrRestore(__pyx_t_16, __pyx_t_21, __pyx_t_22);
                        __pyx_t_16 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_37 = 0;
                        __pyx_lineno = __pyx_t_31; __pyx_clineno = __pyx_t_32; __pyx_filename = __pyx_t_42;
                        goto __pyx_L137_except_error;
                      }
                      __pyx_L193:;
                    }
                    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                    __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                    goto __pyx_L136_exception_handled;
                  }
                  goto __pyx_L137_except_error;

                  /* "ws_package/controllers/activity_controller.py":5080
 * 
 *                         for verify_attempt in range(max_verification_retries):
 *                             try:             # <<<<<<<<<<<<<<
 *                                 with db_lock_manager.read_lock():
 *                                     async with async_session() as session:
*/
                  __pyx_L137_except_error:;
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __Pyx_XGIVEREF(__pyx_t_17);
                  __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_18, __pyx_t_17);
                  goto __pyx_L123_error;
                  __pyx_L140_try_break:;
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __Pyx_XGIVEREF(__pyx_t_17);
                  __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_18, __pyx_t_17);
                  goto __pyx_L134_break;
                  __pyx_L136_exception_handled:;
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __Pyx_XGIVEREF(__pyx_t_17);
                  __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_18, __pyx_t_17);
                  __pyx_L142_try_end:;
                }

                /* "ws_package/controllers/activity_controller.py":5102
 *                                 logger.warning("Error verifying last interval in database (attempt %s/%s): %s", verify_attempt + 1, max_verification_retries, verify_error)
 * 
 *                             if verify_attempt < max_verification_retries - 1:             # <<<<<<<<<<<<<<
 *                                 await asyncio.sleep(verification_delay)
 * 
*/
                __pyx_t_26 = __Pyx_PyLong_SubtractObjC(__pyx_cur_scope->__pyx_v_max_verification_retries, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5102, __pyx_L123_error)
                __Pyx_GOTREF(__pyx_t_26);
                __pyx_t_23 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_verify_attempt, __pyx_t_26, Py_LT); __Pyx_XGOTREF(__pyx_t_23); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5102, __pyx_L123_error)
                __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_23); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5102, __pyx_L123_error)
                __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                if (__pyx_t_28) {

                  /* "ws_package/controllers/activity_controller.py":5103
 * 
 *                             if verify_attempt < max_verification_retries - 1:
 *                                 await asyncio.sleep(verification_delay)             # <<<<<<<<<<<<<<
 * 
 *                         if not interval_verified:
*/
                  __pyx_t_26 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5103, __pyx_L123_error)
                  __Pyx_GOTREF(__pyx_t_24);
                  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5103, __pyx_L123_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                  __pyx_t_24 = PyFloat_FromDouble(__pyx_cur_scope->__pyx_v_verification_delay); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5103, __pyx_L123_error)
                  __Pyx_GOTREF(__pyx_t_24);
                  __pyx_t_8 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_6))) {
                    __pyx_t_26 = PyMethod_GET_SELF(__pyx_t_6);
                    assert(__pyx_t_26);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                    __Pyx_INCREF(__pyx_t_26);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                    __pyx_t_8 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_26, __pyx_t_24};
                    __pyx_t_23 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5103, __pyx_L123_error)
                    __Pyx_GOTREF(__pyx_t_23);
                  }
                  __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_23, &__pyx_r);
                  __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                  if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_XGIVEREF(__pyx_t_1);
                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                    __Pyx_XGIVEREF(__pyx_t_2);
                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                    __Pyx_XGIVEREF(__pyx_t_3);
                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                    __Pyx_XGIVEREF(__pyx_t_10);
                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                    __Pyx_XGIVEREF(__pyx_t_12);
                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                    __Pyx_XGIVEREF(__pyx_t_13);
                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                    __Pyx_XGIVEREF(__pyx_t_14);
                    __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                    __pyx_cur_scope->__pyx_t_18 = __pyx_t_35;
                    __Pyx_XGIVEREF(__pyx_r);
                    __Pyx_RefNannyFinishContext();
                    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                    /* return from generator, awaiting value */
                    __pyx_generator->resume_label = 19;
                    return __pyx_r;
                    __pyx_L199_resume_from_await:;
                    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                    __pyx_cur_scope->__pyx_t_0 = 0;
                    __Pyx_XGOTREF(__pyx_t_1);
                    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                    __pyx_cur_scope->__pyx_t_1 = 0;
                    __Pyx_XGOTREF(__pyx_t_2);
                    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                    __pyx_cur_scope->__pyx_t_2 = 0;
                    __Pyx_XGOTREF(__pyx_t_3);
                    __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                    __pyx_cur_scope->__pyx_t_3 = 0;
                    __Pyx_XGOTREF(__pyx_t_10);
                    __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                    __pyx_cur_scope->__pyx_t_4 = 0;
                    __Pyx_XGOTREF(__pyx_t_12);
                    __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                    __pyx_cur_scope->__pyx_t_5 = 0;
                    __Pyx_XGOTREF(__pyx_t_13);
                    __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                    __pyx_cur_scope->__pyx_t_6 = 0;
                    __Pyx_XGOTREF(__pyx_t_14);
                    __pyx_t_35 = __pyx_cur_scope->__pyx_t_18;
                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5103, __pyx_L123_error)
                  } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                  } else {
                    __Pyx_XGOTREF(__pyx_r);
                    __PYX_ERR(0, 5103, __pyx_L123_error)
                  }

                  /* "ws_package/controllers/activity_controller.py":5102
 *                                 logger.warning("Error verifying last interval in database (attempt %s/%s): %s", verify_attempt + 1, max_verification_retries, verify_error)
 * 
 *                             if verify_attempt < max_verification_retries - 1:             # <<<<<<<<<<<<<<
 *                                 await asyncio.sleep(verification_delay)
 * 
*/
                }

                /* "ws_package/controllers/activity_controller.py":5079
 *                         interval_verified = False
 * 
 *                         for verify_attempt in range(max_verification_retries):             # <<<<<<<<<<<<<<
 *                             try:
 *                                 with db_lock_manager.read_lock():
*/
              }
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              goto __pyx_L200_for_end;
              __pyx_L134_break:;
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              goto __pyx_L200_for_end;
              __pyx_L200_for_end:;

              /* "ws_package/controllers/activity_controller.py":5105
 *                                 await asyncio.sleep(verification_delay)
 * 
 *                         if not interval_verified:             # <<<<<<<<<<<<<<
 *                             logger.error(" CRITICAL: Last interval not found in database after %s attempts. Interval may not be committed!", max_verification_retries)
 *                             logger.error("   Last interval details: start_time=%s, end_time=%s, counter=%s", last_interval.start_time, last_interval.end_time, last_interval.counter)
*/
              __pyx_t_28 = (!__pyx_cur_scope->__pyx_v_interval_verified);
              if (__pyx_t_28) {

                /* "ws_package/controllers/activity_controller.py":5106
 * 
 *                         if not interval_verified:
 *                             logger.error(" CRITICAL: Last interval not found in database after %s attempts. Interval may not be committed!", max_verification_retries)             # <<<<<<<<<<<<<<
 *                             logger.error("   Last interval details: start_time=%s, end_time=%s, counter=%s", last_interval.start_time, last_interval.end_time, last_interval.counter)
 *                         else:
*/
                __pyx_t_23 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5106, __pyx_L123_error)
                __Pyx_GOTREF(__pyx_t_6);
                __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5106, __pyx_L123_error)
                __Pyx_GOTREF(__pyx_t_24);
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_24))) {
                  __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_24);
                  assert(__pyx_t_23);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_24);
                  __Pyx_INCREF(__pyx_t_23);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_24, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_23, __pyx_mstate_global->__pyx_kp_u_CRITICAL_Last_interval_not_foun, __pyx_cur_scope->__pyx_v_max_verification_retries};
                  __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_24, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                  __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                  if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5106, __pyx_L123_error)
                  __Pyx_GOTREF(__pyx_t_10);
                }
                __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

                /* "ws_package/controllers/activity_controller.py":5107
 *                         if not interval_verified:
 *                             logger.error(" CRITICAL: Last interval not found in database after %s attempts. Interval may not be committed!", max_verification_retries)
 *                             logger.error("   Last interval details: start_time=%s, end_time=%s, counter=%s", last_interval.start_time, last_interval.end_time, last_interval.counter)             # <<<<<<<<<<<<<<
 *                         else:
 *                             logger.info(" Last interval verified and has database ID: %s", last_interval_id)
*/
                __pyx_t_24 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5107, __pyx_L123_error)
                __Pyx_GOTREF(__pyx_t_23);
                __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5107, __pyx_L123_error)
                __Pyx_GOTREF(__pyx_t_6);
                __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5107, __pyx_L123_error)
                __Pyx_GOTREF(__pyx_t_23);
                __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5107, __pyx_L123_error)
                __Pyx_GOTREF(__pyx_t_26);
                __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5107, __pyx_L123_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_6))) {
                  __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_6);
                  assert(__pyx_t_24);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                  __Pyx_INCREF(__pyx_t_24);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[5] = {__pyx_t_24, __pyx_mstate_global->__pyx_kp_u_Last_interval_details_start_tim, __pyx_t_23, __pyx_t_26, __pyx_t_4};
                  __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                  __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                  __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5107, __pyx_L123_error)
                  __Pyx_GOTREF(__pyx_t_10);
                }
                __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

                /* "ws_package/controllers/activity_controller.py":5105
 *                                 await asyncio.sleep(verification_delay)
 * 
 *                         if not interval_verified:             # <<<<<<<<<<<<<<
 *                             logger.error(" CRITICAL: Last interval not found in database after %s attempts. Interval may not be committed!", max_verification_retries)
 *                             logger.error("   Last interval details: start_time=%s, end_time=%s, counter=%s", last_interval.start_time, last_interval.end_time, last_interval.counter)
*/
                goto __pyx_L201;
              }

              /* "ws_package/controllers/activity_controller.py":5109
 *                             logger.error("   Last interval details: start_time=%s, end_time=%s, counter=%s", last_interval.start_time, last_interval.end_time, last_interval.counter)
 *                         else:
 *                             logger.info(" Last interval verified and has database ID: %s", last_interval_id)             # <<<<<<<<<<<<<<
 * 
 *                 except Exception as e:
*/
              /*else*/ {
                __pyx_t_6 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5109, __pyx_L123_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5109, __pyx_L123_error)
                __Pyx_GOTREF(__pyx_t_26);
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_26))) {
                  __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_26);
                  assert(__pyx_t_6);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_26);
                  __Pyx_INCREF(__pyx_t_6);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_26, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Last_interval_verified_and_has, __pyx_cur_scope->__pyx_v_last_interval_id};
                  __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_26, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                  if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5109, __pyx_L123_error)
                  __Pyx_GOTREF(__pyx_t_10);
                }
                __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              }
              __pyx_L201:;

              /* "ws_package/controllers/activity_controller.py":5074
 *                     # CRITICAL: Verify the last interval is actually in the database with an ID
 *                     # This ensures the interval exists before we try to query for it
 *                     if last_interval:             # <<<<<<<<<<<<<<
 *                         max_verification_retries = 5
 *                         verification_delay = 0.5
*/
            }

            /* "ws_package/controllers/activity_controller.py":5055
 *                 self.has_on_demand = False
 *                 # Flush immediately to ensure last interval is committed before sending to server
 *                 try:             # <<<<<<<<<<<<<<
 *                     # Check if there are items in the queue before processing
 *                     activity_queue_size = db_write_queue.get_queue_size(WriteOperationType.ACTIVITY_INTERVAL)
*/
          }
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          goto __pyx_L128_try_end;
          __pyx_L123_error:;
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
          __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
          __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
          __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
          __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
          __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "ws_package/controllers/activity_controller.py":5111
 *                             logger.info(" Last interval verified and has database ID: %s", last_interval_id)
 * 
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Error flushing database write queue after last interval: %s", e, exc_info=True)
 *             else:
*/
          __pyx_t_32 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
          if (__pyx_t_32) {
            __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_10, &__pyx_t_26, &__pyx_t_6) < 0) __PYX_ERR(0, 5111, __pyx_L125_except_error)
            __Pyx_XGOTREF(__pyx_t_10);
            __Pyx_XGOTREF(__pyx_t_26);
            __Pyx_XGOTREF(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_26);
            __Pyx_GIVEREF(__pyx_t_26);
            __pyx_cur_scope->__pyx_v_e = __pyx_t_26;
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":5112
 * 
 *                 except Exception as e:
 *                     logger.error("Error flushing database write queue after last interval: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 *             else:
 *                 # time_diff <= 0 or was skipped for small gap
*/
              __pyx_t_23 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5112, __pyx_L207_error)
              __Pyx_GOTREF(__pyx_t_24);
              __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5112, __pyx_L207_error)
              __Pyx_GOTREF(__pyx_t_7);
              __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_7))) {
                __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_7);
                assert(__pyx_t_23);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                __Pyx_INCREF(__pyx_t_23);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_23, __pyx_mstate_global->__pyx_kp_u_Error_flushing_database_write_qu_2, __pyx_cur_scope->__pyx_v_e};
                __pyx_t_24 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5112, __pyx_L207_error)
                __Pyx_GOTREF(__pyx_t_24);
                if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_24, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 5112, __pyx_L207_error)
                __pyx_t_4 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_24);
                __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5112, __pyx_L207_error)
                __Pyx_GOTREF(__pyx_t_4);
              }
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            }

            /* "ws_package/controllers/activity_controller.py":5111
 *                             logger.info(" Last interval verified and has database ID: %s", last_interval_id)
 * 
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Error flushing database write queue after last interval: %s", e, exc_info=True)
 *             else:
*/
            /*finally:*/ {
              /*normal exit:*/{
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                goto __pyx_L208;
              }
              __pyx_L207_error:;
              /*exception exit:*/{
                __Pyx_PyThreadState_assign
                __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_15 = 0; __pyx_t_37 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
                __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                 __Pyx_ExceptionSwap(&__pyx_t_37, &__pyx_t_20, &__pyx_t_19);
                if ( unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_15) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_15);
                __Pyx_XGOTREF(__pyx_t_17);
                __Pyx_XGOTREF(__pyx_t_18);
                __Pyx_XGOTREF(__pyx_t_15);
                __Pyx_XGOTREF(__pyx_t_37);
                __Pyx_XGOTREF(__pyx_t_20);
                __Pyx_XGOTREF(__pyx_t_19);
                __pyx_t_32 = __pyx_lineno; __pyx_t_31 = __pyx_clineno; __pyx_t_43 = __pyx_filename;
                {
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                }
                __Pyx_XGIVEREF(__pyx_t_37);
                __Pyx_XGIVEREF(__pyx_t_20);
                __Pyx_XGIVEREF(__pyx_t_19);
                __Pyx_ExceptionReset(__pyx_t_37, __pyx_t_20, __pyx_t_19);
                __Pyx_XGIVEREF(__pyx_t_17);
                __Pyx_XGIVEREF(__pyx_t_18);
                __Pyx_XGIVEREF(__pyx_t_15);
                __Pyx_ErrRestore(__pyx_t_17, __pyx_t_18, __pyx_t_15);
                __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_15 = 0; __pyx_t_37 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
                __pyx_lineno = __pyx_t_32; __pyx_clineno = __pyx_t_31; __pyx_filename = __pyx_t_43;
                goto __pyx_L125_except_error;
              }
              __pyx_L208:;
            }
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            goto __pyx_L124_exception_handled;
          }
          goto __pyx_L125_except_error;

          /* "ws_package/controllers/activity_controller.py":5055
 *                 self.has_on_demand = False
 *                 # Flush immediately to ensure last interval is committed before sending to server
 *                 try:             # <<<<<<<<<<<<<<
 *                     # Check if there are items in the queue before processing
 *                     activity_queue_size = db_write_queue.get_queue_size(WriteOperationType.ACTIVITY_INTERVAL)
*/
          __pyx_L125_except_error:;
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
          goto __pyx_L4_error;
          __pyx_L124_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
          __pyx_L128_try_end:;
        }

        /* "ws_package/controllers/activity_controller.py":4982
 *                 last_interval_id = None
 *             # Always create the last interval if we have valid dates and gap is significant
 *             elif not trimmed_partial_used and time_diff_seconds > 10:             # <<<<<<<<<<<<<<
 *                 logger.info("Save last activity interval to DB (from %s to %s - actual stop time, duration: %ss)", start_date, end_date, time_diff_seconds)
 *                 # CRITICAL FIX FOR WINDOWS: Check if break has started (break_id is set)
*/
        goto __pyx_L85;
      }

      /* "ws_package/controllers/activity_controller.py":5115
 *             else:
 *                 # time_diff <= 0 or was skipped for small gap
 *                 if time_diff_seconds <= 0:             # <<<<<<<<<<<<<<
 *                     logger.error("Cannot create last interval: start_date=%s, end_date=%s, time_diff=%ss (time_diff <= 0)", start_date, end_date, time_diff_seconds)
 *                 # else: already logged skip message above
*/
      /*else*/ {
        __pyx_t_6 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_time_diff_seconds, __pyx_mstate_global->__pyx_int_0, Py_LE); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5115, __pyx_L4_error)
        __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5115, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (__pyx_t_28) {

          /* "ws_package/controllers/activity_controller.py":5116
 *                 # time_diff <= 0 or was skipped for small gap
 *                 if time_diff_seconds <= 0:
 *                     logger.error("Cannot create last interval: start_date=%s, end_date=%s, time_diff=%ss (time_diff <= 0)", start_date, end_date, time_diff_seconds)             # <<<<<<<<<<<<<<
 *                 # else: already logged skip message above
 *             # Additional flush before querying to ensure last interval is definitely committed
*/
          __pyx_t_26 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5116, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_10);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5116, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_4))) {
            __pyx_t_26 = PyMethod_GET_SELF(__pyx_t_4);
            assert(__pyx_t_26);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_26);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[5] = {__pyx_t_26, __pyx_mstate_global->__pyx_kp_u_Cannot_create_last_interval_star, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date, __pyx_cur_scope->__pyx_v_time_diff_seconds};
            __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5116, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_6);
          }
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

          /* "ws_package/controllers/activity_controller.py":5115
 *             else:
 *                 # time_diff <= 0 or was skipped for small gap
 *                 if time_diff_seconds <= 0:             # <<<<<<<<<<<<<<
 *                     logger.error("Cannot create last interval: start_date=%s, end_date=%s, time_diff=%ss (time_diff <= 0)", start_date, end_date, time_diff_seconds)
 *                 # else: already logged skip message above
*/
        }
      }
      __pyx_L85:;

      /* "ws_package/controllers/activity_controller.py":5120
 *             # Additional flush before querying to ensure last interval is definitely committed
 *             # Check queue again and process if needed
 *             logger.info("Checking queue status before querying intervals...")             # <<<<<<<<<<<<<<
 *             try:
 *                 # Check queue status
*/
      __pyx_t_4 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5120, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_26);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5120, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10);
        assert(__pyx_t_4);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Checking_queue_status_before_que};
        __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5120, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":5121
 *             # Check queue again and process if needed
 *             logger.info("Checking queue status before querying intervals...")
 *             try:             # <<<<<<<<<<<<<<
 *                 # Check queue status
 *                 activity_queue_size = db_write_queue.get_queue_size(WriteOperationType.ACTIVITY_INTERVAL)
*/
      {
        __Pyx_ExceptionSave(&__pyx_t_14, &__pyx_t_13, &__pyx_t_12);
        __Pyx_XGOTREF(__pyx_t_14);
        __Pyx_XGOTREF(__pyx_t_13);
        __Pyx_XGOTREF(__pyx_t_12);
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":5123
 *             try:
 *                 # Check queue status
 *                 activity_queue_size = db_write_queue.get_queue_size(WriteOperationType.ACTIVITY_INTERVAL)             # <<<<<<<<<<<<<<
 *                 total_queue_size = db_write_queue.get_total_queue_size()
 *                 logger.info("Queue status before final flush: ACTIVITY_INTERVAL=%s, Total=%s", activity_queue_size, total_queue_size)
*/
          __pyx_t_10 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_db_write_queue); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5123, __pyx_L214_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_get_queue_size); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5123, __pyx_L214_error)
          __Pyx_GOTREF(__pyx_t_26);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_WriteOperationType); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5123, __pyx_L214_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_ACTIVITY_INTERVAL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5123, __pyx_L214_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_26))) {
            __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_26);
            assert(__pyx_t_10);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_26);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_26, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_t_7};
            __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_26, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
            if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5123, __pyx_L214_error)
            __Pyx_GOTREF(__pyx_t_6);
          }
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_activity_queue_size);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_activity_queue_size, __pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_6);
          __pyx_t_6 = 0;

          /* "ws_package/controllers/activity_controller.py":5124
 *                 # Check queue status
 *                 activity_queue_size = db_write_queue.get_queue_size(WriteOperationType.ACTIVITY_INTERVAL)
 *                 total_queue_size = db_write_queue.get_total_queue_size()             # <<<<<<<<<<<<<<
 *                 logger.info("Queue status before final flush: ACTIVITY_INTERVAL=%s, Total=%s", activity_queue_size, total_queue_size)
 * 
*/
          __pyx_t_26 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_db_write_queue); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5124, __pyx_L214_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_get_total_queue_size); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5124, __pyx_L214_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_10))) {
            __pyx_t_26 = PyMethod_GET_SELF(__pyx_t_10);
            assert(__pyx_t_26);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
            __Pyx_INCREF(__pyx_t_26);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_26, NULL};
            __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5124, __pyx_L214_error)
            __Pyx_GOTREF(__pyx_t_6);
          }
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_total_queue_size);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_total_queue_size, __pyx_t_6);
          __Pyx_GIVEREF(__pyx_t_6);
          __pyx_t_6 = 0;

          /* "ws_package/controllers/activity_controller.py":5125
 *                 activity_queue_size = db_write_queue.get_queue_size(WriteOperationType.ACTIVITY_INTERVAL)
 *                 total_queue_size = db_write_queue.get_total_queue_size()
 *                 logger.info("Queue status before final flush: ACTIVITY_INTERVAL=%s, Total=%s", activity_queue_size, total_queue_size)             # <<<<<<<<<<<<<<
 * 
 *                 if total_queue_size > 0:
*/
          __pyx_t_10 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5125, __pyx_L214_error)
          __Pyx_GOTREF(__pyx_t_26);
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5125, __pyx_L214_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_7))) {
            __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7);
            assert(__pyx_t_10);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[4] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Queue_status_before_final_flush, __pyx_cur_scope->__pyx_v_activity_queue_size, __pyx_cur_scope->__pyx_v_total_queue_size};
            __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5125, __pyx_L214_error)
            __Pyx_GOTREF(__pyx_t_6);
          }
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

          /* "ws_package/controllers/activity_controller.py":5127
 *                 logger.info("Queue status before final flush: ACTIVITY_INTERVAL=%s, Total=%s", activity_queue_size, total_queue_size)
 * 
 *                 if total_queue_size > 0:             # <<<<<<<<<<<<<<
 *                     logger.info("Processing %s remaining queue items immediately before querying...", total_queue_size)
 *                     processed_count = await db_writer_service.process_immediately()
*/
          __pyx_t_6 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_total_queue_size, __pyx_mstate_global->__pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5127, __pyx_L214_error)
          __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5127, __pyx_L214_error)
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (__pyx_t_28) {

            /* "ws_package/controllers/activity_controller.py":5128
 * 
 *                 if total_queue_size > 0:
 *                     logger.info("Processing %s remaining queue items immediately before querying...", total_queue_size)             # <<<<<<<<<<<<<<
 *                     processed_count = await db_writer_service.process_immediately()
 *                     logger.info("Flushed %s queued database writes, last interval should now be committed", processed_count)
*/
            __pyx_t_7 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5128, __pyx_L214_error)
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5128, __pyx_L214_error)
            __Pyx_GOTREF(__pyx_t_26);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_26))) {
              __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_26);
              assert(__pyx_t_7);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_26);
              __Pyx_INCREF(__pyx_t_7);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_26, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Processing_s_remaining_queue_ite, __pyx_cur_scope->__pyx_v_total_queue_size};
              __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_26, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
              __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
              if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5128, __pyx_L214_error)
              __Pyx_GOTREF(__pyx_t_6);
            }
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

            /* "ws_package/controllers/activity_controller.py":5129
 *                 if total_queue_size > 0:
 *                     logger.info("Processing %s remaining queue items immediately before querying...", total_queue_size)
 *                     processed_count = await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 *                     logger.info("Flushed %s queued database writes, last interval should now be committed", processed_count)
 *                 else:
*/
            __pyx_t_26 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5129, __pyx_L214_error)
            __Pyx_GOTREF(__pyx_t_7);
            __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5129, __pyx_L214_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_10))) {
              __pyx_t_26 = PyMethod_GET_SELF(__pyx_t_10);
              assert(__pyx_t_26);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
              __Pyx_INCREF(__pyx_t_26);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_26, NULL};
              __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5129, __pyx_L214_error)
              __Pyx_GOTREF(__pyx_t_6);
            }
            __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_6, &__pyx_r);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (likely(__pyx_t_11 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_1);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
              __Pyx_XGIVEREF(__pyx_t_2);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
              __Pyx_XGIVEREF(__pyx_t_3);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
              __Pyx_XGIVEREF(__pyx_t_12);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
              __Pyx_XGIVEREF(__pyx_t_13);
              __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
              __Pyx_XGIVEREF(__pyx_t_14);
              __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 20;
              return __pyx_r;
              __pyx_L221_resume_from_await:;
              __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_1);
              __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_2);
              __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_3);
              __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_12);
              __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
              __pyx_cur_scope->__pyx_t_4 = 0;
              __Pyx_XGOTREF(__pyx_t_13);
              __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
              __pyx_cur_scope->__pyx_t_5 = 0;
              __Pyx_XGOTREF(__pyx_t_14);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5129, __pyx_L214_error)
              __pyx_t_6 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_6);
            } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __pyx_t_6 = __pyx_r; __pyx_r = NULL;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 5129, __pyx_L214_error)
            }
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_processed_count);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_processed_count, __pyx_t_6);
            __Pyx_GIVEREF(__pyx_t_6);
            __pyx_t_6 = 0;

            /* "ws_package/controllers/activity_controller.py":5130
 *                     logger.info("Processing %s remaining queue items immediately before querying...", total_queue_size)
 *                     processed_count = await db_writer_service.process_immediately()
 *                     logger.info("Flushed %s queued database writes, last interval should now be committed", processed_count)             # <<<<<<<<<<<<<<
 *                 else:
 *                     logger.info("Queue is empty - all items already processed")
*/
            __pyx_t_10 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5130, __pyx_L214_error)
            __Pyx_GOTREF(__pyx_t_26);
            __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5130, __pyx_L214_error)
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_7))) {
              __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7);
              assert(__pyx_t_10);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
              __Pyx_INCREF(__pyx_t_10);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Flushed_s_queued_database_writes_3, __pyx_cur_scope->__pyx_v_processed_count};
              __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5130, __pyx_L214_error)
              __Pyx_GOTREF(__pyx_t_6);
            }
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

            /* "ws_package/controllers/activity_controller.py":5127
 *                 logger.info("Queue status before final flush: ACTIVITY_INTERVAL=%s, Total=%s", activity_queue_size, total_queue_size)
 * 
 *                 if total_queue_size > 0:             # <<<<<<<<<<<<<<
 *                     logger.info("Processing %s remaining queue items immediately before querying...", total_queue_size)
 *                     processed_count = await db_writer_service.process_immediately()
*/
            goto __pyx_L220;
          }

          /* "ws_package/controllers/activity_controller.py":5132
 *                     logger.info("Flushed %s queued database writes, last interval should now be committed", processed_count)
 *                 else:
 *                     logger.info("Queue is empty - all items already processed")             # <<<<<<<<<<<<<<
 * 
 *                 # Give database more time to ensure commit is visible (1.5 seconds)
*/
          /*else*/ {
            __pyx_t_7 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5132, __pyx_L214_error)
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5132, __pyx_L214_error)
            __Pyx_GOTREF(__pyx_t_26);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_26))) {
              __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_26);
              assert(__pyx_t_7);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_26);
              __Pyx_INCREF(__pyx_t_7);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_26, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Queue_is_empty_all_items_already};
              __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_26, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
              __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
              if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5132, __pyx_L214_error)
              __Pyx_GOTREF(__pyx_t_6);
            }
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          }
          __pyx_L220:;

          /* "ws_package/controllers/activity_controller.py":5135
 * 
 *                 # Give database more time to ensure commit is visible (1.5 seconds)
 *                 logger.info("Waiting 1.5 seconds for database commit to be fully visible before querying...")             # <<<<<<<<<<<<<<
 *                 await asyncio.sleep(1.5)
 *             except Exception as e:
*/
          __pyx_t_26 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5135, __pyx_L214_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5135, __pyx_L214_error)
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_10))) {
            __pyx_t_26 = PyMethod_GET_SELF(__pyx_t_10);
            assert(__pyx_t_26);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
            __Pyx_INCREF(__pyx_t_26);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_26, __pyx_mstate_global->__pyx_kp_u_Waiting_1_5_seconds_for_database};
            __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5135, __pyx_L214_error)
            __Pyx_GOTREF(__pyx_t_6);
          }
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

          /* "ws_package/controllers/activity_controller.py":5136
 *                 # Give database more time to ensure commit is visible (1.5 seconds)
 *                 logger.info("Waiting 1.5 seconds for database commit to be fully visible before querying...")
 *                 await asyncio.sleep(1.5)             # <<<<<<<<<<<<<<
 *             except Exception as e:
 *                 logger.error("Error flushing database write queue before fetch: %s", e, exc_info=True)
*/
          __pyx_t_10 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5136, __pyx_L214_error)
          __Pyx_GOTREF(__pyx_t_26);
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5136, __pyx_L214_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_7))) {
            __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7);
            assert(__pyx_t_10);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_mstate_global->__pyx_float_1_5};
            __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5136, __pyx_L214_error)
            __Pyx_GOTREF(__pyx_t_6);
          }
          __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_6, &__pyx_r);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (likely(__pyx_t_11 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_1);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
            __Pyx_XGIVEREF(__pyx_t_2);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
            __Pyx_XGIVEREF(__pyx_t_3);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
            __Pyx_XGIVEREF(__pyx_t_12);
            __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
            __Pyx_XGIVEREF(__pyx_t_13);
            __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
            __Pyx_XGIVEREF(__pyx_t_14);
            __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 21;
            return __pyx_r;
            __pyx_L222_resume_from_await:;
            __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_1);
            __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_2);
            __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_3);
            __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
            __pyx_cur_scope->__pyx_t_3 = 0;
            __Pyx_XGOTREF(__pyx_t_12);
            __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
            __pyx_cur_scope->__pyx_t_4 = 0;
            __Pyx_XGOTREF(__pyx_t_13);
            __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
            __pyx_cur_scope->__pyx_t_5 = 0;
            __Pyx_XGOTREF(__pyx_t_14);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5136, __pyx_L214_error)
          } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_DECREF(__pyx_r); __pyx_r = 0;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 5136, __pyx_L214_error)
          }

          /* "ws_package/controllers/activity_controller.py":5121
 *             # Check queue again and process if needed
 *             logger.info("Checking queue status before querying intervals...")
 *             try:             # <<<<<<<<<<<<<<
 *                 # Check queue status
 *                 activity_queue_size = db_write_queue.get_queue_size(WriteOperationType.ACTIVITY_INTERVAL)
*/
        }
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        goto __pyx_L219_try_end;
        __pyx_L214_error:;
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
        __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
        __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
        __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
        __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
        __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
        __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "ws_package/controllers/activity_controller.py":5137
 *                 logger.info("Waiting 1.5 seconds for database commit to be fully visible before querying...")
 *                 await asyncio.sleep(1.5)
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 logger.error("Error flushing database write queue before fetch: %s", e, exc_info=True)
 * 
*/
        __pyx_t_31 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
        if (__pyx_t_31) {
          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_7, &__pyx_t_10) < 0) __PYX_ERR(0, 5137, __pyx_L216_except_error)
          __Pyx_XGOTREF(__pyx_t_6);
          __Pyx_XGOTREF(__pyx_t_7);
          __Pyx_XGOTREF(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_GIVEREF(__pyx_t_7);
          __pyx_cur_scope->__pyx_v_e = __pyx_t_7;
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":5138
 *                 await asyncio.sleep(1.5)
 *             except Exception as e:
 *                 logger.error("Error flushing database write queue before fetch: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *             logger.info("Collecting and sending unsend activity intervals to server in last API call")
*/
            __pyx_t_4 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5138, __pyx_L228_error)
            __Pyx_GOTREF(__pyx_t_24);
            __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5138, __pyx_L228_error)
            __Pyx_GOTREF(__pyx_t_23);
            __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_23))) {
              __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_23);
              assert(__pyx_t_4);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_23);
              __Pyx_INCREF(__pyx_t_4);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_23, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Error_flushing_database_write_qu_3, __pyx_cur_scope->__pyx_v_e};
              __pyx_t_24 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5138, __pyx_L228_error)
              __Pyx_GOTREF(__pyx_t_24);
              if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_24, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 5138, __pyx_L228_error)
              __pyx_t_26 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_23, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_24);
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
              if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5138, __pyx_L228_error)
              __Pyx_GOTREF(__pyx_t_26);
            }
            __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
          }

          /* "ws_package/controllers/activity_controller.py":5137
 *                 logger.info("Waiting 1.5 seconds for database commit to be fully visible before querying...")
 *                 await asyncio.sleep(1.5)
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 logger.error("Error flushing database write queue before fetch: %s", e, exc_info=True)
 * 
*/
          /*finally:*/ {
            /*normal exit:*/{
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
              goto __pyx_L229;
            }
            __pyx_L228_error:;
            /*exception exit:*/{
              __Pyx_PyThreadState_assign
              __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_37 = 0; __pyx_t_15 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0;
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
              __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
              __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
              __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
              __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
               __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_18, &__pyx_t_17);
              if ( unlikely(__Pyx_GetException(&__pyx_t_19, &__pyx_t_20, &__pyx_t_37) < 0)) __Pyx_ErrFetch(&__pyx_t_19, &__pyx_t_20, &__pyx_t_37);
              __Pyx_XGOTREF(__pyx_t_19);
              __Pyx_XGOTREF(__pyx_t_20);
              __Pyx_XGOTREF(__pyx_t_37);
              __Pyx_XGOTREF(__pyx_t_15);
              __Pyx_XGOTREF(__pyx_t_18);
              __Pyx_XGOTREF(__pyx_t_17);
              __pyx_t_31 = __pyx_lineno; __pyx_t_32 = __pyx_clineno; __pyx_t_44 = __pyx_filename;
              {
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
              }
              __Pyx_XGIVEREF(__pyx_t_15);
              __Pyx_XGIVEREF(__pyx_t_18);
              __Pyx_XGIVEREF(__pyx_t_17);
              __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_18, __pyx_t_17);
              __Pyx_XGIVEREF(__pyx_t_19);
              __Pyx_XGIVEREF(__pyx_t_20);
              __Pyx_XGIVEREF(__pyx_t_37);
              __Pyx_ErrRestore(__pyx_t_19, __pyx_t_20, __pyx_t_37);
              __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_37 = 0; __pyx_t_15 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0;
              __pyx_lineno = __pyx_t_31; __pyx_clineno = __pyx_t_32; __pyx_filename = __pyx_t_44;
              goto __pyx_L216_except_error;
            }
            __pyx_L229:;
          }
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          goto __pyx_L215_exception_handled;
        }
        goto __pyx_L216_except_error;

        /* "ws_package/controllers/activity_controller.py":5121
 *             # Check queue again and process if needed
 *             logger.info("Checking queue status before querying intervals...")
 *             try:             # <<<<<<<<<<<<<<
 *                 # Check queue status
 *                 activity_queue_size = db_write_queue.get_queue_size(WriteOperationType.ACTIVITY_INTERVAL)
*/
        __pyx_L216_except_error:;
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12);
        goto __pyx_L4_error;
        __pyx_L215_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12);
        __pyx_L219_try_end:;
      }

      /* "ws_package/controllers/activity_controller.py":5140
 *                 logger.error("Error flushing database write queue before fetch: %s", e, exc_info=True)
 * 
 *             logger.info("Collecting and sending unsend activity intervals to server in last API call")             # <<<<<<<<<<<<<<
 *             # CRITICAL: Filter by current session counter to prevent picking intervals from previous sessions
 *             current_session_counter = self.last_count + 1
*/
      __pyx_t_7 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5140, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5140, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_26);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_26))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_26);
        assert(__pyx_t_7);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_26);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_26, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Collecting_and_sending_unsend_ac};
        __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_26, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
        if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5140, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
      }
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

      /* "ws_package/controllers/activity_controller.py":5142
 *             logger.info("Collecting and sending unsend activity intervals to server in last API call")
 *             # CRITICAL: Filter by current session counter to prevent picking intervals from previous sessions
 *             current_session_counter = self.last_count + 1             # <<<<<<<<<<<<<<
 *             logger.info("Filtering intervals by current session counter=%s", current_session_counter)
 * 
*/
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5142, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_26 = __Pyx_PyLong_AddObjC(__pyx_t_10, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5142, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_26);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_GIVEREF(__pyx_t_26);
      __pyx_cur_scope->__pyx_v_current_session_counter = __pyx_t_26;
      __pyx_t_26 = 0;

      /* "ws_package/controllers/activity_controller.py":5143
 *             # CRITICAL: Filter by current session counter to prevent picking intervals from previous sessions
 *             current_session_counter = self.last_count + 1
 *             logger.info("Filtering intervals by current session counter=%s", current_session_counter)             # <<<<<<<<<<<<<<
 * 
 *             # Query all unsent intervals from current session only (counter filter applied at database level)
*/
      __pyx_t_10 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5143, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5143, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6);
        assert(__pyx_t_10);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_10);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Filtering_intervals_by_current_s, __pyx_cur_scope->__pyx_v_current_session_counter};
        __pyx_t_26 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5143, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_26);
      }
      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;

      /* "ws_package/controllers/activity_controller.py":5146
 * 
 *             # Query all unsent intervals from current session only (counter filter applied at database level)
 *             intervals = await self.activity_service.get_activity_intervals(None, None, counter=current_session_counter)             # <<<<<<<<<<<<<<
 *             logger.info("Found %s unsent intervals from current session (counter=%s)", len(intervals) if intervals else 0, current_session_counter)
 * 
*/
      __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5146, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_26);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_get_activity_intervals); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5146, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
      __pyx_t_26 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5146, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_26);
      if (PyDict_SetItem(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_counter, __pyx_cur_scope->__pyx_v_current_session_counter) < (0)) __PYX_ERR(0, 5146, __pyx_L4_error)
      __pyx_t_10 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_mstate_global->__pyx_tuple[30], __pyx_t_26); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5146, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
      __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_10, &__pyx_r);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      if (likely(__pyx_t_11 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
        __Pyx_XGIVEREF(__pyx_t_2);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
        __Pyx_XGIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 22;
        return __pyx_r;
        __pyx_L234_resume_from_await:;
        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_1);
        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_2);
        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_3);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5146, __pyx_L4_error)
        __pyx_t_10 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_10);
      } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __pyx_t_10 = __pyx_r; __pyx_r = NULL;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 5146, __pyx_L4_error)
      }
      __Pyx_GIVEREF(__pyx_t_10);
      __pyx_cur_scope->__pyx_v_intervals = __pyx_t_10;
      __pyx_t_10 = 0;

      /* "ws_package/controllers/activity_controller.py":5147
 *             # Query all unsent intervals from current session only (counter filter applied at database level)
 *             intervals = await self.activity_service.get_activity_intervals(None, None, counter=current_session_counter)
 *             logger.info("Found %s unsent intervals from current session (counter=%s)", len(intervals) if intervals else 0, current_session_counter)             # <<<<<<<<<<<<<<
 * 
 *             # If we just saved a last interval, ensure it's included in the results with retry logic
*/
      __pyx_t_26 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5147, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5147, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_intervals); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5147, __pyx_L4_error)
      if (__pyx_t_28) {
        __pyx_t_45 = PyObject_Length(__pyx_cur_scope->__pyx_v_intervals); if (unlikely(__pyx_t_45 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5147, __pyx_L4_error)
        __pyx_t_23 = PyLong_FromSsize_t(__pyx_t_45); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5147, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_23);
        __pyx_t_6 = __pyx_t_23;
        __pyx_t_23 = 0;
      } else {
        __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
        __pyx_t_6 = __pyx_mstate_global->__pyx_int_0;
      }
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_26 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_26);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_26);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[4] = {__pyx_t_26, __pyx_mstate_global->__pyx_kp_u_Found_s_unsent_intervals_from_cu, __pyx_t_6, __pyx_cur_scope->__pyx_v_current_session_counter};
        __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5147, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
      }
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

      /* "ws_package/controllers/activity_controller.py":5152
 *             # Retry up to 3 times with increasing delays if the interval isn't found
 *             # CRITICAL: Only include last_interval if keep_idle_time is True (or if it was a break interval that needed upload)
 *             if last_interval and (keep_idle_time or should_upload):             # <<<<<<<<<<<<<<
 *                 max_retries = 3
 *                 retry_delays = [1.0, 1.5, 2.0]  # Increasing delays: 1s, 1.5s, 2s
*/
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 5152, __pyx_L4_error)
      if (__pyx_t_9) {
      } else {
        __pyx_t_28 = __pyx_t_9;
        goto __pyx_L236_bool_binop_done;
      }
      if (!__pyx_cur_scope->__pyx_v_keep_idle_time) {
      } else {
        __pyx_t_28 = __pyx_cur_scope->__pyx_v_keep_idle_time;
        goto __pyx_L236_bool_binop_done;
      }
      __pyx_t_28 = __pyx_cur_scope->__pyx_v_should_upload;
      __pyx_L236_bool_binop_done:;
      if (__pyx_t_28) {

        /* "ws_package/controllers/activity_controller.py":5153
 *             # CRITICAL: Only include last_interval if keep_idle_time is True (or if it was a break interval that needed upload)
 *             if last_interval and (keep_idle_time or should_upload):
 *                 max_retries = 3             # <<<<<<<<<<<<<<
 *                 retry_delays = [1.0, 1.5, 2.0]  # Increasing delays: 1s, 1.5s, 2s
 *                 last_interval_found = False
*/
        __Pyx_INCREF(__pyx_mstate_global->__pyx_int_3);
        __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_3);
        __pyx_cur_scope->__pyx_v_max_retries = __pyx_mstate_global->__pyx_int_3;

        /* "ws_package/controllers/activity_controller.py":5154
 *             if last_interval and (keep_idle_time or should_upload):
 *                 max_retries = 3
 *                 retry_delays = [1.0, 1.5, 2.0]  # Increasing delays: 1s, 1.5s, 2s             # <<<<<<<<<<<<<<
 *                 last_interval_found = False
 * 
*/
        __pyx_t_10 = PyList_New(3); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5154, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_INCREF(__pyx_mstate_global->__pyx_float_1_0);
        __Pyx_GIVEREF(__pyx_mstate_global->__pyx_float_1_0);
        if (__Pyx_PyList_SET_ITEM(__pyx_t_10, 0, __pyx_mstate_global->__pyx_float_1_0) != (0)) __PYX_ERR(0, 5154, __pyx_L4_error);
        __Pyx_INCREF(__pyx_mstate_global->__pyx_float_1_5);
        __Pyx_GIVEREF(__pyx_mstate_global->__pyx_float_1_5);
        if (__Pyx_PyList_SET_ITEM(__pyx_t_10, 1, __pyx_mstate_global->__pyx_float_1_5) != (0)) __PYX_ERR(0, 5154, __pyx_L4_error);
        __Pyx_INCREF(__pyx_mstate_global->__pyx_float_2_0);
        __Pyx_GIVEREF(__pyx_mstate_global->__pyx_float_2_0);
        if (__Pyx_PyList_SET_ITEM(__pyx_t_10, 2, __pyx_mstate_global->__pyx_float_2_0) != (0)) __PYX_ERR(0, 5154, __pyx_L4_error);
        __Pyx_GIVEREF(__pyx_t_10);
        __pyx_cur_scope->__pyx_v_retry_delays = ((PyObject*)__pyx_t_10);
        __pyx_t_10 = 0;

        /* "ws_package/controllers/activity_controller.py":5155
 *                 max_retries = 3
 *                 retry_delays = [1.0, 1.5, 2.0]  # Increasing delays: 1s, 1.5s, 2s
 *                 last_interval_found = False             # <<<<<<<<<<<<<<
 * 
 *                 # Helper function to compare datetimes with tolerance (1 second) to handle precision differences
*/
        __Pyx_INCREF(Py_False);
        __Pyx_GIVEREF(Py_False);
        __pyx_cur_scope->__pyx_v_last_interval_found = Py_False;

        /* "ws_package/controllers/activity_controller.py":5158
 * 
 *                 # Helper function to compare datetimes with tolerance (1 second) to handle precision differences
 *                 def datetime_matches(dt1, dt2, tolerance_seconds=1.0):             # <<<<<<<<<<<<<<
 *                     """Check if two datetimes match within tolerance"""
 *                     if dt1 is None or dt2 is None:
*/
        __pyx_t_10 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_1datetime_matches, 0, __pyx_mstate_global->__pyx_n_u_ActivityController__last_api_cal_3, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[60])); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5158, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_10, __pyx_mstate_global->__pyx_tuple[28]);
        __Pyx_GIVEREF(__pyx_t_10);
        __pyx_cur_scope->__pyx_v_datetime_matches = __pyx_t_10;
        __pyx_t_10 = 0;

        /* "ws_package/controllers/activity_controller.py":5168
 *                         return False
 * 
 *                 for attempt in range(max_retries):             # <<<<<<<<<<<<<<
 *                     if intervals:
 *                         # Check if last_interval is in the results using tolerance-based comparison
*/
        __pyx_t_7 = NULL;
        __pyx_t_8 = 1;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_cur_scope->__pyx_v_max_retries};
          __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)(&PyRange_Type), __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5168, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_10);
        }
        __pyx_t_7 = PyObject_GetIter(__pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5168, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_35 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_7); if (unlikely(!__pyx_t_35)) __PYX_ERR(0, 5168, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        for (;;) {
          {
            __pyx_t_10 = __pyx_t_35(__pyx_t_7);
            if (unlikely(!__pyx_t_10)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 5168, __pyx_L4_error)
                PyErr_Clear();
              }
              break;
            }
          }
          __Pyx_GOTREF(__pyx_t_10);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_attempt);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_attempt, __pyx_t_10);
          __Pyx_GIVEREF(__pyx_t_10);
          __pyx_t_10 = 0;

          /* "ws_package/controllers/activity_controller.py":5169
 * 
 *                 for attempt in range(max_retries):
 *                     if intervals:             # <<<<<<<<<<<<<<
 *                         # Check if last_interval is in the results using tolerance-based comparison
 *                         # This handles datetime precision differences between saved and queried intervals
*/
          __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_intervals); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5169, __pyx_L4_error)
          if (__pyx_t_28) {

            /* "ws_package/controllers/activity_controller.py":5173
 *                         # This handles datetime precision differences between saved and queried intervals
 *                         last_interval_found = any(
 *                             datetime_matches(getattr(interval, 'start_time', None), last_interval.start_time) and             # <<<<<<<<<<<<<<
 *                             datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                             getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
*/
            __pyx_t_10 = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_4genexpr(((PyObject*)__pyx_cur_scope), __pyx_cur_scope->__pyx_v_intervals); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5173, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_6 = __Pyx_Generator_GetInlinedResult(__pyx_t_10); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5173, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_last_interval_found);
            __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_last_interval_found, __pyx_t_6);
            __Pyx_GIVEREF(__pyx_t_6);
            __pyx_t_6 = 0;

            /* "ws_package/controllers/activity_controller.py":5178
 *                             for interval in intervals
 *                         )
 *                         if last_interval_found:             # <<<<<<<<<<<<<<
 *                             logger.info("Last interval found in query results (attempt %s)", attempt + 1)
 *                             break
*/
            __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval_found); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5178, __pyx_L4_error)
            if (__pyx_t_28) {

              /* "ws_package/controllers/activity_controller.py":5179
 *                         )
 *                         if last_interval_found:
 *                             logger.info("Last interval found in query results (attempt %s)", attempt + 1)             # <<<<<<<<<<<<<<
 *                             break
 * 
*/
              __pyx_t_10 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5179, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_26);
              __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5179, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_23);
              __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
              __pyx_t_26 = __Pyx_PyLong_AddObjC(__pyx_cur_scope->__pyx_v_attempt, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5179, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_26);
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_23))) {
                __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_23);
                assert(__pyx_t_10);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_23);
                __Pyx_INCREF(__pyx_t_10);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_23, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Last_interval_found_in_query_res, __pyx_t_26};
                __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_23, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5179, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_6);
              }
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

              /* "ws_package/controllers/activity_controller.py":5180
 *                         if last_interval_found:
 *                             logger.info("Last interval found in query results (attempt %s)", attempt + 1)
 *                             break             # <<<<<<<<<<<<<<
 * 
 *                     if attempt < max_retries - 1:
*/
              goto __pyx_L240_break;

              /* "ws_package/controllers/activity_controller.py":5178
 *                             for interval in intervals
 *                         )
 *                         if last_interval_found:             # <<<<<<<<<<<<<<
 *                             logger.info("Last interval found in query results (attempt %s)", attempt + 1)
 *                             break
*/
            }

            /* "ws_package/controllers/activity_controller.py":5169
 * 
 *                 for attempt in range(max_retries):
 *                     if intervals:             # <<<<<<<<<<<<<<
 *                         # Check if last_interval is in the results using tolerance-based comparison
 *                         # This handles datetime precision differences between saved and queried intervals
*/
          }

          /* "ws_package/controllers/activity_controller.py":5182
 *                             break
 * 
 *                     if attempt < max_retries - 1:             # <<<<<<<<<<<<<<
 *                         logger.warning("Last interval not found in query results (attempt %s/%s) - waiting %ss and re-querying...", attempt + 1, max_retries, retry_delays[attempt])
 *                         logger.warning("Last interval details: start_time=%s, end_time=%s, counter=%s", last_interval.start_time, last_interval.end_time, last_interval.counter if hasattr(last_interval, 'counter') else 'N/A')
*/
          __pyx_t_6 = __Pyx_PyLong_SubtractObjC(__pyx_cur_scope->__pyx_v_max_retries, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5182, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_23 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_attempt, __pyx_t_6, Py_LT); __Pyx_XGOTREF(__pyx_t_23); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5182, __pyx_L4_error)
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_23); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5182, __pyx_L4_error)
          __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
          if (__pyx_t_28) {

            /* "ws_package/controllers/activity_controller.py":5183
 * 
 *                     if attempt < max_retries - 1:
 *                         logger.warning("Last interval not found in query results (attempt %s/%s) - waiting %ss and re-querying...", attempt + 1, max_retries, retry_delays[attempt])             # <<<<<<<<<<<<<<
 *                         logger.warning("Last interval details: start_time=%s, end_time=%s, counter=%s", last_interval.start_time, last_interval.end_time, last_interval.counter if hasattr(last_interval, 'counter') else 'N/A')
 *                         await asyncio.sleep(retry_delays[attempt])
*/
            __pyx_t_6 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5183, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_26);
            __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5183, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
            __pyx_t_26 = __Pyx_PyLong_AddObjC(__pyx_cur_scope->__pyx_v_attempt, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5183, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_26);
            __pyx_t_24 = __Pyx_PyObject_GetItem(__pyx_cur_scope->__pyx_v_retry_delays, __pyx_cur_scope->__pyx_v_attempt); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5183, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_24);
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_10))) {
              __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_10);
              assert(__pyx_t_6);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
              __Pyx_INCREF(__pyx_t_6);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[5] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Last_interval_not_found_in_query, __pyx_t_26, __pyx_cur_scope->__pyx_v_max_retries, __pyx_t_24};
              __pyx_t_23 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
              __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5183, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_23);
            }
            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

            /* "ws_package/controllers/activity_controller.py":5184
 *                     if attempt < max_retries - 1:
 *                         logger.warning("Last interval not found in query results (attempt %s/%s) - waiting %ss and re-querying...", attempt + 1, max_retries, retry_delays[attempt])
 *                         logger.warning("Last interval details: start_time=%s, end_time=%s, counter=%s", last_interval.start_time, last_interval.end_time, last_interval.counter if hasattr(last_interval, 'counter') else 'N/A')             # <<<<<<<<<<<<<<
 *                         await asyncio.sleep(retry_delays[attempt])
 *                         # Re-query with counter filter applied at database level
*/
            __pyx_t_10 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5184, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_24);
            __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5184, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_26);
            __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
            __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5184, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_24);
            __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5184, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_25 = __pyx_cur_scope->__pyx_v_last_interval;
            __Pyx_INCREF(__pyx_t_25);
            __pyx_t_28 = __Pyx_HasAttr(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(__pyx_t_28 == ((int)-1))) __PYX_ERR(0, 5184, __pyx_L4_error)
            __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
            if (__pyx_t_28) {
              __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5184, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_25);
              __pyx_t_4 = __pyx_t_25;
              __pyx_t_25 = 0;
            } else {
              __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_N_A);
              __pyx_t_4 = __pyx_mstate_global->__pyx_kp_u_N_A;
            }
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_26))) {
              __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_26);
              assert(__pyx_t_10);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_26);
              __Pyx_INCREF(__pyx_t_10);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_26, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[5] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Last_interval_details_start_time, __pyx_t_24, __pyx_t_6, __pyx_t_4};
              __pyx_t_23 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_26, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
              if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5184, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_23);
            }
            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

            /* "ws_package/controllers/activity_controller.py":5185
 *                         logger.warning("Last interval not found in query results (attempt %s/%s) - waiting %ss and re-querying...", attempt + 1, max_retries, retry_delays[attempt])
 *                         logger.warning("Last interval details: start_time=%s, end_time=%s, counter=%s", last_interval.start_time, last_interval.end_time, last_interval.counter if hasattr(last_interval, 'counter') else 'N/A')
 *                         await asyncio.sleep(retry_delays[attempt])             # <<<<<<<<<<<<<<
 *                         # Re-query with counter filter applied at database level
 *                         intervals = await self.activity_service.get_activity_intervals(None, None, counter=current_session_counter)
*/
            __pyx_t_26 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5185, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5185, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __pyx_t_4 = __Pyx_PyObject_GetItem(__pyx_cur_scope->__pyx_v_retry_delays, __pyx_cur_scope->__pyx_v_attempt); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5185, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_6))) {
              __pyx_t_26 = PyMethod_GET_SELF(__pyx_t_6);
              assert(__pyx_t_26);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
              __Pyx_INCREF(__pyx_t_26);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_26, __pyx_t_4};
              __pyx_t_23 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5185, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_23);
            }
            __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_23, &__pyx_r);
            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
            if (likely(__pyx_t_11 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_1);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
              __Pyx_XGIVEREF(__pyx_t_2);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
              __Pyx_XGIVEREF(__pyx_t_3);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
              __Pyx_XGIVEREF(__pyx_t_7);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_7;
              __pyx_cur_scope->__pyx_t_18 = __pyx_t_35;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 23;
              return __pyx_r;
              __pyx_L244_resume_from_await:;
              __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_1);
              __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_2);
              __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_3);
              __pyx_t_7 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_7);
              __pyx_t_35 = __pyx_cur_scope->__pyx_t_18;
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5185, __pyx_L4_error)
            } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_DECREF(__pyx_r); __pyx_r = 0;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 5185, __pyx_L4_error)
            }

            /* "ws_package/controllers/activity_controller.py":5187
 *                         await asyncio.sleep(retry_delays[attempt])
 *                         # Re-query with counter filter applied at database level
 *                         intervals = await self.activity_service.get_activity_intervals(None, None, counter=current_session_counter)             # <<<<<<<<<<<<<<
 *                         logger.info("Re-queried after delay: Found %s intervals from current session (counter=%s)", len(intervals) if intervals else 0, current_session_counter)
 *                     else:
*/
            __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5187, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_23);
            __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_get_activity_intervals); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5187, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
            __pyx_t_23 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5187, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_23);
            if (PyDict_SetItem(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_counter, __pyx_cur_scope->__pyx_v_current_session_counter) < (0)) __PYX_ERR(0, 5187, __pyx_L4_error)
            __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_mstate_global->__pyx_tuple[30], __pyx_t_23); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5187, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
            __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (likely(__pyx_t_11 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_1);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
              __Pyx_XGIVEREF(__pyx_t_2);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
              __Pyx_XGIVEREF(__pyx_t_3);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
              __Pyx_XGIVEREF(__pyx_t_7);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_7;
              __pyx_cur_scope->__pyx_t_18 = __pyx_t_35;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 24;
              return __pyx_r;
              __pyx_L245_resume_from_await:;
              __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_1);
              __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_2);
              __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_3);
              __pyx_t_7 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_7);
              __pyx_t_35 = __pyx_cur_scope->__pyx_t_18;
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5187, __pyx_L4_error)
              __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
            } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __pyx_t_4 = __pyx_r; __pyx_r = NULL;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 5187, __pyx_L4_error)
            }
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_intervals);
            __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_intervals, __pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_4);
            __pyx_t_4 = 0;

            /* "ws_package/controllers/activity_controller.py":5188
 *                         # Re-query with counter filter applied at database level
 *                         intervals = await self.activity_service.get_activity_intervals(None, None, counter=current_session_counter)
 *                         logger.info("Re-queried after delay: Found %s intervals from current session (counter=%s)", len(intervals) if intervals else 0, current_session_counter)             # <<<<<<<<<<<<<<
 *                     else:
 *                         logger.warning("Last interval still not found after %s attempts - will manually include it in results", max_retries)
*/
            __pyx_t_23 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5188, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5188, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_26);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_intervals); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5188, __pyx_L4_error)
            if (__pyx_t_28) {
              __pyx_t_45 = PyObject_Length(__pyx_cur_scope->__pyx_v_intervals); if (unlikely(__pyx_t_45 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5188, __pyx_L4_error)
              __pyx_t_24 = PyLong_FromSsize_t(__pyx_t_45); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5188, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_24);
              __pyx_t_6 = __pyx_t_24;
              __pyx_t_24 = 0;
            } else {
              __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
              __pyx_t_6 = __pyx_mstate_global->__pyx_int_0;
            }
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_26))) {
              __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_26);
              assert(__pyx_t_23);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_26);
              __Pyx_INCREF(__pyx_t_23);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_26, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[4] = {__pyx_t_23, __pyx_mstate_global->__pyx_kp_u_Re_queried_after_delay_Found_s_i, __pyx_t_6, __pyx_cur_scope->__pyx_v_current_session_counter};
              __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_26, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5188, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_4);
            }
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

            /* "ws_package/controllers/activity_controller.py":5182
 *                             break
 * 
 *                     if attempt < max_retries - 1:             # <<<<<<<<<<<<<<
 *                         logger.warning("Last interval not found in query results (attempt %s/%s) - waiting %ss and re-querying...", attempt + 1, max_retries, retry_delays[attempt])
 *                         logger.warning("Last interval details: start_time=%s, end_time=%s, counter=%s", last_interval.start_time, last_interval.end_time, last_interval.counter if hasattr(last_interval, 'counter') else 'N/A')
*/
            goto __pyx_L243;
          }

          /* "ws_package/controllers/activity_controller.py":5190
 *                         logger.info("Re-queried after delay: Found %s intervals from current session (counter=%s)", len(intervals) if intervals else 0, current_session_counter)
 *                     else:
 *                         logger.warning("Last interval still not found after %s attempts - will manually include it in results", max_retries)             # <<<<<<<<<<<<<<
 *                         logger.warning("Last interval details: start_time=%s, end_time=%s, counter=%s", last_interval.start_time, last_interval.end_time, last_interval.counter if hasattr(last_interval, 'counter') else 'N/A')
 *                         # Log all intervals found for debugging
*/
          /*else*/ {
            __pyx_t_26 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5190, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5190, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_23);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_23))) {
              __pyx_t_26 = PyMethod_GET_SELF(__pyx_t_23);
              assert(__pyx_t_26);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_23);
              __Pyx_INCREF(__pyx_t_26);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_23, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_26, __pyx_mstate_global->__pyx_kp_u_Last_interval_still_not_found_af, __pyx_cur_scope->__pyx_v_max_retries};
              __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_23, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
              __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5190, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_4);
            }
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

            /* "ws_package/controllers/activity_controller.py":5191
 *                     else:
 *                         logger.warning("Last interval still not found after %s attempts - will manually include it in results", max_retries)
 *                         logger.warning("Last interval details: start_time=%s, end_time=%s, counter=%s", last_interval.start_time, last_interval.end_time, last_interval.counter if hasattr(last_interval, 'counter') else 'N/A')             # <<<<<<<<<<<<<<
 *                         # Log all intervals found for debugging
 *                         if intervals:
*/
            __pyx_t_23 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5191, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_26);
            __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5191, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
            __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5191, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_26);
            __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5191, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_24);
            __pyx_t_25 = __pyx_cur_scope->__pyx_v_last_interval;
            __Pyx_INCREF(__pyx_t_25);
            __pyx_t_28 = __Pyx_HasAttr(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(__pyx_t_28 == ((int)-1))) __PYX_ERR(0, 5191, __pyx_L4_error)
            __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
            if (__pyx_t_28) {
              __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5191, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_25);
              __pyx_t_10 = __pyx_t_25;
              __pyx_t_25 = 0;
            } else {
              __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_N_A);
              __pyx_t_10 = __pyx_mstate_global->__pyx_kp_u_N_A;
            }
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_6))) {
              __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_6);
              assert(__pyx_t_23);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
              __Pyx_INCREF(__pyx_t_23);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[5] = {__pyx_t_23, __pyx_mstate_global->__pyx_kp_u_Last_interval_details_start_time, __pyx_t_26, __pyx_t_24, __pyx_t_10};
              __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
              __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5191, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_4);
            }
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

            /* "ws_package/controllers/activity_controller.py":5193
 *                         logger.warning("Last interval details: start_time=%s, end_time=%s, counter=%s", last_interval.start_time, last_interval.end_time, last_interval.counter if hasattr(last_interval, 'counter') else 'N/A')
 *                         # Log all intervals found for debugging
 *                         if intervals:             # <<<<<<<<<<<<<<
 *                             logger.info("Intervals found in database (first 5):")
 *                             for idx, interval in enumerate(intervals[:5]):
*/
            __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_intervals); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5193, __pyx_L4_error)
            if (__pyx_t_28) {

              /* "ws_package/controllers/activity_controller.py":5194
 *                         # Log all intervals found for debugging
 *                         if intervals:
 *                             logger.info("Intervals found in database (first 5):")             # <<<<<<<<<<<<<<
 *                             for idx, interval in enumerate(intervals[:5]):
 *                                 logger.info("  Interval %s: start_time=%s, end_time=%s, is_uploaded=%s, counter=%s", idx+1, getattr(interval, 'start_time', 'N/A'), getattr(interval, 'end_time', 'N/A'), getattr(interval, 'is_uploaded', 'N/A'), getattr(interval, 'counter', 'N/A'))
*/
              __pyx_t_6 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5194, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_10);
              __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5194, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_24);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_24))) {
                __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_24);
                assert(__pyx_t_6);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_24);
                __Pyx_INCREF(__pyx_t_6);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_24, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Intervals_found_in_database_firs};
                __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_24, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5194, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_4);
              }
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

              /* "ws_package/controllers/activity_controller.py":5195
 *                         if intervals:
 *                             logger.info("Intervals found in database (first 5):")
 *                             for idx, interval in enumerate(intervals[:5]):             # <<<<<<<<<<<<<<
 *                                 logger.info("  Interval %s: start_time=%s, end_time=%s, is_uploaded=%s, counter=%s", idx+1, getattr(interval, 'start_time', 'N/A'), getattr(interval, 'end_time', 'N/A'), getattr(interval, 'is_uploaded', 'N/A'), getattr(interval, 'counter', 'N/A'))
 *                         else:
*/
              __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
              __pyx_t_4 = __pyx_mstate_global->__pyx_int_0;
              __pyx_t_24 = __Pyx_PyObject_GetSlice(__pyx_cur_scope->__pyx_v_intervals, 0, 5, NULL, NULL, &__pyx_mstate_global->__pyx_slice[3], 0, 1, 0); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5195, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_24);
              if (likely(PyList_CheckExact(__pyx_t_24)) || PyTuple_CheckExact(__pyx_t_24)) {
                __pyx_t_6 = __pyx_t_24; __Pyx_INCREF(__pyx_t_6);
                __pyx_t_45 = 0;
                __pyx_t_46 = NULL;
              } else {
                __pyx_t_45 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_24); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5195, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_6);
                __pyx_t_46 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_46)) __PYX_ERR(0, 5195, __pyx_L4_error)
              }
              __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
              for (;;) {
                if (likely(!__pyx_t_46)) {
                  if (likely(PyList_CheckExact(__pyx_t_6))) {
                    {
                      Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
                      #if !CYTHON_ASSUME_SAFE_SIZE
                      if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5195, __pyx_L4_error)
                      #endif
                      if (__pyx_t_45 >= __pyx_temp) break;
                    }
                    __pyx_t_24 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_6, __pyx_t_45, __Pyx_ReferenceSharing_OwnStrongReference);
                    ++__pyx_t_45;
                  } else {
                    {
                      Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6);
                      #if !CYTHON_ASSUME_SAFE_SIZE
                      if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5195, __pyx_L4_error)
                      #endif
                      if (__pyx_t_45 >= __pyx_temp) break;
                    }
                    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                    __pyx_t_24 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_45));
                    #else
                    __pyx_t_24 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_45);
                    #endif
                    ++__pyx_t_45;
                  }
                  if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5195, __pyx_L4_error)
                } else {
                  __pyx_t_24 = __pyx_t_46(__pyx_t_6);
                  if (unlikely(!__pyx_t_24)) {
                    PyObject* exc_type = PyErr_Occurred();
                    if (exc_type) {
                      if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 5195, __pyx_L4_error)
                      PyErr_Clear();
                    }
                    break;
                  }
                }
                __Pyx_GOTREF(__pyx_t_24);
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_24);
                __Pyx_GIVEREF(__pyx_t_24);
                __pyx_t_24 = 0;
                __Pyx_INCREF(__pyx_t_4);
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_idx);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_idx, __pyx_t_4);
                __Pyx_GIVEREF(__pyx_t_4);
                __pyx_t_24 = __Pyx_PyLong_AddObjC(__pyx_t_4, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5195, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_24);
                __Pyx_DECREF(__pyx_t_4);
                __pyx_t_4 = __pyx_t_24;
                __pyx_t_24 = 0;

                /* "ws_package/controllers/activity_controller.py":5196
 *                             logger.info("Intervals found in database (first 5):")
 *                             for idx, interval in enumerate(intervals[:5]):
 *                                 logger.info("  Interval %s: start_time=%s, end_time=%s, is_uploaded=%s, counter=%s", idx+1, getattr(interval, 'start_time', 'N/A'), getattr(interval, 'end_time', 'N/A'), getattr(interval, 'is_uploaded', 'N/A'), getattr(interval, 'counter', 'N/A'))             # <<<<<<<<<<<<<<
 *                         else:
 *                             logger.warning("No intervals found in database at all - this is unexpected")
*/
                __pyx_t_10 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5196, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_26);
                __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5196, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_23);
                __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                __pyx_t_26 = __Pyx_PyLong_AddObjC(__pyx_cur_scope->__pyx_v_idx, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5196, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_26);
                __pyx_t_25 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_start_time, __pyx_mstate_global->__pyx_kp_u_N_A); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5196, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_25);
                __pyx_t_40 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time, __pyx_mstate_global->__pyx_kp_u_N_A); if (unlikely(!__pyx_t_40)) __PYX_ERR(0, 5196, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_40);
                __pyx_t_39 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_is_uploaded, __pyx_mstate_global->__pyx_kp_u_N_A); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5196, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_39);
                __pyx_t_5 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_counter, __pyx_mstate_global->__pyx_kp_u_N_A); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5196, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_5);
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_23))) {
                  __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_23);
                  assert(__pyx_t_10);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_23);
                  __Pyx_INCREF(__pyx_t_10);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_23, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[7] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Interval_s_start_time_s_end_tim, __pyx_t_26, __pyx_t_25, __pyx_t_40, __pyx_t_39, __pyx_t_5};
                  __pyx_t_24 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_23, __pyx_callargs+__pyx_t_8, (7-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                  __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                  __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                  __Pyx_DECREF(__pyx_t_40); __pyx_t_40 = 0;
                  __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                  if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5196, __pyx_L4_error)
                  __Pyx_GOTREF(__pyx_t_24);
                }
                __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;

                /* "ws_package/controllers/activity_controller.py":5195
 *                         if intervals:
 *                             logger.info("Intervals found in database (first 5):")
 *                             for idx, interval in enumerate(intervals[:5]):             # <<<<<<<<<<<<<<
 *                                 logger.info("  Interval %s: start_time=%s, end_time=%s, is_uploaded=%s, counter=%s", idx+1, getattr(interval, 'start_time', 'N/A'), getattr(interval, 'end_time', 'N/A'), getattr(interval, 'is_uploaded', 'N/A'), getattr(interval, 'counter', 'N/A'))
 *                         else:
*/
              }
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

              /* "ws_package/controllers/activity_controller.py":5193
 *                         logger.warning("Last interval details: start_time=%s, end_time=%s, counter=%s", last_interval.start_time, last_interval.end_time, last_interval.counter if hasattr(last_interval, 'counter') else 'N/A')
 *                         # Log all intervals found for debugging
 *                         if intervals:             # <<<<<<<<<<<<<<
 *                             logger.info("Intervals found in database (first 5):")
 *                             for idx, interval in enumerate(intervals[:5]):
*/
              goto __pyx_L246;
            }

            /* "ws_package/controllers/activity_controller.py":5198
 *                                 logger.info("  Interval %s: start_time=%s, end_time=%s, is_uploaded=%s, counter=%s", idx+1, getattr(interval, 'start_time', 'N/A'), getattr(interval, 'end_time', 'N/A'), getattr(interval, 'is_uploaded', 'N/A'), getattr(interval, 'counter', 'N/A'))
 *                         else:
 *                             logger.warning("No intervals found in database at all - this is unexpected")             # <<<<<<<<<<<<<<
 * 
 * 
*/
            /*else*/ {
              __pyx_t_6 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5198, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_24);
              __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5198, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_23);
              __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_23))) {
                __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_23);
                assert(__pyx_t_6);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_23);
                __Pyx_INCREF(__pyx_t_6);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_23, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_No_intervals_found_in_database_a};
                __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_23, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5198, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_4);
              }
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            }
            __pyx_L246:;
          }
          __pyx_L243:;

          /* "ws_package/controllers/activity_controller.py":5168
 *                         return False
 * 
 *                 for attempt in range(max_retries):             # <<<<<<<<<<<<<<
 *                     if intervals:
 *                         # Check if last_interval is in the results using tolerance-based comparison
*/
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L250_for_end;
        __pyx_L240_break:;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        goto __pyx_L250_for_end;
        __pyx_L250_for_end:;

        /* "ws_package/controllers/activity_controller.py":5208
 *                 # ALSO: Do NOT include sleep intervals (long gaps with zero activity) even if they meet the above conditions
 *                 # ALSO: Do NOT include intervals that were explicitly saved with is_uploaded=True
 *                 if not last_interval_found and (keep_idle_time or should_upload):             # <<<<<<<<<<<<<<
 *                     # NEW: First check if interval was saved with is_uploaded=True - if so, don't include it
 *                     interval_is_uploaded = False
*/
        __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval_found); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 5208, __pyx_L4_error)
        __pyx_t_47 = (!__pyx_t_9);
        if (__pyx_t_47) {
        } else {
          __pyx_t_28 = __pyx_t_47;
          goto __pyx_L252_bool_binop_done;
        }
        if (!__pyx_cur_scope->__pyx_v_keep_idle_time) {
        } else {
          __pyx_t_28 = __pyx_cur_scope->__pyx_v_keep_idle_time;
          goto __pyx_L252_bool_binop_done;
        }
        __pyx_t_28 = __pyx_cur_scope->__pyx_v_should_upload;
        __pyx_L252_bool_binop_done:;
        if (__pyx_t_28) {

          /* "ws_package/controllers/activity_controller.py":5210
 *                 if not last_interval_found and (keep_idle_time or should_upload):
 *                     # NEW: First check if interval was saved with is_uploaded=True - if so, don't include it
 *                     interval_is_uploaded = False             # <<<<<<<<<<<<<<
 *                     if last_interval:
 *                         try:
*/
          __pyx_cur_scope->__pyx_v_interval_is_uploaded = 0;

          /* "ws_package/controllers/activity_controller.py":5211
 *                     # NEW: First check if interval was saved with is_uploaded=True - if so, don't include it
 *                     interval_is_uploaded = False
 *                     if last_interval:             # <<<<<<<<<<<<<<
 *                         try:
 *                             if hasattr(last_interval, 'is_uploaded'):
*/
          __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5211, __pyx_L4_error)
          if (__pyx_t_28) {

            /* "ws_package/controllers/activity_controller.py":5212
 *                     interval_is_uploaded = False
 *                     if last_interval:
 *                         try:             # <<<<<<<<<<<<<<
 *                             if hasattr(last_interval, 'is_uploaded'):
 *                                 interval_is_uploaded = bool(last_interval.is_uploaded)
*/
            {
              __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
              __Pyx_XGOTREF(__pyx_t_12);
              __Pyx_XGOTREF(__pyx_t_13);
              __Pyx_XGOTREF(__pyx_t_14);
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":5213
 *                     if last_interval:
 *                         try:
 *                             if hasattr(last_interval, 'is_uploaded'):             # <<<<<<<<<<<<<<
 *                                 interval_is_uploaded = bool(last_interval.is_uploaded)
 *                             elif hasattr(last_interval, 'isUploaded'):
*/
                __pyx_t_7 = __pyx_cur_scope->__pyx_v_last_interval;
                __Pyx_INCREF(__pyx_t_7);
                __pyx_t_28 = __Pyx_HasAttr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_is_uploaded); if (unlikely(__pyx_t_28 == ((int)-1))) __PYX_ERR(0, 5213, __pyx_L256_error)
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                if (__pyx_t_28) {

                  /* "ws_package/controllers/activity_controller.py":5214
 *                         try:
 *                             if hasattr(last_interval, 'is_uploaded'):
 *                                 interval_is_uploaded = bool(last_interval.is_uploaded)             # <<<<<<<<<<<<<<
 *                             elif hasattr(last_interval, 'isUploaded'):
 *                                 interval_is_uploaded = bool(last_interval.isUploaded)
*/
                  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_is_uploaded); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5214, __pyx_L256_error)
                  __Pyx_GOTREF(__pyx_t_7);
                  __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5214, __pyx_L256_error)
                  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                  __pyx_cur_scope->__pyx_v_interval_is_uploaded = (!(!__pyx_t_28));

                  /* "ws_package/controllers/activity_controller.py":5213
 *                     if last_interval:
 *                         try:
 *                             if hasattr(last_interval, 'is_uploaded'):             # <<<<<<<<<<<<<<
 *                                 interval_is_uploaded = bool(last_interval.is_uploaded)
 *                             elif hasattr(last_interval, 'isUploaded'):
*/
                  goto __pyx_L262;
                }

                /* "ws_package/controllers/activity_controller.py":5215
 *                             if hasattr(last_interval, 'is_uploaded'):
 *                                 interval_is_uploaded = bool(last_interval.is_uploaded)
 *                             elif hasattr(last_interval, 'isUploaded'):             # <<<<<<<<<<<<<<
 *                                 interval_is_uploaded = bool(last_interval.isUploaded)
 *                         except Exception as e:
*/
                __pyx_t_7 = __pyx_cur_scope->__pyx_v_last_interval;
                __Pyx_INCREF(__pyx_t_7);
                __pyx_t_28 = __Pyx_HasAttr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_isUploaded); if (unlikely(__pyx_t_28 == ((int)-1))) __PYX_ERR(0, 5215, __pyx_L256_error)
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                if (__pyx_t_28) {

                  /* "ws_package/controllers/activity_controller.py":5216
 *                                 interval_is_uploaded = bool(last_interval.is_uploaded)
 *                             elif hasattr(last_interval, 'isUploaded'):
 *                                 interval_is_uploaded = bool(last_interval.isUploaded)             # <<<<<<<<<<<<<<
 *                         except Exception as e:
 *                             logger.debug("Could not check is_uploaded status for manual inclusion: %s", e)
*/
                  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_isUploaded); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5216, __pyx_L256_error)
                  __Pyx_GOTREF(__pyx_t_7);
                  __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5216, __pyx_L256_error)
                  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                  __pyx_cur_scope->__pyx_v_interval_is_uploaded = (!(!__pyx_t_28));

                  /* "ws_package/controllers/activity_controller.py":5215
 *                             if hasattr(last_interval, 'is_uploaded'):
 *                                 interval_is_uploaded = bool(last_interval.is_uploaded)
 *                             elif hasattr(last_interval, 'isUploaded'):             # <<<<<<<<<<<<<<
 *                                 interval_is_uploaded = bool(last_interval.isUploaded)
 *                         except Exception as e:
*/
                }
                __pyx_L262:;

                /* "ws_package/controllers/activity_controller.py":5212
 *                     interval_is_uploaded = False
 *                     if last_interval:
 *                         try:             # <<<<<<<<<<<<<<
 *                             if hasattr(last_interval, 'is_uploaded'):
 *                                 interval_is_uploaded = bool(last_interval.is_uploaded)
*/
              }
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
              goto __pyx_L261_try_end;
              __pyx_L256_error:;
              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
              __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
              __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
              __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
              __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

              /* "ws_package/controllers/activity_controller.py":5217
 *                             elif hasattr(last_interval, 'isUploaded'):
 *                                 interval_is_uploaded = bool(last_interval.isUploaded)
 *                         except Exception as e:             # <<<<<<<<<<<<<<
 *                             logger.debug("Could not check is_uploaded status for manual inclusion: %s", e)
 * 
*/
              __pyx_t_32 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
              if (__pyx_t_32) {
                __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
                if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_4, &__pyx_t_23) < 0) __PYX_ERR(0, 5217, __pyx_L258_except_error)
                __Pyx_XGOTREF(__pyx_t_7);
                __Pyx_XGOTREF(__pyx_t_4);
                __Pyx_XGOTREF(__pyx_t_23);
                __Pyx_INCREF(__pyx_t_4);
                __Pyx_GIVEREF(__pyx_t_4);
                __pyx_cur_scope->__pyx_v_e = __pyx_t_4;
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":5218
 *                                 interval_is_uploaded = bool(last_interval.isUploaded)
 *                         except Exception as e:
 *                             logger.debug("Could not check is_uploaded status for manual inclusion: %s", e)             # <<<<<<<<<<<<<<
 * 
 *                     if interval_is_uploaded:
*/
                  __pyx_t_24 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5218, __pyx_L268_error)
                  __Pyx_GOTREF(__pyx_t_5);
                  __pyx_t_39 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5218, __pyx_L268_error)
                  __Pyx_GOTREF(__pyx_t_39);
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __pyx_t_8 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_39))) {
                    __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_39);
                    assert(__pyx_t_24);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_39);
                    __Pyx_INCREF(__pyx_t_24);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_39, __pyx__function);
                    __pyx_t_8 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[3] = {__pyx_t_24, __pyx_mstate_global->__pyx_kp_u_Could_not_check_is_uploaded_stat, __pyx_cur_scope->__pyx_v_e};
                    __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_39, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                    __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                    if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5218, __pyx_L268_error)
                    __Pyx_GOTREF(__pyx_t_6);
                  }
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                }

                /* "ws_package/controllers/activity_controller.py":5217
 *                             elif hasattr(last_interval, 'isUploaded'):
 *                                 interval_is_uploaded = bool(last_interval.isUploaded)
 *                         except Exception as e:             # <<<<<<<<<<<<<<
 *                             logger.debug("Could not check is_uploaded status for manual inclusion: %s", e)
 * 
*/
                /*finally:*/ {
                  /*normal exit:*/{
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    goto __pyx_L269;
                  }
                  __pyx_L268_error:;
                  /*exception exit:*/{
                    __Pyx_PyThreadState_assign
                    __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_15 = 0; __pyx_t_37 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
                    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                    __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                    __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                    __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                    __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                    __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                    __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                     __Pyx_ExceptionSwap(&__pyx_t_37, &__pyx_t_20, &__pyx_t_19);
                    if ( unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_15) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_15);
                    __Pyx_XGOTREF(__pyx_t_17);
                    __Pyx_XGOTREF(__pyx_t_18);
                    __Pyx_XGOTREF(__pyx_t_15);
                    __Pyx_XGOTREF(__pyx_t_37);
                    __Pyx_XGOTREF(__pyx_t_20);
                    __Pyx_XGOTREF(__pyx_t_19);
                    __pyx_t_32 = __pyx_lineno; __pyx_t_31 = __pyx_clineno; __pyx_t_48 = __pyx_filename;
                    {
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    }
                    __Pyx_XGIVEREF(__pyx_t_37);
                    __Pyx_XGIVEREF(__pyx_t_20);
                    __Pyx_XGIVEREF(__pyx_t_19);
                    __Pyx_ExceptionReset(__pyx_t_37, __pyx_t_20, __pyx_t_19);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_ErrRestore(__pyx_t_17, __pyx_t_18, __pyx_t_15);
                    __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_15 = 0; __pyx_t_37 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
                    __pyx_lineno = __pyx_t_32; __pyx_clineno = __pyx_t_31; __pyx_filename = __pyx_t_48;
                    goto __pyx_L258_except_error;
                  }
                  __pyx_L269:;
                }
                __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                goto __pyx_L257_exception_handled;
              }
              goto __pyx_L258_except_error;

              /* "ws_package/controllers/activity_controller.py":5212
 *                     interval_is_uploaded = False
 *                     if last_interval:
 *                         try:             # <<<<<<<<<<<<<<
 *                             if hasattr(last_interval, 'is_uploaded'):
 *                                 interval_is_uploaded = bool(last_interval.is_uploaded)
*/
              __pyx_L258_except_error:;
              __Pyx_XGIVEREF(__pyx_t_12);
              __Pyx_XGIVEREF(__pyx_t_13);
              __Pyx_XGIVEREF(__pyx_t_14);
              __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
              goto __pyx_L4_error;
              __pyx_L257_exception_handled:;
              __Pyx_XGIVEREF(__pyx_t_12);
              __Pyx_XGIVEREF(__pyx_t_13);
              __Pyx_XGIVEREF(__pyx_t_14);
              __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
              __pyx_L261_try_end:;
            }

            /* "ws_package/controllers/activity_controller.py":5211
 *                     # NEW: First check if interval was saved with is_uploaded=True - if so, don't include it
 *                     interval_is_uploaded = False
 *                     if last_interval:             # <<<<<<<<<<<<<<
 *                         try:
 *                             if hasattr(last_interval, 'is_uploaded'):
*/
          }

          /* "ws_package/controllers/activity_controller.py":5220
 *                             logger.debug("Could not check is_uploaded status for manual inclusion: %s", e)
 * 
 *                     if interval_is_uploaded:             # <<<<<<<<<<<<<<
 *                         logger.info("[SleepInterval] Last interval was saved with is_uploaded=True - will NOT manually include it (interval should not be sent to server)")
 *                     else:
*/
          if (__pyx_cur_scope->__pyx_v_interval_is_uploaded) {

            /* "ws_package/controllers/activity_controller.py":5221
 * 
 *                     if interval_is_uploaded:
 *                         logger.info("[SleepInterval] Last interval was saved with is_uploaded=True - will NOT manually include it (interval should not be sent to server)")             # <<<<<<<<<<<<<<
 *                     else:
 *                         # NEW: Check if this is a sleep interval before manually including it
*/
            __pyx_t_4 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5221, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_7);
            __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5221, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_6))) {
              __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
              assert(__pyx_t_4);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
              __Pyx_INCREF(__pyx_t_4);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_SleepInterval_Last_interval_was};
              __pyx_t_23 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5221, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_23);
            }
            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

            /* "ws_package/controllers/activity_controller.py":5220
 *                             logger.debug("Could not check is_uploaded status for manual inclusion: %s", e)
 * 
 *                     if interval_is_uploaded:             # <<<<<<<<<<<<<<
 *                         logger.info("[SleepInterval] Last interval was saved with is_uploaded=True - will NOT manually include it (interval should not be sent to server)")
 *                     else:
*/
            goto __pyx_L274;
          }

          /* "ws_package/controllers/activity_controller.py":5224
 *                     else:
 *                         # NEW: Check if this is a sleep interval before manually including it
 *                         is_sleep_interval_for_manual_check = False             # <<<<<<<<<<<<<<
 *                         if last_interval:
 *                             try:
*/
          /*else*/ {
            __pyx_cur_scope->__pyx_v_is_sleep_interval_for_manual_check = 0;

            /* "ws_package/controllers/activity_controller.py":5225
 *                         # NEW: Check if this is a sleep interval before manually including it
 *                         is_sleep_interval_for_manual_check = False
 *                         if last_interval:             # <<<<<<<<<<<<<<
 *                             try:
 *                                 if hasattr(last_interval, 'start_time') and hasattr(last_interval, 'end_time'):
*/
            __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5225, __pyx_L4_error)
            if (__pyx_t_28) {

              /* "ws_package/controllers/activity_controller.py":5226
 *                         is_sleep_interval_for_manual_check = False
 *                         if last_interval:
 *                             try:             # <<<<<<<<<<<<<<
 *                                 if hasattr(last_interval, 'start_time') and hasattr(last_interval, 'end_time'):
 *                                     gap_seconds = (last_interval.end_time - last_interval.start_time).total_seconds()
*/
              {
                __Pyx_ExceptionSave(&__pyx_t_14, &__pyx_t_13, &__pyx_t_12);
                __Pyx_XGOTREF(__pyx_t_14);
                __Pyx_XGOTREF(__pyx_t_13);
                __Pyx_XGOTREF(__pyx_t_12);
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":5227
 *                         if last_interval:
 *                             try:
 *                                 if hasattr(last_interval, 'start_time') and hasattr(last_interval, 'end_time'):             # <<<<<<<<<<<<<<
 *                                     gap_seconds = (last_interval.end_time - last_interval.start_time).total_seconds()
 *                                     # Check if it's a long interval (>= 1 hour) with zero activity (sleep pattern)
*/
                  __pyx_t_23 = __pyx_cur_scope->__pyx_v_last_interval;
                  __Pyx_INCREF(__pyx_t_23);
                  __pyx_t_47 = __Pyx_HasAttr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(__pyx_t_47 == ((int)-1))) __PYX_ERR(0, 5227, __pyx_L276_error)
                  __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                  if (__pyx_t_47) {
                  } else {
                    __pyx_t_28 = __pyx_t_47;
                    goto __pyx_L283_bool_binop_done;
                  }
                  __pyx_t_23 = __pyx_cur_scope->__pyx_v_last_interval;
                  __Pyx_INCREF(__pyx_t_23);
                  __pyx_t_47 = __Pyx_HasAttr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(__pyx_t_47 == ((int)-1))) __PYX_ERR(0, 5227, __pyx_L276_error)
                  __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                  __pyx_t_28 = __pyx_t_47;
                  __pyx_L283_bool_binop_done:;
                  if (__pyx_t_28) {

                    /* "ws_package/controllers/activity_controller.py":5228
 *                             try:
 *                                 if hasattr(last_interval, 'start_time') and hasattr(last_interval, 'end_time'):
 *                                     gap_seconds = (last_interval.end_time - last_interval.start_time).total_seconds()             # <<<<<<<<<<<<<<
 *                                     # Check if it's a long interval (>= 1 hour) with zero activity (sleep pattern)
 *                                     if gap_seconds >= 3600:  # 1 hour
*/
                    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5228, __pyx_L276_error)
                    __Pyx_GOTREF(__pyx_t_4);
                    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5228, __pyx_L276_error)
                    __Pyx_GOTREF(__pyx_t_7);
                    __pyx_t_39 = PyNumber_Subtract(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5228, __pyx_L276_error)
                    __Pyx_GOTREF(__pyx_t_39);
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                    __pyx_t_6 = __pyx_t_39;
                    __Pyx_INCREF(__pyx_t_6);
                    __pyx_t_8 = 0;
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
                      __pyx_t_23 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_total_seconds, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                      __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                      if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5228, __pyx_L276_error)
                      __Pyx_GOTREF(__pyx_t_23);
                    }
                    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_gap_seconds);
                    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_gap_seconds, __pyx_t_23);
                    __Pyx_GIVEREF(__pyx_t_23);
                    __pyx_t_23 = 0;

                    /* "ws_package/controllers/activity_controller.py":5230
 *                                     gap_seconds = (last_interval.end_time - last_interval.start_time).total_seconds()
 *                                     # Check if it's a long interval (>= 1 hour) with zero activity (sleep pattern)
 *                                     if gap_seconds >= 3600:  # 1 hour             # <<<<<<<<<<<<<<
 *                                         # Check activity level
 *                                         activity_level = None
*/
                    __pyx_t_23 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_gap_seconds, __pyx_mstate_global->__pyx_int_3600, Py_GE); __Pyx_XGOTREF(__pyx_t_23); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5230, __pyx_L276_error)
                    __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_23); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5230, __pyx_L276_error)
                    __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                    if (__pyx_t_28) {

                      /* "ws_package/controllers/activity_controller.py":5232
 *                                     if gap_seconds >= 3600:  # 1 hour
 *                                         # Check activity level
 *                                         activity_level = None             # <<<<<<<<<<<<<<
 *                                         if hasattr(last_interval, 'activityLevel'):
 *                                             activity_level = last_interval.activityLevel
*/
                      __Pyx_INCREF(Py_None);
                      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_activity_level);
                      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_activity_level, Py_None);
                      __Pyx_GIVEREF(Py_None);

                      /* "ws_package/controllers/activity_controller.py":5233
 *                                         # Check activity level
 *                                         activity_level = None
 *                                         if hasattr(last_interval, 'activityLevel'):             # <<<<<<<<<<<<<<
 *                                             activity_level = last_interval.activityLevel
 *                                         elif hasattr(last_interval, 'activity_level'):
*/
                      __pyx_t_23 = __pyx_cur_scope->__pyx_v_last_interval;
                      __Pyx_INCREF(__pyx_t_23);
                      __pyx_t_28 = __Pyx_HasAttr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_activityLevel); if (unlikely(__pyx_t_28 == ((int)-1))) __PYX_ERR(0, 5233, __pyx_L276_error)
                      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                      if (__pyx_t_28) {

                        /* "ws_package/controllers/activity_controller.py":5234
 *                                         activity_level = None
 *                                         if hasattr(last_interval, 'activityLevel'):
 *                                             activity_level = last_interval.activityLevel             # <<<<<<<<<<<<<<
 *                                         elif hasattr(last_interval, 'activity_level'):
 *                                             activity_level = last_interval.activity_level
*/
                        __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_activityLevel); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5234, __pyx_L276_error)
                        __Pyx_GOTREF(__pyx_t_23);
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_activity_level);
                        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_activity_level, __pyx_t_23);
                        __Pyx_GIVEREF(__pyx_t_23);
                        __pyx_t_23 = 0;

                        /* "ws_package/controllers/activity_controller.py":5233
 *                                         # Check activity level
 *                                         activity_level = None
 *                                         if hasattr(last_interval, 'activityLevel'):             # <<<<<<<<<<<<<<
 *                                             activity_level = last_interval.activityLevel
 *                                         elif hasattr(last_interval, 'activity_level'):
*/
                        goto __pyx_L286;
                      }

                      /* "ws_package/controllers/activity_controller.py":5235
 *                                         if hasattr(last_interval, 'activityLevel'):
 *                                             activity_level = last_interval.activityLevel
 *                                         elif hasattr(last_interval, 'activity_level'):             # <<<<<<<<<<<<<<
 *                                             activity_level = last_interval.activity_level
 * 
*/
                      __pyx_t_23 = __pyx_cur_scope->__pyx_v_last_interval;
                      __Pyx_INCREF(__pyx_t_23);
                      __pyx_t_28 = __Pyx_HasAttr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_activity_level); if (unlikely(__pyx_t_28 == ((int)-1))) __PYX_ERR(0, 5235, __pyx_L276_error)
                      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                      if (__pyx_t_28) {

                        /* "ws_package/controllers/activity_controller.py":5236
 *                                             activity_level = last_interval.activityLevel
 *                                         elif hasattr(last_interval, 'activity_level'):
 *                                             activity_level = last_interval.activity_level             # <<<<<<<<<<<<<<
 * 
 *                                         if activity_level:
*/
                        __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_activity_level); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5236, __pyx_L276_error)
                        __Pyx_GOTREF(__pyx_t_23);
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_activity_level);
                        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_activity_level, __pyx_t_23);
                        __Pyx_GIVEREF(__pyx_t_23);
                        __pyx_t_23 = 0;

                        /* "ws_package/controllers/activity_controller.py":5235
 *                                         if hasattr(last_interval, 'activityLevel'):
 *                                             activity_level = last_interval.activityLevel
 *                                         elif hasattr(last_interval, 'activity_level'):             # <<<<<<<<<<<<<<
 *                                             activity_level = last_interval.activity_level
 * 
*/
                      }
                      __pyx_L286:;

                      /* "ws_package/controllers/activity_controller.py":5238
 *                                             activity_level = last_interval.activity_level
 * 
 *                                         if activity_level:             # <<<<<<<<<<<<<<
 *                                             keyboard = float(activity_level.get('keyboard', 0) if isinstance(activity_level, dict) else 0)
 *                                             mouse = float(activity_level.get('mouse', 0) if isinstance(activity_level, dict) else 0)
*/
                      __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_activity_level); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5238, __pyx_L276_error)
                      if (__pyx_t_28) {

                        /* "ws_package/controllers/activity_controller.py":5239
 * 
 *                                         if activity_level:
 *                                             keyboard = float(activity_level.get('keyboard', 0) if isinstance(activity_level, dict) else 0)             # <<<<<<<<<<<<<<
 *                                             mouse = float(activity_level.get('mouse', 0) if isinstance(activity_level, dict) else 0)
 *                                             average = float(activity_level.get('average', 0) if isinstance(activity_level, dict) else 0)
*/
                        __pyx_t_28 = PyDict_Check(__pyx_cur_scope->__pyx_v_activity_level); 
                        if (__pyx_t_28) {
                          __pyx_t_39 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activity_level, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5239, __pyx_L276_error)
                          __Pyx_GOTREF(__pyx_t_39);
                          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_39, __pyx_mstate_global->__pyx_tuple[15], NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5239, __pyx_L276_error)
                          __Pyx_GOTREF(__pyx_t_6);
                          __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                          __pyx_t_23 = __pyx_t_6;
                          __pyx_t_6 = 0;
                        } else {
                          __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
                          __pyx_t_23 = __pyx_mstate_global->__pyx_int_0;
                        }
                        __pyx_t_29 = __Pyx_PyObject_AsDouble(__pyx_t_23); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_29, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 5239, __pyx_L276_error)
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __pyx_cur_scope->__pyx_v_keyboard = __pyx_t_29;

                        /* "ws_package/controllers/activity_controller.py":5240
 *                                         if activity_level:
 *                                             keyboard = float(activity_level.get('keyboard', 0) if isinstance(activity_level, dict) else 0)
 *                                             mouse = float(activity_level.get('mouse', 0) if isinstance(activity_level, dict) else 0)             # <<<<<<<<<<<<<<
 *                                             average = float(activity_level.get('average', 0) if isinstance(activity_level, dict) else 0)
 *                                             if keyboard == 0.0 and mouse == 0.0 and average == 0.0:
*/
                        __pyx_t_28 = PyDict_Check(__pyx_cur_scope->__pyx_v_activity_level); 
                        if (__pyx_t_28) {
                          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activity_level, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5240, __pyx_L276_error)
                          __Pyx_GOTREF(__pyx_t_6);
                          __pyx_t_39 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_mstate_global->__pyx_tuple[16], NULL); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5240, __pyx_L276_error)
                          __Pyx_GOTREF(__pyx_t_39);
                          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                          __pyx_t_23 = __pyx_t_39;
                          __pyx_t_39 = 0;
                        } else {
                          __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
                          __pyx_t_23 = __pyx_mstate_global->__pyx_int_0;
                        }
                        __pyx_t_29 = __Pyx_PyObject_AsDouble(__pyx_t_23); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_29, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 5240, __pyx_L276_error)
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __pyx_cur_scope->__pyx_v_mouse = __pyx_t_29;

                        /* "ws_package/controllers/activity_controller.py":5241
 *                                             keyboard = float(activity_level.get('keyboard', 0) if isinstance(activity_level, dict) else 0)
 *                                             mouse = float(activity_level.get('mouse', 0) if isinstance(activity_level, dict) else 0)
 *                                             average = float(activity_level.get('average', 0) if isinstance(activity_level, dict) else 0)             # <<<<<<<<<<<<<<
 *                                             if keyboard == 0.0 and mouse == 0.0 and average == 0.0:
 *                                                 is_sleep_interval_for_manual_check = True
*/
                        __pyx_t_28 = PyDict_Check(__pyx_cur_scope->__pyx_v_activity_level); 
                        if (__pyx_t_28) {
                          __pyx_t_39 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activity_level, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5241, __pyx_L276_error)
                          __Pyx_GOTREF(__pyx_t_39);
                          __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_39, __pyx_mstate_global->__pyx_tuple[17], NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5241, __pyx_L276_error)
                          __Pyx_GOTREF(__pyx_t_6);
                          __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                          __pyx_t_23 = __pyx_t_6;
                          __pyx_t_6 = 0;
                        } else {
                          __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
                          __pyx_t_23 = __pyx_mstate_global->__pyx_int_0;
                        }
                        __pyx_t_29 = __Pyx_PyObject_AsDouble(__pyx_t_23); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_29, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 5241, __pyx_L276_error)
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __pyx_cur_scope->__pyx_v_average = __pyx_t_29;

                        /* "ws_package/controllers/activity_controller.py":5242
 *                                             mouse = float(activity_level.get('mouse', 0) if isinstance(activity_level, dict) else 0)
 *                                             average = float(activity_level.get('average', 0) if isinstance(activity_level, dict) else 0)
 *                                             if keyboard == 0.0 and mouse == 0.0 and average == 0.0:             # <<<<<<<<<<<<<<
 *                                                 is_sleep_interval_for_manual_check = True
 *                                                 logger.info("[SleepInterval] Last interval is a sleep interval (%s hours) - will NOT manually include it to prevent sending wake-up time as 'stop'", gap_seconds/3600)
*/
                        __pyx_t_47 = (__pyx_cur_scope->__pyx_v_keyboard == 0.0);
                        if (__pyx_t_47) {
                        } else {
                          __pyx_t_28 = __pyx_t_47;
                          goto __pyx_L289_bool_binop_done;
                        }
                        __pyx_t_47 = (__pyx_cur_scope->__pyx_v_mouse == 0.0);
                        if (__pyx_t_47) {
                        } else {
                          __pyx_t_28 = __pyx_t_47;
                          goto __pyx_L289_bool_binop_done;
                        }
                        __pyx_t_47 = (__pyx_cur_scope->__pyx_v_average == 0.0);
                        __pyx_t_28 = __pyx_t_47;
                        __pyx_L289_bool_binop_done:;
                        if (__pyx_t_28) {

                          /* "ws_package/controllers/activity_controller.py":5243
 *                                             average = float(activity_level.get('average', 0) if isinstance(activity_level, dict) else 0)
 *                                             if keyboard == 0.0 and mouse == 0.0 and average == 0.0:
 *                                                 is_sleep_interval_for_manual_check = True             # <<<<<<<<<<<<<<
 *                                                 logger.info("[SleepInterval] Last interval is a sleep interval (%s hours) - will NOT manually include it to prevent sending wake-up time as 'stop'", gap_seconds/3600)
 *                             except Exception as e:
*/
                          __pyx_cur_scope->__pyx_v_is_sleep_interval_for_manual_check = 1;

                          /* "ws_package/controllers/activity_controller.py":5244
 *                                             if keyboard == 0.0 and mouse == 0.0 and average == 0.0:
 *                                                 is_sleep_interval_for_manual_check = True
 *                                                 logger.info("[SleepInterval] Last interval is a sleep interval (%s hours) - will NOT manually include it to prevent sending wake-up time as 'stop'", gap_seconds/3600)             # <<<<<<<<<<<<<<
 *                             except Exception as e:
 *                                 logger.debug("Could not check if last interval is sleep interval for manual inclusion: %s", e)
*/
                          __pyx_t_6 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5244, __pyx_L276_error)
                          __Pyx_GOTREF(__pyx_t_39);
                          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5244, __pyx_L276_error)
                          __Pyx_GOTREF(__pyx_t_7);
                          __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                          __pyx_t_39 = __Pyx_PyLong_TrueDivideObjC(__pyx_cur_scope->__pyx_v_gap_seconds, __pyx_mstate_global->__pyx_int_3600, 0xE10, 0, 0); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5244, __pyx_L276_error)
                          __Pyx_GOTREF(__pyx_t_39);
                          __pyx_t_8 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_7))) {
                            __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
                            assert(__pyx_t_6);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                            __Pyx_INCREF(__pyx_t_6);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                            __pyx_t_8 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_SleepInterval_Last_interval_is_2, __pyx_t_39};
                            __pyx_t_23 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                            __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                            if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5244, __pyx_L276_error)
                            __Pyx_GOTREF(__pyx_t_23);
                          }
                          __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

                          /* "ws_package/controllers/activity_controller.py":5242
 *                                             mouse = float(activity_level.get('mouse', 0) if isinstance(activity_level, dict) else 0)
 *                                             average = float(activity_level.get('average', 0) if isinstance(activity_level, dict) else 0)
 *                                             if keyboard == 0.0 and mouse == 0.0 and average == 0.0:             # <<<<<<<<<<<<<<
 *                                                 is_sleep_interval_for_manual_check = True
 *                                                 logger.info("[SleepInterval] Last interval is a sleep interval (%s hours) - will NOT manually include it to prevent sending wake-up time as 'stop'", gap_seconds/3600)
*/
                        }

                        /* "ws_package/controllers/activity_controller.py":5238
 *                                             activity_level = last_interval.activity_level
 * 
 *                                         if activity_level:             # <<<<<<<<<<<<<<
 *                                             keyboard = float(activity_level.get('keyboard', 0) if isinstance(activity_level, dict) else 0)
 *                                             mouse = float(activity_level.get('mouse', 0) if isinstance(activity_level, dict) else 0)
*/
                      }

                      /* "ws_package/controllers/activity_controller.py":5230
 *                                     gap_seconds = (last_interval.end_time - last_interval.start_time).total_seconds()
 *                                     # Check if it's a long interval (>= 1 hour) with zero activity (sleep pattern)
 *                                     if gap_seconds >= 3600:  # 1 hour             # <<<<<<<<<<<<<<
 *                                         # Check activity level
 *                                         activity_level = None
*/
                    }

                    /* "ws_package/controllers/activity_controller.py":5227
 *                         if last_interval:
 *                             try:
 *                                 if hasattr(last_interval, 'start_time') and hasattr(last_interval, 'end_time'):             # <<<<<<<<<<<<<<
 *                                     gap_seconds = (last_interval.end_time - last_interval.start_time).total_seconds()
 *                                     # Check if it's a long interval (>= 1 hour) with zero activity (sleep pattern)
*/
                  }

                  /* "ws_package/controllers/activity_controller.py":5226
 *                         is_sleep_interval_for_manual_check = False
 *                         if last_interval:
 *                             try:             # <<<<<<<<<<<<<<
 *                                 if hasattr(last_interval, 'start_time') and hasattr(last_interval, 'end_time'):
 *                                     gap_seconds = (last_interval.end_time - last_interval.start_time).total_seconds()
*/
                }
                __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                goto __pyx_L281_try_end;
                __pyx_L276_error:;
                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

                /* "ws_package/controllers/activity_controller.py":5245
 *                                                 is_sleep_interval_for_manual_check = True
 *                                                 logger.info("[SleepInterval] Last interval is a sleep interval (%s hours) - will NOT manually include it to prevent sending wake-up time as 'stop'", gap_seconds/3600)
 *                             except Exception as e:             # <<<<<<<<<<<<<<
 *                                 logger.debug("Could not check if last interval is sleep interval for manual inclusion: %s", e)
 *                                 # Continue with normal flow if check fails (fail-safe)
*/
                __pyx_t_31 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                if (__pyx_t_31) {
                  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
                  if (__Pyx_GetException(&__pyx_t_23, &__pyx_t_7, &__pyx_t_39) < 0) __PYX_ERR(0, 5245, __pyx_L278_except_error)
                  __Pyx_XGOTREF(__pyx_t_23);
                  __Pyx_XGOTREF(__pyx_t_7);
                  __Pyx_XGOTREF(__pyx_t_39);
                  __Pyx_INCREF(__pyx_t_7);
                  __Pyx_GIVEREF(__pyx_t_7);
                  __pyx_cur_scope->__pyx_v_e = __pyx_t_7;
                  /*try:*/ {

                    /* "ws_package/controllers/activity_controller.py":5246
 *                                                 logger.info("[SleepInterval] Last interval is a sleep interval (%s hours) - will NOT manually include it to prevent sending wake-up time as 'stop'", gap_seconds/3600)
 *                             except Exception as e:
 *                                 logger.debug("Could not check if last interval is sleep interval for manual inclusion: %s", e)             # <<<<<<<<<<<<<<
 *                                 # Continue with normal flow if check fails (fail-safe)
 * 
*/
                    __pyx_t_4 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5246, __pyx_L297_error)
                    __Pyx_GOTREF(__pyx_t_24);
                    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5246, __pyx_L297_error)
                    __Pyx_GOTREF(__pyx_t_5);
                    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                    __pyx_t_8 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_5))) {
                      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
                      assert(__pyx_t_4);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                      __Pyx_INCREF(__pyx_t_4);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                      __pyx_t_8 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Could_not_check_if_last_interval_2, __pyx_cur_scope->__pyx_v_e};
                      __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5246, __pyx_L297_error)
                      __Pyx_GOTREF(__pyx_t_6);
                    }
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  }

                  /* "ws_package/controllers/activity_controller.py":5245
 *                                                 is_sleep_interval_for_manual_check = True
 *                                                 logger.info("[SleepInterval] Last interval is a sleep interval (%s hours) - will NOT manually include it to prevent sending wake-up time as 'stop'", gap_seconds/3600)
 *                             except Exception as e:             # <<<<<<<<<<<<<<
 *                                 logger.debug("Could not check if last interval is sleep interval for manual inclusion: %s", e)
 *                                 # Continue with normal flow if check fails (fail-safe)
*/
                  /*finally:*/ {
                    /*normal exit:*/{
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                      goto __pyx_L298;
                    }
                    __pyx_L297_error:;
                    /*exception exit:*/{
                      __Pyx_PyThreadState_assign
                      __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_37 = 0; __pyx_t_15 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0;
                      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                      __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                      __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                      __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                      __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                      __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                       __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_18, &__pyx_t_17);
                      if ( unlikely(__Pyx_GetException(&__pyx_t_19, &__pyx_t_20, &__pyx_t_37) < 0)) __Pyx_ErrFetch(&__pyx_t_19, &__pyx_t_20, &__pyx_t_37);
                      __Pyx_XGOTREF(__pyx_t_19);
                      __Pyx_XGOTREF(__pyx_t_20);
                      __Pyx_XGOTREF(__pyx_t_37);
                      __Pyx_XGOTREF(__pyx_t_15);
                      __Pyx_XGOTREF(__pyx_t_18);
                      __Pyx_XGOTREF(__pyx_t_17);
                      __pyx_t_31 = __pyx_lineno; __pyx_t_32 = __pyx_clineno; __pyx_t_49 = __pyx_filename;
                      {
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                        __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                      }
                      __Pyx_XGIVEREF(__pyx_t_15);
                      __Pyx_XGIVEREF(__pyx_t_18);
                      __Pyx_XGIVEREF(__pyx_t_17);
                      __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_18, __pyx_t_17);
                      __Pyx_XGIVEREF(__pyx_t_19);
                      __Pyx_XGIVEREF(__pyx_t_20);
                      __Pyx_XGIVEREF(__pyx_t_37);
                      __Pyx_ErrRestore(__pyx_t_19, __pyx_t_20, __pyx_t_37);
                      __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_37 = 0; __pyx_t_15 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0;
                      __pyx_lineno = __pyx_t_31; __pyx_clineno = __pyx_t_32; __pyx_filename = __pyx_t_49;
                      goto __pyx_L278_except_error;
                    }
                    __pyx_L298:;
                  }
                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                  __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                  goto __pyx_L277_exception_handled;
                }
                goto __pyx_L278_except_error;

                /* "ws_package/controllers/activity_controller.py":5226
 *                         is_sleep_interval_for_manual_check = False
 *                         if last_interval:
 *                             try:             # <<<<<<<<<<<<<<
 *                                 if hasattr(last_interval, 'start_time') and hasattr(last_interval, 'end_time'):
 *                                     gap_seconds = (last_interval.end_time - last_interval.start_time).total_seconds()
*/
                __pyx_L278_except_error:;
                __Pyx_XGIVEREF(__pyx_t_14);
                __Pyx_XGIVEREF(__pyx_t_13);
                __Pyx_XGIVEREF(__pyx_t_12);
                __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12);
                goto __pyx_L4_error;
                __pyx_L277_exception_handled:;
                __Pyx_XGIVEREF(__pyx_t_14);
                __Pyx_XGIVEREF(__pyx_t_13);
                __Pyx_XGIVEREF(__pyx_t_12);
                __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12);
                __pyx_L281_try_end:;
              }

              /* "ws_package/controllers/activity_controller.py":5225
 *                         # NEW: Check if this is a sleep interval before manually including it
 *                         is_sleep_interval_for_manual_check = False
 *                         if last_interval:             # <<<<<<<<<<<<<<
 *                             try:
 *                                 if hasattr(last_interval, 'start_time') and hasattr(last_interval, 'end_time'):
*/
            }

            /* "ws_package/controllers/activity_controller.py":5249
 *                                 # Continue with normal flow if check fails (fail-safe)
 * 
 *                         if not is_sleep_interval_for_manual_check:             # <<<<<<<<<<<<<<
 *                             logger.warning("Last interval not found in query results - manually including it to ensure it's sent to server")
 *                             try:
*/
            __pyx_t_28 = (!__pyx_cur_scope->__pyx_v_is_sleep_interval_for_manual_check);
            if (__pyx_t_28) {

              /* "ws_package/controllers/activity_controller.py":5250
 * 
 *                         if not is_sleep_interval_for_manual_check:
 *                             logger.warning("Last interval not found in query results - manually including it to ensure it's sent to server")             # <<<<<<<<<<<<<<
 *                             try:
 *                                 # Ensure intervals is a list
*/
              __pyx_t_7 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5250, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_23);
              __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5250, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_6);
              __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_6))) {
                __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
                assert(__pyx_t_7);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                __Pyx_INCREF(__pyx_t_7);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Last_interval_not_found_in_query_2};
                __pyx_t_39 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5250, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_39);
              }
              __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;

              /* "ws_package/controllers/activity_controller.py":5251
 *                         if not is_sleep_interval_for_manual_check:
 *                             logger.warning("Last interval not found in query results - manually including it to ensure it's sent to server")
 *                             try:             # <<<<<<<<<<<<<<
 *                                 # Ensure intervals is a list
 *                                 if intervals is None:
*/
              {
                __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
                __Pyx_XGOTREF(__pyx_t_12);
                __Pyx_XGOTREF(__pyx_t_13);
                __Pyx_XGOTREF(__pyx_t_14);
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":5253
 *                             try:
 *                                 # Ensure intervals is a list
 *                                 if intervals is None:             # <<<<<<<<<<<<<<
 *                                     intervals = []
 * 
*/
                  __pyx_t_28 = (__pyx_cur_scope->__pyx_v_intervals == Py_None);
                  if (__pyx_t_28) {

                    /* "ws_package/controllers/activity_controller.py":5254
 *                                 # Ensure intervals is a list
 *                                 if intervals is None:
 *                                     intervals = []             # <<<<<<<<<<<<<<
 * 
 *                                 # Check if last_interval is already in the list (might have been added by another process)
*/
                    __pyx_t_39 = PyList_New(0); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5254, __pyx_L304_error)
                    __Pyx_GOTREF(__pyx_t_39);
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_intervals);
                    __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_intervals, __pyx_t_39);
                    __Pyx_GIVEREF(__pyx_t_39);
                    __pyx_t_39 = 0;

                    /* "ws_package/controllers/activity_controller.py":5253
 *                             try:
 *                                 # Ensure intervals is a list
 *                                 if intervals is None:             # <<<<<<<<<<<<<<
 *                                     intervals = []
 * 
*/
                  }

                  /* "ws_package/controllers/activity_controller.py":5258
 *                                 # Check if last_interval is already in the list (might have been added by another process)
 *                                 already_in_list = any(
 *                                     datetime_matches(getattr(interval, 'start_time', None), last_interval.start_time) and             # <<<<<<<<<<<<<<
 *                                     datetime_matches(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                                     getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
*/
                  __pyx_t_39 = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_7genexpr(((PyObject*)__pyx_cur_scope), __pyx_cur_scope->__pyx_v_intervals); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5258, __pyx_L304_error)
                  __Pyx_GOTREF(__pyx_t_39);
                  __pyx_t_6 = __Pyx_Generator_GetInlinedResult(__pyx_t_39); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5258, __pyx_L304_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                  __Pyx_GIVEREF(__pyx_t_6);
                  __pyx_cur_scope->__pyx_v_already_in_list = __pyx_t_6;
                  __pyx_t_6 = 0;

                  /* "ws_package/controllers/activity_controller.py":5264
 *                                 )
 * 
 *                                 if not already_in_list:             # <<<<<<<<<<<<<<
 *                                     # Manually add the last interval to the results
 *                                     # Convert entity to database model format if needed
*/
                  __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_already_in_list); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5264, __pyx_L304_error)
                  __pyx_t_47 = (!__pyx_t_28);
                  if (__pyx_t_47) {

                    /* "ws_package/controllers/activity_controller.py":5267
 *                                     # Manually add the last interval to the results
 *                                     # Convert entity to database model format if needed
 *                                     if isinstance(last_interval, ActivityInterval):             # <<<<<<<<<<<<<<
 *                                         intervals.append(last_interval)
 *                                     else:
*/
                    __pyx_t_6 = __pyx_cur_scope->__pyx_v_last_interval;
                    __Pyx_INCREF(__pyx_t_6);
                    __Pyx_GetModuleGlobalName(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5267, __pyx_L304_error)
                    __Pyx_GOTREF(__pyx_t_39);
                    __pyx_t_47 = PyObject_IsInstance(__pyx_t_6, __pyx_t_39); if (unlikely(__pyx_t_47 == ((int)-1))) __PYX_ERR(0, 5267, __pyx_L304_error)
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                    if (__pyx_t_47) {

                      /* "ws_package/controllers/activity_controller.py":5268
 *                                     # Convert entity to database model format if needed
 *                                     if isinstance(last_interval, ActivityInterval):
 *                                         intervals.append(last_interval)             # <<<<<<<<<<<<<<
 *                                     else:
 *                                         # If it's an entity, create a mock database model object
*/
                      __pyx_t_50 = __Pyx_PyObject_Append(__pyx_cur_scope->__pyx_v_intervals, __pyx_cur_scope->__pyx_v_last_interval); if (unlikely(__pyx_t_50 == ((int)-1))) __PYX_ERR(0, 5268, __pyx_L304_error)

                      /* "ws_package/controllers/activity_controller.py":5267
 *                                     # Manually add the last interval to the results
 *                                     # Convert entity to database model format if needed
 *                                     if isinstance(last_interval, ActivityInterval):             # <<<<<<<<<<<<<<
 *                                         intervals.append(last_interval)
 *                                     else:
*/
                      goto __pyx_L312;
                    }

                    /* "ws_package/controllers/activity_controller.py":5272
 *                                         # If it's an entity, create a mock database model object
 *                                         # The process_intervals_bulk will handle it correctly
 *                                         intervals.append(last_interval)             # <<<<<<<<<<<<<<
 *                                     logger.info(" Manually added last interval to results - total intervals: %s", len(intervals))
 *                                 else:
*/
                    /*else*/ {
                      __pyx_t_50 = __Pyx_PyObject_Append(__pyx_cur_scope->__pyx_v_intervals, __pyx_cur_scope->__pyx_v_last_interval); if (unlikely(__pyx_t_50 == ((int)-1))) __PYX_ERR(0, 5272, __pyx_L304_error)
                    }
                    __pyx_L312:;

                    /* "ws_package/controllers/activity_controller.py":5273
 *                                         # The process_intervals_bulk will handle it correctly
 *                                         intervals.append(last_interval)
 *                                     logger.info(" Manually added last interval to results - total intervals: %s", len(intervals))             # <<<<<<<<<<<<<<
 *                                 else:
 *                                     logger.info("Last interval already in list (found after manual check)")
*/
                    __pyx_t_6 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5273, __pyx_L304_error)
                    __Pyx_GOTREF(__pyx_t_7);
                    __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5273, __pyx_L304_error)
                    __Pyx_GOTREF(__pyx_t_23);
                    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                    __pyx_t_45 = PyObject_Length(__pyx_cur_scope->__pyx_v_intervals); if (unlikely(__pyx_t_45 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5273, __pyx_L304_error)
                    __pyx_t_7 = PyLong_FromSsize_t(__pyx_t_45); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5273, __pyx_L304_error)
                    __Pyx_GOTREF(__pyx_t_7);
                    __pyx_t_8 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_23))) {
                      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_23);
                      assert(__pyx_t_6);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_23);
                      __Pyx_INCREF(__pyx_t_6);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_23, __pyx__function);
                      __pyx_t_8 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Manually_added_last_interval_to, __pyx_t_7};
                      __pyx_t_39 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_23, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                      if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5273, __pyx_L304_error)
                      __Pyx_GOTREF(__pyx_t_39);
                    }
                    __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;

                    /* "ws_package/controllers/activity_controller.py":5264
 *                                 )
 * 
 *                                 if not already_in_list:             # <<<<<<<<<<<<<<
 *                                     # Manually add the last interval to the results
 *                                     # Convert entity to database model format if needed
*/
                    goto __pyx_L311;
                  }

                  /* "ws_package/controllers/activity_controller.py":5275
 *                                     logger.info(" Manually added last interval to results - total intervals: %s", len(intervals))
 *                                 else:
 *                                     logger.info("Last interval already in list (found after manual check)")             # <<<<<<<<<<<<<<
 *                             except Exception as e:
 *                                 logger.error("Error manually including last interval: %s", e, exc_info=True)
*/
                  /*else*/ {
                    __pyx_t_23 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5275, __pyx_L304_error)
                    __Pyx_GOTREF(__pyx_t_7);
                    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5275, __pyx_L304_error)
                    __Pyx_GOTREF(__pyx_t_6);
                    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                    __pyx_t_8 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_6))) {
                      __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_6);
                      assert(__pyx_t_23);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                      __Pyx_INCREF(__pyx_t_23);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                      __pyx_t_8 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_23, __pyx_mstate_global->__pyx_kp_u_Last_interval_already_in_list_fo};
                      __pyx_t_39 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                      if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5275, __pyx_L304_error)
                      __Pyx_GOTREF(__pyx_t_39);
                    }
                    __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                  }
                  __pyx_L311:;

                  /* "ws_package/controllers/activity_controller.py":5251
 *                         if not is_sleep_interval_for_manual_check:
 *                             logger.warning("Last interval not found in query results - manually including it to ensure it's sent to server")
 *                             try:             # <<<<<<<<<<<<<<
 *                                 # Ensure intervals is a list
 *                                 if intervals is None:
*/
                }
                __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                goto __pyx_L309_try_end;
                __pyx_L304_error:;
                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

                /* "ws_package/controllers/activity_controller.py":5276
 *                                 else:
 *                                     logger.info("Last interval already in list (found after manual check)")
 *                             except Exception as e:             # <<<<<<<<<<<<<<
 *                                 logger.error("Error manually including last interval: %s", e, exc_info=True)
 *                         else:
*/
                __pyx_t_32 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                if (__pyx_t_32) {
                  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
                  if (__Pyx_GetException(&__pyx_t_39, &__pyx_t_6, &__pyx_t_23) < 0) __PYX_ERR(0, 5276, __pyx_L306_except_error)
                  __Pyx_XGOTREF(__pyx_t_39);
                  __Pyx_XGOTREF(__pyx_t_6);
                  __Pyx_XGOTREF(__pyx_t_23);
                  __Pyx_INCREF(__pyx_t_6);
                  __Pyx_GIVEREF(__pyx_t_6);
                  __pyx_cur_scope->__pyx_v_e = __pyx_t_6;
                  /*try:*/ {

                    /* "ws_package/controllers/activity_controller.py":5277
 *                                     logger.info("Last interval already in list (found after manual check)")
 *                             except Exception as e:
 *                                 logger.error("Error manually including last interval: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 *                         else:
 *                             logger.info("[SleepInterval] Skipping manual inclusion of sleep interval - it was saved with is_uploaded=True and should not be sent to server")
*/
                    __pyx_t_5 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5277, __pyx_L318_error)
                    __Pyx_GOTREF(__pyx_t_4);
                    __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5277, __pyx_L318_error)
                    __Pyx_GOTREF(__pyx_t_24);
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __pyx_t_8 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_24))) {
                      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_24);
                      assert(__pyx_t_5);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_24);
                      __Pyx_INCREF(__pyx_t_5);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_24, __pyx__function);
                      __pyx_t_8 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Error_manually_including_last_in, __pyx_cur_scope->__pyx_v_e};
                      __pyx_t_4 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5277, __pyx_L318_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_4, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 5277, __pyx_L318_error)
                      __pyx_t_7 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_24, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_4);
                      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                      if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5277, __pyx_L318_error)
                      __Pyx_GOTREF(__pyx_t_7);
                    }
                    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                  }

                  /* "ws_package/controllers/activity_controller.py":5276
 *                                 else:
 *                                     logger.info("Last interval already in list (found after manual check)")
 *                             except Exception as e:             # <<<<<<<<<<<<<<
 *                                 logger.error("Error manually including last interval: %s", e, exc_info=True)
 *                         else:
*/
                  /*finally:*/ {
                    /*normal exit:*/{
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                      goto __pyx_L319;
                    }
                    __pyx_L318_error:;
                    /*exception exit:*/{
                      __Pyx_PyThreadState_assign
                      __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_15 = 0; __pyx_t_37 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
                      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                      __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                      __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                      __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                      __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                      __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                       __Pyx_ExceptionSwap(&__pyx_t_37, &__pyx_t_20, &__pyx_t_19);
                      if ( unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_15) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_15);
                      __Pyx_XGOTREF(__pyx_t_17);
                      __Pyx_XGOTREF(__pyx_t_18);
                      __Pyx_XGOTREF(__pyx_t_15);
                      __Pyx_XGOTREF(__pyx_t_37);
                      __Pyx_XGOTREF(__pyx_t_20);
                      __Pyx_XGOTREF(__pyx_t_19);
                      __pyx_t_32 = __pyx_lineno; __pyx_t_31 = __pyx_clineno; __pyx_t_51 = __pyx_filename;
                      {
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                        __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                      }
                      __Pyx_XGIVEREF(__pyx_t_37);
                      __Pyx_XGIVEREF(__pyx_t_20);
                      __Pyx_XGIVEREF(__pyx_t_19);
                      __Pyx_ExceptionReset(__pyx_t_37, __pyx_t_20, __pyx_t_19);
                      __Pyx_XGIVEREF(__pyx_t_17);
                      __Pyx_XGIVEREF(__pyx_t_18);
                      __Pyx_XGIVEREF(__pyx_t_15);
                      __Pyx_ErrRestore(__pyx_t_17, __pyx_t_18, __pyx_t_15);
                      __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_15 = 0; __pyx_t_37 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0;
                      __pyx_lineno = __pyx_t_32; __pyx_clineno = __pyx_t_31; __pyx_filename = __pyx_t_51;
                      goto __pyx_L306_except_error;
                    }
                    __pyx_L319:;
                  }
                  __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                  goto __pyx_L305_exception_handled;
                }
                goto __pyx_L306_except_error;

                /* "ws_package/controllers/activity_controller.py":5251
 *                         if not is_sleep_interval_for_manual_check:
 *                             logger.warning("Last interval not found in query results - manually including it to ensure it's sent to server")
 *                             try:             # <<<<<<<<<<<<<<
 *                                 # Ensure intervals is a list
 *                                 if intervals is None:
*/
                __pyx_L306_except_error:;
                __Pyx_XGIVEREF(__pyx_t_12);
                __Pyx_XGIVEREF(__pyx_t_13);
                __Pyx_XGIVEREF(__pyx_t_14);
                __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
                goto __pyx_L4_error;
                __pyx_L305_exception_handled:;
                __Pyx_XGIVEREF(__pyx_t_12);
                __Pyx_XGIVEREF(__pyx_t_13);
                __Pyx_XGIVEREF(__pyx_t_14);
                __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
                __pyx_L309_try_end:;
              }

              /* "ws_package/controllers/activity_controller.py":5249
 *                                 # Continue with normal flow if check fails (fail-safe)
 * 
 *                         if not is_sleep_interval_for_manual_check:             # <<<<<<<<<<<<<<
 *                             logger.warning("Last interval not found in query results - manually including it to ensure it's sent to server")
 *                             try:
*/
              goto __pyx_L303;
            }

            /* "ws_package/controllers/activity_controller.py":5279
 *                                 logger.error("Error manually including last interval: %s", e, exc_info=True)
 *                         else:
 *                             logger.info("[SleepInterval] Skipping manual inclusion of sleep interval - it was saved with is_uploaded=True and should not be sent to server")             # <<<<<<<<<<<<<<
 *                 elif not last_interval_found:
 *                     logger.info("Last interval not found in query results, but keep_idle_time=%s and should_upload=%s - NOT manually including it (interval was saved with is_uploaded=True and should not be sent)", keep_idle_time, should_upload)
*/
            /*else*/ {
              __pyx_t_6 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5279, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_39);
              __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5279, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_7);
              __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_7))) {
                __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
                assert(__pyx_t_6);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                __Pyx_INCREF(__pyx_t_6);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_SleepInterval_Skipping_manual_i};
                __pyx_t_23 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5279, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_23);
              }
              __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
            }
            __pyx_L303:;
          }
          __pyx_L274:;

          /* "ws_package/controllers/activity_controller.py":5208
 *                 # ALSO: Do NOT include sleep intervals (long gaps with zero activity) even if they meet the above conditions
 *                 # ALSO: Do NOT include intervals that were explicitly saved with is_uploaded=True
 *                 if not last_interval_found and (keep_idle_time or should_upload):             # <<<<<<<<<<<<<<
 *                     # NEW: First check if interval was saved with is_uploaded=True - if so, don't include it
 *                     interval_is_uploaded = False
*/
          goto __pyx_L251;
        }

        /* "ws_package/controllers/activity_controller.py":5280
 *                         else:
 *                             logger.info("[SleepInterval] Skipping manual inclusion of sleep interval - it was saved with is_uploaded=True and should not be sent to server")
 *                 elif not last_interval_found:             # <<<<<<<<<<<<<<
 *                     logger.info("Last interval not found in query results, but keep_idle_time=%s and should_upload=%s - NOT manually including it (interval was saved with is_uploaded=True and should not be sent)", keep_idle_time, should_upload)
 * 
*/
        __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval_found); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5280, __pyx_L4_error)
        __pyx_t_28 = (!__pyx_t_47);
        if (__pyx_t_28) {

          /* "ws_package/controllers/activity_controller.py":5281
 *                             logger.info("[SleepInterval] Skipping manual inclusion of sleep interval - it was saved with is_uploaded=True and should not be sent to server")
 *                 elif not last_interval_found:
 *                     logger.info("Last interval not found in query results, but keep_idle_time=%s and should_upload=%s - NOT manually including it (interval was saved with is_uploaded=True and should not be sent)", keep_idle_time, should_upload)             # <<<<<<<<<<<<<<
 * 
 * 
*/
          __pyx_t_7 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5281, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_39 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5281, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_39);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_cur_scope->__pyx_v_keep_idle_time); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5281, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_24 = __Pyx_PyBool_FromLong(__pyx_cur_scope->__pyx_v_should_upload); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5281, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_24);
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_39))) {
            __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_39);
            assert(__pyx_t_7);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_39);
            __Pyx_INCREF(__pyx_t_7);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_39, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[4] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Last_interval_not_found_in_query_3, __pyx_t_6, __pyx_t_24};
            __pyx_t_23 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_39, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
            __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
            if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5281, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_23);
          }
          __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

          /* "ws_package/controllers/activity_controller.py":5280
 *                         else:
 *                             logger.info("[SleepInterval] Skipping manual inclusion of sleep interval - it was saved with is_uploaded=True and should not be sent to server")
 *                 elif not last_interval_found:             # <<<<<<<<<<<<<<
 *                     logger.info("Last interval not found in query results, but keep_idle_time=%s and should_upload=%s - NOT manually including it (interval was saved with is_uploaded=True and should not be sent)", keep_idle_time, should_upload)
 * 
*/
        }
        __pyx_L251:;

        /* "ws_package/controllers/activity_controller.py":5152
 *             # Retry up to 3 times with increasing delays if the interval isn't found
 *             # CRITICAL: Only include last_interval if keep_idle_time is True (or if it was a break interval that needed upload)
 *             if last_interval and (keep_idle_time or should_upload):             # <<<<<<<<<<<<<<
 *                 max_retries = 3
 *                 retry_delays = [1.0, 1.5, 2.0]  # Increasing delays: 1s, 1.5s, 2s
*/
      }

      /* "ws_package/controllers/activity_controller.py":5285
 * 
 *             # Log final status
 *             if last_interval:             # <<<<<<<<<<<<<<
 *                 logger.info("Last saved interval details: start_time=%s, end_time=%s, is_uploaded=%s, counter=%s", last_interval.start_time, last_interval.end_time, last_interval.is_uploaded if hasattr(last_interval, 'is_uploaded') else 'N/A', last_interval.counter if hasattr(last_interval, 'counter') else 'N/A')
 *                 if intervals:
*/
      __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5285, __pyx_L4_error)
      if (__pyx_t_28) {

        /* "ws_package/controllers/activity_controller.py":5286
 *             # Log final status
 *             if last_interval:
 *                 logger.info("Last saved interval details: start_time=%s, end_time=%s, is_uploaded=%s, counter=%s", last_interval.start_time, last_interval.end_time, last_interval.is_uploaded if hasattr(last_interval, 'is_uploaded') else 'N/A', last_interval.counter if hasattr(last_interval, 'counter') else 'N/A')             # <<<<<<<<<<<<<<
 *                 if intervals:
 *                     # Final check if last interval is in results (using tolerance-based comparison)
*/
        __pyx_t_39 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5286, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_24);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5286, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
        __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5286, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_24);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5286, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_5 = __pyx_cur_scope->__pyx_v_last_interval;
        __Pyx_INCREF(__pyx_t_5);
        __pyx_t_28 = __Pyx_HasAttr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_is_uploaded); if (unlikely(__pyx_t_28 == ((int)-1))) __PYX_ERR(0, 5286, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (__pyx_t_28) {
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_is_uploaded); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5286, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_4 = __pyx_t_5;
          __pyx_t_5 = 0;
        } else {
          __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_N_A);
          __pyx_t_4 = __pyx_mstate_global->__pyx_kp_u_N_A;
        }
        __pyx_t_40 = __pyx_cur_scope->__pyx_v_last_interval;
        __Pyx_INCREF(__pyx_t_40);
        __pyx_t_28 = __Pyx_HasAttr(__pyx_t_40, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(__pyx_t_28 == ((int)-1))) __PYX_ERR(0, 5286, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_40); __pyx_t_40 = 0;
        if (__pyx_t_28) {
          __pyx_t_40 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_40)) __PYX_ERR(0, 5286, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_40);
          __pyx_t_5 = __pyx_t_40;
          __pyx_t_40 = 0;
        } else {
          __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_N_A);
          __pyx_t_5 = __pyx_mstate_global->__pyx_kp_u_N_A;
        }
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_39 = PyMethod_GET_SELF(__pyx_t_6);
          assert(__pyx_t_39);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_39);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[6] = {__pyx_t_39, __pyx_mstate_global->__pyx_kp_u_Last_saved_interval_details_star, __pyx_t_24, __pyx_t_7, __pyx_t_4, __pyx_t_5};
          __pyx_t_23 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (6-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
          __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5286, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_23);
        }
        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

        /* "ws_package/controllers/activity_controller.py":5287
 *             if last_interval:
 *                 logger.info("Last saved interval details: start_time=%s, end_time=%s, is_uploaded=%s, counter=%s", last_interval.start_time, last_interval.end_time, last_interval.is_uploaded if hasattr(last_interval, 'is_uploaded') else 'N/A', last_interval.counter if hasattr(last_interval, 'counter') else 'N/A')
 *                 if intervals:             # <<<<<<<<<<<<<<
 *                     # Final check if last interval is in results (using tolerance-based comparison)
 *                     def datetime_matches_final(dt1, dt2, tolerance_seconds=1.0):
*/
        __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_intervals); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5287, __pyx_L4_error)
        if (__pyx_t_28) {

          /* "ws_package/controllers/activity_controller.py":5289
 *                 if intervals:
 *                     # Final check if last interval is in results (using tolerance-based comparison)
 *                     def datetime_matches_final(dt1, dt2, tolerance_seconds=1.0):             # <<<<<<<<<<<<<<
 *                         if dt1 is None or dt2 is None:
 *                             return False
*/
          __pyx_t_23 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_3datetime_matches_final, 0, __pyx_mstate_global->__pyx_n_u_ActivityController__last_api_cal_4, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[61])); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5289, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_23);
          __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_23, __pyx_mstate_global->__pyx_tuple[28]);
          __Pyx_GIVEREF(__pyx_t_23);
          __pyx_cur_scope->__pyx_v_datetime_matches_final = __pyx_t_23;
          __pyx_t_23 = 0;

          /* "ws_package/controllers/activity_controller.py":5299
 * 
 *                     last_interval_in_list = any(
 *                         datetime_matches_final(getattr(interval, 'start_time', None), last_interval.start_time) and             # <<<<<<<<<<<<<<
 *                         datetime_matches_final(getattr(interval, 'end_time', None), last_interval.end_time) and
 *                         getattr(interval, 'counter', None) == getattr(last_interval, 'counter', None)
*/
          __pyx_t_23 = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_10genexpr(((PyObject*)__pyx_cur_scope), __pyx_cur_scope->__pyx_v_intervals); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5299, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_23);
          __pyx_t_6 = __Pyx_Generator_GetInlinedResult(__pyx_t_23); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5299, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_GIVEREF(__pyx_t_6);
          __pyx_cur_scope->__pyx_v_last_interval_in_list = __pyx_t_6;
          __pyx_t_6 = 0;

          /* "ws_package/controllers/activity_controller.py":5304
 *                         for interval in intervals
 *                     )
 *                     if last_interval_in_list:             # <<<<<<<<<<<<<<
 *                         logger.info(" Last interval confirmed in query results - will be sent to server")
 *                     else:
*/
          __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval_in_list); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5304, __pyx_L4_error)
          if (__pyx_t_28) {

            /* "ws_package/controllers/activity_controller.py":5305
 *                     )
 *                     if last_interval_in_list:
 *                         logger.info(" Last interval confirmed in query results - will be sent to server")             # <<<<<<<<<<<<<<
 *                     else:
 *                         logger.warning(" Last interval may not be in query results - but was manually included if needed")
*/
            __pyx_t_23 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5305, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5305, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_4))) {
              __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_4);
              assert(__pyx_t_23);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
              __Pyx_INCREF(__pyx_t_23);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_23, __pyx_mstate_global->__pyx_kp_u_Last_interval_confirmed_in_quer};
              __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5305, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_6);
            }
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

            /* "ws_package/controllers/activity_controller.py":5304
 *                         for interval in intervals
 *                     )
 *                     if last_interval_in_list:             # <<<<<<<<<<<<<<
 *                         logger.info(" Last interval confirmed in query results - will be sent to server")
 *                     else:
*/
            goto __pyx_L326;
          }

          /* "ws_package/controllers/activity_controller.py":5307
 *                         logger.info(" Last interval confirmed in query results - will be sent to server")
 *                     else:
 *                         logger.warning(" Last interval may not be in query results - but was manually included if needed")             # <<<<<<<<<<<<<<
 *                 else:
 *                     logger.warning(" Query returned 0 intervals - last interval was manually included if needed")
*/
          /*else*/ {
            __pyx_t_4 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5307, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_23);
            __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5307, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_5))) {
              __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
              assert(__pyx_t_4);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
              __Pyx_INCREF(__pyx_t_4);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Last_interval_may_not_be_in_que};
              __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5307, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_6);
            }
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          }
          __pyx_L326:;

          /* "ws_package/controllers/activity_controller.py":5287
 *             if last_interval:
 *                 logger.info("Last saved interval details: start_time=%s, end_time=%s, is_uploaded=%s, counter=%s", last_interval.start_time, last_interval.end_time, last_interval.is_uploaded if hasattr(last_interval, 'is_uploaded') else 'N/A', last_interval.counter if hasattr(last_interval, 'counter') else 'N/A')
 *                 if intervals:             # <<<<<<<<<<<<<<
 *                     # Final check if last interval is in results (using tolerance-based comparison)
 *                     def datetime_matches_final(dt1, dt2, tolerance_seconds=1.0):
*/
          goto __pyx_L325;
        }

        /* "ws_package/controllers/activity_controller.py":5309
 *                         logger.warning(" Last interval may not be in query results - but was manually included if needed")
 *                 else:
 *                     logger.warning(" Query returned 0 intervals - last interval was manually included if needed")             # <<<<<<<<<<<<<<
 * 
 *             work_stop = self._finalize_work_stop_time(
*/
        /*else*/ {
          __pyx_t_5 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5309, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5309, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_23);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_23))) {
            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_23);
            assert(__pyx_t_5);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_23);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_23, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Query_returned_0_intervals_last};
            __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_23, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
            if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5309, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_6);
          }
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        }
        __pyx_L325:;

        /* "ws_package/controllers/activity_controller.py":5285
 * 
 *             # Log final status
 *             if last_interval:             # <<<<<<<<<<<<<<
 *                 logger.info("Last saved interval details: start_time=%s, end_time=%s, is_uploaded=%s, counter=%s", last_interval.start_time, last_interval.end_time, last_interval.is_uploaded if hasattr(last_interval, 'is_uploaded') else 'N/A', last_interval.counter if hasattr(last_interval, 'counter') else 'N/A')
 *                 if intervals:
*/
      }

      /* "ws_package/controllers/activity_controller.py":5311
 *                     logger.warning(" Query returned 0 intervals - last interval was manually included if needed")
 * 
 *             work_stop = self._finalize_work_stop_time(             # <<<<<<<<<<<<<<
 *                 last_interval=last_interval,
 *                 intervals=intervals,
*/
      __pyx_t_23 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_23);

      /* "ws_package/controllers/activity_controller.py":5314
 *                 last_interval=last_interval,
 *                 intervals=intervals,
 *                 fallback_end=end_date,             # <<<<<<<<<<<<<<
 *             )
 *             logger.info("Work segment stop for payload: %s (break will start at %s)", work_stop, work_stop + datetime.timedelta(seconds=1))
*/
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 3 : 0)] = {__pyx_t_23, NULL};
        __pyx_t_5 = __Pyx_MakeVectorcallBuilderKwds(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5311, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_last_interval, __pyx_cur_scope->__pyx_v_last_interval, __pyx_t_5, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 5311, __pyx_L4_error)
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_intervals, __pyx_cur_scope->__pyx_v_intervals, __pyx_t_5, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 5311, __pyx_L4_error)
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_fallback_end, __pyx_cur_scope->__pyx_v_end_date, __pyx_t_5, __pyx_callargs+1, 2) < (0)) __PYX_ERR(0, 5311, __pyx_L4_error)
        __pyx_t_6 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_finalize_work_stop_time, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_5);
        __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5311, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
      }
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_cur_scope->__pyx_v_work_stop = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":5316
 *                 fallback_end=end_date,
 *             )
 *             logger.info("Work segment stop for payload: %s (break will start at %s)", work_stop, work_stop + datetime.timedelta(seconds=1))             # <<<<<<<<<<<<<<
 * 
 *             sending_intervals = self.process_intervals_bulk(
*/
      __pyx_t_5 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5316, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_23);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5316, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
      __pyx_t_7 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5316, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_24);
      __pyx_t_39 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_timedelta); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5316, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_39);
      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_39))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_39);
        assert(__pyx_t_7);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_39);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_39, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_7, NULL};
        __pyx_t_24 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5316, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_24);
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_seconds, __pyx_mstate_global->__pyx_int_1, __pyx_t_24, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 5316, __pyx_L4_error)
        __pyx_t_23 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_39, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_24);
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
        __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
        if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5316, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_23);
      }
      __pyx_t_39 = PyNumber_Add(__pyx_cur_scope->__pyx_v_work_stop, __pyx_t_23); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5316, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_39);
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        assert(__pyx_t_5);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[4] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Work_segment_stop_for_payload_s, __pyx_cur_scope->__pyx_v_work_stop, __pyx_t_39};
        __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5316, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":5318
 *             logger.info("Work segment stop for payload: %s (break will start at %s)", work_stop, work_stop + datetime.timedelta(seconds=1))
 * 
 *             sending_intervals = self.process_intervals_bulk(             # <<<<<<<<<<<<<<
 *                 intervals,
 *                 user_entity.org_id,
*/
      __pyx_t_4 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_4);

      /* "ws_package/controllers/activity_controller.py":5320
 *             sending_intervals = self.process_intervals_bulk(
 *                 intervals,
 *                 user_entity.org_id,             # <<<<<<<<<<<<<<
 *                 user_entity,
 *                 last_interval=last_interval,
*/
      __pyx_t_39 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_org_id); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5320, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_39);

      /* "ws_package/controllers/activity_controller.py":5325
 *                 payload_project_id=payload_project_id,
 *                 payload_task_id=payload_task_id,
 *                 force_stop_time=close_time or work_stop,             # <<<<<<<<<<<<<<
 *             )
 * 
*/
      __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_close_time); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5325, __pyx_L4_error)
      if (!__pyx_t_28) {
      } else {
        __Pyx_INCREF(__pyx_cur_scope->__pyx_v_close_time);
        __pyx_t_5 = __pyx_cur_scope->__pyx_v_close_time;
        goto __pyx_L327_bool_binop_done;
      }
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_work_stop);
      __pyx_t_5 = __pyx_cur_scope->__pyx_v_work_stop;
      __pyx_L327_bool_binop_done:;
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[4 + ((CYTHON_VECTORCALL) ? 4 : 0)] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_intervals, __pyx_t_39, __pyx_cur_scope->__pyx_v_user_entity};
        __pyx_t_23 = __Pyx_MakeVectorcallBuilderKwds(4); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5318, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_23);
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_last_interval, __pyx_cur_scope->__pyx_v_last_interval, __pyx_t_23, __pyx_callargs+4, 0) < (0)) __PYX_ERR(0, 5318, __pyx_L4_error)
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_payload_project_id, __pyx_cur_scope->__pyx_v_payload_project_id, __pyx_t_23, __pyx_callargs+4, 1) < (0)) __PYX_ERR(0, 5318, __pyx_L4_error)
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_payload_task_id, __pyx_cur_scope->__pyx_v_payload_task_id, __pyx_t_23, __pyx_callargs+4, 2) < (0)) __PYX_ERR(0, 5318, __pyx_L4_error)
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_force_stop_time, __pyx_t_5, __pyx_t_23, __pyx_callargs+4, 3) < (0)) __PYX_ERR(0, 5318, __pyx_L4_error)
        __pyx_t_6 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_process_intervals_bulk, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_23);
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5318, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
      }
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_cur_scope->__pyx_v_sending_intervals = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":5329
 * 
 *             self.activity_service.headers = {
 *                 'SDToken': str(user_entity.sd_token),             # <<<<<<<<<<<<<<
 *                 'OrgID': str(user_entity.org_id),
 *                 'UserID': str(user_entity.user_id),
*/
      __pyx_t_6 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5329, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_sd_token); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5329, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_23);
      __pyx_t_5 = __Pyx_PyObject_Unicode(__pyx_t_23); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5329, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
      if (PyDict_SetItem(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_SDToken, __pyx_t_5) < (0)) __PYX_ERR(0, 5329, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "ws_package/controllers/activity_controller.py":5330
 *             self.activity_service.headers = {
 *                 'SDToken': str(user_entity.sd_token),
 *                 'OrgID': str(user_entity.org_id),             # <<<<<<<<<<<<<<
 *                 'UserID': str(user_entity.user_id),
 *                 'appVersion': str(self.appVersion),
*/
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_org_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5330, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_23 = __Pyx_PyObject_Unicode(__pyx_t_5); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5330, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_23);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (PyDict_SetItem(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_OrgID, __pyx_t_23) < (0)) __PYX_ERR(0, 5329, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

      /* "ws_package/controllers/activity_controller.py":5331
 *                 'SDToken': str(user_entity.sd_token),
 *                 'OrgID': str(user_entity.org_id),
 *                 'UserID': str(user_entity.user_id),             # <<<<<<<<<<<<<<
 *                 'appVersion': str(self.appVersion),
 *                 'Authorization': f'Bearer {user_entity.sd_token}'
*/
      __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_user_id); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5331, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_23);
      __pyx_t_5 = __Pyx_PyObject_Unicode(__pyx_t_23); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5331, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
      if (PyDict_SetItem(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_UserID, __pyx_t_5) < (0)) __PYX_ERR(0, 5329, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "ws_package/controllers/activity_controller.py":5332
 *                 'OrgID': str(user_entity.org_id),
 *                 'UserID': str(user_entity.user_id),
 *                 'appVersion': str(self.appVersion),             # <<<<<<<<<<<<<<
 *                 'Authorization': f'Bearer {user_entity.sd_token}'
 *             }
*/
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appVersion); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5332, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_23 = __Pyx_PyObject_Unicode(__pyx_t_5); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5332, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_23);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (PyDict_SetItem(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_appVersion, __pyx_t_23) < (0)) __PYX_ERR(0, 5329, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

      /* "ws_package/controllers/activity_controller.py":5333
 *                 'UserID': str(user_entity.user_id),
 *                 'appVersion': str(self.appVersion),
 *                 'Authorization': f'Bearer {user_entity.sd_token}'             # <<<<<<<<<<<<<<
 *             }
 * 
*/
      __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_sd_token); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5333, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_23);
      __pyx_t_5 = __Pyx_PyObject_FormatSimple(__pyx_t_23, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5333, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
      __pyx_t_23 = __Pyx_PyUnicode_Concat(__pyx_mstate_global->__pyx_kp_u_Bearer, __pyx_t_5); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5333, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_23);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (PyDict_SetItem(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_Authorization, __pyx_t_23) < (0)) __PYX_ERR(0, 5329, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

      /* "ws_package/controllers/activity_controller.py":5328
 *             )
 * 
 *             self.activity_service.headers = {             # <<<<<<<<<<<<<<
 *                 'SDToken': str(user_entity.sd_token),
 *                 'OrgID': str(user_entity.org_id),
*/
      __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5328, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_23);
      if (__Pyx_PyObject_SetAttrStr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_headers, __pyx_t_6) < (0)) __PYX_ERR(0, 5328, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

      /* "ws_package/controllers/activity_controller.py":5337
 * 
 *             # Track if last_interval was updated during batch processing
 *             last_interval_updated = False             # <<<<<<<<<<<<<<
 *             at_least_one_batch_successful = False
 *             # Track all interval IDs that were updated during batch processing
*/
      __pyx_cur_scope->__pyx_v_last_interval_updated = 0;

      /* "ws_package/controllers/activity_controller.py":5338
 *             # Track if last_interval was updated during batch processing
 *             last_interval_updated = False
 *             at_least_one_batch_successful = False             # <<<<<<<<<<<<<<
 *             # Track all interval IDs that were updated during batch processing
 *             updated_interval_ids = set()
*/
      __pyx_cur_scope->__pyx_v_at_least_one_batch_successful = 0;

      /* "ws_package/controllers/activity_controller.py":5340
 *             at_least_one_batch_successful = False
 *             # Track all interval IDs that were updated during batch processing
 *             updated_interval_ids = set()             # <<<<<<<<<<<<<<
 * 
 *             async for response in sending_intervals:
*/
      __pyx_t_23 = PySet_New(0); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5340, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_23);
      __Pyx_GIVEREF(__pyx_t_23);
      __pyx_cur_scope->__pyx_v_updated_interval_ids = ((PyObject*)__pyx_t_23);
      __pyx_t_23 = 0;

      /* "ws_package/controllers/activity_controller.py":5342
 *             updated_interval_ids = set()
 * 
 *             async for response in sending_intervals:             # <<<<<<<<<<<<<<
 *                 if not response or not isinstance(response, (list, tuple)):
 *                     logger.info("No interval found %s", response)
*/
      __pyx_t_23 = __Pyx_Coroutine_GetAsyncIter(__pyx_cur_scope->__pyx_v_sending_intervals); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5342, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_23);
      for (;;) {
        __pyx_t_6 = __Pyx_Coroutine_AsyncIterNext(__pyx_t_23); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5342, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_6, &__pyx_r);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (likely(__pyx_t_11 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_1);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
          __Pyx_XGIVEREF(__pyx_t_2);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
          __Pyx_XGIVEREF(__pyx_t_3);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
          __Pyx_XGIVEREF(__pyx_t_23);
          __pyx_cur_scope->__pyx_t_3 = __pyx_t_23;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 25;
          return __pyx_r;
          __pyx_L331_resume_from_await:;
          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_1);
          __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_2);
          __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_3);
          __pyx_t_23 = __pyx_cur_scope->__pyx_t_3;
          __pyx_cur_scope->__pyx_t_3 = 0;
          __Pyx_XGOTREF(__pyx_t_23);
          if (unlikely(!__pyx_sent_value)) {
            PyObject* exc_type = __Pyx_PyErr_CurrentExceptionType();
            if (unlikely(exc_type && (exc_type == PyExc_StopAsyncIteration || ( exc_type != PyExc_StopIteration && exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopAsyncIteration))))) {
              PyErr_Clear();
              break;
            }
            __PYX_ERR(0, 5342, __pyx_L4_error)
          }
          __pyx_t_6 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_6);
        } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __pyx_t_6 = __pyx_r; __pyx_r = NULL;
        } else {
          PyObject* exc_type = __Pyx_PyErr_CurrentExceptionType();
          if (unlikely(exc_type && (exc_type == PyExc_StopAsyncIteration || ( exc_type != PyExc_StopIteration && exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopAsyncIteration))))) {
            PyErr_Clear();
            break;
          }
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 5342, __pyx_L4_error)
        }
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_response);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_response, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_6);
        __pyx_t_6 = 0;

        /* "ws_package/controllers/activity_controller.py":5343
 * 
 *             async for response in sending_intervals:
 *                 if not response or not isinstance(response, (list, tuple)):             # <<<<<<<<<<<<<<
 *                     logger.info("No interval found %s", response)
 *                     continue
*/
        __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_response); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5343, __pyx_L4_error)
        __pyx_t_9 = (!__pyx_t_47);
        if (!__pyx_t_9) {
        } else {
          __pyx_t_28 = __pyx_t_9;
          goto __pyx_L333_bool_binop_done;
        }
        __pyx_t_47 = PyList_Check(__pyx_cur_scope->__pyx_v_response); 
        if (!__pyx_t_47) {
        } else {
          __pyx_t_9 = __pyx_t_47;
          goto __pyx_L335_bool_binop_done;
        }
        __pyx_t_47 = PyTuple_Check(__pyx_cur_scope->__pyx_v_response); 
        __pyx_t_9 = __pyx_t_47;
        __pyx_L335_bool_binop_done:;
        __pyx_t_47 = (!__pyx_t_9);
        __pyx_t_28 = __pyx_t_47;
        __pyx_L333_bool_binop_done:;
        if (__pyx_t_28) {

          /* "ws_package/controllers/activity_controller.py":5344
 *             async for response in sending_intervals:
 *                 if not response or not isinstance(response, (list, tuple)):
 *                     logger.info("No interval found %s", response)             # <<<<<<<<<<<<<<
 *                     continue
 * 
*/
          __pyx_t_5 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5344, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_39);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5344, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_4))) {
            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
            assert(__pyx_t_5);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_5);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_No_interval_found_s, __pyx_cur_scope->__pyx_v_response};
            __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5344, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_6);
          }
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

          /* "ws_package/controllers/activity_controller.py":5345
 *                 if not response or not isinstance(response, (list, tuple)):
 *                     logger.info("No interval found %s", response)
 *                     continue             # <<<<<<<<<<<<<<
 * 
 *                 _response = self.activity_service.push_activity_logs(response[0])
*/
          goto __pyx_L329_continue;

          /* "ws_package/controllers/activity_controller.py":5343
 * 
 *             async for response in sending_intervals:
 *                 if not response or not isinstance(response, (list, tuple)):             # <<<<<<<<<<<<<<
 *                     logger.info("No interval found %s", response)
 *                     continue
*/
        }

        /* "ws_package/controllers/activity_controller.py":5347
 *                     continue
 * 
 *                 _response = self.activity_service.push_activity_logs(response[0])             # <<<<<<<<<<<<<<
 *                 logger.info("Response: %s", _response)
 *                 if _response and _response.get("message") == "Token is Expired":
*/
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5347, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_4 = __pyx_t_5;
        __Pyx_INCREF(__pyx_t_4);
        __pyx_t_39 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_response, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_SharedReference); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5347, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_39);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_39};
          __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_push_activity_logs, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5347, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v__response);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v__response, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_6);
        __pyx_t_6 = 0;

        /* "ws_package/controllers/activity_controller.py":5348
 * 
 *                 _response = self.activity_service.push_activity_logs(response[0])
 *                 logger.info("Response: %s", _response)             # <<<<<<<<<<<<<<
 *                 if _response and _response.get("message") == "Token is Expired":
 *                     logger.info("Token is Expired")
*/
        __pyx_t_5 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5348, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_39);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5348, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
          assert(__pyx_t_5);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Response_s, __pyx_cur_scope->__pyx_v__response};
          __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5348, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "ws_package/controllers/activity_controller.py":5349
 *                 _response = self.activity_service.push_activity_logs(response[0])
 *                 logger.info("Response: %s", _response)
 *                 if _response and _response.get("message") == "Token is Expired":             # <<<<<<<<<<<<<<
 *                     logger.info("Token is Expired")
 *                     self._send_subscription_expired_popup(_response)
*/
        __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v__response); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5349, __pyx_L4_error)
        if (__pyx_t_47) {
        } else {
          __pyx_t_28 = __pyx_t_47;
          goto __pyx_L338_bool_binop_done;
        }
        __pyx_t_4 = __pyx_cur_scope->__pyx_v__response;
        __Pyx_INCREF(__pyx_t_4);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_n_u_message};
          __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5349, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __pyx_t_47 = (__Pyx_PyUnicode_Equals(__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Token_is_Expired, Py_EQ)); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5349, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_28 = __pyx_t_47;
        __pyx_L338_bool_binop_done:;
        if (__pyx_t_28) {

          /* "ws_package/controllers/activity_controller.py":5350
 *                 logger.info("Response: %s", _response)
 *                 if _response and _response.get("message") == "Token is Expired":
 *                     logger.info("Token is Expired")             # <<<<<<<<<<<<<<
 *                     self._send_subscription_expired_popup(_response)
 *                     self.status = False
*/
          __pyx_t_4 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5350, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_39 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5350, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_39);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_39))) {
            __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_39);
            assert(__pyx_t_4);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_39);
            __Pyx_INCREF(__pyx_t_4);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_39, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Token_is_Expired};
            __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_39, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
            if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5350, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_6);
          }
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

          /* "ws_package/controllers/activity_controller.py":5351
 *                 if _response and _response.get("message") == "Token is Expired":
 *                     logger.info("Token is Expired")
 *                     self._send_subscription_expired_popup(_response)             # <<<<<<<<<<<<<<
 *                     self.status = False
 * 
*/
          __pyx_t_39 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_39);
          __pyx_t_8 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_39, __pyx_cur_scope->__pyx_v__response};
            __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_send_subscription_expired_popup, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
            if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5351, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_6);
          }
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

          /* "ws_package/controllers/activity_controller.py":5352
 *                     logger.info("Token is Expired")
 *                     self._send_subscription_expired_popup(_response)
 *                     self.status = False             # <<<<<<<<<<<<<<
 * 
 *                 elif _response and (
*/
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status, Py_False) < (0)) __PYX_ERR(0, 5352, __pyx_L4_error)

          /* "ws_package/controllers/activity_controller.py":5349
 *                 _response = self.activity_service.push_activity_logs(response[0])
 *                 logger.info("Response: %s", _response)
 *                 if _response and _response.get("message") == "Token is Expired":             # <<<<<<<<<<<<<<
 *                     logger.info("Token is Expired")
 *                     self._send_subscription_expired_popup(_response)
*/
          goto __pyx_L337;
        }

        /* "ws_package/controllers/activity_controller.py":5354
 *                     self.status = False
 * 
 *                 elif _response and (             # <<<<<<<<<<<<<<
 *                     _response.get("planStatus") != "active"
 *                     or _response.get("isdeleted") == 1
*/
        __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v__response); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5354, __pyx_L4_error)
        if (__pyx_t_47) {
        } else {
          __pyx_t_28 = __pyx_t_47;
          goto __pyx_L340_bool_binop_done;
        }

        /* "ws_package/controllers/activity_controller.py":5355
 * 
 *                 elif _response and (
 *                     _response.get("planStatus") != "active"             # <<<<<<<<<<<<<<
 *                     or _response.get("isdeleted") == 1
 *                     or _response.get("isdeactivated") == 1
*/
        __pyx_t_39 = __pyx_cur_scope->__pyx_v__response;
        __Pyx_INCREF(__pyx_t_39);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_39, __pyx_mstate_global->__pyx_n_u_planStatus};
          __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5355, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __pyx_t_47 = (__Pyx_PyUnicode_Equals(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_active, Py_NE)); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5355, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (!__pyx_t_47) {
        } else {
          __pyx_t_28 = __pyx_t_47;
          goto __pyx_L340_bool_binop_done;
        }

        /* "ws_package/controllers/activity_controller.py":5356
 *                 elif _response and (
 *                     _response.get("planStatus") != "active"
 *                     or _response.get("isdeleted") == 1             # <<<<<<<<<<<<<<
 *                     or _response.get("isdeactivated") == 1
 *                 ):
*/
        __pyx_t_39 = __pyx_cur_scope->__pyx_v__response;
        __Pyx_INCREF(__pyx_t_39);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_39, __pyx_mstate_global->__pyx_n_u_isdeleted};
          __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5356, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __pyx_t_47 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_6, __pyx_mstate_global->__pyx_int_1, 1, 0)); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5356, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (!__pyx_t_47) {
        } else {
          __pyx_t_28 = __pyx_t_47;
          goto __pyx_L340_bool_binop_done;
        }

        /* "ws_package/controllers/activity_controller.py":5357
 *                     _response.get("planStatus") != "active"
 *                     or _response.get("isdeleted") == 1
 *                     or _response.get("isdeactivated") == 1             # <<<<<<<<<<<<<<
 *                 ):
 *                     logger.error("Either plan status Deactivated use deleted or user deactivated")
*/
        __pyx_t_39 = __pyx_cur_scope->__pyx_v__response;
        __Pyx_INCREF(__pyx_t_39);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_39, __pyx_mstate_global->__pyx_n_u_isdeactivated};
          __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5357, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __pyx_t_47 = (__Pyx_PyLong_BoolEqObjC(__pyx_t_6, __pyx_mstate_global->__pyx_int_1, 1, 0)); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5357, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_28 = __pyx_t_47;
        __pyx_L340_bool_binop_done:;

        /* "ws_package/controllers/activity_controller.py":5354
 *                     self.status = False
 * 
 *                 elif _response and (             # <<<<<<<<<<<<<<
 *                     _response.get("planStatus") != "active"
 *                     or _response.get("isdeleted") == 1
*/
        if (__pyx_t_28) {

          /* "ws_package/controllers/activity_controller.py":5359
 *                     or _response.get("isdeactivated") == 1
 *                 ):
 *                     logger.error("Either plan status Deactivated use deleted or user deactivated")             # <<<<<<<<<<<<<<
 *                     self._send_subscription_expired_popup(_response)
 *                     self.status = False
*/
          __pyx_t_39 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5359, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5359, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_5))) {
            __pyx_t_39 = PyMethod_GET_SELF(__pyx_t_5);
            assert(__pyx_t_39);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_39);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_39, __pyx_mstate_global->__pyx_kp_u_Either_plan_status_Deactivated_u};
            __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5359, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_6);
          }
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

          /* "ws_package/controllers/activity_controller.py":5360
 *                 ):
 *                     logger.error("Either plan status Deactivated use deleted or user deactivated")
 *                     self._send_subscription_expired_popup(_response)             # <<<<<<<<<<<<<<
 *                     self.status = False
 * 
*/
          __pyx_t_5 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_5);
          __pyx_t_8 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_cur_scope->__pyx_v__response};
            __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_send_subscription_expired_popup, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5360, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_6);
          }
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

          /* "ws_package/controllers/activity_controller.py":5361
 *                     logger.error("Either plan status Deactivated use deleted or user deactivated")
 *                     self._send_subscription_expired_popup(_response)
 *                     self.status = False             # <<<<<<<<<<<<<<
 * 
 *                 elif _response and _response.get("planStatus") == "active":
*/
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status, Py_False) < (0)) __PYX_ERR(0, 5361, __pyx_L4_error)

          /* "ws_package/controllers/activity_controller.py":5354
 *                     self.status = False
 * 
 *                 elif _response and (             # <<<<<<<<<<<<<<
 *                     _response.get("planStatus") != "active"
 *                     or _response.get("isdeleted") == 1
*/
          goto __pyx_L337;
        }

        /* "ws_package/controllers/activity_controller.py":5363
 *                     self.status = False
 * 
 *                 elif _response and _response.get("planStatus") == "active":             # <<<<<<<<<<<<<<
 *                     at_least_one_batch_successful = True
 * 
*/
        __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v__response); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5363, __pyx_L4_error)
        if (__pyx_t_47) {
        } else {
          __pyx_t_28 = __pyx_t_47;
          goto __pyx_L344_bool_binop_done;
        }
        __pyx_t_5 = __pyx_cur_scope->__pyx_v__response;
        __Pyx_INCREF(__pyx_t_5);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_n_u_planStatus};
          __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5363, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __pyx_t_47 = (__Pyx_PyUnicode_Equals(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_active, Py_EQ)); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5363, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_28 = __pyx_t_47;
        __pyx_L344_bool_binop_done:;
        if (__pyx_t_28) {

          /* "ws_package/controllers/activity_controller.py":5364
 * 
 *                 elif _response and _response.get("planStatus") == "active":
 *                     at_least_one_batch_successful = True             # <<<<<<<<<<<<<<
 * 
 *                     intervals_to_update = []
*/
          __pyx_cur_scope->__pyx_v_at_least_one_batch_successful = 1;

          /* "ws_package/controllers/activity_controller.py":5366
 *                     at_least_one_batch_successful = True
 * 
 *                     intervals_to_update = []             # <<<<<<<<<<<<<<
 *                     for interval in response[1]:
 *                         # If interval already has an ID, use it directly
*/
          __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5366, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_intervals_to_update);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_intervals_to_update, ((PyObject*)__pyx_t_6));
          __Pyx_GIVEREF(__pyx_t_6);
          __pyx_t_6 = 0;

          /* "ws_package/controllers/activity_controller.py":5367
 * 
 *                     intervals_to_update = []
 *                     for interval in response[1]:             # <<<<<<<<<<<<<<
 *                         # If interval already has an ID, use it directly
 *                         if hasattr(interval, 'id') and interval.id:
*/
          __pyx_t_6 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_response, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_SharedReference); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5367, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
          if (likely(PyList_CheckExact(__pyx_t_6)) || PyTuple_CheckExact(__pyx_t_6)) {
            __pyx_t_5 = __pyx_t_6; __Pyx_INCREF(__pyx_t_5);
            __pyx_t_45 = 0;
            __pyx_t_35 = NULL;
          } else {
            __pyx_t_45 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5367, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_35 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); if (unlikely(!__pyx_t_35)) __PYX_ERR(0, 5367, __pyx_L4_error)
          }
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          for (;;) {
            if (likely(!__pyx_t_35)) {
              if (likely(PyList_CheckExact(__pyx_t_5))) {
                {
                  Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_5);
                  #if !CYTHON_ASSUME_SAFE_SIZE
                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5367, __pyx_L4_error)
                  #endif
                  if (__pyx_t_45 >= __pyx_temp) break;
                }
                __pyx_t_6 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_5, __pyx_t_45, __Pyx_ReferenceSharing_OwnStrongReference);
                ++__pyx_t_45;
              } else {
                {
                  Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_5);
                  #if !CYTHON_ASSUME_SAFE_SIZE
                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5367, __pyx_L4_error)
                  #endif
                  if (__pyx_t_45 >= __pyx_temp) break;
                }
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_6 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_45));
                #else
                __pyx_t_6 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_45);
                #endif
                ++__pyx_t_45;
              }
              if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5367, __pyx_L4_error)
            } else {
              __pyx_t_6 = __pyx_t_35(__pyx_t_5);
              if (unlikely(!__pyx_t_6)) {
                PyObject* exc_type = PyErr_Occurred();
                if (exc_type) {
                  if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 5367, __pyx_L4_error)
                  PyErr_Clear();
                }
                break;
              }
            }
            __Pyx_GOTREF(__pyx_t_6);
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_6);
            __Pyx_GIVEREF(__pyx_t_6);
            __pyx_t_6 = 0;

            /* "ws_package/controllers/activity_controller.py":5369
 *                     for interval in response[1]:
 *                         # If interval already has an ID, use it directly
 *                         if hasattr(interval, 'id') and interval.id:             # <<<<<<<<<<<<<<
 *                             intervals_to_update.append(interval)
 *                             updated_interval_ids.add(interval.id)
*/
            __pyx_t_47 = __Pyx_HasAttr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(__pyx_t_47 == ((int)-1))) __PYX_ERR(0, 5369, __pyx_L4_error)
            if (__pyx_t_47) {
            } else {
              __pyx_t_28 = __pyx_t_47;
              goto __pyx_L349_bool_binop_done;
            }
            __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5369, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5369, __pyx_L4_error)
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __pyx_t_28 = __pyx_t_47;
            __pyx_L349_bool_binop_done:;
            if (__pyx_t_28) {

              /* "ws_package/controllers/activity_controller.py":5370
 *                         # If interval already has an ID, use it directly
 *                         if hasattr(interval, 'id') and interval.id:
 *                             intervals_to_update.append(interval)             # <<<<<<<<<<<<<<
 *                             updated_interval_ids.add(interval.id)
 *                         else:
*/
              __pyx_t_50 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_intervals_to_update, __pyx_cur_scope->__pyx_v_interval); if (unlikely(__pyx_t_50 == ((int)-1))) __PYX_ERR(0, 5370, __pyx_L4_error)

              /* "ws_package/controllers/activity_controller.py":5371
 *                         if hasattr(interval, 'id') and interval.id:
 *                             intervals_to_update.append(interval)
 *                             updated_interval_ids.add(interval.id)             # <<<<<<<<<<<<<<
 *                         else:
 *                             # Query database to find the actual record with ID
*/
              __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5371, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_6);
              __pyx_t_50 = PySet_Add(__pyx_cur_scope->__pyx_v_updated_interval_ids, __pyx_t_6); if (unlikely(__pyx_t_50 == ((int)-1))) __PYX_ERR(0, 5371, __pyx_L4_error)
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

              /* "ws_package/controllers/activity_controller.py":5369
 *                     for interval in response[1]:
 *                         # If interval already has an ID, use it directly
 *                         if hasattr(interval, 'id') and interval.id:             # <<<<<<<<<<<<<<
 *                             intervals_to_update.append(interval)
 *                             updated_interval_ids.add(interval.id)
*/
              goto __pyx_L348;
            }

            /* "ws_package/controllers/activity_controller.py":5374
 *                         else:
 *                             # Query database to find the actual record with ID
 *                             try:             # <<<<<<<<<<<<<<
 *                                 with db_lock_manager.read_lock():
 *                                     async with async_session() as session:
*/
            /*else*/ {
              {
                __Pyx_ExceptionSave(&__pyx_t_14, &__pyx_t_13, &__pyx_t_12);
                __Pyx_XGOTREF(__pyx_t_14);
                __Pyx_XGOTREF(__pyx_t_13);
                __Pyx_XGOTREF(__pyx_t_12);
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":5375
 *                             # Query database to find the actual record with ID
 *                             try:
 *                                 with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                                     async with async_session() as session:
 *                                         # Match by start_time, end_time, and counter
*/
                  /*with:*/ {
                    __pyx_t_39 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5375, __pyx_L351_error)
                    __Pyx_GOTREF(__pyx_t_4);
                    __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5375, __pyx_L351_error)
                    __Pyx_GOTREF(__pyx_t_24);
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __pyx_t_8 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_24))) {
                      __pyx_t_39 = PyMethod_GET_SELF(__pyx_t_24);
                      assert(__pyx_t_39);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_24);
                      __Pyx_INCREF(__pyx_t_39);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_24, __pyx__function);
                      __pyx_t_8 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_39, NULL};
                      __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_24, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5375, __pyx_L351_error)
                      __Pyx_GOTREF(__pyx_t_6);
                    }
                    __pyx_t_19 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 5375, __pyx_L351_error)
                    __Pyx_GOTREF(__pyx_t_19);
                    __pyx_t_39 = NULL;
                    __pyx_t_4 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5375, __pyx_L359_error)
                    __Pyx_GOTREF(__pyx_t_4);
                    __pyx_t_8 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (likely(PyMethod_Check(__pyx_t_4))) {
                      __pyx_t_39 = PyMethod_GET_SELF(__pyx_t_4);
                      assert(__pyx_t_39);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                      __Pyx_INCREF(__pyx_t_39);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                      __pyx_t_8 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_39, NULL};
                      __pyx_t_24 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5375, __pyx_L359_error)
                      __Pyx_GOTREF(__pyx_t_24);
                    }
                    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    /*try:*/ {
                      {
                        __Pyx_ExceptionSave(&__pyx_t_20, &__pyx_t_37, &__pyx_t_15);
                        __Pyx_XGOTREF(__pyx_t_20);
                        __Pyx_XGOTREF(__pyx_t_37);
                        __Pyx_XGOTREF(__pyx_t_15);
                        /*try:*/ {

                          /* "ws_package/controllers/activity_controller.py":5376
 *                             try:
 *                                 with db_lock_manager.read_lock():
 *                                     async with async_session() as session:             # <<<<<<<<<<<<<<
 *                                         # Match by start_time, end_time, and counter
 *                                         query = select(ActivityInterval).where(
*/
                          /*with:*/ {
                            __pyx_t_24 = NULL;
                            __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5376, __pyx_L365_error)
                            __Pyx_GOTREF(__pyx_t_4);
                            __pyx_t_8 = 1;
                            #if CYTHON_UNPACK_METHODS
                            if (unlikely(PyMethod_Check(__pyx_t_4))) {
                              __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_4);
                              assert(__pyx_t_24);
                              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                              __Pyx_INCREF(__pyx_t_24);
                              __Pyx_INCREF(__pyx__function);
                              __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                              __pyx_t_8 = 0;
                            }
                            #endif
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_24, NULL};
                              __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                              if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5376, __pyx_L365_error)
                              __Pyx_GOTREF(__pyx_t_6);
                            }
                            __pyx_t_18 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 5376, __pyx_L365_error)
                            __Pyx_GOTREF(__pyx_t_18);
                            __pyx_t_24 = NULL;
                            __pyx_t_39 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5376, __pyx_L373_error)
                            __Pyx_GOTREF(__pyx_t_39);
                            __pyx_t_8 = 1;
                            #if CYTHON_UNPACK_METHODS
                            if (likely(PyMethod_Check(__pyx_t_39))) {
                              __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_39);
                              assert(__pyx_t_24);
                              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_39);
                              __Pyx_INCREF(__pyx_t_24);
                              __Pyx_INCREF(__pyx__function);
                              __Pyx_DECREF_SET(__pyx_t_39, __pyx__function);
                              __pyx_t_8 = 0;
                            }
                            #endif
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_24, NULL};
                              __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_39, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                              __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5376, __pyx_L373_error)
                              __Pyx_GOTREF(__pyx_t_4);
                            }
                            __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
                            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                            if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                              __Pyx_GOTREF(__pyx_r);
                              __Pyx_XGIVEREF(__pyx_t_1);
                              __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                              __Pyx_XGIVEREF(__pyx_t_2);
                              __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                              __Pyx_XGIVEREF(__pyx_t_3);
                              __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                              __Pyx_XGIVEREF(__pyx_t_5);
                              __pyx_cur_scope->__pyx_t_3 = __pyx_t_5;
                              __Pyx_XGIVEREF(__pyx_t_6);
                              __pyx_cur_scope->__pyx_t_4 = __pyx_t_6;
                              __Pyx_XGIVEREF(__pyx_t_12);
                              __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                              __Pyx_XGIVEREF(__pyx_t_13);
                              __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                              __Pyx_XGIVEREF(__pyx_t_14);
                              __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                              __Pyx_XGIVEREF(__pyx_t_15);
                              __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                              __Pyx_XGIVEREF(__pyx_t_18);
                              __pyx_cur_scope->__pyx_t_9 = __pyx_t_18;
                              __Pyx_XGIVEREF(__pyx_t_19);
                              __pyx_cur_scope->__pyx_t_10 = __pyx_t_19;
                              __Pyx_XGIVEREF(__pyx_t_20);
                              __pyx_cur_scope->__pyx_t_11 = __pyx_t_20;
                              __Pyx_XGIVEREF(__pyx_t_23);
                              __pyx_cur_scope->__pyx_t_12 = __pyx_t_23;
                              __pyx_cur_scope->__pyx_t_18 = __pyx_t_35;
                              __Pyx_XGIVEREF(__pyx_t_37);
                              __pyx_cur_scope->__pyx_t_13 = __pyx_t_37;
                              __pyx_cur_scope->__pyx_t_23 = __pyx_t_45;
                              __Pyx_XGIVEREF(__pyx_r);
                              __Pyx_RefNannyFinishContext();
                              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                              /* return from generator, awaiting value */
                              __pyx_generator->resume_label = 26;
                              return __pyx_r;
                              __pyx_L374_resume_from_await:;
                              __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                              __pyx_cur_scope->__pyx_t_0 = 0;
                              __Pyx_XGOTREF(__pyx_t_1);
                              __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                              __pyx_cur_scope->__pyx_t_1 = 0;
                              __Pyx_XGOTREF(__pyx_t_2);
                              __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                              __pyx_cur_scope->__pyx_t_2 = 0;
                              __Pyx_XGOTREF(__pyx_t_3);
                              __pyx_t_5 = __pyx_cur_scope->__pyx_t_3;
                              __pyx_cur_scope->__pyx_t_3 = 0;
                              __Pyx_XGOTREF(__pyx_t_5);
                              __pyx_t_6 = __pyx_cur_scope->__pyx_t_4;
                              __pyx_cur_scope->__pyx_t_4 = 0;
                              __Pyx_XGOTREF(__pyx_t_6);
                              __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                              __pyx_cur_scope->__pyx_t_5 = 0;
                              __Pyx_XGOTREF(__pyx_t_12);
                              __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                              __pyx_cur_scope->__pyx_t_6 = 0;
                              __Pyx_XGOTREF(__pyx_t_13);
                              __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                              __pyx_cur_scope->__pyx_t_7 = 0;
                              __Pyx_XGOTREF(__pyx_t_14);
                              __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                              __pyx_cur_scope->__pyx_t_8 = 0;
                              __Pyx_XGOTREF(__pyx_t_15);
                              __pyx_t_18 = __pyx_cur_scope->__pyx_t_9;
                              __pyx_cur_scope->__pyx_t_9 = 0;
                              __Pyx_XGOTREF(__pyx_t_18);
                              __pyx_t_19 = __pyx_cur_scope->__pyx_t_10;
                              __pyx_cur_scope->__pyx_t_10 = 0;
                              __Pyx_XGOTREF(__pyx_t_19);
                              __pyx_t_20 = __pyx_cur_scope->__pyx_t_11;
                              __pyx_cur_scope->__pyx_t_11 = 0;
                              __Pyx_XGOTREF(__pyx_t_20);
                              __pyx_t_23 = __pyx_cur_scope->__pyx_t_12;
                              __pyx_cur_scope->__pyx_t_12 = 0;
                              __Pyx_XGOTREF(__pyx_t_23);
                              __pyx_t_35 = __pyx_cur_scope->__pyx_t_18;
                              __pyx_t_37 = __pyx_cur_scope->__pyx_t_13;
                              __pyx_cur_scope->__pyx_t_13 = 0;
                              __Pyx_XGOTREF(__pyx_t_37);
                              __pyx_t_45 = __pyx_cur_scope->__pyx_t_23;
                              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5376, __pyx_L373_error)
                              __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                            } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                              __Pyx_GOTREF(__pyx_r);
                              __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                            } else {
                              __Pyx_XGOTREF(__pyx_r);
                              __PYX_ERR(0, 5376, __pyx_L373_error)
                            }
                            __pyx_t_39 = __pyx_t_4;
                            __pyx_t_4 = 0;
                            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                            /*try:*/ {
                              {
                                __Pyx_ExceptionSave(&__pyx_t_17, &__pyx_t_22, &__pyx_t_21);
                                __Pyx_XGOTREF(__pyx_t_17);
                                __Pyx_XGOTREF(__pyx_t_22);
                                __Pyx_XGOTREF(__pyx_t_21);
                                /*try:*/ {
                                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_session);
                                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_session, __pyx_t_39);
                                  __Pyx_GIVEREF(__pyx_t_39);
                                  __pyx_t_39 = 0;

                                  /* "ws_package/controllers/activity_controller.py":5378
 *                                     async with async_session() as session:
 *                                         # Match by start_time, end_time, and counter
 *                                         query = select(ActivityInterval).where(             # <<<<<<<<<<<<<<
 *                                             ActivityInterval.start_time == interval.start_time,
 *                                             ActivityInterval.end_time == interval.end_time,
*/
                                  __pyx_t_26 = NULL;
                                  __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5378, __pyx_L380_error)
                                  __Pyx_GOTREF(__pyx_t_10);
                                  __Pyx_GetModuleGlobalName(__pyx_t_27, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 5378, __pyx_L380_error)
                                  __Pyx_GOTREF(__pyx_t_27);
                                  __pyx_t_8 = 1;
                                  #if CYTHON_UNPACK_METHODS
                                  if (unlikely(PyMethod_Check(__pyx_t_10))) {
                                    __pyx_t_26 = PyMethod_GET_SELF(__pyx_t_10);
                                    assert(__pyx_t_26);
                                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
                                    __Pyx_INCREF(__pyx_t_26);
                                    __Pyx_INCREF(__pyx__function);
                                    __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
                                    __pyx_t_8 = 0;
                                  }
                                  #endif
                                  {
                                    PyObject *__pyx_callargs[2] = {__pyx_t_26, __pyx_t_27};
                                    __pyx_t_25 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                    __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                                    __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                                    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                                    if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5378, __pyx_L380_error)
                                    __Pyx_GOTREF(__pyx_t_25);
                                  }
                                  __pyx_t_40 = __pyx_t_25;
                                  __Pyx_INCREF(__pyx_t_40);

                                  /* "ws_package/controllers/activity_controller.py":5379
 *                                         # Match by start_time, end_time, and counter
 *                                         query = select(ActivityInterval).where(
 *                                             ActivityInterval.start_time == interval.start_time,             # <<<<<<<<<<<<<<
 *                                             ActivityInterval.end_time == interval.end_time,
 *                                             ActivityInterval.counter == getattr(interval, 'counter', current_session_counter)
*/
                                  __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5379, __pyx_L380_error)
                                  __Pyx_GOTREF(__pyx_t_10);
                                  __pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 5379, __pyx_L380_error)
                                  __Pyx_GOTREF(__pyx_t_27);
                                  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                                  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5379, __pyx_L380_error)
                                  __Pyx_GOTREF(__pyx_t_10);
                                  __pyx_t_26 = PyObject_RichCompare(__pyx_t_27, __pyx_t_10, Py_EQ); __Pyx_XGOTREF(__pyx_t_26); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5379, __pyx_L380_error)
                                  __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                                  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

                                  /* "ws_package/controllers/activity_controller.py":5380
 *                                         query = select(ActivityInterval).where(
 *                                             ActivityInterval.start_time == interval.start_time,
 *                                             ActivityInterval.end_time == interval.end_time,             # <<<<<<<<<<<<<<
 *                                             ActivityInterval.counter == getattr(interval, 'counter', current_session_counter)
 *                                         ).order_by(ActivityInterval.id.desc()).limit(1)
*/
                                  __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5380, __pyx_L380_error)
                                  __Pyx_GOTREF(__pyx_t_10);
                                  __pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 5380, __pyx_L380_error)
                                  __Pyx_GOTREF(__pyx_t_27);
                                  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                                  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5380, __pyx_L380_error)
                                  __Pyx_GOTREF(__pyx_t_10);
                                  __pyx_t_38 = PyObject_RichCompare(__pyx_t_27, __pyx_t_10, Py_EQ); __Pyx_XGOTREF(__pyx_t_38); if (unlikely(!__pyx_t_38)) __PYX_ERR(0, 5380, __pyx_L380_error)
                                  __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                                  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

                                  /* "ws_package/controllers/activity_controller.py":5381
 *                                             ActivityInterval.start_time == interval.start_time,
 *                                             ActivityInterval.end_time == interval.end_time,
 *                                             ActivityInterval.counter == getattr(interval, 'counter', current_session_counter)             # <<<<<<<<<<<<<<
 *                                         ).order_by(ActivityInterval.id.desc()).limit(1)
 * 
*/
                                  __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5381, __pyx_L380_error)
                                  __Pyx_GOTREF(__pyx_t_10);
                                  __pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 5381, __pyx_L380_error)
                                  __Pyx_GOTREF(__pyx_t_27);
                                  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                                  __pyx_t_10 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_counter, __pyx_cur_scope->__pyx_v_current_session_counter); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5381, __pyx_L380_error)
                                  __Pyx_GOTREF(__pyx_t_10);
                                  __pyx_t_52 = PyObject_RichCompare(__pyx_t_27, __pyx_t_10, Py_EQ); __Pyx_XGOTREF(__pyx_t_52); if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5381, __pyx_L380_error)
                                  __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                                  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                                  __pyx_t_8 = 0;
                                  {
                                    PyObject *__pyx_callargs[4] = {__pyx_t_40, __pyx_t_26, __pyx_t_38, __pyx_t_52};
                                    __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                    __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                                    __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                                    __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0;
                                    __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
                                    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                                    if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5378, __pyx_L380_error)
                                    __Pyx_GOTREF(__pyx_t_7);
                                  }
                                  __pyx_t_24 = __pyx_t_7;
                                  __Pyx_INCREF(__pyx_t_24);

                                  /* "ws_package/controllers/activity_controller.py":5382
 *                                             ActivityInterval.end_time == interval.end_time,
 *                                             ActivityInterval.counter == getattr(interval, 'counter', current_session_counter)
 *                                         ).order_by(ActivityInterval.id.desc()).limit(1)             # <<<<<<<<<<<<<<
 * 
 *                                         result = await session.execute(query)
*/
                                  __Pyx_GetModuleGlobalName(__pyx_t_38, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_38)) __PYX_ERR(0, 5382, __pyx_L380_error)
                                  __Pyx_GOTREF(__pyx_t_38);
                                  __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_t_38, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5382, __pyx_L380_error)
                                  __Pyx_GOTREF(__pyx_t_26);
                                  __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0;
                                  __pyx_t_52 = __pyx_t_26;
                                  __Pyx_INCREF(__pyx_t_52);
                                  __pyx_t_8 = 0;
                                  {
                                    PyObject *__pyx_callargs[2] = {__pyx_t_52, NULL};
                                    __pyx_t_25 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_desc, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                    __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                                    __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                                    if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5382, __pyx_L380_error)
                                    __Pyx_GOTREF(__pyx_t_25);
                                  }
                                  __pyx_t_8 = 0;
                                  {
                                    PyObject *__pyx_callargs[2] = {__pyx_t_24, __pyx_t_25};
                                    __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_order_by, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                                    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                                    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                                    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5382, __pyx_L380_error)
                                    __Pyx_GOTREF(__pyx_t_4);
                                  }
                                  __pyx_t_6 = __pyx_t_4;
                                  __Pyx_INCREF(__pyx_t_6);
                                  __pyx_t_8 = 0;
                                  {
                                    PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_int_1};
                                    __pyx_t_39 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_limit, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                    if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5382, __pyx_L380_error)
                                    __Pyx_GOTREF(__pyx_t_39);
                                  }
                                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_query);
                                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_query, __pyx_t_39);
                                  __Pyx_GIVEREF(__pyx_t_39);
                                  __pyx_t_39 = 0;

                                  /* "ws_package/controllers/activity_controller.py":5384
 *                                         ).order_by(ActivityInterval.id.desc()).limit(1)
 * 
 *                                         result = await session.execute(query)             # <<<<<<<<<<<<<<
 *                                         db_interval = result.scalar_one_or_none()
 * 
*/
                                  __pyx_t_4 = __pyx_cur_scope->__pyx_v_session;
                                  __Pyx_INCREF(__pyx_t_4);
                                  __pyx_t_8 = 0;
                                  {
                                    PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_query};
                                    __pyx_t_39 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                                    if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5384, __pyx_L380_error)
                                    __Pyx_GOTREF(__pyx_t_39);
                                  }
                                  __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_39, &__pyx_r);
                                  __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                                  if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                    __Pyx_GOTREF(__pyx_r);
                                    __Pyx_XGIVEREF(__pyx_t_1);
                                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                    __Pyx_XGIVEREF(__pyx_t_2);
                                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                    __Pyx_XGIVEREF(__pyx_t_3);
                                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                    __Pyx_XGIVEREF(__pyx_t_5);
                                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_5;
                                    __Pyx_XGIVEREF(__pyx_t_12);
                                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                                    __Pyx_XGIVEREF(__pyx_t_13);
                                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                                    __Pyx_XGIVEREF(__pyx_t_14);
                                    __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                                    __Pyx_XGIVEREF(__pyx_t_15);
                                    __pyx_cur_scope->__pyx_t_7 = __pyx_t_15;
                                    __Pyx_XGIVEREF(__pyx_t_17);
                                    __pyx_cur_scope->__pyx_t_8 = __pyx_t_17;
                                    __Pyx_XGIVEREF(__pyx_t_18);
                                    __pyx_cur_scope->__pyx_t_9 = __pyx_t_18;
                                    __Pyx_XGIVEREF(__pyx_t_19);
                                    __pyx_cur_scope->__pyx_t_10 = __pyx_t_19;
                                    __Pyx_XGIVEREF(__pyx_t_20);
                                    __pyx_cur_scope->__pyx_t_11 = __pyx_t_20;
                                    __Pyx_XGIVEREF(__pyx_t_21);
                                    __pyx_cur_scope->__pyx_t_12 = __pyx_t_21;
                                    __Pyx_XGIVEREF(__pyx_t_22);
                                    __pyx_cur_scope->__pyx_t_13 = __pyx_t_22;
                                    __Pyx_XGIVEREF(__pyx_t_23);
                                    __pyx_cur_scope->__pyx_t_14 = __pyx_t_23;
                                    __pyx_cur_scope->__pyx_t_18 = __pyx_t_35;
                                    __Pyx_XGIVEREF(__pyx_t_37);
                                    __pyx_cur_scope->__pyx_t_15 = __pyx_t_37;
                                    __pyx_cur_scope->__pyx_t_23 = __pyx_t_45;
                                    __Pyx_XGIVEREF(__pyx_r);
                                    __Pyx_RefNannyFinishContext();
                                    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                                    /* return from generator, awaiting value */
                                    __pyx_generator->resume_label = 27;
                                    return __pyx_r;
                                    __pyx_L388_resume_from_await:;
                                    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                    __pyx_cur_scope->__pyx_t_0 = 0;
                                    __Pyx_XGOTREF(__pyx_t_1);
                                    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                    __pyx_cur_scope->__pyx_t_1 = 0;
                                    __Pyx_XGOTREF(__pyx_t_2);
                                    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                    __pyx_cur_scope->__pyx_t_2 = 0;
                                    __Pyx_XGOTREF(__pyx_t_3);
                                    __pyx_t_5 = __pyx_cur_scope->__pyx_t_3;
                                    __pyx_cur_scope->__pyx_t_3 = 0;
                                    __Pyx_XGOTREF(__pyx_t_5);
                                    __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                                    __pyx_cur_scope->__pyx_t_4 = 0;
                                    __Pyx_XGOTREF(__pyx_t_12);
                                    __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                                    __pyx_cur_scope->__pyx_t_5 = 0;
                                    __Pyx_XGOTREF(__pyx_t_13);
                                    __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                                    __pyx_cur_scope->__pyx_t_6 = 0;
                                    __Pyx_XGOTREF(__pyx_t_14);
                                    __pyx_t_15 = __pyx_cur_scope->__pyx_t_7;
                                    __pyx_cur_scope->__pyx_t_7 = 0;
                                    __Pyx_XGOTREF(__pyx_t_15);
                                    __pyx_t_17 = __pyx_cur_scope->__pyx_t_8;
                                    __pyx_cur_scope->__pyx_t_8 = 0;
                                    __Pyx_XGOTREF(__pyx_t_17);
                                    __pyx_t_18 = __pyx_cur_scope->__pyx_t_9;
                                    __pyx_cur_scope->__pyx_t_9 = 0;
                                    __Pyx_XGOTREF(__pyx_t_18);
                                    __pyx_t_19 = __pyx_cur_scope->__pyx_t_10;
                                    __pyx_cur_scope->__pyx_t_10 = 0;
                                    __Pyx_XGOTREF(__pyx_t_19);
                                    __pyx_t_20 = __pyx_cur_scope->__pyx_t_11;
                                    __pyx_cur_scope->__pyx_t_11 = 0;
                                    __Pyx_XGOTREF(__pyx_t_20);
                                    __pyx_t_21 = __pyx_cur_scope->__pyx_t_12;
                                    __pyx_cur_scope->__pyx_t_12 = 0;
                                    __Pyx_XGOTREF(__pyx_t_21);
                                    __pyx_t_22 = __pyx_cur_scope->__pyx_t_13;
                                    __pyx_cur_scope->__pyx_t_13 = 0;
                                    __Pyx_XGOTREF(__pyx_t_22);
                                    __pyx_t_23 = __pyx_cur_scope->__pyx_t_14;
                                    __pyx_cur_scope->__pyx_t_14 = 0;
                                    __Pyx_XGOTREF(__pyx_t_23);
                                    __pyx_t_35 = __pyx_cur_scope->__pyx_t_18;
                                    __pyx_t_37 = __pyx_cur_scope->__pyx_t_15;
                                    __pyx_cur_scope->__pyx_t_15 = 0;
                                    __Pyx_XGOTREF(__pyx_t_37);
                                    __pyx_t_45 = __pyx_cur_scope->__pyx_t_23;
                                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5384, __pyx_L380_error)
                                    __pyx_t_39 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_39);
                                  } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                    __Pyx_GOTREF(__pyx_r);
                                    __pyx_t_39 = __pyx_r; __pyx_r = NULL;
                                  } else {
                                    __Pyx_XGOTREF(__pyx_r);
                                    __PYX_ERR(0, 5384, __pyx_L380_error)
                                  }
                                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_result);
                                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_result, __pyx_t_39);
                                  __Pyx_GIVEREF(__pyx_t_39);
                                  __pyx_t_39 = 0;

                                  /* "ws_package/controllers/activity_controller.py":5385
 * 
 *                                         result = await session.execute(query)
 *                                         db_interval = result.scalar_one_or_none()             # <<<<<<<<<<<<<<
 * 
 *                                         if db_interval and db_interval.id:
*/
                                  __pyx_t_4 = __pyx_cur_scope->__pyx_v_result;
                                  __Pyx_INCREF(__pyx_t_4);
                                  __pyx_t_8 = 0;
                                  {
                                    PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
                                    __pyx_t_39 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalar_one_or_none, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                                    if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5385, __pyx_L380_error)
                                    __Pyx_GOTREF(__pyx_t_39);
                                  }
                                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_db_interval);
                                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_db_interval, __pyx_t_39);
                                  __Pyx_GIVEREF(__pyx_t_39);
                                  __pyx_t_39 = 0;

                                  /* "ws_package/controllers/activity_controller.py":5387
 *                                         db_interval = result.scalar_one_or_none()
 * 
 *                                         if db_interval and db_interval.id:             # <<<<<<<<<<<<<<
 *                                             intervals_to_update.append(db_interval)
 *                                             updated_interval_ids.add(db_interval.id)
*/
                                  __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_db_interval); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5387, __pyx_L380_error)
                                  if (__pyx_t_47) {
                                  } else {
                                    __pyx_t_28 = __pyx_t_47;
                                    goto __pyx_L390_bool_binop_done;
                                  }
                                  __pyx_t_39 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_db_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5387, __pyx_L380_error)
                                  __Pyx_GOTREF(__pyx_t_39);
                                  __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_t_39); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5387, __pyx_L380_error)
                                  __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                                  __pyx_t_28 = __pyx_t_47;
                                  __pyx_L390_bool_binop_done:;
                                  if (__pyx_t_28) {

                                    /* "ws_package/controllers/activity_controller.py":5388
 * 
 *                                         if db_interval and db_interval.id:
 *                                             intervals_to_update.append(db_interval)             # <<<<<<<<<<<<<<
 *                                             updated_interval_ids.add(db_interval.id)
 *                                             logger.debug("Found database record for interval: id=%s, start_time=%s, end_time=%s", db_interval.id, db_interval.start_time, db_interval.end_time)
*/
                                    __pyx_t_50 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_intervals_to_update, __pyx_cur_scope->__pyx_v_db_interval); if (unlikely(__pyx_t_50 == ((int)-1))) __PYX_ERR(0, 5388, __pyx_L380_error)

                                    /* "ws_package/controllers/activity_controller.py":5389
 *                                         if db_interval and db_interval.id:
 *                                             intervals_to_update.append(db_interval)
 *                                             updated_interval_ids.add(db_interval.id)             # <<<<<<<<<<<<<<
 *                                             logger.debug("Found database record for interval: id=%s, start_time=%s, end_time=%s", db_interval.id, db_interval.start_time, db_interval.end_time)
 *                                         else:
*/
                                    __pyx_t_39 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_db_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5389, __pyx_L380_error)
                                    __Pyx_GOTREF(__pyx_t_39);
                                    __pyx_t_50 = PySet_Add(__pyx_cur_scope->__pyx_v_updated_interval_ids, __pyx_t_39); if (unlikely(__pyx_t_50 == ((int)-1))) __PYX_ERR(0, 5389, __pyx_L380_error)
                                    __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;

                                    /* "ws_package/controllers/activity_controller.py":5390
 *                                             intervals_to_update.append(db_interval)
 *                                             updated_interval_ids.add(db_interval.id)
 *                                             logger.debug("Found database record for interval: id=%s, start_time=%s, end_time=%s", db_interval.id, db_interval.start_time, db_interval.end_time)             # <<<<<<<<<<<<<<
 *                                         else:
 *                                             logger.warning("Could not find database record for interval: start_time=%s, end_time=%s, counter=%s", interval.start_time, interval.end_time, getattr(interval, 'counter', 'N/A'))
*/
                                    __pyx_t_4 = NULL;
                                    __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5390, __pyx_L380_error)
                                    __Pyx_GOTREF(__pyx_t_6);
                                    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5390, __pyx_L380_error)
                                    __Pyx_GOTREF(__pyx_t_7);
                                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                                    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_db_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5390, __pyx_L380_error)
                                    __Pyx_GOTREF(__pyx_t_6);
                                    __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_db_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5390, __pyx_L380_error)
                                    __Pyx_GOTREF(__pyx_t_25);
                                    __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_db_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5390, __pyx_L380_error)
                                    __Pyx_GOTREF(__pyx_t_24);
                                    __pyx_t_8 = 1;
                                    #if CYTHON_UNPACK_METHODS
                                    if (unlikely(PyMethod_Check(__pyx_t_7))) {
                                      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7);
                                      assert(__pyx_t_4);
                                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                                      __Pyx_INCREF(__pyx_t_4);
                                      __Pyx_INCREF(__pyx__function);
                                      __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                                      __pyx_t_8 = 0;
                                    }
                                    #endif
                                    {
                                      PyObject *__pyx_callargs[5] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Found_database_record_for_interv, __pyx_t_6, __pyx_t_25, __pyx_t_24};
                                      __pyx_t_39 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                                      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                                      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                                      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                                      if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5390, __pyx_L380_error)
                                      __Pyx_GOTREF(__pyx_t_39);
                                    }
                                    __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;

                                    /* "ws_package/controllers/activity_controller.py":5387
 *                                         db_interval = result.scalar_one_or_none()
 * 
 *                                         if db_interval and db_interval.id:             # <<<<<<<<<<<<<<
 *                                             intervals_to_update.append(db_interval)
 *                                             updated_interval_ids.add(db_interval.id)
*/
                                    goto __pyx_L389;
                                  }

                                  /* "ws_package/controllers/activity_controller.py":5392
 *                                             logger.debug("Found database record for interval: id=%s, start_time=%s, end_time=%s", db_interval.id, db_interval.start_time, db_interval.end_time)
 *                                         else:
 *                                             logger.warning("Could not find database record for interval: start_time=%s, end_time=%s, counter=%s", interval.start_time, interval.end_time, getattr(interval, 'counter', 'N/A'))             # <<<<<<<<<<<<<<
 *                             except Exception as e:
 *                                 logger.error("Error querying database for interval: %s", e, exc_info=True)
*/
                                  /*else*/ {
                                    __pyx_t_7 = NULL;
                                    __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5392, __pyx_L380_error)
                                    __Pyx_GOTREF(__pyx_t_24);
                                    __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5392, __pyx_L380_error)
                                    __Pyx_GOTREF(__pyx_t_25);
                                    __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                                    __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5392, __pyx_L380_error)
                                    __Pyx_GOTREF(__pyx_t_24);
                                    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5392, __pyx_L380_error)
                                    __Pyx_GOTREF(__pyx_t_6);
                                    __pyx_t_4 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_counter, __pyx_mstate_global->__pyx_kp_u_N_A); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5392, __pyx_L380_error)
                                    __Pyx_GOTREF(__pyx_t_4);
                                    __pyx_t_8 = 1;
                                    #if CYTHON_UNPACK_METHODS
                                    if (unlikely(PyMethod_Check(__pyx_t_25))) {
                                      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_25);
                                      assert(__pyx_t_7);
                                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_25);
                                      __Pyx_INCREF(__pyx_t_7);
                                      __Pyx_INCREF(__pyx__function);
                                      __Pyx_DECREF_SET(__pyx_t_25, __pyx__function);
                                      __pyx_t_8 = 0;
                                    }
                                    #endif
                                    {
                                      PyObject *__pyx_callargs[5] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Could_not_find_database_record_f, __pyx_t_24, __pyx_t_6, __pyx_t_4};
                                      __pyx_t_39 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_25, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                                      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                                      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                                      if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5392, __pyx_L380_error)
                                      __Pyx_GOTREF(__pyx_t_39);
                                    }
                                    __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                                  }
                                  __pyx_L389:;

                                  /* "ws_package/controllers/activity_controller.py":5376
 *                             try:
 *                                 with db_lock_manager.read_lock():
 *                                     async with async_session() as session:             # <<<<<<<<<<<<<<
 *                                         # Match by start_time, end_time, and counter
 *                                         query = select(ActivityInterval).where(
*/
                                }
                                __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                                __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                                __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                                goto __pyx_L387_try_end;
                                __pyx_L380_error:;
                                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                                __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                                __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                                __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                                __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                                __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                                __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                                __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                                __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                                __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                                /*except:*/ {
                                  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
                                  if (__Pyx_GetException(&__pyx_t_39, &__pyx_t_25, &__pyx_t_4) < 0) __PYX_ERR(0, 5376, __pyx_L382_except_error)
                                  __Pyx_XGOTREF(__pyx_t_39);
                                  __Pyx_XGOTREF(__pyx_t_25);
                                  __Pyx_XGOTREF(__pyx_t_4);
                                  __pyx_t_6 = PyTuple_Pack(3, __pyx_t_39, __pyx_t_25, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5376, __pyx_L382_except_error)
                                  __Pyx_GOTREF(__pyx_t_6);
                                  __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_18, __pyx_t_6, NULL);
                                  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                                  if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 5376, __pyx_L382_except_error)
                                  __Pyx_GOTREF(__pyx_t_16);
                                  __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_16, &__pyx_r);
                                  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                                  if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                    __Pyx_GOTREF(__pyx_r);
                                    __Pyx_XGIVEREF(__pyx_t_1);
                                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                    __Pyx_XGIVEREF(__pyx_t_2);
                                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                    __Pyx_XGIVEREF(__pyx_t_3);
                                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                    __Pyx_XGIVEREF(__pyx_t_4);
                                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
                                    __Pyx_XGIVEREF(__pyx_t_5);
                                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_5;
                                    __Pyx_XGIVEREF(__pyx_t_12);
                                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                                    __Pyx_XGIVEREF(__pyx_t_13);
                                    __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                                    __Pyx_XGIVEREF(__pyx_t_14);
                                    __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                                    __Pyx_XGIVEREF(__pyx_t_15);
                                    __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                                    __Pyx_XGIVEREF(__pyx_t_16);
                                    __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                                    __Pyx_XGIVEREF(__pyx_t_17);
                                    __pyx_cur_scope->__pyx_t_10 = __pyx_t_17;
                                    __Pyx_XGIVEREF(__pyx_t_18);
                                    __pyx_cur_scope->__pyx_t_11 = __pyx_t_18;
                                    __Pyx_XGIVEREF(__pyx_t_19);
                                    __pyx_cur_scope->__pyx_t_12 = __pyx_t_19;
                                    __Pyx_XGIVEREF(__pyx_t_20);
                                    __pyx_cur_scope->__pyx_t_13 = __pyx_t_20;
                                    __Pyx_XGIVEREF(__pyx_t_21);
                                    __pyx_cur_scope->__pyx_t_14 = __pyx_t_21;
                                    __Pyx_XGIVEREF(__pyx_t_22);
                                    __pyx_cur_scope->__pyx_t_15 = __pyx_t_22;
                                    __Pyx_XGIVEREF(__pyx_t_23);
                                    __pyx_cur_scope->__pyx_t_16 = __pyx_t_23;
                                    __Pyx_XGIVEREF(__pyx_t_25);
                                    __pyx_cur_scope->__pyx_t_17 = __pyx_t_25;
                                    __pyx_cur_scope->__pyx_t_18 = __pyx_t_35;
                                    __Pyx_XGIVEREF(__pyx_t_37);
                                    __pyx_cur_scope->__pyx_t_19 = __pyx_t_37;
                                    __Pyx_XGIVEREF(__pyx_t_39);
                                    __pyx_cur_scope->__pyx_t_20 = __pyx_t_39;
                                    __pyx_cur_scope->__pyx_t_23 = __pyx_t_45;
                                    __Pyx_XGIVEREF(__pyx_r);
                                    __Pyx_RefNannyFinishContext();
                                    __Pyx_Coroutine_SwapException(__pyx_generator);
                                    /* return from generator, awaiting value */
                                    __pyx_generator->resume_label = 28;
                                    return __pyx_r;
                                    __pyx_L395_resume_from_await:;
                                    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                    __pyx_cur_scope->__pyx_t_0 = 0;
                                    __Pyx_XGOTREF(__pyx_t_1);
                                    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                    __pyx_cur_scope->__pyx_t_1 = 0;
                                    __Pyx_XGOTREF(__pyx_t_2);
                                    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                    __pyx_cur_scope->__pyx_t_2 = 0;
                                    __Pyx_XGOTREF(__pyx_t_3);
                                    __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
                                    __pyx_cur_scope->__pyx_t_3 = 0;
                                    __Pyx_XGOTREF(__pyx_t_4);
                                    __pyx_t_5 = __pyx_cur_scope->__pyx_t_4;
                                    __pyx_cur_scope->__pyx_t_4 = 0;
                                    __Pyx_XGOTREF(__pyx_t_5);
                                    __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                                    __pyx_cur_scope->__pyx_t_5 = 0;
                                    __Pyx_XGOTREF(__pyx_t_12);
                                    __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                                    __pyx_cur_scope->__pyx_t_6 = 0;
                                    __Pyx_XGOTREF(__pyx_t_13);
                                    __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                                    __pyx_cur_scope->__pyx_t_7 = 0;
                                    __Pyx_XGOTREF(__pyx_t_14);
                                    __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                                    __pyx_cur_scope->__pyx_t_8 = 0;
                                    __Pyx_XGOTREF(__pyx_t_15);
                                    __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                                    __pyx_cur_scope->__pyx_t_9 = 0;
                                    __Pyx_XGOTREF(__pyx_t_16);
                                    __pyx_t_17 = __pyx_cur_scope->__pyx_t_10;
                                    __pyx_cur_scope->__pyx_t_10 = 0;
                                    __Pyx_XGOTREF(__pyx_t_17);
                                    __pyx_t_18 = __pyx_cur_scope->__pyx_t_11;
                                    __pyx_cur_scope->__pyx_t_11 = 0;
                                    __Pyx_XGOTREF(__pyx_t_18);
                                    __pyx_t_19 = __pyx_cur_scope->__pyx_t_12;
                                    __pyx_cur_scope->__pyx_t_12 = 0;
                                    __Pyx_XGOTREF(__pyx_t_19);
                                    __pyx_t_20 = __pyx_cur_scope->__pyx_t_13;
                                    __pyx_cur_scope->__pyx_t_13 = 0;
                                    __Pyx_XGOTREF(__pyx_t_20);
                                    __pyx_t_21 = __pyx_cur_scope->__pyx_t_14;
                                    __pyx_cur_scope->__pyx_t_14 = 0;
                                    __Pyx_XGOTREF(__pyx_t_21);
                                    __pyx_t_22 = __pyx_cur_scope->__pyx_t_15;
                                    __pyx_cur_scope->__pyx_t_15 = 0;
                                    __Pyx_XGOTREF(__pyx_t_22);
                                    __pyx_t_23 = __pyx_cur_scope->__pyx_t_16;
                                    __pyx_cur_scope->__pyx_t_16 = 0;
                                    __Pyx_XGOTREF(__pyx_t_23);
                                    __pyx_t_25 = __pyx_cur_scope->__pyx_t_17;
                                    __pyx_cur_scope->__pyx_t_17 = 0;
                                    __Pyx_XGOTREF(__pyx_t_25);
                                    __pyx_t_35 = __pyx_cur_scope->__pyx_t_18;
                                    __pyx_t_37 = __pyx_cur_scope->__pyx_t_19;
                                    __pyx_cur_scope->__pyx_t_19 = 0;
                                    __Pyx_XGOTREF(__pyx_t_37);
                                    __pyx_t_39 = __pyx_cur_scope->__pyx_t_20;
                                    __pyx_cur_scope->__pyx_t_20 = 0;
                                    __Pyx_XGOTREF(__pyx_t_39);
                                    __pyx_t_45 = __pyx_cur_scope->__pyx_t_23;
                                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5376, __pyx_L382_except_error)
                                    __pyx_t_6 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_6);
                                  } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                    __Pyx_GOTREF(__pyx_r);
                                    __pyx_t_6 = __pyx_r; __pyx_r = NULL;
                                  } else {
                                    __Pyx_XGOTREF(__pyx_r);
                                    __PYX_ERR(0, 5376, __pyx_L382_except_error)
                                  }
                                  __pyx_t_16 = __pyx_t_6;
                                  __pyx_t_6 = 0;
                                  __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_16);
                                  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                                  if (__pyx_t_28 < (0)) __PYX_ERR(0, 5376, __pyx_L382_except_error)
                                  __pyx_t_47 = (!__pyx_t_28);
                                  if (unlikely(__pyx_t_47)) {
                                    __Pyx_GIVEREF(__pyx_t_39);
                                    __Pyx_GIVEREF(__pyx_t_25);
                                    __Pyx_XGIVEREF(__pyx_t_4);
                                    __Pyx_ErrRestoreWithState(__pyx_t_39, __pyx_t_25, __pyx_t_4);
                                    __pyx_t_39 = 0;  __pyx_t_25 = 0;  __pyx_t_4 = 0; 
                                    __PYX_ERR(0, 5376, __pyx_L382_except_error)
                                  }
                                  __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                                  goto __pyx_L381_exception_handled;
                                }
                                __pyx_L382_except_error:;
                                __Pyx_XGIVEREF(__pyx_t_17);
                                __Pyx_XGIVEREF(__pyx_t_22);
                                __Pyx_XGIVEREF(__pyx_t_21);
                                __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_22, __pyx_t_21);
                                goto __pyx_L365_error;
                                __pyx_L381_exception_handled:;
                                __Pyx_XGIVEREF(__pyx_t_17);
                                __Pyx_XGIVEREF(__pyx_t_22);
                                __Pyx_XGIVEREF(__pyx_t_21);
                                __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_22, __pyx_t_21);
                                __pyx_L387_try_end:;
                              }
                            }
                            /*finally:*/ {
                              /*normal exit:*/{
                                if (__pyx_t_18) {
                                  __pyx_t_21 = __Pyx_PyObject_Call(__pyx_t_18, __pyx_mstate_global->__pyx_tuple[7], NULL);
                                  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                                  if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 5376, __pyx_L365_error)
                                  __Pyx_GOTREF(__pyx_t_21);
                                  __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_21, &__pyx_r);
                                  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                                  if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                    __Pyx_GOTREF(__pyx_r);
                                    __Pyx_XGIVEREF(__pyx_t_1);
                                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                    __Pyx_XGIVEREF(__pyx_t_2);
                                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                    __Pyx_XGIVEREF(__pyx_t_3);
                                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                    __Pyx_XGIVEREF(__pyx_t_5);
                                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_5;
                                    __Pyx_XGIVEREF(__pyx_t_12);
                                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                                    __Pyx_XGIVEREF(__pyx_t_13);
                                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                                    __Pyx_XGIVEREF(__pyx_t_14);
                                    __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                                    __Pyx_XGIVEREF(__pyx_t_15);
                                    __pyx_cur_scope->__pyx_t_7 = __pyx_t_15;
                                    __Pyx_XGIVEREF(__pyx_t_18);
                                    __pyx_cur_scope->__pyx_t_8 = __pyx_t_18;
                                    __Pyx_XGIVEREF(__pyx_t_19);
                                    __pyx_cur_scope->__pyx_t_9 = __pyx_t_19;
                                    __Pyx_XGIVEREF(__pyx_t_20);
                                    __pyx_cur_scope->__pyx_t_10 = __pyx_t_20;
                                    __Pyx_XGIVEREF(__pyx_t_21);
                                    __pyx_cur_scope->__pyx_t_11 = __pyx_t_21;
                                    __Pyx_XGIVEREF(__pyx_t_23);
                                    __pyx_cur_scope->__pyx_t_12 = __pyx_t_23;
                                    __pyx_cur_scope->__pyx_t_18 = __pyx_t_35;
                                    __Pyx_XGIVEREF(__pyx_t_37);
                                    __pyx_cur_scope->__pyx_t_13 = __pyx_t_37;
                                    __pyx_cur_scope->__pyx_t_23 = __pyx_t_45;
                                    __Pyx_XGIVEREF(__pyx_r);
                                    __Pyx_RefNannyFinishContext();
                                    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                                    /* return from generator, awaiting value */
                                    __pyx_generator->resume_label = 29;
                                    return __pyx_r;
                                    __pyx_L396_resume_from_await:;
                                    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                    __pyx_cur_scope->__pyx_t_0 = 0;
                                    __Pyx_XGOTREF(__pyx_t_1);
                                    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                    __pyx_cur_scope->__pyx_t_1 = 0;
                                    __Pyx_XGOTREF(__pyx_t_2);
                                    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                    __pyx_cur_scope->__pyx_t_2 = 0;
                                    __Pyx_XGOTREF(__pyx_t_3);
                                    __pyx_t_5 = __pyx_cur_scope->__pyx_t_3;
                                    __pyx_cur_scope->__pyx_t_3 = 0;
                                    __Pyx_XGOTREF(__pyx_t_5);
                                    __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                                    __pyx_cur_scope->__pyx_t_4 = 0;
                                    __Pyx_XGOTREF(__pyx_t_12);
                                    __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                                    __pyx_cur_scope->__pyx_t_5 = 0;
                                    __Pyx_XGOTREF(__pyx_t_13);
                                    __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                                    __pyx_cur_scope->__pyx_t_6 = 0;
                                    __Pyx_XGOTREF(__pyx_t_14);
                                    __pyx_t_15 = __pyx_cur_scope->__pyx_t_7;
                                    __pyx_cur_scope->__pyx_t_7 = 0;
                                    __Pyx_XGOTREF(__pyx_t_15);
                                    __pyx_t_18 = __pyx_cur_scope->__pyx_t_8;
                                    __pyx_cur_scope->__pyx_t_8 = 0;
                                    __Pyx_XGOTREF(__pyx_t_18);
                                    __pyx_t_19 = __pyx_cur_scope->__pyx_t_9;
                                    __pyx_cur_scope->__pyx_t_9 = 0;
                                    __Pyx_XGOTREF(__pyx_t_19);
                                    __pyx_t_20 = __pyx_cur_scope->__pyx_t_10;
                                    __pyx_cur_scope->__pyx_t_10 = 0;
                                    __Pyx_XGOTREF(__pyx_t_20);
                                    __pyx_t_21 = __pyx_cur_scope->__pyx_t_11;
                                    __pyx_cur_scope->__pyx_t_11 = 0;
                                    __Pyx_XGOTREF(__pyx_t_21);
                                    __pyx_t_23 = __pyx_cur_scope->__pyx_t_12;
                                    __pyx_cur_scope->__pyx_t_12 = 0;
                                    __Pyx_XGOTREF(__pyx_t_23);
                                    __pyx_t_35 = __pyx_cur_scope->__pyx_t_18;
                                    __pyx_t_37 = __pyx_cur_scope->__pyx_t_13;
                                    __pyx_cur_scope->__pyx_t_13 = 0;
                                    __Pyx_XGOTREF(__pyx_t_37);
                                    __pyx_t_45 = __pyx_cur_scope->__pyx_t_23;
                                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5376, __pyx_L365_error)
                                    __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                                  } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                    __Pyx_GOTREF(__pyx_r);
                                    __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                                  } else {
                                    __Pyx_XGOTREF(__pyx_r);
                                    __PYX_ERR(0, 5376, __pyx_L365_error)
                                  }
                                  __pyx_t_21 = __pyx_t_4;
                                  __pyx_t_4 = 0;
                                  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                                }
                                goto __pyx_L379;
                              }
                              __pyx_L379:;
                            }
                            goto __pyx_L397;
                            __pyx_L373_error:;
                            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                            goto __pyx_L365_error;
                            __pyx_L397:;
                          }

                          /* "ws_package/controllers/activity_controller.py":5375
 *                             # Query database to find the actual record with ID
 *                             try:
 *                                 with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                                     async with async_session() as session:
 *                                         # Match by start_time, end_time, and counter
*/
                        }
                        __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                        __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                        goto __pyx_L372_try_end;
                        __pyx_L365_error:;
                        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                        __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                        __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                        __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                        __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                        __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                        __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                        /*except:*/ {
                          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
                          if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_25, &__pyx_t_39) < 0) __PYX_ERR(0, 5375, __pyx_L367_except_error)
                          __Pyx_XGOTREF(__pyx_t_4);
                          __Pyx_XGOTREF(__pyx_t_25);
                          __Pyx_XGOTREF(__pyx_t_39);
                          __pyx_t_6 = PyTuple_Pack(3, __pyx_t_4, __pyx_t_25, __pyx_t_39); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5375, __pyx_L367_except_error)
                          __Pyx_GOTREF(__pyx_t_6);
                          __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_19, __pyx_t_6, NULL);
                          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                          if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 5375, __pyx_L367_except_error)
                          __Pyx_GOTREF(__pyx_t_18);
                          __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_t_18);
                          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                          if (__pyx_t_47 < (0)) __PYX_ERR(0, 5375, __pyx_L367_except_error)
                          __pyx_t_28 = (!__pyx_t_47);
                          if (unlikely(__pyx_t_28)) {
                            __Pyx_GIVEREF(__pyx_t_4);
                            __Pyx_GIVEREF(__pyx_t_25);
                            __Pyx_XGIVEREF(__pyx_t_39);
                            __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_25, __pyx_t_39);
                            __pyx_t_4 = 0;  __pyx_t_25 = 0;  __pyx_t_39 = 0; 
                            __PYX_ERR(0, 5375, __pyx_L367_except_error)
                          }
                          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                          __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                          __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                          goto __pyx_L366_exception_handled;
                        }
                        __pyx_L367_except_error:;
                        __Pyx_XGIVEREF(__pyx_t_20);
                        __Pyx_XGIVEREF(__pyx_t_37);
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_37, __pyx_t_15);
                        goto __pyx_L351_error;
                        __pyx_L366_exception_handled:;
                        __Pyx_XGIVEREF(__pyx_t_20);
                        __Pyx_XGIVEREF(__pyx_t_37);
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_37, __pyx_t_15);
                        __pyx_L372_try_end:;
                      }
                    }
                    /*finally:*/ {
                      /*normal exit:*/{
                        if (__pyx_t_19) {
                          __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_19, __pyx_mstate_global->__pyx_tuple[7], NULL);
                          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                          if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5375, __pyx_L351_error)
                          __Pyx_GOTREF(__pyx_t_15);
                          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                        }
                        goto __pyx_L364;
                      }
                      __pyx_L364:;
                    }
                    goto __pyx_L401;
                    __pyx_L359_error:;
                    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                    goto __pyx_L351_error;
                    __pyx_L401:;
                  }

                  /* "ws_package/controllers/activity_controller.py":5374
 *                         else:
 *                             # Query database to find the actual record with ID
 *                             try:             # <<<<<<<<<<<<<<
 *                                 with db_lock_manager.read_lock():
 *                                     async with async_session() as session:
*/
                }
                __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                goto __pyx_L358_try_end;
                __pyx_L351_error:;
                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

                /* "ws_package/controllers/activity_controller.py":5393
 *                                         else:
 *                                             logger.warning("Could not find database record for interval: start_time=%s, end_time=%s, counter=%s", interval.start_time, interval.end_time, getattr(interval, 'counter', 'N/A'))
 *                             except Exception as e:             # <<<<<<<<<<<<<<
 *                                 logger.error("Error querying database for interval: %s", e, exc_info=True)
 *                                 # Fallback: try to update anyway if it has an ID
*/
                __pyx_t_31 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                if (__pyx_t_31) {
                  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
                  if (__Pyx_GetException(&__pyx_t_39, &__pyx_t_25, &__pyx_t_4) < 0) __PYX_ERR(0, 5393, __pyx_L353_except_error)
                  __Pyx_XGOTREF(__pyx_t_39);
                  __Pyx_XGOTREF(__pyx_t_25);
                  __Pyx_XGOTREF(__pyx_t_4);
                  __Pyx_INCREF(__pyx_t_25);
                  __Pyx_GIVEREF(__pyx_t_25);
                  __pyx_cur_scope->__pyx_v_e = __pyx_t_25;
                  /*try:*/ {

                    /* "ws_package/controllers/activity_controller.py":5394
 *                                             logger.warning("Could not find database record for interval: start_time=%s, end_time=%s, counter=%s", interval.start_time, interval.end_time, getattr(interval, 'counter', 'N/A'))
 *                             except Exception as e:
 *                                 logger.error("Error querying database for interval: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 *                                 # Fallback: try to update anyway if it has an ID
 *                                 if hasattr(interval, 'id') and interval.id:
*/
                    __pyx_t_24 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5394, __pyx_L407_error)
                    __Pyx_GOTREF(__pyx_t_7);
                    __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5394, __pyx_L407_error)
                    __Pyx_GOTREF(__pyx_t_26);
                    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                    __pyx_t_8 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_26))) {
                      __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_26);
                      assert(__pyx_t_24);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_26);
                      __Pyx_INCREF(__pyx_t_24);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_26, __pyx__function);
                      __pyx_t_8 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_24, __pyx_mstate_global->__pyx_kp_u_Error_querying_database_for_inte, __pyx_cur_scope->__pyx_v_e};
                      __pyx_t_7 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5394, __pyx_L407_error)
                      __Pyx_GOTREF(__pyx_t_7);
                      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_7, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 5394, __pyx_L407_error)
                      __pyx_t_6 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_26, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_7);
                      __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                      __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5394, __pyx_L407_error)
                      __Pyx_GOTREF(__pyx_t_6);
                    }
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

                    /* "ws_package/controllers/activity_controller.py":5396
 *                                 logger.error("Error querying database for interval: %s", e, exc_info=True)
 *                                 # Fallback: try to update anyway if it has an ID
 *                                 if hasattr(interval, 'id') and interval.id:             # <<<<<<<<<<<<<<
 *                                     intervals_to_update.append(interval)
 * 
*/
                    __pyx_t_47 = __Pyx_HasAttr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(__pyx_t_47 == ((int)-1))) __PYX_ERR(0, 5396, __pyx_L407_error)
                    if (__pyx_t_47) {
                    } else {
                      __pyx_t_28 = __pyx_t_47;
                      goto __pyx_L410_bool_binop_done;
                    }
                    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5396, __pyx_L407_error)
                    __Pyx_GOTREF(__pyx_t_6);
                    __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5396, __pyx_L407_error)
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __pyx_t_28 = __pyx_t_47;
                    __pyx_L410_bool_binop_done:;
                    if (__pyx_t_28) {

                      /* "ws_package/controllers/activity_controller.py":5397
 *                                 # Fallback: try to update anyway if it has an ID
 *                                 if hasattr(interval, 'id') and interval.id:
 *                                     intervals_to_update.append(interval)             # <<<<<<<<<<<<<<
 * 
 *                     # Update all intervals that have IDs
*/
                      __pyx_t_50 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_intervals_to_update, __pyx_cur_scope->__pyx_v_interval); if (unlikely(__pyx_t_50 == ((int)-1))) __PYX_ERR(0, 5397, __pyx_L407_error)

                      /* "ws_package/controllers/activity_controller.py":5396
 *                                 logger.error("Error querying database for interval: %s", e, exc_info=True)
 *                                 # Fallback: try to update anyway if it has an ID
 *                                 if hasattr(interval, 'id') and interval.id:             # <<<<<<<<<<<<<<
 *                                     intervals_to_update.append(interval)
 * 
*/
                    }
                  }

                  /* "ws_package/controllers/activity_controller.py":5393
 *                                         else:
 *                                             logger.warning("Could not find database record for interval: start_time=%s, end_time=%s, counter=%s", interval.start_time, interval.end_time, getattr(interval, 'counter', 'N/A'))
 *                             except Exception as e:             # <<<<<<<<<<<<<<
 *                                 logger.error("Error querying database for interval: %s", e, exc_info=True)
 *                                 # Fallback: try to update anyway if it has an ID
*/
                  /*finally:*/ {
                    /*normal exit:*/{
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                      goto __pyx_L408;
                    }
                    __pyx_L407_error:;
                    /*exception exit:*/{
                      __Pyx_PyThreadState_assign
                      __pyx_t_19 = 0; __pyx_t_15 = 0; __pyx_t_37 = 0; __pyx_t_20 = 0; __pyx_t_18 = 0; __pyx_t_21 = 0;
                      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                      __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                      __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                      __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                      __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                      __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                      __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                       __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_18, &__pyx_t_21);
                      if ( unlikely(__Pyx_GetException(&__pyx_t_19, &__pyx_t_15, &__pyx_t_37) < 0)) __Pyx_ErrFetch(&__pyx_t_19, &__pyx_t_15, &__pyx_t_37);
                      __Pyx_XGOTREF(__pyx_t_19);
                      __Pyx_XGOTREF(__pyx_t_15);
                      __Pyx_XGOTREF(__pyx_t_37);
                      __Pyx_XGOTREF(__pyx_t_20);
                      __Pyx_XGOTREF(__pyx_t_18);
                      __Pyx_XGOTREF(__pyx_t_21);
                      __pyx_t_31 = __pyx_lineno; __pyx_t_32 = __pyx_clineno; __pyx_t_53 = __pyx_filename;
                      {
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                        __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                      }
                      __Pyx_XGIVEREF(__pyx_t_20);
                      __Pyx_XGIVEREF(__pyx_t_18);
                      __Pyx_XGIVEREF(__pyx_t_21);
                      __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_18, __pyx_t_21);
                      __Pyx_XGIVEREF(__pyx_t_19);
                      __Pyx_XGIVEREF(__pyx_t_15);
                      __Pyx_XGIVEREF(__pyx_t_37);
                      __Pyx_ErrRestore(__pyx_t_19, __pyx_t_15, __pyx_t_37);
                      __pyx_t_19 = 0; __pyx_t_15 = 0; __pyx_t_37 = 0; __pyx_t_20 = 0; __pyx_t_18 = 0; __pyx_t_21 = 0;
                      __pyx_lineno = __pyx_t_31; __pyx_clineno = __pyx_t_32; __pyx_filename = __pyx_t_53;
                      goto __pyx_L353_except_error;
                    }
                    __pyx_L408:;
                  }
                  __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  goto __pyx_L352_exception_handled;
                }
                goto __pyx_L353_except_error;

                /* "ws_package/controllers/activity_controller.py":5374
 *                         else:
 *                             # Query database to find the actual record with ID
 *                             try:             # <<<<<<<<<<<<<<
 *                                 with db_lock_manager.read_lock():
 *                                     async with async_session() as session:
*/
                __pyx_L353_except_error:;
                __Pyx_XGIVEREF(__pyx_t_14);
                __Pyx_XGIVEREF(__pyx_t_13);
                __Pyx_XGIVEREF(__pyx_t_12);
                __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12);
                goto __pyx_L4_error;
                __pyx_L352_exception_handled:;
                __Pyx_XGIVEREF(__pyx_t_14);
                __Pyx_XGIVEREF(__pyx_t_13);
                __Pyx_XGIVEREF(__pyx_t_12);
                __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12);
                __pyx_L358_try_end:;
              }
            }
            __pyx_L348:;

            /* "ws_package/controllers/activity_controller.py":5367
 * 
 *                     intervals_to_update = []
 *                     for interval in response[1]:             # <<<<<<<<<<<<<<
 *                         # If interval already has an ID, use it directly
 *                         if hasattr(interval, 'id') and interval.id:
*/
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":5400
 * 
 *                     # Update all intervals that have IDs
 *                     for interval in intervals_to_update:             # <<<<<<<<<<<<<<
 *                         await self.activity_service.update_activity_interval(interval)
 *                         # Check if this interval is the last_interval
*/
          __pyx_t_5 = __pyx_cur_scope->__pyx_v_intervals_to_update; __Pyx_INCREF(__pyx_t_5);
          __pyx_t_45 = 0;
          for (;;) {
            {
              Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_5);
              #if !CYTHON_ASSUME_SAFE_SIZE
              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5400, __pyx_L4_error)
              #endif
              if (__pyx_t_45 >= __pyx_temp) break;
            }
            __pyx_t_4 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_5, __pyx_t_45, __Pyx_ReferenceSharing_OwnStrongReference);
            ++__pyx_t_45;
            if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5400, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_4);
            __pyx_t_4 = 0;

            /* "ws_package/controllers/activity_controller.py":5401
 *                     # Update all intervals that have IDs
 *                     for interval in intervals_to_update:
 *                         await self.activity_service.update_activity_interval(interval)             # <<<<<<<<<<<<<<
 *                         # Check if this interval is the last_interval
 *                         if last_interval:
*/
            __pyx_t_39 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5401, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_39);
            __pyx_t_25 = __pyx_t_39;
            __Pyx_INCREF(__pyx_t_25);
            __pyx_t_8 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_25, __pyx_cur_scope->__pyx_v_interval};
              __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_update_activity_interval, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
              __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5401, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_4);
            }
            __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (likely(__pyx_t_11 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_1);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
              __Pyx_XGIVEREF(__pyx_t_2);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
              __Pyx_XGIVEREF(__pyx_t_3);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
              __Pyx_XGIVEREF(__pyx_t_5);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_5;
              __Pyx_XGIVEREF(__pyx_t_23);
              __pyx_cur_scope->__pyx_t_4 = __pyx_t_23;
              __pyx_cur_scope->__pyx_t_23 = __pyx_t_45;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 30;
              return __pyx_r;
              __pyx_L419_resume_from_await:;
              __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_1);
              __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_2);
              __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_3);
              __pyx_t_5 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_5);
              __pyx_t_23 = __pyx_cur_scope->__pyx_t_4;
              __pyx_cur_scope->__pyx_t_4 = 0;
              __Pyx_XGOTREF(__pyx_t_23);
              __pyx_t_45 = __pyx_cur_scope->__pyx_t_23;
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5401, __pyx_L4_error)
            } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_DECREF(__pyx_r); __pyx_r = 0;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 5401, __pyx_L4_error)
            }

            /* "ws_package/controllers/activity_controller.py":5403
 *                         await self.activity_service.update_activity_interval(interval)
 *                         # Check if this interval is the last_interval
 *                         if last_interval:             # <<<<<<<<<<<<<<
 *                             # Match by start_time, end_time, and counter
 *                             if (hasattr(interval, 'start_time') and hasattr(last_interval, 'start_time') and
*/
            __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5403, __pyx_L4_error)
            if (__pyx_t_28) {

              /* "ws_package/controllers/activity_controller.py":5405
 *                         if last_interval:
 *                             # Match by start_time, end_time, and counter
 *                             if (hasattr(interval, 'start_time') and hasattr(last_interval, 'start_time') and             # <<<<<<<<<<<<<<
 *                                 hasattr(interval, 'end_time') and hasattr(last_interval, 'end_time') and
 *                                 hasattr(interval, 'counter') and hasattr(last_interval, 'counter')):
*/
              __pyx_t_47 = __Pyx_HasAttr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(__pyx_t_47 == ((int)-1))) __PYX_ERR(0, 5405, __pyx_L4_error)
              if (__pyx_t_47) {
              } else {
                __pyx_t_28 = __pyx_t_47;
                goto __pyx_L422_bool_binop_done;
              }
              __pyx_t_4 = __pyx_cur_scope->__pyx_v_last_interval;
              __Pyx_INCREF(__pyx_t_4);
              __pyx_t_47 = __Pyx_HasAttr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(__pyx_t_47 == ((int)-1))) __PYX_ERR(0, 5405, __pyx_L4_error)
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              if (__pyx_t_47) {
              } else {
                __pyx_t_28 = __pyx_t_47;
                goto __pyx_L422_bool_binop_done;
              }

              /* "ws_package/controllers/activity_controller.py":5406
 *                             # Match by start_time, end_time, and counter
 *                             if (hasattr(interval, 'start_time') and hasattr(last_interval, 'start_time') and
 *                                 hasattr(interval, 'end_time') and hasattr(last_interval, 'end_time') and             # <<<<<<<<<<<<<<
 *                                 hasattr(interval, 'counter') and hasattr(last_interval, 'counter')):
 *                                 if (interval.start_time == last_interval.start_time and
*/
              __pyx_t_47 = __Pyx_HasAttr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(__pyx_t_47 == ((int)-1))) __PYX_ERR(0, 5406, __pyx_L4_error)
              if (__pyx_t_47) {
              } else {
                __pyx_t_28 = __pyx_t_47;
                goto __pyx_L422_bool_binop_done;
              }
              __pyx_t_4 = __pyx_cur_scope->__pyx_v_last_interval;
              __Pyx_INCREF(__pyx_t_4);
              __pyx_t_47 = __Pyx_HasAttr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(__pyx_t_47 == ((int)-1))) __PYX_ERR(0, 5406, __pyx_L4_error)
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              if (__pyx_t_47) {
              } else {
                __pyx_t_28 = __pyx_t_47;
                goto __pyx_L422_bool_binop_done;
              }

              /* "ws_package/controllers/activity_controller.py":5407
 *                             if (hasattr(interval, 'start_time') and hasattr(last_interval, 'start_time') and
 *                                 hasattr(interval, 'end_time') and hasattr(last_interval, 'end_time') and
 *                                 hasattr(interval, 'counter') and hasattr(last_interval, 'counter')):             # <<<<<<<<<<<<<<
 *                                 if (interval.start_time == last_interval.start_time and
 *                                     interval.end_time == last_interval.end_time and
*/
              __pyx_t_47 = __Pyx_HasAttr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(__pyx_t_47 == ((int)-1))) __PYX_ERR(0, 5407, __pyx_L4_error)
              if (__pyx_t_47) {
              } else {
                __pyx_t_28 = __pyx_t_47;
                goto __pyx_L422_bool_binop_done;
              }
              __pyx_t_4 = __pyx_cur_scope->__pyx_v_last_interval;
              __Pyx_INCREF(__pyx_t_4);
              __pyx_t_47 = __Pyx_HasAttr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(__pyx_t_47 == ((int)-1))) __PYX_ERR(0, 5407, __pyx_L4_error)
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __pyx_t_28 = __pyx_t_47;
              __pyx_L422_bool_binop_done:;

              /* "ws_package/controllers/activity_controller.py":5405
 *                         if last_interval:
 *                             # Match by start_time, end_time, and counter
 *                             if (hasattr(interval, 'start_time') and hasattr(last_interval, 'start_time') and             # <<<<<<<<<<<<<<
 *                                 hasattr(interval, 'end_time') and hasattr(last_interval, 'end_time') and
 *                                 hasattr(interval, 'counter') and hasattr(last_interval, 'counter')):
*/
              if (__pyx_t_28) {

                /* "ws_package/controllers/activity_controller.py":5408
 *                                 hasattr(interval, 'end_time') and hasattr(last_interval, 'end_time') and
 *                                 hasattr(interval, 'counter') and hasattr(last_interval, 'counter')):
 *                                 if (interval.start_time == last_interval.start_time and             # <<<<<<<<<<<<<<
 *                                     interval.end_time == last_interval.end_time and
 *                                     interval.counter == last_interval.counter):
*/
                __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5408, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_t_39 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5408, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_39);
                __pyx_t_25 = PyObject_RichCompare(__pyx_t_4, __pyx_t_39, Py_EQ); __Pyx_XGOTREF(__pyx_t_25); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5408, __pyx_L4_error)
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_t_25); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5408, __pyx_L4_error)
                __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                if (__pyx_t_47) {
                } else {
                  __pyx_t_28 = __pyx_t_47;
                  goto __pyx_L429_bool_binop_done;
                }

                /* "ws_package/controllers/activity_controller.py":5409
 *                                 hasattr(interval, 'counter') and hasattr(last_interval, 'counter')):
 *                                 if (interval.start_time == last_interval.start_time and
 *                                     interval.end_time == last_interval.end_time and             # <<<<<<<<<<<<<<
 *                                     interval.counter == last_interval.counter):
 *                                     last_interval_updated = True
*/
                __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5409, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_25);
                __pyx_t_39 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5409, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_39);
                __pyx_t_4 = PyObject_RichCompare(__pyx_t_25, __pyx_t_39, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5409, __pyx_L4_error)
                __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5409, __pyx_L4_error)
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                if (__pyx_t_47) {
                } else {
                  __pyx_t_28 = __pyx_t_47;
                  goto __pyx_L429_bool_binop_done;
                }

                /* "ws_package/controllers/activity_controller.py":5410
 *                                 if (interval.start_time == last_interval.start_time and
 *                                     interval.end_time == last_interval.end_time and
 *                                     interval.counter == last_interval.counter):             # <<<<<<<<<<<<<<
 *                                     last_interval_updated = True
 *                                     # Update last_interval_id with the actual database ID
*/
                __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5410, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_t_39 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_last_interval, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5410, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_39);
                __pyx_t_25 = PyObject_RichCompare(__pyx_t_4, __pyx_t_39, Py_EQ); __Pyx_XGOTREF(__pyx_t_25); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5410, __pyx_L4_error)
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_t_25); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5410, __pyx_L4_error)
                __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                __pyx_t_28 = __pyx_t_47;
                __pyx_L429_bool_binop_done:;

                /* "ws_package/controllers/activity_controller.py":5408
 *                                 hasattr(interval, 'end_time') and hasattr(last_interval, 'end_time') and
 *                                 hasattr(interval, 'counter') and hasattr(last_interval, 'counter')):
 *                                 if (interval.start_time == last_interval.start_time and             # <<<<<<<<<<<<<<
 *                                     interval.end_time == last_interval.end_time and
 *                                     interval.counter == last_interval.counter):
*/
                if (__pyx_t_28) {

                  /* "ws_package/controllers/activity_controller.py":5411
 *                                     interval.end_time == last_interval.end_time and
 *                                     interval.counter == last_interval.counter):
 *                                     last_interval_updated = True             # <<<<<<<<<<<<<<
 *                                     # Update last_interval_id with the actual database ID
 *                                     if hasattr(interval, 'id') and interval.id:
*/
                  __pyx_cur_scope->__pyx_v_last_interval_updated = 1;

                  /* "ws_package/controllers/activity_controller.py":5413
 *                                     last_interval_updated = True
 *                                     # Update last_interval_id with the actual database ID
 *                                     if hasattr(interval, 'id') and interval.id:             # <<<<<<<<<<<<<<
 *                                         last_interval_id = interval.id
 *                                     logger.info("Last interval (id=%s) was updated in this batch", getattr(interval, 'id', 'N/A'))
*/
                  __pyx_t_47 = __Pyx_HasAttr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(__pyx_t_47 == ((int)-1))) __PYX_ERR(0, 5413, __pyx_L4_error)
                  if (__pyx_t_47) {
                  } else {
                    __pyx_t_28 = __pyx_t_47;
                    goto __pyx_L433_bool_binop_done;
                  }
                  __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5413, __pyx_L4_error)
                  __Pyx_GOTREF(__pyx_t_25);
                  __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_t_25); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5413, __pyx_L4_error)
                  __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                  __pyx_t_28 = __pyx_t_47;
                  __pyx_L433_bool_binop_done:;
                  if (__pyx_t_28) {

                    /* "ws_package/controllers/activity_controller.py":5414
 *                                     # Update last_interval_id with the actual database ID
 *                                     if hasattr(interval, 'id') and interval.id:
 *                                         last_interval_id = interval.id             # <<<<<<<<<<<<<<
 *                                     logger.info("Last interval (id=%s) was updated in this batch", getattr(interval, 'id', 'N/A'))
 * 
*/
                    __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5414, __pyx_L4_error)
                    __Pyx_GOTREF(__pyx_t_25);
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_last_interval_id);
                    __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_last_interval_id, __pyx_t_25);
                    __Pyx_GIVEREF(__pyx_t_25);
                    __pyx_t_25 = 0;

                    /* "ws_package/controllers/activity_controller.py":5413
 *                                     last_interval_updated = True
 *                                     # Update last_interval_id with the actual database ID
 *                                     if hasattr(interval, 'id') and interval.id:             # <<<<<<<<<<<<<<
 *                                         last_interval_id = interval.id
 *                                     logger.info("Last interval (id=%s) was updated in this batch", getattr(interval, 'id', 'N/A'))
*/
                  }

                  /* "ws_package/controllers/activity_controller.py":5415
 *                                     if hasattr(interval, 'id') and interval.id:
 *                                         last_interval_id = interval.id
 *                                     logger.info("Last interval (id=%s) was updated in this batch", getattr(interval, 'id', 'N/A'))             # <<<<<<<<<<<<<<
 * 
 *                     # Flush the database write queue to ensure is_uploaded=1 is committed before shutdown
*/
                  __pyx_t_39 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5415, __pyx_L4_error)
                  __Pyx_GOTREF(__pyx_t_4);
                  __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5415, __pyx_L4_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __pyx_t_4 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id, __pyx_mstate_global->__pyx_kp_u_N_A); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5415, __pyx_L4_error)
                  __Pyx_GOTREF(__pyx_t_4);
                  __pyx_t_8 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_6))) {
                    __pyx_t_39 = PyMethod_GET_SELF(__pyx_t_6);
                    assert(__pyx_t_39);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                    __Pyx_INCREF(__pyx_t_39);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                    __pyx_t_8 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[3] = {__pyx_t_39, __pyx_mstate_global->__pyx_kp_u_Last_interval_id_s_was_updated_i, __pyx_t_4};
                    __pyx_t_25 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5415, __pyx_L4_error)
                    __Pyx_GOTREF(__pyx_t_25);
                  }
                  __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;

                  /* "ws_package/controllers/activity_controller.py":5408
 *                                 hasattr(interval, 'end_time') and hasattr(last_interval, 'end_time') and
 *                                 hasattr(interval, 'counter') and hasattr(last_interval, 'counter')):
 *                                 if (interval.start_time == last_interval.start_time and             # <<<<<<<<<<<<<<
 *                                     interval.end_time == last_interval.end_time and
 *                                     interval.counter == last_interval.counter):
*/
                }

                /* "ws_package/controllers/activity_controller.py":5405
 *                         if last_interval:
 *                             # Match by start_time, end_time, and counter
 *                             if (hasattr(interval, 'start_time') and hasattr(last_interval, 'start_time') and             # <<<<<<<<<<<<<<
 *                                 hasattr(interval, 'end_time') and hasattr(last_interval, 'end_time') and
 *                                 hasattr(interval, 'counter') and hasattr(last_interval, 'counter')):
*/
              }

              /* "ws_package/controllers/activity_controller.py":5403
 *                         await self.activity_service.update_activity_interval(interval)
 *                         # Check if this interval is the last_interval
 *                         if last_interval:             # <<<<<<<<<<<<<<
 *                             # Match by start_time, end_time, and counter
 *                             if (hasattr(interval, 'start_time') and hasattr(last_interval, 'start_time') and
*/
            }

            /* "ws_package/controllers/activity_controller.py":5400
 * 
 *                     # Update all intervals that have IDs
 *                     for interval in intervals_to_update:             # <<<<<<<<<<<<<<
 *                         await self.activity_service.update_activity_interval(interval)
 *                         # Check if this interval is the last_interval
*/
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":5418
 * 
 *                     # Flush the database write queue to ensure is_uploaded=1 is committed before shutdown
 *                     logger.info("Flushing database write queue to commit interval updates...")             # <<<<<<<<<<<<<<
 *                     try:
 *                         processed_count = await db_writer_service.process_immediately()
*/
          __pyx_t_25 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5418, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5418, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_4))) {
            __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_4);
            assert(__pyx_t_25);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_25);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_25, __pyx_mstate_global->__pyx_kp_u_Flushing_database_write_queue_to};
            __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5418, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":5419
 *                     # Flush the database write queue to ensure is_uploaded=1 is committed before shutdown
 *                     logger.info("Flushing database write queue to commit interval updates...")
 *                     try:             # <<<<<<<<<<<<<<
 *                         processed_count = await db_writer_service.process_immediately()
 *                         logger.info("Successfully processed %s queued database updates", processed_count)
*/
          {
            __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
            __Pyx_XGOTREF(__pyx_t_12);
            __Pyx_XGOTREF(__pyx_t_13);
            __Pyx_XGOTREF(__pyx_t_14);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":5420
 *                     logger.info("Flushing database write queue to commit interval updates...")
 *                     try:
 *                         processed_count = await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 *                         logger.info("Successfully processed %s queued database updates", processed_count)
 * 
*/
              __pyx_t_4 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5420, __pyx_L436_error)
              __Pyx_GOTREF(__pyx_t_25);
              __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5420, __pyx_L436_error)
              __Pyx_GOTREF(__pyx_t_6);
              __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_6))) {
                __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
                assert(__pyx_t_4);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                __Pyx_INCREF(__pyx_t_4);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
                __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5420, __pyx_L436_error)
                __Pyx_GOTREF(__pyx_t_5);
              }
              __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_XGIVEREF(__pyx_t_1);
                __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                __Pyx_XGIVEREF(__pyx_t_2);
                __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                __Pyx_XGIVEREF(__pyx_t_3);
                __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                __Pyx_XGIVEREF(__pyx_t_12);
                __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                __Pyx_XGIVEREF(__pyx_t_13);
                __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                __Pyx_XGIVEREF(__pyx_t_14);
                __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                __Pyx_XGIVEREF(__pyx_t_23);
                __pyx_cur_scope->__pyx_t_6 = __pyx_t_23;
                __Pyx_XGIVEREF(__pyx_r);
                __Pyx_RefNannyFinishContext();
                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                /* return from generator, awaiting value */
                __pyx_generator->resume_label = 31;
                return __pyx_r;
                __pyx_L444_resume_from_await:;
                __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                __pyx_cur_scope->__pyx_t_0 = 0;
                __Pyx_XGOTREF(__pyx_t_1);
                __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                __pyx_cur_scope->__pyx_t_1 = 0;
                __Pyx_XGOTREF(__pyx_t_2);
                __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                __pyx_cur_scope->__pyx_t_2 = 0;
                __Pyx_XGOTREF(__pyx_t_3);
                __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                __pyx_cur_scope->__pyx_t_3 = 0;
                __Pyx_XGOTREF(__pyx_t_12);
                __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                __pyx_cur_scope->__pyx_t_4 = 0;
                __Pyx_XGOTREF(__pyx_t_13);
                __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                __pyx_cur_scope->__pyx_t_5 = 0;
                __Pyx_XGOTREF(__pyx_t_14);
                __pyx_t_23 = __pyx_cur_scope->__pyx_t_6;
                __pyx_cur_scope->__pyx_t_6 = 0;
                __Pyx_XGOTREF(__pyx_t_23);
                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5420, __pyx_L436_error)
                __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
              } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                __Pyx_GOTREF(__pyx_r);
                __pyx_t_5 = __pyx_r; __pyx_r = NULL;
              } else {
                __Pyx_XGOTREF(__pyx_r);
                __PYX_ERR(0, 5420, __pyx_L436_error)
              }
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_processed_count);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_processed_count, __pyx_t_5);
              __Pyx_GIVEREF(__pyx_t_5);
              __pyx_t_5 = 0;

              /* "ws_package/controllers/activity_controller.py":5421
 *                     try:
 *                         processed_count = await db_writer_service.process_immediately()
 *                         logger.info("Successfully processed %s queued database updates", processed_count)             # <<<<<<<<<<<<<<
 * 
 *                         # Verify updates are committed and visible (prevents duplicate sends in next session)
*/
              __pyx_t_6 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5421, __pyx_L436_error)
              __Pyx_GOTREF(__pyx_t_4);
              __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5421, __pyx_L436_error)
              __Pyx_GOTREF(__pyx_t_25);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_25))) {
                __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_25);
                assert(__pyx_t_6);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_25);
                __Pyx_INCREF(__pyx_t_6);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_25, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Successfully_processed_s_queued, __pyx_cur_scope->__pyx_v_processed_count};
                __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_25, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5421, __pyx_L436_error)
                __Pyx_GOTREF(__pyx_t_5);
              }
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

              /* "ws_package/controllers/activity_controller.py":5424
 * 
 *                         # Verify updates are committed and visible (prevents duplicate sends in next session)
 *                         if processed_count > 0 and response[1]:             # <<<<<<<<<<<<<<
 *                             # Small delay to ensure SQLite transaction is visible
 *                             await asyncio.sleep(0.3)
*/
              __pyx_t_5 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_processed_count, __pyx_mstate_global->__pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5424, __pyx_L436_error)
              __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5424, __pyx_L436_error)
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              if (__pyx_t_47) {
              } else {
                __pyx_t_28 = __pyx_t_47;
                goto __pyx_L446_bool_binop_done;
              }
              __pyx_t_5 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_response, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_SharedReference); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5424, __pyx_L436_error)
              __Pyx_GOTREF(__pyx_t_5);
              __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5424, __pyx_L436_error)
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __pyx_t_28 = __pyx_t_47;
              __pyx_L446_bool_binop_done:;
              if (__pyx_t_28) {

                /* "ws_package/controllers/activity_controller.py":5426
 *                         if processed_count > 0 and response[1]:
 *                             # Small delay to ensure SQLite transaction is visible
 *                             await asyncio.sleep(0.3)             # <<<<<<<<<<<<<<
 *                             logger.debug("Verified interval updates are committed to database")
 *                     except Exception as e:
*/
                __pyx_t_25 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5426, __pyx_L436_error)
                __Pyx_GOTREF(__pyx_t_6);
                __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5426, __pyx_L436_error)
                __Pyx_GOTREF(__pyx_t_4);
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_4))) {
                  __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_4);
                  assert(__pyx_t_25);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                  __Pyx_INCREF(__pyx_t_25);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_25, __pyx_mstate_global->__pyx_float_0_3};
                  __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5426, __pyx_L436_error)
                  __Pyx_GOTREF(__pyx_t_5);
                }
                __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_1);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                  __Pyx_XGIVEREF(__pyx_t_2);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                  __Pyx_XGIVEREF(__pyx_t_3);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_t_14);
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                  __Pyx_XGIVEREF(__pyx_t_23);
                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_23;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 32;
                  return __pyx_r;
                  __pyx_L448_resume_from_await:;
                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_1);
                  __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_2);
                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_3);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = 0;
                  __Pyx_XGOTREF(__pyx_t_14);
                  __pyx_t_23 = __pyx_cur_scope->__pyx_t_6;
                  __pyx_cur_scope->__pyx_t_6 = 0;
                  __Pyx_XGOTREF(__pyx_t_23);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5426, __pyx_L436_error)
                } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 5426, __pyx_L436_error)
                }

                /* "ws_package/controllers/activity_controller.py":5427
 *                             # Small delay to ensure SQLite transaction is visible
 *                             await asyncio.sleep(0.3)
 *                             logger.debug("Verified interval updates are committed to database")             # <<<<<<<<<<<<<<
 *                     except Exception as e:
 *                         logger.error("Error flushing database write queue: %s", e, exc_info=True)
*/
                __pyx_t_4 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5427, __pyx_L436_error)
                __Pyx_GOTREF(__pyx_t_25);
                __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5427, __pyx_L436_error)
                __Pyx_GOTREF(__pyx_t_6);
                __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_6))) {
                  __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
                  assert(__pyx_t_4);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                  __Pyx_INCREF(__pyx_t_4);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Verified_interval_updates_are_co};
                  __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5427, __pyx_L436_error)
                  __Pyx_GOTREF(__pyx_t_5);
                }
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                /* "ws_package/controllers/activity_controller.py":5424
 * 
 *                         # Verify updates are committed and visible (prevents duplicate sends in next session)
 *                         if processed_count > 0 and response[1]:             # <<<<<<<<<<<<<<
 *                             # Small delay to ensure SQLite transaction is visible
 *                             await asyncio.sleep(0.3)
*/
              }

              /* "ws_package/controllers/activity_controller.py":5419
 *                     # Flush the database write queue to ensure is_uploaded=1 is committed before shutdown
 *                     logger.info("Flushing database write queue to commit interval updates...")
 *                     try:             # <<<<<<<<<<<<<<
 *                         processed_count = await db_writer_service.process_immediately()
 *                         logger.info("Successfully processed %s queued database updates", processed_count)
*/
            }
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            goto __pyx_L443_try_end;
            __pyx_L436_error:;
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
            __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
            __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
            __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
            __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
            __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

            /* "ws_package/controllers/activity_controller.py":5428
 *                             await asyncio.sleep(0.3)
 *                             logger.debug("Verified interval updates are committed to database")
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error flushing database write queue: %s", e, exc_info=True)
 * 
*/
            __pyx_t_32 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
            if (__pyx_t_32) {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_6, &__pyx_t_4) < 0) __PYX_ERR(0, 5428, __pyx_L438_except_error)
              __Pyx_XGOTREF(__pyx_t_5);
              __Pyx_XGOTREF(__pyx_t_6);
              __Pyx_XGOTREF(__pyx_t_4);
              __Pyx_INCREF(__pyx_t_6);
              __Pyx_GIVEREF(__pyx_t_6);
              __pyx_cur_scope->__pyx_v_e = __pyx_t_6;
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":5429
 *                             logger.debug("Verified interval updates are committed to database")
 *                     except Exception as e:
 *                         logger.error("Error flushing database write queue: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *                     # CRITICAL: Ensure last interval is marked is_uploaded before update_screenshots, so its
*/
                __pyx_t_39 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5429, __pyx_L454_error)
                __Pyx_GOTREF(__pyx_t_26);
                __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5429, __pyx_L454_error)
                __Pyx_GOTREF(__pyx_t_7);
                __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_7))) {
                  __pyx_t_39 = PyMethod_GET_SELF(__pyx_t_7);
                  assert(__pyx_t_39);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                  __Pyx_INCREF(__pyx_t_39);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_39, __pyx_mstate_global->__pyx_kp_u_Error_flushing_database_write_qu_4, __pyx_cur_scope->__pyx_v_e};
                  __pyx_t_26 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5429, __pyx_L454_error)
                  __Pyx_GOTREF(__pyx_t_26);
                  if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_26, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 5429, __pyx_L454_error)
                  __pyx_t_25 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_26);
                  __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                  __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                  if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5429, __pyx_L454_error)
                  __Pyx_GOTREF(__pyx_t_25);
                }
                __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
              }

              /* "ws_package/controllers/activity_controller.py":5428
 *                             await asyncio.sleep(0.3)
 *                             logger.debug("Verified interval updates are committed to database")
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error flushing database write queue: %s", e, exc_info=True)
 * 
*/
              /*finally:*/ {
                /*normal exit:*/{
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  goto __pyx_L455;
                }
                __pyx_L454_error:;
                /*exception exit:*/{
                  __Pyx_PyThreadState_assign
                  __pyx_t_21 = 0; __pyx_t_18 = 0; __pyx_t_20 = 0; __pyx_t_37 = 0; __pyx_t_15 = 0; __pyx_t_19 = 0;
                  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                  __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                  __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                  __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                  __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                  __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                  __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                  __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                   __Pyx_ExceptionSwap(&__pyx_t_37, &__pyx_t_15, &__pyx_t_19);
                  if ( unlikely(__Pyx_GetException(&__pyx_t_21, &__pyx_t_18, &__pyx_t_20) < 0)) __Pyx_ErrFetch(&__pyx_t_21, &__pyx_t_18, &__pyx_t_20);
                  __Pyx_XGOTREF(__pyx_t_21);
                  __Pyx_XGOTREF(__pyx_t_18);
                  __Pyx_XGOTREF(__pyx_t_20);
                  __Pyx_XGOTREF(__pyx_t_37);
                  __Pyx_XGOTREF(__pyx_t_15);
                  __Pyx_XGOTREF(__pyx_t_19);
                  __pyx_t_32 = __pyx_lineno; __pyx_t_31 = __pyx_clineno; __pyx_t_54 = __pyx_filename;
                  {
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  }
                  __Pyx_XGIVEREF(__pyx_t_37);
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __Pyx_XGIVEREF(__pyx_t_19);
                  __Pyx_ExceptionReset(__pyx_t_37, __pyx_t_15, __pyx_t_19);
                  __Pyx_XGIVEREF(__pyx_t_21);
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __Pyx_XGIVEREF(__pyx_t_20);
                  __Pyx_ErrRestore(__pyx_t_21, __pyx_t_18, __pyx_t_20);
                  __pyx_t_21 = 0; __pyx_t_18 = 0; __pyx_t_20 = 0; __pyx_t_37 = 0; __pyx_t_15 = 0; __pyx_t_19 = 0;
                  __pyx_lineno = __pyx_t_32; __pyx_clineno = __pyx_t_31; __pyx_filename = __pyx_t_54;
                  goto __pyx_L438_except_error;
                }
                __pyx_L455:;
              }
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              goto __pyx_L437_exception_handled;
            }
            goto __pyx_L438_except_error;

            /* "ws_package/controllers/activity_controller.py":5419
 *                     # Flush the database write queue to ensure is_uploaded=1 is committed before shutdown
 *                     logger.info("Flushing database write queue to commit interval updates...")
 *                     try:             # <<<<<<<<<<<<<<
 *                         processed_count = await db_writer_service.process_immediately()
 *                         logger.info("Successfully processed %s queued database updates", processed_count)
*/
            __pyx_L438_except_error:;
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
            goto __pyx_L4_error;
            __pyx_L437_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
            __pyx_L443_try_end:;
          }

          /* "ws_package/controllers/activity_controller.py":5434
 *                     # screenshots can be deleted (validation requires is_uploaded=True). Use tolerance query
 *                     # in case DB datetime precision differs from in-memory entity.
 *                     if last_interval and not last_interval_updated:             # <<<<<<<<<<<<<<
 *                         try:
 *                             st = getattr(last_interval, 'start_time', None)
*/
          __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5434, __pyx_L4_error)
          if (__pyx_t_47) {
          } else {
            __pyx_t_28 = __pyx_t_47;
            goto __pyx_L461_bool_binop_done;
          }
          __pyx_t_47 = (!__pyx_cur_scope->__pyx_v_last_interval_updated);
          __pyx_t_28 = __pyx_t_47;
          __pyx_L461_bool_binop_done:;
          if (__pyx_t_28) {

            /* "ws_package/controllers/activity_controller.py":5435
 *                     # in case DB datetime precision differs from in-memory entity.
 *                     if last_interval and not last_interval_updated:
 *                         try:             # <<<<<<<<<<<<<<
 *                             st = getattr(last_interval, 'start_time', None)
 *                             et = getattr(last_interval, 'end_time', None)
*/
            {
              __Pyx_ExceptionSave(&__pyx_t_14, &__pyx_t_13, &__pyx_t_12);
              __Pyx_XGOTREF(__pyx_t_14);
              __Pyx_XGOTREF(__pyx_t_13);
              __Pyx_XGOTREF(__pyx_t_12);
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":5436
 *                     if last_interval and not last_interval_updated:
 *                         try:
 *                             st = getattr(last_interval, 'start_time', None)             # <<<<<<<<<<<<<<
 *                             et = getattr(last_interval, 'end_time', None)
 *                             if st is not None and et is not None:
*/
                __pyx_t_4 = __pyx_cur_scope->__pyx_v_last_interval;
                __Pyx_INCREF(__pyx_t_4);
                __pyx_t_6 = __Pyx_GetAttr3(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_start_time, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5436, __pyx_L463_error)
                __Pyx_GOTREF(__pyx_t_6);
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_st);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_st, __pyx_t_6);
                __Pyx_GIVEREF(__pyx_t_6);
                __pyx_t_6 = 0;

                /* "ws_package/controllers/activity_controller.py":5437
 *                         try:
 *                             st = getattr(last_interval, 'start_time', None)
 *                             et = getattr(last_interval, 'end_time', None)             # <<<<<<<<<<<<<<
 *                             if st is not None and et is not None:
 *                                 tol = datetime.timedelta(seconds=2)
*/
                __pyx_t_6 = __pyx_cur_scope->__pyx_v_last_interval;
                __Pyx_INCREF(__pyx_t_6);
                __pyx_t_4 = __Pyx_GetAttr3(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_end_time, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5437, __pyx_L463_error)
                __Pyx_GOTREF(__pyx_t_4);
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_et);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_et, __pyx_t_4);
                __Pyx_GIVEREF(__pyx_t_4);
                __pyx_t_4 = 0;

                /* "ws_package/controllers/activity_controller.py":5438
 *                             st = getattr(last_interval, 'start_time', None)
 *                             et = getattr(last_interval, 'end_time', None)
 *                             if st is not None and et is not None:             # <<<<<<<<<<<<<<
 *                                 tol = datetime.timedelta(seconds=2)
 *                                 with db_lock_manager.read_lock():
*/
                __pyx_t_47 = (__pyx_cur_scope->__pyx_v_st != Py_None);
                if (__pyx_t_47) {
                } else {
                  __pyx_t_28 = __pyx_t_47;
                  goto __pyx_L472_bool_binop_done;
                }
                __pyx_t_47 = (__pyx_cur_scope->__pyx_v_et != Py_None);
                __pyx_t_28 = __pyx_t_47;
                __pyx_L472_bool_binop_done:;
                if (__pyx_t_28) {

                  /* "ws_package/controllers/activity_controller.py":5439
 *                             et = getattr(last_interval, 'end_time', None)
 *                             if st is not None and et is not None:
 *                                 tol = datetime.timedelta(seconds=2)             # <<<<<<<<<<<<<<
 *                                 with db_lock_manager.read_lock():
 *                                     async with async_session() as session:
*/
                  __pyx_t_6 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5439, __pyx_L463_error)
                  __Pyx_GOTREF(__pyx_t_5);
                  __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_timedelta); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5439, __pyx_L463_error)
                  __Pyx_GOTREF(__pyx_t_25);
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __pyx_t_8 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_25))) {
                    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_25);
                    assert(__pyx_t_6);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_25);
                    __Pyx_INCREF(__pyx_t_6);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_25, __pyx__function);
                    __pyx_t_8 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_6, NULL};
                    __pyx_t_5 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5439, __pyx_L463_error)
                    __Pyx_GOTREF(__pyx_t_5);
                    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_seconds, __pyx_mstate_global->__pyx_int_2, __pyx_t_5, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 5439, __pyx_L463_error)
                    __pyx_t_4 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_25, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_5);
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5439, __pyx_L463_error)
                    __Pyx_GOTREF(__pyx_t_4);
                  }
                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_tol);
                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_tol, __pyx_t_4);
                  __Pyx_GIVEREF(__pyx_t_4);
                  __pyx_t_4 = 0;

                  /* "ws_package/controllers/activity_controller.py":5440
 *                             if st is not None and et is not None:
 *                                 tol = datetime.timedelta(seconds=2)
 *                                 with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                                     async with async_session() as session:
 *                                         q = select(ActivityInterval).where(
*/
                  /*with:*/ {
                    __pyx_t_25 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5440, __pyx_L463_error)
                    __Pyx_GOTREF(__pyx_t_5);
                    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5440, __pyx_L463_error)
                    __Pyx_GOTREF(__pyx_t_6);
                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __pyx_t_8 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_6))) {
                      __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_6);
                      assert(__pyx_t_25);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                      __Pyx_INCREF(__pyx_t_25);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                      __pyx_t_8 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_25, NULL};
                      __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5440, __pyx_L463_error)
                      __Pyx_GOTREF(__pyx_t_4);
                    }
                    __pyx_t_19 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 5440, __pyx_L463_error)
                    __Pyx_GOTREF(__pyx_t_19);
                    __pyx_t_25 = NULL;
                    __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5440, __pyx_L474_error)
                    __Pyx_GOTREF(__pyx_t_5);
                    __pyx_t_8 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (likely(PyMethod_Check(__pyx_t_5))) {
                      __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_5);
                      assert(__pyx_t_25);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                      __Pyx_INCREF(__pyx_t_25);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                      __pyx_t_8 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_25, NULL};
                      __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5440, __pyx_L474_error)
                      __Pyx_GOTREF(__pyx_t_6);
                    }
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    /*try:*/ {
                      {
                        __Pyx_ExceptionSave(&__pyx_t_15, &__pyx_t_37, &__pyx_t_20);
                        __Pyx_XGOTREF(__pyx_t_15);
                        __Pyx_XGOTREF(__pyx_t_37);
                        __Pyx_XGOTREF(__pyx_t_20);
                        /*try:*/ {

                          /* "ws_package/controllers/activity_controller.py":5441
 *                                 tol = datetime.timedelta(seconds=2)
 *                                 with db_lock_manager.read_lock():
 *                                     async with async_session() as session:             # <<<<<<<<<<<<<<
 *                                         q = select(ActivityInterval).where(
 *                                             ActivityInterval.counter == getattr(last_interval, 'counter', current_session_counter),
*/
                          /*with:*/ {
                            __pyx_t_6 = NULL;
                            __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5441, __pyx_L480_error)
                            __Pyx_GOTREF(__pyx_t_5);
                            __pyx_t_8 = 1;
                            #if CYTHON_UNPACK_METHODS
                            if (unlikely(PyMethod_Check(__pyx_t_5))) {
                              __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
                              assert(__pyx_t_6);
                              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                              __Pyx_INCREF(__pyx_t_6);
                              __Pyx_INCREF(__pyx__function);
                              __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                              __pyx_t_8 = 0;
                            }
                            #endif
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
                              __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5441, __pyx_L480_error)
                              __Pyx_GOTREF(__pyx_t_4);
                            }
                            __pyx_t_18 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 5441, __pyx_L480_error)
                            __Pyx_GOTREF(__pyx_t_18);
                            __pyx_t_6 = NULL;
                            __pyx_t_25 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5441, __pyx_L488_error)
                            __Pyx_GOTREF(__pyx_t_25);
                            __pyx_t_8 = 1;
                            #if CYTHON_UNPACK_METHODS
                            if (likely(PyMethod_Check(__pyx_t_25))) {
                              __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_25);
                              assert(__pyx_t_6);
                              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_25);
                              __Pyx_INCREF(__pyx_t_6);
                              __Pyx_INCREF(__pyx__function);
                              __Pyx_DECREF_SET(__pyx_t_25, __pyx__function);
                              __pyx_t_8 = 0;
                            }
                            #endif
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
                              __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_25, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                              __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                              if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5441, __pyx_L488_error)
                              __Pyx_GOTREF(__pyx_t_5);
                            }
                            __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
                            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                            if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                              __Pyx_GOTREF(__pyx_r);
                              __Pyx_XGIVEREF(__pyx_t_1);
                              __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                              __Pyx_XGIVEREF(__pyx_t_2);
                              __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                              __Pyx_XGIVEREF(__pyx_t_3);
                              __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                              __Pyx_XGIVEREF(__pyx_t_4);
                              __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
                              __Pyx_XGIVEREF(__pyx_t_12);
                              __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                              __Pyx_XGIVEREF(__pyx_t_13);
                              __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                              __Pyx_XGIVEREF(__pyx_t_14);
                              __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                              __Pyx_XGIVEREF(__pyx_t_15);
                              __pyx_cur_scope->__pyx_t_7 = __pyx_t_15;
                              __Pyx_XGIVEREF(__pyx_t_18);
                              __pyx_cur_scope->__pyx_t_8 = __pyx_t_18;
                              __Pyx_XGIVEREF(__pyx_t_19);
                              __pyx_cur_scope->__pyx_t_9 = __pyx_t_19;
                              __Pyx_XGIVEREF(__pyx_t_20);
                              __pyx_cur_scope->__pyx_t_10 = __pyx_t_20;
                              __Pyx_XGIVEREF(__pyx_t_23);
                              __pyx_cur_scope->__pyx_t_11 = __pyx_t_23;
                              __Pyx_XGIVEREF(__pyx_t_37);
                              __pyx_cur_scope->__pyx_t_12 = __pyx_t_37;
                              __Pyx_XGIVEREF(__pyx_r);
                              __Pyx_RefNannyFinishContext();
                              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                              /* return from generator, awaiting value */
                              __pyx_generator->resume_label = 33;
                              return __pyx_r;
                              __pyx_L489_resume_from_await:;
                              __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                              __pyx_cur_scope->__pyx_t_0 = 0;
                              __Pyx_XGOTREF(__pyx_t_1);
                              __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                              __pyx_cur_scope->__pyx_t_1 = 0;
                              __Pyx_XGOTREF(__pyx_t_2);
                              __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                              __pyx_cur_scope->__pyx_t_2 = 0;
                              __Pyx_XGOTREF(__pyx_t_3);
                              __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
                              __pyx_cur_scope->__pyx_t_3 = 0;
                              __Pyx_XGOTREF(__pyx_t_4);
                              __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                              __pyx_cur_scope->__pyx_t_4 = 0;
                              __Pyx_XGOTREF(__pyx_t_12);
                              __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                              __pyx_cur_scope->__pyx_t_5 = 0;
                              __Pyx_XGOTREF(__pyx_t_13);
                              __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                              __pyx_cur_scope->__pyx_t_6 = 0;
                              __Pyx_XGOTREF(__pyx_t_14);
                              __pyx_t_15 = __pyx_cur_scope->__pyx_t_7;
                              __pyx_cur_scope->__pyx_t_7 = 0;
                              __Pyx_XGOTREF(__pyx_t_15);
                              __pyx_t_18 = __pyx_cur_scope->__pyx_t_8;
                              __pyx_cur_scope->__pyx_t_8 = 0;
                              __Pyx_XGOTREF(__pyx_t_18);
                              __pyx_t_19 = __pyx_cur_scope->__pyx_t_9;
                              __pyx_cur_scope->__pyx_t_9 = 0;
                              __Pyx_XGOTREF(__pyx_t_19);
                              __pyx_t_20 = __pyx_cur_scope->__pyx_t_10;
                              __pyx_cur_scope->__pyx_t_10 = 0;
                              __Pyx_XGOTREF(__pyx_t_20);
                              __pyx_t_23 = __pyx_cur_scope->__pyx_t_11;
                              __pyx_cur_scope->__pyx_t_11 = 0;
                              __Pyx_XGOTREF(__pyx_t_23);
                              __pyx_t_37 = __pyx_cur_scope->__pyx_t_12;
                              __pyx_cur_scope->__pyx_t_12 = 0;
                              __Pyx_XGOTREF(__pyx_t_37);
                              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5441, __pyx_L488_error)
                              __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
                            } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                              __Pyx_GOTREF(__pyx_r);
                              __pyx_t_5 = __pyx_r; __pyx_r = NULL;
                            } else {
                              __Pyx_XGOTREF(__pyx_r);
                              __PYX_ERR(0, 5441, __pyx_L488_error)
                            }
                            __pyx_t_25 = __pyx_t_5;
                            __pyx_t_5 = 0;
                            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                            /*try:*/ {
                              {
                                __Pyx_ExceptionSave(&__pyx_t_21, &__pyx_t_22, &__pyx_t_17);
                                __Pyx_XGOTREF(__pyx_t_21);
                                __Pyx_XGOTREF(__pyx_t_22);
                                __Pyx_XGOTREF(__pyx_t_17);
                                /*try:*/ {
                                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_session);
                                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_session, __pyx_t_25);
                                  __Pyx_GIVEREF(__pyx_t_25);
                                  __pyx_t_25 = 0;

                                  /* "ws_package/controllers/activity_controller.py":5442
 *                                 with db_lock_manager.read_lock():
 *                                     async with async_session() as session:
 *                                         q = select(ActivityInterval).where(             # <<<<<<<<<<<<<<
 *                                             ActivityInterval.counter == getattr(last_interval, 'counter', current_session_counter),
 *                                             ActivityInterval.start_time >= st - tol,
*/
                                  __pyx_t_24 = NULL;
                                  __Pyx_GetModuleGlobalName(__pyx_t_52, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5442, __pyx_L495_error)
                                  __Pyx_GOTREF(__pyx_t_52);
                                  __Pyx_GetModuleGlobalName(__pyx_t_38, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_38)) __PYX_ERR(0, 5442, __pyx_L495_error)
                                  __Pyx_GOTREF(__pyx_t_38);
                                  __pyx_t_8 = 1;
                                  #if CYTHON_UNPACK_METHODS
                                  if (unlikely(PyMethod_Check(__pyx_t_52))) {
                                    __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_52);
                                    assert(__pyx_t_24);
                                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_52);
                                    __Pyx_INCREF(__pyx_t_24);
                                    __Pyx_INCREF(__pyx__function);
                                    __Pyx_DECREF_SET(__pyx_t_52, __pyx__function);
                                    __pyx_t_8 = 0;
                                  }
                                  #endif
                                  {
                                    PyObject *__pyx_callargs[2] = {__pyx_t_24, __pyx_t_38};
                                    __pyx_t_39 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_52, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                                    __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0;
                                    __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
                                    if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5442, __pyx_L495_error)
                                    __Pyx_GOTREF(__pyx_t_39);
                                  }
                                  __pyx_t_26 = __pyx_t_39;
                                  __Pyx_INCREF(__pyx_t_26);

                                  /* "ws_package/controllers/activity_controller.py":5443
 *                                     async with async_session() as session:
 *                                         q = select(ActivityInterval).where(
 *                                             ActivityInterval.counter == getattr(last_interval, 'counter', current_session_counter),             # <<<<<<<<<<<<<<
 *                                             ActivityInterval.start_time >= st - tol,
 *                                             ActivityInterval.start_time <= st + tol,
*/
                                  __Pyx_GetModuleGlobalName(__pyx_t_52, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5443, __pyx_L495_error)
                                  __Pyx_GOTREF(__pyx_t_52);
                                  __pyx_t_38 = __Pyx_PyObject_GetAttrStr(__pyx_t_52, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_38)) __PYX_ERR(0, 5443, __pyx_L495_error)
                                  __Pyx_GOTREF(__pyx_t_38);
                                  __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
                                  __pyx_t_52 = __pyx_cur_scope->__pyx_v_last_interval;
                                  __Pyx_INCREF(__pyx_t_52);
                                  __pyx_t_24 = __Pyx_GetAttr3(__pyx_t_52, __pyx_mstate_global->__pyx_n_u_counter, __pyx_cur_scope->__pyx_v_current_session_counter); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5443, __pyx_L495_error)
                                  __Pyx_GOTREF(__pyx_t_24);
                                  __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
                                  __pyx_t_52 = PyObject_RichCompare(__pyx_t_38, __pyx_t_24, Py_EQ); __Pyx_XGOTREF(__pyx_t_52); if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5443, __pyx_L495_error)
                                  __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0;
                                  __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;

                                  /* "ws_package/controllers/activity_controller.py":5444
 *                                         q = select(ActivityInterval).where(
 *                                             ActivityInterval.counter == getattr(last_interval, 'counter', current_session_counter),
 *                                             ActivityInterval.start_time >= st - tol,             # <<<<<<<<<<<<<<
 *                                             ActivityInterval.start_time <= st + tol,
 *                                             ActivityInterval.end_time >= et - tol,
*/
                                  __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5444, __pyx_L495_error)
                                  __Pyx_GOTREF(__pyx_t_24);
                                  __pyx_t_38 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_38)) __PYX_ERR(0, 5444, __pyx_L495_error)
                                  __Pyx_GOTREF(__pyx_t_38);
                                  __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                                  __pyx_t_24 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_st, __pyx_cur_scope->__pyx_v_tol); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5444, __pyx_L495_error)
                                  __Pyx_GOTREF(__pyx_t_24);
                                  __pyx_t_40 = PyObject_RichCompare(__pyx_t_38, __pyx_t_24, Py_GE); __Pyx_XGOTREF(__pyx_t_40); if (unlikely(!__pyx_t_40)) __PYX_ERR(0, 5444, __pyx_L495_error)
                                  __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0;
                                  __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;

                                  /* "ws_package/controllers/activity_controller.py":5445
 *                                             ActivityInterval.counter == getattr(last_interval, 'counter', current_session_counter),
 *                                             ActivityInterval.start_time >= st - tol,
 *                                             ActivityInterval.start_time <= st + tol,             # <<<<<<<<<<<<<<
 *                                             ActivityInterval.end_time >= et - tol,
 *                                             ActivityInterval.end_time <= et + tol,
*/
                                  __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5445, __pyx_L495_error)
                                  __Pyx_GOTREF(__pyx_t_24);
                                  __pyx_t_38 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_38)) __PYX_ERR(0, 5445, __pyx_L495_error)
                                  __Pyx_GOTREF(__pyx_t_38);
                                  __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                                  __pyx_t_24 = PyNumber_Add(__pyx_cur_scope->__pyx_v_st, __pyx_cur_scope->__pyx_v_tol); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5445, __pyx_L495_error)
                                  __Pyx_GOTREF(__pyx_t_24);
                                  __pyx_t_10 = PyObject_RichCompare(__pyx_t_38, __pyx_t_24, Py_LE); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5445, __pyx_L495_error)
                                  __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0;
                                  __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;

                                  /* "ws_package/controllers/activity_controller.py":5446
 *                                             ActivityInterval.start_time >= st - tol,
 *                                             ActivityInterval.start_time <= st + tol,
 *                                             ActivityInterval.end_time >= et - tol,             # <<<<<<<<<<<<<<
 *                                             ActivityInterval.end_time <= et + tol,
 *                                         ).order_by(ActivityInterval.id.desc()).limit(1)
*/
                                  __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5446, __pyx_L495_error)
                                  __Pyx_GOTREF(__pyx_t_24);
                                  __pyx_t_38 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_38)) __PYX_ERR(0, 5446, __pyx_L495_error)
                                  __Pyx_GOTREF(__pyx_t_38);
                                  __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                                  __pyx_t_24 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_et, __pyx_cur_scope->__pyx_v_tol); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5446, __pyx_L495_error)
                                  __Pyx_GOTREF(__pyx_t_24);
                                  __pyx_t_27 = PyObject_RichCompare(__pyx_t_38, __pyx_t_24, Py_GE); __Pyx_XGOTREF(__pyx_t_27); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 5446, __pyx_L495_error)
                                  __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0;
                                  __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;

                                  /* "ws_package/controllers/activity_controller.py":5447
 *                                             ActivityInterval.start_time <= st + tol,
 *                                             ActivityInterval.end_time >= et - tol,
 *                                             ActivityInterval.end_time <= et + tol,             # <<<<<<<<<<<<<<
 *                                         ).order_by(ActivityInterval.id.desc()).limit(1)
 *                                         res = await session.execute(q)
*/
                                  __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5447, __pyx_L495_error)
                                  __Pyx_GOTREF(__pyx_t_24);
                                  __pyx_t_38 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_38)) __PYX_ERR(0, 5447, __pyx_L495_error)
                                  __Pyx_GOTREF(__pyx_t_38);
                                  __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                                  __pyx_t_24 = PyNumber_Add(__pyx_cur_scope->__pyx_v_et, __pyx_cur_scope->__pyx_v_tol); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5447, __pyx_L495_error)
                                  __Pyx_GOTREF(__pyx_t_24);
                                  __pyx_t_55 = PyObject_RichCompare(__pyx_t_38, __pyx_t_24, Py_LE); __Pyx_XGOTREF(__pyx_t_55); if (unlikely(!__pyx_t_55)) __PYX_ERR(0, 5447, __pyx_L495_error)
                                  __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0;
                                  __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                                  __pyx_t_8 = 0;
                                  {
                                    PyObject *__pyx_callargs[6] = {__pyx_t_26, __pyx_t_52, __pyx_t_40, __pyx_t_10, __pyx_t_27, __pyx_t_55};
                                    __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_8, (6-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                    __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                                    __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
                                    __Pyx_DECREF(__pyx_t_40); __pyx_t_40 = 0;
                                    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                                    __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                                    __Pyx_DECREF(__pyx_t_55); __pyx_t_55 = 0;
                                    __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                                    if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5442, __pyx_L495_error)
                                    __Pyx_GOTREF(__pyx_t_7);
                                  }
                                  __pyx_t_6 = __pyx_t_7;
                                  __Pyx_INCREF(__pyx_t_6);

                                  /* "ws_package/controllers/activity_controller.py":5448
 *                                             ActivityInterval.end_time >= et - tol,
 *                                             ActivityInterval.end_time <= et + tol,
 *                                         ).order_by(ActivityInterval.id.desc()).limit(1)             # <<<<<<<<<<<<<<
 *                                         res = await session.execute(q)
 *                                         db_last = res.scalar_one_or_none()
*/
                                  __Pyx_GetModuleGlobalName(__pyx_t_27, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 5448, __pyx_L495_error)
                                  __Pyx_GOTREF(__pyx_t_27);
                                  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_27, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5448, __pyx_L495_error)
                                  __Pyx_GOTREF(__pyx_t_10);
                                  __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                                  __pyx_t_55 = __pyx_t_10;
                                  __Pyx_INCREF(__pyx_t_55);
                                  __pyx_t_8 = 0;
                                  {
                                    PyObject *__pyx_callargs[2] = {__pyx_t_55, NULL};
                                    __pyx_t_39 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_desc, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                    __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
                                    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                                    if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5448, __pyx_L495_error)
                                    __Pyx_GOTREF(__pyx_t_39);
                                  }
                                  __pyx_t_8 = 0;
                                  {
                                    PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_39};
                                    __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_order_by, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                                    __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                                    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                                    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5448, __pyx_L495_error)
                                    __Pyx_GOTREF(__pyx_t_5);
                                  }
                                  __pyx_t_4 = __pyx_t_5;
                                  __Pyx_INCREF(__pyx_t_4);
                                  __pyx_t_8 = 0;
                                  {
                                    PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_int_1};
                                    __pyx_t_25 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_limit, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                                    if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5448, __pyx_L495_error)
                                    __Pyx_GOTREF(__pyx_t_25);
                                  }
                                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_q);
                                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_q, __pyx_t_25);
                                  __Pyx_GIVEREF(__pyx_t_25);
                                  __pyx_t_25 = 0;

                                  /* "ws_package/controllers/activity_controller.py":5449
 *                                             ActivityInterval.end_time <= et + tol,
 *                                         ).order_by(ActivityInterval.id.desc()).limit(1)
 *                                         res = await session.execute(q)             # <<<<<<<<<<<<<<
 *                                         db_last = res.scalar_one_or_none()
 *                                         if db_last and db_last.id:
*/
                                  __pyx_t_5 = __pyx_cur_scope->__pyx_v_session;
                                  __Pyx_INCREF(__pyx_t_5);
                                  __pyx_t_8 = 0;
                                  {
                                    PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_q};
                                    __pyx_t_25 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                                    if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5449, __pyx_L495_error)
                                    __Pyx_GOTREF(__pyx_t_25);
                                  }
                                  __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_25, &__pyx_r);
                                  __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                                  if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                    __Pyx_GOTREF(__pyx_r);
                                    __Pyx_XGIVEREF(__pyx_t_1);
                                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                    __Pyx_XGIVEREF(__pyx_t_2);
                                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                    __Pyx_XGIVEREF(__pyx_t_3);
                                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                    __Pyx_XGIVEREF(__pyx_t_12);
                                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                                    __Pyx_XGIVEREF(__pyx_t_13);
                                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                                    __Pyx_XGIVEREF(__pyx_t_14);
                                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                                    __Pyx_XGIVEREF(__pyx_t_15);
                                    __pyx_cur_scope->__pyx_t_6 = __pyx_t_15;
                                    __Pyx_XGIVEREF(__pyx_t_17);
                                    __pyx_cur_scope->__pyx_t_7 = __pyx_t_17;
                                    __Pyx_XGIVEREF(__pyx_t_18);
                                    __pyx_cur_scope->__pyx_t_8 = __pyx_t_18;
                                    __Pyx_XGIVEREF(__pyx_t_19);
                                    __pyx_cur_scope->__pyx_t_9 = __pyx_t_19;
                                    __Pyx_XGIVEREF(__pyx_t_20);
                                    __pyx_cur_scope->__pyx_t_10 = __pyx_t_20;
                                    __Pyx_XGIVEREF(__pyx_t_21);
                                    __pyx_cur_scope->__pyx_t_11 = __pyx_t_21;
                                    __Pyx_XGIVEREF(__pyx_t_22);
                                    __pyx_cur_scope->__pyx_t_12 = __pyx_t_22;
                                    __Pyx_XGIVEREF(__pyx_t_23);
                                    __pyx_cur_scope->__pyx_t_13 = __pyx_t_23;
                                    __Pyx_XGIVEREF(__pyx_t_37);
                                    __pyx_cur_scope->__pyx_t_14 = __pyx_t_37;
                                    __Pyx_XGIVEREF(__pyx_r);
                                    __Pyx_RefNannyFinishContext();
                                    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                                    /* return from generator, awaiting value */
                                    __pyx_generator->resume_label = 34;
                                    return __pyx_r;
                                    __pyx_L503_resume_from_await:;
                                    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                    __pyx_cur_scope->__pyx_t_0 = 0;
                                    __Pyx_XGOTREF(__pyx_t_1);
                                    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                    __pyx_cur_scope->__pyx_t_1 = 0;
                                    __Pyx_XGOTREF(__pyx_t_2);
                                    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                    __pyx_cur_scope->__pyx_t_2 = 0;
                                    __Pyx_XGOTREF(__pyx_t_3);
                                    __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                                    __pyx_cur_scope->__pyx_t_3 = 0;
                                    __Pyx_XGOTREF(__pyx_t_12);
                                    __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                                    __pyx_cur_scope->__pyx_t_4 = 0;
                                    __Pyx_XGOTREF(__pyx_t_13);
                                    __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                                    __pyx_cur_scope->__pyx_t_5 = 0;
                                    __Pyx_XGOTREF(__pyx_t_14);
                                    __pyx_t_15 = __pyx_cur_scope->__pyx_t_6;
                                    __pyx_cur_scope->__pyx_t_6 = 0;
                                    __Pyx_XGOTREF(__pyx_t_15);
                                    __pyx_t_17 = __pyx_cur_scope->__pyx_t_7;
                                    __pyx_cur_scope->__pyx_t_7 = 0;
                                    __Pyx_XGOTREF(__pyx_t_17);
                                    __pyx_t_18 = __pyx_cur_scope->__pyx_t_8;
                                    __pyx_cur_scope->__pyx_t_8 = 0;
                                    __Pyx_XGOTREF(__pyx_t_18);
                                    __pyx_t_19 = __pyx_cur_scope->__pyx_t_9;
                                    __pyx_cur_scope->__pyx_t_9 = 0;
                                    __Pyx_XGOTREF(__pyx_t_19);
                                    __pyx_t_20 = __pyx_cur_scope->__pyx_t_10;
                                    __pyx_cur_scope->__pyx_t_10 = 0;
                                    __Pyx_XGOTREF(__pyx_t_20);
                                    __pyx_t_21 = __pyx_cur_scope->__pyx_t_11;
                                    __pyx_cur_scope->__pyx_t_11 = 0;
                                    __Pyx_XGOTREF(__pyx_t_21);
                                    __pyx_t_22 = __pyx_cur_scope->__pyx_t_12;
                                    __pyx_cur_scope->__pyx_t_12 = 0;
                                    __Pyx_XGOTREF(__pyx_t_22);
                                    __pyx_t_23 = __pyx_cur_scope->__pyx_t_13;
                                    __pyx_cur_scope->__pyx_t_13 = 0;
                                    __Pyx_XGOTREF(__pyx_t_23);
                                    __pyx_t_37 = __pyx_cur_scope->__pyx_t_14;
                                    __pyx_cur_scope->__pyx_t_14 = 0;
                                    __Pyx_XGOTREF(__pyx_t_37);
                                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5449, __pyx_L495_error)
                                    __pyx_t_25 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_25);
                                  } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                    __Pyx_GOTREF(__pyx_r);
                                    __pyx_t_25 = __pyx_r; __pyx_r = NULL;
                                  } else {
                                    __Pyx_XGOTREF(__pyx_r);
                                    __PYX_ERR(0, 5449, __pyx_L495_error)
                                  }
                                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_res);
                                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_res, __pyx_t_25);
                                  __Pyx_GIVEREF(__pyx_t_25);
                                  __pyx_t_25 = 0;

                                  /* "ws_package/controllers/activity_controller.py":5450
 *                                         ).order_by(ActivityInterval.id.desc()).limit(1)
 *                                         res = await session.execute(q)
 *                                         db_last = res.scalar_one_or_none()             # <<<<<<<<<<<<<<
 *                                         if db_last and db_last.id:
 *                                             await self.activity_service.update_activity_interval(db_last)
*/
                                  __pyx_t_5 = __pyx_cur_scope->__pyx_v_res;
                                  __Pyx_INCREF(__pyx_t_5);
                                  __pyx_t_8 = 0;
                                  {
                                    PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                                    __pyx_t_25 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalar_one_or_none, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                                    if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5450, __pyx_L495_error)
                                    __Pyx_GOTREF(__pyx_t_25);
                                  }
                                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_db_last);
                                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_db_last, __pyx_t_25);
                                  __Pyx_GIVEREF(__pyx_t_25);
                                  __pyx_t_25 = 0;

                                  /* "ws_package/controllers/activity_controller.py":5451
 *                                         res = await session.execute(q)
 *                                         db_last = res.scalar_one_or_none()
 *                                         if db_last and db_last.id:             # <<<<<<<<<<<<<<
 *                                             await self.activity_service.update_activity_interval(db_last)
 *                                             last_interval_updated = True
*/
                                  __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_db_last); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5451, __pyx_L495_error)
                                  if (__pyx_t_47) {
                                  } else {
                                    __pyx_t_28 = __pyx_t_47;
                                    goto __pyx_L505_bool_binop_done;
                                  }
                                  __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_db_last, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5451, __pyx_L495_error)
                                  __Pyx_GOTREF(__pyx_t_25);
                                  __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_t_25); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5451, __pyx_L495_error)
                                  __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                                  __pyx_t_28 = __pyx_t_47;
                                  __pyx_L505_bool_binop_done:;
                                  if (__pyx_t_28) {

                                    /* "ws_package/controllers/activity_controller.py":5452
 *                                         db_last = res.scalar_one_or_none()
 *                                         if db_last and db_last.id:
 *                                             await self.activity_service.update_activity_interval(db_last)             # <<<<<<<<<<<<<<
 *                                             last_interval_updated = True
 *                                             logger.info("Last interval (id=%s) found with tolerance and marked uploaded before screenshot delete", db_last.id)
*/
                                    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5452, __pyx_L495_error)
                                    __Pyx_GOTREF(__pyx_t_4);
                                    __pyx_t_5 = __pyx_t_4;
                                    __Pyx_INCREF(__pyx_t_5);
                                    __pyx_t_8 = 0;
                                    {
                                      PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_db_last};
                                      __pyx_t_25 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_update_activity_interval, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                      if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5452, __pyx_L495_error)
                                      __Pyx_GOTREF(__pyx_t_25);
                                    }
                                    __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_25, &__pyx_r);
                                    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                                    if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                      __Pyx_GOTREF(__pyx_r);
                                      __Pyx_XGIVEREF(__pyx_t_1);
                                      __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                      __Pyx_XGIVEREF(__pyx_t_2);
                                      __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                      __Pyx_XGIVEREF(__pyx_t_3);
                                      __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                      __Pyx_XGIVEREF(__pyx_t_12);
                                      __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                                      __Pyx_XGIVEREF(__pyx_t_13);
                                      __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                                      __Pyx_XGIVEREF(__pyx_t_14);
                                      __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                                      __Pyx_XGIVEREF(__pyx_t_15);
                                      __pyx_cur_scope->__pyx_t_6 = __pyx_t_15;
                                      __Pyx_XGIVEREF(__pyx_t_17);
                                      __pyx_cur_scope->__pyx_t_7 = __pyx_t_17;
                                      __Pyx_XGIVEREF(__pyx_t_18);
                                      __pyx_cur_scope->__pyx_t_8 = __pyx_t_18;
                                      __Pyx_XGIVEREF(__pyx_t_19);
                                      __pyx_cur_scope->__pyx_t_9 = __pyx_t_19;
                                      __Pyx_XGIVEREF(__pyx_t_20);
                                      __pyx_cur_scope->__pyx_t_10 = __pyx_t_20;
                                      __Pyx_XGIVEREF(__pyx_t_21);
                                      __pyx_cur_scope->__pyx_t_11 = __pyx_t_21;
                                      __Pyx_XGIVEREF(__pyx_t_22);
                                      __pyx_cur_scope->__pyx_t_12 = __pyx_t_22;
                                      __Pyx_XGIVEREF(__pyx_t_23);
                                      __pyx_cur_scope->__pyx_t_13 = __pyx_t_23;
                                      __Pyx_XGIVEREF(__pyx_t_37);
                                      __pyx_cur_scope->__pyx_t_14 = __pyx_t_37;
                                      __Pyx_XGIVEREF(__pyx_r);
                                      __Pyx_RefNannyFinishContext();
                                      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                                      /* return from generator, awaiting value */
                                      __pyx_generator->resume_label = 35;
                                      return __pyx_r;
                                      __pyx_L507_resume_from_await:;
                                      __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                      __pyx_cur_scope->__pyx_t_0 = 0;
                                      __Pyx_XGOTREF(__pyx_t_1);
                                      __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                      __pyx_cur_scope->__pyx_t_1 = 0;
                                      __Pyx_XGOTREF(__pyx_t_2);
                                      __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                      __pyx_cur_scope->__pyx_t_2 = 0;
                                      __Pyx_XGOTREF(__pyx_t_3);
                                      __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                                      __pyx_cur_scope->__pyx_t_3 = 0;
                                      __Pyx_XGOTREF(__pyx_t_12);
                                      __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                                      __pyx_cur_scope->__pyx_t_4 = 0;
                                      __Pyx_XGOTREF(__pyx_t_13);
                                      __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                                      __pyx_cur_scope->__pyx_t_5 = 0;
                                      __Pyx_XGOTREF(__pyx_t_14);
                                      __pyx_t_15 = __pyx_cur_scope->__pyx_t_6;
                                      __pyx_cur_scope->__pyx_t_6 = 0;
                                      __Pyx_XGOTREF(__pyx_t_15);
                                      __pyx_t_17 = __pyx_cur_scope->__pyx_t_7;
                                      __pyx_cur_scope->__pyx_t_7 = 0;
                                      __Pyx_XGOTREF(__pyx_t_17);
                                      __pyx_t_18 = __pyx_cur_scope->__pyx_t_8;
                                      __pyx_cur_scope->__pyx_t_8 = 0;
                                      __Pyx_XGOTREF(__pyx_t_18);
                                      __pyx_t_19 = __pyx_cur_scope->__pyx_t_9;
                                      __pyx_cur_scope->__pyx_t_9 = 0;
                                      __Pyx_XGOTREF(__pyx_t_19);
                                      __pyx_t_20 = __pyx_cur_scope->__pyx_t_10;
                                      __pyx_cur_scope->__pyx_t_10 = 0;
                                      __Pyx_XGOTREF(__pyx_t_20);
                                      __pyx_t_21 = __pyx_cur_scope->__pyx_t_11;
                                      __pyx_cur_scope->__pyx_t_11 = 0;
                                      __Pyx_XGOTREF(__pyx_t_21);
                                      __pyx_t_22 = __pyx_cur_scope->__pyx_t_12;
                                      __pyx_cur_scope->__pyx_t_12 = 0;
                                      __Pyx_XGOTREF(__pyx_t_22);
                                      __pyx_t_23 = __pyx_cur_scope->__pyx_t_13;
                                      __pyx_cur_scope->__pyx_t_13 = 0;
                                      __Pyx_XGOTREF(__pyx_t_23);
                                      __pyx_t_37 = __pyx_cur_scope->__pyx_t_14;
                                      __pyx_cur_scope->__pyx_t_14 = 0;
                                      __Pyx_XGOTREF(__pyx_t_37);
                                      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5452, __pyx_L495_error)
                                    } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                      __Pyx_GOTREF(__pyx_r);
                                      __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                                    } else {
                                      __Pyx_XGOTREF(__pyx_r);
                                      __PYX_ERR(0, 5452, __pyx_L495_error)
                                    }

                                    /* "ws_package/controllers/activity_controller.py":5453
 *                                         if db_last and db_last.id:
 *                                             await self.activity_service.update_activity_interval(db_last)
 *                                             last_interval_updated = True             # <<<<<<<<<<<<<<
 *                                             logger.info("Last interval (id=%s) found with tolerance and marked uploaded before screenshot delete", db_last.id)
 *                                 if last_interval_updated:
*/
                                    __pyx_cur_scope->__pyx_v_last_interval_updated = 1;

                                    /* "ws_package/controllers/activity_controller.py":5454
 *                                             await self.activity_service.update_activity_interval(db_last)
 *                                             last_interval_updated = True
 *                                             logger.info("Last interval (id=%s) found with tolerance and marked uploaded before screenshot delete", db_last.id)             # <<<<<<<<<<<<<<
 *                                 if last_interval_updated:
 *                                     await db_writer_service.process_immediately()
*/
                                    __pyx_t_4 = NULL;
                                    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5454, __pyx_L495_error)
                                    __Pyx_GOTREF(__pyx_t_5);
                                    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5454, __pyx_L495_error)
                                    __Pyx_GOTREF(__pyx_t_7);
                                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                                    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_db_last, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5454, __pyx_L495_error)
                                    __Pyx_GOTREF(__pyx_t_5);
                                    __pyx_t_8 = 1;
                                    #if CYTHON_UNPACK_METHODS
                                    if (unlikely(PyMethod_Check(__pyx_t_7))) {
                                      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7);
                                      assert(__pyx_t_4);
                                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                                      __Pyx_INCREF(__pyx_t_4);
                                      __Pyx_INCREF(__pyx__function);
                                      __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                                      __pyx_t_8 = 0;
                                    }
                                    #endif
                                    {
                                      PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Last_interval_id_s_found_with_to, __pyx_t_5};
                                      __pyx_t_25 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                                      if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5454, __pyx_L495_error)
                                      __Pyx_GOTREF(__pyx_t_25);
                                    }
                                    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;

                                    /* "ws_package/controllers/activity_controller.py":5451
 *                                         res = await session.execute(q)
 *                                         db_last = res.scalar_one_or_none()
 *                                         if db_last and db_last.id:             # <<<<<<<<<<<<<<
 *                                             await self.activity_service.update_activity_interval(db_last)
 *                                             last_interval_updated = True
*/
                                  }

                                  /* "ws_package/controllers/activity_controller.py":5441
 *                                 tol = datetime.timedelta(seconds=2)
 *                                 with db_lock_manager.read_lock():
 *                                     async with async_session() as session:             # <<<<<<<<<<<<<<
 *                                         q = select(ActivityInterval).where(
 *                                             ActivityInterval.counter == getattr(last_interval, 'counter', current_session_counter),
*/
                                }
                                __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                                __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                                __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                                goto __pyx_L502_try_end;
                                __pyx_L495_error:;
                                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                                __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                                __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                                __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                                __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                                __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                                __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                                __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                                __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                                __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
                                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                                __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                                /*except:*/ {
                                  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
                                  if (__Pyx_GetException(&__pyx_t_25, &__pyx_t_7, &__pyx_t_5) < 0) __PYX_ERR(0, 5441, __pyx_L497_except_error)
                                  __Pyx_XGOTREF(__pyx_t_25);
                                  __Pyx_XGOTREF(__pyx_t_7);
                                  __Pyx_XGOTREF(__pyx_t_5);
                                  __pyx_t_4 = PyTuple_Pack(3, __pyx_t_25, __pyx_t_7, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5441, __pyx_L497_except_error)
                                  __Pyx_GOTREF(__pyx_t_4);
                                  __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_18, __pyx_t_4, NULL);
                                  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                  if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 5441, __pyx_L497_except_error)
                                  __Pyx_GOTREF(__pyx_t_16);
                                  __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_16, &__pyx_r);
                                  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                                  if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                    __Pyx_GOTREF(__pyx_r);
                                    __Pyx_XGIVEREF(__pyx_t_1);
                                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                    __Pyx_XGIVEREF(__pyx_t_2);
                                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                    __Pyx_XGIVEREF(__pyx_t_3);
                                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                    __Pyx_XGIVEREF(__pyx_t_5);
                                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_5;
                                    __Pyx_XGIVEREF(__pyx_t_7);
                                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_7;
                                    __Pyx_XGIVEREF(__pyx_t_12);
                                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                                    __Pyx_XGIVEREF(__pyx_t_13);
                                    __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                                    __Pyx_XGIVEREF(__pyx_t_14);
                                    __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                                    __Pyx_XGIVEREF(__pyx_t_15);
                                    __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                                    __Pyx_XGIVEREF(__pyx_t_16);
                                    __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                                    __Pyx_XGIVEREF(__pyx_t_17);
                                    __pyx_cur_scope->__pyx_t_10 = __pyx_t_17;
                                    __Pyx_XGIVEREF(__pyx_t_18);
                                    __pyx_cur_scope->__pyx_t_11 = __pyx_t_18;
                                    __Pyx_XGIVEREF(__pyx_t_19);
                                    __pyx_cur_scope->__pyx_t_12 = __pyx_t_19;
                                    __Pyx_XGIVEREF(__pyx_t_20);
                                    __pyx_cur_scope->__pyx_t_13 = __pyx_t_20;
                                    __Pyx_XGIVEREF(__pyx_t_21);
                                    __pyx_cur_scope->__pyx_t_14 = __pyx_t_21;
                                    __Pyx_XGIVEREF(__pyx_t_22);
                                    __pyx_cur_scope->__pyx_t_15 = __pyx_t_22;
                                    __Pyx_XGIVEREF(__pyx_t_23);
                                    __pyx_cur_scope->__pyx_t_16 = __pyx_t_23;
                                    __Pyx_XGIVEREF(__pyx_t_25);
                                    __pyx_cur_scope->__pyx_t_17 = __pyx_t_25;
                                    __Pyx_XGIVEREF(__pyx_t_37);
                                    __pyx_cur_scope->__pyx_t_19 = __pyx_t_37;
                                    __Pyx_XGIVEREF(__pyx_r);
                                    __Pyx_RefNannyFinishContext();
                                    __Pyx_Coroutine_SwapException(__pyx_generator);
                                    /* return from generator, awaiting value */
                                    __pyx_generator->resume_label = 36;
                                    return __pyx_r;
                                    __pyx_L511_resume_from_await:;
                                    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                    __pyx_cur_scope->__pyx_t_0 = 0;
                                    __Pyx_XGOTREF(__pyx_t_1);
                                    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                    __pyx_cur_scope->__pyx_t_1 = 0;
                                    __Pyx_XGOTREF(__pyx_t_2);
                                    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                    __pyx_cur_scope->__pyx_t_2 = 0;
                                    __Pyx_XGOTREF(__pyx_t_3);
                                    __pyx_t_5 = __pyx_cur_scope->__pyx_t_3;
                                    __pyx_cur_scope->__pyx_t_3 = 0;
                                    __Pyx_XGOTREF(__pyx_t_5);
                                    __pyx_t_7 = __pyx_cur_scope->__pyx_t_4;
                                    __pyx_cur_scope->__pyx_t_4 = 0;
                                    __Pyx_XGOTREF(__pyx_t_7);
                                    __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                                    __pyx_cur_scope->__pyx_t_5 = 0;
                                    __Pyx_XGOTREF(__pyx_t_12);
                                    __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                                    __pyx_cur_scope->__pyx_t_6 = 0;
                                    __Pyx_XGOTREF(__pyx_t_13);
                                    __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                                    __pyx_cur_scope->__pyx_t_7 = 0;
                                    __Pyx_XGOTREF(__pyx_t_14);
                                    __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                                    __pyx_cur_scope->__pyx_t_8 = 0;
                                    __Pyx_XGOTREF(__pyx_t_15);
                                    __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                                    __pyx_cur_scope->__pyx_t_9 = 0;
                                    __Pyx_XGOTREF(__pyx_t_16);
                                    __pyx_t_17 = __pyx_cur_scope->__pyx_t_10;
                                    __pyx_cur_scope->__pyx_t_10 = 0;
                                    __Pyx_XGOTREF(__pyx_t_17);
                                    __pyx_t_18 = __pyx_cur_scope->__pyx_t_11;
                                    __pyx_cur_scope->__pyx_t_11 = 0;
                                    __Pyx_XGOTREF(__pyx_t_18);
                                    __pyx_t_19 = __pyx_cur_scope->__pyx_t_12;
                                    __pyx_cur_scope->__pyx_t_12 = 0;
                                    __Pyx_XGOTREF(__pyx_t_19);
                                    __pyx_t_20 = __pyx_cur_scope->__pyx_t_13;
                                    __pyx_cur_scope->__pyx_t_13 = 0;
                                    __Pyx_XGOTREF(__pyx_t_20);
                                    __pyx_t_21 = __pyx_cur_scope->__pyx_t_14;
                                    __pyx_cur_scope->__pyx_t_14 = 0;
                                    __Pyx_XGOTREF(__pyx_t_21);
                                    __pyx_t_22 = __pyx_cur_scope->__pyx_t_15;
                                    __pyx_cur_scope->__pyx_t_15 = 0;
                                    __Pyx_XGOTREF(__pyx_t_22);
                                    __pyx_t_23 = __pyx_cur_scope->__pyx_t_16;
                                    __pyx_cur_scope->__pyx_t_16 = 0;
                                    __Pyx_XGOTREF(__pyx_t_23);
                                    __pyx_t_25 = __pyx_cur_scope->__pyx_t_17;
                                    __pyx_cur_scope->__pyx_t_17 = 0;
                                    __Pyx_XGOTREF(__pyx_t_25);
                                    __pyx_t_37 = __pyx_cur_scope->__pyx_t_19;
                                    __pyx_cur_scope->__pyx_t_19 = 0;
                                    __Pyx_XGOTREF(__pyx_t_37);
                                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5441, __pyx_L497_except_error)
                                    __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                                  } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                    __Pyx_GOTREF(__pyx_r);
                                    __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                                  } else {
                                    __Pyx_XGOTREF(__pyx_r);
                                    __PYX_ERR(0, 5441, __pyx_L497_except_error)
                                  }
                                  __pyx_t_16 = __pyx_t_4;
                                  __pyx_t_4 = 0;
                                  __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_16);
                                  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                                  if (__pyx_t_28 < (0)) __PYX_ERR(0, 5441, __pyx_L497_except_error)
                                  __pyx_t_47 = (!__pyx_t_28);
                                  if (unlikely(__pyx_t_47)) {
                                    __Pyx_GIVEREF(__pyx_t_25);
                                    __Pyx_GIVEREF(__pyx_t_7);
                                    __Pyx_XGIVEREF(__pyx_t_5);
                                    __Pyx_ErrRestoreWithState(__pyx_t_25, __pyx_t_7, __pyx_t_5);
                                    __pyx_t_25 = 0;  __pyx_t_7 = 0;  __pyx_t_5 = 0; 
                                    __PYX_ERR(0, 5441, __pyx_L497_except_error)
                                  }
                                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                                  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                                  goto __pyx_L496_exception_handled;
                                }
                                __pyx_L497_except_error:;
                                __Pyx_XGIVEREF(__pyx_t_21);
                                __Pyx_XGIVEREF(__pyx_t_22);
                                __Pyx_XGIVEREF(__pyx_t_17);
                                __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_17);
                                goto __pyx_L480_error;
                                __pyx_L496_exception_handled:;
                                __Pyx_XGIVEREF(__pyx_t_21);
                                __Pyx_XGIVEREF(__pyx_t_22);
                                __Pyx_XGIVEREF(__pyx_t_17);
                                __Pyx_ExceptionReset(__pyx_t_21, __pyx_t_22, __pyx_t_17);
                                __pyx_L502_try_end:;
                              }
                            }
                            /*finally:*/ {
                              /*normal exit:*/{
                                if (__pyx_t_18) {
                                  __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_18, __pyx_mstate_global->__pyx_tuple[7], NULL);
                                  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                                  if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 5441, __pyx_L480_error)
                                  __Pyx_GOTREF(__pyx_t_17);
                                  __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_17, &__pyx_r);
                                  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                                  if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                    __Pyx_GOTREF(__pyx_r);
                                    __Pyx_XGIVEREF(__pyx_t_1);
                                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                    __Pyx_XGIVEREF(__pyx_t_2);
                                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                    __Pyx_XGIVEREF(__pyx_t_3);
                                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                    __Pyx_XGIVEREF(__pyx_t_12);
                                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                                    __Pyx_XGIVEREF(__pyx_t_13);
                                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                                    __Pyx_XGIVEREF(__pyx_t_14);
                                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                                    __Pyx_XGIVEREF(__pyx_t_15);
                                    __pyx_cur_scope->__pyx_t_6 = __pyx_t_15;
                                    __Pyx_XGIVEREF(__pyx_t_17);
                                    __pyx_cur_scope->__pyx_t_7 = __pyx_t_17;
                                    __Pyx_XGIVEREF(__pyx_t_18);
                                    __pyx_cur_scope->__pyx_t_8 = __pyx_t_18;
                                    __Pyx_XGIVEREF(__pyx_t_19);
                                    __pyx_cur_scope->__pyx_t_9 = __pyx_t_19;
                                    __Pyx_XGIVEREF(__pyx_t_20);
                                    __pyx_cur_scope->__pyx_t_10 = __pyx_t_20;
                                    __Pyx_XGIVEREF(__pyx_t_23);
                                    __pyx_cur_scope->__pyx_t_11 = __pyx_t_23;
                                    __Pyx_XGIVEREF(__pyx_t_37);
                                    __pyx_cur_scope->__pyx_t_12 = __pyx_t_37;
                                    __Pyx_XGIVEREF(__pyx_r);
                                    __Pyx_RefNannyFinishContext();
                                    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                                    /* return from generator, awaiting value */
                                    __pyx_generator->resume_label = 37;
                                    return __pyx_r;
                                    __pyx_L512_resume_from_await:;
                                    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                    __pyx_cur_scope->__pyx_t_0 = 0;
                                    __Pyx_XGOTREF(__pyx_t_1);
                                    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                    __pyx_cur_scope->__pyx_t_1 = 0;
                                    __Pyx_XGOTREF(__pyx_t_2);
                                    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                    __pyx_cur_scope->__pyx_t_2 = 0;
                                    __Pyx_XGOTREF(__pyx_t_3);
                                    __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                                    __pyx_cur_scope->__pyx_t_3 = 0;
                                    __Pyx_XGOTREF(__pyx_t_12);
                                    __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                                    __pyx_cur_scope->__pyx_t_4 = 0;
                                    __Pyx_XGOTREF(__pyx_t_13);
                                    __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                                    __pyx_cur_scope->__pyx_t_5 = 0;
                                    __Pyx_XGOTREF(__pyx_t_14);
                                    __pyx_t_15 = __pyx_cur_scope->__pyx_t_6;
                                    __pyx_cur_scope->__pyx_t_6 = 0;
                                    __Pyx_XGOTREF(__pyx_t_15);
                                    __pyx_t_17 = __pyx_cur_scope->__pyx_t_7;
                                    __pyx_cur_scope->__pyx_t_7 = 0;
                                    __Pyx_XGOTREF(__pyx_t_17);
                                    __pyx_t_18 = __pyx_cur_scope->__pyx_t_8;
                                    __pyx_cur_scope->__pyx_t_8 = 0;
                                    __Pyx_XGOTREF(__pyx_t_18);
                                    __pyx_t_19 = __pyx_cur_scope->__pyx_t_9;
                                    __pyx_cur_scope->__pyx_t_9 = 0;
                                    __Pyx_XGOTREF(__pyx_t_19);
                                    __pyx_t_20 = __pyx_cur_scope->__pyx_t_10;
                                    __pyx_cur_scope->__pyx_t_10 = 0;
                                    __Pyx_XGOTREF(__pyx_t_20);
                                    __pyx_t_23 = __pyx_cur_scope->__pyx_t_11;
                                    __pyx_cur_scope->__pyx_t_11 = 0;
                                    __Pyx_XGOTREF(__pyx_t_23);
                                    __pyx_t_37 = __pyx_cur_scope->__pyx_t_12;
                                    __pyx_cur_scope->__pyx_t_12 = 0;
                                    __Pyx_XGOTREF(__pyx_t_37);
                                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5441, __pyx_L480_error)
                                    __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
                                  } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                    __Pyx_GOTREF(__pyx_r);
                                    __pyx_t_5 = __pyx_r; __pyx_r = NULL;
                                  } else {
                                    __Pyx_XGOTREF(__pyx_r);
                                    __PYX_ERR(0, 5441, __pyx_L480_error)
                                  }
                                  __pyx_t_17 = __pyx_t_5;
                                  __pyx_t_5 = 0;
                                  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                                }
                                goto __pyx_L494;
                              }
                              __pyx_L494:;
                            }
                            goto __pyx_L513;
                            __pyx_L488_error:;
                            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                            goto __pyx_L480_error;
                            __pyx_L513:;
                          }

                          /* "ws_package/controllers/activity_controller.py":5440
 *                             if st is not None and et is not None:
 *                                 tol = datetime.timedelta(seconds=2)
 *                                 with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                                     async with async_session() as session:
 *                                         q = select(ActivityInterval).where(
*/
                        }
                        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                        __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                        __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                        goto __pyx_L487_try_end;
                        __pyx_L480_error:;
                        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                        __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                        __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                        __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                        __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                        __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                        __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                        __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
                        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                        /*except:*/ {
                          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
                          if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_7, &__pyx_t_25) < 0) __PYX_ERR(0, 5440, __pyx_L482_except_error)
                          __Pyx_XGOTREF(__pyx_t_5);
                          __Pyx_XGOTREF(__pyx_t_7);
                          __Pyx_XGOTREF(__pyx_t_25);
                          __pyx_t_4 = PyTuple_Pack(3, __pyx_t_5, __pyx_t_7, __pyx_t_25); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5440, __pyx_L482_except_error)
                          __Pyx_GOTREF(__pyx_t_4);
                          __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_19, __pyx_t_4, NULL);
                          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                          if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 5440, __pyx_L482_except_error)
                          __Pyx_GOTREF(__pyx_t_18);
                          __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_t_18);
                          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                          if (__pyx_t_47 < (0)) __PYX_ERR(0, 5440, __pyx_L482_except_error)
                          __pyx_t_28 = (!__pyx_t_47);
                          if (unlikely(__pyx_t_28)) {
                            __Pyx_GIVEREF(__pyx_t_5);
                            __Pyx_GIVEREF(__pyx_t_7);
                            __Pyx_XGIVEREF(__pyx_t_25);
                            __Pyx_ErrRestoreWithState(__pyx_t_5, __pyx_t_7, __pyx_t_25);
                            __pyx_t_5 = 0;  __pyx_t_7 = 0;  __pyx_t_25 = 0; 
                            __PYX_ERR(0, 5440, __pyx_L482_except_error)
                          }
                          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                          __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                          goto __pyx_L481_exception_handled;
                        }
                        __pyx_L482_except_error:;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __Pyx_XGIVEREF(__pyx_t_37);
                        __Pyx_XGIVEREF(__pyx_t_20);
                        __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_37, __pyx_t_20);
                        goto __pyx_L463_error;
                        __pyx_L481_exception_handled:;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __Pyx_XGIVEREF(__pyx_t_37);
                        __Pyx_XGIVEREF(__pyx_t_20);
                        __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_37, __pyx_t_20);
                        __pyx_L487_try_end:;
                      }
                    }
                    /*finally:*/ {
                      /*normal exit:*/{
                        if (__pyx_t_19) {
                          __pyx_t_20 = __Pyx_PyObject_Call(__pyx_t_19, __pyx_mstate_global->__pyx_tuple[7], NULL);
                          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                          if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 5440, __pyx_L463_error)
                          __Pyx_GOTREF(__pyx_t_20);
                          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        }
                        goto __pyx_L479;
                      }
                      __pyx_L479:;
                    }
                    goto __pyx_L517;
                    __pyx_L474_error:;
                    __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                    goto __pyx_L463_error;
                    __pyx_L517:;
                  }

                  /* "ws_package/controllers/activity_controller.py":5455
 *                                             last_interval_updated = True
 *                                             logger.info("Last interval (id=%s) found with tolerance and marked uploaded before screenshot delete", db_last.id)
 *                                 if last_interval_updated:             # <<<<<<<<<<<<<<
 *                                     await db_writer_service.process_immediately()
 *                                     await asyncio.sleep(0.3)
*/
                  if (__pyx_cur_scope->__pyx_v_last_interval_updated) {

                    /* "ws_package/controllers/activity_controller.py":5456
 *                                             logger.info("Last interval (id=%s) found with tolerance and marked uploaded before screenshot delete", db_last.id)
 *                                 if last_interval_updated:
 *                                     await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 *                                     await asyncio.sleep(0.3)
 *                         except Exception as e:
*/
                    __pyx_t_7 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5456, __pyx_L463_error)
                    __Pyx_GOTREF(__pyx_t_5);
                    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5456, __pyx_L463_error)
                    __Pyx_GOTREF(__pyx_t_4);
                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __pyx_t_8 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_4))) {
                      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
                      assert(__pyx_t_7);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                      __Pyx_INCREF(__pyx_t_7);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                      __pyx_t_8 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
                      __pyx_t_25 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5456, __pyx_L463_error)
                      __Pyx_GOTREF(__pyx_t_25);
                    }
                    __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_25, &__pyx_r);
                    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                    if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                      __Pyx_GOTREF(__pyx_r);
                      __Pyx_XGIVEREF(__pyx_t_1);
                      __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                      __Pyx_XGIVEREF(__pyx_t_2);
                      __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                      __Pyx_XGIVEREF(__pyx_t_3);
                      __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                      __Pyx_XGIVEREF(__pyx_t_12);
                      __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                      __Pyx_XGIVEREF(__pyx_t_13);
                      __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                      __Pyx_XGIVEREF(__pyx_t_14);
                      __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                      __Pyx_XGIVEREF(__pyx_t_23);
                      __pyx_cur_scope->__pyx_t_6 = __pyx_t_23;
                      __Pyx_XGIVEREF(__pyx_r);
                      __Pyx_RefNannyFinishContext();
                      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                      /* return from generator, awaiting value */
                      __pyx_generator->resume_label = 38;
                      return __pyx_r;
                      __pyx_L519_resume_from_await:;
                      __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                      __pyx_cur_scope->__pyx_t_0 = 0;
                      __Pyx_XGOTREF(__pyx_t_1);
                      __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                      __pyx_cur_scope->__pyx_t_1 = 0;
                      __Pyx_XGOTREF(__pyx_t_2);
                      __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                      __pyx_cur_scope->__pyx_t_2 = 0;
                      __Pyx_XGOTREF(__pyx_t_3);
                      __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                      __pyx_cur_scope->__pyx_t_3 = 0;
                      __Pyx_XGOTREF(__pyx_t_12);
                      __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                      __pyx_cur_scope->__pyx_t_4 = 0;
                      __Pyx_XGOTREF(__pyx_t_13);
                      __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                      __pyx_cur_scope->__pyx_t_5 = 0;
                      __Pyx_XGOTREF(__pyx_t_14);
                      __pyx_t_23 = __pyx_cur_scope->__pyx_t_6;
                      __pyx_cur_scope->__pyx_t_6 = 0;
                      __Pyx_XGOTREF(__pyx_t_23);
                      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5456, __pyx_L463_error)
                    } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                      __Pyx_GOTREF(__pyx_r);
                      __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                    } else {
                      __Pyx_XGOTREF(__pyx_r);
                      __PYX_ERR(0, 5456, __pyx_L463_error)
                    }

                    /* "ws_package/controllers/activity_controller.py":5457
 *                                 if last_interval_updated:
 *                                     await db_writer_service.process_immediately()
 *                                     await asyncio.sleep(0.3)             # <<<<<<<<<<<<<<
 *                         except Exception as e:
 *                             logger.warning("Could not pre-update last interval for screenshot delete: %s", e)
*/
                    __pyx_t_4 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5457, __pyx_L463_error)
                    __Pyx_GOTREF(__pyx_t_7);
                    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5457, __pyx_L463_error)
                    __Pyx_GOTREF(__pyx_t_5);
                    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                    __pyx_t_8 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_5))) {
                      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
                      assert(__pyx_t_4);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                      __Pyx_INCREF(__pyx_t_4);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                      __pyx_t_8 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_float_0_3};
                      __pyx_t_25 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5457, __pyx_L463_error)
                      __Pyx_GOTREF(__pyx_t_25);
                    }
                    __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_25, &__pyx_r);
                    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                    if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                      __Pyx_GOTREF(__pyx_r);
                      __Pyx_XGIVEREF(__pyx_t_1);
                      __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                      __Pyx_XGIVEREF(__pyx_t_2);
                      __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                      __Pyx_XGIVEREF(__pyx_t_3);
                      __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                      __Pyx_XGIVEREF(__pyx_t_12);
                      __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                      __Pyx_XGIVEREF(__pyx_t_13);
                      __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                      __Pyx_XGIVEREF(__pyx_t_14);
                      __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                      __Pyx_XGIVEREF(__pyx_t_23);
                      __pyx_cur_scope->__pyx_t_6 = __pyx_t_23;
                      __Pyx_XGIVEREF(__pyx_r);
                      __Pyx_RefNannyFinishContext();
                      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                      /* return from generator, awaiting value */
                      __pyx_generator->resume_label = 39;
                      return __pyx_r;
                      __pyx_L520_resume_from_await:;
                      __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                      __pyx_cur_scope->__pyx_t_0 = 0;
                      __Pyx_XGOTREF(__pyx_t_1);
                      __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                      __pyx_cur_scope->__pyx_t_1 = 0;
                      __Pyx_XGOTREF(__pyx_t_2);
                      __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                      __pyx_cur_scope->__pyx_t_2 = 0;
                      __Pyx_XGOTREF(__pyx_t_3);
                      __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                      __pyx_cur_scope->__pyx_t_3 = 0;
                      __Pyx_XGOTREF(__pyx_t_12);
                      __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                      __pyx_cur_scope->__pyx_t_4 = 0;
                      __Pyx_XGOTREF(__pyx_t_13);
                      __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                      __pyx_cur_scope->__pyx_t_5 = 0;
                      __Pyx_XGOTREF(__pyx_t_14);
                      __pyx_t_23 = __pyx_cur_scope->__pyx_t_6;
                      __pyx_cur_scope->__pyx_t_6 = 0;
                      __Pyx_XGOTREF(__pyx_t_23);
                      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5457, __pyx_L463_error)
                    } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                      __Pyx_GOTREF(__pyx_r);
                      __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                    } else {
                      __Pyx_XGOTREF(__pyx_r);
                      __PYX_ERR(0, 5457, __pyx_L463_error)
                    }

                    /* "ws_package/controllers/activity_controller.py":5455
 *                                             last_interval_updated = True
 *                                             logger.info("Last interval (id=%s) found with tolerance and marked uploaded before screenshot delete", db_last.id)
 *                                 if last_interval_updated:             # <<<<<<<<<<<<<<
 *                                     await db_writer_service.process_immediately()
 *                                     await asyncio.sleep(0.3)
*/
                  }

                  /* "ws_package/controllers/activity_controller.py":5438
 *                             st = getattr(last_interval, 'start_time', None)
 *                             et = getattr(last_interval, 'end_time', None)
 *                             if st is not None and et is not None:             # <<<<<<<<<<<<<<
 *                                 tol = datetime.timedelta(seconds=2)
 *                                 with db_lock_manager.read_lock():
*/
                }

                /* "ws_package/controllers/activity_controller.py":5435
 *                     # in case DB datetime precision differs from in-memory entity.
 *                     if last_interval and not last_interval_updated:
 *                         try:             # <<<<<<<<<<<<<<
 *                             st = getattr(last_interval, 'start_time', None)
 *                             et = getattr(last_interval, 'end_time', None)
*/
              }
              __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              goto __pyx_L470_try_end;
              __pyx_L463_error:;
              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
              __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
              __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
              __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
              __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
              __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

              /* "ws_package/controllers/activity_controller.py":5458
 *                                     await db_writer_service.process_immediately()
 *                                     await asyncio.sleep(0.3)
 *                         except Exception as e:             # <<<<<<<<<<<<<<
 *                             logger.warning("Could not pre-update last interval for screenshot delete: %s", e)
 * 
*/
              __pyx_t_31 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
              if (__pyx_t_31) {
                __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
                if (__Pyx_GetException(&__pyx_t_25, &__pyx_t_5, &__pyx_t_4) < 0) __PYX_ERR(0, 5458, __pyx_L465_except_error)
                __Pyx_XGOTREF(__pyx_t_25);
                __Pyx_XGOTREF(__pyx_t_5);
                __Pyx_XGOTREF(__pyx_t_4);
                __Pyx_INCREF(__pyx_t_5);
                __Pyx_GIVEREF(__pyx_t_5);
                __pyx_cur_scope->__pyx_v_e = __pyx_t_5;
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":5459
 *                                     await asyncio.sleep(0.3)
 *                         except Exception as e:
 *                             logger.warning("Could not pre-update last interval for screenshot delete: %s", e)             # <<<<<<<<<<<<<<
 * 
 *                     for interval_payload in response[0]:
*/
                  __pyx_t_39 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5459, __pyx_L526_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5459, __pyx_L526_error)
                  __Pyx_GOTREF(__pyx_t_10);
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __pyx_t_8 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_10))) {
                    __pyx_t_39 = PyMethod_GET_SELF(__pyx_t_10);
                    assert(__pyx_t_39);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
                    __Pyx_INCREF(__pyx_t_39);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
                    __pyx_t_8 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[3] = {__pyx_t_39, __pyx_mstate_global->__pyx_kp_u_Could_not_pre_update_last_interv, __pyx_cur_scope->__pyx_v_e};
                    __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                    if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5459, __pyx_L526_error)
                    __Pyx_GOTREF(__pyx_t_7);
                  }
                  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                }

                /* "ws_package/controllers/activity_controller.py":5458
 *                                     await db_writer_service.process_immediately()
 *                                     await asyncio.sleep(0.3)
 *                         except Exception as e:             # <<<<<<<<<<<<<<
 *                             logger.warning("Could not pre-update last interval for screenshot delete: %s", e)
 * 
*/
                /*finally:*/ {
                  /*normal exit:*/{
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    goto __pyx_L527;
                  }
                  __pyx_L526_error:;
                  /*exception exit:*/{
                    __Pyx_PyThreadState_assign
                    __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_37 = 0; __pyx_t_15 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0;
                    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                    __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                    __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                    __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                    __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                    __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                    __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                    __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                     __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_18, &__pyx_t_17);
                    if ( unlikely(__Pyx_GetException(&__pyx_t_19, &__pyx_t_20, &__pyx_t_37) < 0)) __Pyx_ErrFetch(&__pyx_t_19, &__pyx_t_20, &__pyx_t_37);
                    __Pyx_XGOTREF(__pyx_t_19);
                    __Pyx_XGOTREF(__pyx_t_20);
                    __Pyx_XGOTREF(__pyx_t_37);
                    __Pyx_XGOTREF(__pyx_t_15);
                    __Pyx_XGOTREF(__pyx_t_18);
                    __Pyx_XGOTREF(__pyx_t_17);
                    __pyx_t_31 = __pyx_lineno; __pyx_t_32 = __pyx_clineno; __pyx_t_56 = __pyx_filename;
                    {
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    }
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_18, __pyx_t_17);
                    __Pyx_XGIVEREF(__pyx_t_19);
                    __Pyx_XGIVEREF(__pyx_t_20);
                    __Pyx_XGIVEREF(__pyx_t_37);
                    __Pyx_ErrRestore(__pyx_t_19, __pyx_t_20, __pyx_t_37);
                    __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_37 = 0; __pyx_t_15 = 0; __pyx_t_18 = 0; __pyx_t_17 = 0;
                    __pyx_lineno = __pyx_t_31; __pyx_clineno = __pyx_t_32; __pyx_filename = __pyx_t_56;
                    goto __pyx_L465_except_error;
                  }
                  __pyx_L527:;
                }
                __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                goto __pyx_L464_exception_handled;
              }
              goto __pyx_L465_except_error;

              /* "ws_package/controllers/activity_controller.py":5435
 *                     # in case DB datetime precision differs from in-memory entity.
 *                     if last_interval and not last_interval_updated:
 *                         try:             # <<<<<<<<<<<<<<
 *                             st = getattr(last_interval, 'start_time', None)
 *                             et = getattr(last_interval, 'end_time', None)
*/
              __pyx_L465_except_error:;
              __Pyx_XGIVEREF(__pyx_t_14);
              __Pyx_XGIVEREF(__pyx_t_13);
              __Pyx_XGIVEREF(__pyx_t_12);
              __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12);
              goto __pyx_L4_error;
              __pyx_L464_exception_handled:;
              __Pyx_XGIVEREF(__pyx_t_14);
              __Pyx_XGIVEREF(__pyx_t_13);
              __Pyx_XGIVEREF(__pyx_t_12);
              __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12);
              __pyx_L470_try_end:;
            }

            /* "ws_package/controllers/activity_controller.py":5434
 *                     # screenshots can be deleted (validation requires is_uploaded=True). Use tolerance query
 *                     # in case DB datetime precision differs from in-memory entity.
 *                     if last_interval and not last_interval_updated:             # <<<<<<<<<<<<<<
 *                         try:
 *                             st = getattr(last_interval, 'start_time', None)
*/
          }

          /* "ws_package/controllers/activity_controller.py":5461
 *                             logger.warning("Could not pre-update last interval for screenshot delete: %s", e)
 * 
 *                     for interval_payload in response[0]:             # <<<<<<<<<<<<<<
 *                         for interval in interval_payload.get('intervals', []):  # Ensure 'intervals' exists
 *                             screen_url = interval.get("screenUrl")  # Access the screenUrl from each interval payload
*/
          __pyx_t_4 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_response, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_SharedReference); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5461, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
            __pyx_t_5 = __pyx_t_4; __Pyx_INCREF(__pyx_t_5);
            __pyx_t_45 = 0;
            __pyx_t_35 = NULL;
          } else {
            __pyx_t_45 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5461, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_35 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); if (unlikely(!__pyx_t_35)) __PYX_ERR(0, 5461, __pyx_L4_error)
          }
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          for (;;) {
            if (likely(!__pyx_t_35)) {
              if (likely(PyList_CheckExact(__pyx_t_5))) {
                {
                  Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_5);
                  #if !CYTHON_ASSUME_SAFE_SIZE
                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5461, __pyx_L4_error)
                  #endif
                  if (__pyx_t_45 >= __pyx_temp) break;
                }
                __pyx_t_4 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_5, __pyx_t_45, __Pyx_ReferenceSharing_OwnStrongReference);
                ++__pyx_t_45;
              } else {
                {
                  Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_5);
                  #if !CYTHON_ASSUME_SAFE_SIZE
                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5461, __pyx_L4_error)
                  #endif
                  if (__pyx_t_45 >= __pyx_temp) break;
                }
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_4 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_45));
                #else
                __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_45);
                #endif
                ++__pyx_t_45;
              }
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5461, __pyx_L4_error)
            } else {
              __pyx_t_4 = __pyx_t_35(__pyx_t_5);
              if (unlikely(!__pyx_t_4)) {
                PyObject* exc_type = PyErr_Occurred();
                if (exc_type) {
                  if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 5461, __pyx_L4_error)
                  PyErr_Clear();
                }
                break;
              }
            }
            __Pyx_GOTREF(__pyx_t_4);
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval_payload);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval_payload, __pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_4);
            __pyx_t_4 = 0;

            /* "ws_package/controllers/activity_controller.py":5462
 * 
 *                     for interval_payload in response[0]:
 *                         for interval in interval_payload.get('intervals', []):  # Ensure 'intervals' exists             # <<<<<<<<<<<<<<
 *                             screen_url = interval.get("screenUrl")  # Access the screenUrl from each interval payload
 *                             await self.screenshot_controller.update_screenshots(screen_url, self.last_count+1)
*/
            __pyx_t_25 = __pyx_cur_scope->__pyx_v_interval_payload;
            __Pyx_INCREF(__pyx_t_25);
            __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5462, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_7);
            __pyx_t_8 = 0;
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_25, __pyx_mstate_global->__pyx_n_u_intervals, __pyx_t_7};
              __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5462, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_4);
            }
            if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
              __pyx_t_7 = __pyx_t_4; __Pyx_INCREF(__pyx_t_7);
              __pyx_t_57 = 0;
              __pyx_t_46 = NULL;
            } else {
              __pyx_t_57 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5462, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_7);
              __pyx_t_46 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_7); if (unlikely(!__pyx_t_46)) __PYX_ERR(0, 5462, __pyx_L4_error)
            }
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            for (;;) {
              if (likely(!__pyx_t_46)) {
                if (likely(PyList_CheckExact(__pyx_t_7))) {
                  {
                    Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_7);
                    #if !CYTHON_ASSUME_SAFE_SIZE
                    if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5462, __pyx_L4_error)
                    #endif
                    if (__pyx_t_57 >= __pyx_temp) break;
                  }
                  __pyx_t_4 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_7, __pyx_t_57, __Pyx_ReferenceSharing_OwnStrongReference);
                  ++__pyx_t_57;
                } else {
                  {
                    Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_7);
                    #if !CYTHON_ASSUME_SAFE_SIZE
                    if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5462, __pyx_L4_error)
                    #endif
                    if (__pyx_t_57 >= __pyx_temp) break;
                  }
                  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                  __pyx_t_4 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_57));
                  #else
                  __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_7, __pyx_t_57);
                  #endif
                  ++__pyx_t_57;
                }
                if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5462, __pyx_L4_error)
              } else {
                __pyx_t_4 = __pyx_t_46(__pyx_t_7);
                if (unlikely(!__pyx_t_4)) {
                  PyObject* exc_type = PyErr_Occurred();
                  if (exc_type) {
                    if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 5462, __pyx_L4_error)
                    PyErr_Clear();
                  }
                  break;
                }
              }
              __Pyx_GOTREF(__pyx_t_4);
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_4);
              __Pyx_GIVEREF(__pyx_t_4);
              __pyx_t_4 = 0;

              /* "ws_package/controllers/activity_controller.py":5463
 *                     for interval_payload in response[0]:
 *                         for interval in interval_payload.get('intervals', []):  # Ensure 'intervals' exists
 *                             screen_url = interval.get("screenUrl")  # Access the screenUrl from each interval payload             # <<<<<<<<<<<<<<
 *                             await self.screenshot_controller.update_screenshots(screen_url, self.last_count+1)
 * 
*/
              __pyx_t_25 = __pyx_cur_scope->__pyx_v_interval;
              __Pyx_INCREF(__pyx_t_25);
              __pyx_t_8 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_25, __pyx_mstate_global->__pyx_n_u_screenUrl};
                __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5463, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_4);
              }
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_screen_url);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_screen_url, __pyx_t_4);
              __Pyx_GIVEREF(__pyx_t_4);
              __pyx_t_4 = 0;

              /* "ws_package/controllers/activity_controller.py":5464
 *                         for interval in interval_payload.get('intervals', []):  # Ensure 'intervals' exists
 *                             screen_url = interval.get("screenUrl")  # Access the screenUrl from each interval payload
 *                             await self.screenshot_controller.update_screenshots(screen_url, self.last_count+1)             # <<<<<<<<<<<<<<
 * 
 *             # After all batches are processed, explicitly update last_interval if it wasn't updated yet
*/
              __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5464, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_10);
              __pyx_t_25 = __pyx_t_10;
              __Pyx_INCREF(__pyx_t_25);
              __pyx_t_39 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5464, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_39);
              __pyx_t_6 = __Pyx_PyLong_AddObjC(__pyx_t_39, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5464, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_6);
              __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
              __pyx_t_8 = 0;
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_25, __pyx_cur_scope->__pyx_v_screen_url, __pyx_t_6};
                __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_update_screenshots, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5464, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_4);
              }
              __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_XGIVEREF(__pyx_t_1);
                __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                __Pyx_XGIVEREF(__pyx_t_2);
                __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                __Pyx_XGIVEREF(__pyx_t_3);
                __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                __Pyx_XGIVEREF(__pyx_t_5);
                __pyx_cur_scope->__pyx_t_3 = __pyx_t_5;
                __Pyx_XGIVEREF(__pyx_t_7);
                __pyx_cur_scope->__pyx_t_4 = __pyx_t_7;
                __Pyx_XGIVEREF(__pyx_t_23);
                __pyx_cur_scope->__pyx_t_5 = __pyx_t_23;
                __pyx_cur_scope->__pyx_t_18 = __pyx_t_35;
                __pyx_cur_scope->__pyx_t_23 = __pyx_t_45;
                __pyx_cur_scope->__pyx_t_24 = __pyx_t_46;
                __pyx_cur_scope->__pyx_t_25 = __pyx_t_57;
                __Pyx_XGIVEREF(__pyx_r);
                __Pyx_RefNannyFinishContext();
                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                /* return from generator, awaiting value */
                __pyx_generator->resume_label = 40;
                return __pyx_r;
                __pyx_L536_resume_from_await:;
                __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                __pyx_cur_scope->__pyx_t_0 = 0;
                __Pyx_XGOTREF(__pyx_t_1);
                __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                __pyx_cur_scope->__pyx_t_1 = 0;
                __Pyx_XGOTREF(__pyx_t_2);
                __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                __pyx_cur_scope->__pyx_t_2 = 0;
                __Pyx_XGOTREF(__pyx_t_3);
                __pyx_t_5 = __pyx_cur_scope->__pyx_t_3;
                __pyx_cur_scope->__pyx_t_3 = 0;
                __Pyx_XGOTREF(__pyx_t_5);
                __pyx_t_7 = __pyx_cur_scope->__pyx_t_4;
                __pyx_cur_scope->__pyx_t_4 = 0;
                __Pyx_XGOTREF(__pyx_t_7);
                __pyx_t_23 = __pyx_cur_scope->__pyx_t_5;
                __pyx_cur_scope->__pyx_t_5 = 0;
                __Pyx_XGOTREF(__pyx_t_23);
                __pyx_t_35 = __pyx_cur_scope->__pyx_t_18;
                __pyx_t_45 = __pyx_cur_scope->__pyx_t_23;
                __pyx_t_46 = __pyx_cur_scope->__pyx_t_24;
                __pyx_t_57 = __pyx_cur_scope->__pyx_t_25;
                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5464, __pyx_L4_error)
              } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_DECREF(__pyx_r); __pyx_r = 0;
              } else {
                __Pyx_XGOTREF(__pyx_r);
                __PYX_ERR(0, 5464, __pyx_L4_error)
              }

              /* "ws_package/controllers/activity_controller.py":5462
 * 
 *                     for interval_payload in response[0]:
 *                         for interval in interval_payload.get('intervals', []):  # Ensure 'intervals' exists             # <<<<<<<<<<<<<<
 *                             screen_url = interval.get("screenUrl")  # Access the screenUrl from each interval payload
 *                             await self.screenshot_controller.update_screenshots(screen_url, self.last_count+1)
*/
            }
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

            /* "ws_package/controllers/activity_controller.py":5461
 *                             logger.warning("Could not pre-update last interval for screenshot delete: %s", e)
 * 
 *                     for interval_payload in response[0]:             # <<<<<<<<<<<<<<
 *                         for interval in interval_payload.get('intervals', []):  # Ensure 'intervals' exists
 *                             screen_url = interval.get("screenUrl")  # Access the screenUrl from each interval payload
*/
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":5363
 *                     self.status = False
 * 
 *                 elif _response and _response.get("planStatus") == "active":             # <<<<<<<<<<<<<<
 *                     at_least_one_batch_successful = True
 * 
*/
        }
        __pyx_L337:;

        /* "ws_package/controllers/activity_controller.py":5342
 *             updated_interval_ids = set()
 * 
 *             async for response in sending_intervals:             # <<<<<<<<<<<<<<
 *                 if not response or not isinstance(response, (list, tuple)):
 *                     logger.info("No interval found %s", response)
*/
        __pyx_L329_continue:;
      }
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

      /* "ws_package/controllers/activity_controller.py":5468
 *             # After all batches are processed, explicitly update last_interval if it wasn't updated yet
 *             # This ensures the last saved interval gets is_uploaded=True even if it wasn't in any response[1]
 *             if last_interval and at_least_one_batch_successful and not last_interval_updated:             # <<<<<<<<<<<<<<
 *                 logger.info("Last interval was not updated in any batch - explicitly updating it now")
 *                 # Verify last_interval was actually sent by checking if it's in the original intervals list
*/
      __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5468, __pyx_L4_error)
      if (__pyx_t_47) {
      } else {
        __pyx_t_28 = __pyx_t_47;
        goto __pyx_L541_bool_binop_done;
      }
      if (__pyx_cur_scope->__pyx_v_at_least_one_batch_successful) {
      } else {
        __pyx_t_28 = __pyx_cur_scope->__pyx_v_at_least_one_batch_successful;
        goto __pyx_L541_bool_binop_done;
      }
      __pyx_t_47 = (!__pyx_cur_scope->__pyx_v_last_interval_updated);
      __pyx_t_28 = __pyx_t_47;
      __pyx_L541_bool_binop_done:;
      if (__pyx_t_28) {

        /* "ws_package/controllers/activity_controller.py":5469
 *             # This ensures the last saved interval gets is_uploaded=True even if it wasn't in any response[1]
 *             if last_interval and at_least_one_batch_successful and not last_interval_updated:
 *                 logger.info("Last interval was not updated in any batch - explicitly updating it now")             # <<<<<<<<<<<<<<
 *                 # Verify last_interval was actually sent by checking if it's in the original intervals list
 *                 last_interval_was_sent = any(
*/
        __pyx_t_5 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5469, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5469, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
          assert(__pyx_t_5);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Last_interval_was_not_updated_in};
          __pyx_t_23 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5469, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_23);
        }
        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

        /* "ws_package/controllers/activity_controller.py":5479
 *                      interval.counter == last_interval.counter)
 *                     for interval in intervals
 *                 ) if intervals else False             # <<<<<<<<<<<<<<
 * 
 *                 if last_interval_was_sent:
*/
        __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_intervals); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5479, __pyx_L4_error)
        if (__pyx_t_28) {

          /* "ws_package/controllers/activity_controller.py":5472
 *                 # Verify last_interval was actually sent by checking if it's in the original intervals list
 *                 last_interval_was_sent = any(
 *                     (hasattr(interval, 'start_time') and hasattr(last_interval, 'start_time') and             # <<<<<<<<<<<<<<
 *                      hasattr(interval, 'end_time') and hasattr(last_interval, 'end_time') and
 *                      hasattr(interval, 'counter') and hasattr(last_interval, 'counter') and
*/
          __pyx_t_4 = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_19_last_api_call_impl_13genexpr(((PyObject*)__pyx_cur_scope), __pyx_cur_scope->__pyx_v_intervals); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5472, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_5 = __Pyx_Generator_GetInlinedResult(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5472, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_23 = __pyx_t_5;
          __pyx_t_5 = 0;
        } else {

          /* "ws_package/controllers/activity_controller.py":5479
 *                      interval.counter == last_interval.counter)
 *                     for interval in intervals
 *                 ) if intervals else False             # <<<<<<<<<<<<<<
 * 
 *                 if last_interval_was_sent:
*/
          __Pyx_INCREF(Py_False);
          __pyx_t_23 = Py_False;
        }
        __Pyx_GIVEREF(__pyx_t_23);
        __pyx_cur_scope->__pyx_v_last_interval_was_sent = __pyx_t_23;
        __pyx_t_23 = 0;

        /* "ws_package/controllers/activity_controller.py":5481
 *                 ) if intervals else False
 * 
 *                 if last_interval_was_sent:             # <<<<<<<<<<<<<<
 *                     # Query database to get the actual record with ID (use tolerance for datetime precision)
 *                     try:
*/
        __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval_was_sent); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5481, __pyx_L4_error)
        if (__pyx_t_28) {

          /* "ws_package/controllers/activity_controller.py":5483
 *                 if last_interval_was_sent:
 *                     # Query database to get the actual record with ID (use tolerance for datetime precision)
 *                     try:             # <<<<<<<<<<<<<<
 *                         st = getattr(last_interval, 'start_time', None)
 *                         et = getattr(last_interval, 'end_time', None)
*/
          {
            __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
            __Pyx_XGOTREF(__pyx_t_12);
            __Pyx_XGOTREF(__pyx_t_13);
            __Pyx_XGOTREF(__pyx_t_14);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":5484
 *                     # Query database to get the actual record with ID (use tolerance for datetime precision)
 *                     try:
 *                         st = getattr(last_interval, 'start_time', None)             # <<<<<<<<<<<<<<
 *                         et = getattr(last_interval, 'end_time', None)
 *                         if st is None or et is None:
*/
              __pyx_t_23 = __pyx_cur_scope->__pyx_v_last_interval;
              __Pyx_INCREF(__pyx_t_23);
              __pyx_t_5 = __Pyx_GetAttr3(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_start_time, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5484, __pyx_L545_error)
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_st);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_st, __pyx_t_5);
              __Pyx_GIVEREF(__pyx_t_5);
              __pyx_t_5 = 0;

              /* "ws_package/controllers/activity_controller.py":5485
 *                     try:
 *                         st = getattr(last_interval, 'start_time', None)
 *                         et = getattr(last_interval, 'end_time', None)             # <<<<<<<<<<<<<<
 *                         if st is None or et is None:
 *                             db_interval = None
*/
              __pyx_t_5 = __pyx_cur_scope->__pyx_v_last_interval;
              __Pyx_INCREF(__pyx_t_5);
              __pyx_t_23 = __Pyx_GetAttr3(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_end_time, Py_None); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5485, __pyx_L545_error)
              __Pyx_GOTREF(__pyx_t_23);
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_et);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_et, __pyx_t_23);
              __Pyx_GIVEREF(__pyx_t_23);
              __pyx_t_23 = 0;

              /* "ws_package/controllers/activity_controller.py":5486
 *                         st = getattr(last_interval, 'start_time', None)
 *                         et = getattr(last_interval, 'end_time', None)
 *                         if st is None or et is None:             # <<<<<<<<<<<<<<
 *                             db_interval = None
 *                         else:
*/
              __pyx_t_47 = (__pyx_cur_scope->__pyx_v_st == Py_None);
              if (!__pyx_t_47) {
              } else {
                __pyx_t_28 = __pyx_t_47;
                goto __pyx_L552_bool_binop_done;
              }
              __pyx_t_47 = (__pyx_cur_scope->__pyx_v_et == Py_None);
              __pyx_t_28 = __pyx_t_47;
              __pyx_L552_bool_binop_done:;
              if (__pyx_t_28) {

                /* "ws_package/controllers/activity_controller.py":5487
 *                         et = getattr(last_interval, 'end_time', None)
 *                         if st is None or et is None:
 *                             db_interval = None             # <<<<<<<<<<<<<<
 *                         else:
 *                             tol = datetime.timedelta(seconds=2)
*/
                __Pyx_INCREF(Py_None);
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_db_interval);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_db_interval, Py_None);
                __Pyx_GIVEREF(Py_None);

                /* "ws_package/controllers/activity_controller.py":5486
 *                         st = getattr(last_interval, 'start_time', None)
 *                         et = getattr(last_interval, 'end_time', None)
 *                         if st is None or et is None:             # <<<<<<<<<<<<<<
 *                             db_interval = None
 *                         else:
*/
                goto __pyx_L551;
              }

              /* "ws_package/controllers/activity_controller.py":5489
 *                             db_interval = None
 *                         else:
 *                             tol = datetime.timedelta(seconds=2)             # <<<<<<<<<<<<<<
 *                             with db_lock_manager.read_lock():
 *                                 async with async_session() as session:
*/
              /*else*/ {
                __pyx_t_5 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5489, __pyx_L545_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_timedelta); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5489, __pyx_L545_error)
                __Pyx_GOTREF(__pyx_t_7);
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_7))) {
                  __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
                  assert(__pyx_t_5);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                  __Pyx_INCREF(__pyx_t_5);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_5, NULL};
                  __pyx_t_4 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5489, __pyx_L545_error)
                  __Pyx_GOTREF(__pyx_t_4);
                  if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_seconds, __pyx_mstate_global->__pyx_int_2, __pyx_t_4, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 5489, __pyx_L545_error)
                  __pyx_t_23 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_4);
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                  if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5489, __pyx_L545_error)
                  __Pyx_GOTREF(__pyx_t_23);
                }
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_tol);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_tol, __pyx_t_23);
                __Pyx_GIVEREF(__pyx_t_23);
                __pyx_t_23 = 0;

                /* "ws_package/controllers/activity_controller.py":5490
 *                         else:
 *                             tol = datetime.timedelta(seconds=2)
 *                             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                                 async with async_session() as session:
 *                                     query = select(ActivityInterval).where(
*/
                /*with:*/ {
                  __pyx_t_7 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5490, __pyx_L545_error)
                  __Pyx_GOTREF(__pyx_t_4);
                  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5490, __pyx_L545_error)
                  __Pyx_GOTREF(__pyx_t_5);
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __pyx_t_8 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_5))) {
                    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
                    assert(__pyx_t_7);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                    __Pyx_INCREF(__pyx_t_7);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                    __pyx_t_8 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
                    __pyx_t_23 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                    if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5490, __pyx_L545_error)
                    __Pyx_GOTREF(__pyx_t_23);
                  }
                  __pyx_t_17 = __Pyx_PyObject_LookupSpecial(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 5490, __pyx_L545_error)
                  __Pyx_GOTREF(__pyx_t_17);
                  __pyx_t_7 = NULL;
                  __pyx_t_4 = __Pyx_PyObject_LookupSpecial(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5490, __pyx_L554_error)
                  __Pyx_GOTREF(__pyx_t_4);
                  __pyx_t_8 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (likely(PyMethod_Check(__pyx_t_4))) {
                    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
                    assert(__pyx_t_7);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                    __Pyx_INCREF(__pyx_t_7);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                    __pyx_t_8 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
                    __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5490, __pyx_L554_error)
                    __Pyx_GOTREF(__pyx_t_5);
                  }
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                  /*try:*/ {
                    {
                      __Pyx_ExceptionSave(&__pyx_t_18, &__pyx_t_15, &__pyx_t_37);
                      __Pyx_XGOTREF(__pyx_t_18);
                      __Pyx_XGOTREF(__pyx_t_15);
                      __Pyx_XGOTREF(__pyx_t_37);
                      /*try:*/ {

                        /* "ws_package/controllers/activity_controller.py":5491
 *                             tol = datetime.timedelta(seconds=2)
 *                             with db_lock_manager.read_lock():
 *                                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                                     query = select(ActivityInterval).where(
 *                                         ActivityInterval.counter == getattr(last_interval, 'counter', current_session_counter),
*/
                        /*with:*/ {
                          __pyx_t_5 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5491, __pyx_L558_error)
                          __Pyx_GOTREF(__pyx_t_4);
                          __pyx_t_8 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_4))) {
                            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
                            assert(__pyx_t_5);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                            __Pyx_INCREF(__pyx_t_5);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                            __pyx_t_8 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                            __pyx_t_23 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                            if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5491, __pyx_L558_error)
                            __Pyx_GOTREF(__pyx_t_23);
                          }
                          __pyx_t_20 = __Pyx_PyObject_LookupSpecial(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 5491, __pyx_L558_error)
                          __Pyx_GOTREF(__pyx_t_20);
                          __pyx_t_5 = NULL;
                          __pyx_t_7 = __Pyx_PyObject_LookupSpecial(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5491, __pyx_L564_error)
                          __Pyx_GOTREF(__pyx_t_7);
                          __pyx_t_8 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (likely(PyMethod_Check(__pyx_t_7))) {
                            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
                            assert(__pyx_t_5);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                            __Pyx_INCREF(__pyx_t_5);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                            __pyx_t_8 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                            __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                            if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5491, __pyx_L564_error)
                            __Pyx_GOTREF(__pyx_t_4);
                          }
                          __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
                          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                          if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_XGIVEREF(__pyx_t_1);
                            __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                            __Pyx_XGIVEREF(__pyx_t_2);
                            __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                            __Pyx_XGIVEREF(__pyx_t_3);
                            __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                            __Pyx_XGIVEREF(__pyx_t_12);
                            __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                            __Pyx_XGIVEREF(__pyx_t_13);
                            __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                            __Pyx_XGIVEREF(__pyx_t_14);
                            __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                            __Pyx_XGIVEREF(__pyx_t_15);
                            __pyx_cur_scope->__pyx_t_6 = __pyx_t_15;
                            __Pyx_XGIVEREF(__pyx_t_17);
                            __pyx_cur_scope->__pyx_t_7 = __pyx_t_17;
                            __Pyx_XGIVEREF(__pyx_t_18);
                            __pyx_cur_scope->__pyx_t_8 = __pyx_t_18;
                            __Pyx_XGIVEREF(__pyx_t_20);
                            __pyx_cur_scope->__pyx_t_9 = __pyx_t_20;
                            __Pyx_XGIVEREF(__pyx_t_23);
                            __pyx_cur_scope->__pyx_t_10 = __pyx_t_23;
                            __Pyx_XGIVEREF(__pyx_t_37);
                            __pyx_cur_scope->__pyx_t_11 = __pyx_t_37;
                            __Pyx_XGIVEREF(__pyx_r);
                            __Pyx_RefNannyFinishContext();
                            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                            /* return from generator, awaiting value */
                            __pyx_generator->resume_label = 41;
                            return __pyx_r;
                            __pyx_L565_resume_from_await:;
                            __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                            __pyx_cur_scope->__pyx_t_0 = 0;
                            __Pyx_XGOTREF(__pyx_t_1);
                            __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                            __pyx_cur_scope->__pyx_t_1 = 0;
                            __Pyx_XGOTREF(__pyx_t_2);
                            __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                            __pyx_cur_scope->__pyx_t_2 = 0;
                            __Pyx_XGOTREF(__pyx_t_3);
                            __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                            __pyx_cur_scope->__pyx_t_3 = 0;
                            __Pyx_XGOTREF(__pyx_t_12);
                            __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                            __pyx_cur_scope->__pyx_t_4 = 0;
                            __Pyx_XGOTREF(__pyx_t_13);
                            __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                            __pyx_cur_scope->__pyx_t_5 = 0;
                            __Pyx_XGOTREF(__pyx_t_14);
                            __pyx_t_15 = __pyx_cur_scope->__pyx_t_6;
                            __pyx_cur_scope->__pyx_t_6 = 0;
                            __Pyx_XGOTREF(__pyx_t_15);
                            __pyx_t_17 = __pyx_cur_scope->__pyx_t_7;
                            __pyx_cur_scope->__pyx_t_7 = 0;
                            __Pyx_XGOTREF(__pyx_t_17);
                            __pyx_t_18 = __pyx_cur_scope->__pyx_t_8;
                            __pyx_cur_scope->__pyx_t_8 = 0;
                            __Pyx_XGOTREF(__pyx_t_18);
                            __pyx_t_20 = __pyx_cur_scope->__pyx_t_9;
                            __pyx_cur_scope->__pyx_t_9 = 0;
                            __Pyx_XGOTREF(__pyx_t_20);
                            __pyx_t_23 = __pyx_cur_scope->__pyx_t_10;
                            __pyx_cur_scope->__pyx_t_10 = 0;
                            __Pyx_XGOTREF(__pyx_t_23);
                            __pyx_t_37 = __pyx_cur_scope->__pyx_t_11;
                            __pyx_cur_scope->__pyx_t_11 = 0;
                            __Pyx_XGOTREF(__pyx_t_37);
                            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5491, __pyx_L564_error)
                            __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                          } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                            __Pyx_GOTREF(__pyx_r);
                            __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                          } else {
                            __Pyx_XGOTREF(__pyx_r);
                            __PYX_ERR(0, 5491, __pyx_L564_error)
                          }
                          __pyx_t_7 = __pyx_t_4;
                          __pyx_t_4 = 0;
                          __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                          /*try:*/ {
                            {
                              __Pyx_ExceptionSave(&__pyx_t_19, &__pyx_t_22, &__pyx_t_21);
                              __Pyx_XGOTREF(__pyx_t_19);
                              __Pyx_XGOTREF(__pyx_t_22);
                              __Pyx_XGOTREF(__pyx_t_21);
                              /*try:*/ {
                                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_session);
                                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_session, __pyx_t_7);
                                __Pyx_GIVEREF(__pyx_t_7);
                                __pyx_t_7 = 0;

                                /* "ws_package/controllers/activity_controller.py":5492
 *                             with db_lock_manager.read_lock():
 *                                 async with async_session() as session:
 *                                     query = select(ActivityInterval).where(             # <<<<<<<<<<<<<<
 *                                         ActivityInterval.counter == getattr(last_interval, 'counter', current_session_counter),
 *                                         ActivityInterval.start_time >= st - tol,
*/
                                __pyx_t_39 = NULL;
                                __Pyx_GetModuleGlobalName(__pyx_t_55, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_55)) __PYX_ERR(0, 5492, __pyx_L569_error)
                                __Pyx_GOTREF(__pyx_t_55);
                                __Pyx_GetModuleGlobalName(__pyx_t_27, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 5492, __pyx_L569_error)
                                __Pyx_GOTREF(__pyx_t_27);
                                __pyx_t_8 = 1;
                                #if CYTHON_UNPACK_METHODS
                                if (unlikely(PyMethod_Check(__pyx_t_55))) {
                                  __pyx_t_39 = PyMethod_GET_SELF(__pyx_t_55);
                                  assert(__pyx_t_39);
                                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_55);
                                  __Pyx_INCREF(__pyx_t_39);
                                  __Pyx_INCREF(__pyx__function);
                                  __Pyx_DECREF_SET(__pyx_t_55, __pyx__function);
                                  __pyx_t_8 = 0;
                                }
                                #endif
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_39, __pyx_t_27};
                                  __pyx_t_25 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_55, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                                  __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                                  __Pyx_DECREF(__pyx_t_55); __pyx_t_55 = 0;
                                  if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5492, __pyx_L569_error)
                                  __Pyx_GOTREF(__pyx_t_25);
                                }
                                __pyx_t_6 = __pyx_t_25;
                                __Pyx_INCREF(__pyx_t_6);

                                /* "ws_package/controllers/activity_controller.py":5493
 *                                 async with async_session() as session:
 *                                     query = select(ActivityInterval).where(
 *                                         ActivityInterval.counter == getattr(last_interval, 'counter', current_session_counter),             # <<<<<<<<<<<<<<
 *                                         ActivityInterval.start_time >= st - tol,
 *                                         ActivityInterval.start_time <= st + tol,
*/
                                __Pyx_GetModuleGlobalName(__pyx_t_55, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_55)) __PYX_ERR(0, 5493, __pyx_L569_error)
                                __Pyx_GOTREF(__pyx_t_55);
                                __pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_t_55, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 5493, __pyx_L569_error)
                                __Pyx_GOTREF(__pyx_t_27);
                                __Pyx_DECREF(__pyx_t_55); __pyx_t_55 = 0;
                                __pyx_t_55 = __pyx_cur_scope->__pyx_v_last_interval;
                                __Pyx_INCREF(__pyx_t_55);
                                __pyx_t_39 = __Pyx_GetAttr3(__pyx_t_55, __pyx_mstate_global->__pyx_n_u_counter, __pyx_cur_scope->__pyx_v_current_session_counter); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5493, __pyx_L569_error)
                                __Pyx_GOTREF(__pyx_t_39);
                                __Pyx_DECREF(__pyx_t_55); __pyx_t_55 = 0;
                                __pyx_t_55 = PyObject_RichCompare(__pyx_t_27, __pyx_t_39, Py_EQ); __Pyx_XGOTREF(__pyx_t_55); if (unlikely(!__pyx_t_55)) __PYX_ERR(0, 5493, __pyx_L569_error)
                                __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                                __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;

                                /* "ws_package/controllers/activity_controller.py":5494
 *                                     query = select(ActivityInterval).where(
 *                                         ActivityInterval.counter == getattr(last_interval, 'counter', current_session_counter),
 *                                         ActivityInterval.start_time >= st - tol,             # <<<<<<<<<<<<<<
 *                                         ActivityInterval.start_time <= st + tol,
 *                                         ActivityInterval.end_time >= et - tol,
*/
                                __Pyx_GetModuleGlobalName(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5494, __pyx_L569_error)
                                __Pyx_GOTREF(__pyx_t_39);
                                __pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 5494, __pyx_L569_error)
                                __Pyx_GOTREF(__pyx_t_27);
                                __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                                __pyx_t_39 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_st, __pyx_cur_scope->__pyx_v_tol); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5494, __pyx_L569_error)
                                __Pyx_GOTREF(__pyx_t_39);
                                __pyx_t_40 = PyObject_RichCompare(__pyx_t_27, __pyx_t_39, Py_GE); __Pyx_XGOTREF(__pyx_t_40); if (unlikely(!__pyx_t_40)) __PYX_ERR(0, 5494, __pyx_L569_error)
                                __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                                __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;

                                /* "ws_package/controllers/activity_controller.py":5495
 *                                         ActivityInterval.counter == getattr(last_interval, 'counter', current_session_counter),
 *                                         ActivityInterval.start_time >= st - tol,
 *                                         ActivityInterval.start_time <= st + tol,             # <<<<<<<<<<<<<<
 *                                         ActivityInterval.end_time >= et - tol,
 *                                         ActivityInterval.end_time <= et + tol,
*/
                                __Pyx_GetModuleGlobalName(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5495, __pyx_L569_error)
                                __Pyx_GOTREF(__pyx_t_39);
                                __pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 5495, __pyx_L569_error)
                                __Pyx_GOTREF(__pyx_t_27);
                                __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                                __pyx_t_39 = PyNumber_Add(__pyx_cur_scope->__pyx_v_st, __pyx_cur_scope->__pyx_v_tol); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5495, __pyx_L569_error)
                                __Pyx_GOTREF(__pyx_t_39);
                                __pyx_t_52 = PyObject_RichCompare(__pyx_t_27, __pyx_t_39, Py_LE); __Pyx_XGOTREF(__pyx_t_52); if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5495, __pyx_L569_error)
                                __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                                __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;

                                /* "ws_package/controllers/activity_controller.py":5496
 *                                         ActivityInterval.start_time >= st - tol,
 *                                         ActivityInterval.start_time <= st + tol,
 *                                         ActivityInterval.end_time >= et - tol,             # <<<<<<<<<<<<<<
 *                                         ActivityInterval.end_time <= et + tol,
 *                                     ).order_by(ActivityInterval.id.desc()).limit(1)
*/
                                __Pyx_GetModuleGlobalName(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5496, __pyx_L569_error)
                                __Pyx_GOTREF(__pyx_t_39);
                                __pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 5496, __pyx_L569_error)
                                __Pyx_GOTREF(__pyx_t_27);
                                __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                                __pyx_t_39 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_et, __pyx_cur_scope->__pyx_v_tol); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5496, __pyx_L569_error)
                                __Pyx_GOTREF(__pyx_t_39);
                                __pyx_t_26 = PyObject_RichCompare(__pyx_t_27, __pyx_t_39, Py_GE); __Pyx_XGOTREF(__pyx_t_26); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5496, __pyx_L569_error)
                                __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                                __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;

                                /* "ws_package/controllers/activity_controller.py":5497
 *                                         ActivityInterval.start_time <= st + tol,
 *                                         ActivityInterval.end_time >= et - tol,
 *                                         ActivityInterval.end_time <= et + tol,             # <<<<<<<<<<<<<<
 *                                     ).order_by(ActivityInterval.id.desc()).limit(1)
 *                                     result = await session.execute(query)
*/
                                __Pyx_GetModuleGlobalName(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5497, __pyx_L569_error)
                                __Pyx_GOTREF(__pyx_t_39);
                                __pyx_t_27 = __Pyx_PyObject_GetAttrStr(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 5497, __pyx_L569_error)
                                __Pyx_GOTREF(__pyx_t_27);
                                __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                                __pyx_t_39 = PyNumber_Add(__pyx_cur_scope->__pyx_v_et, __pyx_cur_scope->__pyx_v_tol); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5497, __pyx_L569_error)
                                __Pyx_GOTREF(__pyx_t_39);
                                __pyx_t_24 = PyObject_RichCompare(__pyx_t_27, __pyx_t_39, Py_LE); __Pyx_XGOTREF(__pyx_t_24); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5497, __pyx_L569_error)
                                __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                                __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                                __pyx_t_8 = 0;
                                {
                                  PyObject *__pyx_callargs[6] = {__pyx_t_6, __pyx_t_55, __pyx_t_40, __pyx_t_52, __pyx_t_26, __pyx_t_24};
                                  __pyx_t_10 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_8, (6-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                                  __Pyx_DECREF(__pyx_t_55); __pyx_t_55 = 0;
                                  __Pyx_DECREF(__pyx_t_40); __pyx_t_40 = 0;
                                  __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
                                  __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                                  __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                                  __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                                  if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5492, __pyx_L569_error)
                                  __Pyx_GOTREF(__pyx_t_10);
                                }
                                __pyx_t_5 = __pyx_t_10;
                                __Pyx_INCREF(__pyx_t_5);

                                /* "ws_package/controllers/activity_controller.py":5498
 *                                         ActivityInterval.end_time >= et - tol,
 *                                         ActivityInterval.end_time <= et + tol,
 *                                     ).order_by(ActivityInterval.id.desc()).limit(1)             # <<<<<<<<<<<<<<
 *                                     result = await session.execute(query)
 *                                     db_interval = result.scalar_one_or_none()
*/
                                __Pyx_GetModuleGlobalName(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5498, __pyx_L569_error)
                                __Pyx_GOTREF(__pyx_t_26);
                                __pyx_t_52 = __Pyx_PyObject_GetAttrStr(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5498, __pyx_L569_error)
                                __Pyx_GOTREF(__pyx_t_52);
                                __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                                __pyx_t_24 = __pyx_t_52;
                                __Pyx_INCREF(__pyx_t_24);
                                __pyx_t_8 = 0;
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_24, NULL};
                                  __pyx_t_25 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_desc, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                                  __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
                                  if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5498, __pyx_L569_error)
                                  __Pyx_GOTREF(__pyx_t_25);
                                }
                                __pyx_t_8 = 0;
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_25};
                                  __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_order_by, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                                  __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                                  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                                  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5498, __pyx_L569_error)
                                  __Pyx_GOTREF(__pyx_t_4);
                                }
                                __pyx_t_23 = __pyx_t_4;
                                __Pyx_INCREF(__pyx_t_23);
                                __pyx_t_8 = 0;
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_23, __pyx_mstate_global->__pyx_int_1};
                                  __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_limit, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5498, __pyx_L569_error)
                                  __Pyx_GOTREF(__pyx_t_7);
                                }
                                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_query);
                                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_query, __pyx_t_7);
                                __Pyx_GIVEREF(__pyx_t_7);
                                __pyx_t_7 = 0;

                                /* "ws_package/controllers/activity_controller.py":5499
 *                                         ActivityInterval.end_time <= et + tol,
 *                                     ).order_by(ActivityInterval.id.desc()).limit(1)
 *                                     result = await session.execute(query)             # <<<<<<<<<<<<<<
 *                                     db_interval = result.scalar_one_or_none()
 *                         if db_interval and db_interval.id:
*/
                                __pyx_t_4 = __pyx_cur_scope->__pyx_v_session;
                                __Pyx_INCREF(__pyx_t_4);
                                __pyx_t_8 = 0;
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_query};
                                  __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                                  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5499, __pyx_L569_error)
                                  __Pyx_GOTREF(__pyx_t_7);
                                }
                                __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7, &__pyx_r);
                                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                                if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __Pyx_XGIVEREF(__pyx_t_1);
                                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                  __Pyx_XGIVEREF(__pyx_t_2);
                                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                  __Pyx_XGIVEREF(__pyx_t_3);
                                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                  __Pyx_XGIVEREF(__pyx_t_12);
                                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                                  __Pyx_XGIVEREF(__pyx_t_13);
                                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                                  __Pyx_XGIVEREF(__pyx_t_14);
                                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                                  __Pyx_XGIVEREF(__pyx_t_15);
                                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_15;
                                  __Pyx_XGIVEREF(__pyx_t_17);
                                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_17;
                                  __Pyx_XGIVEREF(__pyx_t_18);
                                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_18;
                                  __Pyx_XGIVEREF(__pyx_t_19);
                                  __pyx_cur_scope->__pyx_t_9 = __pyx_t_19;
                                  __Pyx_XGIVEREF(__pyx_t_20);
                                  __pyx_cur_scope->__pyx_t_10 = __pyx_t_20;
                                  __Pyx_XGIVEREF(__pyx_t_21);
                                  __pyx_cur_scope->__pyx_t_11 = __pyx_t_21;
                                  __Pyx_XGIVEREF(__pyx_t_22);
                                  __pyx_cur_scope->__pyx_t_12 = __pyx_t_22;
                                  __Pyx_XGIVEREF(__pyx_t_37);
                                  __pyx_cur_scope->__pyx_t_13 = __pyx_t_37;
                                  __Pyx_XGIVEREF(__pyx_r);
                                  __Pyx_RefNannyFinishContext();
                                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                                  /* return from generator, awaiting value */
                                  __pyx_generator->resume_label = 42;
                                  return __pyx_r;
                                  __pyx_L575_resume_from_await:;
                                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                  __pyx_cur_scope->__pyx_t_0 = 0;
                                  __Pyx_XGOTREF(__pyx_t_1);
                                  __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                  __pyx_cur_scope->__pyx_t_1 = 0;
                                  __Pyx_XGOTREF(__pyx_t_2);
                                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                  __pyx_cur_scope->__pyx_t_2 = 0;
                                  __Pyx_XGOTREF(__pyx_t_3);
                                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                                  __pyx_cur_scope->__pyx_t_3 = 0;
                                  __Pyx_XGOTREF(__pyx_t_12);
                                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                                  __pyx_cur_scope->__pyx_t_4 = 0;
                                  __Pyx_XGOTREF(__pyx_t_13);
                                  __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                                  __pyx_cur_scope->__pyx_t_5 = 0;
                                  __Pyx_XGOTREF(__pyx_t_14);
                                  __pyx_t_15 = __pyx_cur_scope->__pyx_t_6;
                                  __pyx_cur_scope->__pyx_t_6 = 0;
                                  __Pyx_XGOTREF(__pyx_t_15);
                                  __pyx_t_17 = __pyx_cur_scope->__pyx_t_7;
                                  __pyx_cur_scope->__pyx_t_7 = 0;
                                  __Pyx_XGOTREF(__pyx_t_17);
                                  __pyx_t_18 = __pyx_cur_scope->__pyx_t_8;
                                  __pyx_cur_scope->__pyx_t_8 = 0;
                                  __Pyx_XGOTREF(__pyx_t_18);
                                  __pyx_t_19 = __pyx_cur_scope->__pyx_t_9;
                                  __pyx_cur_scope->__pyx_t_9 = 0;
                                  __Pyx_XGOTREF(__pyx_t_19);
                                  __pyx_t_20 = __pyx_cur_scope->__pyx_t_10;
                                  __pyx_cur_scope->__pyx_t_10 = 0;
                                  __Pyx_XGOTREF(__pyx_t_20);
                                  __pyx_t_21 = __pyx_cur_scope->__pyx_t_11;
                                  __pyx_cur_scope->__pyx_t_11 = 0;
                                  __Pyx_XGOTREF(__pyx_t_21);
                                  __pyx_t_22 = __pyx_cur_scope->__pyx_t_12;
                                  __pyx_cur_scope->__pyx_t_12 = 0;
                                  __Pyx_XGOTREF(__pyx_t_22);
                                  __pyx_t_37 = __pyx_cur_scope->__pyx_t_13;
                                  __pyx_cur_scope->__pyx_t_13 = 0;
                                  __Pyx_XGOTREF(__pyx_t_37);
                                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5499, __pyx_L569_error)
                                  __pyx_t_7 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_7);
                                } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __pyx_t_7 = __pyx_r; __pyx_r = NULL;
                                } else {
                                  __Pyx_XGOTREF(__pyx_r);
                                  __PYX_ERR(0, 5499, __pyx_L569_error)
                                }
                                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_result);
                                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_result, __pyx_t_7);
                                __Pyx_GIVEREF(__pyx_t_7);
                                __pyx_t_7 = 0;

                                /* "ws_package/controllers/activity_controller.py":5500
 *                                     ).order_by(ActivityInterval.id.desc()).limit(1)
 *                                     result = await session.execute(query)
 *                                     db_interval = result.scalar_one_or_none()             # <<<<<<<<<<<<<<
 *                         if db_interval and db_interval.id:
 *                             await self.activity_service.update_activity_interval(db_interval)
*/
                                __pyx_t_4 = __pyx_cur_scope->__pyx_v_result;
                                __Pyx_INCREF(__pyx_t_4);
                                __pyx_t_8 = 0;
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
                                  __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalar_one_or_none, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                                  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5500, __pyx_L569_error)
                                  __Pyx_GOTREF(__pyx_t_7);
                                }
                                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_db_interval);
                                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_db_interval, __pyx_t_7);
                                __Pyx_GIVEREF(__pyx_t_7);
                                __pyx_t_7 = 0;

                                /* "ws_package/controllers/activity_controller.py":5491
 *                             tol = datetime.timedelta(seconds=2)
 *                             with db_lock_manager.read_lock():
 *                                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                                     query = select(ActivityInterval).where(
 *                                         ActivityInterval.counter == getattr(last_interval, 'counter', current_session_counter),
*/
                              }
                              __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                              __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                              __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                              goto __pyx_L574_try_end;
                              __pyx_L569_error:;
                              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                              __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                              __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                              __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                              __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                              __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                              __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                              __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                              __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
                              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                              /*except:*/ {
                                __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
                                if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_4, &__pyx_t_23) < 0) __PYX_ERR(0, 5491, __pyx_L571_except_error)
                                __Pyx_XGOTREF(__pyx_t_7);
                                __Pyx_XGOTREF(__pyx_t_4);
                                __Pyx_XGOTREF(__pyx_t_23);
                                __pyx_t_10 = PyTuple_Pack(3, __pyx_t_7, __pyx_t_4, __pyx_t_23); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5491, __pyx_L571_except_error)
                                __Pyx_GOTREF(__pyx_t_10);
                                __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_20, __pyx_t_10, NULL);
                                __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                                __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                                if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 5491, __pyx_L571_except_error)
                                __Pyx_GOTREF(__pyx_t_16);
                                __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_16, &__pyx_r);
                                __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                                if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __Pyx_XGIVEREF(__pyx_t_1);
                                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                  __Pyx_XGIVEREF(__pyx_t_2);
                                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                  __Pyx_XGIVEREF(__pyx_t_3);
                                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                  __Pyx_XGIVEREF(__pyx_t_4);
                                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
                                  __Pyx_XGIVEREF(__pyx_t_7);
                                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_7;
                                  __Pyx_XGIVEREF(__pyx_t_12);
                                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                                  __Pyx_XGIVEREF(__pyx_t_13);
                                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                                  __Pyx_XGIVEREF(__pyx_t_14);
                                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                                  __Pyx_XGIVEREF(__pyx_t_15);
                                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                                  __Pyx_XGIVEREF(__pyx_t_16);
                                  __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                                  __Pyx_XGIVEREF(__pyx_t_17);
                                  __pyx_cur_scope->__pyx_t_10 = __pyx_t_17;
                                  __Pyx_XGIVEREF(__pyx_t_18);
                                  __pyx_cur_scope->__pyx_t_11 = __pyx_t_18;
                                  __Pyx_XGIVEREF(__pyx_t_19);
                                  __pyx_cur_scope->__pyx_t_12 = __pyx_t_19;
                                  __Pyx_XGIVEREF(__pyx_t_20);
                                  __pyx_cur_scope->__pyx_t_13 = __pyx_t_20;
                                  __Pyx_XGIVEREF(__pyx_t_21);
                                  __pyx_cur_scope->__pyx_t_14 = __pyx_t_21;
                                  __Pyx_XGIVEREF(__pyx_t_22);
                                  __pyx_cur_scope->__pyx_t_15 = __pyx_t_22;
                                  __Pyx_XGIVEREF(__pyx_t_23);
                                  __pyx_cur_scope->__pyx_t_16 = __pyx_t_23;
                                  __Pyx_XGIVEREF(__pyx_t_37);
                                  __pyx_cur_scope->__pyx_t_17 = __pyx_t_37;
                                  __Pyx_XGIVEREF(__pyx_r);
                                  __Pyx_RefNannyFinishContext();
                                  __Pyx_Coroutine_SwapException(__pyx_generator);
                                  /* return from generator, awaiting value */
                                  __pyx_generator->resume_label = 43;
                                  return __pyx_r;
                                  __pyx_L579_resume_from_await:;
                                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                  __pyx_cur_scope->__pyx_t_0 = 0;
                                  __Pyx_XGOTREF(__pyx_t_1);
                                  __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                  __pyx_cur_scope->__pyx_t_1 = 0;
                                  __Pyx_XGOTREF(__pyx_t_2);
                                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                  __pyx_cur_scope->__pyx_t_2 = 0;
                                  __Pyx_XGOTREF(__pyx_t_3);
                                  __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
                                  __pyx_cur_scope->__pyx_t_3 = 0;
                                  __Pyx_XGOTREF(__pyx_t_4);
                                  __pyx_t_7 = __pyx_cur_scope->__pyx_t_4;
                                  __pyx_cur_scope->__pyx_t_4 = 0;
                                  __Pyx_XGOTREF(__pyx_t_7);
                                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                                  __pyx_cur_scope->__pyx_t_5 = 0;
                                  __Pyx_XGOTREF(__pyx_t_12);
                                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                                  __pyx_cur_scope->__pyx_t_6 = 0;
                                  __Pyx_XGOTREF(__pyx_t_13);
                                  __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                                  __pyx_cur_scope->__pyx_t_7 = 0;
                                  __Pyx_XGOTREF(__pyx_t_14);
                                  __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                                  __pyx_cur_scope->__pyx_t_8 = 0;
                                  __Pyx_XGOTREF(__pyx_t_15);
                                  __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                                  __pyx_cur_scope->__pyx_t_9 = 0;
                                  __Pyx_XGOTREF(__pyx_t_16);
                                  __pyx_t_17 = __pyx_cur_scope->__pyx_t_10;
                                  __pyx_cur_scope->__pyx_t_10 = 0;
                                  __Pyx_XGOTREF(__pyx_t_17);
                                  __pyx_t_18 = __pyx_cur_scope->__pyx_t_11;
                                  __pyx_cur_scope->__pyx_t_11 = 0;
                                  __Pyx_XGOTREF(__pyx_t_18);
                                  __pyx_t_19 = __pyx_cur_scope->__pyx_t_12;
                                  __pyx_cur_scope->__pyx_t_12 = 0;
                                  __Pyx_XGOTREF(__pyx_t_19);
                                  __pyx_t_20 = __pyx_cur_scope->__pyx_t_13;
                                  __pyx_cur_scope->__pyx_t_13 = 0;
                                  __Pyx_XGOTREF(__pyx_t_20);
                                  __pyx_t_21 = __pyx_cur_scope->__pyx_t_14;
                                  __pyx_cur_scope->__pyx_t_14 = 0;
                                  __Pyx_XGOTREF(__pyx_t_21);
                                  __pyx_t_22 = __pyx_cur_scope->__pyx_t_15;
                                  __pyx_cur_scope->__pyx_t_15 = 0;
                                  __Pyx_XGOTREF(__pyx_t_22);
                                  __pyx_t_23 = __pyx_cur_scope->__pyx_t_16;
                                  __pyx_cur_scope->__pyx_t_16 = 0;
                                  __Pyx_XGOTREF(__pyx_t_23);
                                  __pyx_t_37 = __pyx_cur_scope->__pyx_t_17;
                                  __pyx_cur_scope->__pyx_t_17 = 0;
                                  __Pyx_XGOTREF(__pyx_t_37);
                                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5491, __pyx_L571_except_error)
                                  __pyx_t_10 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_10);
                                } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __pyx_t_10 = __pyx_r; __pyx_r = NULL;
                                } else {
                                  __Pyx_XGOTREF(__pyx_r);
                                  __PYX_ERR(0, 5491, __pyx_L571_except_error)
                                }
                                __pyx_t_16 = __pyx_t_10;
                                __pyx_t_10 = 0;
                                __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_16);
                                __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                                if (__pyx_t_28 < (0)) __PYX_ERR(0, 5491, __pyx_L571_except_error)
                                __pyx_t_47 = (!__pyx_t_28);
                                if (unlikely(__pyx_t_47)) {
                                  __Pyx_GIVEREF(__pyx_t_7);
                                  __Pyx_GIVEREF(__pyx_t_4);
                                  __Pyx_XGIVEREF(__pyx_t_23);
                                  __Pyx_ErrRestoreWithState(__pyx_t_7, __pyx_t_4, __pyx_t_23);
                                  __pyx_t_7 = 0;  __pyx_t_4 = 0;  __pyx_t_23 = 0; 
                                  __PYX_ERR(0, 5491, __pyx_L571_except_error)
                                }
                                __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                                __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                                goto __pyx_L570_exception_handled;
                              }
                              __pyx_L571_except_error:;
                              __Pyx_XGIVEREF(__pyx_t_19);
                              __Pyx_XGIVEREF(__pyx_t_22);
                              __Pyx_XGIVEREF(__pyx_t_21);
                              __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_22, __pyx_t_21);
                              goto __pyx_L558_error;
                              __pyx_L570_exception_handled:;
                              __Pyx_XGIVEREF(__pyx_t_19);
                              __Pyx_XGIVEREF(__pyx_t_22);
                              __Pyx_XGIVEREF(__pyx_t_21);
                              __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_22, __pyx_t_21);
                              __pyx_L574_try_end:;
                            }
                          }
                          /*finally:*/ {
                            /*normal exit:*/{
                              if (__pyx_t_20) {
                                __pyx_t_21 = __Pyx_PyObject_Call(__pyx_t_20, __pyx_mstate_global->__pyx_tuple[7], NULL);
                                __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                                if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 5491, __pyx_L558_error)
                                __Pyx_GOTREF(__pyx_t_21);
                                __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_21, &__pyx_r);
                                __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                                if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __Pyx_XGIVEREF(__pyx_t_1);
                                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                  __Pyx_XGIVEREF(__pyx_t_2);
                                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                  __Pyx_XGIVEREF(__pyx_t_3);
                                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                  __Pyx_XGIVEREF(__pyx_t_12);
                                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                                  __Pyx_XGIVEREF(__pyx_t_13);
                                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                                  __Pyx_XGIVEREF(__pyx_t_14);
                                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                                  __Pyx_XGIVEREF(__pyx_t_15);
                                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_15;
                                  __Pyx_XGIVEREF(__pyx_t_17);
                                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_17;
                                  __Pyx_XGIVEREF(__pyx_t_18);
                                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_18;
                                  __Pyx_XGIVEREF(__pyx_t_20);
                                  __pyx_cur_scope->__pyx_t_9 = __pyx_t_20;
                                  __Pyx_XGIVEREF(__pyx_t_21);
                                  __pyx_cur_scope->__pyx_t_10 = __pyx_t_21;
                                  __Pyx_XGIVEREF(__pyx_t_37);
                                  __pyx_cur_scope->__pyx_t_11 = __pyx_t_37;
                                  __Pyx_XGIVEREF(__pyx_r);
                                  __Pyx_RefNannyFinishContext();
                                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                                  /* return from generator, awaiting value */
                                  __pyx_generator->resume_label = 44;
                                  return __pyx_r;
                                  __pyx_L580_resume_from_await:;
                                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                  __pyx_cur_scope->__pyx_t_0 = 0;
                                  __Pyx_XGOTREF(__pyx_t_1);
                                  __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                  __pyx_cur_scope->__pyx_t_1 = 0;
                                  __Pyx_XGOTREF(__pyx_t_2);
                                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                  __pyx_cur_scope->__pyx_t_2 = 0;
                                  __Pyx_XGOTREF(__pyx_t_3);
                                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                                  __pyx_cur_scope->__pyx_t_3 = 0;
                                  __Pyx_XGOTREF(__pyx_t_12);
                                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                                  __pyx_cur_scope->__pyx_t_4 = 0;
                                  __Pyx_XGOTREF(__pyx_t_13);
                                  __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                                  __pyx_cur_scope->__pyx_t_5 = 0;
                                  __Pyx_XGOTREF(__pyx_t_14);
                                  __pyx_t_15 = __pyx_cur_scope->__pyx_t_6;
                                  __pyx_cur_scope->__pyx_t_6 = 0;
                                  __Pyx_XGOTREF(__pyx_t_15);
                                  __pyx_t_17 = __pyx_cur_scope->__pyx_t_7;
                                  __pyx_cur_scope->__pyx_t_7 = 0;
                                  __Pyx_XGOTREF(__pyx_t_17);
                                  __pyx_t_18 = __pyx_cur_scope->__pyx_t_8;
                                  __pyx_cur_scope->__pyx_t_8 = 0;
                                  __Pyx_XGOTREF(__pyx_t_18);
                                  __pyx_t_20 = __pyx_cur_scope->__pyx_t_9;
                                  __pyx_cur_scope->__pyx_t_9 = 0;
                                  __Pyx_XGOTREF(__pyx_t_20);
                                  __pyx_t_21 = __pyx_cur_scope->__pyx_t_10;
                                  __pyx_cur_scope->__pyx_t_10 = 0;
                                  __Pyx_XGOTREF(__pyx_t_21);
                                  __pyx_t_37 = __pyx_cur_scope->__pyx_t_11;
                                  __pyx_cur_scope->__pyx_t_11 = 0;
                                  __Pyx_XGOTREF(__pyx_t_37);
                                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5491, __pyx_L558_error)
                                  __pyx_t_23 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_23);
                                } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __pyx_t_23 = __pyx_r; __pyx_r = NULL;
                                } else {
                                  __Pyx_XGOTREF(__pyx_r);
                                  __PYX_ERR(0, 5491, __pyx_L558_error)
                                }
                                __pyx_t_21 = __pyx_t_23;
                                __pyx_t_23 = 0;
                                __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                              }
                              goto __pyx_L568;
                            }
                            __pyx_L568:;
                          }
                          goto __pyx_L581;
                          __pyx_L564_error:;
                          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                          goto __pyx_L558_error;
                          __pyx_L581:;
                        }

                        /* "ws_package/controllers/activity_controller.py":5490
 *                         else:
 *                             tol = datetime.timedelta(seconds=2)
 *                             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                                 async with async_session() as session:
 *                                     query = select(ActivityInterval).where(
*/
                      }
                      __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                      __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                      goto __pyx_L563_try_end;
                      __pyx_L558_error:;
                      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                      __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                      __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                      __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                      __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                      __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                      __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                      __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                      __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
                      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                      /*except:*/ {
                        __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
                        if (__Pyx_GetException(&__pyx_t_23, &__pyx_t_4, &__pyx_t_7) < 0) __PYX_ERR(0, 5490, __pyx_L560_except_error)
                        __Pyx_XGOTREF(__pyx_t_23);
                        __Pyx_XGOTREF(__pyx_t_4);
                        __Pyx_XGOTREF(__pyx_t_7);
                        __pyx_t_10 = PyTuple_Pack(3, __pyx_t_23, __pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5490, __pyx_L560_except_error)
                        __Pyx_GOTREF(__pyx_t_10);
                        __pyx_t_20 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_t_10, NULL);
                        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                        if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 5490, __pyx_L560_except_error)
                        __Pyx_GOTREF(__pyx_t_20);
                        __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_t_20);
                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        if (__pyx_t_47 < (0)) __PYX_ERR(0, 5490, __pyx_L560_except_error)
                        __pyx_t_28 = (!__pyx_t_47);
                        if (unlikely(__pyx_t_28)) {
                          __Pyx_GIVEREF(__pyx_t_23);
                          __Pyx_GIVEREF(__pyx_t_4);
                          __Pyx_XGIVEREF(__pyx_t_7);
                          __Pyx_ErrRestoreWithState(__pyx_t_23, __pyx_t_4, __pyx_t_7);
                          __pyx_t_23 = 0;  __pyx_t_4 = 0;  __pyx_t_7 = 0; 
                          __PYX_ERR(0, 5490, __pyx_L560_except_error)
                        }
                        __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                        goto __pyx_L559_exception_handled;
                      }
                      __pyx_L560_except_error:;
                      __Pyx_XGIVEREF(__pyx_t_18);
                      __Pyx_XGIVEREF(__pyx_t_15);
                      __Pyx_XGIVEREF(__pyx_t_37);
                      __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_15, __pyx_t_37);
                      goto __pyx_L545_error;
                      __pyx_L559_exception_handled:;
                      __Pyx_XGIVEREF(__pyx_t_18);
                      __Pyx_XGIVEREF(__pyx_t_15);
                      __Pyx_XGIVEREF(__pyx_t_37);
                      __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_15, __pyx_t_37);
                      __pyx_L563_try_end:;
                    }
                  }
                  /*finally:*/ {
                    /*normal exit:*/{
                      if (__pyx_t_17) {
                        __pyx_t_37 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_mstate_global->__pyx_tuple[7], NULL);
                        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                        if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 5490, __pyx_L545_error)
                        __Pyx_GOTREF(__pyx_t_37);
                        __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                      }
                      goto __pyx_L557;
                    }
                    __pyx_L557:;
                  }
                  goto __pyx_L585;
                  __pyx_L554_error:;
                  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                  goto __pyx_L545_error;
                  __pyx_L585:;
                }
              }
              __pyx_L551:;

              /* "ws_package/controllers/activity_controller.py":5501
 *                                     result = await session.execute(query)
 *                                     db_interval = result.scalar_one_or_none()
 *                         if db_interval and db_interval.id:             # <<<<<<<<<<<<<<
 *                             await self.activity_service.update_activity_interval(db_interval)
 *                             logger.info("Last interval (id=%s) explicitly updated after successful send", db_interval.id)
*/
              if (unlikely(!__pyx_cur_scope->__pyx_v_db_interval)) { __Pyx_RaiseUnboundLocalError("db_interval"); __PYX_ERR(0, 5501, __pyx_L545_error) }
              __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_db_interval); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5501, __pyx_L545_error)
              if (__pyx_t_47) {
              } else {
                __pyx_t_28 = __pyx_t_47;
                goto __pyx_L587_bool_binop_done;
              }
              if (unlikely(!__pyx_cur_scope->__pyx_v_db_interval)) { __Pyx_RaiseUnboundLocalError("db_interval"); __PYX_ERR(0, 5501, __pyx_L545_error) }
              __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_db_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5501, __pyx_L545_error)
              __Pyx_GOTREF(__pyx_t_7);
              __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5501, __pyx_L545_error)
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              __pyx_t_28 = __pyx_t_47;
              __pyx_L587_bool_binop_done:;
              if (__pyx_t_28) {

                /* "ws_package/controllers/activity_controller.py":5502
 *                                     db_interval = result.scalar_one_or_none()
 *                         if db_interval and db_interval.id:
 *                             await self.activity_service.update_activity_interval(db_interval)             # <<<<<<<<<<<<<<
 *                             logger.info("Last interval (id=%s) explicitly updated after successful send", db_interval.id)
 *                             last_interval_id = db_interval.id
*/
                __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5502, __pyx_L545_error)
                __Pyx_GOTREF(__pyx_t_23);
                __pyx_t_4 = __pyx_t_23;
                __Pyx_INCREF(__pyx_t_4);
                if (unlikely(!__pyx_cur_scope->__pyx_v_db_interval)) { __Pyx_RaiseUnboundLocalError("db_interval"); __PYX_ERR(0, 5502, __pyx_L545_error) }
                __pyx_t_8 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_db_interval};
                  __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_update_activity_interval, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5502, __pyx_L545_error)
                  __Pyx_GOTREF(__pyx_t_7);
                }
                __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7, &__pyx_r);
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_1);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                  __Pyx_XGIVEREF(__pyx_t_2);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                  __Pyx_XGIVEREF(__pyx_t_3);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_t_14);
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 45;
                  return __pyx_r;
                  __pyx_L589_resume_from_await:;
                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_1);
                  __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_2);
                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_3);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = 0;
                  __Pyx_XGOTREF(__pyx_t_14);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5502, __pyx_L545_error)
                } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 5502, __pyx_L545_error)
                }

                /* "ws_package/controllers/activity_controller.py":5503
 *                         if db_interval and db_interval.id:
 *                             await self.activity_service.update_activity_interval(db_interval)
 *                             logger.info("Last interval (id=%s) explicitly updated after successful send", db_interval.id)             # <<<<<<<<<<<<<<
 *                             last_interval_id = db_interval.id
 *                         elif st is not None and et is not None:
*/
                __pyx_t_23 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5503, __pyx_L545_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5503, __pyx_L545_error)
                __Pyx_GOTREF(__pyx_t_10);
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                if (unlikely(!__pyx_cur_scope->__pyx_v_db_interval)) { __Pyx_RaiseUnboundLocalError("db_interval"); __PYX_ERR(0, 5503, __pyx_L545_error) }
                __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_db_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5503, __pyx_L545_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_10))) {
                  __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_10);
                  assert(__pyx_t_23);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
                  __Pyx_INCREF(__pyx_t_23);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_23, __pyx_mstate_global->__pyx_kp_u_Last_interval_id_s_explicitly_up, __pyx_t_4};
                  __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5503, __pyx_L545_error)
                  __Pyx_GOTREF(__pyx_t_7);
                }
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

                /* "ws_package/controllers/activity_controller.py":5504
 *                             await self.activity_service.update_activity_interval(db_interval)
 *                             logger.info("Last interval (id=%s) explicitly updated after successful send", db_interval.id)
 *                             last_interval_id = db_interval.id             # <<<<<<<<<<<<<<
 *                         elif st is not None and et is not None:
 *                             logger.warning("Could not find database record for last interval to update")
*/
                if (unlikely(!__pyx_cur_scope->__pyx_v_db_interval)) { __Pyx_RaiseUnboundLocalError("db_interval"); __PYX_ERR(0, 5504, __pyx_L545_error) }
                __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_db_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5504, __pyx_L545_error)
                __Pyx_GOTREF(__pyx_t_7);
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_last_interval_id);
                __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_last_interval_id, __pyx_t_7);
                __Pyx_GIVEREF(__pyx_t_7);
                __pyx_t_7 = 0;

                /* "ws_package/controllers/activity_controller.py":5501
 *                                     result = await session.execute(query)
 *                                     db_interval = result.scalar_one_or_none()
 *                         if db_interval and db_interval.id:             # <<<<<<<<<<<<<<
 *                             await self.activity_service.update_activity_interval(db_interval)
 *                             logger.info("Last interval (id=%s) explicitly updated after successful send", db_interval.id)
*/
                goto __pyx_L586;
              }

              /* "ws_package/controllers/activity_controller.py":5505
 *                             logger.info("Last interval (id=%s) explicitly updated after successful send", db_interval.id)
 *                             last_interval_id = db_interval.id
 *                         elif st is not None and et is not None:             # <<<<<<<<<<<<<<
 *                             logger.warning("Could not find database record for last interval to update")
 *                     except Exception as e:
*/
              __pyx_t_47 = (__pyx_cur_scope->__pyx_v_st != Py_None);
              if (__pyx_t_47) {
              } else {
                __pyx_t_28 = __pyx_t_47;
                goto __pyx_L590_bool_binop_done;
              }
              __pyx_t_47 = (__pyx_cur_scope->__pyx_v_et != Py_None);
              __pyx_t_28 = __pyx_t_47;
              __pyx_L590_bool_binop_done:;
              if (__pyx_t_28) {

                /* "ws_package/controllers/activity_controller.py":5506
 *                             last_interval_id = db_interval.id
 *                         elif st is not None and et is not None:
 *                             logger.warning("Could not find database record for last interval to update")             # <<<<<<<<<<<<<<
 *                     except Exception as e:
 *                         logger.error("Error querying database for last interval: %s", e, exc_info=True)
*/
                __pyx_t_10 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5506, __pyx_L545_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5506, __pyx_L545_error)
                __Pyx_GOTREF(__pyx_t_23);
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_23))) {
                  __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_23);
                  assert(__pyx_t_10);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_23);
                  __Pyx_INCREF(__pyx_t_10);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_23, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Could_not_find_database_record_f_2};
                  __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_23, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                  __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5506, __pyx_L545_error)
                  __Pyx_GOTREF(__pyx_t_7);
                }
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

                /* "ws_package/controllers/activity_controller.py":5505
 *                             logger.info("Last interval (id=%s) explicitly updated after successful send", db_interval.id)
 *                             last_interval_id = db_interval.id
 *                         elif st is not None and et is not None:             # <<<<<<<<<<<<<<
 *                             logger.warning("Could not find database record for last interval to update")
 *                     except Exception as e:
*/
              }
              __pyx_L586:;

              /* "ws_package/controllers/activity_controller.py":5483
 *                 if last_interval_was_sent:
 *                     # Query database to get the actual record with ID (use tolerance for datetime precision)
 *                     try:             # <<<<<<<<<<<<<<
 *                         st = getattr(last_interval, 'start_time', None)
 *                         et = getattr(last_interval, 'end_time', None)
*/
            }
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            goto __pyx_L550_try_end;
            __pyx_L545_error:;
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
            __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
            __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
            __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
            __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
            __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
            __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

            /* "ws_package/controllers/activity_controller.py":5507
 *                         elif st is not None and et is not None:
 *                             logger.warning("Could not find database record for last interval to update")
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error querying database for last interval: %s", e, exc_info=True)
 *                         # Fallback: try to update if we have an ID
*/
            __pyx_t_32 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
            if (__pyx_t_32) {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_23, &__pyx_t_10) < 0) __PYX_ERR(0, 5507, __pyx_L547_except_error)
              __Pyx_XGOTREF(__pyx_t_7);
              __Pyx_XGOTREF(__pyx_t_23);
              __Pyx_XGOTREF(__pyx_t_10);
              __Pyx_INCREF(__pyx_t_23);
              __Pyx_GIVEREF(__pyx_t_23);
              __pyx_cur_scope->__pyx_v_e = __pyx_t_23;
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":5508
 *                             logger.warning("Could not find database record for last interval to update")
 *                     except Exception as e:
 *                         logger.error("Error querying database for last interval: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 *                         # Fallback: try to update if we have an ID
 *                         if last_interval_id:
*/
                __pyx_t_25 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5508, __pyx_L597_error)
                __Pyx_GOTREF(__pyx_t_5);
                __pyx_t_52 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5508, __pyx_L597_error)
                __Pyx_GOTREF(__pyx_t_52);
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_52))) {
                  __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_52);
                  assert(__pyx_t_25);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_52);
                  __Pyx_INCREF(__pyx_t_25);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_52, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_25, __pyx_mstate_global->__pyx_kp_u_Error_querying_database_for_last, __pyx_cur_scope->__pyx_v_e};
                  __pyx_t_5 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5508, __pyx_L597_error)
                  __Pyx_GOTREF(__pyx_t_5);
                  if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_5, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 5508, __pyx_L597_error)
                  __pyx_t_4 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_52, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_5);
                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
                  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5508, __pyx_L597_error)
                  __Pyx_GOTREF(__pyx_t_4);
                }
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                /* "ws_package/controllers/activity_controller.py":5510
 *                         logger.error("Error querying database for last interval: %s", e, exc_info=True)
 *                         # Fallback: try to update if we have an ID
 *                         if last_interval_id:             # <<<<<<<<<<<<<<
 *                             # Query database to get the interval object with ID
 *                             try:
*/
                __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval_id); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5510, __pyx_L597_error)
                if (__pyx_t_28) {

                  /* "ws_package/controllers/activity_controller.py":5512
 *                         if last_interval_id:
 *                             # Query database to get the interval object with ID
 *                             try:             # <<<<<<<<<<<<<<
 *                                 async with async_session() as session:
 *                                     query = select(ActivityInterval).where(ActivityInterval.id == last_interval_id)
*/
                  {
                    __Pyx_ExceptionSave(&__pyx_t_17, &__pyx_t_37, &__pyx_t_15);
                    __Pyx_XGOTREF(__pyx_t_17);
                    __Pyx_XGOTREF(__pyx_t_37);
                    __Pyx_XGOTREF(__pyx_t_15);
                    /*try:*/ {

                      /* "ws_package/controllers/activity_controller.py":5513
 *                             # Query database to get the interval object with ID
 *                             try:
 *                                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                                     query = select(ActivityInterval).where(ActivityInterval.id == last_interval_id)
 *                                     result = await session.execute(query)
*/
                      /*with:*/ {
                        __pyx_t_52 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5513, __pyx_L600_error)
                        __Pyx_GOTREF(__pyx_t_5);
                        __pyx_t_8 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_5))) {
                          __pyx_t_52 = PyMethod_GET_SELF(__pyx_t_5);
                          assert(__pyx_t_52);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                          __Pyx_INCREF(__pyx_t_52);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                          __pyx_t_8 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_52, NULL};
                          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5513, __pyx_L600_error)
                          __Pyx_GOTREF(__pyx_t_4);
                        }
                        __pyx_t_18 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 5513, __pyx_L600_error)
                        __Pyx_GOTREF(__pyx_t_18);
                        __pyx_t_52 = NULL;
                        __pyx_t_25 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5513, __pyx_L608_error)
                        __Pyx_GOTREF(__pyx_t_25);
                        __pyx_t_8 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (likely(PyMethod_Check(__pyx_t_25))) {
                          __pyx_t_52 = PyMethod_GET_SELF(__pyx_t_25);
                          assert(__pyx_t_52);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_25);
                          __Pyx_INCREF(__pyx_t_52);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_25, __pyx__function);
                          __pyx_t_8 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_52, NULL};
                          __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_25, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                          __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5513, __pyx_L608_error)
                          __Pyx_GOTREF(__pyx_t_5);
                        }
                        __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                        if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                          __Pyx_GOTREF(__pyx_r);
                          __Pyx_XGIVEREF(__pyx_t_1);
                          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                          __Pyx_XGIVEREF(__pyx_t_2);
                          __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                          __Pyx_XGIVEREF(__pyx_t_3);
                          __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                          __Pyx_XGIVEREF(__pyx_t_4);
                          __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
                          __Pyx_XGIVEREF(__pyx_t_7);
                          __pyx_cur_scope->__pyx_t_4 = __pyx_t_7;
                          __Pyx_XGIVEREF(__pyx_t_10);
                          __pyx_cur_scope->__pyx_t_5 = __pyx_t_10;
                          __Pyx_XGIVEREF(__pyx_t_12);
                          __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
                          __Pyx_XGIVEREF(__pyx_t_13);
                          __pyx_cur_scope->__pyx_t_7 = __pyx_t_13;
                          __Pyx_XGIVEREF(__pyx_t_14);
                          __pyx_cur_scope->__pyx_t_8 = __pyx_t_14;
                          __Pyx_XGIVEREF(__pyx_t_15);
                          __pyx_cur_scope->__pyx_t_9 = __pyx_t_15;
                          __Pyx_XGIVEREF(__pyx_t_17);
                          __pyx_cur_scope->__pyx_t_10 = __pyx_t_17;
                          __Pyx_XGIVEREF(__pyx_t_18);
                          __pyx_cur_scope->__pyx_t_11 = __pyx_t_18;
                          __Pyx_XGIVEREF(__pyx_t_23);
                          __pyx_cur_scope->__pyx_t_12 = __pyx_t_23;
                          __Pyx_XGIVEREF(__pyx_t_37);
                          __pyx_cur_scope->__pyx_t_13 = __pyx_t_37;
                          __Pyx_XGIVEREF(__pyx_r);
                          __Pyx_RefNannyFinishContext();
                          __Pyx_Coroutine_SwapException(__pyx_generator);
                          /* return from generator, awaiting value */
                          __pyx_generator->resume_label = 46;
                          return __pyx_r;
                          __pyx_L609_resume_from_await:;
                          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                          __pyx_cur_scope->__pyx_t_0 = 0;
                          __Pyx_XGOTREF(__pyx_t_1);
                          __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                          __pyx_cur_scope->__pyx_t_1 = 0;
                          __Pyx_XGOTREF(__pyx_t_2);
                          __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                          __pyx_cur_scope->__pyx_t_2 = 0;
                          __Pyx_XGOTREF(__pyx_t_3);
                          __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
                          __pyx_cur_scope->__pyx_t_3 = 0;
                          __Pyx_XGOTREF(__pyx_t_4);
                          __pyx_t_7 = __pyx_cur_scope->__pyx_t_4;
                          __pyx_cur_scope->__pyx_t_4 = 0;
                          __Pyx_XGOTREF(__pyx_t_7);
                          __pyx_t_10 = __pyx_cur_scope->__pyx_t_5;
                          __pyx_cur_scope->__pyx_t_5 = 0;
                          __Pyx_XGOTREF(__pyx_t_10);
                          __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
                          __pyx_cur_scope->__pyx_t_6 = 0;
                          __Pyx_XGOTREF(__pyx_t_12);
                          __pyx_t_13 = __pyx_cur_scope->__pyx_t_7;
                          __pyx_cur_scope->__pyx_t_7 = 0;
                          __Pyx_XGOTREF(__pyx_t_13);
                          __pyx_t_14 = __pyx_cur_scope->__pyx_t_8;
                          __pyx_cur_scope->__pyx_t_8 = 0;
                          __Pyx_XGOTREF(__pyx_t_14);
                          __pyx_t_15 = __pyx_cur_scope->__pyx_t_9;
                          __pyx_cur_scope->__pyx_t_9 = 0;
                          __Pyx_XGOTREF(__pyx_t_15);
                          __pyx_t_17 = __pyx_cur_scope->__pyx_t_10;
                          __pyx_cur_scope->__pyx_t_10 = 0;
                          __Pyx_XGOTREF(__pyx_t_17);
                          __pyx_t_18 = __pyx_cur_scope->__pyx_t_11;
                          __pyx_cur_scope->__pyx_t_11 = 0;
                          __Pyx_XGOTREF(__pyx_t_18);
                          __pyx_t_23 = __pyx_cur_scope->__pyx_t_12;
                          __pyx_cur_scope->__pyx_t_12 = 0;
                          __Pyx_XGOTREF(__pyx_t_23);
                          __pyx_t_37 = __pyx_cur_scope->__pyx_t_13;
                          __pyx_cur_scope->__pyx_t_13 = 0;
                          __Pyx_XGOTREF(__pyx_t_37);
                          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5513, __pyx_L608_error)
                          __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
                        } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                          __Pyx_GOTREF(__pyx_r);
                          __pyx_t_5 = __pyx_r; __pyx_r = NULL;
                        } else {
                          __Pyx_XGOTREF(__pyx_r);
                          __PYX_ERR(0, 5513, __pyx_L608_error)
                        }
                        __pyx_t_25 = __pyx_t_5;
                        __pyx_t_5 = 0;
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        /*try:*/ {
                          {
                            __Pyx_ExceptionSave(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
                            __Pyx_XGOTREF(__pyx_t_20);
                            __Pyx_XGOTREF(__pyx_t_21);
                            __Pyx_XGOTREF(__pyx_t_22);
                            /*try:*/ {
                              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_session);
                              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_session, __pyx_t_25);
                              __Pyx_GIVEREF(__pyx_t_25);
                              __pyx_t_25 = 0;

                              /* "ws_package/controllers/activity_controller.py":5514
 *                             try:
 *                                 async with async_session() as session:
 *                                     query = select(ActivityInterval).where(ActivityInterval.id == last_interval_id)             # <<<<<<<<<<<<<<
 *                                     result = await session.execute(query)
 *                                     db_interval = result.scalar_one_or_none()
*/
                              __pyx_t_52 = NULL;
                              __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5514, __pyx_L615_error)
                              __Pyx_GOTREF(__pyx_t_24);
                              __Pyx_GetModuleGlobalName(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5514, __pyx_L615_error)
                              __Pyx_GOTREF(__pyx_t_26);
                              __pyx_t_8 = 1;
                              #if CYTHON_UNPACK_METHODS
                              if (unlikely(PyMethod_Check(__pyx_t_24))) {
                                __pyx_t_52 = PyMethod_GET_SELF(__pyx_t_24);
                                assert(__pyx_t_52);
                                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_24);
                                __Pyx_INCREF(__pyx_t_52);
                                __Pyx_INCREF(__pyx__function);
                                __Pyx_DECREF_SET(__pyx_t_24, __pyx__function);
                                __pyx_t_8 = 0;
                              }
                              #endif
                              {
                                PyObject *__pyx_callargs[2] = {__pyx_t_52, __pyx_t_26};
                                __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_24, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                                __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                                __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                                if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5514, __pyx_L615_error)
                                __Pyx_GOTREF(__pyx_t_5);
                              }
                              __pyx_t_4 = __pyx_t_5;
                              __Pyx_INCREF(__pyx_t_4);
                              __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5514, __pyx_L615_error)
                              __Pyx_GOTREF(__pyx_t_24);
                              __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5514, __pyx_L615_error)
                              __Pyx_GOTREF(__pyx_t_26);
                              __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                              __pyx_t_24 = PyObject_RichCompare(__pyx_t_26, __pyx_cur_scope->__pyx_v_last_interval_id, Py_EQ); __Pyx_XGOTREF(__pyx_t_24); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5514, __pyx_L615_error)
                              __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                              __pyx_t_8 = 0;
                              {
                                PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_24};
                                __pyx_t_25 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                                __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                                if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5514, __pyx_L615_error)
                                __Pyx_GOTREF(__pyx_t_25);
                              }
                              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_query);
                              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_query, __pyx_t_25);
                              __Pyx_GIVEREF(__pyx_t_25);
                              __pyx_t_25 = 0;

                              /* "ws_package/controllers/activity_controller.py":5515
 *                                 async with async_session() as session:
 *                                     query = select(ActivityInterval).where(ActivityInterval.id == last_interval_id)
 *                                     result = await session.execute(query)             # <<<<<<<<<<<<<<
 *                                     db_interval = result.scalar_one_or_none()
 *                                     if db_interval:
*/
                              __pyx_t_5 = __pyx_cur_scope->__pyx_v_session;
                              __Pyx_INCREF(__pyx_t_5);
                              __pyx_t_8 = 0;
                              {
                                PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_query};
                                __pyx_t_25 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                                if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5515, __pyx_L615_error)
                                __Pyx_GOTREF(__pyx_t_25);
                              }
                              __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_25, &__pyx_r);
                              __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                              if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                __Pyx_GOTREF(__pyx_r);
                                __Pyx_XGIVEREF(__pyx_t_1);
                                __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                __Pyx_XGIVEREF(__pyx_t_2);
                                __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                __Pyx_XGIVEREF(__pyx_t_3);
                                __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                __Pyx_XGIVEREF(__pyx_t_7);
                                __pyx_cur_scope->__pyx_t_3 = __pyx_t_7;
                                __Pyx_XGIVEREF(__pyx_t_10);
                                __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                                __Pyx_XGIVEREF(__pyx_t_12);
                                __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                                __Pyx_XGIVEREF(__pyx_t_13);
                                __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                                __Pyx_XGIVEREF(__pyx_t_14);
                                __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                                __Pyx_XGIVEREF(__pyx_t_15);
                                __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                                __Pyx_XGIVEREF(__pyx_t_17);
                                __pyx_cur_scope->__pyx_t_9 = __pyx_t_17;
                                __Pyx_XGIVEREF(__pyx_t_18);
                                __pyx_cur_scope->__pyx_t_10 = __pyx_t_18;
                                __Pyx_XGIVEREF(__pyx_t_20);
                                __pyx_cur_scope->__pyx_t_11 = __pyx_t_20;
                                __Pyx_XGIVEREF(__pyx_t_21);
                                __pyx_cur_scope->__pyx_t_12 = __pyx_t_21;
                                __Pyx_XGIVEREF(__pyx_t_22);
                                __pyx_cur_scope->__pyx_t_13 = __pyx_t_22;
                                __Pyx_XGIVEREF(__pyx_t_23);
                                __pyx_cur_scope->__pyx_t_14 = __pyx_t_23;
                                __Pyx_XGIVEREF(__pyx_t_37);
                                __pyx_cur_scope->__pyx_t_15 = __pyx_t_37;
                                __Pyx_XGIVEREF(__pyx_r);
                                __Pyx_RefNannyFinishContext();
                                __Pyx_Coroutine_SwapException(__pyx_generator);
                                /* return from generator, awaiting value */
                                __pyx_generator->resume_label = 47;
                                return __pyx_r;
                                __pyx_L623_resume_from_await:;
                                __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                __pyx_cur_scope->__pyx_t_0 = 0;
                                __Pyx_XGOTREF(__pyx_t_1);
                                __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                __pyx_cur_scope->__pyx_t_1 = 0;
                                __Pyx_XGOTREF(__pyx_t_2);
                                __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                __pyx_cur_scope->__pyx_t_2 = 0;
                                __Pyx_XGOTREF(__pyx_t_3);
                                __pyx_t_7 = __pyx_cur_scope->__pyx_t_3;
                                __pyx_cur_scope->__pyx_t_3 = 0;
                                __Pyx_XGOTREF(__pyx_t_7);
                                __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                                __pyx_cur_scope->__pyx_t_4 = 0;
                                __Pyx_XGOTREF(__pyx_t_10);
                                __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                                __pyx_cur_scope->__pyx_t_5 = 0;
                                __Pyx_XGOTREF(__pyx_t_12);
                                __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                                __pyx_cur_scope->__pyx_t_6 = 0;
                                __Pyx_XGOTREF(__pyx_t_13);
                                __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                                __pyx_cur_scope->__pyx_t_7 = 0;
                                __Pyx_XGOTREF(__pyx_t_14);
                                __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                                __pyx_cur_scope->__pyx_t_8 = 0;
                                __Pyx_XGOTREF(__pyx_t_15);
                                __pyx_t_17 = __pyx_cur_scope->__pyx_t_9;
                                __pyx_cur_scope->__pyx_t_9 = 0;
                                __Pyx_XGOTREF(__pyx_t_17);
                                __pyx_t_18 = __pyx_cur_scope->__pyx_t_10;
                                __pyx_cur_scope->__pyx_t_10 = 0;
                                __Pyx_XGOTREF(__pyx_t_18);
                                __pyx_t_20 = __pyx_cur_scope->__pyx_t_11;
                                __pyx_cur_scope->__pyx_t_11 = 0;
                                __Pyx_XGOTREF(__pyx_t_20);
                                __pyx_t_21 = __pyx_cur_scope->__pyx_t_12;
                                __pyx_cur_scope->__pyx_t_12 = 0;
                                __Pyx_XGOTREF(__pyx_t_21);
                                __pyx_t_22 = __pyx_cur_scope->__pyx_t_13;
                                __pyx_cur_scope->__pyx_t_13 = 0;
                                __Pyx_XGOTREF(__pyx_t_22);
                                __pyx_t_23 = __pyx_cur_scope->__pyx_t_14;
                                __pyx_cur_scope->__pyx_t_14 = 0;
                                __Pyx_XGOTREF(__pyx_t_23);
                                __pyx_t_37 = __pyx_cur_scope->__pyx_t_15;
                                __pyx_cur_scope->__pyx_t_15 = 0;
                                __Pyx_XGOTREF(__pyx_t_37);
                                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5515, __pyx_L615_error)
                                __pyx_t_25 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_25);
                              } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                __Pyx_GOTREF(__pyx_r);
                                __pyx_t_25 = __pyx_r; __pyx_r = NULL;
                              } else {
                                __Pyx_XGOTREF(__pyx_r);
                                __PYX_ERR(0, 5515, __pyx_L615_error)
                              }
                              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_result);
                              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_result, __pyx_t_25);
                              __Pyx_GIVEREF(__pyx_t_25);
                              __pyx_t_25 = 0;

                              /* "ws_package/controllers/activity_controller.py":5516
 *                                     query = select(ActivityInterval).where(ActivityInterval.id == last_interval_id)
 *                                     result = await session.execute(query)
 *                                     db_interval = result.scalar_one_or_none()             # <<<<<<<<<<<<<<
 *                                     if db_interval:
 *                                         await self.activity_service.update_activity_interval(db_interval)
*/
                              __pyx_t_5 = __pyx_cur_scope->__pyx_v_result;
                              __Pyx_INCREF(__pyx_t_5);
                              __pyx_t_8 = 0;
                              {
                                PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                                __pyx_t_25 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalar_one_or_none, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                                if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5516, __pyx_L615_error)
                                __Pyx_GOTREF(__pyx_t_25);
                              }
                              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_db_interval);
                              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_db_interval, __pyx_t_25);
                              __Pyx_GIVEREF(__pyx_t_25);
                              __pyx_t_25 = 0;

                              /* "ws_package/controllers/activity_controller.py":5517
 *                                     result = await session.execute(query)
 *                                     db_interval = result.scalar_one_or_none()
 *                                     if db_interval:             # <<<<<<<<<<<<<<
 *                                         await self.activity_service.update_activity_interval(db_interval)
 *                                         logger.info("Last interval (id=%s) explicitly updated after successful send (fallback)", last_interval_id)
*/
                              __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_db_interval); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5517, __pyx_L615_error)
                              if (__pyx_t_28) {

                                /* "ws_package/controllers/activity_controller.py":5518
 *                                     db_interval = result.scalar_one_or_none()
 *                                     if db_interval:
 *                                         await self.activity_service.update_activity_interval(db_interval)             # <<<<<<<<<<<<<<
 *                                         logger.info("Last interval (id=%s) explicitly updated after successful send (fallback)", last_interval_id)
 *                             except Exception as fallback_error:
*/
                                __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5518, __pyx_L615_error)
                                __Pyx_GOTREF(__pyx_t_24);
                                __pyx_t_5 = __pyx_t_24;
                                __Pyx_INCREF(__pyx_t_5);
                                __pyx_t_8 = 0;
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_db_interval};
                                  __pyx_t_25 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_update_activity_interval, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                                  __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                                  if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5518, __pyx_L615_error)
                                  __Pyx_GOTREF(__pyx_t_25);
                                }
                                __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_25, &__pyx_r);
                                __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                                if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __Pyx_XGIVEREF(__pyx_t_1);
                                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                  __Pyx_XGIVEREF(__pyx_t_2);
                                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                  __Pyx_XGIVEREF(__pyx_t_3);
                                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                  __Pyx_XGIVEREF(__pyx_t_7);
                                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_7;
                                  __Pyx_XGIVEREF(__pyx_t_10);
                                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                                  __Pyx_XGIVEREF(__pyx_t_12);
                                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                                  __Pyx_XGIVEREF(__pyx_t_13);
                                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                                  __Pyx_XGIVEREF(__pyx_t_14);
                                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                                  __Pyx_XGIVEREF(__pyx_t_15);
                                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                                  __Pyx_XGIVEREF(__pyx_t_17);
                                  __pyx_cur_scope->__pyx_t_9 = __pyx_t_17;
                                  __Pyx_XGIVEREF(__pyx_t_18);
                                  __pyx_cur_scope->__pyx_t_10 = __pyx_t_18;
                                  __Pyx_XGIVEREF(__pyx_t_20);
                                  __pyx_cur_scope->__pyx_t_11 = __pyx_t_20;
                                  __Pyx_XGIVEREF(__pyx_t_21);
                                  __pyx_cur_scope->__pyx_t_12 = __pyx_t_21;
                                  __Pyx_XGIVEREF(__pyx_t_22);
                                  __pyx_cur_scope->__pyx_t_13 = __pyx_t_22;
                                  __Pyx_XGIVEREF(__pyx_t_23);
                                  __pyx_cur_scope->__pyx_t_14 = __pyx_t_23;
                                  __Pyx_XGIVEREF(__pyx_t_37);
                                  __pyx_cur_scope->__pyx_t_15 = __pyx_t_37;
                                  __Pyx_XGIVEREF(__pyx_r);
                                  __Pyx_RefNannyFinishContext();
                                  __Pyx_Coroutine_SwapException(__pyx_generator);
                                  /* return from generator, awaiting value */
                                  __pyx_generator->resume_label = 48;
                                  return __pyx_r;
                                  __pyx_L625_resume_from_await:;
                                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                  __pyx_cur_scope->__pyx_t_0 = 0;
                                  __Pyx_XGOTREF(__pyx_t_1);
                                  __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                  __pyx_cur_scope->__pyx_t_1 = 0;
                                  __Pyx_XGOTREF(__pyx_t_2);
                                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                  __pyx_cur_scope->__pyx_t_2 = 0;
                                  __Pyx_XGOTREF(__pyx_t_3);
                                  __pyx_t_7 = __pyx_cur_scope->__pyx_t_3;
                                  __pyx_cur_scope->__pyx_t_3 = 0;
                                  __Pyx_XGOTREF(__pyx_t_7);
                                  __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                                  __pyx_cur_scope->__pyx_t_4 = 0;
                                  __Pyx_XGOTREF(__pyx_t_10);
                                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                                  __pyx_cur_scope->__pyx_t_5 = 0;
                                  __Pyx_XGOTREF(__pyx_t_12);
                                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                                  __pyx_cur_scope->__pyx_t_6 = 0;
                                  __Pyx_XGOTREF(__pyx_t_13);
                                  __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                                  __pyx_cur_scope->__pyx_t_7 = 0;
                                  __Pyx_XGOTREF(__pyx_t_14);
                                  __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                                  __pyx_cur_scope->__pyx_t_8 = 0;
                                  __Pyx_XGOTREF(__pyx_t_15);
                                  __pyx_t_17 = __pyx_cur_scope->__pyx_t_9;
                                  __pyx_cur_scope->__pyx_t_9 = 0;
                                  __Pyx_XGOTREF(__pyx_t_17);
                                  __pyx_t_18 = __pyx_cur_scope->__pyx_t_10;
                                  __pyx_cur_scope->__pyx_t_10 = 0;
                                  __Pyx_XGOTREF(__pyx_t_18);
                                  __pyx_t_20 = __pyx_cur_scope->__pyx_t_11;
                                  __pyx_cur_scope->__pyx_t_11 = 0;
                                  __Pyx_XGOTREF(__pyx_t_20);
                                  __pyx_t_21 = __pyx_cur_scope->__pyx_t_12;
                                  __pyx_cur_scope->__pyx_t_12 = 0;
                                  __Pyx_XGOTREF(__pyx_t_21);
                                  __pyx_t_22 = __pyx_cur_scope->__pyx_t_13;
                                  __pyx_cur_scope->__pyx_t_13 = 0;
                                  __Pyx_XGOTREF(__pyx_t_22);
                                  __pyx_t_23 = __pyx_cur_scope->__pyx_t_14;
                                  __pyx_cur_scope->__pyx_t_14 = 0;
                                  __Pyx_XGOTREF(__pyx_t_23);
                                  __pyx_t_37 = __pyx_cur_scope->__pyx_t_15;
                                  __pyx_cur_scope->__pyx_t_15 = 0;
                                  __Pyx_XGOTREF(__pyx_t_37);
                                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5518, __pyx_L615_error)
                                } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                                } else {
                                  __Pyx_XGOTREF(__pyx_r);
                                  __PYX_ERR(0, 5518, __pyx_L615_error)
                                }

                                /* "ws_package/controllers/activity_controller.py":5519
 *                                     if db_interval:
 *                                         await self.activity_service.update_activity_interval(db_interval)
 *                                         logger.info("Last interval (id=%s) explicitly updated after successful send (fallback)", last_interval_id)             # <<<<<<<<<<<<<<
 *                             except Exception as fallback_error:
 *                                 logger.error("Error in fallback update: %s", fallback_error, exc_info=True)
*/
                                __pyx_t_24 = NULL;
                                __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5519, __pyx_L615_error)
                                __Pyx_GOTREF(__pyx_t_5);
                                __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5519, __pyx_L615_error)
                                __Pyx_GOTREF(__pyx_t_4);
                                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                                __pyx_t_8 = 1;
                                #if CYTHON_UNPACK_METHODS
                                if (unlikely(PyMethod_Check(__pyx_t_4))) {
                                  __pyx_t_24 = PyMethod_GET_SELF(__pyx_t_4);
                                  assert(__pyx_t_24);
                                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                                  __Pyx_INCREF(__pyx_t_24);
                                  __Pyx_INCREF(__pyx__function);
                                  __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                                  __pyx_t_8 = 0;
                                }
                                #endif
                                {
                                  PyObject *__pyx_callargs[3] = {__pyx_t_24, __pyx_mstate_global->__pyx_kp_u_Last_interval_id_s_explicitly_up_2, __pyx_cur_scope->__pyx_v_last_interval_id};
                                  __pyx_t_25 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                  if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5519, __pyx_L615_error)
                                  __Pyx_GOTREF(__pyx_t_25);
                                }
                                __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;

                                /* "ws_package/controllers/activity_controller.py":5517
 *                                     result = await session.execute(query)
 *                                     db_interval = result.scalar_one_or_none()
 *                                     if db_interval:             # <<<<<<<<<<<<<<
 *                                         await self.activity_service.update_activity_interval(db_interval)
 *                                         logger.info("Last interval (id=%s) explicitly updated after successful send (fallback)", last_interval_id)
*/
                              }

                              /* "ws_package/controllers/activity_controller.py":5513
 *                             # Query database to get the interval object with ID
 *                             try:
 *                                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                                     query = select(ActivityInterval).where(ActivityInterval.id == last_interval_id)
 *                                     result = await session.execute(query)
*/
                            }
                            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                            __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                            __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                            goto __pyx_L622_try_end;
                            __pyx_L615_error:;
                            __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                            __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                            __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                            __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                            __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                            __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                            __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                            __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                            __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
                            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                            /*except:*/ {
                              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
                              if (__Pyx_GetException(&__pyx_t_25, &__pyx_t_4, &__pyx_t_24) < 0) __PYX_ERR(0, 5513, __pyx_L617_except_error)
                              __Pyx_XGOTREF(__pyx_t_25);
                              __Pyx_XGOTREF(__pyx_t_4);
                              __Pyx_XGOTREF(__pyx_t_24);
                              __pyx_t_5 = PyTuple_Pack(3, __pyx_t_25, __pyx_t_4, __pyx_t_24); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5513, __pyx_L617_except_error)
                              __Pyx_GOTREF(__pyx_t_5);
                              __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_18, __pyx_t_5, NULL);
                              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                              if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 5513, __pyx_L617_except_error)
                              __Pyx_GOTREF(__pyx_t_19);
                              __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_19, &__pyx_r);
                              __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                              if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                __Pyx_GOTREF(__pyx_r);
                                __Pyx_XGIVEREF(__pyx_t_1);
                                __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                __Pyx_XGIVEREF(__pyx_t_2);
                                __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                __Pyx_XGIVEREF(__pyx_t_3);
                                __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                __Pyx_XGIVEREF(__pyx_t_4);
                                __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
                                __Pyx_XGIVEREF(__pyx_t_7);
                                __pyx_cur_scope->__pyx_t_4 = __pyx_t_7;
                                __Pyx_XGIVEREF(__pyx_t_10);
                                __pyx_cur_scope->__pyx_t_5 = __pyx_t_10;
                                __Pyx_XGIVEREF(__pyx_t_12);
                                __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
                                __Pyx_XGIVEREF(__pyx_t_13);
                                __pyx_cur_scope->__pyx_t_7 = __pyx_t_13;
                                __Pyx_XGIVEREF(__pyx_t_14);
                                __pyx_cur_scope->__pyx_t_8 = __pyx_t_14;
                                __Pyx_XGIVEREF(__pyx_t_15);
                                __pyx_cur_scope->__pyx_t_9 = __pyx_t_15;
                                __Pyx_XGIVEREF(__pyx_t_17);
                                __pyx_cur_scope->__pyx_t_10 = __pyx_t_17;
                                __Pyx_XGIVEREF(__pyx_t_18);
                                __pyx_cur_scope->__pyx_t_11 = __pyx_t_18;
                                __Pyx_XGIVEREF(__pyx_t_19);
                                __pyx_cur_scope->__pyx_t_12 = __pyx_t_19;
                                __Pyx_XGIVEREF(__pyx_t_20);
                                __pyx_cur_scope->__pyx_t_13 = __pyx_t_20;
                                __Pyx_XGIVEREF(__pyx_t_21);
                                __pyx_cur_scope->__pyx_t_14 = __pyx_t_21;
                                __Pyx_XGIVEREF(__pyx_t_22);
                                __pyx_cur_scope->__pyx_t_15 = __pyx_t_22;
                                __Pyx_XGIVEREF(__pyx_t_23);
                                __pyx_cur_scope->__pyx_t_16 = __pyx_t_23;
                                __Pyx_XGIVEREF(__pyx_t_24);
                                __pyx_cur_scope->__pyx_t_17 = __pyx_t_24;
                                __Pyx_XGIVEREF(__pyx_t_25);
                                __pyx_cur_scope->__pyx_t_19 = __pyx_t_25;
                                __Pyx_XGIVEREF(__pyx_t_37);
                                __pyx_cur_scope->__pyx_t_20 = __pyx_t_37;
                                __Pyx_XGIVEREF(__pyx_r);
                                __Pyx_RefNannyFinishContext();
                                __Pyx_Coroutine_SwapException(__pyx_generator);
                                /* return from generator, awaiting value */
                                __pyx_generator->resume_label = 49;
                                return __pyx_r;
                                __pyx_L629_resume_from_await:;
                                __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                __pyx_cur_scope->__pyx_t_0 = 0;
                                __Pyx_XGOTREF(__pyx_t_1);
                                __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                __pyx_cur_scope->__pyx_t_1 = 0;
                                __Pyx_XGOTREF(__pyx_t_2);
                                __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                __pyx_cur_scope->__pyx_t_2 = 0;
                                __Pyx_XGOTREF(__pyx_t_3);
                                __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
                                __pyx_cur_scope->__pyx_t_3 = 0;
                                __Pyx_XGOTREF(__pyx_t_4);
                                __pyx_t_7 = __pyx_cur_scope->__pyx_t_4;
                                __pyx_cur_scope->__pyx_t_4 = 0;
                                __Pyx_XGOTREF(__pyx_t_7);
                                __pyx_t_10 = __pyx_cur_scope->__pyx_t_5;
                                __pyx_cur_scope->__pyx_t_5 = 0;
                                __Pyx_XGOTREF(__pyx_t_10);
                                __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
                                __pyx_cur_scope->__pyx_t_6 = 0;
                                __Pyx_XGOTREF(__pyx_t_12);
                                __pyx_t_13 = __pyx_cur_scope->__pyx_t_7;
                                __pyx_cur_scope->__pyx_t_7 = 0;
                                __Pyx_XGOTREF(__pyx_t_13);
                                __pyx_t_14 = __pyx_cur_scope->__pyx_t_8;
                                __pyx_cur_scope->__pyx_t_8 = 0;
                                __Pyx_XGOTREF(__pyx_t_14);
                                __pyx_t_15 = __pyx_cur_scope->__pyx_t_9;
                                __pyx_cur_scope->__pyx_t_9 = 0;
                                __Pyx_XGOTREF(__pyx_t_15);
                                __pyx_t_17 = __pyx_cur_scope->__pyx_t_10;
                                __pyx_cur_scope->__pyx_t_10 = 0;
                                __Pyx_XGOTREF(__pyx_t_17);
                                __pyx_t_18 = __pyx_cur_scope->__pyx_t_11;
                                __pyx_cur_scope->__pyx_t_11 = 0;
                                __Pyx_XGOTREF(__pyx_t_18);
                                __pyx_t_19 = __pyx_cur_scope->__pyx_t_12;
                                __pyx_cur_scope->__pyx_t_12 = 0;
                                __Pyx_XGOTREF(__pyx_t_19);
                                __pyx_t_20 = __pyx_cur_scope->__pyx_t_13;
                                __pyx_cur_scope->__pyx_t_13 = 0;
                                __Pyx_XGOTREF(__pyx_t_20);
                                __pyx_t_21 = __pyx_cur_scope->__pyx_t_14;
                                __pyx_cur_scope->__pyx_t_14 = 0;
                                __Pyx_XGOTREF(__pyx_t_21);
                                __pyx_t_22 = __pyx_cur_scope->__pyx_t_15;
                                __pyx_cur_scope->__pyx_t_15 = 0;
                                __Pyx_XGOTREF(__pyx_t_22);
                                __pyx_t_23 = __pyx_cur_scope->__pyx_t_16;
                                __pyx_cur_scope->__pyx_t_16 = 0;
                                __Pyx_XGOTREF(__pyx_t_23);
                                __pyx_t_24 = __pyx_cur_scope->__pyx_t_17;
                                __pyx_cur_scope->__pyx_t_17 = 0;
                                __Pyx_XGOTREF(__pyx_t_24);
                                __pyx_t_25 = __pyx_cur_scope->__pyx_t_19;
                                __pyx_cur_scope->__pyx_t_19 = 0;
                                __Pyx_XGOTREF(__pyx_t_25);
                                __pyx_t_37 = __pyx_cur_scope->__pyx_t_20;
                                __pyx_cur_scope->__pyx_t_20 = 0;
                                __Pyx_XGOTREF(__pyx_t_37);
                                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5513, __pyx_L617_except_error)
                                __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
                              } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                __Pyx_GOTREF(__pyx_r);
                                __pyx_t_5 = __pyx_r; __pyx_r = NULL;
                              } else {
                                __Pyx_XGOTREF(__pyx_r);
                                __PYX_ERR(0, 5513, __pyx_L617_except_error)
                              }
                              __pyx_t_19 = __pyx_t_5;
                              __pyx_t_5 = 0;
                              __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_19);
                              __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                              if (__pyx_t_28 < (0)) __PYX_ERR(0, 5513, __pyx_L617_except_error)
                              __pyx_t_47 = (!__pyx_t_28);
                              if (unlikely(__pyx_t_47)) {
                                __Pyx_GIVEREF(__pyx_t_25);
                                __Pyx_GIVEREF(__pyx_t_4);
                                __Pyx_XGIVEREF(__pyx_t_24);
                                __Pyx_ErrRestoreWithState(__pyx_t_25, __pyx_t_4, __pyx_t_24);
                                __pyx_t_25 = 0;  __pyx_t_4 = 0;  __pyx_t_24 = 0; 
                                __PYX_ERR(0, 5513, __pyx_L617_except_error)
                              }
                              __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                              goto __pyx_L616_exception_handled;
                            }
                            __pyx_L617_except_error:;
                            __Pyx_XGIVEREF(__pyx_t_20);
                            __Pyx_XGIVEREF(__pyx_t_21);
                            __Pyx_XGIVEREF(__pyx_t_22);
                            __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22);
                            goto __pyx_L600_error;
                            __pyx_L616_exception_handled:;
                            __Pyx_XGIVEREF(__pyx_t_20);
                            __Pyx_XGIVEREF(__pyx_t_21);
                            __Pyx_XGIVEREF(__pyx_t_22);
                            __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22);
                            __pyx_L622_try_end:;
                          }
                        }
                        /*finally:*/ {
                          /*normal exit:*/{
                            if (__pyx_t_18) {
                              __pyx_t_22 = __Pyx_PyObject_Call(__pyx_t_18, __pyx_mstate_global->__pyx_tuple[7], NULL);
                              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                              if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 5513, __pyx_L600_error)
                              __Pyx_GOTREF(__pyx_t_22);
                              __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_22, &__pyx_r);
                              __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                              if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                __Pyx_GOTREF(__pyx_r);
                                __Pyx_XGIVEREF(__pyx_t_1);
                                __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                __Pyx_XGIVEREF(__pyx_t_2);
                                __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                __Pyx_XGIVEREF(__pyx_t_3);
                                __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                __Pyx_XGIVEREF(__pyx_t_7);
                                __pyx_cur_scope->__pyx_t_3 = __pyx_t_7;
                                __Pyx_XGIVEREF(__pyx_t_10);
                                __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                                __Pyx_XGIVEREF(__pyx_t_12);
                                __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                                __Pyx_XGIVEREF(__pyx_t_13);
                                __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                                __Pyx_XGIVEREF(__pyx_t_14);
                                __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                                __Pyx_XGIVEREF(__pyx_t_15);
                                __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                                __Pyx_XGIVEREF(__pyx_t_17);
                                __pyx_cur_scope->__pyx_t_9 = __pyx_t_17;
                                __Pyx_XGIVEREF(__pyx_t_18);
                                __pyx_cur_scope->__pyx_t_10 = __pyx_t_18;
                                __Pyx_XGIVEREF(__pyx_t_22);
                                __pyx_cur_scope->__pyx_t_11 = __pyx_t_22;
                                __Pyx_XGIVEREF(__pyx_t_23);
                                __pyx_cur_scope->__pyx_t_12 = __pyx_t_23;
                                __Pyx_XGIVEREF(__pyx_t_37);
                                __pyx_cur_scope->__pyx_t_13 = __pyx_t_37;
                                __Pyx_XGIVEREF(__pyx_r);
                                __Pyx_RefNannyFinishContext();
                                __Pyx_Coroutine_SwapException(__pyx_generator);
                                /* return from generator, awaiting value */
                                __pyx_generator->resume_label = 50;
                                return __pyx_r;
                                __pyx_L630_resume_from_await:;
                                __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                __pyx_cur_scope->__pyx_t_0 = 0;
                                __Pyx_XGOTREF(__pyx_t_1);
                                __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                __pyx_cur_scope->__pyx_t_1 = 0;
                                __Pyx_XGOTREF(__pyx_t_2);
                                __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                __pyx_cur_scope->__pyx_t_2 = 0;
                                __Pyx_XGOTREF(__pyx_t_3);
                                __pyx_t_7 = __pyx_cur_scope->__pyx_t_3;
                                __pyx_cur_scope->__pyx_t_3 = 0;
                                __Pyx_XGOTREF(__pyx_t_7);
                                __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                                __pyx_cur_scope->__pyx_t_4 = 0;
                                __Pyx_XGOTREF(__pyx_t_10);
                                __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                                __pyx_cur_scope->__pyx_t_5 = 0;
                                __Pyx_XGOTREF(__pyx_t_12);
                                __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                                __pyx_cur_scope->__pyx_t_6 = 0;
                                __Pyx_XGOTREF(__pyx_t_13);
                                __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                                __pyx_cur_scope->__pyx_t_7 = 0;
                                __Pyx_XGOTREF(__pyx_t_14);
                                __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                                __pyx_cur_scope->__pyx_t_8 = 0;
                                __Pyx_XGOTREF(__pyx_t_15);
                                __pyx_t_17 = __pyx_cur_scope->__pyx_t_9;
                                __pyx_cur_scope->__pyx_t_9 = 0;
                                __Pyx_XGOTREF(__pyx_t_17);
                                __pyx_t_18 = __pyx_cur_scope->__pyx_t_10;
                                __pyx_cur_scope->__pyx_t_10 = 0;
                                __Pyx_XGOTREF(__pyx_t_18);
                                __pyx_t_22 = __pyx_cur_scope->__pyx_t_11;
                                __pyx_cur_scope->__pyx_t_11 = 0;
                                __Pyx_XGOTREF(__pyx_t_22);
                                __pyx_t_23 = __pyx_cur_scope->__pyx_t_12;
                                __pyx_cur_scope->__pyx_t_12 = 0;
                                __Pyx_XGOTREF(__pyx_t_23);
                                __pyx_t_37 = __pyx_cur_scope->__pyx_t_13;
                                __pyx_cur_scope->__pyx_t_13 = 0;
                                __Pyx_XGOTREF(__pyx_t_37);
                                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5513, __pyx_L600_error)
                                __pyx_t_24 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_24);
                              } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                __Pyx_GOTREF(__pyx_r);
                                __pyx_t_24 = __pyx_r; __pyx_r = NULL;
                              } else {
                                __Pyx_XGOTREF(__pyx_r);
                                __PYX_ERR(0, 5513, __pyx_L600_error)
                              }
                              __pyx_t_22 = __pyx_t_24;
                              __pyx_t_24 = 0;
                              __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                            }
                            goto __pyx_L614;
                          }
                          __pyx_L614:;
                        }
                        goto __pyx_L631;
                        __pyx_L608_error:;
                        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                        goto __pyx_L600_error;
                        __pyx_L631:;
                      }

                      /* "ws_package/controllers/activity_controller.py":5512
 *                         if last_interval_id:
 *                             # Query database to get the interval object with ID
 *                             try:             # <<<<<<<<<<<<<<
 *                                 async with async_session() as session:
 *                                     query = select(ActivityInterval).where(ActivityInterval.id == last_interval_id)
*/
                    }
                    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                    __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    goto __pyx_L607_try_end;
                    __pyx_L600_error:;
                    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                    __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                    __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                    __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                    __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                    __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                    __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;

                    /* "ws_package/controllers/activity_controller.py":5520
 *                                         await self.activity_service.update_activity_interval(db_interval)
 *                                         logger.info("Last interval (id=%s) explicitly updated after successful send (fallback)", last_interval_id)
 *                             except Exception as fallback_error:             # <<<<<<<<<<<<<<
 *                                 logger.error("Error in fallback update: %s", fallback_error, exc_info=True)
 *                     # Flush again to ensure this update is committed
*/
                    __pyx_t_32 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                    if (__pyx_t_32) {
                      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_24, &__pyx_t_4, &__pyx_t_25) < 0) __PYX_ERR(0, 5520, __pyx_L602_except_error)
                      __Pyx_XGOTREF(__pyx_t_24);
                      __Pyx_XGOTREF(__pyx_t_4);
                      __Pyx_XGOTREF(__pyx_t_25);
                      __Pyx_INCREF(__pyx_t_4);
                      __Pyx_GIVEREF(__pyx_t_4);
                      __pyx_cur_scope->__pyx_v_fallback_error = __pyx_t_4;
                      /*try:*/ {

                        /* "ws_package/controllers/activity_controller.py":5521
 *                                         logger.info("Last interval (id=%s) explicitly updated after successful send (fallback)", last_interval_id)
 *                             except Exception as fallback_error:
 *                                 logger.error("Error in fallback update: %s", fallback_error, exc_info=True)             # <<<<<<<<<<<<<<
 *                     # Flush again to ensure this update is committed
 *                     try:
*/
                        __pyx_t_26 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_52, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5521, __pyx_L637_error)
                        __Pyx_GOTREF(__pyx_t_52);
                        __pyx_t_40 = __Pyx_PyObject_GetAttrStr(__pyx_t_52, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_40)) __PYX_ERR(0, 5521, __pyx_L637_error)
                        __Pyx_GOTREF(__pyx_t_40);
                        __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
                        __pyx_t_8 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_40))) {
                          __pyx_t_26 = PyMethod_GET_SELF(__pyx_t_40);
                          assert(__pyx_t_26);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_40);
                          __Pyx_INCREF(__pyx_t_26);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_40, __pyx__function);
                          __pyx_t_8 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_26, __pyx_mstate_global->__pyx_kp_u_Error_in_fallback_update_s, __pyx_cur_scope->__pyx_v_fallback_error};
                          __pyx_t_52 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5521, __pyx_L637_error)
                          __Pyx_GOTREF(__pyx_t_52);
                          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_52, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 5521, __pyx_L637_error)
                          __pyx_t_5 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_40, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_52);
                          __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                          __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
                          __Pyx_DECREF(__pyx_t_40); __pyx_t_40 = 0;
                          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5521, __pyx_L637_error)
                          __Pyx_GOTREF(__pyx_t_5);
                        }
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      }

                      /* "ws_package/controllers/activity_controller.py":5520
 *                                         await self.activity_service.update_activity_interval(db_interval)
 *                                         logger.info("Last interval (id=%s) explicitly updated after successful send (fallback)", last_interval_id)
 *                             except Exception as fallback_error:             # <<<<<<<<<<<<<<
 *                                 logger.error("Error in fallback update: %s", fallback_error, exc_info=True)
 *                     # Flush again to ensure this update is committed
*/
                      /*finally:*/ {
                        /*normal exit:*/{
                          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_fallback_error);
                          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_fallback_error); __pyx_cur_scope->__pyx_v_fallback_error = 0;
                          goto __pyx_L638;
                        }
                        __pyx_L637_error:;
                        /*exception exit:*/{
                          __Pyx_PyThreadState_assign
                          __pyx_t_18 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_16 = 0;
                          __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                          __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                          __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                          __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                          __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                          __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                          __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
                          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                           __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_19, &__pyx_t_16);
                          if ( unlikely(__Pyx_GetException(&__pyx_t_18, &__pyx_t_22, &__pyx_t_21) < 0)) __Pyx_ErrFetch(&__pyx_t_18, &__pyx_t_22, &__pyx_t_21);
                          __Pyx_XGOTREF(__pyx_t_18);
                          __Pyx_XGOTREF(__pyx_t_22);
                          __Pyx_XGOTREF(__pyx_t_21);
                          __Pyx_XGOTREF(__pyx_t_20);
                          __Pyx_XGOTREF(__pyx_t_19);
                          __Pyx_XGOTREF(__pyx_t_16);
                          __pyx_t_32 = __pyx_lineno; __pyx_t_31 = __pyx_clineno; __pyx_t_58 = __pyx_filename;
                          {
                            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_fallback_error);
                            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_fallback_error); __pyx_cur_scope->__pyx_v_fallback_error = 0;
                          }
                          __Pyx_XGIVEREF(__pyx_t_20);
                          __Pyx_XGIVEREF(__pyx_t_19);
                          __Pyx_XGIVEREF(__pyx_t_16);
                          __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_19, __pyx_t_16);
                          __Pyx_XGIVEREF(__pyx_t_18);
                          __Pyx_XGIVEREF(__pyx_t_22);
                          __Pyx_XGIVEREF(__pyx_t_21);
                          __Pyx_ErrRestore(__pyx_t_18, __pyx_t_22, __pyx_t_21);
                          __pyx_t_18 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_16 = 0;
                          __pyx_lineno = __pyx_t_32; __pyx_clineno = __pyx_t_31; __pyx_filename = __pyx_t_58;
                          goto __pyx_L602_except_error;
                        }
                        __pyx_L638:;
                      }
                      __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                      goto __pyx_L601_exception_handled;
                    }
                    goto __pyx_L602_except_error;

                    /* "ws_package/controllers/activity_controller.py":5512
 *                         if last_interval_id:
 *                             # Query database to get the interval object with ID
 *                             try:             # <<<<<<<<<<<<<<
 *                                 async with async_session() as session:
 *                                     query = select(ActivityInterval).where(ActivityInterval.id == last_interval_id)
*/
                    __pyx_L602_except_error:;
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_XGIVEREF(__pyx_t_37);
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_37, __pyx_t_15);
                    goto __pyx_L597_error;
                    __pyx_L601_exception_handled:;
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_XGIVEREF(__pyx_t_37);
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_37, __pyx_t_15);
                    __pyx_L607_try_end:;
                  }

                  /* "ws_package/controllers/activity_controller.py":5510
 *                         logger.error("Error querying database for last interval: %s", e, exc_info=True)
 *                         # Fallback: try to update if we have an ID
 *                         if last_interval_id:             # <<<<<<<<<<<<<<
 *                             # Query database to get the interval object with ID
 *                             try:
*/
                }
              }

              /* "ws_package/controllers/activity_controller.py":5507
 *                         elif st is not None and et is not None:
 *                             logger.warning("Could not find database record for last interval to update")
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error querying database for last interval: %s", e, exc_info=True)
 *                         # Fallback: try to update if we have an ID
*/
              /*finally:*/ {
                /*normal exit:*/{
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  goto __pyx_L598;
                }
                __pyx_L597_error:;
                /*exception exit:*/{
                  __Pyx_PyThreadState_assign
                  __pyx_t_15 = 0; __pyx_t_37 = 0; __pyx_t_17 = 0; __pyx_t_16 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
                  __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                  __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                  __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                  __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                  __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                  __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                   __Pyx_ExceptionSwap(&__pyx_t_16, &__pyx_t_19, &__pyx_t_20);
                  if ( unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_37, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_37, &__pyx_t_17);
                  __Pyx_XGOTREF(__pyx_t_15);
                  __Pyx_XGOTREF(__pyx_t_37);
                  __Pyx_XGOTREF(__pyx_t_17);
                  __Pyx_XGOTREF(__pyx_t_16);
                  __Pyx_XGOTREF(__pyx_t_19);
                  __Pyx_XGOTREF(__pyx_t_20);
                  __pyx_t_31 = __pyx_lineno; __pyx_t_32 = __pyx_clineno; __pyx_t_59 = __pyx_filename;
                  {
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  }
                  __Pyx_XGIVEREF(__pyx_t_16);
                  __Pyx_XGIVEREF(__pyx_t_19);
                  __Pyx_XGIVEREF(__pyx_t_20);
                  __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_19, __pyx_t_20);
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __Pyx_XGIVEREF(__pyx_t_37);
                  __Pyx_XGIVEREF(__pyx_t_17);
                  __Pyx_ErrRestore(__pyx_t_15, __pyx_t_37, __pyx_t_17);
                  __pyx_t_15 = 0; __pyx_t_37 = 0; __pyx_t_17 = 0; __pyx_t_16 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
                  __pyx_lineno = __pyx_t_31; __pyx_clineno = __pyx_t_32; __pyx_filename = __pyx_t_59;
                  goto __pyx_L547_except_error;
                }
                __pyx_L598:;
              }
              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
              goto __pyx_L546_exception_handled;
            }
            goto __pyx_L547_except_error;

            /* "ws_package/controllers/activity_controller.py":5483
 *                 if last_interval_was_sent:
 *                     # Query database to get the actual record with ID (use tolerance for datetime precision)
 *                     try:             # <<<<<<<<<<<<<<
 *                         st = getattr(last_interval, 'start_time', None)
 *                         et = getattr(last_interval, 'end_time', None)
*/
            __pyx_L547_except_error:;
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
            goto __pyx_L4_error;
            __pyx_L546_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
            __pyx_L550_try_end:;
          }

          /* "ws_package/controllers/activity_controller.py":5523
 *                                 logger.error("Error in fallback update: %s", fallback_error, exc_info=True)
 *                     # Flush again to ensure this update is committed
 *                     try:             # <<<<<<<<<<<<<<
 *                         processed_count = await db_writer_service.process_immediately()
 *                         logger.info("Flushed %s queued database updates after last interval update", processed_count)
*/
          {
            __Pyx_ExceptionSave(&__pyx_t_14, &__pyx_t_13, &__pyx_t_12);
            __Pyx_XGOTREF(__pyx_t_14);
            __Pyx_XGOTREF(__pyx_t_13);
            __Pyx_XGOTREF(__pyx_t_12);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":5524
 *                     # Flush again to ensure this update is committed
 *                     try:
 *                         processed_count = await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 *                         logger.info("Flushed %s queued database updates after last interval update", processed_count)
 *                         # Small delay to ensure SQLite transaction is visible
*/
              __pyx_t_23 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5524, __pyx_L647_error)
              __Pyx_GOTREF(__pyx_t_7);
              __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5524, __pyx_L647_error)
              __Pyx_GOTREF(__pyx_t_25);
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_25))) {
                __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_25);
                assert(__pyx_t_23);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_25);
                __Pyx_INCREF(__pyx_t_23);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_25, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_23, NULL};
                __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_25, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5524, __pyx_L647_error)
                __Pyx_GOTREF(__pyx_t_10);
              }
              __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_10, &__pyx_r);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_XGIVEREF(__pyx_t_1);
                __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                __Pyx_XGIVEREF(__pyx_t_2);
                __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                __Pyx_XGIVEREF(__pyx_t_3);
                __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                __Pyx_XGIVEREF(__pyx_t_12);
                __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                __Pyx_XGIVEREF(__pyx_t_13);
                __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                __Pyx_XGIVEREF(__pyx_t_14);
                __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                __Pyx_XGIVEREF(__pyx_r);
                __Pyx_RefNannyFinishContext();
                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                /* return from generator, awaiting value */
                __pyx_generator->resume_label = 51;
                return __pyx_r;
                __pyx_L653_resume_from_await:;
                __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                __pyx_cur_scope->__pyx_t_0 = 0;
                __Pyx_XGOTREF(__pyx_t_1);
                __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                __pyx_cur_scope->__pyx_t_1 = 0;
                __Pyx_XGOTREF(__pyx_t_2);
                __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                __pyx_cur_scope->__pyx_t_2 = 0;
                __Pyx_XGOTREF(__pyx_t_3);
                __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                __pyx_cur_scope->__pyx_t_3 = 0;
                __Pyx_XGOTREF(__pyx_t_12);
                __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                __pyx_cur_scope->__pyx_t_4 = 0;
                __Pyx_XGOTREF(__pyx_t_13);
                __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                __pyx_cur_scope->__pyx_t_5 = 0;
                __Pyx_XGOTREF(__pyx_t_14);
                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5524, __pyx_L647_error)
                __pyx_t_10 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_10);
              } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                __Pyx_GOTREF(__pyx_r);
                __pyx_t_10 = __pyx_r; __pyx_r = NULL;
              } else {
                __Pyx_XGOTREF(__pyx_r);
                __PYX_ERR(0, 5524, __pyx_L647_error)
              }
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_processed_count);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_processed_count, __pyx_t_10);
              __Pyx_GIVEREF(__pyx_t_10);
              __pyx_t_10 = 0;

              /* "ws_package/controllers/activity_controller.py":5525
 *                     try:
 *                         processed_count = await db_writer_service.process_immediately()
 *                         logger.info("Flushed %s queued database updates after last interval update", processed_count)             # <<<<<<<<<<<<<<
 *                         # Small delay to ensure SQLite transaction is visible
 *                         if processed_count > 0:
*/
              __pyx_t_25 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5525, __pyx_L647_error)
              __Pyx_GOTREF(__pyx_t_23);
              __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5525, __pyx_L647_error)
              __Pyx_GOTREF(__pyx_t_7);
              __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_7))) {
                __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_7);
                assert(__pyx_t_25);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                __Pyx_INCREF(__pyx_t_25);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_25, __pyx_mstate_global->__pyx_kp_u_Flushed_s_queued_database_update, __pyx_cur_scope->__pyx_v_processed_count};
                __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5525, __pyx_L647_error)
                __Pyx_GOTREF(__pyx_t_10);
              }
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

              /* "ws_package/controllers/activity_controller.py":5527
 *                         logger.info("Flushed %s queued database updates after last interval update", processed_count)
 *                         # Small delay to ensure SQLite transaction is visible
 *                         if processed_count > 0:             # <<<<<<<<<<<<<<
 *                             await asyncio.sleep(0.3)
 *                             logger.debug("Verified last interval update is committed to database")
*/
              __pyx_t_10 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_processed_count, __pyx_mstate_global->__pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5527, __pyx_L647_error)
              __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5527, __pyx_L647_error)
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (__pyx_t_47) {

                /* "ws_package/controllers/activity_controller.py":5528
 *                         # Small delay to ensure SQLite transaction is visible
 *                         if processed_count > 0:
 *                             await asyncio.sleep(0.3)             # <<<<<<<<<<<<<<
 *                             logger.debug("Verified last interval update is committed to database")
 *                     except Exception as e:
*/
                __pyx_t_7 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5528, __pyx_L647_error)
                __Pyx_GOTREF(__pyx_t_25);
                __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5528, __pyx_L647_error)
                __Pyx_GOTREF(__pyx_t_23);
                __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_23))) {
                  __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_23);
                  assert(__pyx_t_7);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_23);
                  __Pyx_INCREF(__pyx_t_7);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_23, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_mstate_global->__pyx_float_0_3};
                  __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_23, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                  __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                  if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5528, __pyx_L647_error)
                  __Pyx_GOTREF(__pyx_t_10);
                }
                __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_10, &__pyx_r);
                __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_1);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                  __Pyx_XGIVEREF(__pyx_t_2);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                  __Pyx_XGIVEREF(__pyx_t_3);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_t_14);
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 52;
                  return __pyx_r;
                  __pyx_L655_resume_from_await:;
                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_1);
                  __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_2);
                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_3);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = 0;
                  __Pyx_XGOTREF(__pyx_t_14);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5528, __pyx_L647_error)
                } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 5528, __pyx_L647_error)
                }

                /* "ws_package/controllers/activity_controller.py":5529
 *                         if processed_count > 0:
 *                             await asyncio.sleep(0.3)
 *                             logger.debug("Verified last interval update is committed to database")             # <<<<<<<<<<<<<<
 *                     except Exception as e:
 *                         logger.error("Error flushing database write queue after last interval update: %s", e, exc_info=True)
*/
                __pyx_t_23 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5529, __pyx_L647_error)
                __Pyx_GOTREF(__pyx_t_7);
                __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5529, __pyx_L647_error)
                __Pyx_GOTREF(__pyx_t_25);
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_25))) {
                  __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_25);
                  assert(__pyx_t_23);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_25);
                  __Pyx_INCREF(__pyx_t_23);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_25, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_23, __pyx_mstate_global->__pyx_kp_u_Verified_last_interval_update_is};
                  __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_25, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                  __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                  if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5529, __pyx_L647_error)
                  __Pyx_GOTREF(__pyx_t_10);
                }
                __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

                /* "ws_package/controllers/activity_controller.py":5527
 *                         logger.info("Flushed %s queued database updates after last interval update", processed_count)
 *                         # Small delay to ensure SQLite transaction is visible
 *                         if processed_count > 0:             # <<<<<<<<<<<<<<
 *                             await asyncio.sleep(0.3)
 *                             logger.debug("Verified last interval update is committed to database")
*/
              }

              /* "ws_package/controllers/activity_controller.py":5523
 *                                 logger.error("Error in fallback update: %s", fallback_error, exc_info=True)
 *                     # Flush again to ensure this update is committed
 *                     try:             # <<<<<<<<<<<<<<
 *                         processed_count = await db_writer_service.process_immediately()
 *                         logger.info("Flushed %s queued database updates after last interval update", processed_count)
*/
            }
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            goto __pyx_L652_try_end;
            __pyx_L647_error:;
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
            __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
            __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
            __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
            __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
            __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
            __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

            /* "ws_package/controllers/activity_controller.py":5530
 *                             await asyncio.sleep(0.3)
 *                             logger.debug("Verified last interval update is committed to database")
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error flushing database write queue after last interval update: %s", e, exc_info=True)
 *                     # Delete last interval screenshots now that is_uploaded is committed (they were not deleted in the loop)
*/
            __pyx_t_32 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
            if (__pyx_t_32) {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_10, &__pyx_t_25, &__pyx_t_23) < 0) __PYX_ERR(0, 5530, __pyx_L649_except_error)
              __Pyx_XGOTREF(__pyx_t_10);
              __Pyx_XGOTREF(__pyx_t_25);
              __Pyx_XGOTREF(__pyx_t_23);
              __Pyx_INCREF(__pyx_t_25);
              __Pyx_GIVEREF(__pyx_t_25);
              __pyx_cur_scope->__pyx_v_e = __pyx_t_25;
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":5531
 *                             logger.debug("Verified last interval update is committed to database")
 *                     except Exception as e:
 *                         logger.error("Error flushing database write queue after last interval update: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 *                     # Delete last interval screenshots now that is_uploaded is committed (they were not deleted in the loop)
 *                     try:
*/
                __pyx_t_4 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5531, __pyx_L661_error)
                __Pyx_GOTREF(__pyx_t_24);
                __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5531, __pyx_L661_error)
                __Pyx_GOTREF(__pyx_t_5);
                __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_5))) {
                  __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
                  assert(__pyx_t_4);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                  __Pyx_INCREF(__pyx_t_4);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Error_flushing_database_write_qu_5, __pyx_cur_scope->__pyx_v_e};
                  __pyx_t_24 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5531, __pyx_L661_error)
                  __Pyx_GOTREF(__pyx_t_24);
                  if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_24, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 5531, __pyx_L661_error)
                  __pyx_t_7 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_24);
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5531, __pyx_L661_error)
                  __Pyx_GOTREF(__pyx_t_7);
                }
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              }

              /* "ws_package/controllers/activity_controller.py":5530
 *                             await asyncio.sleep(0.3)
 *                             logger.debug("Verified last interval update is committed to database")
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error flushing database write queue after last interval update: %s", e, exc_info=True)
 *                     # Delete last interval screenshots now that is_uploaded is committed (they were not deleted in the loop)
*/
              /*finally:*/ {
                /*normal exit:*/{
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  goto __pyx_L662;
                }
                __pyx_L661_error:;
                /*exception exit:*/{
                  __Pyx_PyThreadState_assign
                  __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_37 = 0; __pyx_t_15 = 0;
                  __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                  __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                  __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                  __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                  __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                  __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                   __Pyx_ExceptionSwap(&__pyx_t_17, &__pyx_t_37, &__pyx_t_15);
                  if ( unlikely(__Pyx_GetException(&__pyx_t_20, &__pyx_t_19, &__pyx_t_16) < 0)) __Pyx_ErrFetch(&__pyx_t_20, &__pyx_t_19, &__pyx_t_16);
                  __Pyx_XGOTREF(__pyx_t_20);
                  __Pyx_XGOTREF(__pyx_t_19);
                  __Pyx_XGOTREF(__pyx_t_16);
                  __Pyx_XGOTREF(__pyx_t_17);
                  __Pyx_XGOTREF(__pyx_t_37);
                  __Pyx_XGOTREF(__pyx_t_15);
                  __pyx_t_32 = __pyx_lineno; __pyx_t_31 = __pyx_clineno; __pyx_t_60 = __pyx_filename;
                  {
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  }
                  __Pyx_XGIVEREF(__pyx_t_17);
                  __Pyx_XGIVEREF(__pyx_t_37);
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_37, __pyx_t_15);
                  __Pyx_XGIVEREF(__pyx_t_20);
                  __Pyx_XGIVEREF(__pyx_t_19);
                  __Pyx_XGIVEREF(__pyx_t_16);
                  __Pyx_ErrRestore(__pyx_t_20, __pyx_t_19, __pyx_t_16);
                  __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_37 = 0; __pyx_t_15 = 0;
                  __pyx_lineno = __pyx_t_32; __pyx_clineno = __pyx_t_31; __pyx_filename = __pyx_t_60;
                  goto __pyx_L649_except_error;
                }
                __pyx_L662:;
              }
              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              goto __pyx_L648_exception_handled;
            }
            goto __pyx_L649_except_error;

            /* "ws_package/controllers/activity_controller.py":5523
 *                                 logger.error("Error in fallback update: %s", fallback_error, exc_info=True)
 *                     # Flush again to ensure this update is committed
 *                     try:             # <<<<<<<<<<<<<<
 *                         processed_count = await db_writer_service.process_immediately()
 *                         logger.info("Flushed %s queued database updates after last interval update", processed_count)
*/
            __pyx_L649_except_error:;
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12);
            goto __pyx_L4_error;
            __pyx_L648_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12);
            __pyx_L652_try_end:;
          }

          /* "ws_package/controllers/activity_controller.py":5533
 *                         logger.error("Error flushing database write queue after last interval update: %s", e, exc_info=True)
 *                     # Delete last interval screenshots now that is_uploaded is committed (they were not deleted in the loop)
 *                     try:             # <<<<<<<<<<<<<<
 *                         st = getattr(last_interval, 'start_time', None)
 *                         et = getattr(last_interval, 'end_time', None)
*/
          {
            __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
            __Pyx_XGOTREF(__pyx_t_12);
            __Pyx_XGOTREF(__pyx_t_13);
            __Pyx_XGOTREF(__pyx_t_14);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":5534
 *                     # Delete last interval screenshots now that is_uploaded is committed (they were not deleted in the loop)
 *                     try:
 *                         st = getattr(last_interval, 'start_time', None)             # <<<<<<<<<<<<<<
 *                         et = getattr(last_interval, 'end_time', None)
 *                         if st is not None and et is not None:
*/
              __pyx_t_23 = __pyx_cur_scope->__pyx_v_last_interval;
              __Pyx_INCREF(__pyx_t_23);
              __pyx_t_25 = __Pyx_GetAttr3(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_start_time, Py_None); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5534, __pyx_L667_error)
              __Pyx_GOTREF(__pyx_t_25);
              __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_st);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_st, __pyx_t_25);
              __Pyx_GIVEREF(__pyx_t_25);
              __pyx_t_25 = 0;

              /* "ws_package/controllers/activity_controller.py":5535
 *                     try:
 *                         st = getattr(last_interval, 'start_time', None)
 *                         et = getattr(last_interval, 'end_time', None)             # <<<<<<<<<<<<<<
 *                         if st is not None and et is not None:
 *                             last_ss_urls = await self.activity_service.get_screenshots(st, et)
*/
              __pyx_t_25 = __pyx_cur_scope->__pyx_v_last_interval;
              __Pyx_INCREF(__pyx_t_25);
              __pyx_t_23 = __Pyx_GetAttr3(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_end_time, Py_None); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5535, __pyx_L667_error)
              __Pyx_GOTREF(__pyx_t_23);
              __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_et);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_et, __pyx_t_23);
              __Pyx_GIVEREF(__pyx_t_23);
              __pyx_t_23 = 0;

              /* "ws_package/controllers/activity_controller.py":5536
 *                         st = getattr(last_interval, 'start_time', None)
 *                         et = getattr(last_interval, 'end_time', None)
 *                         if st is not None and et is not None:             # <<<<<<<<<<<<<<
 *                             last_ss_urls = await self.activity_service.get_screenshots(st, et)
 *                             if last_ss_urls:
*/
              __pyx_t_28 = (__pyx_cur_scope->__pyx_v_st != Py_None);
              if (__pyx_t_28) {
              } else {
                __pyx_t_47 = __pyx_t_28;
                goto __pyx_L674_bool_binop_done;
              }
              __pyx_t_28 = (__pyx_cur_scope->__pyx_v_et != Py_None);
              __pyx_t_47 = __pyx_t_28;
              __pyx_L674_bool_binop_done:;
              if (__pyx_t_47) {

                /* "ws_package/controllers/activity_controller.py":5537
 *                         et = getattr(last_interval, 'end_time', None)
 *                         if st is not None and et is not None:
 *                             last_ss_urls = await self.activity_service.get_screenshots(st, et)             # <<<<<<<<<<<<<<
 *                             if last_ss_urls:
 *                                 await self.screenshot_controller.update_screenshots(last_ss_urls, self.last_count + 1)
*/
                __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5537, __pyx_L667_error)
                __Pyx_GOTREF(__pyx_t_10);
                __pyx_t_25 = __pyx_t_10;
                __Pyx_INCREF(__pyx_t_25);
                __pyx_t_8 = 0;
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_25, __pyx_cur_scope->__pyx_v_st, __pyx_cur_scope->__pyx_v_et};
                  __pyx_t_23 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_screenshots, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                  if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5537, __pyx_L667_error)
                  __Pyx_GOTREF(__pyx_t_23);
                }
                __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_23, &__pyx_r);
                __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_1);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                  __Pyx_XGIVEREF(__pyx_t_2);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                  __Pyx_XGIVEREF(__pyx_t_3);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_t_14);
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 53;
                  return __pyx_r;
                  __pyx_L676_resume_from_await:;
                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_1);
                  __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_2);
                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_3);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = 0;
                  __Pyx_XGOTREF(__pyx_t_14);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5537, __pyx_L667_error)
                  __pyx_t_23 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_23);
                } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __pyx_t_23 = __pyx_r; __pyx_r = NULL;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 5537, __pyx_L667_error)
                }
                __Pyx_GIVEREF(__pyx_t_23);
                __pyx_cur_scope->__pyx_v_last_ss_urls = __pyx_t_23;
                __pyx_t_23 = 0;

                /* "ws_package/controllers/activity_controller.py":5538
 *                         if st is not None and et is not None:
 *                             last_ss_urls = await self.activity_service.get_screenshots(st, et)
 *                             if last_ss_urls:             # <<<<<<<<<<<<<<
 *                                 await self.screenshot_controller.update_screenshots(last_ss_urls, self.last_count + 1)
 *                                 logger.info("Last interval screenshots updated/deleted after explicit interval update (count=%s)", len(last_ss_urls))
*/
                __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_ss_urls); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5538, __pyx_L667_error)
                if (__pyx_t_47) {

                  /* "ws_package/controllers/activity_controller.py":5539
 *                             last_ss_urls = await self.activity_service.get_screenshots(st, et)
 *                             if last_ss_urls:
 *                                 await self.screenshot_controller.update_screenshots(last_ss_urls, self.last_count + 1)             # <<<<<<<<<<<<<<
 *                                 logger.info("Last interval screenshots updated/deleted after explicit interval update (count=%s)", len(last_ss_urls))
 *                     except Exception as e:
*/
                  __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5539, __pyx_L667_error)
                  __Pyx_GOTREF(__pyx_t_25);
                  __pyx_t_10 = __pyx_t_25;
                  __Pyx_INCREF(__pyx_t_10);
                  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5539, __pyx_L667_error)
                  __Pyx_GOTREF(__pyx_t_7);
                  __pyx_t_5 = __Pyx_PyLong_AddObjC(__pyx_t_7, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5539, __pyx_L667_error)
                  __Pyx_GOTREF(__pyx_t_5);
                  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                  __pyx_t_8 = 0;
                  {
                    PyObject *__pyx_callargs[3] = {__pyx_t_10, __pyx_cur_scope->__pyx_v_last_ss_urls, __pyx_t_5};
                    __pyx_t_23 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_update_screenshots, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                    if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5539, __pyx_L667_error)
                    __Pyx_GOTREF(__pyx_t_23);
                  }
                  __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_23, &__pyx_r);
                  __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                  if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_XGIVEREF(__pyx_t_1);
                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                    __Pyx_XGIVEREF(__pyx_t_2);
                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                    __Pyx_XGIVEREF(__pyx_t_3);
                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                    __Pyx_XGIVEREF(__pyx_t_12);
                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                    __Pyx_XGIVEREF(__pyx_t_13);
                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                    __Pyx_XGIVEREF(__pyx_t_14);
                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                    __Pyx_XGIVEREF(__pyx_r);
                    __Pyx_RefNannyFinishContext();
                    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                    /* return from generator, awaiting value */
                    __pyx_generator->resume_label = 54;
                    return __pyx_r;
                    __pyx_L678_resume_from_await:;
                    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                    __pyx_cur_scope->__pyx_t_0 = 0;
                    __Pyx_XGOTREF(__pyx_t_1);
                    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                    __pyx_cur_scope->__pyx_t_1 = 0;
                    __Pyx_XGOTREF(__pyx_t_2);
                    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                    __pyx_cur_scope->__pyx_t_2 = 0;
                    __Pyx_XGOTREF(__pyx_t_3);
                    __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                    __pyx_cur_scope->__pyx_t_3 = 0;
                    __Pyx_XGOTREF(__pyx_t_12);
                    __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                    __pyx_cur_scope->__pyx_t_4 = 0;
                    __Pyx_XGOTREF(__pyx_t_13);
                    __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                    __pyx_cur_scope->__pyx_t_5 = 0;
                    __Pyx_XGOTREF(__pyx_t_14);
                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5539, __pyx_L667_error)
                  } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                  } else {
                    __Pyx_XGOTREF(__pyx_r);
                    __PYX_ERR(0, 5539, __pyx_L667_error)
                  }

                  /* "ws_package/controllers/activity_controller.py":5540
 *                             if last_ss_urls:
 *                                 await self.screenshot_controller.update_screenshots(last_ss_urls, self.last_count + 1)
 *                                 logger.info("Last interval screenshots updated/deleted after explicit interval update (count=%s)", len(last_ss_urls))             # <<<<<<<<<<<<<<
 *                     except Exception as e:
 *                         logger.warning("Could not delete last interval screenshots after explicit update: %s", e)
*/
                  __pyx_t_25 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5540, __pyx_L667_error)
                  __Pyx_GOTREF(__pyx_t_5);
                  __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5540, __pyx_L667_error)
                  __Pyx_GOTREF(__pyx_t_10);
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __pyx_t_45 = PyObject_Length(__pyx_cur_scope->__pyx_v_last_ss_urls); if (unlikely(__pyx_t_45 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5540, __pyx_L667_error)
                  __pyx_t_5 = PyLong_FromSsize_t(__pyx_t_45); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5540, __pyx_L667_error)
                  __Pyx_GOTREF(__pyx_t_5);
                  __pyx_t_8 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_10))) {
                    __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_10);
                    assert(__pyx_t_25);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
                    __Pyx_INCREF(__pyx_t_25);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
                    __pyx_t_8 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[3] = {__pyx_t_25, __pyx_mstate_global->__pyx_kp_u_Last_interval_screenshots_update, __pyx_t_5};
                    __pyx_t_23 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                    if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5540, __pyx_L667_error)
                    __Pyx_GOTREF(__pyx_t_23);
                  }
                  __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

                  /* "ws_package/controllers/activity_controller.py":5538
 *                         if st is not None and et is not None:
 *                             last_ss_urls = await self.activity_service.get_screenshots(st, et)
 *                             if last_ss_urls:             # <<<<<<<<<<<<<<
 *                                 await self.screenshot_controller.update_screenshots(last_ss_urls, self.last_count + 1)
 *                                 logger.info("Last interval screenshots updated/deleted after explicit interval update (count=%s)", len(last_ss_urls))
*/
                }

                /* "ws_package/controllers/activity_controller.py":5536
 *                         st = getattr(last_interval, 'start_time', None)
 *                         et = getattr(last_interval, 'end_time', None)
 *                         if st is not None and et is not None:             # <<<<<<<<<<<<<<
 *                             last_ss_urls = await self.activity_service.get_screenshots(st, et)
 *                             if last_ss_urls:
*/
              }

              /* "ws_package/controllers/activity_controller.py":5533
 *                         logger.error("Error flushing database write queue after last interval update: %s", e, exc_info=True)
 *                     # Delete last interval screenshots now that is_uploaded is committed (they were not deleted in the loop)
 *                     try:             # <<<<<<<<<<<<<<
 *                         st = getattr(last_interval, 'start_time', None)
 *                         et = getattr(last_interval, 'end_time', None)
*/
            }
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            goto __pyx_L672_try_end;
            __pyx_L667_error:;
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
            __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
            __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
            __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
            __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
            __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
            __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

            /* "ws_package/controllers/activity_controller.py":5541
 *                                 await self.screenshot_controller.update_screenshots(last_ss_urls, self.last_count + 1)
 *                                 logger.info("Last interval screenshots updated/deleted after explicit interval update (count=%s)", len(last_ss_urls))
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.warning("Could not delete last interval screenshots after explicit update: %s", e)
 *                 else:
*/
            __pyx_t_31 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
            if (__pyx_t_31) {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_23, &__pyx_t_10, &__pyx_t_5) < 0) __PYX_ERR(0, 5541, __pyx_L669_except_error)
              __Pyx_XGOTREF(__pyx_t_23);
              __Pyx_XGOTREF(__pyx_t_10);
              __Pyx_XGOTREF(__pyx_t_5);
              __Pyx_INCREF(__pyx_t_10);
              __Pyx_GIVEREF(__pyx_t_10);
              __pyx_cur_scope->__pyx_v_e = __pyx_t_10;
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":5542
 *                                 logger.info("Last interval screenshots updated/deleted after explicit interval update (count=%s)", len(last_ss_urls))
 *                     except Exception as e:
 *                         logger.warning("Could not delete last interval screenshots after explicit update: %s", e)             # <<<<<<<<<<<<<<
 *                 else:
 *                     logger.warning("Last interval (id=%s) was not in the intervals list - may not have been sent", last_interval_id or 'N/A')
*/
                __pyx_t_7 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5542, __pyx_L684_error)
                __Pyx_GOTREF(__pyx_t_24);
                __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5542, __pyx_L684_error)
                __Pyx_GOTREF(__pyx_t_4);
                __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_4))) {
                  __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
                  assert(__pyx_t_7);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                  __Pyx_INCREF(__pyx_t_7);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Could_not_delete_last_interval_s, __pyx_cur_scope->__pyx_v_e};
                  __pyx_t_25 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5542, __pyx_L684_error)
                  __Pyx_GOTREF(__pyx_t_25);
                }
                __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
              }

              /* "ws_package/controllers/activity_controller.py":5541
 *                                 await self.screenshot_controller.update_screenshots(last_ss_urls, self.last_count + 1)
 *                                 logger.info("Last interval screenshots updated/deleted after explicit interval update (count=%s)", len(last_ss_urls))
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.warning("Could not delete last interval screenshots after explicit update: %s", e)
 *                 else:
*/
              /*finally:*/ {
                /*normal exit:*/{
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  goto __pyx_L685;
                }
                __pyx_L684_error:;
                /*exception exit:*/{
                  __Pyx_PyThreadState_assign
                  __pyx_t_15 = 0; __pyx_t_37 = 0; __pyx_t_17 = 0; __pyx_t_16 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
                  __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                  __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                  __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                  __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                  __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                  __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                  __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                   __Pyx_ExceptionSwap(&__pyx_t_16, &__pyx_t_19, &__pyx_t_20);
                  if ( unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_37, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_37, &__pyx_t_17);
                  __Pyx_XGOTREF(__pyx_t_15);
                  __Pyx_XGOTREF(__pyx_t_37);
                  __Pyx_XGOTREF(__pyx_t_17);
                  __Pyx_XGOTREF(__pyx_t_16);
                  __Pyx_XGOTREF(__pyx_t_19);
                  __Pyx_XGOTREF(__pyx_t_20);
                  __pyx_t_31 = __pyx_lineno; __pyx_t_32 = __pyx_clineno; __pyx_t_61 = __pyx_filename;
                  {
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  }
                  __Pyx_XGIVEREF(__pyx_t_16);
                  __Pyx_XGIVEREF(__pyx_t_19);
                  __Pyx_XGIVEREF(__pyx_t_20);
                  __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_19, __pyx_t_20);
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __Pyx_XGIVEREF(__pyx_t_37);
                  __Pyx_XGIVEREF(__pyx_t_17);
                  __Pyx_ErrRestore(__pyx_t_15, __pyx_t_37, __pyx_t_17);
                  __pyx_t_15 = 0; __pyx_t_37 = 0; __pyx_t_17 = 0; __pyx_t_16 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
                  __pyx_lineno = __pyx_t_31; __pyx_clineno = __pyx_t_32; __pyx_filename = __pyx_t_61;
                  goto __pyx_L669_except_error;
                }
                __pyx_L685:;
              }
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              goto __pyx_L668_exception_handled;
            }
            goto __pyx_L669_except_error;

            /* "ws_package/controllers/activity_controller.py":5533
 *                         logger.error("Error flushing database write queue after last interval update: %s", e, exc_info=True)
 *                     # Delete last interval screenshots now that is_uploaded is committed (they were not deleted in the loop)
 *                     try:             # <<<<<<<<<<<<<<
 *                         st = getattr(last_interval, 'start_time', None)
 *                         et = getattr(last_interval, 'end_time', None)
*/
            __pyx_L669_except_error:;
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
            goto __pyx_L4_error;
            __pyx_L668_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
            __pyx_L672_try_end:;
          }

          /* "ws_package/controllers/activity_controller.py":5481
 *                 ) if intervals else False
 * 
 *                 if last_interval_was_sent:             # <<<<<<<<<<<<<<
 *                     # Query database to get the actual record with ID (use tolerance for datetime precision)
 *                     try:
*/
          goto __pyx_L544;
        }

        /* "ws_package/controllers/activity_controller.py":5544
 *                         logger.warning("Could not delete last interval screenshots after explicit update: %s", e)
 *                 else:
 *                     logger.warning("Last interval (id=%s) was not in the intervals list - may not have been sent", last_interval_id or 'N/A')             # <<<<<<<<<<<<<<
 * 
 *             # CRITICAL: Ensure ALL intervals from current session that were successfully sent are marked as uploaded
*/
        /*else*/ {
          __pyx_t_10 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5544, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_23);
          __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5544, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_25);
          __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
          __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_last_interval_id); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5544, __pyx_L4_error)
          if (!__pyx_t_47) {
          } else {
            __Pyx_INCREF(__pyx_cur_scope->__pyx_v_last_interval_id);
            __pyx_t_23 = __pyx_cur_scope->__pyx_v_last_interval_id;
            goto __pyx_L690_bool_binop_done;
          }
          __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_N_A);
          __pyx_t_23 = __pyx_mstate_global->__pyx_kp_u_N_A;
          __pyx_L690_bool_binop_done:;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_25))) {
            __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_25);
            assert(__pyx_t_10);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_25);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_25, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Last_interval_id_s_was_not_in_th, __pyx_t_23};
            __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_25, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5544, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        }
        __pyx_L544:;

        /* "ws_package/controllers/activity_controller.py":5468
 *             # After all batches are processed, explicitly update last_interval if it wasn't updated yet
 *             # This ensures the last saved interval gets is_uploaded=True even if it wasn't in any response[1]
 *             if last_interval and at_least_one_batch_successful and not last_interval_updated:             # <<<<<<<<<<<<<<
 *                 logger.info("Last interval was not updated in any batch - explicitly updating it now")
 *                 # Verify last_interval was actually sent by checking if it's in the original intervals list
*/
      }

      /* "ws_package/controllers/activity_controller.py":5548
 *             # CRITICAL: Ensure ALL intervals from current session that were successfully sent are marked as uploaded
 *             # Mark any intervals from current session that weren't updated in the batch processing loop
 *             if at_least_one_batch_successful and intervals:             # <<<<<<<<<<<<<<
 *                 intervals_updated_count = 0
 *                 for interval in intervals:
*/
      if (__pyx_cur_scope->__pyx_v_at_least_one_batch_successful) {
      } else {
        __pyx_t_47 = __pyx_cur_scope->__pyx_v_at_least_one_batch_successful;
        goto __pyx_L693_bool_binop_done;
      }
      __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_intervals); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5548, __pyx_L4_error)
      __pyx_t_47 = __pyx_t_28;
      __pyx_L693_bool_binop_done:;
      if (__pyx_t_47) {

        /* "ws_package/controllers/activity_controller.py":5549
 *             # Mark any intervals from current session that weren't updated in the batch processing loop
 *             if at_least_one_batch_successful and intervals:
 *                 intervals_updated_count = 0             # <<<<<<<<<<<<<<
 *                 for interval in intervals:
 *                     # If interval doesn't have an ID, query database to get it
*/
        __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
        __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_0);
        __pyx_cur_scope->__pyx_v_intervals_updated_count = __pyx_mstate_global->__pyx_int_0;

        /* "ws_package/controllers/activity_controller.py":5550
 *             if at_least_one_batch_successful and intervals:
 *                 intervals_updated_count = 0
 *                 for interval in intervals:             # <<<<<<<<<<<<<<
 *                     # If interval doesn't have an ID, query database to get it
 *                     interval_to_update = None
*/
        if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_intervals)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_intervals)) {
          __pyx_t_5 = __pyx_cur_scope->__pyx_v_intervals; __Pyx_INCREF(__pyx_t_5);
          __pyx_t_45 = 0;
          __pyx_t_35 = NULL;
        } else {
          __pyx_t_45 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_intervals); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5550, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_35 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_5); if (unlikely(!__pyx_t_35)) __PYX_ERR(0, 5550, __pyx_L4_error)
        }
        for (;;) {
          if (likely(!__pyx_t_35)) {
            if (likely(PyList_CheckExact(__pyx_t_5))) {
              {
                Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_5);
                #if !CYTHON_ASSUME_SAFE_SIZE
                if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5550, __pyx_L4_error)
                #endif
                if (__pyx_t_45 >= __pyx_temp) break;
              }
              __pyx_t_25 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_5, __pyx_t_45, __Pyx_ReferenceSharing_OwnStrongReference);
              ++__pyx_t_45;
            } else {
              {
                Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_5);
                #if !CYTHON_ASSUME_SAFE_SIZE
                if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5550, __pyx_L4_error)
                #endif
                if (__pyx_t_45 >= __pyx_temp) break;
              }
              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
              __pyx_t_25 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_45));
              #else
              __pyx_t_25 = __Pyx_PySequence_ITEM(__pyx_t_5, __pyx_t_45);
              #endif
              ++__pyx_t_45;
            }
            if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5550, __pyx_L4_error)
          } else {
            __pyx_t_25 = __pyx_t_35(__pyx_t_5);
            if (unlikely(!__pyx_t_25)) {
              PyObject* exc_type = PyErr_Occurred();
              if (exc_type) {
                if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 5550, __pyx_L4_error)
                PyErr_Clear();
              }
              break;
            }
          }
          __Pyx_GOTREF(__pyx_t_25);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_25);
          __Pyx_GIVEREF(__pyx_t_25);
          __pyx_t_25 = 0;

          /* "ws_package/controllers/activity_controller.py":5552
 *                 for interval in intervals:
 *                     # If interval doesn't have an ID, query database to get it
 *                     interval_to_update = None             # <<<<<<<<<<<<<<
 *                     if hasattr(interval, 'id') and interval.id:
 *                         if interval.id not in updated_interval_ids:
*/
          __Pyx_INCREF(Py_None);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval_to_update);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval_to_update, Py_None);
          __Pyx_GIVEREF(Py_None);

          /* "ws_package/controllers/activity_controller.py":5553
 *                     # If interval doesn't have an ID, query database to get it
 *                     interval_to_update = None
 *                     if hasattr(interval, 'id') and interval.id:             # <<<<<<<<<<<<<<
 *                         if interval.id not in updated_interval_ids:
 *                             interval_to_update = interval
*/
          __pyx_t_28 = __Pyx_HasAttr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(__pyx_t_28 == ((int)-1))) __PYX_ERR(0, 5553, __pyx_L4_error)
          if (__pyx_t_28) {
          } else {
            __pyx_t_47 = __pyx_t_28;
            goto __pyx_L698_bool_binop_done;
          }
          __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5553, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_25);
          __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_25); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5553, __pyx_L4_error)
          __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
          __pyx_t_47 = __pyx_t_28;
          __pyx_L698_bool_binop_done:;
          if (__pyx_t_47) {

            /* "ws_package/controllers/activity_controller.py":5554
 *                     interval_to_update = None
 *                     if hasattr(interval, 'id') and interval.id:
 *                         if interval.id not in updated_interval_ids:             # <<<<<<<<<<<<<<
 *                             interval_to_update = interval
 *                     else:
*/
            __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5554, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_25);
            __pyx_t_47 = (__Pyx_PySet_ContainsTF(__pyx_t_25, __pyx_cur_scope->__pyx_v_updated_interval_ids, Py_NE)); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5554, __pyx_L4_error)
            __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
            if (__pyx_t_47) {

              /* "ws_package/controllers/activity_controller.py":5555
 *                     if hasattr(interval, 'id') and interval.id:
 *                         if interval.id not in updated_interval_ids:
 *                             interval_to_update = interval             # <<<<<<<<<<<<<<
 *                     else:
 *                         # Query database to get the actual record with ID
*/
              __Pyx_INCREF(__pyx_cur_scope->__pyx_v_interval);
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_interval_to_update);
              __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_interval_to_update, __pyx_cur_scope->__pyx_v_interval);
              __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_interval);

              /* "ws_package/controllers/activity_controller.py":5554
 *                     interval_to_update = None
 *                     if hasattr(interval, 'id') and interval.id:
 *                         if interval.id not in updated_interval_ids:             # <<<<<<<<<<<<<<
 *                             interval_to_update = interval
 *                     else:
*/
            }

            /* "ws_package/controllers/activity_controller.py":5553
 *                     # If interval doesn't have an ID, query database to get it
 *                     interval_to_update = None
 *                     if hasattr(interval, 'id') and interval.id:             # <<<<<<<<<<<<<<
 *                         if interval.id not in updated_interval_ids:
 *                             interval_to_update = interval
*/
            goto __pyx_L697;
          }

          /* "ws_package/controllers/activity_controller.py":5558
 *                     else:
 *                         # Query database to get the actual record with ID
 *                         try:             # <<<<<<<<<<<<<<
 *                             with db_lock_manager.read_lock():
 *                                 async with async_session() as session:
*/
          /*else*/ {
            {
              __Pyx_ExceptionSave(&__pyx_t_14, &__pyx_t_13, &__pyx_t_12);
              __Pyx_XGOTREF(__pyx_t_14);
              __Pyx_XGOTREF(__pyx_t_13);
              __Pyx_XGOTREF(__pyx_t_12);
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":5559
 *                         # Query database to get the actual record with ID
 *                         try:
 *                             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                                 async with async_session() as session:
 *                                     query = select(ActivityInterval).where(
*/
                /*with:*/ {
                  __pyx_t_23 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5559, __pyx_L701_error)
                  __Pyx_GOTREF(__pyx_t_10);
                  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5559, __pyx_L701_error)
                  __Pyx_GOTREF(__pyx_t_4);
                  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                  __pyx_t_8 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_4))) {
                    __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_4);
                    assert(__pyx_t_23);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                    __Pyx_INCREF(__pyx_t_23);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                    __pyx_t_8 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_23, NULL};
                    __pyx_t_25 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5559, __pyx_L701_error)
                    __Pyx_GOTREF(__pyx_t_25);
                  }
                  __pyx_t_20 = __Pyx_PyObject_LookupSpecial(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 5559, __pyx_L701_error)
                  __Pyx_GOTREF(__pyx_t_20);
                  __pyx_t_23 = NULL;
                  __pyx_t_10 = __Pyx_PyObject_LookupSpecial(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5559, __pyx_L709_error)
                  __Pyx_GOTREF(__pyx_t_10);
                  __pyx_t_8 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (likely(PyMethod_Check(__pyx_t_10))) {
                    __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_10);
                    assert(__pyx_t_23);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
                    __Pyx_INCREF(__pyx_t_23);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
                    __pyx_t_8 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_23, NULL};
                    __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5559, __pyx_L709_error)
                    __Pyx_GOTREF(__pyx_t_4);
                  }
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                  /*try:*/ {
                    {
                      __Pyx_ExceptionSave(&__pyx_t_19, &__pyx_t_16, &__pyx_t_17);
                      __Pyx_XGOTREF(__pyx_t_19);
                      __Pyx_XGOTREF(__pyx_t_16);
                      __Pyx_XGOTREF(__pyx_t_17);
                      /*try:*/ {

                        /* "ws_package/controllers/activity_controller.py":5560
 *                         try:
 *                             with db_lock_manager.read_lock():
 *                                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                                     query = select(ActivityInterval).where(
 *                                         ActivityInterval.start_time == interval.start_time,
*/
                        /*with:*/ {
                          __pyx_t_4 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5560, __pyx_L715_error)
                          __Pyx_GOTREF(__pyx_t_10);
                          __pyx_t_8 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_10))) {
                            __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10);
                            assert(__pyx_t_4);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
                            __Pyx_INCREF(__pyx_t_4);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
                            __pyx_t_8 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
                            __pyx_t_25 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                            if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5560, __pyx_L715_error)
                            __Pyx_GOTREF(__pyx_t_25);
                          }
                          __pyx_t_37 = __Pyx_PyObject_LookupSpecial(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 5560, __pyx_L715_error)
                          __Pyx_GOTREF(__pyx_t_37);
                          __pyx_t_4 = NULL;
                          __pyx_t_23 = __Pyx_PyObject_LookupSpecial(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5560, __pyx_L723_error)
                          __Pyx_GOTREF(__pyx_t_23);
                          __pyx_t_8 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (likely(PyMethod_Check(__pyx_t_23))) {
                            __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_23);
                            assert(__pyx_t_4);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_23);
                            __Pyx_INCREF(__pyx_t_4);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_23, __pyx__function);
                            __pyx_t_8 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
                            __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_23, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                            if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5560, __pyx_L723_error)
                            __Pyx_GOTREF(__pyx_t_10);
                          }
                          __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_10, &__pyx_r);
                          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                          if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_XGIVEREF(__pyx_t_1);
                            __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                            __Pyx_XGIVEREF(__pyx_t_2);
                            __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                            __Pyx_XGIVEREF(__pyx_t_3);
                            __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                            __Pyx_XGIVEREF(__pyx_t_5);
                            __pyx_cur_scope->__pyx_t_3 = __pyx_t_5;
                            __Pyx_XGIVEREF(__pyx_t_12);
                            __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                            __Pyx_XGIVEREF(__pyx_t_13);
                            __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                            __Pyx_XGIVEREF(__pyx_t_14);
                            __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                            __Pyx_XGIVEREF(__pyx_t_16);
                            __pyx_cur_scope->__pyx_t_7 = __pyx_t_16;
                            __Pyx_XGIVEREF(__pyx_t_17);
                            __pyx_cur_scope->__pyx_t_8 = __pyx_t_17;
                            __Pyx_XGIVEREF(__pyx_t_19);
                            __pyx_cur_scope->__pyx_t_9 = __pyx_t_19;
                            __Pyx_XGIVEREF(__pyx_t_20);
                            __pyx_cur_scope->__pyx_t_10 = __pyx_t_20;
                            __Pyx_XGIVEREF(__pyx_t_25);
                            __pyx_cur_scope->__pyx_t_11 = __pyx_t_25;
                            __pyx_cur_scope->__pyx_t_18 = __pyx_t_35;
                            __Pyx_XGIVEREF(__pyx_t_37);
                            __pyx_cur_scope->__pyx_t_12 = __pyx_t_37;
                            __pyx_cur_scope->__pyx_t_23 = __pyx_t_45;
                            __Pyx_XGIVEREF(__pyx_r);
                            __Pyx_RefNannyFinishContext();
                            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                            /* return from generator, awaiting value */
                            __pyx_generator->resume_label = 55;
                            return __pyx_r;
                            __pyx_L724_resume_from_await:;
                            __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                            __pyx_cur_scope->__pyx_t_0 = 0;
                            __Pyx_XGOTREF(__pyx_t_1);
                            __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                            __pyx_cur_scope->__pyx_t_1 = 0;
                            __Pyx_XGOTREF(__pyx_t_2);
                            __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                            __pyx_cur_scope->__pyx_t_2 = 0;
                            __Pyx_XGOTREF(__pyx_t_3);
                            __pyx_t_5 = __pyx_cur_scope->__pyx_t_3;
                            __pyx_cur_scope->__pyx_t_3 = 0;
                            __Pyx_XGOTREF(__pyx_t_5);
                            __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                            __pyx_cur_scope->__pyx_t_4 = 0;
                            __Pyx_XGOTREF(__pyx_t_12);
                            __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                            __pyx_cur_scope->__pyx_t_5 = 0;
                            __Pyx_XGOTREF(__pyx_t_13);
                            __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                            __pyx_cur_scope->__pyx_t_6 = 0;
                            __Pyx_XGOTREF(__pyx_t_14);
                            __pyx_t_16 = __pyx_cur_scope->__pyx_t_7;
                            __pyx_cur_scope->__pyx_t_7 = 0;
                            __Pyx_XGOTREF(__pyx_t_16);
                            __pyx_t_17 = __pyx_cur_scope->__pyx_t_8;
                            __pyx_cur_scope->__pyx_t_8 = 0;
                            __Pyx_XGOTREF(__pyx_t_17);
                            __pyx_t_19 = __pyx_cur_scope->__pyx_t_9;
                            __pyx_cur_scope->__pyx_t_9 = 0;
                            __Pyx_XGOTREF(__pyx_t_19);
                            __pyx_t_20 = __pyx_cur_scope->__pyx_t_10;
                            __pyx_cur_scope->__pyx_t_10 = 0;
                            __Pyx_XGOTREF(__pyx_t_20);
                            __pyx_t_25 = __pyx_cur_scope->__pyx_t_11;
                            __pyx_cur_scope->__pyx_t_11 = 0;
                            __Pyx_XGOTREF(__pyx_t_25);
                            __pyx_t_35 = __pyx_cur_scope->__pyx_t_18;
                            __pyx_t_37 = __pyx_cur_scope->__pyx_t_12;
                            __pyx_cur_scope->__pyx_t_12 = 0;
                            __Pyx_XGOTREF(__pyx_t_37);
                            __pyx_t_45 = __pyx_cur_scope->__pyx_t_23;
                            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5560, __pyx_L723_error)
                            __pyx_t_10 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_10);
                          } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                            __Pyx_GOTREF(__pyx_r);
                            __pyx_t_10 = __pyx_r; __pyx_r = NULL;
                          } else {
                            __Pyx_XGOTREF(__pyx_r);
                            __PYX_ERR(0, 5560, __pyx_L723_error)
                          }
                          __pyx_t_23 = __pyx_t_10;
                          __pyx_t_10 = 0;
                          __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                          /*try:*/ {
                            {
                              __Pyx_ExceptionSave(&__pyx_t_15, &__pyx_t_21, &__pyx_t_22);
                              __Pyx_XGOTREF(__pyx_t_15);
                              __Pyx_XGOTREF(__pyx_t_21);
                              __Pyx_XGOTREF(__pyx_t_22);
                              /*try:*/ {
                                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_session);
                                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_session, __pyx_t_23);
                                __Pyx_GIVEREF(__pyx_t_23);
                                __pyx_t_23 = 0;

                                /* "ws_package/controllers/activity_controller.py":5561
 *                             with db_lock_manager.read_lock():
 *                                 async with async_session() as session:
 *                                     query = select(ActivityInterval).where(             # <<<<<<<<<<<<<<
 *                                         ActivityInterval.start_time == interval.start_time,
 *                                         ActivityInterval.end_time == interval.end_time,
*/
                                __pyx_t_52 = NULL;
                                __Pyx_GetModuleGlobalName(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5561, __pyx_L730_error)
                                __Pyx_GOTREF(__pyx_t_26);
                                __Pyx_GetModuleGlobalName(__pyx_t_55, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_55)) __PYX_ERR(0, 5561, __pyx_L730_error)
                                __Pyx_GOTREF(__pyx_t_55);
                                __pyx_t_8 = 1;
                                #if CYTHON_UNPACK_METHODS
                                if (unlikely(PyMethod_Check(__pyx_t_26))) {
                                  __pyx_t_52 = PyMethod_GET_SELF(__pyx_t_26);
                                  assert(__pyx_t_52);
                                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_26);
                                  __Pyx_INCREF(__pyx_t_52);
                                  __Pyx_INCREF(__pyx__function);
                                  __Pyx_DECREF_SET(__pyx_t_26, __pyx__function);
                                  __pyx_t_8 = 0;
                                }
                                #endif
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_52, __pyx_t_55};
                                  __pyx_t_40 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_26, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                                  __Pyx_DECREF(__pyx_t_55); __pyx_t_55 = 0;
                                  __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                                  if (unlikely(!__pyx_t_40)) __PYX_ERR(0, 5561, __pyx_L730_error)
                                  __Pyx_GOTREF(__pyx_t_40);
                                }
                                __pyx_t_24 = __pyx_t_40;
                                __Pyx_INCREF(__pyx_t_24);

                                /* "ws_package/controllers/activity_controller.py":5562
 *                                 async with async_session() as session:
 *                                     query = select(ActivityInterval).where(
 *                                         ActivityInterval.start_time == interval.start_time,             # <<<<<<<<<<<<<<
 *                                         ActivityInterval.end_time == interval.end_time,
 *                                         ActivityInterval.counter == getattr(interval, 'counter', current_session_counter)
*/
                                __Pyx_GetModuleGlobalName(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5562, __pyx_L730_error)
                                __Pyx_GOTREF(__pyx_t_26);
                                __pyx_t_55 = __Pyx_PyObject_GetAttrStr(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_55)) __PYX_ERR(0, 5562, __pyx_L730_error)
                                __Pyx_GOTREF(__pyx_t_55);
                                __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                                __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5562, __pyx_L730_error)
                                __Pyx_GOTREF(__pyx_t_26);
                                __pyx_t_52 = PyObject_RichCompare(__pyx_t_55, __pyx_t_26, Py_EQ); __Pyx_XGOTREF(__pyx_t_52); if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5562, __pyx_L730_error)
                                __Pyx_DECREF(__pyx_t_55); __pyx_t_55 = 0;
                                __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;

                                /* "ws_package/controllers/activity_controller.py":5563
 *                                     query = select(ActivityInterval).where(
 *                                         ActivityInterval.start_time == interval.start_time,
 *                                         ActivityInterval.end_time == interval.end_time,             # <<<<<<<<<<<<<<
 *                                         ActivityInterval.counter == getattr(interval, 'counter', current_session_counter)
 *                                     ).order_by(ActivityInterval.id.desc()).limit(1)
*/
                                __Pyx_GetModuleGlobalName(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5563, __pyx_L730_error)
                                __Pyx_GOTREF(__pyx_t_26);
                                __pyx_t_55 = __Pyx_PyObject_GetAttrStr(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_55)) __PYX_ERR(0, 5563, __pyx_L730_error)
                                __Pyx_GOTREF(__pyx_t_55);
                                __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                                __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5563, __pyx_L730_error)
                                __Pyx_GOTREF(__pyx_t_26);
                                __pyx_t_6 = PyObject_RichCompare(__pyx_t_55, __pyx_t_26, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5563, __pyx_L730_error)
                                __Pyx_DECREF(__pyx_t_55); __pyx_t_55 = 0;
                                __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;

                                /* "ws_package/controllers/activity_controller.py":5564
 *                                         ActivityInterval.start_time == interval.start_time,
 *                                         ActivityInterval.end_time == interval.end_time,
 *                                         ActivityInterval.counter == getattr(interval, 'counter', current_session_counter)             # <<<<<<<<<<<<<<
 *                                     ).order_by(ActivityInterval.id.desc()).limit(1)
 * 
*/
                                __Pyx_GetModuleGlobalName(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5564, __pyx_L730_error)
                                __Pyx_GOTREF(__pyx_t_26);
                                __pyx_t_55 = __Pyx_PyObject_GetAttrStr(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_55)) __PYX_ERR(0, 5564, __pyx_L730_error)
                                __Pyx_GOTREF(__pyx_t_55);
                                __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                                __pyx_t_26 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_counter, __pyx_cur_scope->__pyx_v_current_session_counter); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5564, __pyx_L730_error)
                                __Pyx_GOTREF(__pyx_t_26);
                                __pyx_t_39 = PyObject_RichCompare(__pyx_t_55, __pyx_t_26, Py_EQ); __Pyx_XGOTREF(__pyx_t_39); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5564, __pyx_L730_error)
                                __Pyx_DECREF(__pyx_t_55); __pyx_t_55 = 0;
                                __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                                __pyx_t_8 = 0;
                                {
                                  PyObject *__pyx_callargs[4] = {__pyx_t_24, __pyx_t_52, __pyx_t_6, __pyx_t_39};
                                  __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                                  __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
                                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                                  __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                                  __Pyx_DECREF(__pyx_t_40); __pyx_t_40 = 0;
                                  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5561, __pyx_L730_error)
                                  __Pyx_GOTREF(__pyx_t_7);
                                }
                                __pyx_t_4 = __pyx_t_7;
                                __Pyx_INCREF(__pyx_t_4);

                                /* "ws_package/controllers/activity_controller.py":5565
 *                                         ActivityInterval.end_time == interval.end_time,
 *                                         ActivityInterval.counter == getattr(interval, 'counter', current_session_counter)
 *                                     ).order_by(ActivityInterval.id.desc()).limit(1)             # <<<<<<<<<<<<<<
 * 
 *                                     result = await session.execute(query)
*/
                                __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5565, __pyx_L730_error)
                                __Pyx_GOTREF(__pyx_t_6);
                                __pyx_t_52 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5565, __pyx_L730_error)
                                __Pyx_GOTREF(__pyx_t_52);
                                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                                __pyx_t_39 = __pyx_t_52;
                                __Pyx_INCREF(__pyx_t_39);
                                __pyx_t_8 = 0;
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_39, NULL};
                                  __pyx_t_40 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_desc, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                                  __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
                                  if (unlikely(!__pyx_t_40)) __PYX_ERR(0, 5565, __pyx_L730_error)
                                  __Pyx_GOTREF(__pyx_t_40);
                                }
                                __pyx_t_8 = 0;
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_40};
                                  __pyx_t_10 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_order_by, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                                  __Pyx_DECREF(__pyx_t_40); __pyx_t_40 = 0;
                                  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                                  if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5565, __pyx_L730_error)
                                  __Pyx_GOTREF(__pyx_t_10);
                                }
                                __pyx_t_25 = __pyx_t_10;
                                __Pyx_INCREF(__pyx_t_25);
                                __pyx_t_8 = 0;
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_25, __pyx_mstate_global->__pyx_int_1};
                                  __pyx_t_23 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_limit, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                                  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                                  if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5565, __pyx_L730_error)
                                  __Pyx_GOTREF(__pyx_t_23);
                                }
                                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_query);
                                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_query, __pyx_t_23);
                                __Pyx_GIVEREF(__pyx_t_23);
                                __pyx_t_23 = 0;

                                /* "ws_package/controllers/activity_controller.py":5567
 *                                     ).order_by(ActivityInterval.id.desc()).limit(1)
 * 
 *                                     result = await session.execute(query)             # <<<<<<<<<<<<<<
 *                                     db_interval = result.scalar_one_or_none()
 * 
*/
                                __pyx_t_10 = __pyx_cur_scope->__pyx_v_session;
                                __Pyx_INCREF(__pyx_t_10);
                                __pyx_t_8 = 0;
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_cur_scope->__pyx_v_query};
                                  __pyx_t_23 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                                  if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5567, __pyx_L730_error)
                                  __Pyx_GOTREF(__pyx_t_23);
                                }
                                __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_23, &__pyx_r);
                                __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                                if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __Pyx_XGIVEREF(__pyx_t_1);
                                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                  __Pyx_XGIVEREF(__pyx_t_2);
                                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                  __Pyx_XGIVEREF(__pyx_t_3);
                                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                  __Pyx_XGIVEREF(__pyx_t_5);
                                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_5;
                                  __Pyx_XGIVEREF(__pyx_t_12);
                                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                                  __Pyx_XGIVEREF(__pyx_t_13);
                                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                                  __Pyx_XGIVEREF(__pyx_t_14);
                                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                                  __Pyx_XGIVEREF(__pyx_t_15);
                                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_15;
                                  __Pyx_XGIVEREF(__pyx_t_16);
                                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_16;
                                  __Pyx_XGIVEREF(__pyx_t_17);
                                  __pyx_cur_scope->__pyx_t_9 = __pyx_t_17;
                                  __Pyx_XGIVEREF(__pyx_t_19);
                                  __pyx_cur_scope->__pyx_t_10 = __pyx_t_19;
                                  __Pyx_XGIVEREF(__pyx_t_20);
                                  __pyx_cur_scope->__pyx_t_11 = __pyx_t_20;
                                  __Pyx_XGIVEREF(__pyx_t_21);
                                  __pyx_cur_scope->__pyx_t_12 = __pyx_t_21;
                                  __Pyx_XGIVEREF(__pyx_t_22);
                                  __pyx_cur_scope->__pyx_t_13 = __pyx_t_22;
                                  __pyx_cur_scope->__pyx_t_18 = __pyx_t_35;
                                  __Pyx_XGIVEREF(__pyx_t_37);
                                  __pyx_cur_scope->__pyx_t_14 = __pyx_t_37;
                                  __pyx_cur_scope->__pyx_t_23 = __pyx_t_45;
                                  __Pyx_XGIVEREF(__pyx_r);
                                  __Pyx_RefNannyFinishContext();
                                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                                  /* return from generator, awaiting value */
                                  __pyx_generator->resume_label = 56;
                                  return __pyx_r;
                                  __pyx_L738_resume_from_await:;
                                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                  __pyx_cur_scope->__pyx_t_0 = 0;
                                  __Pyx_XGOTREF(__pyx_t_1);
                                  __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                  __pyx_cur_scope->__pyx_t_1 = 0;
                                  __Pyx_XGOTREF(__pyx_t_2);
                                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                  __pyx_cur_scope->__pyx_t_2 = 0;
                                  __Pyx_XGOTREF(__pyx_t_3);
                                  __pyx_t_5 = __pyx_cur_scope->__pyx_t_3;
                                  __pyx_cur_scope->__pyx_t_3 = 0;
                                  __Pyx_XGOTREF(__pyx_t_5);
                                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                                  __pyx_cur_scope->__pyx_t_4 = 0;
                                  __Pyx_XGOTREF(__pyx_t_12);
                                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                                  __pyx_cur_scope->__pyx_t_5 = 0;
                                  __Pyx_XGOTREF(__pyx_t_13);
                                  __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                                  __pyx_cur_scope->__pyx_t_6 = 0;
                                  __Pyx_XGOTREF(__pyx_t_14);
                                  __pyx_t_15 = __pyx_cur_scope->__pyx_t_7;
                                  __pyx_cur_scope->__pyx_t_7 = 0;
                                  __Pyx_XGOTREF(__pyx_t_15);
                                  __pyx_t_16 = __pyx_cur_scope->__pyx_t_8;
                                  __pyx_cur_scope->__pyx_t_8 = 0;
                                  __Pyx_XGOTREF(__pyx_t_16);
                                  __pyx_t_17 = __pyx_cur_scope->__pyx_t_9;
                                  __pyx_cur_scope->__pyx_t_9 = 0;
                                  __Pyx_XGOTREF(__pyx_t_17);
                                  __pyx_t_19 = __pyx_cur_scope->__pyx_t_10;
                                  __pyx_cur_scope->__pyx_t_10 = 0;
                                  __Pyx_XGOTREF(__pyx_t_19);
                                  __pyx_t_20 = __pyx_cur_scope->__pyx_t_11;
                                  __pyx_cur_scope->__pyx_t_11 = 0;
                                  __Pyx_XGOTREF(__pyx_t_20);
                                  __pyx_t_21 = __pyx_cur_scope->__pyx_t_12;
                                  __pyx_cur_scope->__pyx_t_12 = 0;
                                  __Pyx_XGOTREF(__pyx_t_21);
                                  __pyx_t_22 = __pyx_cur_scope->__pyx_t_13;
                                  __pyx_cur_scope->__pyx_t_13 = 0;
                                  __Pyx_XGOTREF(__pyx_t_22);
                                  __pyx_t_35 = __pyx_cur_scope->__pyx_t_18;
                                  __pyx_t_37 = __pyx_cur_scope->__pyx_t_14;
                                  __pyx_cur_scope->__pyx_t_14 = 0;
                                  __Pyx_XGOTREF(__pyx_t_37);
                                  __pyx_t_45 = __pyx_cur_scope->__pyx_t_23;
                                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5567, __pyx_L730_error)
                                  __pyx_t_23 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_23);
                                } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __pyx_t_23 = __pyx_r; __pyx_r = NULL;
                                } else {
                                  __Pyx_XGOTREF(__pyx_r);
                                  __PYX_ERR(0, 5567, __pyx_L730_error)
                                }
                                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_result);
                                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_result, __pyx_t_23);
                                __Pyx_GIVEREF(__pyx_t_23);
                                __pyx_t_23 = 0;

                                /* "ws_package/controllers/activity_controller.py":5568
 * 
 *                                     result = await session.execute(query)
 *                                     db_interval = result.scalar_one_or_none()             # <<<<<<<<<<<<<<
 * 
 *                                     if db_interval and db_interval.id:
*/
                                __pyx_t_10 = __pyx_cur_scope->__pyx_v_result;
                                __Pyx_INCREF(__pyx_t_10);
                                __pyx_t_8 = 0;
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_10, NULL};
                                  __pyx_t_23 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalar_one_or_none, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                                  if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5568, __pyx_L730_error)
                                  __Pyx_GOTREF(__pyx_t_23);
                                }
                                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_db_interval);
                                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_db_interval, __pyx_t_23);
                                __Pyx_GIVEREF(__pyx_t_23);
                                __pyx_t_23 = 0;

                                /* "ws_package/controllers/activity_controller.py":5570
 *                                     db_interval = result.scalar_one_or_none()
 * 
 *                                     if db_interval and db_interval.id:             # <<<<<<<<<<<<<<
 *                                         if db_interval.id not in updated_interval_ids:
 *                                             interval_to_update = db_interval
*/
                                __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_db_interval); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5570, __pyx_L730_error)
                                if (__pyx_t_28) {
                                } else {
                                  __pyx_t_47 = __pyx_t_28;
                                  goto __pyx_L740_bool_binop_done;
                                }
                                __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_db_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5570, __pyx_L730_error)
                                __Pyx_GOTREF(__pyx_t_23);
                                __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_23); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5570, __pyx_L730_error)
                                __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                                __pyx_t_47 = __pyx_t_28;
                                __pyx_L740_bool_binop_done:;
                                if (__pyx_t_47) {

                                  /* "ws_package/controllers/activity_controller.py":5571
 * 
 *                                     if db_interval and db_interval.id:
 *                                         if db_interval.id not in updated_interval_ids:             # <<<<<<<<<<<<<<
 *                                             interval_to_update = db_interval
 *                         except Exception as e:
*/
                                  __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_db_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5571, __pyx_L730_error)
                                  __Pyx_GOTREF(__pyx_t_23);
                                  __pyx_t_47 = (__Pyx_PySet_ContainsTF(__pyx_t_23, __pyx_cur_scope->__pyx_v_updated_interval_ids, Py_NE)); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5571, __pyx_L730_error)
                                  __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                                  if (__pyx_t_47) {

                                    /* "ws_package/controllers/activity_controller.py":5572
 *                                     if db_interval and db_interval.id:
 *                                         if db_interval.id not in updated_interval_ids:
 *                                             interval_to_update = db_interval             # <<<<<<<<<<<<<<
 *                         except Exception as e:
 *                             logger.error("Error querying database for interval: %s", e, exc_info=True)
*/
                                    __Pyx_INCREF(__pyx_cur_scope->__pyx_v_db_interval);
                                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_interval_to_update);
                                    __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_interval_to_update, __pyx_cur_scope->__pyx_v_db_interval);
                                    __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_db_interval);

                                    /* "ws_package/controllers/activity_controller.py":5571
 * 
 *                                     if db_interval and db_interval.id:
 *                                         if db_interval.id not in updated_interval_ids:             # <<<<<<<<<<<<<<
 *                                             interval_to_update = db_interval
 *                         except Exception as e:
*/
                                  }

                                  /* "ws_package/controllers/activity_controller.py":5570
 *                                     db_interval = result.scalar_one_or_none()
 * 
 *                                     if db_interval and db_interval.id:             # <<<<<<<<<<<<<<
 *                                         if db_interval.id not in updated_interval_ids:
 *                                             interval_to_update = db_interval
*/
                                }

                                /* "ws_package/controllers/activity_controller.py":5560
 *                         try:
 *                             with db_lock_manager.read_lock():
 *                                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                                     query = select(ActivityInterval).where(
 *                                         ActivityInterval.start_time == interval.start_time,
*/
                              }
                              __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                              __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                              __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                              goto __pyx_L737_try_end;
                              __pyx_L730_error:;
                              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                              __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                              __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                              __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                              __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                              __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                              __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                              __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                              __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
                              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                              /*except:*/ {
                                __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
                                if (__Pyx_GetException(&__pyx_t_23, &__pyx_t_10, &__pyx_t_25) < 0) __PYX_ERR(0, 5560, __pyx_L732_except_error)
                                __Pyx_XGOTREF(__pyx_t_23);
                                __Pyx_XGOTREF(__pyx_t_10);
                                __Pyx_XGOTREF(__pyx_t_25);
                                __pyx_t_7 = PyTuple_Pack(3, __pyx_t_23, __pyx_t_10, __pyx_t_25); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5560, __pyx_L732_except_error)
                                __Pyx_GOTREF(__pyx_t_7);
                                __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_37, __pyx_t_7, NULL);
                                __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                                if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 5560, __pyx_L732_except_error)
                                __Pyx_GOTREF(__pyx_t_18);
                                __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_18, &__pyx_r);
                                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                                if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __Pyx_XGIVEREF(__pyx_t_1);
                                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                  __Pyx_XGIVEREF(__pyx_t_2);
                                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                  __Pyx_XGIVEREF(__pyx_t_3);
                                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                  __Pyx_XGIVEREF(__pyx_t_5);
                                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_5;
                                  __Pyx_XGIVEREF(__pyx_t_10);
                                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                                  __Pyx_XGIVEREF(__pyx_t_12);
                                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                                  __Pyx_XGIVEREF(__pyx_t_13);
                                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                                  __Pyx_XGIVEREF(__pyx_t_14);
                                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                                  __Pyx_XGIVEREF(__pyx_t_15);
                                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                                  __Pyx_XGIVEREF(__pyx_t_16);
                                  __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                                  __Pyx_XGIVEREF(__pyx_t_17);
                                  __pyx_cur_scope->__pyx_t_10 = __pyx_t_17;
                                  __Pyx_XGIVEREF(__pyx_t_18);
                                  __pyx_cur_scope->__pyx_t_11 = __pyx_t_18;
                                  __Pyx_XGIVEREF(__pyx_t_19);
                                  __pyx_cur_scope->__pyx_t_12 = __pyx_t_19;
                                  __Pyx_XGIVEREF(__pyx_t_20);
                                  __pyx_cur_scope->__pyx_t_13 = __pyx_t_20;
                                  __Pyx_XGIVEREF(__pyx_t_21);
                                  __pyx_cur_scope->__pyx_t_14 = __pyx_t_21;
                                  __Pyx_XGIVEREF(__pyx_t_22);
                                  __pyx_cur_scope->__pyx_t_15 = __pyx_t_22;
                                  __Pyx_XGIVEREF(__pyx_t_23);
                                  __pyx_cur_scope->__pyx_t_16 = __pyx_t_23;
                                  __Pyx_XGIVEREF(__pyx_t_25);
                                  __pyx_cur_scope->__pyx_t_17 = __pyx_t_25;
                                  __pyx_cur_scope->__pyx_t_18 = __pyx_t_35;
                                  __Pyx_XGIVEREF(__pyx_t_37);
                                  __pyx_cur_scope->__pyx_t_19 = __pyx_t_37;
                                  __pyx_cur_scope->__pyx_t_23 = __pyx_t_45;
                                  __Pyx_XGIVEREF(__pyx_r);
                                  __Pyx_RefNannyFinishContext();
                                  __Pyx_Coroutine_SwapException(__pyx_generator);
                                  /* return from generator, awaiting value */
                                  __pyx_generator->resume_label = 57;
                                  return __pyx_r;
                                  __pyx_L746_resume_from_await:;
                                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                  __pyx_cur_scope->__pyx_t_0 = 0;
                                  __Pyx_XGOTREF(__pyx_t_1);
                                  __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                  __pyx_cur_scope->__pyx_t_1 = 0;
                                  __Pyx_XGOTREF(__pyx_t_2);
                                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                  __pyx_cur_scope->__pyx_t_2 = 0;
                                  __Pyx_XGOTREF(__pyx_t_3);
                                  __pyx_t_5 = __pyx_cur_scope->__pyx_t_3;
                                  __pyx_cur_scope->__pyx_t_3 = 0;
                                  __Pyx_XGOTREF(__pyx_t_5);
                                  __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                                  __pyx_cur_scope->__pyx_t_4 = 0;
                                  __Pyx_XGOTREF(__pyx_t_10);
                                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                                  __pyx_cur_scope->__pyx_t_5 = 0;
                                  __Pyx_XGOTREF(__pyx_t_12);
                                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                                  __pyx_cur_scope->__pyx_t_6 = 0;
                                  __Pyx_XGOTREF(__pyx_t_13);
                                  __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                                  __pyx_cur_scope->__pyx_t_7 = 0;
                                  __Pyx_XGOTREF(__pyx_t_14);
                                  __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                                  __pyx_cur_scope->__pyx_t_8 = 0;
                                  __Pyx_XGOTREF(__pyx_t_15);
                                  __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                                  __pyx_cur_scope->__pyx_t_9 = 0;
                                  __Pyx_XGOTREF(__pyx_t_16);
                                  __pyx_t_17 = __pyx_cur_scope->__pyx_t_10;
                                  __pyx_cur_scope->__pyx_t_10 = 0;
                                  __Pyx_XGOTREF(__pyx_t_17);
                                  __pyx_t_18 = __pyx_cur_scope->__pyx_t_11;
                                  __pyx_cur_scope->__pyx_t_11 = 0;
                                  __Pyx_XGOTREF(__pyx_t_18);
                                  __pyx_t_19 = __pyx_cur_scope->__pyx_t_12;
                                  __pyx_cur_scope->__pyx_t_12 = 0;
                                  __Pyx_XGOTREF(__pyx_t_19);
                                  __pyx_t_20 = __pyx_cur_scope->__pyx_t_13;
                                  __pyx_cur_scope->__pyx_t_13 = 0;
                                  __Pyx_XGOTREF(__pyx_t_20);
                                  __pyx_t_21 = __pyx_cur_scope->__pyx_t_14;
                                  __pyx_cur_scope->__pyx_t_14 = 0;
                                  __Pyx_XGOTREF(__pyx_t_21);
                                  __pyx_t_22 = __pyx_cur_scope->__pyx_t_15;
                                  __pyx_cur_scope->__pyx_t_15 = 0;
                                  __Pyx_XGOTREF(__pyx_t_22);
                                  __pyx_t_23 = __pyx_cur_scope->__pyx_t_16;
                                  __pyx_cur_scope->__pyx_t_16 = 0;
                                  __Pyx_XGOTREF(__pyx_t_23);
                                  __pyx_t_25 = __pyx_cur_scope->__pyx_t_17;
                                  __pyx_cur_scope->__pyx_t_17 = 0;
                                  __Pyx_XGOTREF(__pyx_t_25);
                                  __pyx_t_35 = __pyx_cur_scope->__pyx_t_18;
                                  __pyx_t_37 = __pyx_cur_scope->__pyx_t_19;
                                  __pyx_cur_scope->__pyx_t_19 = 0;
                                  __Pyx_XGOTREF(__pyx_t_37);
                                  __pyx_t_45 = __pyx_cur_scope->__pyx_t_23;
                                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5560, __pyx_L732_except_error)
                                  __pyx_t_7 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_7);
                                } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __pyx_t_7 = __pyx_r; __pyx_r = NULL;
                                } else {
                                  __Pyx_XGOTREF(__pyx_r);
                                  __PYX_ERR(0, 5560, __pyx_L732_except_error)
                                }
                                __pyx_t_18 = __pyx_t_7;
                                __pyx_t_7 = 0;
                                __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_t_18);
                                __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                                if (__pyx_t_47 < (0)) __PYX_ERR(0, 5560, __pyx_L732_except_error)
                                __pyx_t_28 = (!__pyx_t_47);
                                if (unlikely(__pyx_t_28)) {
                                  __Pyx_GIVEREF(__pyx_t_23);
                                  __Pyx_GIVEREF(__pyx_t_10);
                                  __Pyx_XGIVEREF(__pyx_t_25);
                                  __Pyx_ErrRestoreWithState(__pyx_t_23, __pyx_t_10, __pyx_t_25);
                                  __pyx_t_23 = 0;  __pyx_t_10 = 0;  __pyx_t_25 = 0; 
                                  __PYX_ERR(0, 5560, __pyx_L732_except_error)
                                }
                                __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                                __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                                goto __pyx_L731_exception_handled;
                              }
                              __pyx_L732_except_error:;
                              __Pyx_XGIVEREF(__pyx_t_15);
                              __Pyx_XGIVEREF(__pyx_t_21);
                              __Pyx_XGIVEREF(__pyx_t_22);
                              __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_21, __pyx_t_22);
                              goto __pyx_L715_error;
                              __pyx_L731_exception_handled:;
                              __Pyx_XGIVEREF(__pyx_t_15);
                              __Pyx_XGIVEREF(__pyx_t_21);
                              __Pyx_XGIVEREF(__pyx_t_22);
                              __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_21, __pyx_t_22);
                              __pyx_L737_try_end:;
                            }
                          }
                          /*finally:*/ {
                            /*normal exit:*/{
                              if (__pyx_t_37) {
                                __pyx_t_22 = __Pyx_PyObject_Call(__pyx_t_37, __pyx_mstate_global->__pyx_tuple[7], NULL);
                                __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                                if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 5560, __pyx_L715_error)
                                __Pyx_GOTREF(__pyx_t_22);
                                __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_22, &__pyx_r);
                                __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                                if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __Pyx_XGIVEREF(__pyx_t_1);
                                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                  __Pyx_XGIVEREF(__pyx_t_2);
                                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                  __Pyx_XGIVEREF(__pyx_t_3);
                                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                  __Pyx_XGIVEREF(__pyx_t_5);
                                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_5;
                                  __Pyx_XGIVEREF(__pyx_t_12);
                                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                                  __Pyx_XGIVEREF(__pyx_t_13);
                                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                                  __Pyx_XGIVEREF(__pyx_t_14);
                                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                                  __Pyx_XGIVEREF(__pyx_t_16);
                                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_16;
                                  __Pyx_XGIVEREF(__pyx_t_17);
                                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_17;
                                  __Pyx_XGIVEREF(__pyx_t_19);
                                  __pyx_cur_scope->__pyx_t_9 = __pyx_t_19;
                                  __Pyx_XGIVEREF(__pyx_t_20);
                                  __pyx_cur_scope->__pyx_t_10 = __pyx_t_20;
                                  __Pyx_XGIVEREF(__pyx_t_22);
                                  __pyx_cur_scope->__pyx_t_11 = __pyx_t_22;
                                  __pyx_cur_scope->__pyx_t_18 = __pyx_t_35;
                                  __Pyx_XGIVEREF(__pyx_t_37);
                                  __pyx_cur_scope->__pyx_t_12 = __pyx_t_37;
                                  __pyx_cur_scope->__pyx_t_23 = __pyx_t_45;
                                  __Pyx_XGIVEREF(__pyx_r);
                                  __Pyx_RefNannyFinishContext();
                                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                                  /* return from generator, awaiting value */
                                  __pyx_generator->resume_label = 58;
                                  return __pyx_r;
                                  __pyx_L747_resume_from_await:;
                                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                  __pyx_cur_scope->__pyx_t_0 = 0;
                                  __Pyx_XGOTREF(__pyx_t_1);
                                  __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                  __pyx_cur_scope->__pyx_t_1 = 0;
                                  __Pyx_XGOTREF(__pyx_t_2);
                                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                  __pyx_cur_scope->__pyx_t_2 = 0;
                                  __Pyx_XGOTREF(__pyx_t_3);
                                  __pyx_t_5 = __pyx_cur_scope->__pyx_t_3;
                                  __pyx_cur_scope->__pyx_t_3 = 0;
                                  __Pyx_XGOTREF(__pyx_t_5);
                                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                                  __pyx_cur_scope->__pyx_t_4 = 0;
                                  __Pyx_XGOTREF(__pyx_t_12);
                                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                                  __pyx_cur_scope->__pyx_t_5 = 0;
                                  __Pyx_XGOTREF(__pyx_t_13);
                                  __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                                  __pyx_cur_scope->__pyx_t_6 = 0;
                                  __Pyx_XGOTREF(__pyx_t_14);
                                  __pyx_t_16 = __pyx_cur_scope->__pyx_t_7;
                                  __pyx_cur_scope->__pyx_t_7 = 0;
                                  __Pyx_XGOTREF(__pyx_t_16);
                                  __pyx_t_17 = __pyx_cur_scope->__pyx_t_8;
                                  __pyx_cur_scope->__pyx_t_8 = 0;
                                  __Pyx_XGOTREF(__pyx_t_17);
                                  __pyx_t_19 = __pyx_cur_scope->__pyx_t_9;
                                  __pyx_cur_scope->__pyx_t_9 = 0;
                                  __Pyx_XGOTREF(__pyx_t_19);
                                  __pyx_t_20 = __pyx_cur_scope->__pyx_t_10;
                                  __pyx_cur_scope->__pyx_t_10 = 0;
                                  __Pyx_XGOTREF(__pyx_t_20);
                                  __pyx_t_22 = __pyx_cur_scope->__pyx_t_11;
                                  __pyx_cur_scope->__pyx_t_11 = 0;
                                  __Pyx_XGOTREF(__pyx_t_22);
                                  __pyx_t_35 = __pyx_cur_scope->__pyx_t_18;
                                  __pyx_t_37 = __pyx_cur_scope->__pyx_t_12;
                                  __pyx_cur_scope->__pyx_t_12 = 0;
                                  __Pyx_XGOTREF(__pyx_t_37);
                                  __pyx_t_45 = __pyx_cur_scope->__pyx_t_23;
                                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5560, __pyx_L715_error)
                                  __pyx_t_25 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_25);
                                } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __pyx_t_25 = __pyx_r; __pyx_r = NULL;
                                } else {
                                  __Pyx_XGOTREF(__pyx_r);
                                  __PYX_ERR(0, 5560, __pyx_L715_error)
                                }
                                __pyx_t_22 = __pyx_t_25;
                                __pyx_t_25 = 0;
                                __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                              }
                              goto __pyx_L729;
                            }
                            __pyx_L729:;
                          }
                          goto __pyx_L748;
                          __pyx_L723_error:;
                          __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                          goto __pyx_L715_error;
                          __pyx_L748:;
                        }

                        /* "ws_package/controllers/activity_controller.py":5559
 *                         # Query database to get the actual record with ID
 *                         try:
 *                             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                                 async with async_session() as session:
 *                                     query = select(ActivityInterval).where(
*/
                      }
                      __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                      __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                      goto __pyx_L722_try_end;
                      __pyx_L715_error:;
                      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                      __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                      __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                      __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                      __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                      __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                      __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                      __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                      __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                      __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
                      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                      /*except:*/ {
                        __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
                        if (__Pyx_GetException(&__pyx_t_25, &__pyx_t_10, &__pyx_t_23) < 0) __PYX_ERR(0, 5559, __pyx_L717_except_error)
                        __Pyx_XGOTREF(__pyx_t_25);
                        __Pyx_XGOTREF(__pyx_t_10);
                        __Pyx_XGOTREF(__pyx_t_23);
                        __pyx_t_7 = PyTuple_Pack(3, __pyx_t_25, __pyx_t_10, __pyx_t_23); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5559, __pyx_L717_except_error)
                        __Pyx_GOTREF(__pyx_t_7);
                        __pyx_t_37 = __Pyx_PyObject_Call(__pyx_t_20, __pyx_t_7, NULL);
                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                        if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 5559, __pyx_L717_except_error)
                        __Pyx_GOTREF(__pyx_t_37);
                        __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_37);
                        __Pyx_DECREF(__pyx_t_37); __pyx_t_37 = 0;
                        if (__pyx_t_28 < (0)) __PYX_ERR(0, 5559, __pyx_L717_except_error)
                        __pyx_t_47 = (!__pyx_t_28);
                        if (unlikely(__pyx_t_47)) {
                          __Pyx_GIVEREF(__pyx_t_25);
                          __Pyx_GIVEREF(__pyx_t_10);
                          __Pyx_XGIVEREF(__pyx_t_23);
                          __Pyx_ErrRestoreWithState(__pyx_t_25, __pyx_t_10, __pyx_t_23);
                          __pyx_t_25 = 0;  __pyx_t_10 = 0;  __pyx_t_23 = 0; 
                          __PYX_ERR(0, 5559, __pyx_L717_except_error)
                        }
                        __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                        __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                        goto __pyx_L716_exception_handled;
                      }
                      __pyx_L717_except_error:;
                      __Pyx_XGIVEREF(__pyx_t_19);
                      __Pyx_XGIVEREF(__pyx_t_16);
                      __Pyx_XGIVEREF(__pyx_t_17);
                      __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_16, __pyx_t_17);
                      goto __pyx_L701_error;
                      __pyx_L716_exception_handled:;
                      __Pyx_XGIVEREF(__pyx_t_19);
                      __Pyx_XGIVEREF(__pyx_t_16);
                      __Pyx_XGIVEREF(__pyx_t_17);
                      __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_16, __pyx_t_17);
                      __pyx_L722_try_end:;
                    }
                  }
                  /*finally:*/ {
                    /*normal exit:*/{
                      if (__pyx_t_20) {
                        __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_20, __pyx_mstate_global->__pyx_tuple[7], NULL);
                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 5559, __pyx_L701_error)
                        __Pyx_GOTREF(__pyx_t_17);
                        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                      }
                      goto __pyx_L714;
                    }
                    __pyx_L714:;
                  }
                  goto __pyx_L752;
                  __pyx_L709_error:;
                  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                  goto __pyx_L701_error;
                  __pyx_L752:;
                }

                /* "ws_package/controllers/activity_controller.py":5558
 *                     else:
 *                         # Query database to get the actual record with ID
 *                         try:             # <<<<<<<<<<<<<<
 *                             with db_lock_manager.read_lock():
 *                                 async with async_session() as session:
*/
              }
              __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              goto __pyx_L708_try_end;
              __pyx_L701_error:;
              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
              __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
              __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
              __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
              __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
              __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
              __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

              /* "ws_package/controllers/activity_controller.py":5573
 *                                         if db_interval.id not in updated_interval_ids:
 *                                             interval_to_update = db_interval
 *                         except Exception as e:             # <<<<<<<<<<<<<<
 *                             logger.error("Error querying database for interval: %s", e, exc_info=True)
 * 
*/
              __pyx_t_32 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
              if (__pyx_t_32) {
                __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
                if (__Pyx_GetException(&__pyx_t_23, &__pyx_t_10, &__pyx_t_25) < 0) __PYX_ERR(0, 5573, __pyx_L703_except_error)
                __Pyx_XGOTREF(__pyx_t_23);
                __Pyx_XGOTREF(__pyx_t_10);
                __Pyx_XGOTREF(__pyx_t_25);
                __Pyx_INCREF(__pyx_t_10);
                __Pyx_GIVEREF(__pyx_t_10);
                __pyx_cur_scope->__pyx_v_e = __pyx_t_10;
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":5574
 *                                             interval_to_update = db_interval
 *                         except Exception as e:
 *                             logger.error("Error querying database for interval: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *                     if interval_to_update:
*/
                  __pyx_t_40 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5574, __pyx_L758_error)
                  __Pyx_GOTREF(__pyx_t_4);
                  __pyx_t_52 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5574, __pyx_L758_error)
                  __Pyx_GOTREF(__pyx_t_52);
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __pyx_t_8 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_52))) {
                    __pyx_t_40 = PyMethod_GET_SELF(__pyx_t_52);
                    assert(__pyx_t_40);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_52);
                    __Pyx_INCREF(__pyx_t_40);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_52, __pyx__function);
                    __pyx_t_8 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_40, __pyx_mstate_global->__pyx_kp_u_Error_querying_database_for_inte, __pyx_cur_scope->__pyx_v_e};
                    __pyx_t_4 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5574, __pyx_L758_error)
                    __Pyx_GOTREF(__pyx_t_4);
                    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_4, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 5574, __pyx_L758_error)
                    __pyx_t_7 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_52, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_4);
                    __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
                    if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5574, __pyx_L758_error)
                    __Pyx_GOTREF(__pyx_t_7);
                  }
                  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                }

                /* "ws_package/controllers/activity_controller.py":5573
 *                                         if db_interval.id not in updated_interval_ids:
 *                                             interval_to_update = db_interval
 *                         except Exception as e:             # <<<<<<<<<<<<<<
 *                             logger.error("Error querying database for interval: %s", e, exc_info=True)
 * 
*/
                /*finally:*/ {
                  /*normal exit:*/{
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    goto __pyx_L759;
                  }
                  __pyx_L758_error:;
                  /*exception exit:*/{
                    __Pyx_PyThreadState_assign
                    __pyx_t_20 = 0; __pyx_t_17 = 0; __pyx_t_16 = 0; __pyx_t_19 = 0; __pyx_t_37 = 0; __pyx_t_22 = 0;
                    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                    __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                    __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                    __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                    __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                    __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                    __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                     __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_37, &__pyx_t_22);
                    if ( unlikely(__Pyx_GetException(&__pyx_t_20, &__pyx_t_17, &__pyx_t_16) < 0)) __Pyx_ErrFetch(&__pyx_t_20, &__pyx_t_17, &__pyx_t_16);
                    __Pyx_XGOTREF(__pyx_t_20);
                    __Pyx_XGOTREF(__pyx_t_17);
                    __Pyx_XGOTREF(__pyx_t_16);
                    __Pyx_XGOTREF(__pyx_t_19);
                    __Pyx_XGOTREF(__pyx_t_37);
                    __Pyx_XGOTREF(__pyx_t_22);
                    __pyx_t_32 = __pyx_lineno; __pyx_t_31 = __pyx_clineno; __pyx_t_62 = __pyx_filename;
                    {
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    }
                    __Pyx_XGIVEREF(__pyx_t_19);
                    __Pyx_XGIVEREF(__pyx_t_37);
                    __Pyx_XGIVEREF(__pyx_t_22);
                    __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_37, __pyx_t_22);
                    __Pyx_XGIVEREF(__pyx_t_20);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_ErrRestore(__pyx_t_20, __pyx_t_17, __pyx_t_16);
                    __pyx_t_20 = 0; __pyx_t_17 = 0; __pyx_t_16 = 0; __pyx_t_19 = 0; __pyx_t_37 = 0; __pyx_t_22 = 0;
                    __pyx_lineno = __pyx_t_32; __pyx_clineno = __pyx_t_31; __pyx_filename = __pyx_t_62;
                    goto __pyx_L703_except_error;
                  }
                  __pyx_L759:;
                }
                __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                goto __pyx_L702_exception_handled;
              }
              goto __pyx_L703_except_error;

              /* "ws_package/controllers/activity_controller.py":5558
 *                     else:
 *                         # Query database to get the actual record with ID
 *                         try:             # <<<<<<<<<<<<<<
 *                             with db_lock_manager.read_lock():
 *                                 async with async_session() as session:
*/
              __pyx_L703_except_error:;
              __Pyx_XGIVEREF(__pyx_t_14);
              __Pyx_XGIVEREF(__pyx_t_13);
              __Pyx_XGIVEREF(__pyx_t_12);
              __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12);
              goto __pyx_L4_error;
              __pyx_L702_exception_handled:;
              __Pyx_XGIVEREF(__pyx_t_14);
              __Pyx_XGIVEREF(__pyx_t_13);
              __Pyx_XGIVEREF(__pyx_t_12);
              __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12);
              __pyx_L708_try_end:;
            }
          }
          __pyx_L697:;

          /* "ws_package/controllers/activity_controller.py":5576
 *                             logger.error("Error querying database for interval: %s", e, exc_info=True)
 * 
 *                     if interval_to_update:             # <<<<<<<<<<<<<<
 *                         # This interval was sent but not updated yet - mark it as uploaded
 *                         try:
*/
          __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_interval_to_update); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5576, __pyx_L4_error)
          if (__pyx_t_47) {

            /* "ws_package/controllers/activity_controller.py":5578
 *                     if interval_to_update:
 *                         # This interval was sent but not updated yet - mark it as uploaded
 *                         try:             # <<<<<<<<<<<<<<
 *                             await self.activity_service.update_activity_interval(interval_to_update)
 *                             intervals_updated_count += 1
*/
            {
              __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
              __Pyx_XGOTREF(__pyx_t_12);
              __Pyx_XGOTREF(__pyx_t_13);
              __Pyx_XGOTREF(__pyx_t_14);
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":5579
 *                         # This interval was sent but not updated yet - mark it as uploaded
 *                         try:
 *                             await self.activity_service.update_activity_interval(interval_to_update)             # <<<<<<<<<<<<<<
 *                             intervals_updated_count += 1
 *                             logger.debug("Marked interval (id=%s, counter=%s) from current session as uploaded", interval_to_update.id, getattr(interval_to_update, 'counter', 'N/A'))
*/
                __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5579, __pyx_L765_error)
                __Pyx_GOTREF(__pyx_t_23);
                __pyx_t_10 = __pyx_t_23;
                __Pyx_INCREF(__pyx_t_10);
                __pyx_t_8 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_cur_scope->__pyx_v_interval_to_update};
                  __pyx_t_25 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_update_activity_interval, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                  __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                  if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5579, __pyx_L765_error)
                  __Pyx_GOTREF(__pyx_t_25);
                }
                __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_25, &__pyx_r);
                __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_1);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                  __Pyx_XGIVEREF(__pyx_t_2);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                  __Pyx_XGIVEREF(__pyx_t_3);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                  __Pyx_XGIVEREF(__pyx_t_5);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_5;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_t_14);
                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                  __pyx_cur_scope->__pyx_t_18 = __pyx_t_35;
                  __pyx_cur_scope->__pyx_t_23 = __pyx_t_45;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 59;
                  return __pyx_r;
                  __pyx_L773_resume_from_await:;
                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_1);
                  __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_2);
                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_3);
                  __pyx_t_5 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_5);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                  __pyx_cur_scope->__pyx_t_6 = 0;
                  __Pyx_XGOTREF(__pyx_t_14);
                  __pyx_t_35 = __pyx_cur_scope->__pyx_t_18;
                  __pyx_t_45 = __pyx_cur_scope->__pyx_t_23;
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5579, __pyx_L765_error)
                } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 5579, __pyx_L765_error)
                }

                /* "ws_package/controllers/activity_controller.py":5580
 *                         try:
 *                             await self.activity_service.update_activity_interval(interval_to_update)
 *                             intervals_updated_count += 1             # <<<<<<<<<<<<<<
 *                             logger.debug("Marked interval (id=%s, counter=%s) from current session as uploaded", interval_to_update.id, getattr(interval_to_update, 'counter', 'N/A'))
 *                         except Exception as e:
*/
                __pyx_t_25 = __Pyx_PyLong_AddObjC(__pyx_cur_scope->__pyx_v_intervals_updated_count, __pyx_mstate_global->__pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5580, __pyx_L765_error)
                __Pyx_GOTREF(__pyx_t_25);
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_intervals_updated_count);
                __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_intervals_updated_count, __pyx_t_25);
                __Pyx_GIVEREF(__pyx_t_25);
                __pyx_t_25 = 0;

                /* "ws_package/controllers/activity_controller.py":5581
 *                             await self.activity_service.update_activity_interval(interval_to_update)
 *                             intervals_updated_count += 1
 *                             logger.debug("Marked interval (id=%s, counter=%s) from current session as uploaded", interval_to_update.id, getattr(interval_to_update, 'counter', 'N/A'))             # <<<<<<<<<<<<<<
 *                         except Exception as e:
 *                             logger.error("Error updating interval (id=%s): %s", getattr(interval_to_update, 'id', 'N/A'), e, exc_info=True)
*/
                __pyx_t_23 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5581, __pyx_L765_error)
                __Pyx_GOTREF(__pyx_t_10);
                __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5581, __pyx_L765_error)
                __Pyx_GOTREF(__pyx_t_7);
                __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval_to_update, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5581, __pyx_L765_error)
                __Pyx_GOTREF(__pyx_t_10);
                __pyx_t_52 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval_to_update, __pyx_mstate_global->__pyx_n_u_counter, __pyx_mstate_global->__pyx_kp_u_N_A); if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5581, __pyx_L765_error)
                __Pyx_GOTREF(__pyx_t_52);
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_7))) {
                  __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_7);
                  assert(__pyx_t_23);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                  __Pyx_INCREF(__pyx_t_23);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[4] = {__pyx_t_23, __pyx_mstate_global->__pyx_kp_u_Marked_interval_id_s_counter_s_f, __pyx_t_10, __pyx_t_52};
                  __pyx_t_25 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                  __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
                  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                  if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5581, __pyx_L765_error)
                  __Pyx_GOTREF(__pyx_t_25);
                }
                __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;

                /* "ws_package/controllers/activity_controller.py":5578
 *                     if interval_to_update:
 *                         # This interval was sent but not updated yet - mark it as uploaded
 *                         try:             # <<<<<<<<<<<<<<
 *                             await self.activity_service.update_activity_interval(interval_to_update)
 *                             intervals_updated_count += 1
*/
              }
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
              goto __pyx_L772_try_end;
              __pyx_L765_error:;
              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
              __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
              __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
              __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
              __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
              __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
              __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

              /* "ws_package/controllers/activity_controller.py":5582
 *                             intervals_updated_count += 1
 *                             logger.debug("Marked interval (id=%s, counter=%s) from current session as uploaded", interval_to_update.id, getattr(interval_to_update, 'counter', 'N/A'))
 *                         except Exception as e:             # <<<<<<<<<<<<<<
 *                             logger.error("Error updating interval (id=%s): %s", getattr(interval_to_update, 'id', 'N/A'), e, exc_info=True)
 * 
*/
              __pyx_t_31 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
              if (__pyx_t_31) {
                __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
                if (__Pyx_GetException(&__pyx_t_25, &__pyx_t_7, &__pyx_t_52) < 0) __PYX_ERR(0, 5582, __pyx_L767_except_error)
                __Pyx_XGOTREF(__pyx_t_25);
                __Pyx_XGOTREF(__pyx_t_7);
                __Pyx_XGOTREF(__pyx_t_52);
                __Pyx_INCREF(__pyx_t_7);
                __Pyx_GIVEREF(__pyx_t_7);
                __pyx_cur_scope->__pyx_v_e = __pyx_t_7;
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":5583
 *                             logger.debug("Marked interval (id=%s, counter=%s) from current session as uploaded", interval_to_update.id, getattr(interval_to_update, 'counter', 'N/A'))
 *                         except Exception as e:
 *                             logger.error("Error updating interval (id=%s): %s", getattr(interval_to_update, 'id', 'N/A'), e, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *                 if intervals_updated_count > 0:
*/
                  __pyx_t_23 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5583, __pyx_L779_error)
                  __Pyx_GOTREF(__pyx_t_4);
                  __pyx_t_40 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_40)) __PYX_ERR(0, 5583, __pyx_L779_error)
                  __Pyx_GOTREF(__pyx_t_40);
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __pyx_t_4 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval_to_update, __pyx_mstate_global->__pyx_n_u_id, __pyx_mstate_global->__pyx_kp_u_N_A); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5583, __pyx_L779_error)
                  __Pyx_GOTREF(__pyx_t_4);
                  __pyx_t_8 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_40))) {
                    __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_40);
                    assert(__pyx_t_23);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_40);
                    __Pyx_INCREF(__pyx_t_23);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_40, __pyx__function);
                    __pyx_t_8 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[4 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_23, __pyx_mstate_global->__pyx_kp_u_Error_updating_interval_id_s_s, __pyx_t_4, __pyx_cur_scope->__pyx_v_e};
                    __pyx_t_39 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5583, __pyx_L779_error)
                    __Pyx_GOTREF(__pyx_t_39);
                    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_39, __pyx_callargs+4, 0) < (0)) __PYX_ERR(0, 5583, __pyx_L779_error)
                    __pyx_t_10 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_40, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_39);
                    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                    __Pyx_DECREF(__pyx_t_40); __pyx_t_40 = 0;
                    if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5583, __pyx_L779_error)
                    __Pyx_GOTREF(__pyx_t_10);
                  }
                  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                }

                /* "ws_package/controllers/activity_controller.py":5582
 *                             intervals_updated_count += 1
 *                             logger.debug("Marked interval (id=%s, counter=%s) from current session as uploaded", interval_to_update.id, getattr(interval_to_update, 'counter', 'N/A'))
 *                         except Exception as e:             # <<<<<<<<<<<<<<
 *                             logger.error("Error updating interval (id=%s): %s", getattr(interval_to_update, 'id', 'N/A'), e, exc_info=True)
 * 
*/
                /*finally:*/ {
                  /*normal exit:*/{
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    goto __pyx_L780;
                  }
                  __pyx_L779_error:;
                  /*exception exit:*/{
                    __Pyx_PyThreadState_assign
                    __pyx_t_22 = 0; __pyx_t_37 = 0; __pyx_t_19 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_20 = 0;
                    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                    __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                    __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                    __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                    __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                    __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                     __Pyx_ExceptionSwap(&__pyx_t_16, &__pyx_t_17, &__pyx_t_20);
                    if ( unlikely(__Pyx_GetException(&__pyx_t_22, &__pyx_t_37, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_22, &__pyx_t_37, &__pyx_t_19);
                    __Pyx_XGOTREF(__pyx_t_22);
                    __Pyx_XGOTREF(__pyx_t_37);
                    __Pyx_XGOTREF(__pyx_t_19);
                    __Pyx_XGOTREF(__pyx_t_16);
                    __Pyx_XGOTREF(__pyx_t_17);
                    __Pyx_XGOTREF(__pyx_t_20);
                    __pyx_t_31 = __pyx_lineno; __pyx_t_32 = __pyx_clineno; __pyx_t_63 = __pyx_filename;
                    {
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    }
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_XGIVEREF(__pyx_t_20);
                    __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_20);
                    __Pyx_XGIVEREF(__pyx_t_22);
                    __Pyx_XGIVEREF(__pyx_t_37);
                    __Pyx_XGIVEREF(__pyx_t_19);
                    __Pyx_ErrRestore(__pyx_t_22, __pyx_t_37, __pyx_t_19);
                    __pyx_t_22 = 0; __pyx_t_37 = 0; __pyx_t_19 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_20 = 0;
                    __pyx_lineno = __pyx_t_31; __pyx_clineno = __pyx_t_32; __pyx_filename = __pyx_t_63;
                    goto __pyx_L767_except_error;
                  }
                  __pyx_L780:;
                }
                __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                goto __pyx_L766_exception_handled;
              }
              goto __pyx_L767_except_error;

              /* "ws_package/controllers/activity_controller.py":5578
 *                     if interval_to_update:
 *                         # This interval was sent but not updated yet - mark it as uploaded
 *                         try:             # <<<<<<<<<<<<<<
 *                             await self.activity_service.update_activity_interval(interval_to_update)
 *                             intervals_updated_count += 1
*/
              __pyx_L767_except_error:;
              __Pyx_XGIVEREF(__pyx_t_12);
              __Pyx_XGIVEREF(__pyx_t_13);
              __Pyx_XGIVEREF(__pyx_t_14);
              __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
              goto __pyx_L4_error;
              __pyx_L766_exception_handled:;
              __Pyx_XGIVEREF(__pyx_t_12);
              __Pyx_XGIVEREF(__pyx_t_13);
              __Pyx_XGIVEREF(__pyx_t_14);
              __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
              __pyx_L772_try_end:;
            }

            /* "ws_package/controllers/activity_controller.py":5576
 *                             logger.error("Error querying database for interval: %s", e, exc_info=True)
 * 
 *                     if interval_to_update:             # <<<<<<<<<<<<<<
 *                         # This interval was sent but not updated yet - mark it as uploaded
 *                         try:
*/
          }

          /* "ws_package/controllers/activity_controller.py":5550
 *             if at_least_one_batch_successful and intervals:
 *                 intervals_updated_count = 0
 *                 for interval in intervals:             # <<<<<<<<<<<<<<
 *                     # If interval doesn't have an ID, query database to get it
 *                     interval_to_update = None
*/
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":5585
 *                             logger.error("Error updating interval (id=%s): %s", getattr(interval_to_update, 'id', 'N/A'), e, exc_info=True)
 * 
 *                 if intervals_updated_count > 0:             # <<<<<<<<<<<<<<
 *                     logger.info("Marked %s additional intervals from current session (counter=%s) as uploaded", intervals_updated_count, current_session_counter)
 *                     # Flush the queue to ensure all updates are committed
*/
        __pyx_t_5 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_intervals_updated_count, __pyx_mstate_global->__pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5585, __pyx_L4_error)
        __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5585, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (__pyx_t_47) {

          /* "ws_package/controllers/activity_controller.py":5586
 * 
 *                 if intervals_updated_count > 0:
 *                     logger.info("Marked %s additional intervals from current session (counter=%s) as uploaded", intervals_updated_count, current_session_counter)             # <<<<<<<<<<<<<<
 *                     # Flush the queue to ensure all updates are committed
 *                     try:
*/
          __pyx_t_52 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5586, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
          __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5586, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_25);
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_25))) {
            __pyx_t_52 = PyMethod_GET_SELF(__pyx_t_25);
            assert(__pyx_t_52);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_25);
            __Pyx_INCREF(__pyx_t_52);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_25, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[4] = {__pyx_t_52, __pyx_mstate_global->__pyx_kp_u_Marked_s_additional_intervals_fr, __pyx_cur_scope->__pyx_v_intervals_updated_count, __pyx_cur_scope->__pyx_v_current_session_counter};
            __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_25, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
            __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5586, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":5588
 *                     logger.info("Marked %s additional intervals from current session (counter=%s) as uploaded", intervals_updated_count, current_session_counter)
 *                     # Flush the queue to ensure all updates are committed
 *                     try:             # <<<<<<<<<<<<<<
 *                         processed_count = await db_writer_service.process_immediately()
 *                         logger.info("Flushed %s queued database updates after marking all current session intervals as uploaded", processed_count)
*/
          {
            __Pyx_ExceptionSave(&__pyx_t_14, &__pyx_t_13, &__pyx_t_12);
            __Pyx_XGOTREF(__pyx_t_14);
            __Pyx_XGOTREF(__pyx_t_13);
            __Pyx_XGOTREF(__pyx_t_12);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":5589
 *                     # Flush the queue to ensure all updates are committed
 *                     try:
 *                         processed_count = await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 *                         logger.info("Flushed %s queued database updates after marking all current session intervals as uploaded", processed_count)
 *                         if processed_count > 0:
*/
              __pyx_t_25 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_52, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5589, __pyx_L787_error)
              __Pyx_GOTREF(__pyx_t_52);
              __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_52, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5589, __pyx_L787_error)
              __Pyx_GOTREF(__pyx_t_7);
              __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_7))) {
                __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_7);
                assert(__pyx_t_25);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                __Pyx_INCREF(__pyx_t_25);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_25, NULL};
                __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5589, __pyx_L787_error)
                __Pyx_GOTREF(__pyx_t_5);
              }
              __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_XGIVEREF(__pyx_t_1);
                __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                __Pyx_XGIVEREF(__pyx_t_2);
                __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                __Pyx_XGIVEREF(__pyx_t_3);
                __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                __Pyx_XGIVEREF(__pyx_t_12);
                __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                __Pyx_XGIVEREF(__pyx_t_13);
                __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                __Pyx_XGIVEREF(__pyx_t_14);
                __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                __Pyx_XGIVEREF(__pyx_r);
                __Pyx_RefNannyFinishContext();
                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                /* return from generator, awaiting value */
                __pyx_generator->resume_label = 60;
                return __pyx_r;
                __pyx_L793_resume_from_await:;
                __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                __pyx_cur_scope->__pyx_t_0 = 0;
                __Pyx_XGOTREF(__pyx_t_1);
                __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                __pyx_cur_scope->__pyx_t_1 = 0;
                __Pyx_XGOTREF(__pyx_t_2);
                __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                __pyx_cur_scope->__pyx_t_2 = 0;
                __Pyx_XGOTREF(__pyx_t_3);
                __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                __pyx_cur_scope->__pyx_t_3 = 0;
                __Pyx_XGOTREF(__pyx_t_12);
                __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                __pyx_cur_scope->__pyx_t_4 = 0;
                __Pyx_XGOTREF(__pyx_t_13);
                __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                __pyx_cur_scope->__pyx_t_5 = 0;
                __Pyx_XGOTREF(__pyx_t_14);
                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5589, __pyx_L787_error)
                __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
              } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                __Pyx_GOTREF(__pyx_r);
                __pyx_t_5 = __pyx_r; __pyx_r = NULL;
              } else {
                __Pyx_XGOTREF(__pyx_r);
                __PYX_ERR(0, 5589, __pyx_L787_error)
              }
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_processed_count);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_processed_count, __pyx_t_5);
              __Pyx_GIVEREF(__pyx_t_5);
              __pyx_t_5 = 0;

              /* "ws_package/controllers/activity_controller.py":5590
 *                     try:
 *                         processed_count = await db_writer_service.process_immediately()
 *                         logger.info("Flushed %s queued database updates after marking all current session intervals as uploaded", processed_count)             # <<<<<<<<<<<<<<
 *                         if processed_count > 0:
 *                             await asyncio.sleep(0.3)
*/
              __pyx_t_7 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5590, __pyx_L787_error)
              __Pyx_GOTREF(__pyx_t_25);
              __pyx_t_52 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5590, __pyx_L787_error)
              __Pyx_GOTREF(__pyx_t_52);
              __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_52))) {
                __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_52);
                assert(__pyx_t_7);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_52);
                __Pyx_INCREF(__pyx_t_7);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_52, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Flushed_s_queued_database_update_2, __pyx_cur_scope->__pyx_v_processed_count};
                __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_52, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
                if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5590, __pyx_L787_error)
                __Pyx_GOTREF(__pyx_t_5);
              }
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

              /* "ws_package/controllers/activity_controller.py":5591
 *                         processed_count = await db_writer_service.process_immediately()
 *                         logger.info("Flushed %s queued database updates after marking all current session intervals as uploaded", processed_count)
 *                         if processed_count > 0:             # <<<<<<<<<<<<<<
 *                             await asyncio.sleep(0.3)
 *                             logger.debug("Verified all current session interval updates are committed to database")
*/
              __pyx_t_5 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_processed_count, __pyx_mstate_global->__pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5591, __pyx_L787_error)
              __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5591, __pyx_L787_error)
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              if (__pyx_t_47) {

                /* "ws_package/controllers/activity_controller.py":5592
 *                         logger.info("Flushed %s queued database updates after marking all current session intervals as uploaded", processed_count)
 *                         if processed_count > 0:
 *                             await asyncio.sleep(0.3)             # <<<<<<<<<<<<<<
 *                             logger.debug("Verified all current session interval updates are committed to database")
 *                     except Exception as e:
*/
                __pyx_t_52 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5592, __pyx_L787_error)
                __Pyx_GOTREF(__pyx_t_7);
                __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5592, __pyx_L787_error)
                __Pyx_GOTREF(__pyx_t_25);
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_25))) {
                  __pyx_t_52 = PyMethod_GET_SELF(__pyx_t_25);
                  assert(__pyx_t_52);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_25);
                  __Pyx_INCREF(__pyx_t_52);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_25, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_52, __pyx_mstate_global->__pyx_float_0_3};
                  __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_25, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                  __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5592, __pyx_L787_error)
                  __Pyx_GOTREF(__pyx_t_5);
                }
                __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_1);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                  __Pyx_XGIVEREF(__pyx_t_2);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                  __Pyx_XGIVEREF(__pyx_t_3);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_t_14);
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 61;
                  return __pyx_r;
                  __pyx_L795_resume_from_await:;
                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_1);
                  __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_2);
                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_3);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = 0;
                  __Pyx_XGOTREF(__pyx_t_14);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5592, __pyx_L787_error)
                } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 5592, __pyx_L787_error)
                }

                /* "ws_package/controllers/activity_controller.py":5593
 *                         if processed_count > 0:
 *                             await asyncio.sleep(0.3)
 *                             logger.debug("Verified all current session interval updates are committed to database")             # <<<<<<<<<<<<<<
 *                     except Exception as e:
 *                         logger.error("Error flushing database write queue after marking all intervals: %s", e, exc_info=True)
*/
                __pyx_t_25 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_52, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5593, __pyx_L787_error)
                __Pyx_GOTREF(__pyx_t_52);
                __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_52, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5593, __pyx_L787_error)
                __Pyx_GOTREF(__pyx_t_7);
                __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_7))) {
                  __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_7);
                  assert(__pyx_t_25);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                  __Pyx_INCREF(__pyx_t_25);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_25, __pyx_mstate_global->__pyx_kp_u_Verified_all_current_session_int};
                  __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5593, __pyx_L787_error)
                  __Pyx_GOTREF(__pyx_t_5);
                }
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                /* "ws_package/controllers/activity_controller.py":5591
 *                         processed_count = await db_writer_service.process_immediately()
 *                         logger.info("Flushed %s queued database updates after marking all current session intervals as uploaded", processed_count)
 *                         if processed_count > 0:             # <<<<<<<<<<<<<<
 *                             await asyncio.sleep(0.3)
 *                             logger.debug("Verified all current session interval updates are committed to database")
*/
              }

              /* "ws_package/controllers/activity_controller.py":5588
 *                     logger.info("Marked %s additional intervals from current session (counter=%s) as uploaded", intervals_updated_count, current_session_counter)
 *                     # Flush the queue to ensure all updates are committed
 *                     try:             # <<<<<<<<<<<<<<
 *                         processed_count = await db_writer_service.process_immediately()
 *                         logger.info("Flushed %s queued database updates after marking all current session intervals as uploaded", processed_count)
*/
            }
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            goto __pyx_L792_try_end;
            __pyx_L787_error:;
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
            __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
            __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
            __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
            __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
            __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
            __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

            /* "ws_package/controllers/activity_controller.py":5594
 *                             await asyncio.sleep(0.3)
 *                             logger.debug("Verified all current session interval updates are committed to database")
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error flushing database write queue after marking all intervals: %s", e, exc_info=True)
 *                 else:
*/
            __pyx_t_32 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
            if (__pyx_t_32) {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_7, &__pyx_t_25) < 0) __PYX_ERR(0, 5594, __pyx_L789_except_error)
              __Pyx_XGOTREF(__pyx_t_5);
              __Pyx_XGOTREF(__pyx_t_7);
              __Pyx_XGOTREF(__pyx_t_25);
              __Pyx_INCREF(__pyx_t_7);
              __Pyx_GIVEREF(__pyx_t_7);
              __pyx_cur_scope->__pyx_v_e = __pyx_t_7;
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":5595
 *                             logger.debug("Verified all current session interval updates are committed to database")
 *                     except Exception as e:
 *                         logger.error("Error flushing database write queue after marking all intervals: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 *                 else:
 *                     logger.info("All %s intervals from current session (counter=%s) were already marked as uploaded", len(intervals), current_session_counter)
*/
                __pyx_t_10 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_40, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_40)) __PYX_ERR(0, 5595, __pyx_L801_error)
                __Pyx_GOTREF(__pyx_t_40);
                __pyx_t_39 = __Pyx_PyObject_GetAttrStr(__pyx_t_40, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5595, __pyx_L801_error)
                __Pyx_GOTREF(__pyx_t_39);
                __Pyx_DECREF(__pyx_t_40); __pyx_t_40 = 0;
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_39))) {
                  __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_39);
                  assert(__pyx_t_10);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_39);
                  __Pyx_INCREF(__pyx_t_10);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_39, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Error_flushing_database_write_qu_6, __pyx_cur_scope->__pyx_v_e};
                  __pyx_t_40 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_40)) __PYX_ERR(0, 5595, __pyx_L801_error)
                  __Pyx_GOTREF(__pyx_t_40);
                  if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_40, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 5595, __pyx_L801_error)
                  __pyx_t_52 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_39, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_40);
                  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                  __Pyx_DECREF(__pyx_t_40); __pyx_t_40 = 0;
                  __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                  if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5595, __pyx_L801_error)
                  __Pyx_GOTREF(__pyx_t_52);
                }
                __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
              }

              /* "ws_package/controllers/activity_controller.py":5594
 *                             await asyncio.sleep(0.3)
 *                             logger.debug("Verified all current session interval updates are committed to database")
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error flushing database write queue after marking all intervals: %s", e, exc_info=True)
 *                 else:
*/
              /*finally:*/ {
                /*normal exit:*/{
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  goto __pyx_L802;
                }
                __pyx_L801_error:;
                /*exception exit:*/{
                  __Pyx_PyThreadState_assign
                  __pyx_t_20 = 0; __pyx_t_17 = 0; __pyx_t_16 = 0; __pyx_t_19 = 0; __pyx_t_37 = 0; __pyx_t_22 = 0;
                  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                  __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                  __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                  __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                  __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                  __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                  __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                  __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                   __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_37, &__pyx_t_22);
                  if ( unlikely(__Pyx_GetException(&__pyx_t_20, &__pyx_t_17, &__pyx_t_16) < 0)) __Pyx_ErrFetch(&__pyx_t_20, &__pyx_t_17, &__pyx_t_16);
                  __Pyx_XGOTREF(__pyx_t_20);
                  __Pyx_XGOTREF(__pyx_t_17);
                  __Pyx_XGOTREF(__pyx_t_16);
                  __Pyx_XGOTREF(__pyx_t_19);
                  __Pyx_XGOTREF(__pyx_t_37);
                  __Pyx_XGOTREF(__pyx_t_22);
                  __pyx_t_32 = __pyx_lineno; __pyx_t_31 = __pyx_clineno; __pyx_t_64 = __pyx_filename;
                  {
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                  }
                  __Pyx_XGIVEREF(__pyx_t_19);
                  __Pyx_XGIVEREF(__pyx_t_37);
                  __Pyx_XGIVEREF(__pyx_t_22);
                  __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_37, __pyx_t_22);
                  __Pyx_XGIVEREF(__pyx_t_20);
                  __Pyx_XGIVEREF(__pyx_t_17);
                  __Pyx_XGIVEREF(__pyx_t_16);
                  __Pyx_ErrRestore(__pyx_t_20, __pyx_t_17, __pyx_t_16);
                  __pyx_t_20 = 0; __pyx_t_17 = 0; __pyx_t_16 = 0; __pyx_t_19 = 0; __pyx_t_37 = 0; __pyx_t_22 = 0;
                  __pyx_lineno = __pyx_t_32; __pyx_clineno = __pyx_t_31; __pyx_filename = __pyx_t_64;
                  goto __pyx_L789_except_error;
                }
                __pyx_L802:;
              }
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
              __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
              goto __pyx_L788_exception_handled;
            }
            goto __pyx_L789_except_error;

            /* "ws_package/controllers/activity_controller.py":5588
 *                     logger.info("Marked %s additional intervals from current session (counter=%s) as uploaded", intervals_updated_count, current_session_counter)
 *                     # Flush the queue to ensure all updates are committed
 *                     try:             # <<<<<<<<<<<<<<
 *                         processed_count = await db_writer_service.process_immediately()
 *                         logger.info("Flushed %s queued database updates after marking all current session intervals as uploaded", processed_count)
*/
            __pyx_L789_except_error:;
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12);
            goto __pyx_L4_error;
            __pyx_L788_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_13, __pyx_t_12);
            __pyx_L792_try_end:;
          }

          /* "ws_package/controllers/activity_controller.py":5585
 *                             logger.error("Error updating interval (id=%s): %s", getattr(interval_to_update, 'id', 'N/A'), e, exc_info=True)
 * 
 *                 if intervals_updated_count > 0:             # <<<<<<<<<<<<<<
 *                     logger.info("Marked %s additional intervals from current session (counter=%s) as uploaded", intervals_updated_count, current_session_counter)
 *                     # Flush the queue to ensure all updates are committed
*/
          goto __pyx_L786;
        }

        /* "ws_package/controllers/activity_controller.py":5597
 *                         logger.error("Error flushing database write queue after marking all intervals: %s", e, exc_info=True)
 *                 else:
 *                     logger.info("All %s intervals from current session (counter=%s) were already marked as uploaded", len(intervals), current_session_counter)             # <<<<<<<<<<<<<<
 * 
 *             # CRITICAL FINAL STEP: Verify all intervals from current session are marked as uploaded in database
*/
        /*else*/ {
          __pyx_t_7 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5597, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_52 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5597, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_52);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_45 = PyObject_Length(__pyx_cur_scope->__pyx_v_intervals); if (unlikely(__pyx_t_45 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5597, __pyx_L4_error)
          __pyx_t_5 = PyLong_FromSsize_t(__pyx_t_45); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5597, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_52))) {
            __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_52);
            assert(__pyx_t_7);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_52);
            __Pyx_INCREF(__pyx_t_7);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_52, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[4] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_All_s_intervals_from_current_ses, __pyx_t_5, __pyx_cur_scope->__pyx_v_current_session_counter};
            __pyx_t_25 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_52, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
            if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5597, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_25);
          }
          __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
        }
        __pyx_L786:;

        /* "ws_package/controllers/activity_controller.py":5548
 *             # CRITICAL: Ensure ALL intervals from current session that were successfully sent are marked as uploaded
 *             # Mark any intervals from current session that weren't updated in the batch processing loop
 *             if at_least_one_batch_successful and intervals:             # <<<<<<<<<<<<<<
 *                 intervals_updated_count = 0
 *                 for interval in intervals:
*/
      }

      /* "ws_package/controllers/activity_controller.py":5601
 *             # CRITICAL FINAL STEP: Verify all intervals from current session are marked as uploaded in database
 *             # This prevents them from being sent again when timer restarts
 *             if at_least_one_batch_successful and intervals:             # <<<<<<<<<<<<<<
 *                 logger.info("Performing final verification: checking all %s intervals from current session are marked as uploaded in database...", len(intervals))
 *                 try:
*/
      if (__pyx_cur_scope->__pyx_v_at_least_one_batch_successful) {
      } else {
        __pyx_t_47 = __pyx_cur_scope->__pyx_v_at_least_one_batch_successful;
        goto __pyx_L808_bool_binop_done;
      }
      __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_intervals); if (unlikely((__pyx_t_28 < 0))) __PYX_ERR(0, 5601, __pyx_L4_error)
      __pyx_t_47 = __pyx_t_28;
      __pyx_L808_bool_binop_done:;
      if (__pyx_t_47) {

        /* "ws_package/controllers/activity_controller.py":5602
 *             # This prevents them from being sent again when timer restarts
 *             if at_least_one_batch_successful and intervals:
 *                 logger.info("Performing final verification: checking all %s intervals from current session are marked as uploaded in database...", len(intervals))             # <<<<<<<<<<<<<<
 *                 try:
 *                     # Wait a bit more to ensure all updates are committed
*/
        __pyx_t_52 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5602, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5602, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_45 = PyObject_Length(__pyx_cur_scope->__pyx_v_intervals); if (unlikely(__pyx_t_45 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5602, __pyx_L4_error)
        __pyx_t_5 = PyLong_FromSsize_t(__pyx_t_45); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5602, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_52 = PyMethod_GET_SELF(__pyx_t_7);
          assert(__pyx_t_52);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_52);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_52, __pyx_mstate_global->__pyx_kp_u_Performing_final_verification_ch, __pyx_t_5};
          __pyx_t_25 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5602, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_25);
        }
        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;

        /* "ws_package/controllers/activity_controller.py":5603
 *             if at_least_one_batch_successful and intervals:
 *                 logger.info("Performing final verification: checking all %s intervals from current session are marked as uploaded in database...", len(intervals))
 *                 try:             # <<<<<<<<<<<<<<
 *                     # Wait a bit more to ensure all updates are committed
 *                     await asyncio.sleep(0.5)
*/
        {
          __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_14);
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":5605
 *                 try:
 *                     # Wait a bit more to ensure all updates are committed
 *                     await asyncio.sleep(0.5)             # <<<<<<<<<<<<<<
 * 
 *                     with db_lock_manager.read_lock():
*/
            __pyx_t_7 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5605, __pyx_L810_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_52 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5605, __pyx_L810_error)
            __Pyx_GOTREF(__pyx_t_52);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_52))) {
              __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_52);
              assert(__pyx_t_7);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_52);
              __Pyx_INCREF(__pyx_t_7);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_52, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_mstate_global->__pyx_float_0_5};
              __pyx_t_25 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_52, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
              __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
              if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5605, __pyx_L810_error)
              __Pyx_GOTREF(__pyx_t_25);
            }
            __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_25, &__pyx_r);
            __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
            if (likely(__pyx_t_11 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_1);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
              __Pyx_XGIVEREF(__pyx_t_2);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
              __Pyx_XGIVEREF(__pyx_t_3);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
              __Pyx_XGIVEREF(__pyx_t_12);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
              __Pyx_XGIVEREF(__pyx_t_13);
              __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
              __Pyx_XGIVEREF(__pyx_t_14);
              __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 62;
              return __pyx_r;
              __pyx_L816_resume_from_await:;
              __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_1);
              __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_2);
              __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_3);
              __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_12);
              __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
              __pyx_cur_scope->__pyx_t_4 = 0;
              __Pyx_XGOTREF(__pyx_t_13);
              __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
              __pyx_cur_scope->__pyx_t_5 = 0;
              __Pyx_XGOTREF(__pyx_t_14);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5605, __pyx_L810_error)
            } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_DECREF(__pyx_r); __pyx_r = 0;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 5605, __pyx_L810_error)
            }

            /* "ws_package/controllers/activity_controller.py":5607
 *                     await asyncio.sleep(0.5)
 * 
 *                     with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                         async with async_session() as session:
 *                             # Query for all intervals from current session
*/
            /*with:*/ {
              __pyx_t_52 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5607, __pyx_L810_error)
              __Pyx_GOTREF(__pyx_t_7);
              __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5607, __pyx_L810_error)
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_5))) {
                __pyx_t_52 = PyMethod_GET_SELF(__pyx_t_5);
                assert(__pyx_t_52);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                __Pyx_INCREF(__pyx_t_52);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_52, NULL};
                __pyx_t_25 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5607, __pyx_L810_error)
                __Pyx_GOTREF(__pyx_t_25);
              }
              __pyx_t_22 = __Pyx_PyObject_LookupSpecial(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 5607, __pyx_L810_error)
              __Pyx_GOTREF(__pyx_t_22);
              __pyx_t_52 = NULL;
              __pyx_t_7 = __Pyx_PyObject_LookupSpecial(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5607, __pyx_L817_error)
              __Pyx_GOTREF(__pyx_t_7);
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (likely(PyMethod_Check(__pyx_t_7))) {
                __pyx_t_52 = PyMethod_GET_SELF(__pyx_t_7);
                assert(__pyx_t_52);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                __Pyx_INCREF(__pyx_t_52);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_52, NULL};
                __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5607, __pyx_L817_error)
                __Pyx_GOTREF(__pyx_t_5);
              }
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
              /*try:*/ {
                {
                  __Pyx_ExceptionSave(&__pyx_t_37, &__pyx_t_19, &__pyx_t_16);
                  __Pyx_XGOTREF(__pyx_t_37);
                  __Pyx_XGOTREF(__pyx_t_19);
                  __Pyx_XGOTREF(__pyx_t_16);
                  /*try:*/ {

                    /* "ws_package/controllers/activity_controller.py":5608
 * 
 *                     with db_lock_manager.read_lock():
 *                         async with async_session() as session:             # <<<<<<<<<<<<<<
 *                             # Query for all intervals from current session
 *                             query = select(ActivityInterval).where(
*/
                    /*with:*/ {
                      __pyx_t_5 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5608, __pyx_L821_error)
                      __Pyx_GOTREF(__pyx_t_7);
                      __pyx_t_8 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_7))) {
                        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
                        assert(__pyx_t_5);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                        __Pyx_INCREF(__pyx_t_5);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                        __pyx_t_8 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                        __pyx_t_25 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                        if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5608, __pyx_L821_error)
                        __Pyx_GOTREF(__pyx_t_25);
                      }
                      __pyx_t_17 = __Pyx_PyObject_LookupSpecial(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 5608, __pyx_L821_error)
                      __Pyx_GOTREF(__pyx_t_17);
                      __pyx_t_5 = NULL;
                      __pyx_t_52 = __Pyx_PyObject_LookupSpecial(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5608, __pyx_L827_error)
                      __Pyx_GOTREF(__pyx_t_52);
                      __pyx_t_8 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (likely(PyMethod_Check(__pyx_t_52))) {
                        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_52);
                        assert(__pyx_t_5);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_52);
                        __Pyx_INCREF(__pyx_t_5);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_52, __pyx__function);
                        __pyx_t_8 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                        __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_52, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                        __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
                        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5608, __pyx_L827_error)
                        __Pyx_GOTREF(__pyx_t_7);
                      }
                      __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                      if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_19);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_19;
                        __Pyx_XGIVEREF(__pyx_t_22);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_22;
                        __Pyx_XGIVEREF(__pyx_t_25);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_25;
                        __Pyx_XGIVEREF(__pyx_t_37);
                        __pyx_cur_scope->__pyx_t_11 = __pyx_t_37;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 63;
                        return __pyx_r;
                        __pyx_L828_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_19 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_19);
                        __pyx_t_22 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_22);
                        __pyx_t_25 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_25);
                        __pyx_t_37 = __pyx_cur_scope->__pyx_t_11;
                        __pyx_cur_scope->__pyx_t_11 = 0;
                        __Pyx_XGOTREF(__pyx_t_37);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5608, __pyx_L827_error)
                        __pyx_t_7 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_7);
                      } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_7 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 5608, __pyx_L827_error)
                      }
                      __pyx_t_52 = __pyx_t_7;
                      __pyx_t_7 = 0;
                      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                      /*try:*/ {
                        {
                          __Pyx_ExceptionSave(&__pyx_t_20, &__pyx_t_21, &__pyx_t_15);
                          __Pyx_XGOTREF(__pyx_t_20);
                          __Pyx_XGOTREF(__pyx_t_21);
                          __Pyx_XGOTREF(__pyx_t_15);
                          /*try:*/ {
                            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_session);
                            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_session, __pyx_t_52);
                            __Pyx_GIVEREF(__pyx_t_52);
                            __pyx_t_52 = 0;

                            /* "ws_package/controllers/activity_controller.py":5610
 *                         async with async_session() as session:
 *                             # Query for all intervals from current session
 *                             query = select(ActivityInterval).where(             # <<<<<<<<<<<<<<
 *                                 ActivityInterval.counter == current_session_counter,
 *                                 ActivityInterval.is_uploaded == False
*/
                            __pyx_t_5 = NULL;
                            __Pyx_GetModuleGlobalName(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5610, __pyx_L832_error)
                            __Pyx_GOTREF(__pyx_t_39);
                            __Pyx_GetModuleGlobalName(__pyx_t_40, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_40)) __PYX_ERR(0, 5610, __pyx_L832_error)
                            __Pyx_GOTREF(__pyx_t_40);
                            __pyx_t_8 = 1;
                            #if CYTHON_UNPACK_METHODS
                            if (unlikely(PyMethod_Check(__pyx_t_39))) {
                              __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_39);
                              assert(__pyx_t_5);
                              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_39);
                              __Pyx_INCREF(__pyx_t_5);
                              __Pyx_INCREF(__pyx__function);
                              __Pyx_DECREF_SET(__pyx_t_39, __pyx__function);
                              __pyx_t_8 = 0;
                            }
                            #endif
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_40};
                              __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_39, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                              __Pyx_DECREF(__pyx_t_40); __pyx_t_40 = 0;
                              __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                              if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5610, __pyx_L832_error)
                              __Pyx_GOTREF(__pyx_t_7);
                            }
                            __pyx_t_25 = __pyx_t_7;
                            __Pyx_INCREF(__pyx_t_25);

                            /* "ws_package/controllers/activity_controller.py":5611
 *                             # Query for all intervals from current session
 *                             query = select(ActivityInterval).where(
 *                                 ActivityInterval.counter == current_session_counter,             # <<<<<<<<<<<<<<
 *                                 ActivityInterval.is_uploaded == False
 *                             )
*/
                            __Pyx_GetModuleGlobalName(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5611, __pyx_L832_error)
                            __Pyx_GOTREF(__pyx_t_39);
                            __pyx_t_40 = __Pyx_PyObject_GetAttrStr(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_40)) __PYX_ERR(0, 5611, __pyx_L832_error)
                            __Pyx_GOTREF(__pyx_t_40);
                            __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                            __pyx_t_39 = PyObject_RichCompare(__pyx_t_40, __pyx_cur_scope->__pyx_v_current_session_counter, Py_EQ); __Pyx_XGOTREF(__pyx_t_39); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5611, __pyx_L832_error)
                            __Pyx_DECREF(__pyx_t_40); __pyx_t_40 = 0;

                            /* "ws_package/controllers/activity_controller.py":5612
 *                             query = select(ActivityInterval).where(
 *                                 ActivityInterval.counter == current_session_counter,
 *                                 ActivityInterval.is_uploaded == False             # <<<<<<<<<<<<<<
 *                             )
 *                             result = await session.execute(query)
*/
                            __Pyx_GetModuleGlobalName(__pyx_t_40, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_40)) __PYX_ERR(0, 5612, __pyx_L832_error)
                            __Pyx_GOTREF(__pyx_t_40);
                            __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_40, __pyx_mstate_global->__pyx_n_u_is_uploaded); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5612, __pyx_L832_error)
                            __Pyx_GOTREF(__pyx_t_5);
                            __Pyx_DECREF(__pyx_t_40); __pyx_t_40 = 0;
                            __pyx_t_40 = PyObject_RichCompare(__pyx_t_5, Py_False, Py_EQ); __Pyx_XGOTREF(__pyx_t_40); if (unlikely(!__pyx_t_40)) __PYX_ERR(0, 5612, __pyx_L832_error)
                            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                            __pyx_t_8 = 0;
                            {
                              PyObject *__pyx_callargs[3] = {__pyx_t_25, __pyx_t_39, __pyx_t_40};
                              __pyx_t_52 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                              __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                              __Pyx_DECREF(__pyx_t_40); __pyx_t_40 = 0;
                              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                              if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5610, __pyx_L832_error)
                              __Pyx_GOTREF(__pyx_t_52);
                            }
                            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_query);
                            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_query, __pyx_t_52);
                            __Pyx_GIVEREF(__pyx_t_52);
                            __pyx_t_52 = 0;

                            /* "ws_package/controllers/activity_controller.py":5614
 *                                 ActivityInterval.is_uploaded == False
 *                             )
 *                             result = await session.execute(query)             # <<<<<<<<<<<<<<
 *                             unsent_intervals = result.scalars().all()
 * 
*/
                            __pyx_t_7 = __pyx_cur_scope->__pyx_v_session;
                            __Pyx_INCREF(__pyx_t_7);
                            __pyx_t_8 = 0;
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_cur_scope->__pyx_v_query};
                              __pyx_t_52 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                              if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5614, __pyx_L832_error)
                              __Pyx_GOTREF(__pyx_t_52);
                            }
                            __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_52, &__pyx_r);
                            __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
                            if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                              __Pyx_GOTREF(__pyx_r);
                              __Pyx_XGIVEREF(__pyx_t_1);
                              __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                              __Pyx_XGIVEREF(__pyx_t_2);
                              __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                              __Pyx_XGIVEREF(__pyx_t_3);
                              __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                              __Pyx_XGIVEREF(__pyx_t_12);
                              __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                              __Pyx_XGIVEREF(__pyx_t_13);
                              __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                              __Pyx_XGIVEREF(__pyx_t_14);
                              __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                              __Pyx_XGIVEREF(__pyx_t_15);
                              __pyx_cur_scope->__pyx_t_6 = __pyx_t_15;
                              __Pyx_XGIVEREF(__pyx_t_16);
                              __pyx_cur_scope->__pyx_t_7 = __pyx_t_16;
                              __Pyx_XGIVEREF(__pyx_t_17);
                              __pyx_cur_scope->__pyx_t_8 = __pyx_t_17;
                              __Pyx_XGIVEREF(__pyx_t_19);
                              __pyx_cur_scope->__pyx_t_9 = __pyx_t_19;
                              __Pyx_XGIVEREF(__pyx_t_20);
                              __pyx_cur_scope->__pyx_t_10 = __pyx_t_20;
                              __Pyx_XGIVEREF(__pyx_t_21);
                              __pyx_cur_scope->__pyx_t_11 = __pyx_t_21;
                              __Pyx_XGIVEREF(__pyx_t_22);
                              __pyx_cur_scope->__pyx_t_12 = __pyx_t_22;
                              __Pyx_XGIVEREF(__pyx_t_37);
                              __pyx_cur_scope->__pyx_t_13 = __pyx_t_37;
                              __Pyx_XGIVEREF(__pyx_r);
                              __Pyx_RefNannyFinishContext();
                              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                              /* return from generator, awaiting value */
                              __pyx_generator->resume_label = 64;
                              return __pyx_r;
                              __pyx_L838_resume_from_await:;
                              __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                              __pyx_cur_scope->__pyx_t_0 = 0;
                              __Pyx_XGOTREF(__pyx_t_1);
                              __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                              __pyx_cur_scope->__pyx_t_1 = 0;
                              __Pyx_XGOTREF(__pyx_t_2);
                              __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                              __pyx_cur_scope->__pyx_t_2 = 0;
                              __Pyx_XGOTREF(__pyx_t_3);
                              __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                              __pyx_cur_scope->__pyx_t_3 = 0;
                              __Pyx_XGOTREF(__pyx_t_12);
                              __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                              __pyx_cur_scope->__pyx_t_4 = 0;
                              __Pyx_XGOTREF(__pyx_t_13);
                              __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                              __pyx_cur_scope->__pyx_t_5 = 0;
                              __Pyx_XGOTREF(__pyx_t_14);
                              __pyx_t_15 = __pyx_cur_scope->__pyx_t_6;
                              __pyx_cur_scope->__pyx_t_6 = 0;
                              __Pyx_XGOTREF(__pyx_t_15);
                              __pyx_t_16 = __pyx_cur_scope->__pyx_t_7;
                              __pyx_cur_scope->__pyx_t_7 = 0;
                              __Pyx_XGOTREF(__pyx_t_16);
                              __pyx_t_17 = __pyx_cur_scope->__pyx_t_8;
                              __pyx_cur_scope->__pyx_t_8 = 0;
                              __Pyx_XGOTREF(__pyx_t_17);
                              __pyx_t_19 = __pyx_cur_scope->__pyx_t_9;
                              __pyx_cur_scope->__pyx_t_9 = 0;
                              __Pyx_XGOTREF(__pyx_t_19);
                              __pyx_t_20 = __pyx_cur_scope->__pyx_t_10;
                              __pyx_cur_scope->__pyx_t_10 = 0;
                              __Pyx_XGOTREF(__pyx_t_20);
                              __pyx_t_21 = __pyx_cur_scope->__pyx_t_11;
                              __pyx_cur_scope->__pyx_t_11 = 0;
                              __Pyx_XGOTREF(__pyx_t_21);
                              __pyx_t_22 = __pyx_cur_scope->__pyx_t_12;
                              __pyx_cur_scope->__pyx_t_12 = 0;
                              __Pyx_XGOTREF(__pyx_t_22);
                              __pyx_t_37 = __pyx_cur_scope->__pyx_t_13;
                              __pyx_cur_scope->__pyx_t_13 = 0;
                              __Pyx_XGOTREF(__pyx_t_37);
                              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5614, __pyx_L832_error)
                              __pyx_t_52 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_52);
                            } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                              __Pyx_GOTREF(__pyx_r);
                              __pyx_t_52 = __pyx_r; __pyx_r = NULL;
                            } else {
                              __Pyx_XGOTREF(__pyx_r);
                              __PYX_ERR(0, 5614, __pyx_L832_error)
                            }
                            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_result);
                            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_result, __pyx_t_52);
                            __Pyx_GIVEREF(__pyx_t_52);
                            __pyx_t_52 = 0;

                            /* "ws_package/controllers/activity_controller.py":5615
 *                             )
 *                             result = await session.execute(query)
 *                             unsent_intervals = result.scalars().all()             # <<<<<<<<<<<<<<
 * 
 *                             if unsent_intervals:
*/
                            __pyx_t_39 = __pyx_cur_scope->__pyx_v_result;
                            __Pyx_INCREF(__pyx_t_39);
                            __pyx_t_8 = 0;
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_39, NULL};
                              __pyx_t_40 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalars, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                              if (unlikely(!__pyx_t_40)) __PYX_ERR(0, 5615, __pyx_L832_error)
                              __Pyx_GOTREF(__pyx_t_40);
                            }
                            __pyx_t_7 = __pyx_t_40;
                            __Pyx_INCREF(__pyx_t_7);
                            __pyx_t_8 = 0;
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
                              __pyx_t_52 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_all, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                              __Pyx_DECREF(__pyx_t_40); __pyx_t_40 = 0;
                              if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5615, __pyx_L832_error)
                              __Pyx_GOTREF(__pyx_t_52);
                            }
                            __Pyx_GIVEREF(__pyx_t_52);
                            __pyx_cur_scope->__pyx_v_unsent_intervals = __pyx_t_52;
                            __pyx_t_52 = 0;

                            /* "ws_package/controllers/activity_controller.py":5617
 *                             unsent_intervals = result.scalars().all()
 * 
 *                             if unsent_intervals:             # <<<<<<<<<<<<<<
 *                                 logger.warning(" Found %s intervals from current session (counter=%s) still marked as unsent after upload!", len(unsent_intervals), current_session_counter)
 *                                 for interval in unsent_intervals:
*/
                            __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_unsent_intervals); if (unlikely((__pyx_t_47 < 0))) __PYX_ERR(0, 5617, __pyx_L832_error)
                            if (__pyx_t_47) {

                              /* "ws_package/controllers/activity_controller.py":5618
 * 
 *                             if unsent_intervals:
 *                                 logger.warning(" Found %s intervals from current session (counter=%s) still marked as unsent after upload!", len(unsent_intervals), current_session_counter)             # <<<<<<<<<<<<<<
 *                                 for interval in unsent_intervals:
 *                                     logger.warning("   Unsent interval: id=%s, start_time=%s, end_time=%s", interval.id, interval.start_time, interval.end_time)
*/
                              __pyx_t_40 = NULL;
                              __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5618, __pyx_L832_error)
                              __Pyx_GOTREF(__pyx_t_7);
                              __pyx_t_39 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5618, __pyx_L832_error)
                              __Pyx_GOTREF(__pyx_t_39);
                              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                              __pyx_t_45 = PyObject_Length(__pyx_cur_scope->__pyx_v_unsent_intervals); if (unlikely(__pyx_t_45 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5618, __pyx_L832_error)
                              __pyx_t_7 = PyLong_FromSsize_t(__pyx_t_45); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5618, __pyx_L832_error)
                              __Pyx_GOTREF(__pyx_t_7);
                              __pyx_t_8 = 1;
                              #if CYTHON_UNPACK_METHODS
                              if (unlikely(PyMethod_Check(__pyx_t_39))) {
                                __pyx_t_40 = PyMethod_GET_SELF(__pyx_t_39);
                                assert(__pyx_t_40);
                                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_39);
                                __Pyx_INCREF(__pyx_t_40);
                                __Pyx_INCREF(__pyx__function);
                                __Pyx_DECREF_SET(__pyx_t_39, __pyx__function);
                                __pyx_t_8 = 0;
                              }
                              #endif
                              {
                                PyObject *__pyx_callargs[4] = {__pyx_t_40, __pyx_mstate_global->__pyx_kp_u_Found_s_intervals_from_current, __pyx_t_7, __pyx_cur_scope->__pyx_v_current_session_counter};
                                __pyx_t_52 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_39, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                                __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                                if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5618, __pyx_L832_error)
                                __Pyx_GOTREF(__pyx_t_52);
                              }
                              __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;

                              /* "ws_package/controllers/activity_controller.py":5619
 *                             if unsent_intervals:
 *                                 logger.warning(" Found %s intervals from current session (counter=%s) still marked as unsent after upload!", len(unsent_intervals), current_session_counter)
 *                                 for interval in unsent_intervals:             # <<<<<<<<<<<<<<
 *                                     logger.warning("   Unsent interval: id=%s, start_time=%s, end_time=%s", interval.id, interval.start_time, interval.end_time)
 *                                 # Force update them
*/
                              if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_unsent_intervals)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_unsent_intervals)) {
                                __pyx_t_52 = __pyx_cur_scope->__pyx_v_unsent_intervals; __Pyx_INCREF(__pyx_t_52);
                                __pyx_t_45 = 0;
                                __pyx_t_35 = NULL;
                              } else {
                                __pyx_t_45 = -1; __pyx_t_52 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_unsent_intervals); if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5619, __pyx_L832_error)
                                __Pyx_GOTREF(__pyx_t_52);
                                __pyx_t_35 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_52); if (unlikely(!__pyx_t_35)) __PYX_ERR(0, 5619, __pyx_L832_error)
                              }
                              for (;;) {
                                if (likely(!__pyx_t_35)) {
                                  if (likely(PyList_CheckExact(__pyx_t_52))) {
                                    {
                                      Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_52);
                                      #if !CYTHON_ASSUME_SAFE_SIZE
                                      if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5619, __pyx_L832_error)
                                      #endif
                                      if (__pyx_t_45 >= __pyx_temp) break;
                                    }
                                    __pyx_t_39 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_52, __pyx_t_45, __Pyx_ReferenceSharing_OwnStrongReference);
                                    ++__pyx_t_45;
                                  } else {
                                    {
                                      Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_52);
                                      #if !CYTHON_ASSUME_SAFE_SIZE
                                      if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5619, __pyx_L832_error)
                                      #endif
                                      if (__pyx_t_45 >= __pyx_temp) break;
                                    }
                                    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                                    __pyx_t_39 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_52, __pyx_t_45));
                                    #else
                                    __pyx_t_39 = __Pyx_PySequence_ITEM(__pyx_t_52, __pyx_t_45);
                                    #endif
                                    ++__pyx_t_45;
                                  }
                                  if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5619, __pyx_L832_error)
                                } else {
                                  __pyx_t_39 = __pyx_t_35(__pyx_t_52);
                                  if (unlikely(!__pyx_t_39)) {
                                    PyObject* exc_type = PyErr_Occurred();
                                    if (exc_type) {
                                      if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 5619, __pyx_L832_error)
                                      PyErr_Clear();
                                    }
                                    break;
                                  }
                                }
                                __Pyx_GOTREF(__pyx_t_39);
                                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
                                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_39);
                                __Pyx_GIVEREF(__pyx_t_39);
                                __pyx_t_39 = 0;

                                /* "ws_package/controllers/activity_controller.py":5620
 *                                 logger.warning(" Found %s intervals from current session (counter=%s) still marked as unsent after upload!", len(unsent_intervals), current_session_counter)
 *                                 for interval in unsent_intervals:
 *                                     logger.warning("   Unsent interval: id=%s, start_time=%s, end_time=%s", interval.id, interval.start_time, interval.end_time)             # <<<<<<<<<<<<<<
 *                                 # Force update them
 *                                 for interval in unsent_intervals:
*/
                                __pyx_t_7 = NULL;
                                __Pyx_GetModuleGlobalName(__pyx_t_40, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_40)) __PYX_ERR(0, 5620, __pyx_L832_error)
                                __Pyx_GOTREF(__pyx_t_40);
                                __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_40, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5620, __pyx_L832_error)
                                __Pyx_GOTREF(__pyx_t_25);
                                __Pyx_DECREF(__pyx_t_40); __pyx_t_40 = 0;
                                __pyx_t_40 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_40)) __PYX_ERR(0, 5620, __pyx_L832_error)
                                __Pyx_GOTREF(__pyx_t_40);
                                __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5620, __pyx_L832_error)
                                __Pyx_GOTREF(__pyx_t_5);
                                __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5620, __pyx_L832_error)
                                __Pyx_GOTREF(__pyx_t_10);
                                __pyx_t_8 = 1;
                                #if CYTHON_UNPACK_METHODS
                                if (unlikely(PyMethod_Check(__pyx_t_25))) {
                                  __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_25);
                                  assert(__pyx_t_7);
                                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_25);
                                  __Pyx_INCREF(__pyx_t_7);
                                  __Pyx_INCREF(__pyx__function);
                                  __Pyx_DECREF_SET(__pyx_t_25, __pyx__function);
                                  __pyx_t_8 = 0;
                                }
                                #endif
                                {
                                  PyObject *__pyx_callargs[5] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Unsent_interval_id_s_start_time, __pyx_t_40, __pyx_t_5, __pyx_t_10};
                                  __pyx_t_39 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_25, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                                  __Pyx_DECREF(__pyx_t_40); __pyx_t_40 = 0;
                                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                                  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                                  __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                                  if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5620, __pyx_L832_error)
                                  __Pyx_GOTREF(__pyx_t_39);
                                }
                                __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;

                                /* "ws_package/controllers/activity_controller.py":5619
 *                             if unsent_intervals:
 *                                 logger.warning(" Found %s intervals from current session (counter=%s) still marked as unsent after upload!", len(unsent_intervals), current_session_counter)
 *                                 for interval in unsent_intervals:             # <<<<<<<<<<<<<<
 *                                     logger.warning("   Unsent interval: id=%s, start_time=%s, end_time=%s", interval.id, interval.start_time, interval.end_time)
 *                                 # Force update them
*/
                              }
                              __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;

                              /* "ws_package/controllers/activity_controller.py":5622
 *                                     logger.warning("   Unsent interval: id=%s, start_time=%s, end_time=%s", interval.id, interval.start_time, interval.end_time)
 *                                 # Force update them
 *                                 for interval in unsent_intervals:             # <<<<<<<<<<<<<<
 *                                     try:
 *                                         await self.activity_service.update_activity_interval(interval)
*/
                              if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_unsent_intervals)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_unsent_intervals)) {
                                __pyx_t_52 = __pyx_cur_scope->__pyx_v_unsent_intervals; __Pyx_INCREF(__pyx_t_52);
                                __pyx_t_45 = 0;
                                __pyx_t_35 = NULL;
                              } else {
                                __pyx_t_45 = -1; __pyx_t_52 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_unsent_intervals); if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5622, __pyx_L832_error)
                                __Pyx_GOTREF(__pyx_t_52);
                                __pyx_t_35 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_52); if (unlikely(!__pyx_t_35)) __PYX_ERR(0, 5622, __pyx_L832_error)
                              }
                              for (;;) {
                                if (likely(!__pyx_t_35)) {
                                  if (likely(PyList_CheckExact(__pyx_t_52))) {
                                    {
                                      Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_52);
                                      #if !CYTHON_ASSUME_SAFE_SIZE
                                      if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5622, __pyx_L832_error)
                                      #endif
                                      if (__pyx_t_45 >= __pyx_temp) break;
                                    }
                                    __pyx_t_39 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_52, __pyx_t_45, __Pyx_ReferenceSharing_OwnStrongReference);
                                    ++__pyx_t_45;
                                  } else {
                                    {
                                      Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_52);
                                      #if !CYTHON_ASSUME_SAFE_SIZE
                                      if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5622, __pyx_L832_error)
                                      #endif
                                      if (__pyx_t_45 >= __pyx_temp) break;
                                    }
                                    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                                    __pyx_t_39 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_52, __pyx_t_45));
                                    #else
                                    __pyx_t_39 = __Pyx_PySequence_ITEM(__pyx_t_52, __pyx_t_45);
                                    #endif
                                    ++__pyx_t_45;
                                  }
                                  if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5622, __pyx_L832_error)
                                } else {
                                  __pyx_t_39 = __pyx_t_35(__pyx_t_52);
                                  if (unlikely(!__pyx_t_39)) {
                                    PyObject* exc_type = PyErr_Occurred();
                                    if (exc_type) {
                                      if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 5622, __pyx_L832_error)
                                      PyErr_Clear();
                                    }
                                    break;
                                  }
                                }
                                __Pyx_GOTREF(__pyx_t_39);
                                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
                                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_39);
                                __Pyx_GIVEREF(__pyx_t_39);
                                __pyx_t_39 = 0;

                                /* "ws_package/controllers/activity_controller.py":5623
 *                                 # Force update them
 *                                 for interval in unsent_intervals:
 *                                     try:             # <<<<<<<<<<<<<<
 *                                         await self.activity_service.update_activity_interval(interval)
 *                                         logger.info("Force-marked interval (id=%s) as uploaded", interval.id)
*/
                                {
                                  __Pyx_ExceptionSave(&__pyx_t_18, &__pyx_t_36, &__pyx_t_30);
                                  __Pyx_XGOTREF(__pyx_t_18);
                                  __Pyx_XGOTREF(__pyx_t_36);
                                  __Pyx_XGOTREF(__pyx_t_30);
                                  /*try:*/ {

                                    /* "ws_package/controllers/activity_controller.py":5624
 *                                 for interval in unsent_intervals:
 *                                     try:
 *                                         await self.activity_service.update_activity_interval(interval)             # <<<<<<<<<<<<<<
 *                                         logger.info("Force-marked interval (id=%s) as uploaded", interval.id)
 *                                     except Exception as e:
*/
                                    __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5624, __pyx_L845_error)
                                    __Pyx_GOTREF(__pyx_t_10);
                                    __pyx_t_25 = __pyx_t_10;
                                    __Pyx_INCREF(__pyx_t_25);
                                    __pyx_t_8 = 0;
                                    {
                                      PyObject *__pyx_callargs[2] = {__pyx_t_25, __pyx_cur_scope->__pyx_v_interval};
                                      __pyx_t_39 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_update_activity_interval, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                      __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                                      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                                      if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5624, __pyx_L845_error)
                                      __Pyx_GOTREF(__pyx_t_39);
                                    }
                                    __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_39, &__pyx_r);
                                    __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                                    if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                      __Pyx_GOTREF(__pyx_r);
                                      __Pyx_XGIVEREF(__pyx_t_1);
                                      __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                      __Pyx_XGIVEREF(__pyx_t_2);
                                      __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                      __Pyx_XGIVEREF(__pyx_t_3);
                                      __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                      __Pyx_XGIVEREF(__pyx_t_12);
                                      __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                                      __Pyx_XGIVEREF(__pyx_t_13);
                                      __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                                      __Pyx_XGIVEREF(__pyx_t_14);
                                      __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                                      __Pyx_XGIVEREF(__pyx_t_15);
                                      __pyx_cur_scope->__pyx_t_6 = __pyx_t_15;
                                      __Pyx_XGIVEREF(__pyx_t_16);
                                      __pyx_cur_scope->__pyx_t_7 = __pyx_t_16;
                                      __Pyx_XGIVEREF(__pyx_t_17);
                                      __pyx_cur_scope->__pyx_t_8 = __pyx_t_17;
                                      __Pyx_XGIVEREF(__pyx_t_18);
                                      __pyx_cur_scope->__pyx_t_9 = __pyx_t_18;
                                      __Pyx_XGIVEREF(__pyx_t_19);
                                      __pyx_cur_scope->__pyx_t_10 = __pyx_t_19;
                                      __Pyx_XGIVEREF(__pyx_t_20);
                                      __pyx_cur_scope->__pyx_t_11 = __pyx_t_20;
                                      __Pyx_XGIVEREF(__pyx_t_21);
                                      __pyx_cur_scope->__pyx_t_12 = __pyx_t_21;
                                      __Pyx_XGIVEREF(__pyx_t_22);
                                      __pyx_cur_scope->__pyx_t_13 = __pyx_t_22;
                                      __Pyx_XGIVEREF(__pyx_t_30);
                                      __pyx_cur_scope->__pyx_t_14 = __pyx_t_30;
                                      __pyx_cur_scope->__pyx_t_18 = __pyx_t_35;
                                      __Pyx_XGIVEREF(__pyx_t_36);
                                      __pyx_cur_scope->__pyx_t_15 = __pyx_t_36;
                                      __Pyx_XGIVEREF(__pyx_t_37);
                                      __pyx_cur_scope->__pyx_t_16 = __pyx_t_37;
                                      __pyx_cur_scope->__pyx_t_23 = __pyx_t_45;
                                      __Pyx_XGIVEREF(__pyx_t_52);
                                      __pyx_cur_scope->__pyx_t_17 = __pyx_t_52;
                                      __Pyx_XGIVEREF(__pyx_r);
                                      __Pyx_RefNannyFinishContext();
                                      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                                      /* return from generator, awaiting value */
                                      __pyx_generator->resume_label = 65;
                                      return __pyx_r;
                                      __pyx_L853_resume_from_await:;
                                      __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                      __pyx_cur_scope->__pyx_t_0 = 0;
                                      __Pyx_XGOTREF(__pyx_t_1);
                                      __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                      __pyx_cur_scope->__pyx_t_1 = 0;
                                      __Pyx_XGOTREF(__pyx_t_2);
                                      __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                      __pyx_cur_scope->__pyx_t_2 = 0;
                                      __Pyx_XGOTREF(__pyx_t_3);
                                      __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                                      __pyx_cur_scope->__pyx_t_3 = 0;
                                      __Pyx_XGOTREF(__pyx_t_12);
                                      __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                                      __pyx_cur_scope->__pyx_t_4 = 0;
                                      __Pyx_XGOTREF(__pyx_t_13);
                                      __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                                      __pyx_cur_scope->__pyx_t_5 = 0;
                                      __Pyx_XGOTREF(__pyx_t_14);
                                      __pyx_t_15 = __pyx_cur_scope->__pyx_t_6;
                                      __pyx_cur_scope->__pyx_t_6 = 0;
                                      __Pyx_XGOTREF(__pyx_t_15);
                                      __pyx_t_16 = __pyx_cur_scope->__pyx_t_7;
                                      __pyx_cur_scope->__pyx_t_7 = 0;
                                      __Pyx_XGOTREF(__pyx_t_16);
                                      __pyx_t_17 = __pyx_cur_scope->__pyx_t_8;
                                      __pyx_cur_scope->__pyx_t_8 = 0;
                                      __Pyx_XGOTREF(__pyx_t_17);
                                      __pyx_t_18 = __pyx_cur_scope->__pyx_t_9;
                                      __pyx_cur_scope->__pyx_t_9 = 0;
                                      __Pyx_XGOTREF(__pyx_t_18);
                                      __pyx_t_19 = __pyx_cur_scope->__pyx_t_10;
                                      __pyx_cur_scope->__pyx_t_10 = 0;
                                      __Pyx_XGOTREF(__pyx_t_19);
                                      __pyx_t_20 = __pyx_cur_scope->__pyx_t_11;
                                      __pyx_cur_scope->__pyx_t_11 = 0;
                                      __Pyx_XGOTREF(__pyx_t_20);
                                      __pyx_t_21 = __pyx_cur_scope->__pyx_t_12;
                                      __pyx_cur_scope->__pyx_t_12 = 0;
                                      __Pyx_XGOTREF(__pyx_t_21);
                                      __pyx_t_22 = __pyx_cur_scope->__pyx_t_13;
                                      __pyx_cur_scope->__pyx_t_13 = 0;
                                      __Pyx_XGOTREF(__pyx_t_22);
                                      __pyx_t_30 = __pyx_cur_scope->__pyx_t_14;
                                      __pyx_cur_scope->__pyx_t_14 = 0;
                                      __Pyx_XGOTREF(__pyx_t_30);
                                      __pyx_t_35 = __pyx_cur_scope->__pyx_t_18;
                                      __pyx_t_36 = __pyx_cur_scope->__pyx_t_15;
                                      __pyx_cur_scope->__pyx_t_15 = 0;
                                      __Pyx_XGOTREF(__pyx_t_36);
                                      __pyx_t_37 = __pyx_cur_scope->__pyx_t_16;
                                      __pyx_cur_scope->__pyx_t_16 = 0;
                                      __Pyx_XGOTREF(__pyx_t_37);
                                      __pyx_t_45 = __pyx_cur_scope->__pyx_t_23;
                                      __pyx_t_52 = __pyx_cur_scope->__pyx_t_17;
                                      __pyx_cur_scope->__pyx_t_17 = 0;
                                      __Pyx_XGOTREF(__pyx_t_52);
                                      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5624, __pyx_L845_error)
                                    } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                      __Pyx_GOTREF(__pyx_r);
                                      __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                                    } else {
                                      __Pyx_XGOTREF(__pyx_r);
                                      __PYX_ERR(0, 5624, __pyx_L845_error)
                                    }

                                    /* "ws_package/controllers/activity_controller.py":5625
 *                                     try:
 *                                         await self.activity_service.update_activity_interval(interval)
 *                                         logger.info("Force-marked interval (id=%s) as uploaded", interval.id)             # <<<<<<<<<<<<<<
 *                                     except Exception as e:
 *                                         logger.error("Error force-updating interval (id=%s): %s", interval.id, e)
*/
                                    __pyx_t_10 = NULL;
                                    __Pyx_GetModuleGlobalName(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5625, __pyx_L845_error)
                                    __Pyx_GOTREF(__pyx_t_25);
                                    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5625, __pyx_L845_error)
                                    __Pyx_GOTREF(__pyx_t_5);
                                    __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                                    __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5625, __pyx_L845_error)
                                    __Pyx_GOTREF(__pyx_t_25);
                                    __pyx_t_8 = 1;
                                    #if CYTHON_UNPACK_METHODS
                                    if (unlikely(PyMethod_Check(__pyx_t_5))) {
                                      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5);
                                      assert(__pyx_t_10);
                                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                                      __Pyx_INCREF(__pyx_t_10);
                                      __Pyx_INCREF(__pyx__function);
                                      __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                                      __pyx_t_8 = 0;
                                    }
                                    #endif
                                    {
                                      PyObject *__pyx_callargs[3] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Force_marked_interval_id_s_as_up, __pyx_t_25};
                                      __pyx_t_39 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                                      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                                      if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5625, __pyx_L845_error)
                                      __Pyx_GOTREF(__pyx_t_39);
                                    }
                                    __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;

                                    /* "ws_package/controllers/activity_controller.py":5623
 *                                 # Force update them
 *                                 for interval in unsent_intervals:
 *                                     try:             # <<<<<<<<<<<<<<
 *                                         await self.activity_service.update_activity_interval(interval)
 *                                         logger.info("Force-marked interval (id=%s) as uploaded", interval.id)
*/
                                  }
                                  __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                                  __Pyx_XDECREF(__pyx_t_36); __pyx_t_36 = 0;
                                  __Pyx_XDECREF(__pyx_t_30); __pyx_t_30 = 0;
                                  goto __pyx_L852_try_end;
                                  __pyx_L845_error:;
                                  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                                  __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                                  __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                                  __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                                  __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                                  __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                                  __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                                  __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
                                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                                  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

                                  /* "ws_package/controllers/activity_controller.py":5626
 *                                         await self.activity_service.update_activity_interval(interval)
 *                                         logger.info("Force-marked interval (id=%s) as uploaded", interval.id)
 *                                     except Exception as e:             # <<<<<<<<<<<<<<
 *                                         logger.error("Error force-updating interval (id=%s): %s", interval.id, e)
 * 
*/
                                  __pyx_t_31 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                                  if (__pyx_t_31) {
                                    __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
                                    if (__Pyx_GetException(&__pyx_t_39, &__pyx_t_5, &__pyx_t_25) < 0) __PYX_ERR(0, 5626, __pyx_L847_except_error)
                                    __Pyx_XGOTREF(__pyx_t_39);
                                    __Pyx_XGOTREF(__pyx_t_5);
                                    __Pyx_XGOTREF(__pyx_t_25);
                                    __Pyx_INCREF(__pyx_t_5);
                                    __Pyx_GIVEREF(__pyx_t_5);
                                    __pyx_cur_scope->__pyx_v_e = __pyx_t_5;
                                    /*try:*/ {

                                      /* "ws_package/controllers/activity_controller.py":5627
 *                                         logger.info("Force-marked interval (id=%s) as uploaded", interval.id)
 *                                     except Exception as e:
 *                                         logger.error("Error force-updating interval (id=%s): %s", interval.id, e)             # <<<<<<<<<<<<<<
 * 
 *                                 # Flush one more time
*/
                                      __pyx_t_40 = NULL;
                                      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5627, __pyx_L859_error)
                                      __Pyx_GOTREF(__pyx_t_7);
                                      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5627, __pyx_L859_error)
                                      __Pyx_GOTREF(__pyx_t_4);
                                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                                      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5627, __pyx_L859_error)
                                      __Pyx_GOTREF(__pyx_t_7);
                                      __pyx_t_8 = 1;
                                      #if CYTHON_UNPACK_METHODS
                                      if (unlikely(PyMethod_Check(__pyx_t_4))) {
                                        __pyx_t_40 = PyMethod_GET_SELF(__pyx_t_4);
                                        assert(__pyx_t_40);
                                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                                        __Pyx_INCREF(__pyx_t_40);
                                        __Pyx_INCREF(__pyx__function);
                                        __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                                        __pyx_t_8 = 0;
                                      }
                                      #endif
                                      {
                                        PyObject *__pyx_callargs[4] = {__pyx_t_40, __pyx_mstate_global->__pyx_kp_u_Error_force_updating_interval_id, __pyx_t_7, __pyx_cur_scope->__pyx_v_e};
                                        __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                        __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                        if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5627, __pyx_L859_error)
                                        __Pyx_GOTREF(__pyx_t_10);
                                      }
                                      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                                    }

                                    /* "ws_package/controllers/activity_controller.py":5626
 *                                         await self.activity_service.update_activity_interval(interval)
 *                                         logger.info("Force-marked interval (id=%s) as uploaded", interval.id)
 *                                     except Exception as e:             # <<<<<<<<<<<<<<
 *                                         logger.error("Error force-updating interval (id=%s): %s", interval.id, e)
 * 
*/
                                    /*finally:*/ {
                                      /*normal exit:*/{
                                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                                        __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                                        goto __pyx_L860;
                                      }
                                      __pyx_L859_error:;
                                      /*exception exit:*/{
                                        __Pyx_PyThreadState_assign
                                        __pyx_t_41 = 0; __pyx_t_66 = 0; __pyx_t_67 = 0; __pyx_t_68 = 0; __pyx_t_69 = 0; __pyx_t_70 = 0;
                                        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                                        __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                                        __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                                        __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                                        __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                                        __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                                        __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                                        __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
                                        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                                         __Pyx_ExceptionSwap(&__pyx_t_68, &__pyx_t_69, &__pyx_t_70);
                                        if ( unlikely(__Pyx_GetException(&__pyx_t_41, &__pyx_t_66, &__pyx_t_67) < 0)) __Pyx_ErrFetch(&__pyx_t_41, &__pyx_t_66, &__pyx_t_67);
                                        __Pyx_XGOTREF(__pyx_t_41);
                                        __Pyx_XGOTREF(__pyx_t_66);
                                        __Pyx_XGOTREF(__pyx_t_67);
                                        __Pyx_XGOTREF(__pyx_t_68);
                                        __Pyx_XGOTREF(__pyx_t_69);
                                        __Pyx_XGOTREF(__pyx_t_70);
                                        __pyx_t_31 = __pyx_lineno; __pyx_t_32 = __pyx_clineno; __pyx_t_65 = __pyx_filename;
                                        {
                                          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                                          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                                        }
                                        __Pyx_XGIVEREF(__pyx_t_68);
                                        __Pyx_XGIVEREF(__pyx_t_69);
                                        __Pyx_XGIVEREF(__pyx_t_70);
                                        __Pyx_ExceptionReset(__pyx_t_68, __pyx_t_69, __pyx_t_70);
                                        __Pyx_XGIVEREF(__pyx_t_41);
                                        __Pyx_XGIVEREF(__pyx_t_66);
                                        __Pyx_XGIVEREF(__pyx_t_67);
                                        __Pyx_ErrRestore(__pyx_t_41, __pyx_t_66, __pyx_t_67);
                                        __pyx_t_41 = 0; __pyx_t_66 = 0; __pyx_t_67 = 0; __pyx_t_68 = 0; __pyx_t_69 = 0; __pyx_t_70 = 0;
                                        __pyx_lineno = __pyx_t_31; __pyx_clineno = __pyx_t_32; __pyx_filename = __pyx_t_65;
                                        goto __pyx_L847_except_error;
                                      }
                                      __pyx_L860:;
                                    }
                                    __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                                    __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                                    goto __pyx_L846_exception_handled;
                                  }
                                  goto __pyx_L847_except_error;

                                  /* "ws_package/controllers/activity_controller.py":5623
 *                                 # Force update them
 *                                 for interval in unsent_intervals:
 *                                     try:             # <<<<<<<<<<<<<<
 *                                         await self.activity_service.update_activity_interval(interval)
 *                                         logger.info("Force-marked interval (id=%s) as uploaded", interval.id)
*/
                                  __pyx_L847_except_error:;
                                  __Pyx_XGIVEREF(__pyx_t_18);
                                  __Pyx_XGIVEREF(__pyx_t_36);
                                  __Pyx_XGIVEREF(__pyx_t_30);
                                  __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_36, __pyx_t_30);
                                  goto __pyx_L832_error;
                                  __pyx_L846_exception_handled:;
                                  __Pyx_XGIVEREF(__pyx_t_18);
                                  __Pyx_XGIVEREF(__pyx_t_36);
                                  __Pyx_XGIVEREF(__pyx_t_30);
                                  __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_36, __pyx_t_30);
                                  __pyx_L852_try_end:;
                                }

                                /* "ws_package/controllers/activity_controller.py":5622
 *                                     logger.warning("   Unsent interval: id=%s, start_time=%s, end_time=%s", interval.id, interval.start_time, interval.end_time)
 *                                 # Force update them
 *                                 for interval in unsent_intervals:             # <<<<<<<<<<<<<<
 *                                     try:
 *                                         await self.activity_service.update_activity_interval(interval)
*/
                              }
                              __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;

                              /* "ws_package/controllers/activity_controller.py":5630
 * 
 *                                 # Flush one more time
 *                                 processed_count = await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 *                                 logger.info("Flushed %s queued database updates after force-marking intervals", processed_count)
 *                                 await asyncio.sleep(0.5)
*/
                              __pyx_t_25 = NULL;
                              __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5630, __pyx_L832_error)
                              __Pyx_GOTREF(__pyx_t_5);
                              __pyx_t_39 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5630, __pyx_L832_error)
                              __Pyx_GOTREF(__pyx_t_39);
                              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                              __pyx_t_8 = 1;
                              #if CYTHON_UNPACK_METHODS
                              if (unlikely(PyMethod_Check(__pyx_t_39))) {
                                __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_39);
                                assert(__pyx_t_25);
                                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_39);
                                __Pyx_INCREF(__pyx_t_25);
                                __Pyx_INCREF(__pyx__function);
                                __Pyx_DECREF_SET(__pyx_t_39, __pyx__function);
                                __pyx_t_8 = 0;
                              }
                              #endif
                              {
                                PyObject *__pyx_callargs[2] = {__pyx_t_25, NULL};
                                __pyx_t_52 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_39, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                                __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                                if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5630, __pyx_L832_error)
                                __Pyx_GOTREF(__pyx_t_52);
                              }
                              __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_52, &__pyx_r);
                              __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
                              if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                __Pyx_GOTREF(__pyx_r);
                                __Pyx_XGIVEREF(__pyx_t_1);
                                __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                __Pyx_XGIVEREF(__pyx_t_2);
                                __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                __Pyx_XGIVEREF(__pyx_t_3);
                                __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                __Pyx_XGIVEREF(__pyx_t_12);
                                __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                                __Pyx_XGIVEREF(__pyx_t_13);
                                __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                                __Pyx_XGIVEREF(__pyx_t_14);
                                __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                                __Pyx_XGIVEREF(__pyx_t_15);
                                __pyx_cur_scope->__pyx_t_6 = __pyx_t_15;
                                __Pyx_XGIVEREF(__pyx_t_16);
                                __pyx_cur_scope->__pyx_t_7 = __pyx_t_16;
                                __Pyx_XGIVEREF(__pyx_t_17);
                                __pyx_cur_scope->__pyx_t_8 = __pyx_t_17;
                                __Pyx_XGIVEREF(__pyx_t_19);
                                __pyx_cur_scope->__pyx_t_9 = __pyx_t_19;
                                __Pyx_XGIVEREF(__pyx_t_20);
                                __pyx_cur_scope->__pyx_t_10 = __pyx_t_20;
                                __Pyx_XGIVEREF(__pyx_t_21);
                                __pyx_cur_scope->__pyx_t_11 = __pyx_t_21;
                                __Pyx_XGIVEREF(__pyx_t_22);
                                __pyx_cur_scope->__pyx_t_12 = __pyx_t_22;
                                __Pyx_XGIVEREF(__pyx_t_37);
                                __pyx_cur_scope->__pyx_t_13 = __pyx_t_37;
                                __Pyx_XGIVEREF(__pyx_r);
                                __Pyx_RefNannyFinishContext();
                                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                                /* return from generator, awaiting value */
                                __pyx_generator->resume_label = 66;
                                return __pyx_r;
                                __pyx_L866_resume_from_await:;
                                __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                __pyx_cur_scope->__pyx_t_0 = 0;
                                __Pyx_XGOTREF(__pyx_t_1);
                                __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                __pyx_cur_scope->__pyx_t_1 = 0;
                                __Pyx_XGOTREF(__pyx_t_2);
                                __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                __pyx_cur_scope->__pyx_t_2 = 0;
                                __Pyx_XGOTREF(__pyx_t_3);
                                __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                                __pyx_cur_scope->__pyx_t_3 = 0;
                                __Pyx_XGOTREF(__pyx_t_12);
                                __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                                __pyx_cur_scope->__pyx_t_4 = 0;
                                __Pyx_XGOTREF(__pyx_t_13);
                                __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                                __pyx_cur_scope->__pyx_t_5 = 0;
                                __Pyx_XGOTREF(__pyx_t_14);
                                __pyx_t_15 = __pyx_cur_scope->__pyx_t_6;
                                __pyx_cur_scope->__pyx_t_6 = 0;
                                __Pyx_XGOTREF(__pyx_t_15);
                                __pyx_t_16 = __pyx_cur_scope->__pyx_t_7;
                                __pyx_cur_scope->__pyx_t_7 = 0;
                                __Pyx_XGOTREF(__pyx_t_16);
                                __pyx_t_17 = __pyx_cur_scope->__pyx_t_8;
                                __pyx_cur_scope->__pyx_t_8 = 0;
                                __Pyx_XGOTREF(__pyx_t_17);
                                __pyx_t_19 = __pyx_cur_scope->__pyx_t_9;
                                __pyx_cur_scope->__pyx_t_9 = 0;
                                __Pyx_XGOTREF(__pyx_t_19);
                                __pyx_t_20 = __pyx_cur_scope->__pyx_t_10;
                                __pyx_cur_scope->__pyx_t_10 = 0;
                                __Pyx_XGOTREF(__pyx_t_20);
                                __pyx_t_21 = __pyx_cur_scope->__pyx_t_11;
                                __pyx_cur_scope->__pyx_t_11 = 0;
                                __Pyx_XGOTREF(__pyx_t_21);
                                __pyx_t_22 = __pyx_cur_scope->__pyx_t_12;
                                __pyx_cur_scope->__pyx_t_12 = 0;
                                __Pyx_XGOTREF(__pyx_t_22);
                                __pyx_t_37 = __pyx_cur_scope->__pyx_t_13;
                                __pyx_cur_scope->__pyx_t_13 = 0;
                                __Pyx_XGOTREF(__pyx_t_37);
                                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5630, __pyx_L832_error)
                                __pyx_t_52 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_52);
                              } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                __Pyx_GOTREF(__pyx_r);
                                __pyx_t_52 = __pyx_r; __pyx_r = NULL;
                              } else {
                                __Pyx_XGOTREF(__pyx_r);
                                __PYX_ERR(0, 5630, __pyx_L832_error)
                              }
                              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_processed_count);
                              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_processed_count, __pyx_t_52);
                              __Pyx_GIVEREF(__pyx_t_52);
                              __pyx_t_52 = 0;

                              /* "ws_package/controllers/activity_controller.py":5631
 *                                 # Flush one more time
 *                                 processed_count = await db_writer_service.process_immediately()
 *                                 logger.info("Flushed %s queued database updates after force-marking intervals", processed_count)             # <<<<<<<<<<<<<<
 *                                 await asyncio.sleep(0.5)
 *                             else:
*/
                              __pyx_t_39 = NULL;
                              __Pyx_GetModuleGlobalName(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5631, __pyx_L832_error)
                              __Pyx_GOTREF(__pyx_t_25);
                              __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5631, __pyx_L832_error)
                              __Pyx_GOTREF(__pyx_t_5);
                              __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                              __pyx_t_8 = 1;
                              #if CYTHON_UNPACK_METHODS
                              if (unlikely(PyMethod_Check(__pyx_t_5))) {
                                __pyx_t_39 = PyMethod_GET_SELF(__pyx_t_5);
                                assert(__pyx_t_39);
                                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                                __Pyx_INCREF(__pyx_t_39);
                                __Pyx_INCREF(__pyx__function);
                                __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                                __pyx_t_8 = 0;
                              }
                              #endif
                              {
                                PyObject *__pyx_callargs[3] = {__pyx_t_39, __pyx_mstate_global->__pyx_kp_u_Flushed_s_queued_database_update_3, __pyx_cur_scope->__pyx_v_processed_count};
                                __pyx_t_52 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                                if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5631, __pyx_L832_error)
                                __Pyx_GOTREF(__pyx_t_52);
                              }
                              __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;

                              /* "ws_package/controllers/activity_controller.py":5632
 *                                 processed_count = await db_writer_service.process_immediately()
 *                                 logger.info("Flushed %s queued database updates after force-marking intervals", processed_count)
 *                                 await asyncio.sleep(0.5)             # <<<<<<<<<<<<<<
 *                             else:
 *                                 logger.info(" Final verification passed: All intervals from current session (counter=%s) are marked as uploaded", current_session_counter)
*/
                              __pyx_t_5 = NULL;
                              __Pyx_GetModuleGlobalName(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5632, __pyx_L832_error)
                              __Pyx_GOTREF(__pyx_t_39);
                              __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_39, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5632, __pyx_L832_error)
                              __Pyx_GOTREF(__pyx_t_25);
                              __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                              __pyx_t_8 = 1;
                              #if CYTHON_UNPACK_METHODS
                              if (unlikely(PyMethod_Check(__pyx_t_25))) {
                                __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_25);
                                assert(__pyx_t_5);
                                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_25);
                                __Pyx_INCREF(__pyx_t_5);
                                __Pyx_INCREF(__pyx__function);
                                __Pyx_DECREF_SET(__pyx_t_25, __pyx__function);
                                __pyx_t_8 = 0;
                              }
                              #endif
                              {
                                PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_float_0_5};
                                __pyx_t_52 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_25, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                                __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                                if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5632, __pyx_L832_error)
                                __Pyx_GOTREF(__pyx_t_52);
                              }
                              __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_52, &__pyx_r);
                              __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
                              if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                __Pyx_GOTREF(__pyx_r);
                                __Pyx_XGIVEREF(__pyx_t_1);
                                __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                __Pyx_XGIVEREF(__pyx_t_2);
                                __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                __Pyx_XGIVEREF(__pyx_t_3);
                                __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                __Pyx_XGIVEREF(__pyx_t_12);
                                __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                                __Pyx_XGIVEREF(__pyx_t_13);
                                __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                                __Pyx_XGIVEREF(__pyx_t_14);
                                __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                                __Pyx_XGIVEREF(__pyx_t_15);
                                __pyx_cur_scope->__pyx_t_6 = __pyx_t_15;
                                __Pyx_XGIVEREF(__pyx_t_16);
                                __pyx_cur_scope->__pyx_t_7 = __pyx_t_16;
                                __Pyx_XGIVEREF(__pyx_t_17);
                                __pyx_cur_scope->__pyx_t_8 = __pyx_t_17;
                                __Pyx_XGIVEREF(__pyx_t_19);
                                __pyx_cur_scope->__pyx_t_9 = __pyx_t_19;
                                __Pyx_XGIVEREF(__pyx_t_20);
                                __pyx_cur_scope->__pyx_t_10 = __pyx_t_20;
                                __Pyx_XGIVEREF(__pyx_t_21);
                                __pyx_cur_scope->__pyx_t_11 = __pyx_t_21;
                                __Pyx_XGIVEREF(__pyx_t_22);
                                __pyx_cur_scope->__pyx_t_12 = __pyx_t_22;
                                __Pyx_XGIVEREF(__pyx_t_37);
                                __pyx_cur_scope->__pyx_t_13 = __pyx_t_37;
                                __Pyx_XGIVEREF(__pyx_r);
                                __Pyx_RefNannyFinishContext();
                                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                                /* return from generator, awaiting value */
                                __pyx_generator->resume_label = 67;
                                return __pyx_r;
                                __pyx_L867_resume_from_await:;
                                __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                __pyx_cur_scope->__pyx_t_0 = 0;
                                __Pyx_XGOTREF(__pyx_t_1);
                                __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                __pyx_cur_scope->__pyx_t_1 = 0;
                                __Pyx_XGOTREF(__pyx_t_2);
                                __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                __pyx_cur_scope->__pyx_t_2 = 0;
                                __Pyx_XGOTREF(__pyx_t_3);
                                __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                                __pyx_cur_scope->__pyx_t_3 = 0;
                                __Pyx_XGOTREF(__pyx_t_12);
                                __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                                __pyx_cur_scope->__pyx_t_4 = 0;
                                __Pyx_XGOTREF(__pyx_t_13);
                                __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                                __pyx_cur_scope->__pyx_t_5 = 0;
                                __Pyx_XGOTREF(__pyx_t_14);
                                __pyx_t_15 = __pyx_cur_scope->__pyx_t_6;
                                __pyx_cur_scope->__pyx_t_6 = 0;
                                __Pyx_XGOTREF(__pyx_t_15);
                                __pyx_t_16 = __pyx_cur_scope->__pyx_t_7;
                                __pyx_cur_scope->__pyx_t_7 = 0;
                                __Pyx_XGOTREF(__pyx_t_16);
                                __pyx_t_17 = __pyx_cur_scope->__pyx_t_8;
                                __pyx_cur_scope->__pyx_t_8 = 0;
                                __Pyx_XGOTREF(__pyx_t_17);
                                __pyx_t_19 = __pyx_cur_scope->__pyx_t_9;
                                __pyx_cur_scope->__pyx_t_9 = 0;
                                __Pyx_XGOTREF(__pyx_t_19);
                                __pyx_t_20 = __pyx_cur_scope->__pyx_t_10;
                                __pyx_cur_scope->__pyx_t_10 = 0;
                                __Pyx_XGOTREF(__pyx_t_20);
                                __pyx_t_21 = __pyx_cur_scope->__pyx_t_11;
                                __pyx_cur_scope->__pyx_t_11 = 0;
                                __Pyx_XGOTREF(__pyx_t_21);
                                __pyx_t_22 = __pyx_cur_scope->__pyx_t_12;
                                __pyx_cur_scope->__pyx_t_12 = 0;
                                __Pyx_XGOTREF(__pyx_t_22);
                                __pyx_t_37 = __pyx_cur_scope->__pyx_t_13;
                                __pyx_cur_scope->__pyx_t_13 = 0;
                                __Pyx_XGOTREF(__pyx_t_37);
                                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5632, __pyx_L832_error)
                              } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                __Pyx_GOTREF(__pyx_r);
                                __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                              } else {
                                __Pyx_XGOTREF(__pyx_r);
                                __PYX_ERR(0, 5632, __pyx_L832_error)
                              }

                              /* "ws_package/controllers/activity_controller.py":5617
 *                             unsent_intervals = result.scalars().all()
 * 
 *                             if unsent_intervals:             # <<<<<<<<<<<<<<
 *                                 logger.warning(" Found %s intervals from current session (counter=%s) still marked as unsent after upload!", len(unsent_intervals), current_session_counter)
 *                                 for interval in unsent_intervals:
*/
                              goto __pyx_L839;
                            }

                            /* "ws_package/controllers/activity_controller.py":5634
 *                                 await asyncio.sleep(0.5)
 *                             else:
 *                                 logger.info(" Final verification passed: All intervals from current session (counter=%s) are marked as uploaded", current_session_counter)             # <<<<<<<<<<<<<<
 *                 except Exception as e:
 *                     logger.error("Error in final verification step: %s", e, exc_info=True)
*/
                            /*else*/ {
                              __pyx_t_25 = NULL;
                              __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5634, __pyx_L832_error)
                              __Pyx_GOTREF(__pyx_t_5);
                              __pyx_t_39 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_39)) __PYX_ERR(0, 5634, __pyx_L832_error)
                              __Pyx_GOTREF(__pyx_t_39);
                              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                              __pyx_t_8 = 1;
                              #if CYTHON_UNPACK_METHODS
                              if (unlikely(PyMethod_Check(__pyx_t_39))) {
                                __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_39);
                                assert(__pyx_t_25);
                                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_39);
                                __Pyx_INCREF(__pyx_t_25);
                                __Pyx_INCREF(__pyx__function);
                                __Pyx_DECREF_SET(__pyx_t_39, __pyx__function);
                                __pyx_t_8 = 0;
                              }
                              #endif
                              {
                                PyObject *__pyx_callargs[3] = {__pyx_t_25, __pyx_mstate_global->__pyx_kp_u_Final_verification_passed_All_i, __pyx_cur_scope->__pyx_v_current_session_counter};
                                __pyx_t_52 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_39, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                                __Pyx_DECREF(__pyx_t_39); __pyx_t_39 = 0;
                                if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5634, __pyx_L832_error)
                                __Pyx_GOTREF(__pyx_t_52);
                              }
                              __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
                            }
                            __pyx_L839:;

                            /* "ws_package/controllers/activity_controller.py":5608
 * 
 *                     with db_lock_manager.read_lock():
 *                         async with async_session() as session:             # <<<<<<<<<<<<<<
 *                             # Query for all intervals from current session
 *                             query = select(ActivityInterval).where(
*/
                          }
                          __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                          __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                          goto __pyx_L837_try_end;
                          __pyx_L832_error:;
                          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                          __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                          __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                          __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                          __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                          __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                          __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                          __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                          __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                          __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
                          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                          /*except:*/ {
                            __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
                            if (__Pyx_GetException(&__pyx_t_52, &__pyx_t_39, &__pyx_t_25) < 0) __PYX_ERR(0, 5608, __pyx_L834_except_error)
                            __Pyx_XGOTREF(__pyx_t_52);
                            __Pyx_XGOTREF(__pyx_t_39);
                            __Pyx_XGOTREF(__pyx_t_25);
                            __pyx_t_5 = PyTuple_Pack(3, __pyx_t_52, __pyx_t_39, __pyx_t_25); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5608, __pyx_L834_except_error)
                            __Pyx_GOTREF(__pyx_t_5);
                            __pyx_t_30 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_t_5, NULL);
                            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                            if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 5608, __pyx_L834_except_error)
                            __Pyx_GOTREF(__pyx_t_30);
                            __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_30, &__pyx_r);
                            __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
                            if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                              __Pyx_GOTREF(__pyx_r);
                              __Pyx_XGIVEREF(__pyx_t_1);
                              __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                              __Pyx_XGIVEREF(__pyx_t_2);
                              __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                              __Pyx_XGIVEREF(__pyx_t_3);
                              __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                              __Pyx_XGIVEREF(__pyx_t_12);
                              __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                              __Pyx_XGIVEREF(__pyx_t_13);
                              __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                              __Pyx_XGIVEREF(__pyx_t_14);
                              __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                              __Pyx_XGIVEREF(__pyx_t_15);
                              __pyx_cur_scope->__pyx_t_6 = __pyx_t_15;
                              __Pyx_XGIVEREF(__pyx_t_16);
                              __pyx_cur_scope->__pyx_t_7 = __pyx_t_16;
                              __Pyx_XGIVEREF(__pyx_t_17);
                              __pyx_cur_scope->__pyx_t_8 = __pyx_t_17;
                              __Pyx_XGIVEREF(__pyx_t_19);
                              __pyx_cur_scope->__pyx_t_9 = __pyx_t_19;
                              __Pyx_XGIVEREF(__pyx_t_20);
                              __pyx_cur_scope->__pyx_t_10 = __pyx_t_20;
                              __Pyx_XGIVEREF(__pyx_t_21);
                              __pyx_cur_scope->__pyx_t_11 = __pyx_t_21;
                              __Pyx_XGIVEREF(__pyx_t_22);
                              __pyx_cur_scope->__pyx_t_12 = __pyx_t_22;
                              __Pyx_XGIVEREF(__pyx_t_25);
                              __pyx_cur_scope->__pyx_t_13 = __pyx_t_25;
                              __Pyx_XGIVEREF(__pyx_t_30);
                              __pyx_cur_scope->__pyx_t_14 = __pyx_t_30;
                              __Pyx_XGIVEREF(__pyx_t_37);
                              __pyx_cur_scope->__pyx_t_15 = __pyx_t_37;
                              __Pyx_XGIVEREF(__pyx_t_39);
                              __pyx_cur_scope->__pyx_t_16 = __pyx_t_39;
                              __Pyx_XGIVEREF(__pyx_t_52);
                              __pyx_cur_scope->__pyx_t_17 = __pyx_t_52;
                              __Pyx_XGIVEREF(__pyx_r);
                              __Pyx_RefNannyFinishContext();
                              __Pyx_Coroutine_SwapException(__pyx_generator);
                              /* return from generator, awaiting value */
                              __pyx_generator->resume_label = 68;
                              return __pyx_r;
                              __pyx_L871_resume_from_await:;
                              __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                              __pyx_cur_scope->__pyx_t_0 = 0;
                              __Pyx_XGOTREF(__pyx_t_1);
                              __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                              __pyx_cur_scope->__pyx_t_1 = 0;
                              __Pyx_XGOTREF(__pyx_t_2);
                              __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                              __pyx_cur_scope->__pyx_t_2 = 0;
                              __Pyx_XGOTREF(__pyx_t_3);
                              __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                              __pyx_cur_scope->__pyx_t_3 = 0;
                              __Pyx_XGOTREF(__pyx_t_12);
                              __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                              __pyx_cur_scope->__pyx_t_4 = 0;
                              __Pyx_XGOTREF(__pyx_t_13);
                              __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                              __pyx_cur_scope->__pyx_t_5 = 0;
                              __Pyx_XGOTREF(__pyx_t_14);
                              __pyx_t_15 = __pyx_cur_scope->__pyx_t_6;
                              __pyx_cur_scope->__pyx_t_6 = 0;
                              __Pyx_XGOTREF(__pyx_t_15);
                              __pyx_t_16 = __pyx_cur_scope->__pyx_t_7;
                              __pyx_cur_scope->__pyx_t_7 = 0;
                              __Pyx_XGOTREF(__pyx_t_16);
                              __pyx_t_17 = __pyx_cur_scope->__pyx_t_8;
                              __pyx_cur_scope->__pyx_t_8 = 0;
                              __Pyx_XGOTREF(__pyx_t_17);
                              __pyx_t_19 = __pyx_cur_scope->__pyx_t_9;
                              __pyx_cur_scope->__pyx_t_9 = 0;
                              __Pyx_XGOTREF(__pyx_t_19);
                              __pyx_t_20 = __pyx_cur_scope->__pyx_t_10;
                              __pyx_cur_scope->__pyx_t_10 = 0;
                              __Pyx_XGOTREF(__pyx_t_20);
                              __pyx_t_21 = __pyx_cur_scope->__pyx_t_11;
                              __pyx_cur_scope->__pyx_t_11 = 0;
                              __Pyx_XGOTREF(__pyx_t_21);
                              __pyx_t_22 = __pyx_cur_scope->__pyx_t_12;
                              __pyx_cur_scope->__pyx_t_12 = 0;
                              __Pyx_XGOTREF(__pyx_t_22);
                              __pyx_t_25 = __pyx_cur_scope->__pyx_t_13;
                              __pyx_cur_scope->__pyx_t_13 = 0;
                              __Pyx_XGOTREF(__pyx_t_25);
                              __pyx_t_30 = __pyx_cur_scope->__pyx_t_14;
                              __pyx_cur_scope->__pyx_t_14 = 0;
                              __Pyx_XGOTREF(__pyx_t_30);
                              __pyx_t_37 = __pyx_cur_scope->__pyx_t_15;
                              __pyx_cur_scope->__pyx_t_15 = 0;
                              __Pyx_XGOTREF(__pyx_t_37);
                              __pyx_t_39 = __pyx_cur_scope->__pyx_t_16;
                              __pyx_cur_scope->__pyx_t_16 = 0;
                              __Pyx_XGOTREF(__pyx_t_39);
                              __pyx_t_52 = __pyx_cur_scope->__pyx_t_17;
                              __pyx_cur_scope->__pyx_t_17 = 0;
                              __Pyx_XGOTREF(__pyx_t_52);
                              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5608, __pyx_L834_except_error)
                              __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
                            } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                              __Pyx_GOTREF(__pyx_r);
                              __pyx_t_5 = __pyx_r; __pyx_r = NULL;
                            } else {
                              __Pyx_XGOTREF(__pyx_r);
                              __PYX_ERR(0, 5608, __pyx_L834_except_error)
                            }
                            __pyx_t_30 = __pyx_t_5;
                            __pyx_t_5 = 0;
                            __pyx_t_47 = __Pyx_PyObject_IsTrue(__pyx_t_30);
                            __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
                            if (__pyx_t_47 < (0)) __PYX_ERR(0, 5608, __pyx_L834_except_error)
                            __pyx_t_28 = (!__pyx_t_47);
                            if (unlikely(__pyx_t_28)) {
                              __Pyx_GIVEREF(__pyx_t_52);
                              __Pyx_GIVEREF(__pyx_t_39);
                              __Pyx_XGIVEREF(__pyx_t_25);
                              __Pyx_ErrRestoreWithState(__pyx_t_52, __pyx_t_39, __pyx_t_25);
                              __pyx_t_52 = 0;  __pyx_t_39 = 0;  __pyx_t_25 = 0; 
                              __PYX_ERR(0, 5608, __pyx_L834_except_error)
                            }
                            __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                            __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                            __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                            goto __pyx_L833_exception_handled;
                          }
                          __pyx_L834_except_error:;
                          __Pyx_XGIVEREF(__pyx_t_20);
                          __Pyx_XGIVEREF(__pyx_t_21);
                          __Pyx_XGIVEREF(__pyx_t_15);
                          __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_15);
                          goto __pyx_L821_error;
                          __pyx_L833_exception_handled:;
                          __Pyx_XGIVEREF(__pyx_t_20);
                          __Pyx_XGIVEREF(__pyx_t_21);
                          __Pyx_XGIVEREF(__pyx_t_15);
                          __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_15);
                          __pyx_L837_try_end:;
                        }
                      }
                      /*finally:*/ {
                        /*normal exit:*/{
                          if (__pyx_t_17) {
                            __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_mstate_global->__pyx_tuple[7], NULL);
                            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                            if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5608, __pyx_L821_error)
                            __Pyx_GOTREF(__pyx_t_15);
                            __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_15, &__pyx_r);
                            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                            if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                              __Pyx_GOTREF(__pyx_r);
                              __Pyx_XGIVEREF(__pyx_t_1);
                              __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                              __Pyx_XGIVEREF(__pyx_t_2);
                              __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                              __Pyx_XGIVEREF(__pyx_t_3);
                              __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                              __Pyx_XGIVEREF(__pyx_t_12);
                              __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                              __Pyx_XGIVEREF(__pyx_t_13);
                              __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                              __Pyx_XGIVEREF(__pyx_t_14);
                              __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                              __Pyx_XGIVEREF(__pyx_t_15);
                              __pyx_cur_scope->__pyx_t_6 = __pyx_t_15;
                              __Pyx_XGIVEREF(__pyx_t_16);
                              __pyx_cur_scope->__pyx_t_7 = __pyx_t_16;
                              __Pyx_XGIVEREF(__pyx_t_17);
                              __pyx_cur_scope->__pyx_t_8 = __pyx_t_17;
                              __Pyx_XGIVEREF(__pyx_t_19);
                              __pyx_cur_scope->__pyx_t_9 = __pyx_t_19;
                              __Pyx_XGIVEREF(__pyx_t_22);
                              __pyx_cur_scope->__pyx_t_10 = __pyx_t_22;
                              __Pyx_XGIVEREF(__pyx_t_37);
                              __pyx_cur_scope->__pyx_t_11 = __pyx_t_37;
                              __Pyx_XGIVEREF(__pyx_r);
                              __Pyx_RefNannyFinishContext();
                              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                              /* return from generator, awaiting value */
                              __pyx_generator->resume_label = 69;
                              return __pyx_r;
                              __pyx_L872_resume_from_await:;
                              __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                              __pyx_cur_scope->__pyx_t_0 = 0;
                              __Pyx_XGOTREF(__pyx_t_1);
                              __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                              __pyx_cur_scope->__pyx_t_1 = 0;
                              __Pyx_XGOTREF(__pyx_t_2);
                              __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                              __pyx_cur_scope->__pyx_t_2 = 0;
                              __Pyx_XGOTREF(__pyx_t_3);
                              __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                              __pyx_cur_scope->__pyx_t_3 = 0;
                              __Pyx_XGOTREF(__pyx_t_12);
                              __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                              __pyx_cur_scope->__pyx_t_4 = 0;
                              __Pyx_XGOTREF(__pyx_t_13);
                              __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                              __pyx_cur_scope->__pyx_t_5 = 0;
                              __Pyx_XGOTREF(__pyx_t_14);
                              __pyx_t_15 = __pyx_cur_scope->__pyx_t_6;
                              __pyx_cur_scope->__pyx_t_6 = 0;
                              __Pyx_XGOTREF(__pyx_t_15);
                              __pyx_t_16 = __pyx_cur_scope->__pyx_t_7;
                              __pyx_cur_scope->__pyx_t_7 = 0;
                              __Pyx_XGOTREF(__pyx_t_16);
                              __pyx_t_17 = __pyx_cur_scope->__pyx_t_8;
                              __pyx_cur_scope->__pyx_t_8 = 0;
                              __Pyx_XGOTREF(__pyx_t_17);
                              __pyx_t_19 = __pyx_cur_scope->__pyx_t_9;
                              __pyx_cur_scope->__pyx_t_9 = 0;
                              __Pyx_XGOTREF(__pyx_t_19);
                              __pyx_t_22 = __pyx_cur_scope->__pyx_t_10;
                              __pyx_cur_scope->__pyx_t_10 = 0;
                              __Pyx_XGOTREF(__pyx_t_22);
                              __pyx_t_37 = __pyx_cur_scope->__pyx_t_11;
                              __pyx_cur_scope->__pyx_t_11 = 0;
                              __Pyx_XGOTREF(__pyx_t_37);
                              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5608, __pyx_L821_error)
                              __pyx_t_25 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_25);
                            } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                              __Pyx_GOTREF(__pyx_r);
                              __pyx_t_25 = __pyx_r; __pyx_r = NULL;
                            } else {
                              __Pyx_XGOTREF(__pyx_r);
                              __PYX_ERR(0, 5608, __pyx_L821_error)
                            }
                            __pyx_t_15 = __pyx_t_25;
                            __pyx_t_25 = 0;
                            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                          }
                          goto __pyx_L831;
                        }
                        __pyx_L831:;
                      }
                      goto __pyx_L873;
                      __pyx_L827_error:;
                      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                      goto __pyx_L821_error;
                      __pyx_L873:;
                    }

                    /* "ws_package/controllers/activity_controller.py":5607
 *                     await asyncio.sleep(0.5)
 * 
 *                     with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                         async with async_session() as session:
 *                             # Query for all intervals from current session
*/
                  }
                  __Pyx_XDECREF(__pyx_t_37); __pyx_t_37 = 0;
                  __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                  __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                  goto __pyx_L826_try_end;
                  __pyx_L821_error:;
                  __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                  __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                  __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                  __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                  __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                  __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                  __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                  /*except:*/ {
                    __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
                    if (__Pyx_GetException(&__pyx_t_25, &__pyx_t_39, &__pyx_t_52) < 0) __PYX_ERR(0, 5607, __pyx_L823_except_error)
                    __Pyx_XGOTREF(__pyx_t_25);
                    __Pyx_XGOTREF(__pyx_t_39);
                    __Pyx_XGOTREF(__pyx_t_52);
                    __pyx_t_5 = PyTuple_Pack(3, __pyx_t_25, __pyx_t_39, __pyx_t_52); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5607, __pyx_L823_except_error)
                    __Pyx_GOTREF(__pyx_t_5);
                    __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_22, __pyx_t_5, NULL);
                    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                    if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 5607, __pyx_L823_except_error)
                    __Pyx_GOTREF(__pyx_t_17);
                    __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_17);
                    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                    if (__pyx_t_28 < (0)) __PYX_ERR(0, 5607, __pyx_L823_except_error)
                    __pyx_t_47 = (!__pyx_t_28);
                    if (unlikely(__pyx_t_47)) {
                      __Pyx_GIVEREF(__pyx_t_25);
                      __Pyx_GIVEREF(__pyx_t_39);
                      __Pyx_XGIVEREF(__pyx_t_52);
                      __Pyx_ErrRestoreWithState(__pyx_t_25, __pyx_t_39, __pyx_t_52);
                      __pyx_t_25 = 0;  __pyx_t_39 = 0;  __pyx_t_52 = 0; 
                      __PYX_ERR(0, 5607, __pyx_L823_except_error)
                    }
                    __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                    __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
                    __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
                    goto __pyx_L822_exception_handled;
                  }
                  __pyx_L823_except_error:;
                  __Pyx_XGIVEREF(__pyx_t_37);
                  __Pyx_XGIVEREF(__pyx_t_19);
                  __Pyx_XGIVEREF(__pyx_t_16);
                  __Pyx_ExceptionReset(__pyx_t_37, __pyx_t_19, __pyx_t_16);
                  goto __pyx_L810_error;
                  __pyx_L822_exception_handled:;
                  __Pyx_XGIVEREF(__pyx_t_37);
                  __Pyx_XGIVEREF(__pyx_t_19);
                  __Pyx_XGIVEREF(__pyx_t_16);
                  __Pyx_ExceptionReset(__pyx_t_37, __pyx_t_19, __pyx_t_16);
                  __pyx_L826_try_end:;
                }
              }
              /*finally:*/ {
                /*normal exit:*/{
                  if (__pyx_t_22) {
                    __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_22, __pyx_mstate_global->__pyx_tuple[7], NULL);
                    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                    if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 5607, __pyx_L810_error)
                    __Pyx_GOTREF(__pyx_t_16);
                    __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                  }
                  goto __pyx_L820;
                }
                __pyx_L820:;
              }
              goto __pyx_L877;
              __pyx_L817_error:;
              __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
              goto __pyx_L810_error;
              __pyx_L877:;
            }

            /* "ws_package/controllers/activity_controller.py":5603
 *             if at_least_one_batch_successful and intervals:
 *                 logger.info("Performing final verification: checking all %s intervals from current session are marked as uploaded in database...", len(intervals))
 *                 try:             # <<<<<<<<<<<<<<
 *                     # Wait a bit more to ensure all updates are committed
 *                     await asyncio.sleep(0.5)
*/
          }
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          goto __pyx_L815_try_end;
          __pyx_L810_error:;
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
          __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
          __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
          __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
          __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
          __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
          __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "ws_package/controllers/activity_controller.py":5635
 *                             else:
 *                                 logger.info(" Final verification passed: All intervals from current session (counter=%s) are marked as uploaded", current_session_counter)
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Error in final verification step: %s", e, exc_info=True)
 * 
*/
          __pyx_t_32 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
          if (__pyx_t_32) {
            __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_52, &__pyx_t_39, &__pyx_t_25) < 0) __PYX_ERR(0, 5635, __pyx_L812_except_error)
            __Pyx_XGOTREF(__pyx_t_52);
            __Pyx_XGOTREF(__pyx_t_39);
            __Pyx_XGOTREF(__pyx_t_25);
            __Pyx_INCREF(__pyx_t_39);
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_39);
            __Pyx_GIVEREF(__pyx_t_39);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":5636
 *                                 logger.info(" Final verification passed: All intervals from current session (counter=%s) are marked as uploaded", current_session_counter)
 *                 except Exception as e:
 *                     logger.error("Error in final verification step: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *             logger.info("=== last_api_call COMPLETED SUCCESSFULLY ===")
*/
              __pyx_t_10 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5636, __pyx_L883_error)
              __Pyx_GOTREF(__pyx_t_4);
              __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5636, __pyx_L883_error)
              __Pyx_GOTREF(__pyx_t_7);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_7))) {
                __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7);
                assert(__pyx_t_10);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                __Pyx_INCREF(__pyx_t_10);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Error_in_final_verification_step, __pyx_cur_scope->__pyx_v_e};
                __pyx_t_4 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5636, __pyx_L883_error)
                __Pyx_GOTREF(__pyx_t_4);
                if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_4, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 5636, __pyx_L883_error)
                __pyx_t_5 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_4);
                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5636, __pyx_L883_error)
                __Pyx_GOTREF(__pyx_t_5);
              }
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            }

            /* "ws_package/controllers/activity_controller.py":5635
 *                             else:
 *                                 logger.info(" Final verification passed: All intervals from current session (counter=%s) are marked as uploaded", current_session_counter)
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Error in final verification step: %s", e, exc_info=True)
 * 
*/
            /*finally:*/ {
              /*normal exit:*/{
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                goto __pyx_L884;
              }
              __pyx_L883_error:;
              /*exception exit:*/{
                __Pyx_PyThreadState_assign
                __pyx_t_22 = 0; __pyx_t_16 = 0; __pyx_t_19 = 0; __pyx_t_37 = 0; __pyx_t_17 = 0; __pyx_t_15 = 0;
                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
                __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                 __Pyx_ExceptionSwap(&__pyx_t_37, &__pyx_t_17, &__pyx_t_15);
                if ( unlikely(__Pyx_GetException(&__pyx_t_22, &__pyx_t_16, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_22, &__pyx_t_16, &__pyx_t_19);
                __Pyx_XGOTREF(__pyx_t_22);
                __Pyx_XGOTREF(__pyx_t_16);
                __Pyx_XGOTREF(__pyx_t_19);
                __Pyx_XGOTREF(__pyx_t_37);
                __Pyx_XGOTREF(__pyx_t_17);
                __Pyx_XGOTREF(__pyx_t_15);
                __pyx_t_32 = __pyx_lineno; __pyx_t_31 = __pyx_clineno; __pyx_t_71 = __pyx_filename;
                {
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                }
                __Pyx_XGIVEREF(__pyx_t_37);
                __Pyx_XGIVEREF(__pyx_t_17);
                __Pyx_XGIVEREF(__pyx_t_15);
                __Pyx_ExceptionReset(__pyx_t_37, __pyx_t_17, __pyx_t_15);
                __Pyx_XGIVEREF(__pyx_t_22);
                __Pyx_XGIVEREF(__pyx_t_16);
                __Pyx_XGIVEREF(__pyx_t_19);
                __Pyx_ErrRestore(__pyx_t_22, __pyx_t_16, __pyx_t_19);
                __pyx_t_22 = 0; __pyx_t_16 = 0; __pyx_t_19 = 0; __pyx_t_37 = 0; __pyx_t_17 = 0; __pyx_t_15 = 0;
                __pyx_lineno = __pyx_t_32; __pyx_clineno = __pyx_t_31; __pyx_filename = __pyx_t_71;
                goto __pyx_L812_except_error;
              }
              __pyx_L884:;
            }
            __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
            __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
            __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
            goto __pyx_L811_exception_handled;
          }
          goto __pyx_L812_except_error;

          /* "ws_package/controllers/activity_controller.py":5603
 *             if at_least_one_batch_successful and intervals:
 *                 logger.info("Performing final verification: checking all %s intervals from current session are marked as uploaded in database...", len(intervals))
 *                 try:             # <<<<<<<<<<<<<<
 *                     # Wait a bit more to ensure all updates are committed
 *                     await asyncio.sleep(0.5)
*/
          __pyx_L812_except_error:;
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
          goto __pyx_L4_error;
          __pyx_L811_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
          __pyx_L815_try_end:;
        }

        /* "ws_package/controllers/activity_controller.py":5601
 *             # CRITICAL FINAL STEP: Verify all intervals from current session are marked as uploaded in database
 *             # This prevents them from being sent again when timer restarts
 *             if at_least_one_batch_successful and intervals:             # <<<<<<<<<<<<<<
 *                 logger.info("Performing final verification: checking all %s intervals from current session are marked as uploaded in database...", len(intervals))
 *                 try:
*/
      }

      /* "ws_package/controllers/activity_controller.py":5638
 *                     logger.error("Error in final verification step: %s", e, exc_info=True)
 * 
 *             logger.info("=== last_api_call COMPLETED SUCCESSFULLY ===")             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             logger.error("=== last_api_call FAILED: %s ===", e, exc_info=True)
*/
      __pyx_t_39 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_52, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5638, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_52);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_52, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5638, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_39 = PyMethod_GET_SELF(__pyx_t_5);
        assert(__pyx_t_39);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_39);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_39, __pyx_mstate_global->__pyx_kp_u_last_api_call_COMPLETED_SUCCESS};
        __pyx_t_25 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5638, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_25);
      }
      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;

      /* "ws_package/controllers/activity_controller.py":4860
 *     ):
 *         """Internal implementation of last_api_call (caller must hold _session_close_lock)."""
 *         try:             # <<<<<<<<<<<<<<
 *             logger.info(
 *                 "=== last_api_call STARTED (keep_idle_time=%s, close_time=%s, project_override=%s) ===",
*/
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L9_try_end;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
    __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
    __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
    __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
    __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
    __Pyx_XDECREF(__pyx_t_39); __pyx_t_39 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
    __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "ws_package/controllers/activity_controller.py":5639
 * 
 *             logger.info("=== last_api_call COMPLETED SUCCESSFULLY ===")
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("=== last_api_call FAILED: %s ===", e, exc_info=True)
 *             raise  # Re-raise to let caller know it failed
*/
    __pyx_t_31 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_31) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_25, &__pyx_t_5, &__pyx_t_39) < 0) __PYX_ERR(0, 5639, __pyx_L6_except_error)
      __Pyx_XGOTREF(__pyx_t_25);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_39);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":5640
 *             logger.info("=== last_api_call COMPLETED SUCCESSFULLY ===")
 *         except Exception as e:
 *             logger.error("=== last_api_call FAILED: %s ===", e, exc_info=True)             # <<<<<<<<<<<<<<
 *             raise  # Re-raise to let caller know it failed
 * 
*/
        __pyx_t_7 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5640, __pyx_L894_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5640, __pyx_L894_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_10);
          assert(__pyx_t_7);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_last_api_call_FAILED_s, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_4 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5640, __pyx_L894_error)
          __Pyx_GOTREF(__pyx_t_4);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_4, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 5640, __pyx_L894_error)
          __pyx_t_52 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_4);
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_52)) __PYX_ERR(0, 5640, __pyx_L894_error)
          __Pyx_GOTREF(__pyx_t_52);
        }
        __Pyx_DECREF(__pyx_t_52); __pyx_t_52 = 0;

        /* "ws_package/controllers/activity_controller.py":5641
 *         except Exception as e:
 *             logger.error("=== last_api_call FAILED: %s ===", e, exc_info=True)
 *             raise  # Re-raise to let caller know it failed             # <<<<<<<<<<<<<<
 * 
 *     async def stop_event(self, user_entity: UserEntity, keep_idle_time: bool = True):
*/
        __Pyx_GIVEREF(__pyx_t_25);
        __Pyx_GIVEREF(__pyx_t_5);
        __Pyx_XGIVEREF(__pyx_t_39);
        __Pyx_ErrRestoreWithState(__pyx_t_25, __pyx_t_5, __pyx_t_39);
        __pyx_t_25 = 0;  __pyx_t_5 = 0;  __pyx_t_39 = 0; 
        __PYX_ERR(0, 5641, __pyx_L894_error)
      }

      /* "ws_package/controllers/activity_controller.py":5639
 * 
 *             logger.info("=== last_api_call COMPLETED SUCCESSFULLY ===")
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("=== last_api_call FAILED: %s ===", e, exc_info=True)
 *             raise  # Re-raise to let caller know it failed
*/
      /*finally:*/ {
        __pyx_L894_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_15 = 0; __pyx_t_17 = 0; __pyx_t_37 = 0;
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
          __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
          __Pyx_XDECREF(__pyx_t_27); __pyx_t_27 = 0;
          __Pyx_XDECREF(__pyx_t_38); __pyx_t_38 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_40); __pyx_t_40 = 0;
          __Pyx_XDECREF(__pyx_t_52); __pyx_t_52 = 0;
          __Pyx_XDECREF(__pyx_t_55); __pyx_t_55 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_17, &__pyx_t_37);
          if ( unlikely(__Pyx_GetException(&__pyx_t_14, &__pyx_t_13, &__pyx_t_12) < 0)) __Pyx_ErrFetch(&__pyx_t_14, &__pyx_t_13, &__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_17);
          __Pyx_XGOTREF(__pyx_t_37);
          __pyx_t_31 = __pyx_lineno; __pyx_t_32 = __pyx_clineno; __pyx_t_72 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_XGIVEREF(__pyx_t_37);
          __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_17, __pyx_t_37);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ErrRestore(__pyx_t_14, __pyx_t_13, __pyx_t_12);
          __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_15 = 0; __pyx_t_17 = 0; __pyx_t_37 = 0;
          __pyx_lineno = __pyx_t_31; __pyx_clineno = __pyx_t_32; __pyx_filename = __pyx_t_72;
          goto __pyx_L6_except_error;
        }
      }
    }
    goto __pyx_L6_except_error;

    /* "ws_package/controllers/activity_controller.py":4860
 *     ):
 *         """Internal implementation of last_api_call (caller must hold _session_close_lock)."""
 *         try:             # <<<<<<<<<<<<<<
 *             logger.info(
 *                 "=== last_api_call STARTED (keep_idle_time=%s, close_time=%s, project_override=%s) ===",
*/
    __pyx_L6_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L9_try_end:;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":4850
 *             )
 * 
 *     async def _last_api_call_impl(             # <<<<<<<<<<<<<<
 *         self,
 *         user_entity: UserEntity,
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_23);
  __Pyx_XDECREF(__pyx_t_24);
  __Pyx_XDECREF(__pyx_t_25);
  __Pyx_XDECREF(__pyx_t_26);
  __Pyx_XDECREF(__pyx_t_27);
  __Pyx_XDECREF(__pyx_t_38);
  __Pyx_XDECREF(__pyx_t_39);
  __Pyx_XDECREF(__pyx_t_40);
  __Pyx_XDECREF(__pyx_t_52);
  __Pyx_XDECREF(__pyx_t_55);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("_last_api_call_impl", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_182generator36(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":5643
 *             raise  # Re-raise to let caller know it failed
 * 
 *     async def stop_event(self, user_entity: UserEntity, keep_idle_time: bool = True):             # <<<<<<<<<<<<<<
 *         """Stop all activity monitoring and cleanup resources"""
 *         try:
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_181stop_event(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_180stop_event, "Stop all activity monitoring and cleanup resources");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_181stop_event = {"stop_event", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_181stop_event, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_180stop_event};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_181stop_event(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_user_entity = 0;
  int __pyx_v_keep_idle_time;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("stop_event (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_user_entity,&__pyx_mstate_global->__pyx_n_u_keep_idle_time,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 5643, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 5643, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 5643, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 5643, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "stop_event", 0) < (0)) __PYX_ERR(0, 5643, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("stop_event", 0, 2, 3, i); __PYX_ERR(0, 5643, __pyx_L3_error) }
      }
    } else {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 5643, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 5643, __pyx_L3_error)
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 5643, __pyx_L3_error)
        break;
        default: goto __pyx_L5_argtuple_error;
      }
    }
    __pyx_v_self = values[0];
    __pyx_v_user_entity = values[1];
    if (values[2]) {
      __pyx_v_keep_idle_time = __Pyx_PyObject_IsTrue(values[2]); if (unlikely((__pyx_v_keep_idle_time == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 5643, __pyx_L3_error)
    } else {
      __pyx_v_keep_idle_time = ((int)((int)1));
    }
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("stop_event", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 5643, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.stop_event", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_180stop_event(__pyx_self, __pyx_v_self, __pyx_v_user_entity, __pyx_v_keep_idle_time);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_180stop_event(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_user_entity, int __pyx_v_keep_idle_time) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("stop_event", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 5643, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_user_entity = __pyx_v_user_entity;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_user_entity);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_user_entity);
  __pyx_cur_scope->__pyx_v_keep_idle_time = __pyx_v_keep_idle_time;
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_182generator36, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[62]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_stop_event, __pyx_mstate_global->__pyx_n_u_ActivityController_stop_event, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 5643, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.stop_event", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_182generator36(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  size_t __pyx_t_8;
  int __pyx_t_9;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  __Pyx_PySendResult __pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  Py_ssize_t __pyx_t_26;
  int __pyx_t_27;
  PyObject *__pyx_t_28 = NULL;
  int __pyx_t_29;
  int __pyx_t_30;
  char const *__pyx_t_31;
  char const *__pyx_t_32;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("stop_event", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L22_resume_from_await;
    case 2: goto __pyx_L23_resume_from_await;
    case 3: goto __pyx_L35_resume_from_await;
    case 4: goto __pyx_L45_resume_from_await;
    case 5: goto __pyx_L52_resume_from_await;
    case 6: goto __pyx_L56_resume_from_await;
    case 7: goto __pyx_L57_resume_from_await;
    case 8: goto __pyx_L74_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 5643, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":5645
 *     async def stop_event(self, user_entity: UserEntity, keep_idle_time: bool = True):
 *         """Stop all activity monitoring and cleanup resources"""
 *         try:             # <<<<<<<<<<<<<<
 *             logger.info("=== stop_event() called (keep_idle_time=%s) ===", keep_idle_time)
 * 
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":5646
 *         """Stop all activity monitoring and cleanup resources"""
 *         try:
 *             logger.info("=== stop_event() called (keep_idle_time=%s) ===", keep_idle_time)             # <<<<<<<<<<<<<<
 * 
 *             # On timezone/datetime integrity error: do NOT send last interval to DB/API.
*/
      __pyx_t_5 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5646, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5646, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_cur_scope->__pyx_v_keep_idle_time); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5646, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_5);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_stop_event_called_keep_idle_tim, __pyx_t_6};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5646, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":5650
 *             # On timezone/datetime integrity error: do NOT send last interval to DB/API.
 *             if (
 *                 getattr(self, '_timezone_mismatch', False)             # <<<<<<<<<<<<<<
 *                 and self._timezone_checks_enabled(user_entity)
 *             ):
*/
      __pyx_t_4 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_timezone_mismatch, Py_False); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5650, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 5650, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (__pyx_t_10) {
      } else {
        __pyx_t_9 = __pyx_t_10;
        goto __pyx_L11_bool_binop_done;
      }

      /* "ws_package/controllers/activity_controller.py":5651
 *             if (
 *                 getattr(self, '_timezone_mismatch', False)
 *                 and self._timezone_checks_enabled(user_entity)             # <<<<<<<<<<<<<<
 *             ):
 *                 logger.error(
*/
      __pyx_t_7 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_7);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_cur_scope->__pyx_v_user_entity};
        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_timezone_checks_enabled, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5651, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 5651, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_9 = __pyx_t_10;
      __pyx_L11_bool_binop_done:;

      /* "ws_package/controllers/activity_controller.py":5649
 * 
 *             # On timezone/datetime integrity error: do NOT send last interval to DB/API.
 *             if (             # <<<<<<<<<<<<<<
 *                 getattr(self, '_timezone_mismatch', False)
 *                 and self._timezone_checks_enabled(user_entity)
*/
      if (__pyx_t_9) {

        /* "ws_package/controllers/activity_controller.py":5653
 *                 and self._timezone_checks_enabled(user_entity)
 *             ):
 *                 logger.error(             # <<<<<<<<<<<<<<
 *                     "Timezone mismatch detected - SKIPPING last_api_call (no last interval sent to DB/API)"
 *                 )
*/
        __pyx_t_7 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5653, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5653, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
          assert(__pyx_t_7);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Timezone_mismatch_detected_SKIPP};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5653, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":5656
 *                     "Timezone mismatch detected - SKIPPING last_api_call (no last interval sent to DB/API)"
 *                 )
 *                 return True             # <<<<<<<<<<<<<<
 * 
 *             logger.info("Starting last_api_call (normal stop)")
*/
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_True);
        __pyx_r = Py_True;
        goto __pyx_L8_try_return;

        /* "ws_package/controllers/activity_controller.py":5649
 * 
 *             # On timezone/datetime integrity error: do NOT send last interval to DB/API.
 *             if (             # <<<<<<<<<<<<<<
 *                 getattr(self, '_timezone_mismatch', False)
 *                 and self._timezone_checks_enabled(user_entity)
*/
      }

      /* "ws_package/controllers/activity_controller.py":5658
 *                 return True
 * 
 *             logger.info("Starting last_api_call (normal stop)")             # <<<<<<<<<<<<<<
 * 
 *             # Stop screenshot disabled: no screenshot captured on stop button press
*/
      __pyx_t_5 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5658, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5658, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
        assert(__pyx_t_5);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Starting_last_api_call_normal_st};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5658, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":5665
 *             # CRITICAL: Before stopping, check for and send any remaining break intervals
 *             # This ensures break intervals are uploaded even if break_stop_event wasn't called explicitly
 *             try:             # <<<<<<<<<<<<<<
 *                 logger.info("Checking for remaining break intervals before stop...")
 * 
*/
      {
        __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
        __Pyx_XGOTREF(__pyx_t_11);
        __Pyx_XGOTREF(__pyx_t_12);
        __Pyx_XGOTREF(__pyx_t_13);
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":5666
 *             # This ensures break intervals are uploaded even if break_stop_event wasn't called explicitly
 *             try:
 *                 logger.info("Checking for remaining break intervals before stop...")             # <<<<<<<<<<<<<<
 * 
 *                 # CRITICAL: Skip processing break intervals if break_stop_event was called recently
*/
          __pyx_t_6 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5666, __pyx_L13_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5666, __pyx_L13_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_7))) {
            __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
            assert(__pyx_t_6);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
            __Pyx_INCREF(__pyx_t_6);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Checking_for_remaining_break_int};
            __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5666, __pyx_L13_error)
            __Pyx_GOTREF(__pyx_t_4);
          }
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

          /* "ws_package/controllers/activity_controller.py":5670
 *                 # CRITICAL: Skip processing break intervals if break_stop_event was called recently
 *                 # This prevents duplicate API calls when both BreakStopEventThread and StopEventThread run
 *                 should_skip_break_processing = False             # <<<<<<<<<<<<<<
 *                 if self._last_break_stop_event_time is not None:
 *                     time_since_break_stop = (datetime.datetime.now() - self._last_break_stop_event_time).total_seconds()
*/
          __pyx_cur_scope->__pyx_v_should_skip_break_processing = 0;

          /* "ws_package/controllers/activity_controller.py":5671
 *                 # This prevents duplicate API calls when both BreakStopEventThread and StopEventThread run
 *                 should_skip_break_processing = False
 *                 if self._last_break_stop_event_time is not None:             # <<<<<<<<<<<<<<
 *                     time_since_break_stop = (datetime.datetime.now() - self._last_break_stop_event_time).total_seconds()
 *                     if time_since_break_stop < 5:  # If break_stop_event was called within last 5 seconds
*/
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_break_stop_event_time); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5671, __pyx_L13_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_9 = (__pyx_t_4 != Py_None);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (__pyx_t_9) {

            /* "ws_package/controllers/activity_controller.py":5672
 *                 should_skip_break_processing = False
 *                 if self._last_break_stop_event_time is not None:
 *                     time_since_break_stop = (datetime.datetime.now() - self._last_break_stop_event_time).total_seconds()             # <<<<<<<<<<<<<<
 *                     if time_since_break_stop < 5:  # If break_stop_event was called within last 5 seconds
 *                         logger.info("break_stop_event was called %ss ago - skipping duplicate break interval processing to prevent duplicate API calls", time_since_break_stop)
*/
            __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5672, __pyx_L13_error)
            __Pyx_GOTREF(__pyx_t_14);
            __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5672, __pyx_L13_error)
            __Pyx_GOTREF(__pyx_t_15);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            __pyx_t_5 = __pyx_t_15;
            __Pyx_INCREF(__pyx_t_5);
            __pyx_t_8 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
              __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5672, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_6);
            }
            __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_break_stop_event_time); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5672, __pyx_L13_error)
            __Pyx_GOTREF(__pyx_t_15);
            __pyx_t_5 = PyNumber_Subtract(__pyx_t_6, __pyx_t_15); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5672, __pyx_L13_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            __pyx_t_7 = __pyx_t_5;
            __Pyx_INCREF(__pyx_t_7);
            __pyx_t_8 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
              __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_total_seconds, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5672, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_4);
            }
            __Pyx_GIVEREF(__pyx_t_4);
            __pyx_cur_scope->__pyx_v_time_since_break_stop = __pyx_t_4;
            __pyx_t_4 = 0;

            /* "ws_package/controllers/activity_controller.py":5673
 *                 if self._last_break_stop_event_time is not None:
 *                     time_since_break_stop = (datetime.datetime.now() - self._last_break_stop_event_time).total_seconds()
 *                     if time_since_break_stop < 5:  # If break_stop_event was called within last 5 seconds             # <<<<<<<<<<<<<<
 *                         logger.info("break_stop_event was called %ss ago - skipping duplicate break interval processing to prevent duplicate API calls", time_since_break_stop)
 *                         should_skip_break_processing = True
*/
            __pyx_t_4 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_time_since_break_stop, __pyx_mstate_global->__pyx_int_5, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5673, __pyx_L13_error)
            __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 5673, __pyx_L13_error)
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (__pyx_t_9) {

              /* "ws_package/controllers/activity_controller.py":5674
 *                     time_since_break_stop = (datetime.datetime.now() - self._last_break_stop_event_time).total_seconds()
 *                     if time_since_break_stop < 5:  # If break_stop_event was called within last 5 seconds
 *                         logger.info("break_stop_event was called %ss ago - skipping duplicate break interval processing to prevent duplicate API calls", time_since_break_stop)             # <<<<<<<<<<<<<<
 *                         should_skip_break_processing = True
 * 
*/
              __pyx_t_5 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5674, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_7);
              __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5674, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_15);
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_15))) {
                __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_15);
                assert(__pyx_t_5);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                __Pyx_INCREF(__pyx_t_5);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_break_stop_event_was_called_ss_a, __pyx_cur_scope->__pyx_v_time_since_break_stop};
                __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5674, __pyx_L13_error)
                __Pyx_GOTREF(__pyx_t_4);
              }
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

              /* "ws_package/controllers/activity_controller.py":5675
 *                     if time_since_break_stop < 5:  # If break_stop_event was called within last 5 seconds
 *                         logger.info("break_stop_event was called %ss ago - skipping duplicate break interval processing to prevent duplicate API calls", time_since_break_stop)
 *                         should_skip_break_processing = True             # <<<<<<<<<<<<<<
 * 
 *                 if not should_skip_break_processing:
*/
              __pyx_cur_scope->__pyx_v_should_skip_break_processing = 1;

              /* "ws_package/controllers/activity_controller.py":5673
 *                 if self._last_break_stop_event_time is not None:
 *                     time_since_break_stop = (datetime.datetime.now() - self._last_break_stop_event_time).total_seconds()
 *                     if time_since_break_stop < 5:  # If break_stop_event was called within last 5 seconds             # <<<<<<<<<<<<<<
 *                         logger.info("break_stop_event was called %ss ago - skipping duplicate break interval processing to prevent duplicate API calls", time_since_break_stop)
 *                         should_skip_break_processing = True
*/
            }

            /* "ws_package/controllers/activity_controller.py":5671
 *                 # This prevents duplicate API calls when both BreakStopEventThread and StopEventThread run
 *                 should_skip_break_processing = False
 *                 if self._last_break_stop_event_time is not None:             # <<<<<<<<<<<<<<
 *                     time_since_break_stop = (datetime.datetime.now() - self._last_break_stop_event_time).total_seconds()
 *                     if time_since_break_stop < 5:  # If break_stop_event was called within last 5 seconds
*/
          }

          /* "ws_package/controllers/activity_controller.py":5677
 *                         should_skip_break_processing = True
 * 
 *                 if not should_skip_break_processing:             # <<<<<<<<<<<<<<
 *                     # Check if there are any break intervals with is_uploaded=0
 *                     # Flush queue first to ensure all pending writes are committed
*/
          __pyx_t_9 = (!__pyx_cur_scope->__pyx_v_should_skip_break_processing);
          if (__pyx_t_9) {

            /* "ws_package/controllers/activity_controller.py":5680
 *                     # Check if there are any break intervals with is_uploaded=0
 *                     # Flush queue first to ensure all pending writes are committed
 *                     await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 *                     await asyncio.sleep(0.3)
 * 
*/
            __pyx_t_15 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5680, __pyx_L13_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5680, __pyx_L13_error)
            __Pyx_GOTREF(__pyx_t_7);
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_7))) {
              __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_7);
              assert(__pyx_t_15);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
              __Pyx_INCREF(__pyx_t_15);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL};
              __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5680, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_4);
            }
            __pyx_t_16 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (likely(__pyx_t_16 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_1);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
              __Pyx_XGIVEREF(__pyx_t_2);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
              __Pyx_XGIVEREF(__pyx_t_3);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
              __Pyx_XGIVEREF(__pyx_t_11);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_11;
              __Pyx_XGIVEREF(__pyx_t_12);
              __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
              __Pyx_XGIVEREF(__pyx_t_13);
              __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 1;
              return __pyx_r;
              __pyx_L22_resume_from_await:;
              __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_1);
              __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_2);
              __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_3);
              __pyx_t_11 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_11);
              __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
              __pyx_cur_scope->__pyx_t_4 = 0;
              __Pyx_XGOTREF(__pyx_t_12);
              __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
              __pyx_cur_scope->__pyx_t_5 = 0;
              __Pyx_XGOTREF(__pyx_t_13);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5680, __pyx_L13_error)
            } else if (likely(__pyx_t_16 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_DECREF(__pyx_r); __pyx_r = 0;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 5680, __pyx_L13_error)
            }

            /* "ws_package/controllers/activity_controller.py":5681
 *                     # Flush queue first to ensure all pending writes are committed
 *                     await db_writer_service.process_immediately()
 *                     await asyncio.sleep(0.3)             # <<<<<<<<<<<<<<
 * 
 *                     with db_lock_manager.read_lock():
*/
            __pyx_t_7 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5681, __pyx_L13_error)
            __Pyx_GOTREF(__pyx_t_15);
            __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5681, __pyx_L13_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_5))) {
              __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
              assert(__pyx_t_7);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
              __Pyx_INCREF(__pyx_t_7);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_mstate_global->__pyx_float_0_3};
              __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5681, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_4);
            }
            __pyx_t_16 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (likely(__pyx_t_16 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_1);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
              __Pyx_XGIVEREF(__pyx_t_2);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
              __Pyx_XGIVEREF(__pyx_t_3);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
              __Pyx_XGIVEREF(__pyx_t_11);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_11;
              __Pyx_XGIVEREF(__pyx_t_12);
              __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
              __Pyx_XGIVEREF(__pyx_t_13);
              __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 2;
              return __pyx_r;
              __pyx_L23_resume_from_await:;
              __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_1);
              __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_2);
              __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_3);
              __pyx_t_11 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_11);
              __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
              __pyx_cur_scope->__pyx_t_4 = 0;
              __Pyx_XGOTREF(__pyx_t_12);
              __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
              __pyx_cur_scope->__pyx_t_5 = 0;
              __Pyx_XGOTREF(__pyx_t_13);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5681, __pyx_L13_error)
            } else if (likely(__pyx_t_16 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_DECREF(__pyx_r); __pyx_r = 0;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 5681, __pyx_L13_error)
            }

            /* "ws_package/controllers/activity_controller.py":5683
 *                     await asyncio.sleep(0.3)
 * 
 *                     with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                         async with async_session() as session:
 *                             query = select(ActivityInterval).where(
*/
            /*with:*/ {
              __pyx_t_5 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5683, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_7);
              __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5683, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_15);
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_15))) {
                __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_15);
                assert(__pyx_t_5);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
                __Pyx_INCREF(__pyx_t_5);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5683, __pyx_L13_error)
                __Pyx_GOTREF(__pyx_t_4);
              }
              __pyx_t_17 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 5683, __pyx_L13_error)
              __Pyx_GOTREF(__pyx_t_17);
              __pyx_t_5 = NULL;
              __pyx_t_7 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5683, __pyx_L24_error)
              __Pyx_GOTREF(__pyx_t_7);
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (likely(PyMethod_Check(__pyx_t_7))) {
                __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
                assert(__pyx_t_5);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                __Pyx_INCREF(__pyx_t_5);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                __pyx_t_15 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5683, __pyx_L24_error)
                __Pyx_GOTREF(__pyx_t_15);
              }
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              /*try:*/ {
                {
                  __Pyx_ExceptionSave(&__pyx_t_18, &__pyx_t_19, &__pyx_t_20);
                  __Pyx_XGOTREF(__pyx_t_18);
                  __Pyx_XGOTREF(__pyx_t_19);
                  __Pyx_XGOTREF(__pyx_t_20);
                  /*try:*/ {

                    /* "ws_package/controllers/activity_controller.py":5684
 * 
 *                     with db_lock_manager.read_lock():
 *                         async with async_session() as session:             # <<<<<<<<<<<<<<
 *                             query = select(ActivityInterval).where(
 *                                 ActivityInterval.is_uploaded.is_(False),
*/
                    /*with:*/ {
                      __pyx_t_15 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5684, __pyx_L28_error)
                      __Pyx_GOTREF(__pyx_t_7);
                      __pyx_t_8 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_7))) {
                        __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_7);
                        assert(__pyx_t_15);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                        __Pyx_INCREF(__pyx_t_15);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                        __pyx_t_8 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL};
                        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5684, __pyx_L28_error)
                        __Pyx_GOTREF(__pyx_t_4);
                      }
                      __pyx_t_21 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 5684, __pyx_L28_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __pyx_t_15 = NULL;
                      __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5684, __pyx_L34_error)
                      __Pyx_GOTREF(__pyx_t_5);
                      __pyx_t_8 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (likely(PyMethod_Check(__pyx_t_5))) {
                        __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_5);
                        assert(__pyx_t_15);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                        __Pyx_INCREF(__pyx_t_15);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                        __pyx_t_8 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL};
                        __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5684, __pyx_L34_error)
                        __Pyx_GOTREF(__pyx_t_7);
                      }
                      __pyx_t_16 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                      if (likely(__pyx_t_16 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_4);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_t_19);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_19;
                        __Pyx_XGIVEREF(__pyx_t_20);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_20;
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __pyx_cur_scope->__pyx_t_11 = __pyx_t_21;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 3;
                        return __pyx_r;
                        __pyx_L35_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_4);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        __pyx_t_19 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_19);
                        __pyx_t_20 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_20);
                        __pyx_t_21 = __pyx_cur_scope->__pyx_t_11;
                        __pyx_cur_scope->__pyx_t_11 = 0;
                        __Pyx_XGOTREF(__pyx_t_21);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5684, __pyx_L34_error)
                        __pyx_t_7 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_7);
                      } else if (likely(__pyx_t_16 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_7 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 5684, __pyx_L34_error)
                      }
                      __pyx_t_5 = __pyx_t_7;
                      __pyx_t_7 = 0;
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      /*try:*/ {
                        {
                          __Pyx_ExceptionSave(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
                          __Pyx_XGOTREF(__pyx_t_22);
                          __Pyx_XGOTREF(__pyx_t_23);
                          __Pyx_XGOTREF(__pyx_t_24);
                          /*try:*/ {
                            __Pyx_GIVEREF(__pyx_t_5);
                            __pyx_cur_scope->__pyx_v_session = __pyx_t_5;
                            __pyx_t_5 = 0;

                            /* "ws_package/controllers/activity_controller.py":5685
 *                     with db_lock_manager.read_lock():
 *                         async with async_session() as session:
 *                             query = select(ActivityInterval).where(             # <<<<<<<<<<<<<<
 *                                 ActivityInterval.is_uploaded.is_(False),
 *                                 ActivityInterval.is_break != 0
*/
                            __pyx_t_15 = NULL;
                            __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5685, __pyx_L39_error)
                            __Pyx_GOTREF(__pyx_t_6);
                            __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5685, __pyx_L39_error)
                            __Pyx_GOTREF(__pyx_t_14);
                            __pyx_t_8 = 1;
                            #if CYTHON_UNPACK_METHODS
                            if (unlikely(PyMethod_Check(__pyx_t_6))) {
                              __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_6);
                              assert(__pyx_t_15);
                              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                              __Pyx_INCREF(__pyx_t_15);
                              __Pyx_INCREF(__pyx__function);
                              __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                              __pyx_t_8 = 0;
                            }
                            #endif
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_t_14};
                              __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                              if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5685, __pyx_L39_error)
                              __Pyx_GOTREF(__pyx_t_7);
                            }
                            __pyx_t_4 = __pyx_t_7;
                            __Pyx_INCREF(__pyx_t_4);

                            /* "ws_package/controllers/activity_controller.py":5686
 *                         async with async_session() as session:
 *                             query = select(ActivityInterval).where(
 *                                 ActivityInterval.is_uploaded.is_(False),             # <<<<<<<<<<<<<<
 *                                 ActivityInterval.is_break != 0
 *                             )
*/
                            __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5686, __pyx_L39_error)
                            __Pyx_GOTREF(__pyx_t_15);
                            __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_is_uploaded); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5686, __pyx_L39_error)
                            __Pyx_GOTREF(__pyx_t_25);
                            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                            __pyx_t_14 = __pyx_t_25;
                            __Pyx_INCREF(__pyx_t_14);
                            __pyx_t_8 = 0;
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_14, Py_False};
                              __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                              __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                              if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5686, __pyx_L39_error)
                              __Pyx_GOTREF(__pyx_t_6);
                            }

                            /* "ws_package/controllers/activity_controller.py":5687
 *                             query = select(ActivityInterval).where(
 *                                 ActivityInterval.is_uploaded.is_(False),
 *                                 ActivityInterval.is_break != 0             # <<<<<<<<<<<<<<
 *                             )
 *                             result = await session.execute(query)
*/
                            __Pyx_GetModuleGlobalName(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5687, __pyx_L39_error)
                            __Pyx_GOTREF(__pyx_t_25);
                            __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_is_break); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5687, __pyx_L39_error)
                            __Pyx_GOTREF(__pyx_t_14);
                            __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                            __pyx_t_25 = __Pyx_PyLong_NeObjC(__pyx_t_14, __pyx_mstate_global->__pyx_int_0, 0, 0); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5687, __pyx_L39_error)
                            __Pyx_GOTREF(__pyx_t_25);
                            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                            __pyx_t_8 = 0;
                            {
                              PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_t_6, __pyx_t_25};
                              __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                              __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                              if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5685, __pyx_L39_error)
                              __Pyx_GOTREF(__pyx_t_5);
                            }
                            __Pyx_GIVEREF(__pyx_t_5);
                            __pyx_cur_scope->__pyx_v_query = __pyx_t_5;
                            __pyx_t_5 = 0;

                            /* "ws_package/controllers/activity_controller.py":5689
 *                                 ActivityInterval.is_break != 0
 *                             )
 *                             result = await session.execute(query)             # <<<<<<<<<<<<<<
 *                             remaining_break_intervals = result.scalars().all()
 * 
*/
                            __pyx_t_7 = __pyx_cur_scope->__pyx_v_session;
                            __Pyx_INCREF(__pyx_t_7);
                            __pyx_t_8 = 0;
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_cur_scope->__pyx_v_query};
                              __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                              if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5689, __pyx_L39_error)
                              __Pyx_GOTREF(__pyx_t_5);
                            }
                            __pyx_t_16 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
                            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                            if (likely(__pyx_t_16 == PYGEN_NEXT)) {
                              __Pyx_GOTREF(__pyx_r);
                              __Pyx_XGIVEREF(__pyx_t_1);
                              __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                              __Pyx_XGIVEREF(__pyx_t_2);
                              __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                              __Pyx_XGIVEREF(__pyx_t_3);
                              __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                              __Pyx_XGIVEREF(__pyx_t_11);
                              __pyx_cur_scope->__pyx_t_3 = __pyx_t_11;
                              __Pyx_XGIVEREF(__pyx_t_12);
                              __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                              __Pyx_XGIVEREF(__pyx_t_13);
                              __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                              __Pyx_XGIVEREF(__pyx_t_17);
                              __pyx_cur_scope->__pyx_t_6 = __pyx_t_17;
                              __Pyx_XGIVEREF(__pyx_t_18);
                              __pyx_cur_scope->__pyx_t_7 = __pyx_t_18;
                              __Pyx_XGIVEREF(__pyx_t_19);
                              __pyx_cur_scope->__pyx_t_8 = __pyx_t_19;
                              __Pyx_XGIVEREF(__pyx_t_20);
                              __pyx_cur_scope->__pyx_t_9 = __pyx_t_20;
                              __Pyx_XGIVEREF(__pyx_t_21);
                              __pyx_cur_scope->__pyx_t_10 = __pyx_t_21;
                              __Pyx_XGIVEREF(__pyx_t_22);
                              __pyx_cur_scope->__pyx_t_11 = __pyx_t_22;
                              __Pyx_XGIVEREF(__pyx_t_23);
                              __pyx_cur_scope->__pyx_t_12 = __pyx_t_23;
                              __Pyx_XGIVEREF(__pyx_t_24);
                              __pyx_cur_scope->__pyx_t_13 = __pyx_t_24;
                              __Pyx_XGIVEREF(__pyx_r);
                              __Pyx_RefNannyFinishContext();
                              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                              /* return from generator, awaiting value */
                              __pyx_generator->resume_label = 4;
                              return __pyx_r;
                              __pyx_L45_resume_from_await:;
                              __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                              __pyx_cur_scope->__pyx_t_0 = 0;
                              __Pyx_XGOTREF(__pyx_t_1);
                              __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                              __pyx_cur_scope->__pyx_t_1 = 0;
                              __Pyx_XGOTREF(__pyx_t_2);
                              __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                              __pyx_cur_scope->__pyx_t_2 = 0;
                              __Pyx_XGOTREF(__pyx_t_3);
                              __pyx_t_11 = __pyx_cur_scope->__pyx_t_3;
                              __pyx_cur_scope->__pyx_t_3 = 0;
                              __Pyx_XGOTREF(__pyx_t_11);
                              __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                              __pyx_cur_scope->__pyx_t_4 = 0;
                              __Pyx_XGOTREF(__pyx_t_12);
                              __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                              __pyx_cur_scope->__pyx_t_5 = 0;
                              __Pyx_XGOTREF(__pyx_t_13);
                              __pyx_t_17 = __pyx_cur_scope->__pyx_t_6;
                              __pyx_cur_scope->__pyx_t_6 = 0;
                              __Pyx_XGOTREF(__pyx_t_17);
                              __pyx_t_18 = __pyx_cur_scope->__pyx_t_7;
                              __pyx_cur_scope->__pyx_t_7 = 0;
                              __Pyx_XGOTREF(__pyx_t_18);
                              __pyx_t_19 = __pyx_cur_scope->__pyx_t_8;
                              __pyx_cur_scope->__pyx_t_8 = 0;
                              __Pyx_XGOTREF(__pyx_t_19);
                              __pyx_t_20 = __pyx_cur_scope->__pyx_t_9;
                              __pyx_cur_scope->__pyx_t_9 = 0;
                              __Pyx_XGOTREF(__pyx_t_20);
                              __pyx_t_21 = __pyx_cur_scope->__pyx_t_10;
                              __pyx_cur_scope->__pyx_t_10 = 0;
                              __Pyx_XGOTREF(__pyx_t_21);
                              __pyx_t_22 = __pyx_cur_scope->__pyx_t_11;
                              __pyx_cur_scope->__pyx_t_11 = 0;
                              __Pyx_XGOTREF(__pyx_t_22);
                              __pyx_t_23 = __pyx_cur_scope->__pyx_t_12;
                              __pyx_cur_scope->__pyx_t_12 = 0;
                              __Pyx_XGOTREF(__pyx_t_23);
                              __pyx_t_24 = __pyx_cur_scope->__pyx_t_13;
                              __pyx_cur_scope->__pyx_t_13 = 0;
                              __Pyx_XGOTREF(__pyx_t_24);
                              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5689, __pyx_L39_error)
                              __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
                            } else if (likely(__pyx_t_16 == PYGEN_RETURN)) {
                              __Pyx_GOTREF(__pyx_r);
                              __pyx_t_5 = __pyx_r; __pyx_r = NULL;
                            } else {
                              __Pyx_XGOTREF(__pyx_r);
                              __PYX_ERR(0, 5689, __pyx_L39_error)
                            }
                            __Pyx_GIVEREF(__pyx_t_5);
                            __pyx_cur_scope->__pyx_v_result = __pyx_t_5;
                            __pyx_t_5 = 0;

                            /* "ws_package/controllers/activity_controller.py":5690
 *                             )
 *                             result = await session.execute(query)
 *                             remaining_break_intervals = result.scalars().all()             # <<<<<<<<<<<<<<
 * 
 *                             if remaining_break_intervals and len(remaining_break_intervals) > 0:
*/
                            __pyx_t_6 = __pyx_cur_scope->__pyx_v_result;
                            __Pyx_INCREF(__pyx_t_6);
                            __pyx_t_8 = 0;
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
                              __pyx_t_25 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalars, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                              if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5690, __pyx_L39_error)
                              __Pyx_GOTREF(__pyx_t_25);
                            }
                            __pyx_t_7 = __pyx_t_25;
                            __Pyx_INCREF(__pyx_t_7);
                            __pyx_t_8 = 0;
                            {
                              PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
                              __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_all, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                              __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                              if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5690, __pyx_L39_error)
                              __Pyx_GOTREF(__pyx_t_5);
                            }
                            __Pyx_GIVEREF(__pyx_t_5);
                            __pyx_cur_scope->__pyx_v_remaining_break_intervals = __pyx_t_5;
                            __pyx_t_5 = 0;

                            /* "ws_package/controllers/activity_controller.py":5692
 *                             remaining_break_intervals = result.scalars().all()
 * 
 *                             if remaining_break_intervals and len(remaining_break_intervals) > 0:             # <<<<<<<<<<<<<<
 *                                 logger.info("Found %s remaining break interval(s) with is_uploaded=0 - calling break_stop_event to send them", len(remaining_break_intervals))
 *                                 # Set user_entity if not already set
*/
                            __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_remaining_break_intervals); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 5692, __pyx_L39_error)
                            if (__pyx_t_10) {
                            } else {
                              __pyx_t_9 = __pyx_t_10;
                              goto __pyx_L47_bool_binop_done;
                            }
                            __pyx_t_26 = PyObject_Length(__pyx_cur_scope->__pyx_v_remaining_break_intervals); if (unlikely(__pyx_t_26 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5692, __pyx_L39_error)
                            __pyx_t_10 = (__pyx_t_26 > 0);
                            __pyx_t_9 = __pyx_t_10;
                            __pyx_L47_bool_binop_done:;
                            if (__pyx_t_9) {

                              /* "ws_package/controllers/activity_controller.py":5693
 * 
 *                             if remaining_break_intervals and len(remaining_break_intervals) > 0:
 *                                 logger.info("Found %s remaining break interval(s) with is_uploaded=0 - calling break_stop_event to send them", len(remaining_break_intervals))             # <<<<<<<<<<<<<<
 *                                 # Set user_entity if not already set
 *                                 if not hasattr(self, 'user_entity') or self.user_entity is None:
*/
                              __pyx_t_25 = NULL;
                              __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5693, __pyx_L39_error)
                              __Pyx_GOTREF(__pyx_t_7);
                              __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5693, __pyx_L39_error)
                              __Pyx_GOTREF(__pyx_t_6);
                              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                              __pyx_t_26 = PyObject_Length(__pyx_cur_scope->__pyx_v_remaining_break_intervals); if (unlikely(__pyx_t_26 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5693, __pyx_L39_error)
                              __pyx_t_7 = PyLong_FromSsize_t(__pyx_t_26); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5693, __pyx_L39_error)
                              __Pyx_GOTREF(__pyx_t_7);
                              __pyx_t_8 = 1;
                              #if CYTHON_UNPACK_METHODS
                              if (unlikely(PyMethod_Check(__pyx_t_6))) {
                                __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_6);
                                assert(__pyx_t_25);
                                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                                __Pyx_INCREF(__pyx_t_25);
                                __Pyx_INCREF(__pyx__function);
                                __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                                __pyx_t_8 = 0;
                              }
                              #endif
                              {
                                PyObject *__pyx_callargs[3] = {__pyx_t_25, __pyx_mstate_global->__pyx_kp_u_Found_s_remaining_break_interval, __pyx_t_7};
                                __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                                if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5693, __pyx_L39_error)
                                __Pyx_GOTREF(__pyx_t_5);
                              }
                              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                              /* "ws_package/controllers/activity_controller.py":5695
 *                                 logger.info("Found %s remaining break interval(s) with is_uploaded=0 - calling break_stop_event to send them", len(remaining_break_intervals))
 *                                 # Set user_entity if not already set
 *                                 if not hasattr(self, 'user_entity') or self.user_entity is None:             # <<<<<<<<<<<<<<
 *                                     self.user_entity = user_entity
 *                                 # Call break_stop_event to send remaining break intervals
*/
                              __pyx_t_10 = __Pyx_HasAttr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_user_entity); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 5695, __pyx_L39_error)
                              __pyx_t_27 = (!__pyx_t_10);
                              if (!__pyx_t_27) {
                              } else {
                                __pyx_t_9 = __pyx_t_27;
                                goto __pyx_L50_bool_binop_done;
                              }
                              __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_user_entity); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5695, __pyx_L39_error)
                              __Pyx_GOTREF(__pyx_t_5);
                              __pyx_t_27 = (__pyx_t_5 == Py_None);
                              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                              __pyx_t_9 = __pyx_t_27;
                              __pyx_L50_bool_binop_done:;
                              if (__pyx_t_9) {

                                /* "ws_package/controllers/activity_controller.py":5696
 *                                 # Set user_entity if not already set
 *                                 if not hasattr(self, 'user_entity') or self.user_entity is None:
 *                                     self.user_entity = user_entity             # <<<<<<<<<<<<<<
 *                                 # Call break_stop_event to send remaining break intervals
 *                                 await self.break_stop_event()
*/
                                if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_cur_scope->__pyx_v_user_entity) < (0)) __PYX_ERR(0, 5696, __pyx_L39_error)

                                /* "ws_package/controllers/activity_controller.py":5695
 *                                 logger.info("Found %s remaining break interval(s) with is_uploaded=0 - calling break_stop_event to send them", len(remaining_break_intervals))
 *                                 # Set user_entity if not already set
 *                                 if not hasattr(self, 'user_entity') or self.user_entity is None:             # <<<<<<<<<<<<<<
 *                                     self.user_entity = user_entity
 *                                 # Call break_stop_event to send remaining break intervals
*/
                              }

                              /* "ws_package/controllers/activity_controller.py":5698
 *                                     self.user_entity = user_entity
 *                                 # Call break_stop_event to send remaining break intervals
 *                                 await self.break_stop_event()             # <<<<<<<<<<<<<<
 *                                 logger.info(" Remaining break intervals sent via break_stop_event")
 *                             else:
*/
                              __pyx_t_6 = __pyx_cur_scope->__pyx_v_self;
                              __Pyx_INCREF(__pyx_t_6);
                              __pyx_t_8 = 0;
                              {
                                PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
                                __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_break_stop_event, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                                if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5698, __pyx_L39_error)
                                __Pyx_GOTREF(__pyx_t_5);
                              }
                              __pyx_t_16 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
                              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                              if (likely(__pyx_t_16 == PYGEN_NEXT)) {
                                __Pyx_GOTREF(__pyx_r);
                                __Pyx_XGIVEREF(__pyx_t_1);
                                __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                __Pyx_XGIVEREF(__pyx_t_2);
                                __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                __Pyx_XGIVEREF(__pyx_t_3);
                                __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                __Pyx_XGIVEREF(__pyx_t_11);
                                __pyx_cur_scope->__pyx_t_3 = __pyx_t_11;
                                __Pyx_XGIVEREF(__pyx_t_12);
                                __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                                __Pyx_XGIVEREF(__pyx_t_13);
                                __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                                __Pyx_XGIVEREF(__pyx_t_17);
                                __pyx_cur_scope->__pyx_t_6 = __pyx_t_17;
                                __Pyx_XGIVEREF(__pyx_t_18);
                                __pyx_cur_scope->__pyx_t_7 = __pyx_t_18;
                                __Pyx_XGIVEREF(__pyx_t_19);
                                __pyx_cur_scope->__pyx_t_8 = __pyx_t_19;
                                __Pyx_XGIVEREF(__pyx_t_20);
                                __pyx_cur_scope->__pyx_t_9 = __pyx_t_20;
                                __Pyx_XGIVEREF(__pyx_t_21);
                                __pyx_cur_scope->__pyx_t_10 = __pyx_t_21;
                                __Pyx_XGIVEREF(__pyx_t_22);
                                __pyx_cur_scope->__pyx_t_11 = __pyx_t_22;
                                __Pyx_XGIVEREF(__pyx_t_23);
                                __pyx_cur_scope->__pyx_t_12 = __pyx_t_23;
                                __Pyx_XGIVEREF(__pyx_t_24);
                                __pyx_cur_scope->__pyx_t_13 = __pyx_t_24;
                                __Pyx_XGIVEREF(__pyx_r);
                                __Pyx_RefNannyFinishContext();
                                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                                /* return from generator, awaiting value */
                                __pyx_generator->resume_label = 5;
                                return __pyx_r;
                                __pyx_L52_resume_from_await:;
                                __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                __pyx_cur_scope->__pyx_t_0 = 0;
                                __Pyx_XGOTREF(__pyx_t_1);
                                __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                __pyx_cur_scope->__pyx_t_1 = 0;
                                __Pyx_XGOTREF(__pyx_t_2);
                                __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                __pyx_cur_scope->__pyx_t_2 = 0;
                                __Pyx_XGOTREF(__pyx_t_3);
                                __pyx_t_11 = __pyx_cur_scope->__pyx_t_3;
                                __pyx_cur_scope->__pyx_t_3 = 0;
                                __Pyx_XGOTREF(__pyx_t_11);
                                __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                                __pyx_cur_scope->__pyx_t_4 = 0;
                                __Pyx_XGOTREF(__pyx_t_12);
                                __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                                __pyx_cur_scope->__pyx_t_5 = 0;
                                __Pyx_XGOTREF(__pyx_t_13);
                                __pyx_t_17 = __pyx_cur_scope->__pyx_t_6;
                                __pyx_cur_scope->__pyx_t_6 = 0;
                                __Pyx_XGOTREF(__pyx_t_17);
                                __pyx_t_18 = __pyx_cur_scope->__pyx_t_7;
                                __pyx_cur_scope->__pyx_t_7 = 0;
                                __Pyx_XGOTREF(__pyx_t_18);
                                __pyx_t_19 = __pyx_cur_scope->__pyx_t_8;
                                __pyx_cur_scope->__pyx_t_8 = 0;
                                __Pyx_XGOTREF(__pyx_t_19);
                                __pyx_t_20 = __pyx_cur_scope->__pyx_t_9;
                                __pyx_cur_scope->__pyx_t_9 = 0;
                                __Pyx_XGOTREF(__pyx_t_20);
                                __pyx_t_21 = __pyx_cur_scope->__pyx_t_10;
                                __pyx_cur_scope->__pyx_t_10 = 0;
                                __Pyx_XGOTREF(__pyx_t_21);
                                __pyx_t_22 = __pyx_cur_scope->__pyx_t_11;
                                __pyx_cur_scope->__pyx_t_11 = 0;
                                __Pyx_XGOTREF(__pyx_t_22);
                                __pyx_t_23 = __pyx_cur_scope->__pyx_t_12;
                                __pyx_cur_scope->__pyx_t_12 = 0;
                                __Pyx_XGOTREF(__pyx_t_23);
                                __pyx_t_24 = __pyx_cur_scope->__pyx_t_13;
                                __pyx_cur_scope->__pyx_t_13 = 0;
                                __Pyx_XGOTREF(__pyx_t_24);
                                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5698, __pyx_L39_error)
                              } else if (likely(__pyx_t_16 == PYGEN_RETURN)) {
                                __Pyx_GOTREF(__pyx_r);
                                __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                              } else {
                                __Pyx_XGOTREF(__pyx_r);
                                __PYX_ERR(0, 5698, __pyx_L39_error)
                              }

                              /* "ws_package/controllers/activity_controller.py":5699
 *                                 # Call break_stop_event to send remaining break intervals
 *                                 await self.break_stop_event()
 *                                 logger.info(" Remaining break intervals sent via break_stop_event")             # <<<<<<<<<<<<<<
 *                             else:
 *                                 logger.info("No remaining break intervals found - nothing to send")
*/
                              __pyx_t_6 = NULL;
                              __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5699, __pyx_L39_error)
                              __Pyx_GOTREF(__pyx_t_7);
                              __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5699, __pyx_L39_error)
                              __Pyx_GOTREF(__pyx_t_25);
                              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                              __pyx_t_8 = 1;
                              #if CYTHON_UNPACK_METHODS
                              if (unlikely(PyMethod_Check(__pyx_t_25))) {
                                __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_25);
                                assert(__pyx_t_6);
                                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_25);
                                __Pyx_INCREF(__pyx_t_6);
                                __Pyx_INCREF(__pyx__function);
                                __Pyx_DECREF_SET(__pyx_t_25, __pyx__function);
                                __pyx_t_8 = 0;
                              }
                              #endif
                              {
                                PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Remaining_break_intervals_sent};
                                __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_25, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                                __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                                if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5699, __pyx_L39_error)
                                __Pyx_GOTREF(__pyx_t_5);
                              }
                              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                              /* "ws_package/controllers/activity_controller.py":5692
 *                             remaining_break_intervals = result.scalars().all()
 * 
 *                             if remaining_break_intervals and len(remaining_break_intervals) > 0:             # <<<<<<<<<<<<<<
 *                                 logger.info("Found %s remaining break interval(s) with is_uploaded=0 - calling break_stop_event to send them", len(remaining_break_intervals))
 *                                 # Set user_entity if not already set
*/
                              goto __pyx_L46;
                            }

                            /* "ws_package/controllers/activity_controller.py":5701
 *                                 logger.info(" Remaining break intervals sent via break_stop_event")
 *                             else:
 *                                 logger.info("No remaining break intervals found - nothing to send")             # <<<<<<<<<<<<<<
 *             except Exception as break_error:
 *                 logger.error("Error checking/sending remaining break intervals: %s", break_error, exc_info=True)
*/
                            /*else*/ {
                              __pyx_t_25 = NULL;
                              __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5701, __pyx_L39_error)
                              __Pyx_GOTREF(__pyx_t_6);
                              __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5701, __pyx_L39_error)
                              __Pyx_GOTREF(__pyx_t_7);
                              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                              __pyx_t_8 = 1;
                              #if CYTHON_UNPACK_METHODS
                              if (unlikely(PyMethod_Check(__pyx_t_7))) {
                                __pyx_t_25 = PyMethod_GET_SELF(__pyx_t_7);
                                assert(__pyx_t_25);
                                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                                __Pyx_INCREF(__pyx_t_25);
                                __Pyx_INCREF(__pyx__function);
                                __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                                __pyx_t_8 = 0;
                              }
                              #endif
                              {
                                PyObject *__pyx_callargs[2] = {__pyx_t_25, __pyx_mstate_global->__pyx_kp_u_No_remaining_break_intervals_fou};
                                __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                                if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5701, __pyx_L39_error)
                                __Pyx_GOTREF(__pyx_t_5);
                              }
                              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                            }
                            __pyx_L46:;

                            /* "ws_package/controllers/activity_controller.py":5684
 * 
 *                     with db_lock_manager.read_lock():
 *                         async with async_session() as session:             # <<<<<<<<<<<<<<
 *                             query = select(ActivityInterval).where(
 *                                 ActivityInterval.is_uploaded.is_(False),
*/
                          }
                          __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                          __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                          goto __pyx_L44_try_end;
                          __pyx_L39_error:;
                          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                          __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                          /*except:*/ {
                            __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.stop_event", __pyx_clineno, __pyx_lineno, __pyx_filename);
                            if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_7, &__pyx_t_25) < 0) __PYX_ERR(0, 5684, __pyx_L41_except_error)
                            __Pyx_XGOTREF(__pyx_t_5);
                            __Pyx_XGOTREF(__pyx_t_7);
                            __Pyx_XGOTREF(__pyx_t_25);
                            __pyx_t_6 = PyTuple_Pack(3, __pyx_t_5, __pyx_t_7, __pyx_t_25); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5684, __pyx_L41_except_error)
                            __Pyx_GOTREF(__pyx_t_6);
                            __pyx_t_28 = __Pyx_PyObject_Call(__pyx_t_21, __pyx_t_6, NULL);
                            __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                            if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 5684, __pyx_L41_except_error)
                            __Pyx_GOTREF(__pyx_t_28);
                            __pyx_t_16 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_28, &__pyx_r);
                            __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
                            if (likely(__pyx_t_16 == PYGEN_NEXT)) {
                              __Pyx_GOTREF(__pyx_r);
                              __Pyx_XGIVEREF(__pyx_t_1);
                              __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                              __Pyx_XGIVEREF(__pyx_t_2);
                              __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                              __Pyx_XGIVEREF(__pyx_t_3);
                              __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                              __Pyx_XGIVEREF(__pyx_t_5);
                              __pyx_cur_scope->__pyx_t_3 = __pyx_t_5;
                              __Pyx_XGIVEREF(__pyx_t_7);
                              __pyx_cur_scope->__pyx_t_4 = __pyx_t_7;
                              __Pyx_XGIVEREF(__pyx_t_11);
                              __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
                              __Pyx_XGIVEREF(__pyx_t_12);
                              __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
                              __Pyx_XGIVEREF(__pyx_t_13);
                              __pyx_cur_scope->__pyx_t_7 = __pyx_t_13;
                              __Pyx_XGIVEREF(__pyx_t_17);
                              __pyx_cur_scope->__pyx_t_8 = __pyx_t_17;
                              __Pyx_XGIVEREF(__pyx_t_18);
                              __pyx_cur_scope->__pyx_t_9 = __pyx_t_18;
                              __Pyx_XGIVEREF(__pyx_t_19);
                              __pyx_cur_scope->__pyx_t_10 = __pyx_t_19;
                              __Pyx_XGIVEREF(__pyx_t_20);
                              __pyx_cur_scope->__pyx_t_11 = __pyx_t_20;
                              __Pyx_XGIVEREF(__pyx_t_21);
                              __pyx_cur_scope->__pyx_t_12 = __pyx_t_21;
                              __Pyx_XGIVEREF(__pyx_t_22);
                              __pyx_cur_scope->__pyx_t_13 = __pyx_t_22;
                              __Pyx_XGIVEREF(__pyx_t_23);
                              __pyx_cur_scope->__pyx_t_14 = __pyx_t_23;
                              __Pyx_XGIVEREF(__pyx_t_24);
                              __pyx_cur_scope->__pyx_t_15 = __pyx_t_24;
                              __Pyx_XGIVEREF(__pyx_t_25);
                              __pyx_cur_scope->__pyx_t_16 = __pyx_t_25;
                              __Pyx_XGIVEREF(__pyx_t_28);
                              __pyx_cur_scope->__pyx_t_17 = __pyx_t_28;
                              __Pyx_XGIVEREF(__pyx_r);
                              __Pyx_RefNannyFinishContext();
                              __Pyx_Coroutine_SwapException(__pyx_generator);
                              /* return from generator, awaiting value */
                              __pyx_generator->resume_label = 6;
                              return __pyx_r;
                              __pyx_L56_resume_from_await:;
                              __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                              __pyx_cur_scope->__pyx_t_0 = 0;
                              __Pyx_XGOTREF(__pyx_t_1);
                              __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                              __pyx_cur_scope->__pyx_t_1 = 0;
                              __Pyx_XGOTREF(__pyx_t_2);
                              __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                              __pyx_cur_scope->__pyx_t_2 = 0;
                              __Pyx_XGOTREF(__pyx_t_3);
                              __pyx_t_5 = __pyx_cur_scope->__pyx_t_3;
                              __pyx_cur_scope->__pyx_t_3 = 0;
                              __Pyx_XGOTREF(__pyx_t_5);
                              __pyx_t_7 = __pyx_cur_scope->__pyx_t_4;
                              __pyx_cur_scope->__pyx_t_4 = 0;
                              __Pyx_XGOTREF(__pyx_t_7);
                              __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
                              __pyx_cur_scope->__pyx_t_5 = 0;
                              __Pyx_XGOTREF(__pyx_t_11);
                              __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
                              __pyx_cur_scope->__pyx_t_6 = 0;
                              __Pyx_XGOTREF(__pyx_t_12);
                              __pyx_t_13 = __pyx_cur_scope->__pyx_t_7;
                              __pyx_cur_scope->__pyx_t_7 = 0;
                              __Pyx_XGOTREF(__pyx_t_13);
                              __pyx_t_17 = __pyx_cur_scope->__pyx_t_8;
                              __pyx_cur_scope->__pyx_t_8 = 0;
                              __Pyx_XGOTREF(__pyx_t_17);
                              __pyx_t_18 = __pyx_cur_scope->__pyx_t_9;
                              __pyx_cur_scope->__pyx_t_9 = 0;
                              __Pyx_XGOTREF(__pyx_t_18);
                              __pyx_t_19 = __pyx_cur_scope->__pyx_t_10;
                              __pyx_cur_scope->__pyx_t_10 = 0;
                              __Pyx_XGOTREF(__pyx_t_19);
                              __pyx_t_20 = __pyx_cur_scope->__pyx_t_11;
                              __pyx_cur_scope->__pyx_t_11 = 0;
                              __Pyx_XGOTREF(__pyx_t_20);
                              __pyx_t_21 = __pyx_cur_scope->__pyx_t_12;
                              __pyx_cur_scope->__pyx_t_12 = 0;
                              __Pyx_XGOTREF(__pyx_t_21);
                              __pyx_t_22 = __pyx_cur_scope->__pyx_t_13;
                              __pyx_cur_scope->__pyx_t_13 = 0;
                              __Pyx_XGOTREF(__pyx_t_22);
                              __pyx_t_23 = __pyx_cur_scope->__pyx_t_14;
                              __pyx_cur_scope->__pyx_t_14 = 0;
                              __Pyx_XGOTREF(__pyx_t_23);
                              __pyx_t_24 = __pyx_cur_scope->__pyx_t_15;
                              __pyx_cur_scope->__pyx_t_15 = 0;
                              __Pyx_XGOTREF(__pyx_t_24);
                              __pyx_t_25 = __pyx_cur_scope->__pyx_t_16;
                              __pyx_cur_scope->__pyx_t_16 = 0;
                              __Pyx_XGOTREF(__pyx_t_25);
                              __pyx_t_28 = __pyx_cur_scope->__pyx_t_17;
                              __pyx_cur_scope->__pyx_t_17 = 0;
                              __Pyx_XGOTREF(__pyx_t_28);
                              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5684, __pyx_L41_except_error)
                              __pyx_t_6 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_6);
                            } else if (likely(__pyx_t_16 == PYGEN_RETURN)) {
                              __Pyx_GOTREF(__pyx_r);
                              __pyx_t_6 = __pyx_r; __pyx_r = NULL;
                            } else {
                              __Pyx_XGOTREF(__pyx_r);
                              __PYX_ERR(0, 5684, __pyx_L41_except_error)
                            }
                            __pyx_t_28 = __pyx_t_6;
                            __pyx_t_6 = 0;
                            __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_28);
                            __Pyx_DECREF(__pyx_t_28); __pyx_t_28 = 0;
                            if (__pyx_t_9 < (0)) __PYX_ERR(0, 5684, __pyx_L41_except_error)
                            __pyx_t_27 = (!__pyx_t_9);
                            if (unlikely(__pyx_t_27)) {
                              __Pyx_GIVEREF(__pyx_t_5);
                              __Pyx_GIVEREF(__pyx_t_7);
                              __Pyx_XGIVEREF(__pyx_t_25);
                              __Pyx_ErrRestoreWithState(__pyx_t_5, __pyx_t_7, __pyx_t_25);
                              __pyx_t_5 = 0;  __pyx_t_7 = 0;  __pyx_t_25 = 0; 
                              __PYX_ERR(0, 5684, __pyx_L41_except_error)
                            }
                            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                            __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                            goto __pyx_L40_exception_handled;
                          }
                          __pyx_L41_except_error:;
                          __Pyx_XGIVEREF(__pyx_t_22);
                          __Pyx_XGIVEREF(__pyx_t_23);
                          __Pyx_XGIVEREF(__pyx_t_24);
                          __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_23, __pyx_t_24);
                          goto __pyx_L28_error;
                          __pyx_L40_exception_handled:;
                          __Pyx_XGIVEREF(__pyx_t_22);
                          __Pyx_XGIVEREF(__pyx_t_23);
                          __Pyx_XGIVEREF(__pyx_t_24);
                          __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_23, __pyx_t_24);
                          __pyx_L44_try_end:;
                        }
                      }
                      /*finally:*/ {
                        /*normal exit:*/{
                          if (__pyx_t_21) {
                            __pyx_t_24 = __Pyx_PyObject_Call(__pyx_t_21, __pyx_mstate_global->__pyx_tuple[7], NULL);
                            __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                            if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5684, __pyx_L28_error)
                            __Pyx_GOTREF(__pyx_t_24);
                            __pyx_t_16 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_24, &__pyx_r);
                            __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                            if (likely(__pyx_t_16 == PYGEN_NEXT)) {
                              __Pyx_GOTREF(__pyx_r);
                              __Pyx_XGIVEREF(__pyx_t_1);
                              __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                              __Pyx_XGIVEREF(__pyx_t_2);
                              __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                              __Pyx_XGIVEREF(__pyx_t_3);
                              __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                              __Pyx_XGIVEREF(__pyx_t_11);
                              __pyx_cur_scope->__pyx_t_3 = __pyx_t_11;
                              __Pyx_XGIVEREF(__pyx_t_12);
                              __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                              __Pyx_XGIVEREF(__pyx_t_13);
                              __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                              __Pyx_XGIVEREF(__pyx_t_17);
                              __pyx_cur_scope->__pyx_t_6 = __pyx_t_17;
                              __Pyx_XGIVEREF(__pyx_t_18);
                              __pyx_cur_scope->__pyx_t_7 = __pyx_t_18;
                              __Pyx_XGIVEREF(__pyx_t_19);
                              __pyx_cur_scope->__pyx_t_8 = __pyx_t_19;
                              __Pyx_XGIVEREF(__pyx_t_20);
                              __pyx_cur_scope->__pyx_t_9 = __pyx_t_20;
                              __Pyx_XGIVEREF(__pyx_t_21);
                              __pyx_cur_scope->__pyx_t_10 = __pyx_t_21;
                              __Pyx_XGIVEREF(__pyx_t_24);
                              __pyx_cur_scope->__pyx_t_11 = __pyx_t_24;
                              __Pyx_XGIVEREF(__pyx_r);
                              __Pyx_RefNannyFinishContext();
                              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                              /* return from generator, awaiting value */
                              __pyx_generator->resume_label = 7;
                              return __pyx_r;
                              __pyx_L57_resume_from_await:;
                              __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                              __pyx_cur_scope->__pyx_t_0 = 0;
                              __Pyx_XGOTREF(__pyx_t_1);
                              __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                              __pyx_cur_scope->__pyx_t_1 = 0;
                              __Pyx_XGOTREF(__pyx_t_2);
                              __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                              __pyx_cur_scope->__pyx_t_2 = 0;
                              __Pyx_XGOTREF(__pyx_t_3);
                              __pyx_t_11 = __pyx_cur_scope->__pyx_t_3;
                              __pyx_cur_scope->__pyx_t_3 = 0;
                              __Pyx_XGOTREF(__pyx_t_11);
                              __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                              __pyx_cur_scope->__pyx_t_4 = 0;
                              __Pyx_XGOTREF(__pyx_t_12);
                              __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                              __pyx_cur_scope->__pyx_t_5 = 0;
                              __Pyx_XGOTREF(__pyx_t_13);
                              __pyx_t_17 = __pyx_cur_scope->__pyx_t_6;
                              __pyx_cur_scope->__pyx_t_6 = 0;
                              __Pyx_XGOTREF(__pyx_t_17);
                              __pyx_t_18 = __pyx_cur_scope->__pyx_t_7;
                              __pyx_cur_scope->__pyx_t_7 = 0;
                              __Pyx_XGOTREF(__pyx_t_18);
                              __pyx_t_19 = __pyx_cur_scope->__pyx_t_8;
                              __pyx_cur_scope->__pyx_t_8 = 0;
                              __Pyx_XGOTREF(__pyx_t_19);
                              __pyx_t_20 = __pyx_cur_scope->__pyx_t_9;
                              __pyx_cur_scope->__pyx_t_9 = 0;
                              __Pyx_XGOTREF(__pyx_t_20);
                              __pyx_t_21 = __pyx_cur_scope->__pyx_t_10;
                              __pyx_cur_scope->__pyx_t_10 = 0;
                              __Pyx_XGOTREF(__pyx_t_21);
                              __pyx_t_24 = __pyx_cur_scope->__pyx_t_11;
                              __pyx_cur_scope->__pyx_t_11 = 0;
                              __Pyx_XGOTREF(__pyx_t_24);
                              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5684, __pyx_L28_error)
                              __pyx_t_25 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_25);
                            } else if (likely(__pyx_t_16 == PYGEN_RETURN)) {
                              __Pyx_GOTREF(__pyx_r);
                              __pyx_t_25 = __pyx_r; __pyx_r = NULL;
                            } else {
                              __Pyx_XGOTREF(__pyx_r);
                              __PYX_ERR(0, 5684, __pyx_L28_error)
                            }
                            __pyx_t_24 = __pyx_t_25;
                            __pyx_t_25 = 0;
                            __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                          }
                          goto __pyx_L38;
                        }
                        __pyx_L38:;
                      }
                      goto __pyx_L58;
                      __pyx_L34_error:;
                      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                      goto __pyx_L28_error;
                      __pyx_L58:;
                    }

                    /* "ws_package/controllers/activity_controller.py":5683
 *                     await asyncio.sleep(0.3)
 * 
 *                     with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                         async with async_session() as session:
 *                             query = select(ActivityInterval).where(
*/
                  }
                  __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                  __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                  __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                  goto __pyx_L33_try_end;
                  __pyx_L28_error:;
                  __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
                  __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                  __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                  /*except:*/ {
                    __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.stop_event", __pyx_clineno, __pyx_lineno, __pyx_filename);
                    if (__Pyx_GetException(&__pyx_t_25, &__pyx_t_7, &__pyx_t_5) < 0) __PYX_ERR(0, 5683, __pyx_L30_except_error)
                    __Pyx_XGOTREF(__pyx_t_25);
                    __Pyx_XGOTREF(__pyx_t_7);
                    __Pyx_XGOTREF(__pyx_t_5);
                    __pyx_t_6 = PyTuple_Pack(3, __pyx_t_25, __pyx_t_7, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5683, __pyx_L30_except_error)
                    __Pyx_GOTREF(__pyx_t_6);
                    __pyx_t_21 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_t_6, NULL);
                    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 5683, __pyx_L30_except_error)
                    __Pyx_GOTREF(__pyx_t_21);
                    __pyx_t_27 = __Pyx_PyObject_IsTrue(__pyx_t_21);
                    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                    if (__pyx_t_27 < (0)) __PYX_ERR(0, 5683, __pyx_L30_except_error)
                    __pyx_t_9 = (!__pyx_t_27);
                    if (unlikely(__pyx_t_9)) {
                      __Pyx_GIVEREF(__pyx_t_25);
                      __Pyx_GIVEREF(__pyx_t_7);
                      __Pyx_XGIVEREF(__pyx_t_5);
                      __Pyx_ErrRestoreWithState(__pyx_t_25, __pyx_t_7, __pyx_t_5);
                      __pyx_t_25 = 0;  __pyx_t_7 = 0;  __pyx_t_5 = 0; 
                      __PYX_ERR(0, 5683, __pyx_L30_except_error)
                    }
                    __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    goto __pyx_L29_exception_handled;
                  }
                  __pyx_L30_except_error:;
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __Pyx_XGIVEREF(__pyx_t_19);
                  __Pyx_XGIVEREF(__pyx_t_20);
                  __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20);
                  goto __pyx_L13_error;
                  __pyx_L29_exception_handled:;
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __Pyx_XGIVEREF(__pyx_t_19);
                  __Pyx_XGIVEREF(__pyx_t_20);
                  __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_19, __pyx_t_20);
                  __pyx_L33_try_end:;
                }
              }
              /*finally:*/ {
                /*normal exit:*/{
                  if (__pyx_t_17) {
                    __pyx_t_20 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_mstate_global->__pyx_tuple[7], NULL);
                    __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                    if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 5683, __pyx_L13_error)
                    __Pyx_GOTREF(__pyx_t_20);
                    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                  }
                  goto __pyx_L27;
                }
                __pyx_L27:;
              }
              goto __pyx_L62;
              __pyx_L24_error:;
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
              goto __pyx_L13_error;
              __pyx_L62:;
            }

            /* "ws_package/controllers/activity_controller.py":5677
 *                         should_skip_break_processing = True
 * 
 *                 if not should_skip_break_processing:             # <<<<<<<<<<<<<<
 *                     # Check if there are any break intervals with is_uploaded=0
 *                     # Flush queue first to ensure all pending writes are committed
*/
          }

          /* "ws_package/controllers/activity_controller.py":5665
 *             # CRITICAL: Before stopping, check for and send any remaining break intervals
 *             # This ensures break intervals are uploaded even if break_stop_event wasn't called explicitly
 *             try:             # <<<<<<<<<<<<<<
 *                 logger.info("Checking for remaining break intervals before stop...")
 * 
*/
        }
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        goto __pyx_L18_try_end;
        __pyx_L13_error:;
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "ws_package/controllers/activity_controller.py":5702
 *                             else:
 *                                 logger.info("No remaining break intervals found - nothing to send")
 *             except Exception as break_error:             # <<<<<<<<<<<<<<
 *                 logger.error("Error checking/sending remaining break intervals: %s", break_error, exc_info=True)
 *                 # Continue with stop_event even if break interval check fails
*/
        __pyx_t_29 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
        if (__pyx_t_29) {
          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.stop_event", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_7, &__pyx_t_25) < 0) __PYX_ERR(0, 5702, __pyx_L15_except_error)
          __Pyx_XGOTREF(__pyx_t_5);
          __Pyx_XGOTREF(__pyx_t_7);
          __Pyx_XGOTREF(__pyx_t_25);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_GIVEREF(__pyx_t_7);
          __pyx_cur_scope->__pyx_v_break_error = __pyx_t_7;
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":5703
 *                                 logger.info("No remaining break intervals found - nothing to send")
 *             except Exception as break_error:
 *                 logger.error("Error checking/sending remaining break intervals: %s", break_error, exc_info=True)             # <<<<<<<<<<<<<<
 *                 # Continue with stop_event even if break interval check fails
 * 
*/
            __pyx_t_4 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5703, __pyx_L68_error)
            __Pyx_GOTREF(__pyx_t_14);
            __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5703, __pyx_L68_error)
            __Pyx_GOTREF(__pyx_t_15);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_15))) {
              __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_15);
              assert(__pyx_t_4);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
              __Pyx_INCREF(__pyx_t_4);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Error_checking_sending_remaining, __pyx_cur_scope->__pyx_v_break_error};
              __pyx_t_14 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5703, __pyx_L68_error)
              __Pyx_GOTREF(__pyx_t_14);
              if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_14, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 5703, __pyx_L68_error)
              __pyx_t_6 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_14);
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5703, __pyx_L68_error)
              __Pyx_GOTREF(__pyx_t_6);
            }
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          }

          /* "ws_package/controllers/activity_controller.py":5702
 *                             else:
 *                                 logger.info("No remaining break intervals found - nothing to send")
 *             except Exception as break_error:             # <<<<<<<<<<<<<<
 *                 logger.error("Error checking/sending remaining break intervals: %s", break_error, exc_info=True)
 *                 # Continue with stop_event even if break interval check fails
*/
          /*finally:*/ {
            /*normal exit:*/{
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_break_error);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_break_error); __pyx_cur_scope->__pyx_v_break_error = 0;
              goto __pyx_L69;
            }
            __pyx_L68_error:;
            /*exception exit:*/{
              __Pyx_PyThreadState_assign
              __pyx_t_17 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_21 = 0; __pyx_t_24 = 0;
              __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
               __Pyx_ExceptionSwap(&__pyx_t_18, &__pyx_t_21, &__pyx_t_24);
              if ( unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_20, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_20, &__pyx_t_19);
              __Pyx_XGOTREF(__pyx_t_17);
              __Pyx_XGOTREF(__pyx_t_20);
              __Pyx_XGOTREF(__pyx_t_19);
              __Pyx_XGOTREF(__pyx_t_18);
              __Pyx_XGOTREF(__pyx_t_21);
              __Pyx_XGOTREF(__pyx_t_24);
              __pyx_t_29 = __pyx_lineno; __pyx_t_30 = __pyx_clineno; __pyx_t_31 = __pyx_filename;
              {
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_break_error);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_break_error); __pyx_cur_scope->__pyx_v_break_error = 0;
              }
              __Pyx_XGIVEREF(__pyx_t_18);
              __Pyx_XGIVEREF(__pyx_t_21);
              __Pyx_XGIVEREF(__pyx_t_24);
              __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_21, __pyx_t_24);
              __Pyx_XGIVEREF(__pyx_t_17);
              __Pyx_XGIVEREF(__pyx_t_20);
              __Pyx_XGIVEREF(__pyx_t_19);
              __Pyx_ErrRestore(__pyx_t_17, __pyx_t_20, __pyx_t_19);
              __pyx_t_17 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_18 = 0; __pyx_t_21 = 0; __pyx_t_24 = 0;
              __pyx_lineno = __pyx_t_29; __pyx_clineno = __pyx_t_30; __pyx_filename = __pyx_t_31;
              goto __pyx_L15_except_error;
            }
            __pyx_L69:;
          }
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
          goto __pyx_L14_exception_handled;
        }
        goto __pyx_L15_except_error;

        /* "ws_package/controllers/activity_controller.py":5665
 *             # CRITICAL: Before stopping, check for and send any remaining break intervals
 *             # This ensures break intervals are uploaded even if break_stop_event wasn't called explicitly
 *             try:             # <<<<<<<<<<<<<<
 *                 logger.info("Checking for remaining break intervals before stop...")
 * 
*/
        __pyx_L15_except_error:;
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
        goto __pyx_L4_error;
        __pyx_L14_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
        __pyx_L18_try_end:;
      }

      /* "ws_package/controllers/activity_controller.py":5707
 * 
 *             # hitting last api - this saves and sends final activity data
 *             await self.last_api_call(user_entity, keep_idle_time=keep_idle_time)             # <<<<<<<<<<<<<<
 * 
 *             logger.info("=== stop_event() completed - last_api_call finished ===")
*/
      __pyx_t_7 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_7);
      __pyx_t_5 = __Pyx_PyBool_FromLong(__pyx_cur_scope->__pyx_v_keep_idle_time); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5707, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_7, __pyx_cur_scope->__pyx_v_user_entity};
        __pyx_t_6 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 5707, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_keep_idle_time, __pyx_t_5, __pyx_t_6, __pyx_callargs+2, 0) < (0)) __PYX_ERR(0, 5707, __pyx_L4_error)
        __pyx_t_25 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_last_api_call, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_6);
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5707, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_25);
      }
      __pyx_t_16 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_25, &__pyx_r);
      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
      if (likely(__pyx_t_16 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
        __Pyx_XGIVEREF(__pyx_t_2);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
        __Pyx_XGIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 8;
        return __pyx_r;
        __pyx_L74_resume_from_await:;
        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_1);
        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_2);
        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_3);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5707, __pyx_L4_error)
      } else if (likely(__pyx_t_16 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_DECREF(__pyx_r); __pyx_r = 0;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 5707, __pyx_L4_error)
      }

      /* "ws_package/controllers/activity_controller.py":5709
 *             await self.last_api_call(user_entity, keep_idle_time=keep_idle_time)
 * 
 *             logger.info("=== stop_event() completed - last_api_call finished ===")             # <<<<<<<<<<<<<<
 *             return True
 *         except Exception as e:
*/
      __pyx_t_6 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5709, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5709, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_6);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_stop_event_completed_last_api_c};
        __pyx_t_25 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5709, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_25);
      }
      __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;

      /* "ws_package/controllers/activity_controller.py":5710
 * 
 *             logger.info("=== stop_event() completed - last_api_call finished ===")
 *             return True             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             logger.error("Error in stop_event: %s", e, exc_info=True)
*/
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_True);
      __pyx_r = Py_True;
      goto __pyx_L8_try_return;

      /* "ws_package/controllers/activity_controller.py":5645
 *     async def stop_event(self, user_entity: UserEntity, keep_idle_time: bool = True):
 *         """Stop all activity monitoring and cleanup resources"""
 *         try:             # <<<<<<<<<<<<<<
 *             logger.info("=== stop_event() called (keep_idle_time=%s) ===", keep_idle_time)
 * 
*/
    }
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "ws_package/controllers/activity_controller.py":5711
 *             logger.info("=== stop_event() completed - last_api_call finished ===")
 *             return True
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error in stop_event: %s", e, exc_info=True)
 *             # Don't fail completely - threads are already stopped
*/
    __pyx_t_30 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_30) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.stop_event", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_25, &__pyx_t_7, &__pyx_t_6) < 0) __PYX_ERR(0, 5711, __pyx_L6_except_error)
      __Pyx_XGOTREF(__pyx_t_25);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_7);
      __pyx_cur_scope->__pyx_v_e = __pyx_t_7;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":5712
 *             return True
 *         except Exception as e:
 *             logger.error("Error in stop_event: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 *             # Don't fail completely - threads are already stopped
 *             return False
*/
        __pyx_t_15 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5712, __pyx_L80_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5712, __pyx_L80_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_4);
          assert(__pyx_t_15);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_15);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Error_in_stop_event_s, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_14 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5712, __pyx_L80_error)
          __Pyx_GOTREF(__pyx_t_14);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_14, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 5712, __pyx_L80_error)
          __pyx_t_5 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_14);
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5712, __pyx_L80_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":5714
 *             logger.error("Error in stop_event: %s", e, exc_info=True)
 *             # Don't fail completely - threads are already stopped
 *             return False             # <<<<<<<<<<<<<<
 * 
 *     async def _send_active_app_update_to_electron(self, app_name: str, app_icon: Optional[str] = None):
*/
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_False);
        __pyx_r = Py_False;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
        goto __pyx_L79_return;
      }

      /* "ws_package/controllers/activity_controller.py":5711
 *             logger.info("=== stop_event() completed - last_api_call finished ===")
 *             return True
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error in stop_event: %s", e, exc_info=True)
 *             # Don't fail completely - threads are already stopped
*/
      /*finally:*/ {
        __pyx_L80_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_24 = 0; __pyx_t_21 = 0; __pyx_t_18 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_24, &__pyx_t_21, &__pyx_t_18);
          if ( unlikely(__Pyx_GetException(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11) < 0)) __Pyx_ErrFetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_24);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_18);
          __pyx_t_30 = __pyx_lineno; __pyx_t_29 = __pyx_clineno; __pyx_t_32 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_24);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_21, __pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_ErrRestore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
          __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_24 = 0; __pyx_t_21 = 0; __pyx_t_18 = 0;
          __pyx_lineno = __pyx_t_30; __pyx_clineno = __pyx_t_29; __pyx_filename = __pyx_t_32;
          goto __pyx_L6_except_error;
        }
        __pyx_L79_return: {
          __pyx_t_18 = __pyx_r;
          __pyx_r = 0;
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          __pyx_r = __pyx_t_18;
          __pyx_t_18 = 0;
          goto __pyx_L7_except_return;
        }
      }
    }
    goto __pyx_L6_except_error;

    /* "ws_package/controllers/activity_controller.py":5645
 *     async def stop_event(self, user_entity: UserEntity, keep_idle_time: bool = True):
 *         """Stop all activity monitoring and cleanup resources"""
 *         try:             # <<<<<<<<<<<<<<
 *             logger.info("=== stop_event() called (keep_idle_time=%s) ===", keep_idle_time)
 * 
*/
    __pyx_L6_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L7_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":5643
 *             raise  # Re-raise to let caller know it failed
 * 
 *     async def stop_event(self, user_entity: UserEntity, keep_idle_time: bool = True):             # <<<<<<<<<<<<<<
 *         """Stop all activity monitoring and cleanup resources"""
 *         try:
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_25);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("stop_event", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_185generator37(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":5716
 *             return False
 * 
 *     async def _send_active_app_update_to_electron(self, app_name: str, app_icon: Optional[str] = None):             # <<<<<<<<<<<<<<
 *         """
 *         Send active app update to Electron for UI display.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_184_send_active_app_update_to_electron(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_183_send_active_app_update_to_electron, "\n        Send active app update to Electron for UI display.\n        \n        Args:\n            app_name: Current active application name\n            app_icon: Base64 encoded icon (optional)\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_184_send_active_app_update_to_electron = {"_send_active_app_update_to_electron", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_184_send_active_app_update_to_electron, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_183_send_active_app_update_to_electron};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_184_send_active_app_update_to_electron(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_app_name = 0;
  PyObject *__pyx_v_app_icon = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_send_active_app_update_to_electron (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_app_name,&__pyx_mstate_global->__pyx_n_u_app_icon,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 5716, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 5716, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 5716, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 5716, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_send_active_app_update_to_electron", 0) < (0)) __PYX_ERR(0, 5716, __pyx_L3_error)
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject*)Py_None));
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_send_active_app_update_to_electron", 0, 2, 3, i); __PYX_ERR(0, 5716, __pyx_L3_error) }
      }
    } else {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 5716, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 5716, __pyx_L3_error)
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 5716, __pyx_L3_error)
        break;
        default: goto __pyx_L5_argtuple_error;
      }
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject*)Py_None));
    }
    __pyx_v_self = values[0];
    __pyx_v_app_name = ((PyObject*)values[1]);
    __pyx_v_app_icon = ((PyObject*)values[2]);
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_send_active_app_update_to_electron", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 5716, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._send_active_app_update_to_electron", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_app_name), (&PyUnicode_Type), 0, "app_name", 2))) __PYX_ERR(0, 5716, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_app_icon), (&PyUnicode_Type), 1, "app_icon", 2))) __PYX_ERR(0, 5716, __pyx_L1_error)
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_183_send_active_app_update_to_electron(__pyx_self, __pyx_v_self, __pyx_v_app_name, __pyx_v_app_icon);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  goto __pyx_L7_cleaned_up;
  __pyx_L0:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __pyx_L7_cleaned_up:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_183_send_active_app_update_to_electron(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_app_name, PyObject *__pyx_v_app_icon) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_send_active_app_update_to_electron", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 5716, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_app_name = __pyx_v_app_name;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_app_name);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_app_name);
  __pyx_cur_scope->__pyx_v_app_icon = __pyx_v_app_icon;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_app_icon);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_app_icon);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_185generator37, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[63]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_send_active_app_update_to_elect, __pyx_mstate_global->__pyx_n_u_ActivityController__send_active, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 5716, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._send_active_app_update_to_electron", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_185generator37(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  size_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  int __pyx_t_15;
  char const *__pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_send_active_app_update_to_electron", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 5716, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":5724
 *             app_icon: Base64 encoded icon (optional)
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             electron_comm = self._get_electron_comm()
 * 
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":5725
 *         """
 *         try:
 *             electron_comm = self._get_electron_comm()             # <<<<<<<<<<<<<<
 * 
 *             if not is_ipc_ready():
*/
      __pyx_t_5 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_6 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_electron_comm_2, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5725, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_cur_scope->__pyx_v_electron_comm = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":5727
 *             electron_comm = self._get_electron_comm()
 * 
 *             if not is_ipc_ready():             # <<<<<<<<<<<<<<
 *                 logger.debug("IPC server not ready - skipping active app update")
 *                 return
*/
      __pyx_t_5 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_is_ipc_ready); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5727, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_5);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_6 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5727, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 5727, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_9 = (!__pyx_t_8);
      if (__pyx_t_9) {

        /* "ws_package/controllers/activity_controller.py":5728
 * 
 *             if not is_ipc_ready():
 *                 logger.debug("IPC server not ready - skipping active app update")             # <<<<<<<<<<<<<<
 *                 return
 * 
*/
        __pyx_t_7 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5728, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5728, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_6 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_10);
          assert(__pyx_t_7);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
          __pyx_t_6 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_IPC_server_not_ready_skipping_ac};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5728, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":5729
 *             if not is_ipc_ready():
 *                 logger.debug("IPC server not ready - skipping active app update")
 *                 return             # <<<<<<<<<<<<<<
 * 
 *             if not electron_comm.is_connected():
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
        goto __pyx_L8_try_return;

        /* "ws_package/controllers/activity_controller.py":5727
 *             electron_comm = self._get_electron_comm()
 * 
 *             if not is_ipc_ready():             # <<<<<<<<<<<<<<
 *                 logger.debug("IPC server not ready - skipping active app update")
 *                 return
*/
      }

      /* "ws_package/controllers/activity_controller.py":5731
 *                 return
 * 
 *             if not electron_comm.is_connected():             # <<<<<<<<<<<<<<
 *                 logger.debug("IPC not connected - skipping active app update")
 *                 return
*/
      __pyx_t_10 = __pyx_cur_scope->__pyx_v_electron_comm;
      __Pyx_INCREF(__pyx_t_10);
      __pyx_t_6 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_10, NULL};
        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_connected, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5731, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 5731, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_8 = (!__pyx_t_9);
      if (__pyx_t_8) {

        /* "ws_package/controllers/activity_controller.py":5732
 * 
 *             if not electron_comm.is_connected():
 *                 logger.debug("IPC not connected - skipping active app update")             # <<<<<<<<<<<<<<
 *                 return
 * 
*/
        __pyx_t_10 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5732, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5732, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_6 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5);
          assert(__pyx_t_10);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
          __pyx_t_6 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_IPC_not_connected_skipping_activ};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5732, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":5733
 *             if not electron_comm.is_connected():
 *                 logger.debug("IPC not connected - skipping active app update")
 *                 return             # <<<<<<<<<<<<<<
 * 
 *             # Send active app change message
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
        goto __pyx_L8_try_return;

        /* "ws_package/controllers/activity_controller.py":5731
 *                 return
 * 
 *             if not electron_comm.is_connected():             # <<<<<<<<<<<<<<
 *                 logger.debug("IPC not connected - skipping active app update")
 *                 return
*/
      }

      /* "ws_package/controllers/activity_controller.py":5737
 *             # Send active app change message
 *             message_data = {
 *                 'app_name': app_name,             # <<<<<<<<<<<<<<
 *                 'app_icon': app_icon,
 *                 'timestamp': datetime.datetime.now().isoformat()
*/
      __pyx_t_4 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5737, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_app_name, __pyx_cur_scope->__pyx_v_app_name) < (0)) __PYX_ERR(0, 5737, __pyx_L4_error)

      /* "ws_package/controllers/activity_controller.py":5738
 *             message_data = {
 *                 'app_name': app_name,
 *                 'app_icon': app_icon,             # <<<<<<<<<<<<<<
 *                 'timestamp': datetime.datetime.now().isoformat()
 *             }
*/
      if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_app_icon, __pyx_cur_scope->__pyx_v_app_icon) < (0)) __PYX_ERR(0, 5737, __pyx_L4_error)

      /* "ws_package/controllers/activity_controller.py":5739
 *                 'app_name': app_name,
 *                 'app_icon': app_icon,
 *                 'timestamp': datetime.datetime.now().isoformat()             # <<<<<<<<<<<<<<
 *             }
 * 
*/
      __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5739, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 5739, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_11 = __pyx_t_13;
      __Pyx_INCREF(__pyx_t_11);
      __pyx_t_6 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_11, NULL};
        __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5739, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
      }
      __pyx_t_10 = __pyx_t_7;
      __Pyx_INCREF(__pyx_t_10);
      __pyx_t_6 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_10, NULL};
        __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_isoformat, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5739, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
      }
      if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_timestamp, __pyx_t_5) < (0)) __PYX_ERR(0, 5737, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_cur_scope->__pyx_v_message_data = ((PyObject*)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":5742
 *             }
 * 
 *             success = electron_comm.send_to_electron('active_app_change', message_data)             # <<<<<<<<<<<<<<
 * 
 *             if success:
*/
      __pyx_t_5 = __pyx_cur_scope->__pyx_v_electron_comm;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_6 = 0;
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_n_u_active_app_change, __pyx_cur_scope->__pyx_v_message_data};
        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_send_to_electron, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5742, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_cur_scope->__pyx_v_success = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":5744
 *             success = electron_comm.send_to_electron('active_app_change', message_data)
 * 
 *             if success:             # <<<<<<<<<<<<<<
 *                 logger.debug("Sent active app update to Electron: %s", app_name)
 *             else:
*/
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_success); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 5744, __pyx_L4_error)
      if (__pyx_t_8) {

        /* "ws_package/controllers/activity_controller.py":5745
 * 
 *             if success:
 *                 logger.debug("Sent active app update to Electron: %s", app_name)             # <<<<<<<<<<<<<<
 *             else:
 *                 logger.debug("Failed to send active app update to Electron: %s", app_name)
*/
        __pyx_t_5 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5745, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5745, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_6 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_10);
          assert(__pyx_t_5);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
          __pyx_t_6 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_Sent_active_app_update_to_Electr, __pyx_cur_scope->__pyx_v_app_name};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5745, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":5744
 *             success = electron_comm.send_to_electron('active_app_change', message_data)
 * 
 *             if success:             # <<<<<<<<<<<<<<
 *                 logger.debug("Sent active app update to Electron: %s", app_name)
 *             else:
*/
        goto __pyx_L12;
      }

      /* "ws_package/controllers/activity_controller.py":5747
 *                 logger.debug("Sent active app update to Electron: %s", app_name)
 *             else:
 *                 logger.debug("Failed to send active app update to Electron: %s", app_name)             # <<<<<<<<<<<<<<
 * 
 *         except Exception as e:
*/
      /*else*/ {
        __pyx_t_10 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5747, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5747, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_6 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7);
          assert(__pyx_t_10);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
          __pyx_t_6 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Failed_to_send_active_app_update, __pyx_cur_scope->__pyx_v_app_name};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5747, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      __pyx_L12:;

      /* "ws_package/controllers/activity_controller.py":5724
 *             app_icon: Base64 encoded icon (optional)
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             electron_comm = self._get_electron_comm()
 * 
*/
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L9_try_end;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "ws_package/controllers/activity_controller.py":5749
 *                 logger.debug("Failed to send active app update to Electron: %s", app_name)
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error sending active app update to Electron: %s", e, exc_info=True)
 * 
*/
    __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_14) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._send_active_app_update_to_electron", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_7, &__pyx_t_10) < 0) __PYX_ERR(0, 5749, __pyx_L6_except_error)
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_7);
      __pyx_cur_scope->__pyx_v_e = __pyx_t_7;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":5750
 * 
 *         except Exception as e:
 *             logger.error("Error sending active app update to Electron: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *     async def _send_file_upload_success_to_electron(self, s3_url: str):
*/
        __pyx_t_13 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 5750, __pyx_L18_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5750, __pyx_L18_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_6 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_12))) {
          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12);
          assert(__pyx_t_13);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
          __pyx_t_6 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Error_sending_active_app_update, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_11 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 5750, __pyx_L18_error)
          __Pyx_GOTREF(__pyx_t_11);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_11, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 5750, __pyx_L18_error)
          __pyx_t_5 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_11);
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5750, __pyx_L18_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      }

      /* "ws_package/controllers/activity_controller.py":5749
 *                 logger.debug("Failed to send active app update to Electron: %s", app_name)
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error sending active app update to Electron: %s", e, exc_info=True)
 * 
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          goto __pyx_L19;
        }
        __pyx_L18_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
          if ( unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_17);
          __Pyx_XGOTREF(__pyx_t_18);
          __Pyx_XGOTREF(__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_22);
          __pyx_t_14 = __pyx_lineno; __pyx_t_15 = __pyx_clineno; __pyx_t_16 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_ErrRestore(__pyx_t_17, __pyx_t_18, __pyx_t_19);
          __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0;
          __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_16;
          goto __pyx_L6_except_error;
        }
        __pyx_L19:;
      }
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      goto __pyx_L5_exception_handled;
    }
    goto __pyx_L6_except_error;

    /* "ws_package/controllers/activity_controller.py":5724
 *             app_icon: Base64 encoded icon (optional)
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             electron_comm = self._get_electron_comm()
 * 
*/
    __pyx_L6_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L5_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    __pyx_L9_try_end:;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":5716
 *             return False
 * 
 *     async def _send_active_app_update_to_electron(self, app_name: str, app_icon: Optional[str] = None):             # <<<<<<<<<<<<<<
 *         """
 *         Send active app update to Electron for UI display.
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("_send_active_app_update_to_electron", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_188generator38(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":5752
 *             logger.error("Error sending active app update to Electron: %s", e, exc_info=True)
 * 
 *     async def _send_file_upload_success_to_electron(self, s3_url: str):             # <<<<<<<<<<<<<<
 *         """Sends file upload success message to Electron for UI notification."""
 *         try:
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_187_send_file_upload_success_to_electron(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_186_send_file_upload_success_to_electron, "Sends file upload success message to Electron for UI notification.");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_187_send_file_upload_success_to_electron = {"_send_file_upload_success_to_electron", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_187_send_file_upload_success_to_electron, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_186_send_file_upload_success_to_electron};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_187_send_file_upload_success_to_electron(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_s3_url = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_send_file_upload_success_to_electron (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_s3_url,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 5752, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 5752, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 5752, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_send_file_upload_success_to_electron", 0) < (0)) __PYX_ERR(0, 5752, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_send_file_upload_success_to_electron", 1, 2, 2, i); __PYX_ERR(0, 5752, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 5752, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 5752, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_s3_url = ((PyObject*)values[1]);
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_send_file_upload_success_to_electron", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 5752, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._send_file_upload_success_to_electron", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_s3_url), (&PyUnicode_Type), 0, "s3_url", 2))) __PYX_ERR(0, 5752, __pyx_L1_error)
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_186_send_file_upload_success_to_electron(__pyx_self, __pyx_v_self, __pyx_v_s3_url);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  goto __pyx_L7_cleaned_up;
  __pyx_L0:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __pyx_L7_cleaned_up:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_186_send_file_upload_success_to_electron(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_s3_url) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_send_file_upload_success_to_electron", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 5752, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_s3_url = __pyx_v_s3_url;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_s3_url);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_s3_url);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_188generator38, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[64]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_send_file_upload_success_to_ele, __pyx_mstate_global->__pyx_n_u_ActivityController__send_file_up, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 5752, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._send_file_upload_success_to_electron", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_188generator38(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  size_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  int __pyx_t_15;
  char const *__pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_send_file_upload_success_to_electron", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 5752, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":5754
 *     async def _send_file_upload_success_to_electron(self, s3_url: str):
 *         """Sends file upload success message to Electron for UI notification."""
 *         try:             # <<<<<<<<<<<<<<
 *             electron_comm = self._get_electron_comm()
 * 
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":5755
 *         """Sends file upload success message to Electron for UI notification."""
 *         try:
 *             electron_comm = self._get_electron_comm()             # <<<<<<<<<<<<<<
 * 
 *             if not is_ipc_ready():
*/
      __pyx_t_5 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_6 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_electron_comm_2, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5755, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_cur_scope->__pyx_v_electron_comm = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":5757
 *             electron_comm = self._get_electron_comm()
 * 
 *             if not is_ipc_ready():             # <<<<<<<<<<<<<<
 *                 logger.debug("IPC server not ready - skipping file upload success notification")
 *                 return False
*/
      __pyx_t_5 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_is_ipc_ready); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5757, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_5);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_6 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5757, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 5757, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_9 = (!__pyx_t_8);
      if (__pyx_t_9) {

        /* "ws_package/controllers/activity_controller.py":5758
 * 
 *             if not is_ipc_ready():
 *                 logger.debug("IPC server not ready - skipping file upload success notification")             # <<<<<<<<<<<<<<
 *                 return False
 * 
*/
        __pyx_t_7 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5758, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5758, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_6 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_10);
          assert(__pyx_t_7);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
          __pyx_t_6 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_IPC_server_not_ready_skipping_fi};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5758, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":5759
 *             if not is_ipc_ready():
 *                 logger.debug("IPC server not ready - skipping file upload success notification")
 *                 return False             # <<<<<<<<<<<<<<
 * 
 *             if not electron_comm.is_connected():
*/
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_False);
        __pyx_r = Py_False;
        goto __pyx_L8_try_return;

        /* "ws_package/controllers/activity_controller.py":5757
 *             electron_comm = self._get_electron_comm()
 * 
 *             if not is_ipc_ready():             # <<<<<<<<<<<<<<
 *                 logger.debug("IPC server not ready - skipping file upload success notification")
 *                 return False
*/
      }

      /* "ws_package/controllers/activity_controller.py":5761
 *                 return False
 * 
 *             if not electron_comm.is_connected():             # <<<<<<<<<<<<<<
 *                 logger.debug("IPC not connected - skipping file upload success notification")
 *                 return False
*/
      __pyx_t_10 = __pyx_cur_scope->__pyx_v_electron_comm;
      __Pyx_INCREF(__pyx_t_10);
      __pyx_t_6 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_10, NULL};
        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_connected, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5761, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 5761, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_8 = (!__pyx_t_9);
      if (__pyx_t_8) {

        /* "ws_package/controllers/activity_controller.py":5762
 * 
 *             if not electron_comm.is_connected():
 *                 logger.debug("IPC not connected - skipping file upload success notification")             # <<<<<<<<<<<<<<
 *                 return False
 * 
*/
        __pyx_t_10 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5762, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5762, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_6 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5);
          assert(__pyx_t_10);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
          __pyx_t_6 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_IPC_not_connected_skipping_file};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5762, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":5763
 *             if not electron_comm.is_connected():
 *                 logger.debug("IPC not connected - skipping file upload success notification")
 *                 return False             # <<<<<<<<<<<<<<
 * 
 *             # Send file upload success message
*/
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_False);
        __pyx_r = Py_False;
        goto __pyx_L8_try_return;

        /* "ws_package/controllers/activity_controller.py":5761
 *                 return False
 * 
 *             if not electron_comm.is_connected():             # <<<<<<<<<<<<<<
 *                 logger.debug("IPC not connected - skipping file upload success notification")
 *                 return False
*/
      }

      /* "ws_package/controllers/activity_controller.py":5767
 *             # Send file upload success message
 *             message_data = {
 *                 'message': 'File uploaded successfully',             # <<<<<<<<<<<<<<
 *                 's3_url': s3_url,
 *                 'timestamp': datetime.datetime.now().isoformat()
*/
      __pyx_t_4 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5767, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_message, __pyx_mstate_global->__pyx_kp_u_File_uploaded_successfully) < (0)) __PYX_ERR(0, 5767, __pyx_L4_error)

      /* "ws_package/controllers/activity_controller.py":5768
 *             message_data = {
 *                 'message': 'File uploaded successfully',
 *                 's3_url': s3_url,             # <<<<<<<<<<<<<<
 *                 'timestamp': datetime.datetime.now().isoformat()
 *             }
*/
      if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_s3_url, __pyx_cur_scope->__pyx_v_s3_url) < (0)) __PYX_ERR(0, 5767, __pyx_L4_error)

      /* "ws_package/controllers/activity_controller.py":5769
 *                 'message': 'File uploaded successfully',
 *                 's3_url': s3_url,
 *                 'timestamp': datetime.datetime.now().isoformat()             # <<<<<<<<<<<<<<
 *             }
 * 
*/
      __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5769, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 5769, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_11 = __pyx_t_13;
      __Pyx_INCREF(__pyx_t_11);
      __pyx_t_6 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_11, NULL};
        __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5769, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
      }
      __pyx_t_10 = __pyx_t_7;
      __Pyx_INCREF(__pyx_t_10);
      __pyx_t_6 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_10, NULL};
        __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_isoformat, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5769, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
      }
      if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_timestamp, __pyx_t_5) < (0)) __PYX_ERR(0, 5767, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_cur_scope->__pyx_v_message_data = ((PyObject*)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":5772
 *             }
 * 
 *             success = electron_comm.send_to_electron('idle_file_upload_success', message_data)             # <<<<<<<<<<<<<<
 * 
 *             if success:
*/
      __pyx_t_5 = __pyx_cur_scope->__pyx_v_electron_comm;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_6 = 0;
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_n_u_idle_file_upload_success, __pyx_cur_scope->__pyx_v_message_data};
        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_send_to_electron, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5772, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_cur_scope->__pyx_v_success = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":5774
 *             success = electron_comm.send_to_electron('idle_file_upload_success', message_data)
 * 
 *             if success:             # <<<<<<<<<<<<<<
 *                 logger.info("[SUCCESS] Sent file upload success message to Electron (URL: %s...)", s3_url[:120])
 *             else:
*/
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_success); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 5774, __pyx_L4_error)
      if (__pyx_t_8) {

        /* "ws_package/controllers/activity_controller.py":5775
 * 
 *             if success:
 *                 logger.info("[SUCCESS] Sent file upload success message to Electron (URL: %s...)", s3_url[:120])             # <<<<<<<<<<<<<<
 *             else:
 *                 logger.warning("[FAILED] Failed to send file upload success message to Electron")
*/
        __pyx_t_5 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5775, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5775, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_7 = __Pyx_PyUnicode_Substring(__pyx_cur_scope->__pyx_v_s3_url, 0, 0x78); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5775, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_6 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_10);
          assert(__pyx_t_5);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
          __pyx_t_6 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_SUCCESS_Sent_file_upload_succes, __pyx_t_7};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5775, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":5774
 *             success = electron_comm.send_to_electron('idle_file_upload_success', message_data)
 * 
 *             if success:             # <<<<<<<<<<<<<<
 *                 logger.info("[SUCCESS] Sent file upload success message to Electron (URL: %s...)", s3_url[:120])
 *             else:
*/
        goto __pyx_L12;
      }

      /* "ws_package/controllers/activity_controller.py":5777
 *                 logger.info("[SUCCESS] Sent file upload success message to Electron (URL: %s...)", s3_url[:120])
 *             else:
 *                 logger.warning("[FAILED] Failed to send file upload success message to Electron")             # <<<<<<<<<<<<<<
 *             return success
 *         except Exception as e:
*/
      /*else*/ {
        __pyx_t_10 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5777, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5777, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_6 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5);
          assert(__pyx_t_10);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
          __pyx_t_6 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_FAILED_Failed_to_send_file_uplo};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5777, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      __pyx_L12:;

      /* "ws_package/controllers/activity_controller.py":5778
 *             else:
 *                 logger.warning("[FAILED] Failed to send file upload success message to Electron")
 *             return success             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             logger.error("Error sending file upload success message to Electron: %s", e, exc_info=True)
*/
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_success);
      __pyx_r = __pyx_cur_scope->__pyx_v_success;
      goto __pyx_L8_try_return;

      /* "ws_package/controllers/activity_controller.py":5754
 *     async def _send_file_upload_success_to_electron(self, s3_url: str):
 *         """Sends file upload success message to Electron for UI notification."""
 *         try:             # <<<<<<<<<<<<<<
 *             electron_comm = self._get_electron_comm()
 * 
*/
    }
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "ws_package/controllers/activity_controller.py":5779
 *                 logger.warning("[FAILED] Failed to send file upload success message to Electron")
 *             return success
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error sending file upload success message to Electron: %s", e, exc_info=True)
 *             return False
*/
    __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_14) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._send_file_upload_success_to_electron", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_5, &__pyx_t_10) < 0) __PYX_ERR(0, 5779, __pyx_L6_except_error)
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_cur_scope->__pyx_v_e = __pyx_t_5;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":5780
 *             return success
 *         except Exception as e:
 *             logger.error("Error sending file upload success message to Electron: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 *             return False
 * 
*/
        __pyx_t_13 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 5780, __pyx_L18_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5780, __pyx_L18_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_6 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_12))) {
          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12);
          assert(__pyx_t_13);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
          __pyx_t_6 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Error_sending_file_upload_succes, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_11 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 5780, __pyx_L18_error)
          __Pyx_GOTREF(__pyx_t_11);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_11, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 5780, __pyx_L18_error)
          __pyx_t_7 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_11);
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5780, __pyx_L18_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "ws_package/controllers/activity_controller.py":5781
 *         except Exception as e:
 *             logger.error("Error sending file upload success message to Electron: %s", e, exc_info=True)
 *             return False             # <<<<<<<<<<<<<<
 * 
 *     async def _send_file_upload_failure_to_electron(self):
*/
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_False);
        __pyx_r = Py_False;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L17_return;
      }

      /* "ws_package/controllers/activity_controller.py":5779
 *                 logger.warning("[FAILED] Failed to send file upload success message to Electron")
 *             return success
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error sending file upload success message to Electron: %s", e, exc_info=True)
 *             return False
*/
      /*finally:*/ {
        __pyx_L18_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
          if ( unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_17);
          __Pyx_XGOTREF(__pyx_t_18);
          __Pyx_XGOTREF(__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_22);
          __pyx_t_14 = __pyx_lineno; __pyx_t_15 = __pyx_clineno; __pyx_t_16 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_ErrRestore(__pyx_t_17, __pyx_t_18, __pyx_t_19);
          __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0;
          __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_16;
          goto __pyx_L6_except_error;
        }
        __pyx_L17_return: {
          __pyx_t_22 = __pyx_r;
          __pyx_r = 0;
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          __pyx_r = __pyx_t_22;
          __pyx_t_22 = 0;
          goto __pyx_L7_except_return;
        }
      }
    }
    goto __pyx_L6_except_error;

    /* "ws_package/controllers/activity_controller.py":5754
 *     async def _send_file_upload_success_to_electron(self, s3_url: str):
 *         """Sends file upload success message to Electron for UI notification."""
 *         try:             # <<<<<<<<<<<<<<
 *             electron_comm = self._get_electron_comm()
 * 
*/
    __pyx_L6_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L7_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":5752
 *             logger.error("Error sending active app update to Electron: %s", e, exc_info=True)
 * 
 *     async def _send_file_upload_success_to_electron(self, s3_url: str):             # <<<<<<<<<<<<<<
 *         """Sends file upload success message to Electron for UI notification."""
 *         try:
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("_send_file_upload_success_to_electron", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_191generator39(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":5783
 *             return False
 * 
 *     async def _send_file_upload_failure_to_electron(self):             # <<<<<<<<<<<<<<
 *         """Sends file upload failure message to Electron for UI notification."""
 *         try:
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_190_send_file_upload_failure_to_electron(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_189_send_file_upload_failure_to_electron, "Sends file upload failure message to Electron for UI notification.");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_190_send_file_upload_failure_to_electron = {"_send_file_upload_failure_to_electron", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_190_send_file_upload_failure_to_electron, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_189_send_file_upload_failure_to_electron};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_190_send_file_upload_failure_to_electron(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[1] = {0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_send_file_upload_failure_to_electron (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 5783, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 5783, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_send_file_upload_failure_to_electron", 0) < (0)) __PYX_ERR(0, 5783, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_send_file_upload_failure_to_electron", 1, 1, 1, i); __PYX_ERR(0, 5783, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 1)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 5783, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_send_file_upload_failure_to_electron", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 5783, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._send_file_upload_failure_to_electron", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_189_send_file_upload_failure_to_electron(__pyx_self, __pyx_v_self);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_189_send_file_upload_failure_to_electron(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_send_file_upload_failure_to_electron", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 5783, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_191generator39, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[65]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_send_file_upload_failure_to_ele, __pyx_mstate_global->__pyx_n_u_ActivityController__send_file_up_2, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 5783, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._send_file_upload_failure_to_electron", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_191generator39(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  size_t __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  int __pyx_t_8;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  int __pyx_t_15;
  char const *__pyx_t_16;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_send_file_upload_failure_to_electron", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 5783, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":5785
 *     async def _send_file_upload_failure_to_electron(self):
 *         """Sends file upload failure message to Electron for UI notification."""
 *         try:             # <<<<<<<<<<<<<<
 *             electron_comm = self._get_electron_comm()
 * 
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":5786
 *         """Sends file upload failure message to Electron for UI notification."""
 *         try:
 *             electron_comm = self._get_electron_comm()             # <<<<<<<<<<<<<<
 * 
 *             if not is_ipc_ready():
*/
      __pyx_t_5 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_6 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_electron_comm_2, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5786, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_cur_scope->__pyx_v_electron_comm = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":5788
 *             electron_comm = self._get_electron_comm()
 * 
 *             if not is_ipc_ready():             # <<<<<<<<<<<<<<
 *                 logger.debug("IPC server not ready - skipping file upload failure notification")
 *                 return False
*/
      __pyx_t_5 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_is_ipc_ready); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5788, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_5);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_6 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5788, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 5788, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_9 = (!__pyx_t_8);
      if (__pyx_t_9) {

        /* "ws_package/controllers/activity_controller.py":5789
 * 
 *             if not is_ipc_ready():
 *                 logger.debug("IPC server not ready - skipping file upload failure notification")             # <<<<<<<<<<<<<<
 *                 return False
 * 
*/
        __pyx_t_7 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5789, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5789, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_6 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_10);
          assert(__pyx_t_7);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
          __pyx_t_6 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_IPC_server_not_ready_skipping_fi_2};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5789, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":5790
 *             if not is_ipc_ready():
 *                 logger.debug("IPC server not ready - skipping file upload failure notification")
 *                 return False             # <<<<<<<<<<<<<<
 * 
 *             if not electron_comm.is_connected():
*/
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_False);
        __pyx_r = Py_False;
        goto __pyx_L8_try_return;

        /* "ws_package/controllers/activity_controller.py":5788
 *             electron_comm = self._get_electron_comm()
 * 
 *             if not is_ipc_ready():             # <<<<<<<<<<<<<<
 *                 logger.debug("IPC server not ready - skipping file upload failure notification")
 *                 return False
*/
      }

      /* "ws_package/controllers/activity_controller.py":5792
 *                 return False
 * 
 *             if not electron_comm.is_connected():             # <<<<<<<<<<<<<<
 *                 logger.debug("IPC not connected - skipping file upload failure notification")
 *                 return False
*/
      __pyx_t_10 = __pyx_cur_scope->__pyx_v_electron_comm;
      __Pyx_INCREF(__pyx_t_10);
      __pyx_t_6 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_10, NULL};
        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_connected, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5792, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 5792, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_8 = (!__pyx_t_9);
      if (__pyx_t_8) {

        /* "ws_package/controllers/activity_controller.py":5793
 * 
 *             if not electron_comm.is_connected():
 *                 logger.debug("IPC not connected - skipping file upload failure notification")             # <<<<<<<<<<<<<<
 *                 return False
 * 
*/
        __pyx_t_10 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5793, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5793, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_6 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_5);
          assert(__pyx_t_10);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
          __pyx_t_6 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_IPC_not_connected_skipping_file_2};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5793, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":5794
 *             if not electron_comm.is_connected():
 *                 logger.debug("IPC not connected - skipping file upload failure notification")
 *                 return False             # <<<<<<<<<<<<<<
 * 
 *             # Send file upload failure message
*/
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_False);
        __pyx_r = Py_False;
        goto __pyx_L8_try_return;

        /* "ws_package/controllers/activity_controller.py":5792
 *                 return False
 * 
 *             if not electron_comm.is_connected():             # <<<<<<<<<<<<<<
 *                 logger.debug("IPC not connected - skipping file upload failure notification")
 *                 return False
*/
      }

      /* "ws_package/controllers/activity_controller.py":5798
 *             # Send file upload failure message
 *             message_data = {
 *                 'message': 'File upload failed',             # <<<<<<<<<<<<<<
 *                 'timestamp': datetime.datetime.now().isoformat()
 *             }
*/
      __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5798, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_message, __pyx_mstate_global->__pyx_kp_u_File_upload_failed) < (0)) __PYX_ERR(0, 5798, __pyx_L4_error)

      /* "ws_package/controllers/activity_controller.py":5799
 *             message_data = {
 *                 'message': 'File upload failed',
 *                 'timestamp': datetime.datetime.now().isoformat()             # <<<<<<<<<<<<<<
 *             }
 * 
*/
      __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5799, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 5799, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_11 = __pyx_t_13;
      __Pyx_INCREF(__pyx_t_11);
      __pyx_t_6 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_11, NULL};
        __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5799, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
      }
      __pyx_t_10 = __pyx_t_7;
      __Pyx_INCREF(__pyx_t_10);
      __pyx_t_6 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_10, NULL};
        __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_isoformat, __pyx_callargs+__pyx_t_6, (1-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5799, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
      }
      if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_timestamp, __pyx_t_5) < (0)) __PYX_ERR(0, 5798, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_cur_scope->__pyx_v_message_data = ((PyObject*)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":5802
 *             }
 * 
 *             success = electron_comm.send_to_electron('idle_file_upload_failure', message_data)             # <<<<<<<<<<<<<<
 * 
 *             if success:
*/
      __pyx_t_5 = __pyx_cur_scope->__pyx_v_electron_comm;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_6 = 0;
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_n_u_idle_file_upload_failure, __pyx_cur_scope->__pyx_v_message_data};
        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_send_to_electron, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5802, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_cur_scope->__pyx_v_success = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":5804
 *             success = electron_comm.send_to_electron('idle_file_upload_failure', message_data)
 * 
 *             if success:             # <<<<<<<<<<<<<<
 *                 logger.info("[SUCCESS] Sent file upload failure message to Electron")
 *             else:
*/
      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_success); if (unlikely((__pyx_t_8 < 0))) __PYX_ERR(0, 5804, __pyx_L4_error)
      if (__pyx_t_8) {

        /* "ws_package/controllers/activity_controller.py":5805
 * 
 *             if success:
 *                 logger.info("[SUCCESS] Sent file upload failure message to Electron")             # <<<<<<<<<<<<<<
 *             else:
 *                 logger.warning("[FAILED] Failed to send file upload failure message to Electron")
*/
        __pyx_t_5 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5805, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 5805, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_6 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_10);
          assert(__pyx_t_5);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
          __pyx_t_6 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_SUCCESS_Sent_file_upload_failur};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5805, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":5804
 *             success = electron_comm.send_to_electron('idle_file_upload_failure', message_data)
 * 
 *             if success:             # <<<<<<<<<<<<<<
 *                 logger.info("[SUCCESS] Sent file upload failure message to Electron")
 *             else:
*/
        goto __pyx_L12;
      }

      /* "ws_package/controllers/activity_controller.py":5807
 *                 logger.info("[SUCCESS] Sent file upload failure message to Electron")
 *             else:
 *                 logger.warning("[FAILED] Failed to send file upload failure message to Electron")             # <<<<<<<<<<<<<<
 *             return success
 *         except Exception as e:
*/
      /*else*/ {
        __pyx_t_10 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5807, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 5807, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_6 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7);
          assert(__pyx_t_10);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
          __pyx_t_6 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_FAILED_Failed_to_send_file_uplo_2};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_6, (2-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5807, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }
      __pyx_L12:;

      /* "ws_package/controllers/activity_controller.py":5808
 *             else:
 *                 logger.warning("[FAILED] Failed to send file upload failure message to Electron")
 *             return success             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             logger.error("Error sending file upload failure message to Electron: %s", e, exc_info=True)
*/
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_success);
      __pyx_r = __pyx_cur_scope->__pyx_v_success;
      goto __pyx_L8_try_return;

      /* "ws_package/controllers/activity_controller.py":5785
 *     async def _send_file_upload_failure_to_electron(self):
 *         """Sends file upload failure message to Electron for UI notification."""
 *         try:             # <<<<<<<<<<<<<<
 *             electron_comm = self._get_electron_comm()
 * 
*/
    }
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "ws_package/controllers/activity_controller.py":5809
 *                 logger.warning("[FAILED] Failed to send file upload failure message to Electron")
 *             return success
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error sending file upload failure message to Electron: %s", e, exc_info=True)
 *             return False
*/
    __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_14) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._send_file_upload_failure_to_electron", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_7, &__pyx_t_10) < 0) __PYX_ERR(0, 5809, __pyx_L6_except_error)
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_7);
      __pyx_cur_scope->__pyx_v_e = __pyx_t_7;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":5810
 *             return success
 *         except Exception as e:
 *             logger.error("Error sending file upload failure message to Electron: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 *             return False
 * 
*/
        __pyx_t_13 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 5810, __pyx_L18_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5810, __pyx_L18_error)
        __Pyx_GOTREF(__pyx_t_12);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_6 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_12))) {
          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_12);
          assert(__pyx_t_13);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
          __pyx_t_6 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Error_sending_file_upload_failur, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_11 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 5810, __pyx_L18_error)
          __Pyx_GOTREF(__pyx_t_11);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_11, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 5810, __pyx_L18_error)
          __pyx_t_5 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_11);
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 5810, __pyx_L18_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":5811
 *         except Exception as e:
 *             logger.error("Error sending file upload failure message to Electron: %s", e, exc_info=True)
 *             return False             # <<<<<<<<<<<<<<
 * 
 *     async def check_idle_popup_timeout(self) -> bool:
*/
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_False);
        __pyx_r = Py_False;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L17_return;
      }

      /* "ws_package/controllers/activity_controller.py":5809
 *                 logger.warning("[FAILED] Failed to send file upload failure message to Electron")
 *             return success
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error sending file upload failure message to Electron: %s", e, exc_info=True)
 *             return False
*/
      /*finally:*/ {
        __pyx_L18_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
          if ( unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_17);
          __Pyx_XGOTREF(__pyx_t_18);
          __Pyx_XGOTREF(__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_22);
          __pyx_t_14 = __pyx_lineno; __pyx_t_15 = __pyx_clineno; __pyx_t_16 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_ErrRestore(__pyx_t_17, __pyx_t_18, __pyx_t_19);
          __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0;
          __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_16;
          goto __pyx_L6_except_error;
        }
        __pyx_L17_return: {
          __pyx_t_22 = __pyx_r;
          __pyx_r = 0;
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          __pyx_r = __pyx_t_22;
          __pyx_t_22 = 0;
          goto __pyx_L7_except_return;
        }
      }
    }
    goto __pyx_L6_except_error;

    /* "ws_package/controllers/activity_controller.py":5785
 *     async def _send_file_upload_failure_to_electron(self):
 *         """Sends file upload failure message to Electron for UI notification."""
 *         try:             # <<<<<<<<<<<<<<
 *             electron_comm = self._get_electron_comm()
 * 
*/
    __pyx_L6_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L7_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":5783
 *             return False
 * 
 *     async def _send_file_upload_failure_to_electron(self):             # <<<<<<<<<<<<<<
 *         """Sends file upload failure message to Electron for UI notification."""
 *         try:
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("_send_file_upload_failure_to_electron", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_194generator40(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":5813
 *             return False
 * 
 *     async def check_idle_popup_timeout(self) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Check if 60 minutes have passed since idle popup was triggered.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_193check_idle_popup_timeout(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_192check_idle_popup_timeout, "\n        Check if 60 minutes have passed since idle popup was triggered.\n        If timeout reached, auto-stop timer and mark all idle intervals as unkeep.\n        \n        Returns:\n            bool: True if timeout reached and auto-stop triggered, False otherwise\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_193check_idle_popup_timeout = {"check_idle_popup_timeout", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_193check_idle_popup_timeout, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_192check_idle_popup_timeout};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_193check_idle_popup_timeout(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[1] = {0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("check_idle_popup_timeout (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 5813, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 5813, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "check_idle_popup_timeout", 0) < (0)) __PYX_ERR(0, 5813, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("check_idle_popup_timeout", 1, 1, 1, i); __PYX_ERR(0, 5813, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 1)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 5813, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("check_idle_popup_timeout", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 5813, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.check_idle_popup_timeout", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_192check_idle_popup_timeout(__pyx_self, __pyx_v_self);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_192check_idle_popup_timeout(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("check_idle_popup_timeout", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 5813, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_194generator40, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[66]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_check_idle_popup_timeout, __pyx_mstate_global->__pyx_n_u_ActivityController_check_idle_po, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 5813, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.check_idle_popup_timeout", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_194generator40(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  size_t __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  __Pyx_PySendResult __pyx_t_18;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  PyObject *__pyx_t_26 = NULL;
  Py_ssize_t __pyx_t_27;
  PyObject *(*__pyx_t_28)(PyObject *);
  int __pyx_t_29;
  PyObject *__pyx_t_30 = NULL;
  int __pyx_t_31;
  int __pyx_t_32;
  char const *__pyx_t_33;
  char const *__pyx_t_34;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("check_idle_popup_timeout", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L26_resume_from_await;
    case 2: goto __pyx_L36_resume_from_await;
    case 3: goto __pyx_L42_resume_from_await;
    case 4: goto __pyx_L46_resume_from_await;
    case 5: goto __pyx_L47_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 5813, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":5821
 *             bool: True if timeout reached and auto-stop triggered, False otherwise
 *         """
 *         if is_silent_build():             # <<<<<<<<<<<<<<
 *             return False
 *         try:
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_is_silent_build); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5821, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
    __pyx_t_4 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5821, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 5821, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "ws_package/controllers/activity_controller.py":5822
 *         """
 *         if is_silent_build():
 *             return False             # <<<<<<<<<<<<<<
 *         try:
 *             if not self._idle_popup_active or self._idle_popup_triggered_at is None:
*/
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":5821
 *             bool: True if timeout reached and auto-stop triggered, False otherwise
 *         """
 *         if is_silent_build():             # <<<<<<<<<<<<<<
 *             return False
 *         try:
*/
  }

  /* "ws_package/controllers/activity_controller.py":5823
 *         if is_silent_build():
 *             return False
 *         try:             # <<<<<<<<<<<<<<
 *             if not self._idle_popup_active or self._idle_popup_triggered_at is None:
 *                 return False
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
    __Pyx_XGOTREF(__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_7);
    __Pyx_XGOTREF(__pyx_t_8);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":5824
 *             return False
 *         try:
 *             if not self._idle_popup_active or self._idle_popup_triggered_at is None:             # <<<<<<<<<<<<<<
 *                 return False
 * 
*/
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_active); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5824, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 5824, __pyx_L5_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_10 = (!__pyx_t_9);
      if (!__pyx_t_10) {
      } else {
        __pyx_t_5 = __pyx_t_10;
        goto __pyx_L12_bool_binop_done;
      }
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_triggered_at); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5824, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_10 = (__pyx_t_1 == Py_None);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_5 = __pyx_t_10;
      __pyx_L12_bool_binop_done:;
      if (__pyx_t_5) {

        /* "ws_package/controllers/activity_controller.py":5825
 *         try:
 *             if not self._idle_popup_active or self._idle_popup_triggered_at is None:
 *                 return False             # <<<<<<<<<<<<<<
 * 
 *             current_time = datetime.datetime.now()
*/
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_False);
        __pyx_r = Py_False;
        goto __pyx_L9_try_return;

        /* "ws_package/controllers/activity_controller.py":5824
 *             return False
 *         try:
 *             if not self._idle_popup_active or self._idle_popup_triggered_at is None:             # <<<<<<<<<<<<<<
 *                 return False
 * 
*/
      }

      /* "ws_package/controllers/activity_controller.py":5827
 *                 return False
 * 
 *             current_time = datetime.datetime.now()             # <<<<<<<<<<<<<<
 *             elapsed_seconds = (current_time - self._idle_popup_triggered_at).total_seconds()
 * 
*/
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5827, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 5827, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_11);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_3 = __pyx_t_11;
      __Pyx_INCREF(__pyx_t_3);
      __pyx_t_4 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
        __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5827, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_cur_scope->__pyx_v_current_time = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":5828
 * 
 *             current_time = datetime.datetime.now()
 *             elapsed_seconds = (current_time - self._idle_popup_triggered_at).total_seconds()             # <<<<<<<<<<<<<<
 * 
 *             logger.info("[IdleTimeout] Checking timeout: elapsed=%ss, limit=%ss", int(elapsed_seconds), self._idle_popup_timeout_seconds)
*/
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_triggered_at); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5828, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_3);
      __pyx_t_2 = PyNumber_Subtract(__pyx_cur_scope->__pyx_v_current_time, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5828, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_2);
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      __pyx_t_11 = __pyx_t_2;
      __Pyx_INCREF(__pyx_t_11);
      __pyx_t_4 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_11, NULL};
        __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_total_seconds, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5828, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_cur_scope->__pyx_v_elapsed_seconds = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":5830
 *             elapsed_seconds = (current_time - self._idle_popup_triggered_at).total_seconds()
 * 
 *             logger.info("[IdleTimeout] Checking timeout: elapsed=%ss, limit=%ss", int(elapsed_seconds), self._idle_popup_timeout_seconds)             # <<<<<<<<<<<<<<
 * 
 *             if elapsed_seconds >= self._idle_popup_timeout_seconds:
*/
      __pyx_t_2 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 5830, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5830, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
      __pyx_t_11 = __Pyx_PyNumber_Int(__pyx_cur_scope->__pyx_v_elapsed_seconds); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 5830, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_11);
      __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_timeout_seconds); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5830, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_4 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_3))) {
        __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
        assert(__pyx_t_2);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
        __Pyx_INCREF(__pyx_t_2);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
        __pyx_t_4 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[4] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_IdleTimeout_Checking_timeout_el, __pyx_t_11, __pyx_t_12};
        __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (4-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5830, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":5832
 *             logger.info("[IdleTimeout] Checking timeout: elapsed=%ss, limit=%ss", int(elapsed_seconds), self._idle_popup_timeout_seconds)
 * 
 *             if elapsed_seconds >= self._idle_popup_timeout_seconds:             # <<<<<<<<<<<<<<
 *                 logger.warning("[IdleTimeout]  TIMEOUT REACHED: %ss >= %ss - Auto-stopping timer", int(elapsed_seconds), self._idle_popup_timeout_seconds)
 * 
*/
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_timeout_seconds); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5832, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_3 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_elapsed_seconds, __pyx_t_1, Py_GE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5832, __pyx_L5_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 5832, __pyx_L5_error)
      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
      if (__pyx_t_5) {

        /* "ws_package/controllers/activity_controller.py":5833
 * 
 *             if elapsed_seconds >= self._idle_popup_timeout_seconds:
 *                 logger.warning("[IdleTimeout]  TIMEOUT REACHED: %ss >= %ss - Auto-stopping timer", int(elapsed_seconds), self._idle_popup_timeout_seconds)             # <<<<<<<<<<<<<<
 * 
 *                 # CRITICAL FIX: Mark ALL intervals created during idle popup period (from _idle_popup_triggered_at to now)
*/
        __pyx_t_1 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5833, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 5833, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_12 = __Pyx_PyNumber_Int(__pyx_cur_scope->__pyx_v_elapsed_seconds); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5833, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_timeout_seconds); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5833, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_11))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_11);
          assert(__pyx_t_1);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_11, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[4] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_IdleTimeout_TIMEOUT_REACHED_ss, __pyx_t_12, __pyx_t_2};
          __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_11, __pyx_callargs+__pyx_t_4, (4-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5833, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_3);
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "ws_package/controllers/activity_controller.py":5838
 *                 # as unkeep (is_uploaded=True). This includes both idle intervals AND intervals with activity
 *                 # that occurred while popup was active but not handled
 *                 with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                     async with async_session() as session:
 *                         # Query ALL intervals from popup trigger time onwards (not just idle ones)
*/
        /*with:*/ {
          __pyx_t_11 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5838, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5838, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_12);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_4 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_12))) {
            __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_12);
            assert(__pyx_t_11);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
            __Pyx_INCREF(__pyx_t_11);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
            __pyx_t_4 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_11, NULL};
            __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5838, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_3);
          }
          __pyx_t_13 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 5838, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_13);
          __pyx_t_11 = NULL;
          __pyx_t_2 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5838, __pyx_L15_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_4 = 1;
          #if CYTHON_UNPACK_METHODS
          if (likely(PyMethod_Check(__pyx_t_2))) {
            __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_2);
            assert(__pyx_t_11);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
            __Pyx_INCREF(__pyx_t_11);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
            __pyx_t_4 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_11, NULL};
            __pyx_t_12 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5838, __pyx_L15_error)
            __Pyx_GOTREF(__pyx_t_12);
          }
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          /*try:*/ {
            {
              __Pyx_ExceptionSave(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
              __Pyx_XGOTREF(__pyx_t_14);
              __Pyx_XGOTREF(__pyx_t_15);
              __Pyx_XGOTREF(__pyx_t_16);
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":5839
 *                 # that occurred while popup was active but not handled
 *                 with db_lock_manager.read_lock():
 *                     async with async_session() as session:             # <<<<<<<<<<<<<<
 *                         # Query ALL intervals from popup trigger time onwards (not just idle ones)
 *                         query = select(ActivityInterval).where(
*/
                /*with:*/ {
                  __pyx_t_12 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5839, __pyx_L19_error)
                  __Pyx_GOTREF(__pyx_t_2);
                  __pyx_t_4 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_2))) {
                    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_2);
                    assert(__pyx_t_12);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
                    __Pyx_INCREF(__pyx_t_12);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
                    __pyx_t_4 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_12, NULL};
                    __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                    if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5839, __pyx_L19_error)
                    __Pyx_GOTREF(__pyx_t_3);
                  }
                  __pyx_t_17 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 5839, __pyx_L19_error)
                  __Pyx_GOTREF(__pyx_t_17);
                  __pyx_t_12 = NULL;
                  __pyx_t_11 = __Pyx_PyObject_LookupSpecial(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 5839, __pyx_L25_error)
                  __Pyx_GOTREF(__pyx_t_11);
                  __pyx_t_4 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (likely(PyMethod_Check(__pyx_t_11))) {
                    __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_11);
                    assert(__pyx_t_12);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_11);
                    __Pyx_INCREF(__pyx_t_12);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_11, __pyx__function);
                    __pyx_t_4 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_12, NULL};
                    __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_11, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
                    if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5839, __pyx_L25_error)
                    __Pyx_GOTREF(__pyx_t_2);
                  }
                  __pyx_t_18 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_2, &__pyx_r);
                  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                  if (likely(__pyx_t_18 == PYGEN_NEXT)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_XGIVEREF(__pyx_t_3);
                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_3;
                    __Pyx_XGIVEREF(__pyx_t_6);
                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_6;
                    __Pyx_XGIVEREF(__pyx_t_7);
                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_7;
                    __Pyx_XGIVEREF(__pyx_t_8);
                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_8;
                    __Pyx_XGIVEREF(__pyx_t_13);
                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                    __Pyx_XGIVEREF(__pyx_t_14);
                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __pyx_cur_scope->__pyx_t_6 = __pyx_t_15;
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __pyx_cur_scope->__pyx_t_7 = __pyx_t_16;
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __pyx_cur_scope->__pyx_t_8 = __pyx_t_17;
                    __Pyx_XGIVEREF(__pyx_r);
                    __Pyx_RefNannyFinishContext();
                    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                    /* return from generator, awaiting value */
                    __pyx_generator->resume_label = 1;
                    return __pyx_r;
                    __pyx_L26_resume_from_await:;
                    __pyx_t_3 = __pyx_cur_scope->__pyx_t_0;
                    __pyx_cur_scope->__pyx_t_0 = 0;
                    __Pyx_XGOTREF(__pyx_t_3);
                    __pyx_t_6 = __pyx_cur_scope->__pyx_t_1;
                    __pyx_cur_scope->__pyx_t_1 = 0;
                    __Pyx_XGOTREF(__pyx_t_6);
                    __pyx_t_7 = __pyx_cur_scope->__pyx_t_2;
                    __pyx_cur_scope->__pyx_t_2 = 0;
                    __Pyx_XGOTREF(__pyx_t_7);
                    __pyx_t_8 = __pyx_cur_scope->__pyx_t_3;
                    __pyx_cur_scope->__pyx_t_3 = 0;
                    __Pyx_XGOTREF(__pyx_t_8);
                    __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                    __pyx_cur_scope->__pyx_t_4 = 0;
                    __Pyx_XGOTREF(__pyx_t_13);
                    __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                    __pyx_cur_scope->__pyx_t_5 = 0;
                    __Pyx_XGOTREF(__pyx_t_14);
                    __pyx_t_15 = __pyx_cur_scope->__pyx_t_6;
                    __pyx_cur_scope->__pyx_t_6 = 0;
                    __Pyx_XGOTREF(__pyx_t_15);
                    __pyx_t_16 = __pyx_cur_scope->__pyx_t_7;
                    __pyx_cur_scope->__pyx_t_7 = 0;
                    __Pyx_XGOTREF(__pyx_t_16);
                    __pyx_t_17 = __pyx_cur_scope->__pyx_t_8;
                    __pyx_cur_scope->__pyx_t_8 = 0;
                    __Pyx_XGOTREF(__pyx_t_17);
                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5839, __pyx_L25_error)
                    __pyx_t_2 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_2);
                  } else if (likely(__pyx_t_18 == PYGEN_RETURN)) {
                    __Pyx_GOTREF(__pyx_r);
                    __pyx_t_2 = __pyx_r; __pyx_r = NULL;
                  } else {
                    __Pyx_XGOTREF(__pyx_r);
                    __PYX_ERR(0, 5839, __pyx_L25_error)
                  }
                  __pyx_t_11 = __pyx_t_2;
                  __pyx_t_2 = 0;
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  /*try:*/ {
                    {
                      __Pyx_ExceptionSave(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21);
                      __Pyx_XGOTREF(__pyx_t_19);
                      __Pyx_XGOTREF(__pyx_t_20);
                      __Pyx_XGOTREF(__pyx_t_21);
                      /*try:*/ {
                        __Pyx_GIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_v_session = __pyx_t_11;
                        __pyx_t_11 = 0;

                        /* "ws_package/controllers/activity_controller.py":5841
 *                     async with async_session() as session:
 *                         # Query ALL intervals from popup trigger time onwards (not just idle ones)
 *                         query = select(ActivityInterval).where(             # <<<<<<<<<<<<<<
 *                             and_(
 *                                 ActivityInterval.counter == self.last_count + 1,
*/
                        __pyx_t_12 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5841, __pyx_L30_error)
                        __Pyx_GOTREF(__pyx_t_1);
                        __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 5841, __pyx_L30_error)
                        __Pyx_GOTREF(__pyx_t_22);
                        __pyx_t_4 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_1))) {
                          __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_1);
                          assert(__pyx_t_12);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
                          __Pyx_INCREF(__pyx_t_12);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
                          __pyx_t_4 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_12, __pyx_t_22};
                          __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                          __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5841, __pyx_L30_error)
                          __Pyx_GOTREF(__pyx_t_2);
                        }
                        __pyx_t_3 = __pyx_t_2;
                        __Pyx_INCREF(__pyx_t_3);

                        /* "ws_package/controllers/activity_controller.py":5842
 *                         # Query ALL intervals from popup trigger time onwards (not just idle ones)
 *                         query = select(ActivityInterval).where(
 *                             and_(             # <<<<<<<<<<<<<<
 *                                 ActivityInterval.counter == self.last_count + 1,
 *                                 ActivityInterval.start_time >= self._idle_popup_triggered_at,
*/
                        __pyx_t_22 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_and); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5842, __pyx_L30_error)
                        __Pyx_GOTREF(__pyx_t_12);

                        /* "ws_package/controllers/activity_controller.py":5843
 *                         query = select(ActivityInterval).where(
 *                             and_(
 *                                 ActivityInterval.counter == self.last_count + 1,             # <<<<<<<<<<<<<<
 *                                 ActivityInterval.start_time >= self._idle_popup_triggered_at,
 *                                 ActivityInterval.is_uploaded == False
*/
                        __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5843, __pyx_L30_error)
                        __Pyx_GOTREF(__pyx_t_23);
                        __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5843, __pyx_L30_error)
                        __Pyx_GOTREF(__pyx_t_24);
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5843, __pyx_L30_error)
                        __Pyx_GOTREF(__pyx_t_23);
                        __pyx_t_25 = __Pyx_PyLong_AddObjC(__pyx_t_23, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5843, __pyx_L30_error)
                        __Pyx_GOTREF(__pyx_t_25);
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __pyx_t_23 = PyObject_RichCompare(__pyx_t_24, __pyx_t_25, Py_EQ); __Pyx_XGOTREF(__pyx_t_23); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 5843, __pyx_L30_error)
                        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;

                        /* "ws_package/controllers/activity_controller.py":5844
 *                             and_(
 *                                 ActivityInterval.counter == self.last_count + 1,
 *                                 ActivityInterval.start_time >= self._idle_popup_triggered_at,             # <<<<<<<<<<<<<<
 *                                 ActivityInterval.is_uploaded == False
 *                             )
*/
                        __Pyx_GetModuleGlobalName(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5844, __pyx_L30_error)
                        __Pyx_GOTREF(__pyx_t_25);
                        __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5844, __pyx_L30_error)
                        __Pyx_GOTREF(__pyx_t_24);
                        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                        __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_triggered_at); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5844, __pyx_L30_error)
                        __Pyx_GOTREF(__pyx_t_25);
                        __pyx_t_26 = PyObject_RichCompare(__pyx_t_24, __pyx_t_25, Py_GE); __Pyx_XGOTREF(__pyx_t_26); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5844, __pyx_L30_error)
                        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;

                        /* "ws_package/controllers/activity_controller.py":5845
 *                                 ActivityInterval.counter == self.last_count + 1,
 *                                 ActivityInterval.start_time >= self._idle_popup_triggered_at,
 *                                 ActivityInterval.is_uploaded == False             # <<<<<<<<<<<<<<
 *                             )
 *                         )
*/
                        __Pyx_GetModuleGlobalName(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5845, __pyx_L30_error)
                        __Pyx_GOTREF(__pyx_t_25);
                        __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_is_uploaded); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 5845, __pyx_L30_error)
                        __Pyx_GOTREF(__pyx_t_24);
                        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                        __pyx_t_25 = PyObject_RichCompare(__pyx_t_24, Py_False, Py_EQ); __Pyx_XGOTREF(__pyx_t_25); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5845, __pyx_L30_error)
                        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __pyx_t_4 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_12))) {
                          __pyx_t_22 = PyMethod_GET_SELF(__pyx_t_12);
                          assert(__pyx_t_22);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
                          __Pyx_INCREF(__pyx_t_22);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
                          __pyx_t_4 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[4] = {__pyx_t_22, __pyx_t_23, __pyx_t_26, __pyx_t_25};
                          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_4, (4-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                          __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                          __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                          __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5842, __pyx_L30_error)
                          __Pyx_GOTREF(__pyx_t_1);
                        }
                        __pyx_t_4 = 0;
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_t_1};
                          __pyx_t_11 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 5841, __pyx_L30_error)
                          __Pyx_GOTREF(__pyx_t_11);
                        }
                        __Pyx_GIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_v_query = __pyx_t_11;
                        __pyx_t_11 = 0;

                        /* "ws_package/controllers/activity_controller.py":5848
 *                             )
 *                         )
 *                         result = await session.execute(query)             # <<<<<<<<<<<<<<
 *                         all_intervals = result.scalars().all()
 * 
*/
                        __pyx_t_2 = __pyx_cur_scope->__pyx_v_session;
                        __Pyx_INCREF(__pyx_t_2);
                        __pyx_t_4 = 0;
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_cur_scope->__pyx_v_query};
                          __pyx_t_11 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 5848, __pyx_L30_error)
                          __Pyx_GOTREF(__pyx_t_11);
                        }
                        __pyx_t_18 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_11, &__pyx_r);
                        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
                        if (likely(__pyx_t_18 == PYGEN_NEXT)) {
                          __Pyx_GOTREF(__pyx_r);
                          __Pyx_XGIVEREF(__pyx_t_6);
                          __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
                          __Pyx_XGIVEREF(__pyx_t_7);
                          __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
                          __Pyx_XGIVEREF(__pyx_t_8);
                          __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
                          __Pyx_XGIVEREF(__pyx_t_13);
                          __pyx_cur_scope->__pyx_t_3 = __pyx_t_13;
                          __Pyx_XGIVEREF(__pyx_t_14);
                          __pyx_cur_scope->__pyx_t_4 = __pyx_t_14;
                          __Pyx_XGIVEREF(__pyx_t_15);
                          __pyx_cur_scope->__pyx_t_5 = __pyx_t_15;
                          __Pyx_XGIVEREF(__pyx_t_16);
                          __pyx_cur_scope->__pyx_t_6 = __pyx_t_16;
                          __Pyx_XGIVEREF(__pyx_t_17);
                          __pyx_cur_scope->__pyx_t_7 = __pyx_t_17;
                          __Pyx_XGIVEREF(__pyx_t_19);
                          __pyx_cur_scope->__pyx_t_8 = __pyx_t_19;
                          __Pyx_XGIVEREF(__pyx_t_20);
                          __pyx_cur_scope->__pyx_t_9 = __pyx_t_20;
                          __Pyx_XGIVEREF(__pyx_t_21);
                          __pyx_cur_scope->__pyx_t_10 = __pyx_t_21;
                          __Pyx_XGIVEREF(__pyx_r);
                          __Pyx_RefNannyFinishContext();
                          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                          /* return from generator, awaiting value */
                          __pyx_generator->resume_label = 2;
                          return __pyx_r;
                          __pyx_L36_resume_from_await:;
                          __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
                          __pyx_cur_scope->__pyx_t_0 = 0;
                          __Pyx_XGOTREF(__pyx_t_6);
                          __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
                          __pyx_cur_scope->__pyx_t_1 = 0;
                          __Pyx_XGOTREF(__pyx_t_7);
                          __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
                          __pyx_cur_scope->__pyx_t_2 = 0;
                          __Pyx_XGOTREF(__pyx_t_8);
                          __pyx_t_13 = __pyx_cur_scope->__pyx_t_3;
                          __pyx_cur_scope->__pyx_t_3 = 0;
                          __Pyx_XGOTREF(__pyx_t_13);
                          __pyx_t_14 = __pyx_cur_scope->__pyx_t_4;
                          __pyx_cur_scope->__pyx_t_4 = 0;
                          __Pyx_XGOTREF(__pyx_t_14);
                          __pyx_t_15 = __pyx_cur_scope->__pyx_t_5;
                          __pyx_cur_scope->__pyx_t_5 = 0;
                          __Pyx_XGOTREF(__pyx_t_15);
                          __pyx_t_16 = __pyx_cur_scope->__pyx_t_6;
                          __pyx_cur_scope->__pyx_t_6 = 0;
                          __Pyx_XGOTREF(__pyx_t_16);
                          __pyx_t_17 = __pyx_cur_scope->__pyx_t_7;
                          __pyx_cur_scope->__pyx_t_7 = 0;
                          __Pyx_XGOTREF(__pyx_t_17);
                          __pyx_t_19 = __pyx_cur_scope->__pyx_t_8;
                          __pyx_cur_scope->__pyx_t_8 = 0;
                          __Pyx_XGOTREF(__pyx_t_19);
                          __pyx_t_20 = __pyx_cur_scope->__pyx_t_9;
                          __pyx_cur_scope->__pyx_t_9 = 0;
                          __Pyx_XGOTREF(__pyx_t_20);
                          __pyx_t_21 = __pyx_cur_scope->__pyx_t_10;
                          __pyx_cur_scope->__pyx_t_10 = 0;
                          __Pyx_XGOTREF(__pyx_t_21);
                          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5848, __pyx_L30_error)
                          __pyx_t_11 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_11);
                        } else if (likely(__pyx_t_18 == PYGEN_RETURN)) {
                          __Pyx_GOTREF(__pyx_r);
                          __pyx_t_11 = __pyx_r; __pyx_r = NULL;
                        } else {
                          __Pyx_XGOTREF(__pyx_r);
                          __PYX_ERR(0, 5848, __pyx_L30_error)
                        }
                        __Pyx_GIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_v_result = __pyx_t_11;
                        __pyx_t_11 = 0;

                        /* "ws_package/controllers/activity_controller.py":5849
 *                         )
 *                         result = await session.execute(query)
 *                         all_intervals = result.scalars().all()             # <<<<<<<<<<<<<<
 * 
 *                         if all_intervals:
*/
                        __pyx_t_3 = __pyx_cur_scope->__pyx_v_result;
                        __Pyx_INCREF(__pyx_t_3);
                        __pyx_t_4 = 0;
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
                          __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalars, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5849, __pyx_L30_error)
                          __Pyx_GOTREF(__pyx_t_1);
                        }
                        __pyx_t_2 = __pyx_t_1;
                        __Pyx_INCREF(__pyx_t_2);
                        __pyx_t_4 = 0;
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
                          __pyx_t_11 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_all, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 5849, __pyx_L30_error)
                          __Pyx_GOTREF(__pyx_t_11);
                        }
                        __Pyx_GIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_v_all_intervals = __pyx_t_11;
                        __pyx_t_11 = 0;

                        /* "ws_package/controllers/activity_controller.py":5851
 *                         all_intervals = result.scalars().all()
 * 
 *                         if all_intervals:             # <<<<<<<<<<<<<<
 *                             interval_ids = []
 *                             idle_count = 0
*/
                        __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_all_intervals); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 5851, __pyx_L30_error)
                        if (__pyx_t_5) {

                          /* "ws_package/controllers/activity_controller.py":5852
 * 
 *                         if all_intervals:
 *                             interval_ids = []             # <<<<<<<<<<<<<<
 *                             idle_count = 0
 *                             activity_count = 0
*/
                          __pyx_t_11 = PyList_New(0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 5852, __pyx_L30_error)
                          __Pyx_GOTREF(__pyx_t_11);
                          __Pyx_GIVEREF(__pyx_t_11);
                          __pyx_cur_scope->__pyx_v_interval_ids = ((PyObject*)__pyx_t_11);
                          __pyx_t_11 = 0;

                          /* "ws_package/controllers/activity_controller.py":5853
 *                         if all_intervals:
 *                             interval_ids = []
 *                             idle_count = 0             # <<<<<<<<<<<<<<
 *                             activity_count = 0
 *                             for interval in all_intervals:
*/
                          __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
                          __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_0);
                          __pyx_cur_scope->__pyx_v_idle_count = __pyx_mstate_global->__pyx_int_0;

                          /* "ws_package/controllers/activity_controller.py":5854
 *                             interval_ids = []
 *                             idle_count = 0
 *                             activity_count = 0             # <<<<<<<<<<<<<<
 *                             for interval in all_intervals:
 *                                 interval_ids.append(interval.id)
*/
                          __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
                          __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_0);
                          __pyx_cur_scope->__pyx_v_activity_count = __pyx_mstate_global->__pyx_int_0;

                          /* "ws_package/controllers/activity_controller.py":5855
 *                             idle_count = 0
 *                             activity_count = 0
 *                             for interval in all_intervals:             # <<<<<<<<<<<<<<
 *                                 interval_ids.append(interval.id)
 *                                 if interval.is_idle:
*/
                          if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_all_intervals)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_all_intervals)) {
                            __pyx_t_11 = __pyx_cur_scope->__pyx_v_all_intervals; __Pyx_INCREF(__pyx_t_11);
                            __pyx_t_27 = 0;
                            __pyx_t_28 = NULL;
                          } else {
                            __pyx_t_27 = -1; __pyx_t_11 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_all_intervals); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 5855, __pyx_L30_error)
                            __Pyx_GOTREF(__pyx_t_11);
                            __pyx_t_28 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_11); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 5855, __pyx_L30_error)
                          }
                          for (;;) {
                            if (likely(!__pyx_t_28)) {
                              if (likely(PyList_CheckExact(__pyx_t_11))) {
                                {
                                  Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_11);
                                  #if !CYTHON_ASSUME_SAFE_SIZE
                                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5855, __pyx_L30_error)
                                  #endif
                                  if (__pyx_t_27 >= __pyx_temp) break;
                                }
                                __pyx_t_1 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_11, __pyx_t_27, __Pyx_ReferenceSharing_OwnStrongReference);
                                ++__pyx_t_27;
                              } else {
                                {
                                  Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_11);
                                  #if !CYTHON_ASSUME_SAFE_SIZE
                                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 5855, __pyx_L30_error)
                                  #endif
                                  if (__pyx_t_27 >= __pyx_temp) break;
                                }
                                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                                __pyx_t_1 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_11, __pyx_t_27));
                                #else
                                __pyx_t_1 = __Pyx_PySequence_ITEM(__pyx_t_11, __pyx_t_27);
                                #endif
                                ++__pyx_t_27;
                              }
                              if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5855, __pyx_L30_error)
                            } else {
                              __pyx_t_1 = __pyx_t_28(__pyx_t_11);
                              if (unlikely(!__pyx_t_1)) {
                                PyObject* exc_type = PyErr_Occurred();
                                if (exc_type) {
                                  if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 5855, __pyx_L30_error)
                                  PyErr_Clear();
                                }
                                break;
                              }
                            }
                            __Pyx_GOTREF(__pyx_t_1);
                            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
                            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_1);
                            __Pyx_GIVEREF(__pyx_t_1);
                            __pyx_t_1 = 0;

                            /* "ws_package/controllers/activity_controller.py":5856
 *                             activity_count = 0
 *                             for interval in all_intervals:
 *                                 interval_ids.append(interval.id)             # <<<<<<<<<<<<<<
 *                                 if interval.is_idle:
 *                                     idle_count += 1
*/
                            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5856, __pyx_L30_error)
                            __Pyx_GOTREF(__pyx_t_1);
                            __pyx_t_29 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_interval_ids, __pyx_t_1); if (unlikely(__pyx_t_29 == ((int)-1))) __PYX_ERR(0, 5856, __pyx_L30_error)
                            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

                            /* "ws_package/controllers/activity_controller.py":5857
 *                             for interval in all_intervals:
 *                                 interval_ids.append(interval.id)
 *                                 if interval.is_idle:             # <<<<<<<<<<<<<<
 *                                     idle_count += 1
 *                                 else:
*/
                            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_is_idle); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5857, __pyx_L30_error)
                            __Pyx_GOTREF(__pyx_t_1);
                            __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 5857, __pyx_L30_error)
                            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                            if (__pyx_t_5) {

                              /* "ws_package/controllers/activity_controller.py":5858
 *                                 interval_ids.append(interval.id)
 *                                 if interval.is_idle:
 *                                     idle_count += 1             # <<<<<<<<<<<<<<
 *                                 else:
 *                                     activity_count += 1
*/
                              __pyx_t_1 = __Pyx_PyLong_AddObjC(__pyx_cur_scope->__pyx_v_idle_count, __pyx_mstate_global->__pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5858, __pyx_L30_error)
                              __Pyx_GOTREF(__pyx_t_1);
                              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_idle_count);
                              __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_idle_count, __pyx_t_1);
                              __Pyx_GIVEREF(__pyx_t_1);
                              __pyx_t_1 = 0;

                              /* "ws_package/controllers/activity_controller.py":5857
 *                             for interval in all_intervals:
 *                                 interval_ids.append(interval.id)
 *                                 if interval.is_idle:             # <<<<<<<<<<<<<<
 *                                     idle_count += 1
 *                                 else:
*/
                              goto __pyx_L40;
                            }

                            /* "ws_package/controllers/activity_controller.py":5860
 *                                     idle_count += 1
 *                                 else:
 *                                     activity_count += 1             # <<<<<<<<<<<<<<
 *                                 db_write_queue.enqueue(
 *                                     WriteOperationType.UPDATE_ACTIVITY_INTERVAL,
*/
                            /*else*/ {
                              __pyx_t_1 = __Pyx_PyLong_AddObjC(__pyx_cur_scope->__pyx_v_activity_count, __pyx_mstate_global->__pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5860, __pyx_L30_error)
                              __Pyx_GOTREF(__pyx_t_1);
                              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_activity_count);
                              __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_activity_count, __pyx_t_1);
                              __Pyx_GIVEREF(__pyx_t_1);
                              __pyx_t_1 = 0;
                            }
                            __pyx_L40:;

                            /* "ws_package/controllers/activity_controller.py":5861
 *                                 else:
 *                                     activity_count += 1
 *                                 db_write_queue.enqueue(             # <<<<<<<<<<<<<<
 *                                     WriteOperationType.UPDATE_ACTIVITY_INTERVAL,
 *                                     interval.id,
*/
                            __pyx_t_2 = NULL;
                            __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_db_write_queue); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5861, __pyx_L30_error)
                            __Pyx_GOTREF(__pyx_t_3);
                            __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_enqueue); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5861, __pyx_L30_error)
                            __Pyx_GOTREF(__pyx_t_12);
                            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                            /* "ws_package/controllers/activity_controller.py":5862
 *                                     activity_count += 1
 *                                 db_write_queue.enqueue(
 *                                     WriteOperationType.UPDATE_ACTIVITY_INTERVAL,             # <<<<<<<<<<<<<<
 *                                     interval.id,
 *                                     {'is_uploaded': True}
*/
                            __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_WriteOperationType); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5862, __pyx_L30_error)
                            __Pyx_GOTREF(__pyx_t_3);
                            __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_UPDATE_ACTIVITY_INTERVAL); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5862, __pyx_L30_error)
                            __Pyx_GOTREF(__pyx_t_25);
                            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

                            /* "ws_package/controllers/activity_controller.py":5863
 *                                 db_write_queue.enqueue(
 *                                     WriteOperationType.UPDATE_ACTIVITY_INTERVAL,
 *                                     interval.id,             # <<<<<<<<<<<<<<
 *                                     {'is_uploaded': True}
 *                                 )
*/
                            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5863, __pyx_L30_error)
                            __Pyx_GOTREF(__pyx_t_3);

                            /* "ws_package/controllers/activity_controller.py":5864
 *                                     WriteOperationType.UPDATE_ACTIVITY_INTERVAL,
 *                                     interval.id,
 *                                     {'is_uploaded': True}             # <<<<<<<<<<<<<<
 *                                 )
 * 
*/
                            __pyx_t_26 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5864, __pyx_L30_error)
                            __Pyx_GOTREF(__pyx_t_26);
                            if (PyDict_SetItem(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_is_uploaded, Py_True) < (0)) __PYX_ERR(0, 5864, __pyx_L30_error)
                            __pyx_t_4 = 1;
                            #if CYTHON_UNPACK_METHODS
                            if (unlikely(PyMethod_Check(__pyx_t_12))) {
                              __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_12);
                              assert(__pyx_t_2);
                              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
                              __Pyx_INCREF(__pyx_t_2);
                              __Pyx_INCREF(__pyx__function);
                              __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
                              __pyx_t_4 = 0;
                            }
                            #endif
                            {
                              PyObject *__pyx_callargs[4] = {__pyx_t_2, __pyx_t_25, __pyx_t_3, __pyx_t_26};
                              __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_4, (4-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                              __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                              __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                              if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5861, __pyx_L30_error)
                              __Pyx_GOTREF(__pyx_t_1);
                            }
                            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

                            /* "ws_package/controllers/activity_controller.py":5855
 *                             idle_count = 0
 *                             activity_count = 0
 *                             for interval in all_intervals:             # <<<<<<<<<<<<<<
 *                                 interval_ids.append(interval.id)
 *                                 if interval.is_idle:
*/
                          }
                          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

                          /* "ws_package/controllers/activity_controller.py":5867
 *                                 )
 * 
 *                             logger.warning("[IdleTimeout] Marking %s intervals from popup period as unkeep (is_uploaded=True): %s idle + %s with activity, interval_ids=%s%s", len(interval_ids), idle_count, activity_count, interval_ids, '...' if len(interval_ids) > 10 else '')             # <<<<<<<<<<<<<<
 * 
 *                             # Flush immediately
*/
                          __pyx_t_1 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5867, __pyx_L30_error)
                          __Pyx_GOTREF(__pyx_t_12);
                          __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5867, __pyx_L30_error)
                          __Pyx_GOTREF(__pyx_t_26);
                          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                          __pyx_t_27 = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_interval_ids); if (unlikely(__pyx_t_27 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5867, __pyx_L30_error)
                          __pyx_t_12 = PyLong_FromSsize_t(__pyx_t_27); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5867, __pyx_L30_error)
                          __Pyx_GOTREF(__pyx_t_12);
                          __pyx_t_27 = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_interval_ids); if (unlikely(__pyx_t_27 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5867, __pyx_L30_error)
                          __pyx_t_5 = (__pyx_t_27 > 10);
                          if (__pyx_t_5) {
                            __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u__13);
                            __pyx_t_3 = __pyx_mstate_global->__pyx_kp_u__13;
                          } else {
                            __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u__2);
                            __pyx_t_3 = __pyx_mstate_global->__pyx_kp_u__2;
                          }
                          __pyx_t_4 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_26))) {
                            __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_26);
                            assert(__pyx_t_1);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_26);
                            __Pyx_INCREF(__pyx_t_1);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_26, __pyx__function);
                            __pyx_t_4 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[7] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_IdleTimeout_Marking_s_intervals, __pyx_t_12, __pyx_cur_scope->__pyx_v_idle_count, __pyx_cur_scope->__pyx_v_activity_count, __pyx_cur_scope->__pyx_v_interval_ids, __pyx_t_3};
                            __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_26, __pyx_callargs+__pyx_t_4, (7-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                            __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                            if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 5867, __pyx_L30_error)
                            __Pyx_GOTREF(__pyx_t_11);
                          }
                          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

                          /* "ws_package/controllers/activity_controller.py":5870
 * 
 *                             # Flush immediately
 *                             await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 * 
 *                 # Clear popup state
*/
                          __pyx_t_26 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5870, __pyx_L30_error)
                          __Pyx_GOTREF(__pyx_t_3);
                          __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5870, __pyx_L30_error)
                          __Pyx_GOTREF(__pyx_t_12);
                          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                          __pyx_t_4 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_12))) {
                            __pyx_t_26 = PyMethod_GET_SELF(__pyx_t_12);
                            assert(__pyx_t_26);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
                            __Pyx_INCREF(__pyx_t_26);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
                            __pyx_t_4 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_26, NULL};
                            __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                            if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 5870, __pyx_L30_error)
                            __Pyx_GOTREF(__pyx_t_11);
                          }
                          __pyx_t_18 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_11, &__pyx_r);
                          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
                          if (likely(__pyx_t_18 == PYGEN_NEXT)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_XGIVEREF(__pyx_t_6);
                            __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
                            __Pyx_XGIVEREF(__pyx_t_7);
                            __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
                            __Pyx_XGIVEREF(__pyx_t_8);
                            __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
                            __Pyx_XGIVEREF(__pyx_t_13);
                            __pyx_cur_scope->__pyx_t_3 = __pyx_t_13;
                            __Pyx_XGIVEREF(__pyx_t_14);
                            __pyx_cur_scope->__pyx_t_4 = __pyx_t_14;
                            __Pyx_XGIVEREF(__pyx_t_15);
                            __pyx_cur_scope->__pyx_t_5 = __pyx_t_15;
                            __Pyx_XGIVEREF(__pyx_t_16);
                            __pyx_cur_scope->__pyx_t_6 = __pyx_t_16;
                            __Pyx_XGIVEREF(__pyx_t_17);
                            __pyx_cur_scope->__pyx_t_7 = __pyx_t_17;
                            __Pyx_XGIVEREF(__pyx_t_19);
                            __pyx_cur_scope->__pyx_t_8 = __pyx_t_19;
                            __Pyx_XGIVEREF(__pyx_t_20);
                            __pyx_cur_scope->__pyx_t_9 = __pyx_t_20;
                            __Pyx_XGIVEREF(__pyx_t_21);
                            __pyx_cur_scope->__pyx_t_10 = __pyx_t_21;
                            __Pyx_XGIVEREF(__pyx_r);
                            __Pyx_RefNannyFinishContext();
                            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                            /* return from generator, awaiting value */
                            __pyx_generator->resume_label = 3;
                            return __pyx_r;
                            __pyx_L42_resume_from_await:;
                            __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
                            __pyx_cur_scope->__pyx_t_0 = 0;
                            __Pyx_XGOTREF(__pyx_t_6);
                            __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
                            __pyx_cur_scope->__pyx_t_1 = 0;
                            __Pyx_XGOTREF(__pyx_t_7);
                            __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
                            __pyx_cur_scope->__pyx_t_2 = 0;
                            __Pyx_XGOTREF(__pyx_t_8);
                            __pyx_t_13 = __pyx_cur_scope->__pyx_t_3;
                            __pyx_cur_scope->__pyx_t_3 = 0;
                            __Pyx_XGOTREF(__pyx_t_13);
                            __pyx_t_14 = __pyx_cur_scope->__pyx_t_4;
                            __pyx_cur_scope->__pyx_t_4 = 0;
                            __Pyx_XGOTREF(__pyx_t_14);
                            __pyx_t_15 = __pyx_cur_scope->__pyx_t_5;
                            __pyx_cur_scope->__pyx_t_5 = 0;
                            __Pyx_XGOTREF(__pyx_t_15);
                            __pyx_t_16 = __pyx_cur_scope->__pyx_t_6;
                            __pyx_cur_scope->__pyx_t_6 = 0;
                            __Pyx_XGOTREF(__pyx_t_16);
                            __pyx_t_17 = __pyx_cur_scope->__pyx_t_7;
                            __pyx_cur_scope->__pyx_t_7 = 0;
                            __Pyx_XGOTREF(__pyx_t_17);
                            __pyx_t_19 = __pyx_cur_scope->__pyx_t_8;
                            __pyx_cur_scope->__pyx_t_8 = 0;
                            __Pyx_XGOTREF(__pyx_t_19);
                            __pyx_t_20 = __pyx_cur_scope->__pyx_t_9;
                            __pyx_cur_scope->__pyx_t_9 = 0;
                            __Pyx_XGOTREF(__pyx_t_20);
                            __pyx_t_21 = __pyx_cur_scope->__pyx_t_10;
                            __pyx_cur_scope->__pyx_t_10 = 0;
                            __Pyx_XGOTREF(__pyx_t_21);
                            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5870, __pyx_L30_error)
                          } else if (likely(__pyx_t_18 == PYGEN_RETURN)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                          } else {
                            __Pyx_XGOTREF(__pyx_r);
                            __PYX_ERR(0, 5870, __pyx_L30_error)
                          }

                          /* "ws_package/controllers/activity_controller.py":5851
 *                         all_intervals = result.scalars().all()
 * 
 *                         if all_intervals:             # <<<<<<<<<<<<<<
 *                             interval_ids = []
 *                             idle_count = 0
*/
                        }

                        /* "ws_package/controllers/activity_controller.py":5839
 *                 # that occurred while popup was active but not handled
 *                 with db_lock_manager.read_lock():
 *                     async with async_session() as session:             # <<<<<<<<<<<<<<
 *                         # Query ALL intervals from popup trigger time onwards (not just idle ones)
 *                         query = select(ActivityInterval).where(
*/
                      }
                      __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                      __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                      __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                      goto __pyx_L35_try_end;
                      __pyx_L30_error:;
                      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                      __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
                      __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                      __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                      __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                      __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                      __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                      __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                      __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                      /*except:*/ {
                        __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.check_idle_popup_timeout", __pyx_clineno, __pyx_lineno, __pyx_filename);
                        if (__Pyx_GetException(&__pyx_t_11, &__pyx_t_12, &__pyx_t_26) < 0) __PYX_ERR(0, 5839, __pyx_L32_except_error)
                        __Pyx_XGOTREF(__pyx_t_11);
                        __Pyx_XGOTREF(__pyx_t_12);
                        __Pyx_XGOTREF(__pyx_t_26);
                        __pyx_t_3 = PyTuple_Pack(3, __pyx_t_11, __pyx_t_12, __pyx_t_26); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5839, __pyx_L32_except_error)
                        __Pyx_GOTREF(__pyx_t_3);
                        __pyx_t_30 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_t_3, NULL);
                        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                        if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 5839, __pyx_L32_except_error)
                        __Pyx_GOTREF(__pyx_t_30);
                        __pyx_t_18 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_30, &__pyx_r);
                        __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
                        if (likely(__pyx_t_18 == PYGEN_NEXT)) {
                          __Pyx_GOTREF(__pyx_r);
                          __Pyx_XGIVEREF(__pyx_t_6);
                          __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
                          __Pyx_XGIVEREF(__pyx_t_7);
                          __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
                          __Pyx_XGIVEREF(__pyx_t_8);
                          __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
                          __Pyx_XGIVEREF(__pyx_t_11);
                          __pyx_cur_scope->__pyx_t_3 = __pyx_t_11;
                          __Pyx_XGIVEREF(__pyx_t_12);
                          __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                          __Pyx_XGIVEREF(__pyx_t_13);
                          __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                          __Pyx_XGIVEREF(__pyx_t_14);
                          __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                          __Pyx_XGIVEREF(__pyx_t_15);
                          __pyx_cur_scope->__pyx_t_7 = __pyx_t_15;
                          __Pyx_XGIVEREF(__pyx_t_16);
                          __pyx_cur_scope->__pyx_t_8 = __pyx_t_16;
                          __Pyx_XGIVEREF(__pyx_t_17);
                          __pyx_cur_scope->__pyx_t_9 = __pyx_t_17;
                          __Pyx_XGIVEREF(__pyx_t_19);
                          __pyx_cur_scope->__pyx_t_10 = __pyx_t_19;
                          __Pyx_XGIVEREF(__pyx_t_20);
                          __pyx_cur_scope->__pyx_t_11 = __pyx_t_20;
                          __Pyx_XGIVEREF(__pyx_t_21);
                          __pyx_cur_scope->__pyx_t_12 = __pyx_t_21;
                          __Pyx_XGIVEREF(__pyx_t_26);
                          __pyx_cur_scope->__pyx_t_13 = __pyx_t_26;
                          __Pyx_XGIVEREF(__pyx_t_30);
                          __pyx_cur_scope->__pyx_t_14 = __pyx_t_30;
                          __Pyx_XGIVEREF(__pyx_r);
                          __Pyx_RefNannyFinishContext();
                          __Pyx_Coroutine_SwapException(__pyx_generator);
                          /* return from generator, awaiting value */
                          __pyx_generator->resume_label = 4;
                          return __pyx_r;
                          __pyx_L46_resume_from_await:;
                          __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
                          __pyx_cur_scope->__pyx_t_0 = 0;
                          __Pyx_XGOTREF(__pyx_t_6);
                          __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
                          __pyx_cur_scope->__pyx_t_1 = 0;
                          __Pyx_XGOTREF(__pyx_t_7);
                          __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
                          __pyx_cur_scope->__pyx_t_2 = 0;
                          __Pyx_XGOTREF(__pyx_t_8);
                          __pyx_t_11 = __pyx_cur_scope->__pyx_t_3;
                          __pyx_cur_scope->__pyx_t_3 = 0;
                          __Pyx_XGOTREF(__pyx_t_11);
                          __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                          __pyx_cur_scope->__pyx_t_4 = 0;
                          __Pyx_XGOTREF(__pyx_t_12);
                          __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                          __pyx_cur_scope->__pyx_t_5 = 0;
                          __Pyx_XGOTREF(__pyx_t_13);
                          __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                          __pyx_cur_scope->__pyx_t_6 = 0;
                          __Pyx_XGOTREF(__pyx_t_14);
                          __pyx_t_15 = __pyx_cur_scope->__pyx_t_7;
                          __pyx_cur_scope->__pyx_t_7 = 0;
                          __Pyx_XGOTREF(__pyx_t_15);
                          __pyx_t_16 = __pyx_cur_scope->__pyx_t_8;
                          __pyx_cur_scope->__pyx_t_8 = 0;
                          __Pyx_XGOTREF(__pyx_t_16);
                          __pyx_t_17 = __pyx_cur_scope->__pyx_t_9;
                          __pyx_cur_scope->__pyx_t_9 = 0;
                          __Pyx_XGOTREF(__pyx_t_17);
                          __pyx_t_19 = __pyx_cur_scope->__pyx_t_10;
                          __pyx_cur_scope->__pyx_t_10 = 0;
                          __Pyx_XGOTREF(__pyx_t_19);
                          __pyx_t_20 = __pyx_cur_scope->__pyx_t_11;
                          __pyx_cur_scope->__pyx_t_11 = 0;
                          __Pyx_XGOTREF(__pyx_t_20);
                          __pyx_t_21 = __pyx_cur_scope->__pyx_t_12;
                          __pyx_cur_scope->__pyx_t_12 = 0;
                          __Pyx_XGOTREF(__pyx_t_21);
                          __pyx_t_26 = __pyx_cur_scope->__pyx_t_13;
                          __pyx_cur_scope->__pyx_t_13 = 0;
                          __Pyx_XGOTREF(__pyx_t_26);
                          __pyx_t_30 = __pyx_cur_scope->__pyx_t_14;
                          __pyx_cur_scope->__pyx_t_14 = 0;
                          __Pyx_XGOTREF(__pyx_t_30);
                          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5839, __pyx_L32_except_error)
                          __pyx_t_3 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_3);
                        } else if (likely(__pyx_t_18 == PYGEN_RETURN)) {
                          __Pyx_GOTREF(__pyx_r);
                          __pyx_t_3 = __pyx_r; __pyx_r = NULL;
                        } else {
                          __Pyx_XGOTREF(__pyx_r);
                          __PYX_ERR(0, 5839, __pyx_L32_except_error)
                        }
                        __pyx_t_30 = __pyx_t_3;
                        __pyx_t_3 = 0;
                        __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_30);
                        __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
                        if (__pyx_t_5 < (0)) __PYX_ERR(0, 5839, __pyx_L32_except_error)
                        __pyx_t_10 = (!__pyx_t_5);
                        if (unlikely(__pyx_t_10)) {
                          __Pyx_GIVEREF(__pyx_t_11);
                          __Pyx_GIVEREF(__pyx_t_12);
                          __Pyx_XGIVEREF(__pyx_t_26);
                          __Pyx_ErrRestoreWithState(__pyx_t_11, __pyx_t_12, __pyx_t_26);
                          __pyx_t_11 = 0;  __pyx_t_12 = 0;  __pyx_t_26 = 0; 
                          __PYX_ERR(0, 5839, __pyx_L32_except_error)
                        }
                        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
                        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                        __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                        goto __pyx_L31_exception_handled;
                      }
                      __pyx_L32_except_error:;
                      __Pyx_XGIVEREF(__pyx_t_19);
                      __Pyx_XGIVEREF(__pyx_t_20);
                      __Pyx_XGIVEREF(__pyx_t_21);
                      __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21);
                      goto __pyx_L19_error;
                      __pyx_L31_exception_handled:;
                      __Pyx_XGIVEREF(__pyx_t_19);
                      __Pyx_XGIVEREF(__pyx_t_20);
                      __Pyx_XGIVEREF(__pyx_t_21);
                      __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21);
                      __pyx_L35_try_end:;
                    }
                  }
                  /*finally:*/ {
                    /*normal exit:*/{
                      if (__pyx_t_17) {
                        __pyx_t_21 = __Pyx_PyObject_Call(__pyx_t_17, __pyx_mstate_global->__pyx_tuple[7], NULL);
                        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                        if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 5839, __pyx_L19_error)
                        __Pyx_GOTREF(__pyx_t_21);
                        __pyx_t_18 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_21, &__pyx_r);
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        if (likely(__pyx_t_18 == PYGEN_NEXT)) {
                          __Pyx_GOTREF(__pyx_r);
                          __Pyx_XGIVEREF(__pyx_t_6);
                          __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
                          __Pyx_XGIVEREF(__pyx_t_7);
                          __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
                          __Pyx_XGIVEREF(__pyx_t_8);
                          __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
                          __Pyx_XGIVEREF(__pyx_t_13);
                          __pyx_cur_scope->__pyx_t_3 = __pyx_t_13;
                          __Pyx_XGIVEREF(__pyx_t_14);
                          __pyx_cur_scope->__pyx_t_4 = __pyx_t_14;
                          __Pyx_XGIVEREF(__pyx_t_15);
                          __pyx_cur_scope->__pyx_t_5 = __pyx_t_15;
                          __Pyx_XGIVEREF(__pyx_t_16);
                          __pyx_cur_scope->__pyx_t_6 = __pyx_t_16;
                          __Pyx_XGIVEREF(__pyx_t_17);
                          __pyx_cur_scope->__pyx_t_7 = __pyx_t_17;
                          __Pyx_XGIVEREF(__pyx_t_21);
                          __pyx_cur_scope->__pyx_t_8 = __pyx_t_21;
                          __Pyx_XGIVEREF(__pyx_r);
                          __Pyx_RefNannyFinishContext();
                          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                          /* return from generator, awaiting value */
                          __pyx_generator->resume_label = 5;
                          return __pyx_r;
                          __pyx_L47_resume_from_await:;
                          __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
                          __pyx_cur_scope->__pyx_t_0 = 0;
                          __Pyx_XGOTREF(__pyx_t_6);
                          __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
                          __pyx_cur_scope->__pyx_t_1 = 0;
                          __Pyx_XGOTREF(__pyx_t_7);
                          __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
                          __pyx_cur_scope->__pyx_t_2 = 0;
                          __Pyx_XGOTREF(__pyx_t_8);
                          __pyx_t_13 = __pyx_cur_scope->__pyx_t_3;
                          __pyx_cur_scope->__pyx_t_3 = 0;
                          __Pyx_XGOTREF(__pyx_t_13);
                          __pyx_t_14 = __pyx_cur_scope->__pyx_t_4;
                          __pyx_cur_scope->__pyx_t_4 = 0;
                          __Pyx_XGOTREF(__pyx_t_14);
                          __pyx_t_15 = __pyx_cur_scope->__pyx_t_5;
                          __pyx_cur_scope->__pyx_t_5 = 0;
                          __Pyx_XGOTREF(__pyx_t_15);
                          __pyx_t_16 = __pyx_cur_scope->__pyx_t_6;
                          __pyx_cur_scope->__pyx_t_6 = 0;
                          __Pyx_XGOTREF(__pyx_t_16);
                          __pyx_t_17 = __pyx_cur_scope->__pyx_t_7;
                          __pyx_cur_scope->__pyx_t_7 = 0;
                          __Pyx_XGOTREF(__pyx_t_17);
                          __pyx_t_21 = __pyx_cur_scope->__pyx_t_8;
                          __pyx_cur_scope->__pyx_t_8 = 0;
                          __Pyx_XGOTREF(__pyx_t_21);
                          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5839, __pyx_L19_error)
                          __pyx_t_26 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_26);
                        } else if (likely(__pyx_t_18 == PYGEN_RETURN)) {
                          __Pyx_GOTREF(__pyx_r);
                          __pyx_t_26 = __pyx_r; __pyx_r = NULL;
                        } else {
                          __Pyx_XGOTREF(__pyx_r);
                          __PYX_ERR(0, 5839, __pyx_L19_error)
                        }
                        __pyx_t_21 = __pyx_t_26;
                        __pyx_t_26 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                      }
                      goto __pyx_L29;
                    }
                    __pyx_L29:;
                  }
                  goto __pyx_L48;
                  __pyx_L25_error:;
                  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                  goto __pyx_L19_error;
                  __pyx_L48:;
                }

                /* "ws_package/controllers/activity_controller.py":5838
 *                 # as unkeep (is_uploaded=True). This includes both idle intervals AND intervals with activity
 *                 # that occurred while popup was active but not handled
 *                 with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                     async with async_session() as session:
 *                         # Query ALL intervals from popup trigger time onwards (not just idle ones)
*/
              }
              __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
              __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
              goto __pyx_L24_try_end;
              __pyx_L19_error:;
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
              __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
              __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
              __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              /*except:*/ {
                __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.check_idle_popup_timeout", __pyx_clineno, __pyx_lineno, __pyx_filename);
                if (__Pyx_GetException(&__pyx_t_26, &__pyx_t_12, &__pyx_t_11) < 0) __PYX_ERR(0, 5838, __pyx_L21_except_error)
                __Pyx_XGOTREF(__pyx_t_26);
                __Pyx_XGOTREF(__pyx_t_12);
                __Pyx_XGOTREF(__pyx_t_11);
                __pyx_t_3 = PyTuple_Pack(3, __pyx_t_26, __pyx_t_12, __pyx_t_11); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5838, __pyx_L21_except_error)
                __Pyx_GOTREF(__pyx_t_3);
                __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_3, NULL);
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 5838, __pyx_L21_except_error)
                __Pyx_GOTREF(__pyx_t_17);
                __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_17);
                __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                if (__pyx_t_10 < (0)) __PYX_ERR(0, 5838, __pyx_L21_except_error)
                __pyx_t_5 = (!__pyx_t_10);
                if (unlikely(__pyx_t_5)) {
                  __Pyx_GIVEREF(__pyx_t_26);
                  __Pyx_GIVEREF(__pyx_t_12);
                  __Pyx_XGIVEREF(__pyx_t_11);
                  __Pyx_ErrRestoreWithState(__pyx_t_26, __pyx_t_12, __pyx_t_11);
                  __pyx_t_26 = 0;  __pyx_t_12 = 0;  __pyx_t_11 = 0; 
                  __PYX_ERR(0, 5838, __pyx_L21_except_error)
                }
                __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
                goto __pyx_L20_exception_handled;
              }
              __pyx_L21_except_error:;
              __Pyx_XGIVEREF(__pyx_t_14);
              __Pyx_XGIVEREF(__pyx_t_15);
              __Pyx_XGIVEREF(__pyx_t_16);
              __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
              goto __pyx_L5_error;
              __pyx_L20_exception_handled:;
              __Pyx_XGIVEREF(__pyx_t_14);
              __Pyx_XGIVEREF(__pyx_t_15);
              __Pyx_XGIVEREF(__pyx_t_16);
              __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
              __pyx_L24_try_end:;
            }
          }
          /*finally:*/ {
            /*normal exit:*/{
              if (__pyx_t_13) {
                __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_mstate_global->__pyx_tuple[7], NULL);
                __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
                if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 5838, __pyx_L5_error)
                __Pyx_GOTREF(__pyx_t_16);
                __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
              }
              goto __pyx_L18;
            }
            __pyx_L18:;
          }
          goto __pyx_L52;
          __pyx_L15_error:;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          goto __pyx_L5_error;
          __pyx_L52:;
        }

        /* "ws_package/controllers/activity_controller.py":5873
 * 
 *                 # Clear popup state
 *                 self._idle_popup_active = False             # <<<<<<<<<<<<<<
 *                 self._idle_popup_triggered_at = None
 *                 self._api_pause_active = False
*/
        if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_active, Py_False) < (0)) __PYX_ERR(0, 5873, __pyx_L5_error)

        /* "ws_package/controllers/activity_controller.py":5874
 *                 # Clear popup state
 *                 self._idle_popup_active = False
 *                 self._idle_popup_triggered_at = None             # <<<<<<<<<<<<<<
 *                 self._api_pause_active = False
 *                 # Stop saving new intervals; Electron must send a real stop so
*/
        if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_triggered_at, Py_None) < (0)) __PYX_ERR(0, 5874, __pyx_L5_error)

        /* "ws_package/controllers/activity_controller.py":5875
 *                 self._idle_popup_active = False
 *                 self._idle_popup_triggered_at = None
 *                 self._api_pause_active = False             # <<<<<<<<<<<<<<
 *                 # Stop saving new intervals; Electron must send a real stop so
 *                 # monitoring_started / threads are cleared (do NOT set force_stop
*/
        if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_api_pause_active, Py_False) < (0)) __PYX_ERR(0, 5875, __pyx_L5_error)

        /* "ws_package/controllers/activity_controller.py":5879
 *                 # monitoring_started / threads are cleared (do NOT set force_stop
 *                 # that sticks across restart and blocks the next Start).
 *                 self.status = False             # <<<<<<<<<<<<<<
 * 
 *                 logger.warning("[IdleTimeout] Timer stopped due to unhandled idle popup (60 minutes timeout)")
*/
        if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_status, Py_False) < (0)) __PYX_ERR(0, 5879, __pyx_L5_error)

        /* "ws_package/controllers/activity_controller.py":5881
 *                 self.status = False
 * 
 *                 logger.warning("[IdleTimeout] Timer stopped due to unhandled idle popup (60 minutes timeout)")             # <<<<<<<<<<<<<<
 * 
 *                 # Ask Electron to drive the normal stop path (idle_popup_response /
*/
        __pyx_t_12 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5881, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_26);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5881, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_3);
          assert(__pyx_t_12);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_12);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_12, __pyx_mstate_global->__pyx_kp_u_IdleTimeout_Timer_stopped_due_t};
          __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 5881, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_11);
        }
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

        /* "ws_package/controllers/activity_controller.py":5887
 *                 # MonitorThread would restart push within ~60s and leave a half-stopped
 *                 # session that fails the next Start with MONITORING_NOT_STARTED.
 *                 try:             # <<<<<<<<<<<<<<
 *                     electron_comm = self._get_electron_comm()
 *                     if electron_comm and electron_comm.is_connected():
*/
        {
          __Pyx_ExceptionSave(&__pyx_t_13, &__pyx_t_16, &__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_16);
          __Pyx_XGOTREF(__pyx_t_15);
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":5888
 *                 # session that fails the next Start with MONITORING_NOT_STARTED.
 *                 try:
 *                     electron_comm = self._get_electron_comm()             # <<<<<<<<<<<<<<
 *                     if electron_comm and electron_comm.is_connected():
 *                         electron_comm.send_to_electron('idle_timeout_auto_stop', {
*/
            __pyx_t_3 = __pyx_cur_scope->__pyx_v_self;
            __Pyx_INCREF(__pyx_t_3);
            __pyx_t_4 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
              __pyx_t_11 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_electron_comm_2, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 5888, __pyx_L53_error)
              __Pyx_GOTREF(__pyx_t_11);
            }
            __Pyx_GIVEREF(__pyx_t_11);
            __pyx_cur_scope->__pyx_v_electron_comm = __pyx_t_11;
            __pyx_t_11 = 0;

            /* "ws_package/controllers/activity_controller.py":5889
 *                 try:
 *                     electron_comm = self._get_electron_comm()
 *                     if electron_comm and electron_comm.is_connected():             # <<<<<<<<<<<<<<
 *                         electron_comm.send_to_electron('idle_timeout_auto_stop', {
 *                             'message': 'Your system has been idle for 60 minutes thus timer has stopped automatically...',
*/
            __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_electron_comm); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 5889, __pyx_L53_error)
            if (__pyx_t_10) {
            } else {
              __pyx_t_5 = __pyx_t_10;
              goto __pyx_L60_bool_binop_done;
            }
            __pyx_t_3 = __pyx_cur_scope->__pyx_v_electron_comm;
            __Pyx_INCREF(__pyx_t_3);
            __pyx_t_4 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
              __pyx_t_11 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_connected, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 5889, __pyx_L53_error)
              __Pyx_GOTREF(__pyx_t_11);
            }
            __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 5889, __pyx_L53_error)
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            __pyx_t_5 = __pyx_t_10;
            __pyx_L60_bool_binop_done:;
            if (__pyx_t_5) {

              /* "ws_package/controllers/activity_controller.py":5890
 *                     electron_comm = self._get_electron_comm()
 *                     if electron_comm and electron_comm.is_connected():
 *                         electron_comm.send_to_electron('idle_timeout_auto_stop', {             # <<<<<<<<<<<<<<
 *                             'message': 'Your system has been idle for 60 minutes thus timer has stopped automatically...',
 *                             'timestamp': current_time.isoformat(),
*/
              __pyx_t_3 = __pyx_cur_scope->__pyx_v_electron_comm;
              __Pyx_INCREF(__pyx_t_3);

              /* "ws_package/controllers/activity_controller.py":5891
 *                     if electron_comm and electron_comm.is_connected():
 *                         electron_comm.send_to_electron('idle_timeout_auto_stop', {
 *                             'message': 'Your system has been idle for 60 minutes thus timer has stopped automatically...',             # <<<<<<<<<<<<<<
 *                             'timestamp': current_time.isoformat(),
 *                         })
*/
              __pyx_t_12 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5891, __pyx_L53_error)
              __Pyx_GOTREF(__pyx_t_12);
              if (PyDict_SetItem(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_message, __pyx_mstate_global->__pyx_kp_u_Your_system_has_been_idle_for_60) < (0)) __PYX_ERR(0, 5891, __pyx_L53_error)

              /* "ws_package/controllers/activity_controller.py":5892
 *                         electron_comm.send_to_electron('idle_timeout_auto_stop', {
 *                             'message': 'Your system has been idle for 60 minutes thus timer has stopped automatically...',
 *                             'timestamp': current_time.isoformat(),             # <<<<<<<<<<<<<<
 *                         })
 *                         logger.info("[IdleTimeout] Sent auto-stop signal to Electron")
*/
              __pyx_t_1 = __pyx_cur_scope->__pyx_v_current_time;
              __Pyx_INCREF(__pyx_t_1);
              __pyx_t_4 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
                __pyx_t_26 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_isoformat, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5892, __pyx_L53_error)
                __Pyx_GOTREF(__pyx_t_26);
              }
              if (PyDict_SetItem(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_timestamp, __pyx_t_26) < (0)) __PYX_ERR(0, 5891, __pyx_L53_error)
              __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
              __pyx_t_4 = 0;
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_mstate_global->__pyx_n_u_idle_timeout_auto_stop, __pyx_t_12};
                __pyx_t_11 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_send_to_electron, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 5890, __pyx_L53_error)
                __Pyx_GOTREF(__pyx_t_11);
              }
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

              /* "ws_package/controllers/activity_controller.py":5894
 *                             'timestamp': current_time.isoformat(),
 *                         })
 *                         logger.info("[IdleTimeout] Sent auto-stop signal to Electron")             # <<<<<<<<<<<<<<
 *                 except Exception as e:
 *                     logger.error("[IdleTimeout] Error sending auto-stop signal to Electron: %s", e, exc_info=True)
*/
              __pyx_t_12 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5894, __pyx_L53_error)
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 5894, __pyx_L53_error)
              __Pyx_GOTREF(__pyx_t_26);
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              __pyx_t_4 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_26))) {
                __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_26);
                assert(__pyx_t_12);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_26);
                __Pyx_INCREF(__pyx_t_12);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_26, __pyx__function);
                __pyx_t_4 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_12, __pyx_mstate_global->__pyx_kp_u_IdleTimeout_Sent_auto_stop_sign};
                __pyx_t_11 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_26, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 5894, __pyx_L53_error)
                __Pyx_GOTREF(__pyx_t_11);
              }
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

              /* "ws_package/controllers/activity_controller.py":5889
 *                 try:
 *                     electron_comm = self._get_electron_comm()
 *                     if electron_comm and electron_comm.is_connected():             # <<<<<<<<<<<<<<
 *                         electron_comm.send_to_electron('idle_timeout_auto_stop', {
 *                             'message': 'Your system has been idle for 60 minutes thus timer has stopped automatically...',
*/
            }

            /* "ws_package/controllers/activity_controller.py":5887
 *                 # MonitorThread would restart push within ~60s and leave a half-stopped
 *                 # session that fails the next Start with MONITORING_NOT_STARTED.
 *                 try:             # <<<<<<<<<<<<<<
 *                     electron_comm = self._get_electron_comm()
 *                     if electron_comm and electron_comm.is_connected():
*/
          }
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          goto __pyx_L58_try_end;
          __pyx_L53_error:;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
          __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
          __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

          /* "ws_package/controllers/activity_controller.py":5895
 *                         })
 *                         logger.info("[IdleTimeout] Sent auto-stop signal to Electron")
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("[IdleTimeout] Error sending auto-stop signal to Electron: %s", e, exc_info=True)
 * 
*/
          __pyx_t_31 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
          if (__pyx_t_31) {
            __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.check_idle_popup_timeout", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_11, &__pyx_t_26, &__pyx_t_12) < 0) __PYX_ERR(0, 5895, __pyx_L55_except_error)
            __Pyx_XGOTREF(__pyx_t_11);
            __Pyx_XGOTREF(__pyx_t_26);
            __Pyx_XGOTREF(__pyx_t_12);
            __Pyx_INCREF(__pyx_t_26);
            __Pyx_GIVEREF(__pyx_t_26);
            __pyx_cur_scope->__pyx_v_e = __pyx_t_26;
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":5896
 *                         logger.info("[IdleTimeout] Sent auto-stop signal to Electron")
 *                 except Exception as e:
 *                     logger.error("[IdleTimeout] Error sending auto-stop signal to Electron: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *                 return True
*/
              __pyx_t_1 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5896, __pyx_L67_error)
              __Pyx_GOTREF(__pyx_t_25);
              __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5896, __pyx_L67_error)
              __Pyx_GOTREF(__pyx_t_2);
              __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
              __pyx_t_4 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_2))) {
                __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
                assert(__pyx_t_1);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
                __Pyx_INCREF(__pyx_t_1);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
                __pyx_t_4 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_IdleTimeout_Error_sending_auto, __pyx_cur_scope->__pyx_v_e};
                __pyx_t_25 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5896, __pyx_L67_error)
                __Pyx_GOTREF(__pyx_t_25);
                if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_25, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 5896, __pyx_L67_error)
                __pyx_t_3 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_25);
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5896, __pyx_L67_error)
                __Pyx_GOTREF(__pyx_t_3);
              }
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            }

            /* "ws_package/controllers/activity_controller.py":5895
 *                         })
 *                         logger.info("[IdleTimeout] Sent auto-stop signal to Electron")
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("[IdleTimeout] Error sending auto-stop signal to Electron: %s", e, exc_info=True)
 * 
*/
            /*finally:*/ {
              /*normal exit:*/{
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                goto __pyx_L68;
              }
              __pyx_L67_error:;
              /*exception exit:*/{
                __Pyx_PyThreadState_assign
                __pyx_t_14 = 0; __pyx_t_17 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_30 = 0;
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                 __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_19, &__pyx_t_30);
                if ( unlikely(__Pyx_GetException(&__pyx_t_14, &__pyx_t_17, &__pyx_t_21) < 0)) __Pyx_ErrFetch(&__pyx_t_14, &__pyx_t_17, &__pyx_t_21);
                __Pyx_XGOTREF(__pyx_t_14);
                __Pyx_XGOTREF(__pyx_t_17);
                __Pyx_XGOTREF(__pyx_t_21);
                __Pyx_XGOTREF(__pyx_t_20);
                __Pyx_XGOTREF(__pyx_t_19);
                __Pyx_XGOTREF(__pyx_t_30);
                __pyx_t_31 = __pyx_lineno; __pyx_t_32 = __pyx_clineno; __pyx_t_33 = __pyx_filename;
                {
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                }
                __Pyx_XGIVEREF(__pyx_t_20);
                __Pyx_XGIVEREF(__pyx_t_19);
                __Pyx_XGIVEREF(__pyx_t_30);
                __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_19, __pyx_t_30);
                __Pyx_XGIVEREF(__pyx_t_14);
                __Pyx_XGIVEREF(__pyx_t_17);
                __Pyx_XGIVEREF(__pyx_t_21);
                __Pyx_ErrRestore(__pyx_t_14, __pyx_t_17, __pyx_t_21);
                __pyx_t_14 = 0; __pyx_t_17 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_30 = 0;
                __pyx_lineno = __pyx_t_31; __pyx_clineno = __pyx_t_32; __pyx_filename = __pyx_t_33;
                goto __pyx_L55_except_error;
              }
              __pyx_L68:;
            }
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            goto __pyx_L54_exception_handled;
          }
          goto __pyx_L55_except_error;

          /* "ws_package/controllers/activity_controller.py":5887
 *                 # MonitorThread would restart push within ~60s and leave a half-stopped
 *                 # session that fails the next Start with MONITORING_NOT_STARTED.
 *                 try:             # <<<<<<<<<<<<<<
 *                     electron_comm = self._get_electron_comm()
 *                     if electron_comm and electron_comm.is_connected():
*/
          __pyx_L55_except_error:;
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_16);
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_16, __pyx_t_15);
          goto __pyx_L5_error;
          __pyx_L54_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_16);
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_16, __pyx_t_15);
          __pyx_L58_try_end:;
        }

        /* "ws_package/controllers/activity_controller.py":5898
 *                     logger.error("[IdleTimeout] Error sending auto-stop signal to Electron: %s", e, exc_info=True)
 * 
 *                 return True             # <<<<<<<<<<<<<<
 * 
 *             return False
*/
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_True);
        __pyx_r = Py_True;
        goto __pyx_L9_try_return;

        /* "ws_package/controllers/activity_controller.py":5832
 *             logger.info("[IdleTimeout] Checking timeout: elapsed=%ss, limit=%ss", int(elapsed_seconds), self._idle_popup_timeout_seconds)
 * 
 *             if elapsed_seconds >= self._idle_popup_timeout_seconds:             # <<<<<<<<<<<<<<
 *                 logger.warning("[IdleTimeout]  TIMEOUT REACHED: %ss >= %ss - Auto-stopping timer", int(elapsed_seconds), self._idle_popup_timeout_seconds)
 * 
*/
      }

      /* "ws_package/controllers/activity_controller.py":5900
 *                 return True
 * 
 *             return False             # <<<<<<<<<<<<<<
 * 
 *         except Exception as e:
*/
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_False);
      __pyx_r = Py_False;
      goto __pyx_L9_try_return;

      /* "ws_package/controllers/activity_controller.py":5823
 *         if is_silent_build():
 *             return False
 *         try:             # <<<<<<<<<<<<<<
 *             if not self._idle_popup_active or self._idle_popup_triggered_at is None:
 *                 return False
*/
    }
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
    __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
    __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

    /* "ws_package/controllers/activity_controller.py":5902
 *             return False
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("[IdleTimeout] Error checking idle popup timeout: %s", e, exc_info=True)
 *             return False
*/
    __pyx_t_32 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_32) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.check_idle_popup_timeout", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_12, &__pyx_t_26, &__pyx_t_11) < 0) __PYX_ERR(0, 5902, __pyx_L7_except_error)
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_26);
      __Pyx_XGOTREF(__pyx_t_11);
      __Pyx_INCREF(__pyx_t_26);
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_26);
      __Pyx_GIVEREF(__pyx_t_26);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":5903
 * 
 *         except Exception as e:
 *             logger.error("[IdleTimeout] Error checking idle popup timeout: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 *             return False
 * 
*/
        __pyx_t_2 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5903, __pyx_L78_error)
        __Pyx_GOTREF(__pyx_t_25);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_25, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5903, __pyx_L78_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
          assert(__pyx_t_2);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_IdleTimeout_Error_checking_idle, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_25 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 5903, __pyx_L78_error)
          __Pyx_GOTREF(__pyx_t_25);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_25, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 5903, __pyx_L78_error)
          __pyx_t_3 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_25);
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5903, __pyx_L78_error)
          __Pyx_GOTREF(__pyx_t_3);
        }
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "ws_package/controllers/activity_controller.py":5904
 *         except Exception as e:
 *             logger.error("[IdleTimeout] Error checking idle popup timeout: %s", e, exc_info=True)
 *             return False             # <<<<<<<<<<<<<<
 * 
 *     async def arise_idle_popup(self):
*/
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_False);
        __pyx_r = Py_False;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
        goto __pyx_L77_return;
      }

      /* "ws_package/controllers/activity_controller.py":5902
 *             return False
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("[IdleTimeout] Error checking idle popup timeout: %s", e, exc_info=True)
 *             return False
*/
      /*finally:*/ {
        __pyx_L78_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_13 = 0; __pyx_t_30 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
          __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_30, &__pyx_t_19, &__pyx_t_20);
          if ( unlikely(__Pyx_GetException(&__pyx_t_15, &__pyx_t_16, &__pyx_t_13) < 0)) __Pyx_ErrFetch(&__pyx_t_15, &__pyx_t_16, &__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_16);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_30);
          __Pyx_XGOTREF(__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_20);
          __pyx_t_32 = __pyx_lineno; __pyx_t_31 = __pyx_clineno; __pyx_t_34 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_30);
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_ExceptionReset(__pyx_t_30, __pyx_t_19, __pyx_t_20);
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_XGIVEREF(__pyx_t_16);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_ErrRestore(__pyx_t_15, __pyx_t_16, __pyx_t_13);
          __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_13 = 0; __pyx_t_30 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0;
          __pyx_lineno = __pyx_t_32; __pyx_clineno = __pyx_t_31; __pyx_filename = __pyx_t_34;
          goto __pyx_L7_except_error;
        }
        __pyx_L77_return: {
          __pyx_t_20 = __pyx_r;
          __pyx_r = 0;
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          __pyx_r = __pyx_t_20;
          __pyx_t_20 = 0;
          goto __pyx_L8_except_return;
        }
      }
    }
    goto __pyx_L7_except_error;

    /* "ws_package/controllers/activity_controller.py":5823
 *         if is_silent_build():
 *             return False
 *         try:             # <<<<<<<<<<<<<<
 *             if not self._idle_popup_active or self._idle_popup_triggered_at is None:
 *                 return False
*/
    __pyx_L7_except_error:;
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
    goto __pyx_L1_error;
    __pyx_L9_try_return:;
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
    goto __pyx_L0;
    __pyx_L8_except_return:;
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
    goto __pyx_L0;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":5813
 *             return False
 * 
 *     async def check_idle_popup_timeout(self) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Check if 60 minutes have passed since idle popup was triggered.
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_XDECREF(__pyx_t_23);
  __Pyx_XDECREF(__pyx_t_24);
  __Pyx_XDECREF(__pyx_t_25);
  __Pyx_XDECREF(__pyx_t_26);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("check_idle_popup_timeout", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_197generator41(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":5906
 *             return False
 * 
 *     async def arise_idle_popup(self):             # <<<<<<<<<<<<<<
 *         """
 *         Trigger idle popup in Electron app.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_196arise_idle_popup(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_195arise_idle_popup, "\n        Trigger idle popup in Electron app.\n        This method sends a message to Electron to display the idle popup.\n        Includes debounce mechanism to prevent duplicate triggers and retry logic for TCP disconnections.\n        \n        NEW REQUIREMENT: \n        - If 2 consecutive idle intervals found, show popup\n        - While popup active, block server uploads\n        - Check 60-minute timeout for auto-stop\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_196arise_idle_popup = {"arise_idle_popup", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_196arise_idle_popup, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_195arise_idle_popup};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_196arise_idle_popup(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[1] = {0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("arise_idle_popup (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 5906, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 5906, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "arise_idle_popup", 0) < (0)) __PYX_ERR(0, 5906, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("arise_idle_popup", 1, 1, 1, i); __PYX_ERR(0, 5906, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 1)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 5906, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("arise_idle_popup", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 5906, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.arise_idle_popup", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_195arise_idle_popup(__pyx_self, __pyx_v_self);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_195arise_idle_popup(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("arise_idle_popup", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 5906, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_197generator41, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[67]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_arise_idle_popup, __pyx_mstate_global->__pyx_n_u_ActivityController_arise_idle_po, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 5906, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.arise_idle_popup", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_197generator41(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  size_t __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  __Pyx_PySendResult __pyx_t_10;
  int __pyx_t_11;
  PyObject *(*__pyx_t_12)(PyObject *);
  Py_ssize_t __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_t_18;
  int __pyx_t_19;
  char const *__pyx_t_20;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  PyObject *__pyx_t_26 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("arise_idle_popup", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L11_resume_from_await;
    case 2: goto __pyx_L24_resume_from_await;
    case 3: goto __pyx_L25_resume_from_await;
    case 4: goto __pyx_L28_resume_from_await;
    case 5: goto __pyx_L30_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 5906, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":5917
 *         - Check 60-minute timeout for auto-stop
 *         """
 *         if is_silent_build():             # <<<<<<<<<<<<<<
 *             return
 *         try:
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_is_silent_build); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5917, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
    __pyx_t_4 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5917, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 5917, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "ws_package/controllers/activity_controller.py":5918
 *         """
 *         if is_silent_build():
 *             return             # <<<<<<<<<<<<<<
 *         try:
 *             logger.info("[IdlePopup] arise_idle_popup() called - checking conditions before sending trigger to Electron")
*/
    __Pyx_XDECREF(__pyx_r);
    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":5917
 *         - Check 60-minute timeout for auto-stop
 *         """
 *         if is_silent_build():             # <<<<<<<<<<<<<<
 *             return
 *         try:
*/
  }

  /* "ws_package/controllers/activity_controller.py":5919
 *         if is_silent_build():
 *             return
 *         try:             # <<<<<<<<<<<<<<
 *             logger.info("[IdlePopup] arise_idle_popup() called - checking conditions before sending trigger to Electron")
 * 
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
    __Pyx_XGOTREF(__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_7);
    __Pyx_XGOTREF(__pyx_t_8);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":5920
 *             return
 *         try:
 *             logger.info("[IdlePopup] arise_idle_popup() called - checking conditions before sending trigger to Electron")             # <<<<<<<<<<<<<<
 * 
 *             # Check 60-minute timeout first
*/
      __pyx_t_3 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5920, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5920, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_4 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_9);
        assert(__pyx_t_3);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
        __pyx_t_4 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_IdlePopup_arise_idle_popup_call};
        __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5920, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":5923
 * 
 *             # Check 60-minute timeout first
 *             timeout_reached = await self.check_idle_popup_timeout()             # <<<<<<<<<<<<<<
 *             if timeout_reached:
 *                 logger.warning("[IdlePopup] Timeout reached - auto-stop triggered, skipping popup")
*/
      __pyx_t_9 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_9);
      __pyx_t_4 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_9, NULL};
        __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_check_idle_popup_timeout, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5923, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_1);
      }
      __pyx_t_10 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (likely(__pyx_t_10 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_6);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
        __Pyx_XGIVEREF(__pyx_t_7);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
        __Pyx_XGIVEREF(__pyx_t_8);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 1;
        return __pyx_r;
        __pyx_L11_resume_from_await:;
        __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_6);
        __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_7);
        __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_8);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5923, __pyx_L5_error)
        __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
      } else if (likely(__pyx_t_10 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __pyx_t_1 = __pyx_r; __pyx_r = NULL;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 5923, __pyx_L5_error)
      }
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_cur_scope->__pyx_v_timeout_reached = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":5924
 *             # Check 60-minute timeout first
 *             timeout_reached = await self.check_idle_popup_timeout()
 *             if timeout_reached:             # <<<<<<<<<<<<<<
 *                 logger.warning("[IdlePopup] Timeout reached - auto-stop triggered, skipping popup")
 *                 return
*/
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_timeout_reached); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 5924, __pyx_L5_error)
      if (__pyx_t_5) {

        /* "ws_package/controllers/activity_controller.py":5925
 *             timeout_reached = await self.check_idle_popup_timeout()
 *             if timeout_reached:
 *                 logger.warning("[IdlePopup] Timeout reached - auto-stop triggered, skipping popup")             # <<<<<<<<<<<<<<
 *                 return
 * 
*/
        __pyx_t_9 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5925, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5925, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2);
          assert(__pyx_t_9);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_mstate_global->__pyx_kp_u_IdlePopup_Timeout_reached_auto};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5925, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":5926
 *             if timeout_reached:
 *                 logger.warning("[IdlePopup] Timeout reached - auto-stop triggered, skipping popup")
 *                 return             # <<<<<<<<<<<<<<
 * 
 *             if self._idle_popup_active and self._idle_popup_triggered_at is not None:
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
        goto __pyx_L9_try_return;

        /* "ws_package/controllers/activity_controller.py":5924
 *             # Check 60-minute timeout first
 *             timeout_reached = await self.check_idle_popup_timeout()
 *             if timeout_reached:             # <<<<<<<<<<<<<<
 *                 logger.warning("[IdlePopup] Timeout reached - auto-stop triggered, skipping popup")
 *                 return
*/
      }

      /* "ws_package/controllers/activity_controller.py":5928
 *                 return
 * 
 *             if self._idle_popup_active and self._idle_popup_triggered_at is not None:             # <<<<<<<<<<<<<<
 *                 logger.info(
 *                     "[IdlePopup] Popup already active (triggered_at=%s)  not sending another trigger",
*/
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_active); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5928, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 5928, __pyx_L5_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_11) {
      } else {
        __pyx_t_5 = __pyx_t_11;
        goto __pyx_L14_bool_binop_done;
      }
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_triggered_at); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5928, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_11 = (__pyx_t_1 != Py_None);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_5 = __pyx_t_11;
      __pyx_L14_bool_binop_done:;
      if (__pyx_t_5) {

        /* "ws_package/controllers/activity_controller.py":5929
 * 
 *             if self._idle_popup_active and self._idle_popup_triggered_at is not None:
 *                 logger.info(             # <<<<<<<<<<<<<<
 *                     "[IdlePopup] Popup already active (triggered_at=%s)  not sending another trigger",
 *                     self._idle_popup_triggered_at,
*/
        __pyx_t_2 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5929, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5929, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

        /* "ws_package/controllers/activity_controller.py":5931
 *                 logger.info(
 *                     "[IdlePopup] Popup already active (triggered_at=%s)  not sending another trigger",
 *                     self._idle_popup_triggered_at,             # <<<<<<<<<<<<<<
 *                 )
 *                 return
*/
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_triggered_at); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5931, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_3))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
          assert(__pyx_t_2);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_IdlePopup_Popup_already_active, __pyx_t_9};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5929, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":5933
 *                     self._idle_popup_triggered_at,
 *                 )
 *                 return             # <<<<<<<<<<<<<<
 * 
 *             # CRITICAL: Never trigger idle popup when break session is active (away time)
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
        goto __pyx_L9_try_return;

        /* "ws_package/controllers/activity_controller.py":5928
 *                 return
 * 
 *             if self._idle_popup_active and self._idle_popup_triggered_at is not None:             # <<<<<<<<<<<<<<
 *                 logger.info(
 *                     "[IdlePopup] Popup already active (triggered_at=%s)  not sending another trigger",
*/
      }

      /* "ws_package/controllers/activity_controller.py":5936
 * 
 *             # CRITICAL: Never trigger idle popup when break session is active (away time)
 *             current_break_id = getattr(self, 'break_id', 0)             # <<<<<<<<<<<<<<
 *             if current_break_id != 0 or self.is_break != 0:
 *                 logger.info("[IdlePopup] Break session is active (break_id=%s, is_break=%s) - skipping idle popup trigger", current_break_id, self.is_break)
*/
      __pyx_t_1 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_break_id, __pyx_mstate_global->__pyx_int_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5936, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_cur_scope->__pyx_v_current_break_id = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":5937
 *             # CRITICAL: Never trigger idle popup when break session is active (away time)
 *             current_break_id = getattr(self, 'break_id', 0)
 *             if current_break_id != 0 or self.is_break != 0:             # <<<<<<<<<<<<<<
 *                 logger.info("[IdlePopup] Break session is active (break_id=%s, is_break=%s) - skipping idle popup trigger", current_break_id, self.is_break)
 *                 return
*/
      __pyx_t_11 = (__Pyx_PyLong_BoolNeObjC(__pyx_cur_scope->__pyx_v_current_break_id, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 5937, __pyx_L5_error)
      if (!__pyx_t_11) {
      } else {
        __pyx_t_5 = __pyx_t_11;
        goto __pyx_L17_bool_binop_done;
      }
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_is_break); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5937, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_11 = (__Pyx_PyLong_BoolNeObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_0, 0, 0)); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 5937, __pyx_L5_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_5 = __pyx_t_11;
      __pyx_L17_bool_binop_done:;
      if (__pyx_t_5) {

        /* "ws_package/controllers/activity_controller.py":5938
 *             current_break_id = getattr(self, 'break_id', 0)
 *             if current_break_id != 0 or self.is_break != 0:
 *                 logger.info("[IdlePopup] Break session is active (break_id=%s, is_break=%s) - skipping idle popup trigger", current_break_id, self.is_break)             # <<<<<<<<<<<<<<
 *                 return
 * 
*/
        __pyx_t_3 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5938, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5938, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_is_break); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5938, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
          assert(__pyx_t_3);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[4] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_IdlePopup_Break_session_is_acti, __pyx_cur_scope->__pyx_v_current_break_id, __pyx_t_9};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_4, (4-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5938, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":5939
 *             if current_break_id != 0 or self.is_break != 0:
 *                 logger.info("[IdlePopup] Break session is active (break_id=%s, is_break=%s) - skipping idle popup trigger", current_break_id, self.is_break)
 *                 return             # <<<<<<<<<<<<<<
 * 
 *             # No cooldown: Python sends trigger every time 2+ consecutive idle intervals detected.
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
        goto __pyx_L9_try_return;

        /* "ws_package/controllers/activity_controller.py":5937
 *             # CRITICAL: Never trigger idle popup when break session is active (away time)
 *             current_break_id = getattr(self, 'break_id', 0)
 *             if current_break_id != 0 or self.is_break != 0:             # <<<<<<<<<<<<<<
 *                 logger.info("[IdlePopup] Break session is active (break_id=%s, is_break=%s) - skipping idle popup trigger", current_break_id, self.is_break)
 *                 return
*/
      }

      /* "ws_package/controllers/activity_controller.py":5945
 *             # First popup's response (keep/unkeep/stop/continue) handles ALL consecutive idle intervals.
 * 
 *             current_time = datetime.datetime.now()             # <<<<<<<<<<<<<<
 *             electron_comm = self._get_electron_comm()
 * 
*/
      __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5945, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5945, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_3);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_2 = __pyx_t_3;
      __Pyx_INCREF(__pyx_t_2);
      __pyx_t_4 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
        __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5945, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_cur_scope->__pyx_v_current_time = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":5946
 * 
 *             current_time = datetime.datetime.now()
 *             electron_comm = self._get_electron_comm()             # <<<<<<<<<<<<<<
 * 
 *             # Check if IPC server is running
*/
      __pyx_t_3 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_3);
      __pyx_t_4 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
        __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_electron_comm_2, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5946, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_1);
      }
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_cur_scope->__pyx_v_electron_comm = __pyx_t_1;
      __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":5949
 * 
 *             # Check if IPC server is running
 *             if not is_ipc_ready():             # <<<<<<<<<<<<<<
 *                 logger.error("[IdlePopup] IPC server is not running - cannot send idle popup. IPC server may not have started properly.")
 *                 return
*/
      __pyx_t_3 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_is_ipc_ready); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5949, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_2))) {
        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
        assert(__pyx_t_3);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
        __Pyx_INCREF(__pyx_t_3);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
        __pyx_t_4 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
        __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5949, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_1);
      }
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 5949, __pyx_L5_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_11 = (!__pyx_t_5);
      if (__pyx_t_11) {

        /* "ws_package/controllers/activity_controller.py":5950
 *             # Check if IPC server is running
 *             if not is_ipc_ready():
 *                 logger.error("[IdlePopup] IPC server is not running - cannot send idle popup. IPC server may not have started properly.")             # <<<<<<<<<<<<<<
 *                 return
 * 
*/
        __pyx_t_2 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5950, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5950, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_9);
          assert(__pyx_t_2);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_IdlePopup_IPC_server_is_not_run};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5950, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":5951
 *             if not is_ipc_ready():
 *                 logger.error("[IdlePopup] IPC server is not running - cannot send idle popup. IPC server may not have started properly.")
 *                 return             # <<<<<<<<<<<<<<
 * 
 *             # Retry logic: Try sending with exponential backoff if IPC is not connected
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
        goto __pyx_L9_try_return;

        /* "ws_package/controllers/activity_controller.py":5949
 * 
 *             # Check if IPC server is running
 *             if not is_ipc_ready():             # <<<<<<<<<<<<<<
 *                 logger.error("[IdlePopup] IPC server is not running - cannot send idle popup. IPC server may not have started properly.")
 *                 return
*/
      }

      /* "ws_package/controllers/activity_controller.py":5954
 * 
 *             # Retry logic: Try sending with exponential backoff if IPC is not connected
 *             max_retries = 10  # Increased retries to give more time for connection             # <<<<<<<<<<<<<<
 *             retry_delays = [0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 6.0, 8.0, 10.0]  # Longer delays, more attempts
 *             success = False
*/
      __Pyx_INCREF(__pyx_mstate_global->__pyx_int_10);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_10);
      __pyx_cur_scope->__pyx_v_max_retries = __pyx_mstate_global->__pyx_int_10;

      /* "ws_package/controllers/activity_controller.py":5955
 *             # Retry logic: Try sending with exponential backoff if IPC is not connected
 *             max_retries = 10  # Increased retries to give more time for connection
 *             retry_delays = [0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 6.0, 8.0, 10.0]  # Longer delays, more attempts             # <<<<<<<<<<<<<<
 *             success = False
 * 
*/
      __pyx_t_1 = PyList_New(10); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5955, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_float_0_5);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_float_0_5);
      if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 0, __pyx_mstate_global->__pyx_float_0_5) != (0)) __PYX_ERR(0, 5955, __pyx_L5_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_float_1_0);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_float_1_0);
      if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 1, __pyx_mstate_global->__pyx_float_1_0) != (0)) __PYX_ERR(0, 5955, __pyx_L5_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_float_1_5);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_float_1_5);
      if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 2, __pyx_mstate_global->__pyx_float_1_5) != (0)) __PYX_ERR(0, 5955, __pyx_L5_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_float_2_0);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_float_2_0);
      if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 3, __pyx_mstate_global->__pyx_float_2_0) != (0)) __PYX_ERR(0, 5955, __pyx_L5_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_float_3_0);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_float_3_0);
      if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 4, __pyx_mstate_global->__pyx_float_3_0) != (0)) __PYX_ERR(0, 5955, __pyx_L5_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_float_4_0);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_float_4_0);
      if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 5, __pyx_mstate_global->__pyx_float_4_0) != (0)) __PYX_ERR(0, 5955, __pyx_L5_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_float_5_0);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_float_5_0);
      if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 6, __pyx_mstate_global->__pyx_float_5_0) != (0)) __PYX_ERR(0, 5955, __pyx_L5_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_float_6_0);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_float_6_0);
      if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 7, __pyx_mstate_global->__pyx_float_6_0) != (0)) __PYX_ERR(0, 5955, __pyx_L5_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_float_8_0);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_float_8_0);
      if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 8, __pyx_mstate_global->__pyx_float_8_0) != (0)) __PYX_ERR(0, 5955, __pyx_L5_error);
      __Pyx_INCREF(__pyx_mstate_global->__pyx_float_10_0);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_float_10_0);
      if (__Pyx_PyList_SET_ITEM(__pyx_t_1, 9, __pyx_mstate_global->__pyx_float_10_0) != (0)) __PYX_ERR(0, 5955, __pyx_L5_error);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_cur_scope->__pyx_v_retry_delays = ((PyObject*)__pyx_t_1);
      __pyx_t_1 = 0;

      /* "ws_package/controllers/activity_controller.py":5956
 *             max_retries = 10  # Increased retries to give more time for connection
 *             retry_delays = [0.5, 1.0, 1.5, 2.0, 3.0, 4.0, 5.0, 6.0, 8.0, 10.0]  # Longer delays, more attempts
 *             success = False             # <<<<<<<<<<<<<<
 * 
 *             for attempt in range(max_retries):
*/
      __Pyx_INCREF(Py_False);
      __Pyx_GIVEREF(Py_False);
      __pyx_cur_scope->__pyx_v_success = Py_False;

      /* "ws_package/controllers/activity_controller.py":5958
 *             success = False
 * 
 *             for attempt in range(max_retries):             # <<<<<<<<<<<<<<
 *                 # Check if connected before attempting to send
 *                 is_connected = electron_comm.is_connected()
*/
      __pyx_t_9 = NULL;
      __pyx_t_4 = 1;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_cur_scope->__pyx_v_max_retries};
        __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)(&PyRange_Type), __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5958, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_1);
      }
      __pyx_t_9 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 5958, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_12 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_9); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 5958, __pyx_L5_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      for (;;) {
        {
          __pyx_t_1 = __pyx_t_12(__pyx_t_9);
          if (unlikely(!__pyx_t_1)) {
            PyObject* exc_type = PyErr_Occurred();
            if (exc_type) {
              if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 5958, __pyx_L5_error)
              PyErr_Clear();
            }
            break;
          }
        }
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_attempt);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_attempt, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":5960
 *             for attempt in range(max_retries):
 *                 # Check if connected before attempting to send
 *                 is_connected = electron_comm.is_connected()             # <<<<<<<<<<<<<<
 * 
 *                 if not is_connected:
*/
        __pyx_t_2 = __pyx_cur_scope->__pyx_v_electron_comm;
        __Pyx_INCREF(__pyx_t_2);
        __pyx_t_4 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
          __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_connected, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5960, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_is_connected);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_is_connected, __pyx_t_1);
        __Pyx_GIVEREF(__pyx_t_1);
        __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":5962
 *                 is_connected = electron_comm.is_connected()
 * 
 *                 if not is_connected:             # <<<<<<<<<<<<<<
 *                     if attempt < max_retries - 1:
 *                         delay = retry_delays[attempt] if attempt < len(retry_delays) else 10.0
*/
        __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_is_connected); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 5962, __pyx_L5_error)
        __pyx_t_5 = (!__pyx_t_11);
        if (__pyx_t_5) {

          /* "ws_package/controllers/activity_controller.py":5963
 * 
 *                 if not is_connected:
 *                     if attempt < max_retries - 1:             # <<<<<<<<<<<<<<
 *                         delay = retry_delays[attempt] if attempt < len(retry_delays) else 10.0
 *                         logger.info("IPC not connected for idle popup (attempt %s/%s), IPC server ready: %s, retrying in %ss...",
*/
          __pyx_t_1 = __Pyx_PyLong_SubtractObjC(__pyx_cur_scope->__pyx_v_max_retries, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5963, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_2 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_attempt, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5963, __pyx_L5_error)
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 5963, __pyx_L5_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (__pyx_t_5) {

            /* "ws_package/controllers/activity_controller.py":5964
 *                 if not is_connected:
 *                     if attempt < max_retries - 1:
 *                         delay = retry_delays[attempt] if attempt < len(retry_delays) else 10.0             # <<<<<<<<<<<<<<
 *                         logger.info("IPC not connected for idle popup (attempt %s/%s), IPC server ready: %s, retrying in %ss...",
 *                                   attempt + 1, max_retries, is_ipc_ready(), delay)
*/
            __pyx_t_13 = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_retry_delays); if (unlikely(__pyx_t_13 == ((Py_ssize_t)-1))) __PYX_ERR(0, 5964, __pyx_L5_error)
            __pyx_t_1 = PyLong_FromSsize_t(__pyx_t_13); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5964, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_3 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_attempt, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5964, __pyx_L5_error)
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 5964, __pyx_L5_error)
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            if (__pyx_t_5) {
              __pyx_t_3 = __Pyx_PyObject_GetItem(__pyx_cur_scope->__pyx_v_retry_delays, __pyx_cur_scope->__pyx_v_attempt); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 5964, __pyx_L5_error)
              __Pyx_GOTREF(__pyx_t_3);
              __pyx_t_2 = __pyx_t_3;
              __pyx_t_3 = 0;
            } else {
              __Pyx_INCREF(__pyx_mstate_global->__pyx_float_10_0);
              __pyx_t_2 = __pyx_mstate_global->__pyx_float_10_0;
            }
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_delay);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_delay, __pyx_t_2);
            __Pyx_GIVEREF(__pyx_t_2);
            __pyx_t_2 = 0;

            /* "ws_package/controllers/activity_controller.py":5965
 *                     if attempt < max_retries - 1:
 *                         delay = retry_delays[attempt] if attempt < len(retry_delays) else 10.0
 *                         logger.info("IPC not connected for idle popup (attempt %s/%s), IPC server ready: %s, retrying in %ss...",             # <<<<<<<<<<<<<<
 *                                   attempt + 1, max_retries, is_ipc_ready(), delay)
 *                         await asyncio.sleep(delay)
*/
            __pyx_t_3 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5965, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5965, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_14);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

            /* "ws_package/controllers/activity_controller.py":5966
 *                         delay = retry_delays[attempt] if attempt < len(retry_delays) else 10.0
 *                         logger.info("IPC not connected for idle popup (attempt %s/%s), IPC server ready: %s, retrying in %ss...",
 *                                   attempt + 1, max_retries, is_ipc_ready(), delay)             # <<<<<<<<<<<<<<
 *                         await asyncio.sleep(delay)
 *                         continue
*/
            __pyx_t_1 = __Pyx_PyLong_AddObjC(__pyx_cur_scope->__pyx_v_attempt, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5966, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_16 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_is_ipc_ready); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 5966, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_17);
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_17))) {
              __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_17);
              assert(__pyx_t_16);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
              __Pyx_INCREF(__pyx_t_16);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_16, NULL};
              __pyx_t_15 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
              if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5966, __pyx_L5_error)
              __Pyx_GOTREF(__pyx_t_15);
            }
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_14))) {
              __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_14);
              assert(__pyx_t_3);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[6] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_IPC_not_connected_for_idle_popup, __pyx_t_1, __pyx_cur_scope->__pyx_v_max_retries, __pyx_t_15, __pyx_cur_scope->__pyx_v_delay};
              __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_4, (6-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5965, __pyx_L5_error)
              __Pyx_GOTREF(__pyx_t_2);
            }
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

            /* "ws_package/controllers/activity_controller.py":5967
 *                         logger.info("IPC not connected for idle popup (attempt %s/%s), IPC server ready: %s, retrying in %ss...",
 *                                   attempt + 1, max_retries, is_ipc_ready(), delay)
 *                         await asyncio.sleep(delay)             # <<<<<<<<<<<<<<
 *                         continue
 *                     else:
*/
            __pyx_t_14 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5967, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_15);
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5967, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_1);
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_1))) {
              __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_1);
              assert(__pyx_t_14);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
              __Pyx_INCREF(__pyx_t_14);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_14, __pyx_cur_scope->__pyx_v_delay};
              __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5967, __pyx_L5_error)
              __Pyx_GOTREF(__pyx_t_2);
            }
            __pyx_t_10 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_2, &__pyx_r);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            if (likely(__pyx_t_10 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_6);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
              __Pyx_XGIVEREF(__pyx_t_7);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
              __Pyx_XGIVEREF(__pyx_t_8);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
              __Pyx_XGIVEREF(__pyx_t_9);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
              __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 2;
              return __pyx_r;
              __pyx_L24_resume_from_await:;
              __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_6);
              __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_7);
              __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_8);
              __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_9);
              __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5967, __pyx_L5_error)
            } else if (likely(__pyx_t_10 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_DECREF(__pyx_r); __pyx_r = 0;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 5967, __pyx_L5_error)
            }

            /* "ws_package/controllers/activity_controller.py":5968
 *                                   attempt + 1, max_retries, is_ipc_ready(), delay)
 *                         await asyncio.sleep(delay)
 *                         continue             # <<<<<<<<<<<<<<
 *                     else:
 *                         logger.warning("IPC not connected after %s attempts - idle popup not sent. IPC server ready: %s",
*/
            goto __pyx_L20_continue;

            /* "ws_package/controllers/activity_controller.py":5963
 * 
 *                 if not is_connected:
 *                     if attempt < max_retries - 1:             # <<<<<<<<<<<<<<
 *                         delay = retry_delays[attempt] if attempt < len(retry_delays) else 10.0
 *                         logger.info("IPC not connected for idle popup (attempt %s/%s), IPC server ready: %s, retrying in %ss...",
*/
          }

          /* "ws_package/controllers/activity_controller.py":5970
 *                         continue
 *                     else:
 *                         logger.warning("IPC not connected after %s attempts - idle popup not sent. IPC server ready: %s",             # <<<<<<<<<<<<<<
 *                                      max_retries, is_ipc_ready())
 *                         break
*/
          /*else*/ {
            __pyx_t_1 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5970, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_14);
            __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5970, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_15);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

            /* "ws_package/controllers/activity_controller.py":5971
 *                     else:
 *                         logger.warning("IPC not connected after %s attempts - idle popup not sent. IPC server ready: %s",
 *                                      max_retries, is_ipc_ready())             # <<<<<<<<<<<<<<
 *                         break
 * 
*/
            __pyx_t_3 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_is_ipc_ready); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 5971, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_17);
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_17))) {
              __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_17);
              assert(__pyx_t_3);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
              __pyx_t_14 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
              if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5971, __pyx_L5_error)
              __Pyx_GOTREF(__pyx_t_14);
            }
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_15))) {
              __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_15);
              assert(__pyx_t_1);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
              __Pyx_INCREF(__pyx_t_1);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[4] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_IPC_not_connected_after_s_attemp, __pyx_cur_scope->__pyx_v_max_retries, __pyx_t_14};
              __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_4, (4-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5970, __pyx_L5_error)
              __Pyx_GOTREF(__pyx_t_2);
            }
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

            /* "ws_package/controllers/activity_controller.py":5972
 *                         logger.warning("IPC not connected after %s attempts - idle popup not sent. IPC server ready: %s",
 *                                      max_retries, is_ipc_ready())
 *                         break             # <<<<<<<<<<<<<<
 * 
 *                 # Calculate actual consecutive idle intervals
*/
            goto __pyx_L21_break;
          }

          /* "ws_package/controllers/activity_controller.py":5962
 *                 is_connected = electron_comm.is_connected()
 * 
 *                 if not is_connected:             # <<<<<<<<<<<<<<
 *                     if attempt < max_retries - 1:
 *                         delay = retry_delays[attempt] if attempt < len(retry_delays) else 10.0
*/
        }

        /* "ws_package/controllers/activity_controller.py":5975
 * 
 *                 # Calculate actual consecutive idle intervals
 *                 consecutive_idle_count = await self._get_consecutive_idle_count()             # <<<<<<<<<<<<<<
 *                 logger.info("[IdlePopup] Calculated consecutive idle count: %s", consecutive_idle_count)
 * 
*/
        __pyx_t_15 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_15);
        __pyx_t_4 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL};
          __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_consecutive_idle_count, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5975, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_2);
        }
        __pyx_t_10 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_2, &__pyx_r);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (likely(__pyx_t_10 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_6);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
          __Pyx_XGIVEREF(__pyx_t_7);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
          __Pyx_XGIVEREF(__pyx_t_8);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
          __Pyx_XGIVEREF(__pyx_t_9);
          __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
          __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 3;
          return __pyx_r;
          __pyx_L25_resume_from_await:;
          __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_6);
          __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_7);
          __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_8);
          __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
          __pyx_cur_scope->__pyx_t_3 = 0;
          __Pyx_XGOTREF(__pyx_t_9);
          __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 5975, __pyx_L5_error)
          __pyx_t_2 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_2);
        } else if (likely(__pyx_t_10 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __pyx_t_2 = __pyx_r; __pyx_r = NULL;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 5975, __pyx_L5_error)
        }
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_consecutive_idle_count);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_consecutive_idle_count, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        __pyx_t_2 = 0;

        /* "ws_package/controllers/activity_controller.py":5976
 *                 # Calculate actual consecutive idle intervals
 *                 consecutive_idle_count = await self._get_consecutive_idle_count()
 *                 logger.info("[IdlePopup] Calculated consecutive idle count: %s", consecutive_idle_count)             # <<<<<<<<<<<<<<
 * 
 *                 # Strictly after 2 idle intervals: only show popup when count >= 2
*/
        __pyx_t_15 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5976, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5976, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_1);
          assert(__pyx_t_15);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_15);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_IdlePopup_Calculated_consecutiv, __pyx_cur_scope->__pyx_v_consecutive_idle_count};
          __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5976, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_2);
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "ws_package/controllers/activity_controller.py":5979
 * 
 *                 # Strictly after 2 idle intervals: only show popup when count >= 2
 *                 if consecutive_idle_count < 2:             # <<<<<<<<<<<<<<
 *                     logger.info("[IdlePopup] Not triggered: consecutive_idle_count=%s (need >= 2)", consecutive_idle_count)
 *                     return
*/
        __pyx_t_2 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_consecutive_idle_count, __pyx_mstate_global->__pyx_int_2, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5979, __pyx_L5_error)
        __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 5979, __pyx_L5_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        if (__pyx_t_5) {

          /* "ws_package/controllers/activity_controller.py":5980
 *                 # Strictly after 2 idle intervals: only show popup when count >= 2
 *                 if consecutive_idle_count < 2:
 *                     logger.info("[IdlePopup] Not triggered: consecutive_idle_count=%s (need >= 2)", consecutive_idle_count)             # <<<<<<<<<<<<<<
 *                     return
 * 
*/
          __pyx_t_1 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5980, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_15);
          __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5980, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __pyx_t_4 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_14))) {
            __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_14);
            assert(__pyx_t_1);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
            __pyx_t_4 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_IdlePopup_Not_triggered_consecu, __pyx_cur_scope->__pyx_v_consecutive_idle_count};
            __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5980, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_2);
          }
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":5981
 *                 if consecutive_idle_count < 2:
 *                     logger.info("[IdlePopup] Not triggered: consecutive_idle_count=%s (need >= 2)", consecutive_idle_count)
 *                     return             # <<<<<<<<<<<<<<
 * 
 *                 # Send idle popup trigger message to Electron
*/
          __Pyx_XDECREF(__pyx_r);
          __pyx_r = Py_None; __Pyx_INCREF(Py_None);
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          goto __pyx_L9_try_return;

          /* "ws_package/controllers/activity_controller.py":5979
 * 
 *                 # Strictly after 2 idle intervals: only show popup when count >= 2
 *                 if consecutive_idle_count < 2:             # <<<<<<<<<<<<<<
 *                     logger.info("[IdlePopup] Not triggered: consecutive_idle_count=%s (need >= 2)", consecutive_idle_count)
 *                     return
*/
        }

        /* "ws_package/controllers/activity_controller.py":5984
 * 
 *                 # Send idle popup trigger message to Electron
 *                 logger.info("[IdlePopup] Triggering popup: consecutive_idle_count=%s, timestamp=%s", consecutive_idle_count, current_time.isoformat())             # <<<<<<<<<<<<<<
 *                 success = electron_comm.send_to_electron('idle_popup_trigger', {
 *                     'remaining_intervals': consecutive_idle_count,
*/
        __pyx_t_14 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5984, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5984, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_15);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_17 = __pyx_cur_scope->__pyx_v_current_time;
        __Pyx_INCREF(__pyx_t_17);
        __pyx_t_4 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_17, NULL};
          __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_isoformat, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5984, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_15))) {
          __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_15);
          assert(__pyx_t_14);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
          __Pyx_INCREF(__pyx_t_14);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[4] = {__pyx_t_14, __pyx_mstate_global->__pyx_kp_u_IdlePopup_Triggering_popup_cons, __pyx_cur_scope->__pyx_v_consecutive_idle_count, __pyx_t_1};
          __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_4, (4-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5984, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_2);
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "ws_package/controllers/activity_controller.py":5985
 *                 # Send idle popup trigger message to Electron
 *                 logger.info("[IdlePopup] Triggering popup: consecutive_idle_count=%s, timestamp=%s", consecutive_idle_count, current_time.isoformat())
 *                 success = electron_comm.send_to_electron('idle_popup_trigger', {             # <<<<<<<<<<<<<<
 *                     'remaining_intervals': consecutive_idle_count,
 *                     'timestamp': current_time.isoformat()
*/
        __pyx_t_15 = __pyx_cur_scope->__pyx_v_electron_comm;
        __Pyx_INCREF(__pyx_t_15);

        /* "ws_package/controllers/activity_controller.py":5986
 *                 logger.info("[IdlePopup] Triggering popup: consecutive_idle_count=%s, timestamp=%s", consecutive_idle_count, current_time.isoformat())
 *                 success = electron_comm.send_to_electron('idle_popup_trigger', {
 *                     'remaining_intervals': consecutive_idle_count,             # <<<<<<<<<<<<<<
 *                     'timestamp': current_time.isoformat()
 *                 })
*/
        __pyx_t_1 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5986, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_1);
        if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_remaining_intervals, __pyx_cur_scope->__pyx_v_consecutive_idle_count) < (0)) __PYX_ERR(0, 5986, __pyx_L5_error)

        /* "ws_package/controllers/activity_controller.py":5987
 *                 success = electron_comm.send_to_electron('idle_popup_trigger', {
 *                     'remaining_intervals': consecutive_idle_count,
 *                     'timestamp': current_time.isoformat()             # <<<<<<<<<<<<<<
 *                 })
 * 
*/
        __pyx_t_17 = __pyx_cur_scope->__pyx_v_current_time;
        __Pyx_INCREF(__pyx_t_17);
        __pyx_t_4 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_17, NULL};
          __pyx_t_14 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_isoformat, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5987, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_14);
        }
        if (PyDict_SetItem(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_timestamp, __pyx_t_14) < (0)) __PYX_ERR(0, 5986, __pyx_L5_error)
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_4 = 0;
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_15, __pyx_mstate_global->__pyx_n_u_idle_popup_trigger, __pyx_t_1};
          __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_send_to_electron, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5985, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_2);
        }
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_success);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_success, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        __pyx_t_2 = 0;

        /* "ws_package/controllers/activity_controller.py":5990
 *                 })
 * 
 *                 if success:             # <<<<<<<<<<<<<<
 *                     self._idle_popup_active = True  # Mark idle popup as active (for interval is_idle marking)
 *                     self._idle_popup_triggered_at = current_time  # Track when popup was triggered
*/
        __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_success); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 5990, __pyx_L5_error)
        if (__pyx_t_5) {

          /* "ws_package/controllers/activity_controller.py":5991
 * 
 *                 if success:
 *                     self._idle_popup_active = True  # Mark idle popup as active (for interval is_idle marking)             # <<<<<<<<<<<<<<
 *                     self._idle_popup_triggered_at = current_time  # Track when popup was triggered
 *                     self._api_pause_active = True  # Block server uploads while popup active
*/
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_active, Py_True) < (0)) __PYX_ERR(0, 5991, __pyx_L5_error)

          /* "ws_package/controllers/activity_controller.py":5992
 *                 if success:
 *                     self._idle_popup_active = True  # Mark idle popup as active (for interval is_idle marking)
 *                     self._idle_popup_triggered_at = current_time  # Track when popup was triggered             # <<<<<<<<<<<<<<
 *                     self._api_pause_active = True  # Block server uploads while popup active
 * 
*/
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_triggered_at, __pyx_cur_scope->__pyx_v_current_time) < (0)) __PYX_ERR(0, 5992, __pyx_L5_error)

          /* "ws_package/controllers/activity_controller.py":5993
 *                     self._idle_popup_active = True  # Mark idle popup as active (for interval is_idle marking)
 *                     self._idle_popup_triggered_at = current_time  # Track when popup was triggered
 *                     self._api_pause_active = True  # Block server uploads while popup active             # <<<<<<<<<<<<<<
 * 
 *                     logger.info("[IdlePopup]  Trigger sent to Electron (2 consecutive zero-activity intervals) [attempt %s]", attempt + 1)
*/
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_api_pause_active, Py_True) < (0)) __PYX_ERR(0, 5993, __pyx_L5_error)

          /* "ws_package/controllers/activity_controller.py":5995
 *                     self._api_pause_active = True  # Block server uploads while popup active
 * 
 *                     logger.info("[IdlePopup]  Trigger sent to Electron (2 consecutive zero-activity intervals) [attempt %s]", attempt + 1)             # <<<<<<<<<<<<<<
 *                     logger.info("[IdlePopup] State: active=True, triggered_at=%s, timeout_limit=%ss", current_time.isoformat(), self._idle_popup_timeout_seconds)
 *                     logger.info("[IdlePopup] Server uploads BLOCKED until popup handled")
*/
          __pyx_t_1 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5995, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_15);
          __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 5995, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __pyx_t_15 = __Pyx_PyLong_AddObjC(__pyx_cur_scope->__pyx_v_attempt, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5995, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_15);
          __pyx_t_4 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_14))) {
            __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_14);
            assert(__pyx_t_1);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
            __pyx_t_4 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_IdlePopup_Trigger_sent_to_Elect, __pyx_t_15};
            __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5995, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_2);
          }
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":5996
 * 
 *                     logger.info("[IdlePopup]  Trigger sent to Electron (2 consecutive zero-activity intervals) [attempt %s]", attempt + 1)
 *                     logger.info("[IdlePopup] State: active=True, triggered_at=%s, timeout_limit=%ss", current_time.isoformat(), self._idle_popup_timeout_seconds)             # <<<<<<<<<<<<<<
 *                     logger.info("[IdlePopup] Server uploads BLOCKED until popup handled")
 * 
*/
          __pyx_t_14 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5996, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_15);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5996, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          __pyx_t_17 = __pyx_cur_scope->__pyx_v_current_time;
          __Pyx_INCREF(__pyx_t_17);
          __pyx_t_4 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_17, NULL};
            __pyx_t_15 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_isoformat, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
            if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5996, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_15);
          }
          __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_timeout_seconds); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 5996, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_4 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_1))) {
            __pyx_t_14 = PyMethod_GET_SELF(__pyx_t_1);
            assert(__pyx_t_14);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_14);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
            __pyx_t_4 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[4] = {__pyx_t_14, __pyx_mstate_global->__pyx_kp_u_IdlePopup_State_active_True_tri, __pyx_t_15, __pyx_t_17};
            __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_4, (4-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5996, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_2);
          }
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":5997
 *                     logger.info("[IdlePopup]  Trigger sent to Electron (2 consecutive zero-activity intervals) [attempt %s]", attempt + 1)
 *                     logger.info("[IdlePopup] State: active=True, triggered_at=%s, timeout_limit=%ss", current_time.isoformat(), self._idle_popup_timeout_seconds)
 *                     logger.info("[IdlePopup] Server uploads BLOCKED until popup handled")             # <<<<<<<<<<<<<<
 * 
 *                     # Mark all previous consecutive zero-activity intervals as is_idle=1
*/
          __pyx_t_1 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 5997, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5997, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_15);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __pyx_t_4 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_15))) {
            __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_15);
            assert(__pyx_t_1);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_15);
            __Pyx_INCREF(__pyx_t_1);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_15, __pyx__function);
            __pyx_t_4 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_IdlePopup_Server_uploads_BLOCKE};
            __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_15, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5997, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_2);
          }
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":6000
 * 
 *                     # Mark all previous consecutive zero-activity intervals as is_idle=1
 *                     await self._mark_previous_zero_activity_intervals_as_idle()             # <<<<<<<<<<<<<<
 * 
 *                     break
*/
          __pyx_t_15 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_15);
          __pyx_t_4 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_15, NULL};
            __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_mark_previous_zero_activity_int, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6000, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_2);
          }
          __pyx_t_10 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_2, &__pyx_r);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (likely(__pyx_t_10 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_6);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
            __Pyx_XGIVEREF(__pyx_t_7);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
            __Pyx_XGIVEREF(__pyx_t_8);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
            __Pyx_XGIVEREF(__pyx_t_9);
            __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
            __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 4;
            return __pyx_r;
            __pyx_L28_resume_from_await:;
            __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_6);
            __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_7);
            __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_8);
            __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
            __pyx_cur_scope->__pyx_t_3 = 0;
            __Pyx_XGOTREF(__pyx_t_9);
            __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6000, __pyx_L5_error)
          } else if (likely(__pyx_t_10 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_DECREF(__pyx_r); __pyx_r = 0;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 6000, __pyx_L5_error)
          }

          /* "ws_package/controllers/activity_controller.py":6002
 *                     await self._mark_previous_zero_activity_intervals_as_idle()
 * 
 *                     break             # <<<<<<<<<<<<<<
 *                 else:
 *                     if attempt < max_retries - 1:
*/
          goto __pyx_L21_break;

          /* "ws_package/controllers/activity_controller.py":5990
 *                 })
 * 
 *                 if success:             # <<<<<<<<<<<<<<
 *                     self._idle_popup_active = True  # Mark idle popup as active (for interval is_idle marking)
 *                     self._idle_popup_triggered_at = current_time  # Track when popup was triggered
*/
        }

        /* "ws_package/controllers/activity_controller.py":6004
 *                     break
 *                 else:
 *                     if attempt < max_retries - 1:             # <<<<<<<<<<<<<<
 *                         delay = retry_delays[attempt] if attempt < len(retry_delays) else 10.0
 *                         logger.info("Failed to send idle popup (attempt %s/%s), IPC connected: %s, retrying in %ss...",
*/
        /*else*/ {
          __pyx_t_2 = __Pyx_PyLong_SubtractObjC(__pyx_cur_scope->__pyx_v_max_retries, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6004, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_15 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_attempt, __pyx_t_2, Py_LT); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 6004, __pyx_L5_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 6004, __pyx_L5_error)
          __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          if (__pyx_t_5) {

            /* "ws_package/controllers/activity_controller.py":6005
 *                 else:
 *                     if attempt < max_retries - 1:
 *                         delay = retry_delays[attempt] if attempt < len(retry_delays) else 10.0             # <<<<<<<<<<<<<<
 *                         logger.info("Failed to send idle popup (attempt %s/%s), IPC connected: %s, retrying in %ss...",
 *                                   attempt + 1, max_retries, electron_comm.is_connected(), delay)
*/
            __pyx_t_13 = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_retry_delays); if (unlikely(__pyx_t_13 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6005, __pyx_L5_error)
            __pyx_t_2 = PyLong_FromSsize_t(__pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6005, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_1 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_attempt, __pyx_t_2, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6005, __pyx_L5_error)
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 6005, __pyx_L5_error)
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (__pyx_t_5) {
              __pyx_t_1 = __Pyx_PyObject_GetItem(__pyx_cur_scope->__pyx_v_retry_delays, __pyx_cur_scope->__pyx_v_attempt); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6005, __pyx_L5_error)
              __Pyx_GOTREF(__pyx_t_1);
              __pyx_t_15 = __pyx_t_1;
              __pyx_t_1 = 0;
            } else {
              __Pyx_INCREF(__pyx_mstate_global->__pyx_float_10_0);
              __pyx_t_15 = __pyx_mstate_global->__pyx_float_10_0;
            }
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_delay);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_delay, __pyx_t_15);
            __Pyx_GIVEREF(__pyx_t_15);
            __pyx_t_15 = 0;

            /* "ws_package/controllers/activity_controller.py":6006
 *                     if attempt < max_retries - 1:
 *                         delay = retry_delays[attempt] if attempt < len(retry_delays) else 10.0
 *                         logger.info("Failed to send idle popup (attempt %s/%s), IPC connected: %s, retrying in %ss...",             # <<<<<<<<<<<<<<
 *                                   attempt + 1, max_retries, electron_comm.is_connected(), delay)
 *                         await asyncio.sleep(delay)
*/
            __pyx_t_1 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6006, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6006, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_17);
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

            /* "ws_package/controllers/activity_controller.py":6007
 *                         delay = retry_delays[attempt] if attempt < len(retry_delays) else 10.0
 *                         logger.info("Failed to send idle popup (attempt %s/%s), IPC connected: %s, retrying in %ss...",
 *                                   attempt + 1, max_retries, electron_comm.is_connected(), delay)             # <<<<<<<<<<<<<<
 *                         await asyncio.sleep(delay)
 *                     else:
*/
            __pyx_t_2 = __Pyx_PyLong_AddObjC(__pyx_cur_scope->__pyx_v_attempt, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6007, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_3 = __pyx_cur_scope->__pyx_v_electron_comm;
            __Pyx_INCREF(__pyx_t_3);
            __pyx_t_4 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
              __pyx_t_14 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_connected, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 6007, __pyx_L5_error)
              __Pyx_GOTREF(__pyx_t_14);
            }
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_17))) {
              __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_17);
              assert(__pyx_t_1);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
              __Pyx_INCREF(__pyx_t_1);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[6] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_Failed_to_send_idle_popup_attemp, __pyx_t_2, __pyx_cur_scope->__pyx_v_max_retries, __pyx_t_14, __pyx_cur_scope->__pyx_v_delay};
              __pyx_t_15 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_4, (6-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
              if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 6006, __pyx_L5_error)
              __Pyx_GOTREF(__pyx_t_15);
            }
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

            /* "ws_package/controllers/activity_controller.py":6008
 *                         logger.info("Failed to send idle popup (attempt %s/%s), IPC connected: %s, retrying in %ss...",
 *                                   attempt + 1, max_retries, electron_comm.is_connected(), delay)
 *                         await asyncio.sleep(delay)             # <<<<<<<<<<<<<<
 *                     else:
 *                         logger.warning(
*/
            __pyx_t_17 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 6008, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_14);
            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6008, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_2))) {
              __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_2);
              assert(__pyx_t_17);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_17);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_17, __pyx_cur_scope->__pyx_v_delay};
              __pyx_t_15 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 6008, __pyx_L5_error)
              __Pyx_GOTREF(__pyx_t_15);
            }
            __pyx_t_10 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_15, &__pyx_r);
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            if (likely(__pyx_t_10 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_6);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
              __Pyx_XGIVEREF(__pyx_t_7);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
              __Pyx_XGIVEREF(__pyx_t_8);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
              __Pyx_XGIVEREF(__pyx_t_9);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_9;
              __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 5;
              return __pyx_r;
              __pyx_L30_resume_from_await:;
              __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_6);
              __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_7);
              __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_8);
              __pyx_t_9 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_9);
              __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6008, __pyx_L5_error)
            } else if (likely(__pyx_t_10 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_DECREF(__pyx_r); __pyx_r = 0;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 6008, __pyx_L5_error)
            }

            /* "ws_package/controllers/activity_controller.py":6004
 *                     break
 *                 else:
 *                     if attempt < max_retries - 1:             # <<<<<<<<<<<<<<
 *                         delay = retry_delays[attempt] if attempt < len(retry_delays) else 10.0
 *                         logger.info("Failed to send idle popup (attempt %s/%s), IPC connected: %s, retrying in %ss...",
*/
            goto __pyx_L29;
          }

          /* "ws_package/controllers/activity_controller.py":6010
 *                         await asyncio.sleep(delay)
 *                     else:
 *                         logger.warning(             # <<<<<<<<<<<<<<
 *                             "Failed to send idle popup trigger after %s attempts. "
 *                             "Final IPC status - Connected: %s, IPC server ready: %s",
*/
          /*else*/ {
            __pyx_t_2 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6010, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_17);
            __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 6010, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_14);
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

            /* "ws_package/controllers/activity_controller.py":6013
 *                             "Failed to send idle popup trigger after %s attempts. "
 *                             "Final IPC status - Connected: %s, IPC server ready: %s",
 *                             max_retries, electron_comm.is_connected(), is_ipc_ready())             # <<<<<<<<<<<<<<
 * 
 *             if not success:
*/
            __pyx_t_1 = __pyx_cur_scope->__pyx_v_electron_comm;
            __Pyx_INCREF(__pyx_t_1);
            __pyx_t_4 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
              __pyx_t_17 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_is_connected, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6013, __pyx_L5_error)
              __Pyx_GOTREF(__pyx_t_17);
            }
            __pyx_t_3 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_is_ipc_ready); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 6013, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_16);
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_16))) {
              __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_16);
              assert(__pyx_t_3);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_16);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_16, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
              __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_16, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
              if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6013, __pyx_L5_error)
              __Pyx_GOTREF(__pyx_t_1);
            }
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_14))) {
              __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_14);
              assert(__pyx_t_2);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
              __Pyx_INCREF(__pyx_t_2);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[5] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Failed_to_send_idle_popup_trigge, __pyx_cur_scope->__pyx_v_max_retries, __pyx_t_17, __pyx_t_1};
              __pyx_t_15 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_4, (5-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
              __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 6010, __pyx_L5_error)
              __Pyx_GOTREF(__pyx_t_15);
            }
            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
          }
          __pyx_L29:;
        }

        /* "ws_package/controllers/activity_controller.py":5958
 *             success = False
 * 
 *             for attempt in range(max_retries):             # <<<<<<<<<<<<<<
 *                 # Check if connected before attempting to send
 *                 is_connected = electron_comm.is_connected()
*/
        __pyx_L20_continue:;
      }
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L31_for_end;
      __pyx_L21_break:;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      goto __pyx_L31_for_end;
      __pyx_L31_for_end:;

      /* "ws_package/controllers/activity_controller.py":6015
 *                             max_retries, electron_comm.is_connected(), is_ipc_ready())
 * 
 *             if not success:             # <<<<<<<<<<<<<<
 *                 logger.warning("Idle popup could not be sent - IPC connection unavailable. Will retry on next idle detection if cooldown allows.")
 * 
*/
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_success); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 6015, __pyx_L5_error)
      __pyx_t_11 = (!__pyx_t_5);
      if (__pyx_t_11) {

        /* "ws_package/controllers/activity_controller.py":6016
 * 
 *             if not success:
 *                 logger.warning("Idle popup could not be sent - IPC connection unavailable. Will retry on next idle detection if cooldown allows.")             # <<<<<<<<<<<<<<
 * 
 *         except Exception as e:
*/
        __pyx_t_15 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 6016, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_14);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6016, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_1);
          assert(__pyx_t_15);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_15);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Idle_popup_could_not_be_sent_IPC};
          __pyx_t_9 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6016, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_9);
        }
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

        /* "ws_package/controllers/activity_controller.py":6015
 *                             max_retries, electron_comm.is_connected(), is_ipc_ready())
 * 
 *             if not success:             # <<<<<<<<<<<<<<
 *                 logger.warning("Idle popup could not be sent - IPC connection unavailable. Will retry on next idle detection if cooldown allows.")
 * 
*/
      }

      /* "ws_package/controllers/activity_controller.py":5919
 *         if is_silent_build():
 *             return
 *         try:             # <<<<<<<<<<<<<<
 *             logger.info("[IdlePopup] arise_idle_popup() called - checking conditions before sending trigger to Electron")
 * 
*/
    }
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    goto __pyx_L10_try_end;
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "ws_package/controllers/activity_controller.py":6018
 *                 logger.warning("Idle popup could not be sent - IPC connection unavailable. Will retry on next idle detection if cooldown allows.")
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error triggering idle popup: %s", e, exc_info=True)
 * 
*/
    __pyx_t_18 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_18) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.arise_idle_popup", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_1, &__pyx_t_15) < 0) __PYX_ERR(0, 6018, __pyx_L7_except_error)
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_1);
      __Pyx_XGOTREF(__pyx_t_15);
      __Pyx_INCREF(__pyx_t_1);
      __Pyx_GIVEREF(__pyx_t_1);
      __pyx_cur_scope->__pyx_v_e = __pyx_t_1;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":6019
 * 
 *         except Exception as e:
 *             logger.error("Error triggering idle popup: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *     async def _has_zero_activity_for_interval(self, start_date: datetime.datetime, end_date: datetime.datetime) -> bool:
*/
        __pyx_t_17 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6019, __pyx_L38_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 6019, __pyx_L38_error)
        __Pyx_GOTREF(__pyx_t_16);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_16))) {
          __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_16);
          assert(__pyx_t_17);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_16);
          __Pyx_INCREF(__pyx_t_17);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_16, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_17, __pyx_mstate_global->__pyx_kp_u_Error_triggering_idle_popup_s, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_2 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6019, __pyx_L38_error)
          __Pyx_GOTREF(__pyx_t_2);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_2, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 6019, __pyx_L38_error)
          __pyx_t_14 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_16, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_2);
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 6019, __pyx_L38_error)
          __Pyx_GOTREF(__pyx_t_14);
        }
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
      }

      /* "ws_package/controllers/activity_controller.py":6018
 *                 logger.warning("Idle popup could not be sent - IPC connection unavailable. Will retry on next idle detection if cooldown allows.")
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error triggering idle popup: %s", e, exc_info=True)
 * 
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          goto __pyx_L39;
        }
        __pyx_L38_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_24, &__pyx_t_25, &__pyx_t_26);
          if ( unlikely(__Pyx_GetException(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23) < 0)) __Pyx_ErrFetch(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_23);
          __Pyx_XGOTREF(__pyx_t_24);
          __Pyx_XGOTREF(__pyx_t_25);
          __Pyx_XGOTREF(__pyx_t_26);
          __pyx_t_18 = __pyx_lineno; __pyx_t_19 = __pyx_clineno; __pyx_t_20 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_24);
          __Pyx_XGIVEREF(__pyx_t_25);
          __Pyx_XGIVEREF(__pyx_t_26);
          __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_25, __pyx_t_26);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_ErrRestore(__pyx_t_21, __pyx_t_22, __pyx_t_23);
          __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0;
          __pyx_lineno = __pyx_t_18; __pyx_clineno = __pyx_t_19; __pyx_filename = __pyx_t_20;
          goto __pyx_L7_except_error;
        }
        __pyx_L39:;
      }
      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
      goto __pyx_L6_exception_handled;
    }
    goto __pyx_L7_except_error;

    /* "ws_package/controllers/activity_controller.py":5919
 *         if is_silent_build():
 *             return
 *         try:             # <<<<<<<<<<<<<<
 *             logger.info("[IdlePopup] arise_idle_popup() called - checking conditions before sending trigger to Electron")
 * 
*/
    __pyx_L7_except_error:;
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
    goto __pyx_L1_error;
    __pyx_L9_try_return:;
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
    goto __pyx_L0;
    __pyx_L6_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
    __pyx_L10_try_end:;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":5906
 *             return False
 * 
 *     async def arise_idle_popup(self):             # <<<<<<<<<<<<<<
 *         """
 *         Trigger idle popup in Electron app.
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("arise_idle_popup", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_200generator42(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":6021
 *             logger.error("Error triggering idle popup: %s", e, exc_info=True)
 * 
 *     async def _has_zero_activity_for_interval(self, start_date: datetime.datetime, end_date: datetime.datetime) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Check if an interval has zero activity in both activityLevel and activity_percentage.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_199_has_zero_activity_for_interval(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_198_has_zero_activity_for_interval, "\n        Check if an interval has zero activity in both activityLevel and activity_percentage.\n        \n        Args:\n            start_date: Interval start time\n            end_date: Interval end time\n            \n        Returns:\n            bool: True if both activityLevel and activity_percentage have zero activity\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_199_has_zero_activity_for_interval = {"_has_zero_activity_for_interval", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_199_has_zero_activity_for_interval, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_198_has_zero_activity_for_interval};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_199_has_zero_activity_for_interval(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_start_date = 0;
  PyObject *__pyx_v_end_date = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_has_zero_activity_for_interval (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_start_date,&__pyx_mstate_global->__pyx_n_u_end_date,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 6021, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 6021, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 6021, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 6021, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_has_zero_activity_for_interval", 0) < (0)) __PYX_ERR(0, 6021, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 3; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_has_zero_activity_for_interval", 1, 3, 3, i); __PYX_ERR(0, 6021, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 3)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 6021, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 6021, __pyx_L3_error)
      values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 6021, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_start_date = values[1];
    __pyx_v_end_date = values[2];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_has_zero_activity_for_interval", 1, 3, 3, __pyx_nargs); __PYX_ERR(0, 6021, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._has_zero_activity_for_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_198_has_zero_activity_for_interval(__pyx_self, __pyx_v_self, __pyx_v_start_date, __pyx_v_end_date);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_198_has_zero_activity_for_interval(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_start_date, PyObject *__pyx_v_end_date) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_has_zero_activity_for_interval", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 6021, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_start_date = __pyx_v_start_date;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_start_date);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_start_date);
  __pyx_cur_scope->__pyx_v_end_date = __pyx_v_end_date;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_end_date);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_end_date);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_200generator42, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[68]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_has_zero_activity_for_interval, __pyx_mstate_global->__pyx_n_u_ActivityController__has_zero_act, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 6021, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._has_zero_activity_for_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_200generator42(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  size_t __pyx_t_6;
  __Pyx_PySendResult __pyx_t_7;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  double __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  int __pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  int __pyx_t_19;
  char const *__pyx_t_20;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  PyObject *__pyx_t_26 = NULL;
  int __pyx_t_27;
  char const *__pyx_t_28;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_has_zero_activity_for_interval", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L10_resume_from_await;
    case 2: goto __pyx_L26_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 6021, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":6032
 *             bool: True if both activityLevel and activity_percentage have zero activity
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # Get activityLevel
 *             activityLevel = await self.get_activity_level_from_db(start_date, end_date)
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":6034
 *         try:
 *             # Get activityLevel
 *             activityLevel = await self.get_activity_level_from_db(start_date, end_date)             # <<<<<<<<<<<<<<
 *             keyboard = float(activityLevel.get('keyboard', 0) or 0)
 *             mouse = float(activityLevel.get('mouse', 0) or 0)
*/
      __pyx_t_5 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_6 = 0;
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_activity_level_from_db, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6034, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_t_7 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (likely(__pyx_t_7 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
        __Pyx_XGIVEREF(__pyx_t_2);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
        __Pyx_XGIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 1;
        return __pyx_r;
        __pyx_L10_resume_from_await:;
        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_1);
        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_2);
        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_3);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6034, __pyx_L4_error)
        __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
      } else if (likely(__pyx_t_7 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __pyx_t_4 = __pyx_r; __pyx_r = NULL;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 6034, __pyx_L4_error)
      }
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_cur_scope->__pyx_v_activityLevel = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":6035
 *             # Get activityLevel
 *             activityLevel = await self.get_activity_level_from_db(start_date, end_date)
 *             keyboard = float(activityLevel.get('keyboard', 0) or 0)             # <<<<<<<<<<<<<<
 *             mouse = float(activityLevel.get('mouse', 0) or 0)
 *             average = float(activityLevel.get('average', 0) or 0)
*/
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activityLevel, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6035, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_mstate_global->__pyx_tuple[15], NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6035, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 6035, __pyx_L4_error)
      if (!__pyx_t_9) {
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else {
        __Pyx_INCREF(__pyx_t_8);
        __pyx_t_4 = __pyx_t_8;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L11_bool_binop_done;
      }
      __pyx_t_8 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6035, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_4 = __pyx_t_8;
      __pyx_t_8 = 0;
      __pyx_L11_bool_binop_done:;
      __pyx_t_10 = __Pyx_PyObject_AsDouble(__pyx_t_4); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_10, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 6035, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_cur_scope->__pyx_v_keyboard = __pyx_t_10;

      /* "ws_package/controllers/activity_controller.py":6036
 *             activityLevel = await self.get_activity_level_from_db(start_date, end_date)
 *             keyboard = float(activityLevel.get('keyboard', 0) or 0)
 *             mouse = float(activityLevel.get('mouse', 0) or 0)             # <<<<<<<<<<<<<<
 *             average = float(activityLevel.get('average', 0) or 0)
 *             has_activity_level_activity = keyboard > 0 or mouse > 0 or average > 0
*/
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activityLevel, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6036, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_mstate_global->__pyx_tuple[16], NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6036, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 6036, __pyx_L4_error)
      if (!__pyx_t_9) {
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      } else {
        __Pyx_INCREF(__pyx_t_5);
        __pyx_t_4 = __pyx_t_5;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        goto __pyx_L13_bool_binop_done;
      }
      __pyx_t_5 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6036, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = __pyx_t_5;
      __pyx_t_5 = 0;
      __pyx_L13_bool_binop_done:;
      __pyx_t_10 = __Pyx_PyObject_AsDouble(__pyx_t_4); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_10, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 6036, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_cur_scope->__pyx_v_mouse = __pyx_t_10;

      /* "ws_package/controllers/activity_controller.py":6037
 *             keyboard = float(activityLevel.get('keyboard', 0) or 0)
 *             mouse = float(activityLevel.get('mouse', 0) or 0)
 *             average = float(activityLevel.get('average', 0) or 0)             # <<<<<<<<<<<<<<
 *             has_activity_level_activity = keyboard > 0 or mouse > 0 or average > 0
 * 
*/
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activityLevel, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6037, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_mstate_global->__pyx_tuple[17], NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6037, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 6037, __pyx_L4_error)
      if (!__pyx_t_9) {
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      } else {
        __Pyx_INCREF(__pyx_t_8);
        __pyx_t_4 = __pyx_t_8;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        goto __pyx_L15_bool_binop_done;
      }
      __pyx_t_8 = __Pyx_PyLong_From_long(0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6037, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_4 = __pyx_t_8;
      __pyx_t_8 = 0;
      __pyx_L15_bool_binop_done:;
      __pyx_t_10 = __Pyx_PyObject_AsDouble(__pyx_t_4); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_10, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 6037, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_cur_scope->__pyx_v_average = __pyx_t_10;

      /* "ws_package/controllers/activity_controller.py":6038
 *             mouse = float(activityLevel.get('mouse', 0) or 0)
 *             average = float(activityLevel.get('average', 0) or 0)
 *             has_activity_level_activity = keyboard > 0 or mouse > 0 or average > 0             # <<<<<<<<<<<<<<
 * 
 *             # Get activity_percentage
*/
      __pyx_t_9 = (__pyx_cur_scope->__pyx_v_keyboard > 0.0);
      if (!__pyx_t_9) {
      } else {
        __pyx_t_8 = __Pyx_PyBool_FromLong(__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6038, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_4 = __pyx_t_8;
        __pyx_t_8 = 0;
        goto __pyx_L17_bool_binop_done;
      }
      __pyx_t_9 = (__pyx_cur_scope->__pyx_v_mouse > 0.0);
      if (!__pyx_t_9) {
      } else {
        __pyx_t_8 = __Pyx_PyBool_FromLong(__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6038, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_4 = __pyx_t_8;
        __pyx_t_8 = 0;
        goto __pyx_L17_bool_binop_done;
      }
      __pyx_t_9 = (__pyx_cur_scope->__pyx_v_average > 0.0);
      __pyx_t_8 = __Pyx_PyBool_FromLong(__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6038, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_4 = __pyx_t_8;
      __pyx_t_8 = 0;
      __pyx_L17_bool_binop_done:;
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_cur_scope->__pyx_v_has_activity_level_activity = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":6041
 * 
 *             # Get activity_percentage
 *             has_activity_percentage_activity = False             # <<<<<<<<<<<<<<
 *             try:
 *                 activity_percentage = await activity_percentage_manager.find_overlapping_activity_percentage(
*/
      __Pyx_INCREF(Py_False);
      __Pyx_GIVEREF(Py_False);
      __pyx_cur_scope->__pyx_v_has_activity_percentage_activity = Py_False;

      /* "ws_package/controllers/activity_controller.py":6042
 *             # Get activity_percentage
 *             has_activity_percentage_activity = False
 *             try:             # <<<<<<<<<<<<<<
 *                 activity_percentage = await activity_percentage_manager.find_overlapping_activity_percentage(
 *                     start_date, end_date
*/
      {
        __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
        __Pyx_XGOTREF(__pyx_t_11);
        __Pyx_XGOTREF(__pyx_t_12);
        __Pyx_XGOTREF(__pyx_t_13);
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":6043
 *             has_activity_percentage_activity = False
 *             try:
 *                 activity_percentage = await activity_percentage_manager.find_overlapping_activity_percentage(             # <<<<<<<<<<<<<<
 *                     start_date, end_date
 *                 )
*/
          __pyx_t_8 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_activity_percentage_manager); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6043, __pyx_L20_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_find_overlapping_activity_percen); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 6043, __pyx_L20_error)
          __Pyx_GOTREF(__pyx_t_14);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":6044
 *             try:
 *                 activity_percentage = await activity_percentage_manager.find_overlapping_activity_percentage(
 *                     start_date, end_date             # <<<<<<<<<<<<<<
 *                 )
 *                 if activity_percentage:
*/
          __pyx_t_6 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_14))) {
            __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_14);
            assert(__pyx_t_8);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_14);
            __Pyx_INCREF(__pyx_t_8);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_14, __pyx__function);
            __pyx_t_6 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_8, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date};
            __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_14, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6043, __pyx_L20_error)
            __Pyx_GOTREF(__pyx_t_4);
          }
          __pyx_t_7 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (likely(__pyx_t_7 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_1);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
            __Pyx_XGIVEREF(__pyx_t_2);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
            __Pyx_XGIVEREF(__pyx_t_3);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
            __Pyx_XGIVEREF(__pyx_t_11);
            __pyx_cur_scope->__pyx_t_3 = __pyx_t_11;
            __Pyx_XGIVEREF(__pyx_t_12);
            __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
            __Pyx_XGIVEREF(__pyx_t_13);
            __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 2;
            return __pyx_r;
            __pyx_L26_resume_from_await:;
            __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_1);
            __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_2);
            __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_3);
            __pyx_t_11 = __pyx_cur_scope->__pyx_t_3;
            __pyx_cur_scope->__pyx_t_3 = 0;
            __Pyx_XGOTREF(__pyx_t_11);
            __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
            __pyx_cur_scope->__pyx_t_4 = 0;
            __Pyx_XGOTREF(__pyx_t_12);
            __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
            __pyx_cur_scope->__pyx_t_5 = 0;
            __Pyx_XGOTREF(__pyx_t_13);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6043, __pyx_L20_error)
            __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
          } else if (likely(__pyx_t_7 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __pyx_t_4 = __pyx_r; __pyx_r = NULL;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 6043, __pyx_L20_error)
          }
          __Pyx_GIVEREF(__pyx_t_4);
          __pyx_cur_scope->__pyx_v_activity_percentage = __pyx_t_4;
          __pyx_t_4 = 0;

          /* "ws_package/controllers/activity_controller.py":6046
 *                     start_date, end_date
 *                 )
 *                 if activity_percentage:             # <<<<<<<<<<<<<<
 *                     has_activity_percentage_activity = (
 *                         activity_percentage.keyboard > 0 or
*/
          __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_activity_percentage); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 6046, __pyx_L20_error)
          if (__pyx_t_9) {

            /* "ws_package/controllers/activity_controller.py":6048
 *                 if activity_percentage:
 *                     has_activity_percentage_activity = (
 *                         activity_percentage.keyboard > 0 or             # <<<<<<<<<<<<<<
 *                         activity_percentage.mouse > 0 or
 *                         activity_percentage.average > 0
*/
            __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activity_percentage, __pyx_mstate_global->__pyx_n_u_keyboard); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 6048, __pyx_L20_error)
            __Pyx_GOTREF(__pyx_t_14);
            __pyx_t_8 = PyObject_RichCompare(__pyx_t_14, __pyx_mstate_global->__pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6048, __pyx_L20_error)
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 6048, __pyx_L20_error)
            if (!__pyx_t_9) {
              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            } else {
              __Pyx_INCREF(__pyx_t_8);
              __pyx_t_4 = __pyx_t_8;
              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
              goto __pyx_L28_bool_binop_done;
            }

            /* "ws_package/controllers/activity_controller.py":6049
 *                     has_activity_percentage_activity = (
 *                         activity_percentage.keyboard > 0 or
 *                         activity_percentage.mouse > 0 or             # <<<<<<<<<<<<<<
 *                         activity_percentage.average > 0
 *                     )
*/
            __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activity_percentage, __pyx_mstate_global->__pyx_n_u_mouse); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6049, __pyx_L20_error)
            __Pyx_GOTREF(__pyx_t_8);
            __pyx_t_14 = PyObject_RichCompare(__pyx_t_8, __pyx_mstate_global->__pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_14); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 6049, __pyx_L20_error)
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 6049, __pyx_L20_error)
            if (!__pyx_t_9) {
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            } else {
              __Pyx_INCREF(__pyx_t_14);
              __pyx_t_4 = __pyx_t_14;
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              goto __pyx_L28_bool_binop_done;
            }

            /* "ws_package/controllers/activity_controller.py":6050
 *                         activity_percentage.keyboard > 0 or
 *                         activity_percentage.mouse > 0 or
 *                         activity_percentage.average > 0             # <<<<<<<<<<<<<<
 *                     )
 *             except Exception as e:
*/
            __pyx_t_14 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activity_percentage, __pyx_mstate_global->__pyx_n_u_average); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 6050, __pyx_L20_error)
            __Pyx_GOTREF(__pyx_t_14);
            __pyx_t_8 = PyObject_RichCompare(__pyx_t_14, __pyx_mstate_global->__pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6050, __pyx_L20_error)
            __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_INCREF(__pyx_t_8);
            __pyx_t_4 = __pyx_t_8;
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            __pyx_L28_bool_binop_done:;
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_has_activity_percentage_activity);
            __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_has_activity_percentage_activity, __pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_4);
            __pyx_t_4 = 0;

            /* "ws_package/controllers/activity_controller.py":6046
 *                     start_date, end_date
 *                 )
 *                 if activity_percentage:             # <<<<<<<<<<<<<<
 *                     has_activity_percentage_activity = (
 *                         activity_percentage.keyboard > 0 or
*/
          }

          /* "ws_package/controllers/activity_controller.py":6042
 *             # Get activity_percentage
 *             has_activity_percentage_activity = False
 *             try:             # <<<<<<<<<<<<<<
 *                 activity_percentage = await activity_percentage_manager.find_overlapping_activity_percentage(
 *                     start_date, end_date
*/
        }
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        goto __pyx_L25_try_end;
        __pyx_L20_error:;
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

        /* "ws_package/controllers/activity_controller.py":6052
 *                         activity_percentage.average > 0
 *                     )
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 logger.debug("Error checking activity_percentage for interval %s to %s: %s", start_date, end_date, e)
 * 
*/
        __pyx_t_15 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
        if (__pyx_t_15) {
          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._has_zero_activity_for_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_8, &__pyx_t_14) < 0) __PYX_ERR(0, 6052, __pyx_L22_except_error)
          __Pyx_XGOTREF(__pyx_t_4);
          __Pyx_XGOTREF(__pyx_t_8);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_GIVEREF(__pyx_t_8);
          __pyx_cur_scope->__pyx_v_e = __pyx_t_8;
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":6053
 *                     )
 *             except Exception as e:
 *                 logger.debug("Error checking activity_percentage for interval %s to %s: %s", start_date, end_date, e)             # <<<<<<<<<<<<<<
 * 
 *             # Both must be zero
*/
            __pyx_t_16 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6053, __pyx_L36_error)
            __Pyx_GOTREF(__pyx_t_17);
            __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 6053, __pyx_L36_error)
            __Pyx_GOTREF(__pyx_t_18);
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            __pyx_t_6 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_18))) {
              __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_18);
              assert(__pyx_t_16);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_18);
              __Pyx_INCREF(__pyx_t_16);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_18, __pyx__function);
              __pyx_t_6 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[5] = {__pyx_t_16, __pyx_mstate_global->__pyx_kp_u_Error_checking_activity_percenta, __pyx_cur_scope->__pyx_v_start_date, __pyx_cur_scope->__pyx_v_end_date, __pyx_cur_scope->__pyx_v_e};
              __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_18, __pyx_callargs+__pyx_t_6, (5-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
              __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
              if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6053, __pyx_L36_error)
              __Pyx_GOTREF(__pyx_t_5);
            }
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          }

          /* "ws_package/controllers/activity_controller.py":6052
 *                         activity_percentage.average > 0
 *                     )
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 logger.debug("Error checking activity_percentage for interval %s to %s: %s", start_date, end_date, e)
 * 
*/
          /*finally:*/ {
            /*normal exit:*/{
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
              goto __pyx_L37;
            }
            __pyx_L36_error:;
            /*exception exit:*/{
              __Pyx_PyThreadState_assign
              __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0;
              __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
              __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
              __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
              __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
               __Pyx_ExceptionSwap(&__pyx_t_24, &__pyx_t_25, &__pyx_t_26);
              if ( unlikely(__Pyx_GetException(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23) < 0)) __Pyx_ErrFetch(&__pyx_t_21, &__pyx_t_22, &__pyx_t_23);
              __Pyx_XGOTREF(__pyx_t_21);
              __Pyx_XGOTREF(__pyx_t_22);
              __Pyx_XGOTREF(__pyx_t_23);
              __Pyx_XGOTREF(__pyx_t_24);
              __Pyx_XGOTREF(__pyx_t_25);
              __Pyx_XGOTREF(__pyx_t_26);
              __pyx_t_15 = __pyx_lineno; __pyx_t_19 = __pyx_clineno; __pyx_t_20 = __pyx_filename;
              {
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
              }
              __Pyx_XGIVEREF(__pyx_t_24);
              __Pyx_XGIVEREF(__pyx_t_25);
              __Pyx_XGIVEREF(__pyx_t_26);
              __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_25, __pyx_t_26);
              __Pyx_XGIVEREF(__pyx_t_21);
              __Pyx_XGIVEREF(__pyx_t_22);
              __Pyx_XGIVEREF(__pyx_t_23);
              __Pyx_ErrRestore(__pyx_t_21, __pyx_t_22, __pyx_t_23);
              __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0; __pyx_t_26 = 0;
              __pyx_lineno = __pyx_t_15; __pyx_clineno = __pyx_t_19; __pyx_filename = __pyx_t_20;
              goto __pyx_L22_except_error;
            }
            __pyx_L37:;
          }
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          goto __pyx_L21_exception_handled;
        }
        goto __pyx_L22_except_error;

        /* "ws_package/controllers/activity_controller.py":6042
 *             # Get activity_percentage
 *             has_activity_percentage_activity = False
 *             try:             # <<<<<<<<<<<<<<
 *                 activity_percentage = await activity_percentage_manager.find_overlapping_activity_percentage(
 *                     start_date, end_date
*/
        __pyx_L22_except_error:;
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
        goto __pyx_L4_error;
        __pyx_L21_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_11);
        __Pyx_XGIVEREF(__pyx_t_12);
        __Pyx_XGIVEREF(__pyx_t_13);
        __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
        __pyx_L25_try_end:;
      }

      /* "ws_package/controllers/activity_controller.py":6056
 * 
 *             # Both must be zero
 *             return not has_activity_level_activity and not has_activity_percentage_activity             # <<<<<<<<<<<<<<
 * 
 *         except Exception as e:
*/
      __Pyx_XDECREF(__pyx_r);
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_has_activity_level_activity); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 6056, __pyx_L4_error)
      __pyx_t_27 = (!__pyx_t_9);
      if (__pyx_t_27) {
      } else {
        __pyx_t_8 = __Pyx_PyBool_FromLong(__pyx_t_27); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6056, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_14 = __pyx_t_8;
        __pyx_t_8 = 0;
        goto __pyx_L42_bool_binop_done;
      }
      __pyx_t_27 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_has_activity_percentage_activity); if (unlikely((__pyx_t_27 < 0))) __PYX_ERR(0, 6056, __pyx_L4_error)
      __pyx_t_9 = (!__pyx_t_27);
      __pyx_t_8 = __Pyx_PyBool_FromLong(__pyx_t_9); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6056, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_14 = __pyx_t_8;
      __pyx_t_8 = 0;
      __pyx_L42_bool_binop_done:;
      __pyx_r = __pyx_t_14;
      __pyx_t_14 = 0;
      goto __pyx_L8_try_return;

      /* "ws_package/controllers/activity_controller.py":6032
 *             bool: True if both activityLevel and activity_percentage have zero activity
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # Get activityLevel
 *             activityLevel = await self.get_activity_level_from_db(start_date, end_date)
*/
    }
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

    /* "ws_package/controllers/activity_controller.py":6058
 *             return not has_activity_level_activity and not has_activity_percentage_activity
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error checking zero activity for interval: %s", e, exc_info=True)
 *             return False
*/
    __pyx_t_19 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_19) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._has_zero_activity_for_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_14, &__pyx_t_8, &__pyx_t_4) < 0) __PYX_ERR(0, 6058, __pyx_L6_except_error)
      __Pyx_XGOTREF(__pyx_t_14);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_8);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":6059
 * 
 *         except Exception as e:
 *             logger.error("Error checking zero activity for interval: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 *             return False
 * 
*/
        __pyx_t_18 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 6059, __pyx_L49_error)
        __Pyx_GOTREF(__pyx_t_16);
        __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6059, __pyx_L49_error)
        __Pyx_GOTREF(__pyx_t_17);
        __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
        __pyx_t_6 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_17))) {
          __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_17);
          assert(__pyx_t_18);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
          __Pyx_INCREF(__pyx_t_18);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
          __pyx_t_6 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_18, __pyx_mstate_global->__pyx_kp_u_Error_checking_zero_activity_for, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_16 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 6059, __pyx_L49_error)
          __Pyx_GOTREF(__pyx_t_16);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_16, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 6059, __pyx_L49_error)
          __pyx_t_5 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_6, (3-__pyx_t_6) | (__pyx_t_6*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_16);
          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6059, __pyx_L49_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":6060
 *         except Exception as e:
 *             logger.error("Error checking zero activity for interval: %s", e, exc_info=True)
 *             return False             # <<<<<<<<<<<<<<
 * 
 *     async def handle_idle_popup_response(self, keep_idle_time: bool, action: str, project_id: Optional[str] = None, task_id: Optional[str] = None, note: Optional[str] = None, file_path: Optional[str] = None):
*/
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_False);
        __pyx_r = Py_False;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
        goto __pyx_L48_return;
      }

      /* "ws_package/controllers/activity_controller.py":6058
 *             return not has_activity_level_activity and not has_activity_percentage_activity
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error checking zero activity for interval: %s", e, exc_info=True)
 *             return False
*/
      /*finally:*/ {
        __pyx_L49_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_26 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_26, &__pyx_t_25, &__pyx_t_24);
          if ( unlikely(__Pyx_GetException(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11) < 0)) __Pyx_ErrFetch(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_26);
          __Pyx_XGOTREF(__pyx_t_25);
          __Pyx_XGOTREF(__pyx_t_24);
          __pyx_t_19 = __pyx_lineno; __pyx_t_15 = __pyx_clineno; __pyx_t_28 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_26);
          __Pyx_XGIVEREF(__pyx_t_25);
          __Pyx_XGIVEREF(__pyx_t_24);
          __Pyx_ExceptionReset(__pyx_t_26, __pyx_t_25, __pyx_t_24);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_ErrRestore(__pyx_t_13, __pyx_t_12, __pyx_t_11);
          __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_26 = 0; __pyx_t_25 = 0; __pyx_t_24 = 0;
          __pyx_lineno = __pyx_t_19; __pyx_clineno = __pyx_t_15; __pyx_filename = __pyx_t_28;
          goto __pyx_L6_except_error;
        }
        __pyx_L48_return: {
          __pyx_t_24 = __pyx_r;
          __pyx_r = 0;
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          __pyx_r = __pyx_t_24;
          __pyx_t_24 = 0;
          goto __pyx_L7_except_return;
        }
      }
    }
    goto __pyx_L6_except_error;

    /* "ws_package/controllers/activity_controller.py":6032
 *             bool: True if both activityLevel and activity_percentage have zero activity
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # Get activityLevel
 *             activityLevel = await self.get_activity_level_from_db(start_date, end_date)
*/
    __pyx_L6_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L7_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":6021
 *             logger.error("Error triggering idle popup: %s", e, exc_info=True)
 * 
 *     async def _has_zero_activity_for_interval(self, start_date: datetime.datetime, end_date: datetime.datetime) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Check if an interval has zero activity in both activityLevel and activity_percentage.
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_18);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("_has_zero_activity_for_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_203generator43(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":6062
 *             return False
 * 
 *     async def handle_idle_popup_response(self, keep_idle_time: bool, action: str, project_id: Optional[str] = None, task_id: Optional[str] = None, note: Optional[str] = None, file_path: Optional[str] = None):             # <<<<<<<<<<<<<<
 *         """
 *         Handle idle popup response from Electron.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_202handle_idle_popup_response(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_201handle_idle_popup_response, "\n        Handle idle popup response from Electron.\n\n        CRITICAL: The first popup response (keep/unkeep/stop/continue) applies to ALL consecutive\n        idle intervals in the current session. Python sends idle triggers every interval (no cooldown),\n        frontend shows only one popup and suppresses duplicates; this single response handles all.\n        \n        Args:\n            keep_idle_time: True if \"keep\" checkbox is checked, False if unchecked\n            action: Action taken ('continue', 'stop', 'reassign')\n            project_id: Project ID for reassign action (required if action is 'reassign')\n            task_id: Task ID for reassign action (optional, defaults to \"0\" if not provided)\n            note: Optional note provided by user when keeping idle time (max 120 characters)\n            file_path: Optional local file path to upload to S3\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_202handle_idle_popup_response = {"handle_idle_popup_response", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_202handle_idle_popup_response, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_201handle_idle_popup_response};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_202handle_idle_popup_response(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  int __pyx_v_keep_idle_time;
  PyObject *__pyx_v_action = 0;
  PyObject *__pyx_v_project_id = 0;
  PyObject *__pyx_v_task_id = 0;
  PyObject *__pyx_v_note = 0;
  PyObject *__pyx_v_file_path = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[7] = {0,0,0,0,0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("handle_idle_popup_response (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_keep_idle_time,&__pyx_mstate_global->__pyx_n_u_action,&__pyx_mstate_global->__pyx_n_u_project_id,&__pyx_mstate_global->__pyx_n_u_task_id,&__pyx_mstate_global->__pyx_n_u_note,&__pyx_mstate_global->__pyx_n_u_file_path,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 6062, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  7:
        values[6] = __Pyx_ArgRef_FASTCALL(__pyx_args, 6);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[6])) __PYX_ERR(0, 6062, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  6:
        values[5] = __Pyx_ArgRef_FASTCALL(__pyx_args, 5);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[5])) __PYX_ERR(0, 6062, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  5:
        values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 6062, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  4:
        values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 6062, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 6062, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 6062, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 6062, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "handle_idle_popup_response", 0) < (0)) __PYX_ERR(0, 6062, __pyx_L3_error)
      if (!values[3]) values[3] = __Pyx_NewRef(((PyObject*)Py_None));
      if (!values[4]) values[4] = __Pyx_NewRef(((PyObject*)Py_None));
      if (!values[5]) values[5] = __Pyx_NewRef(((PyObject*)Py_None));
      if (!values[6]) values[6] = __Pyx_NewRef(((PyObject*)Py_None));
      for (Py_ssize_t i = __pyx_nargs; i < 3; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("handle_idle_popup_response", 0, 3, 7, i); __PYX_ERR(0, 6062, __pyx_L3_error) }
      }
    } else {
      switch (__pyx_nargs) {
        case  7:
        values[6] = __Pyx_ArgRef_FASTCALL(__pyx_args, 6);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[6])) __PYX_ERR(0, 6062, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  6:
        values[5] = __Pyx_ArgRef_FASTCALL(__pyx_args, 5);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[5])) __PYX_ERR(0, 6062, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  5:
        values[4] = __Pyx_ArgRef_FASTCALL(__pyx_args, 4);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[4])) __PYX_ERR(0, 6062, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  4:
        values[3] = __Pyx_ArgRef_FASTCALL(__pyx_args, 3);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[3])) __PYX_ERR(0, 6062, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 6062, __pyx_L3_error)
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 6062, __pyx_L3_error)
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 6062, __pyx_L3_error)
        break;
        default: goto __pyx_L5_argtuple_error;
      }
      if (!values[3]) values[3] = __Pyx_NewRef(((PyObject*)Py_None));
      if (!values[4]) values[4] = __Pyx_NewRef(((PyObject*)Py_None));
      if (!values[5]) values[5] = __Pyx_NewRef(((PyObject*)Py_None));
      if (!values[6]) values[6] = __Pyx_NewRef(((PyObject*)Py_None));
    }
    __pyx_v_self = values[0];
    __pyx_v_keep_idle_time = __Pyx_PyObject_IsTrue(values[1]); if (unlikely((__pyx_v_keep_idle_time == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 6062, __pyx_L3_error)
    __pyx_v_action = ((PyObject*)values[2]);
    __pyx_v_project_id = ((PyObject*)values[3]);
    __pyx_v_task_id = ((PyObject*)values[4]);
    __pyx_v_note = ((PyObject*)values[5]);
    __pyx_v_file_path = ((PyObject*)values[6]);
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("handle_idle_popup_response", 0, 3, 7, __pyx_nargs); __PYX_ERR(0, 6062, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.handle_idle_popup_response", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_action), (&PyUnicode_Type), 0, "action", 2))) __PYX_ERR(0, 6062, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_project_id), (&PyUnicode_Type), 1, "project_id", 2))) __PYX_ERR(0, 6062, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_task_id), (&PyUnicode_Type), 1, "task_id", 2))) __PYX_ERR(0, 6062, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_note), (&PyUnicode_Type), 1, "note", 2))) __PYX_ERR(0, 6062, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_file_path), (&PyUnicode_Type), 1, "file_path", 2))) __PYX_ERR(0, 6062, __pyx_L1_error)
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_201handle_idle_popup_response(__pyx_self, __pyx_v_self, __pyx_v_keep_idle_time, __pyx_v_action, __pyx_v_project_id, __pyx_v_task_id, __pyx_v_note, __pyx_v_file_path);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  goto __pyx_L7_cleaned_up;
  __pyx_L0:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __pyx_L7_cleaned_up:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_201handle_idle_popup_response(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, int __pyx_v_keep_idle_time, PyObject *__pyx_v_action, PyObject *__pyx_v_project_id, PyObject *__pyx_v_task_id, PyObject *__pyx_v_note, PyObject *__pyx_v_file_path) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("handle_idle_popup_response", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 6062, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_keep_idle_time = __pyx_v_keep_idle_time;
  __pyx_cur_scope->__pyx_v_action = __pyx_v_action;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_action);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_action);
  __pyx_cur_scope->__pyx_v_project_id = __pyx_v_project_id;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_project_id);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_project_id);
  __pyx_cur_scope->__pyx_v_task_id = __pyx_v_task_id;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_task_id);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_task_id);
  __pyx_cur_scope->__pyx_v_note = __pyx_v_note;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_note);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_note);
  __pyx_cur_scope->__pyx_v_file_path = __pyx_v_file_path;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_file_path);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_file_path);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_203generator43, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[69]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_handle_idle_popup_response, __pyx_mstate_global->__pyx_n_u_ActivityController_handle_idle_p, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 6062, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.handle_idle_popup_response", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_203generator43(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  size_t __pyx_t_8;
  __Pyx_PySendResult __pyx_t_9;
  int __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  int __pyx_t_14;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_t_18;
  char const *__pyx_t_19;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  int __pyx_t_26;
  Py_ssize_t __pyx_t_27;
  PyObject *(*__pyx_t_28)(PyObject *);
  PyObject *__pyx_t_29 = NULL;
  PyObject *__pyx_t_30 = NULL;
  char const *__pyx_t_31;
  char const *__pyx_t_32;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("handle_idle_popup_response", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L10_resume_from_await;
    case 2: goto __pyx_L18_resume_from_await;
    case 3: goto __pyx_L20_resume_from_await;
    case 4: goto __pyx_L28_resume_from_await;
    case 5: goto __pyx_L40_resume_from_await;
    case 6: goto __pyx_L44_resume_from_await;
    case 7: goto __pyx_L47_resume_from_await;
    case 8: goto __pyx_L88_resume_from_await;
    case 9: goto __pyx_L89_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 6062, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":6078
 *             file_path: Optional local file path to upload to S3
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             logger.info("[IdleResponse] Handling idle popup response: keep_idle_time=%s, action=%s, project_id=%s, task_id=%s, file_path=%s", keep_idle_time, action, project_id, task_id, file_path)
 * 
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":6079
 *         """
 *         try:
 *             logger.info("[IdleResponse] Handling idle popup response: keep_idle_time=%s, action=%s, project_id=%s, task_id=%s, file_path=%s", keep_idle_time, action, project_id, task_id, file_path)             # <<<<<<<<<<<<<<
 * 
 *             await self._persist_idle_popup_intervals_minimum_activity(minimum_percent=1.0)
*/
      __pyx_t_5 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6079, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6079, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_cur_scope->__pyx_v_keep_idle_time); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6079, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_5);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[7] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_IdleResponse_Handling_idle_popu, __pyx_t_6, __pyx_cur_scope->__pyx_v_action, __pyx_cur_scope->__pyx_v_project_id, __pyx_cur_scope->__pyx_v_task_id, __pyx_cur_scope->__pyx_v_file_path};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (7-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6079, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":6081
 *             logger.info("[IdleResponse] Handling idle popup response: keep_idle_time=%s, action=%s, project_id=%s, task_id=%s, file_path=%s", keep_idle_time, action, project_id, task_id, file_path)
 * 
 *             await self._persist_idle_popup_intervals_minimum_activity(minimum_percent=1.0)             # <<<<<<<<<<<<<<
 * 
 *             # Upload file to S3 if file_path is provided
*/
      __pyx_t_7 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_7);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_7, NULL};
        __pyx_t_6 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6081, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_minimum_percent, __pyx_mstate_global->__pyx_float_1_0, __pyx_t_6, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 6081, __pyx_L4_error)
        __pyx_t_4 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_persist_idle_popup_intervals_mi, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_6);
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6081, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (likely(__pyx_t_9 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
        __Pyx_XGIVEREF(__pyx_t_2);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
        __Pyx_XGIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 1;
        return __pyx_r;
        __pyx_L10_resume_from_await:;
        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_1);
        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_2);
        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_3);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6081, __pyx_L4_error)
      } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_DECREF(__pyx_r); __pyx_r = 0;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 6081, __pyx_L4_error)
      }

      /* "ws_package/controllers/activity_controller.py":6084
 * 
 *             # Upload file to S3 if file_path is provided
 *             s3_file_url = None             # <<<<<<<<<<<<<<
 *             file_upload_success = False
 *             if file_path:
*/
      __Pyx_INCREF(Py_None);
      __Pyx_GIVEREF(Py_None);
      __pyx_cur_scope->__pyx_v_s3_file_url = Py_None;

      /* "ws_package/controllers/activity_controller.py":6085
 *             # Upload file to S3 if file_path is provided
 *             s3_file_url = None
 *             file_upload_success = False             # <<<<<<<<<<<<<<
 *             if file_path:
 *                 try:
*/
      __pyx_cur_scope->__pyx_v_file_upload_success = 0;

      /* "ws_package/controllers/activity_controller.py":6086
 *             s3_file_url = None
 *             file_upload_success = False
 *             if file_path:             # <<<<<<<<<<<<<<
 *                 try:
 *                     s3_file_url = await self._upload_file_to_s3(file_path)
*/
      if (__pyx_cur_scope->__pyx_v_file_path == Py_None) __pyx_t_10 = 0;
      else
      {
        Py_ssize_t __pyx_temp = __Pyx_PyUnicode_IS_TRUE(__pyx_cur_scope->__pyx_v_file_path);
        if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 6086, __pyx_L4_error)
        __pyx_t_10 = (__pyx_temp != 0);
      }

      if (__pyx_t_10) {

        /* "ws_package/controllers/activity_controller.py":6087
 *             file_upload_success = False
 *             if file_path:
 *                 try:             # <<<<<<<<<<<<<<
 *                     s3_file_url = await self._upload_file_to_s3(file_path)
 *                     if s3_file_url:
*/
        {
          __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_13);
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":6088
 *             if file_path:
 *                 try:
 *                     s3_file_url = await self._upload_file_to_s3(file_path)             # <<<<<<<<<<<<<<
 *                     if s3_file_url:
 *                         logger.info("File uploaded to S3 successfully: %s", s3_file_url)
*/
            __pyx_t_6 = __pyx_cur_scope->__pyx_v_self;
            __Pyx_INCREF(__pyx_t_6);
            __pyx_t_8 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_cur_scope->__pyx_v_file_path};
              __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_upload_file_to_s3, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6088, __pyx_L12_error)
              __Pyx_GOTREF(__pyx_t_4);
            }
            __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (likely(__pyx_t_9 == PYGEN_NEXT)) {
              __Pyx_GOTREF(__pyx_r);
              __Pyx_XGIVEREF(__pyx_t_1);
              __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
              __Pyx_XGIVEREF(__pyx_t_2);
              __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
              __Pyx_XGIVEREF(__pyx_t_3);
              __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
              __Pyx_XGIVEREF(__pyx_t_11);
              __pyx_cur_scope->__pyx_t_3 = __pyx_t_11;
              __Pyx_XGIVEREF(__pyx_t_12);
              __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
              __Pyx_XGIVEREF(__pyx_t_13);
              __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
              __Pyx_XGIVEREF(__pyx_r);
              __Pyx_RefNannyFinishContext();
              __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
              /* return from generator, awaiting value */
              __pyx_generator->resume_label = 2;
              return __pyx_r;
              __pyx_L18_resume_from_await:;
              __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
              __pyx_cur_scope->__pyx_t_0 = 0;
              __Pyx_XGOTREF(__pyx_t_1);
              __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
              __pyx_cur_scope->__pyx_t_1 = 0;
              __Pyx_XGOTREF(__pyx_t_2);
              __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
              __pyx_cur_scope->__pyx_t_2 = 0;
              __Pyx_XGOTREF(__pyx_t_3);
              __pyx_t_11 = __pyx_cur_scope->__pyx_t_3;
              __pyx_cur_scope->__pyx_t_3 = 0;
              __Pyx_XGOTREF(__pyx_t_11);
              __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
              __pyx_cur_scope->__pyx_t_4 = 0;
              __Pyx_XGOTREF(__pyx_t_12);
              __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
              __pyx_cur_scope->__pyx_t_5 = 0;
              __Pyx_XGOTREF(__pyx_t_13);
              if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6088, __pyx_L12_error)
              __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
            } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
              __Pyx_GOTREF(__pyx_r);
              __pyx_t_4 = __pyx_r; __pyx_r = NULL;
            } else {
              __Pyx_XGOTREF(__pyx_r);
              __PYX_ERR(0, 6088, __pyx_L12_error)
            }
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_s3_file_url);
            __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_s3_file_url, __pyx_t_4);
            __Pyx_GIVEREF(__pyx_t_4);
            __pyx_t_4 = 0;

            /* "ws_package/controllers/activity_controller.py":6089
 *                 try:
 *                     s3_file_url = await self._upload_file_to_s3(file_path)
 *                     if s3_file_url:             # <<<<<<<<<<<<<<
 *                         logger.info("File uploaded to S3 successfully: %s", s3_file_url)
 *                         file_upload_success = True
*/
            __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_s3_file_url); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 6089, __pyx_L12_error)
            if (__pyx_t_10) {

              /* "ws_package/controllers/activity_controller.py":6090
 *                     s3_file_url = await self._upload_file_to_s3(file_path)
 *                     if s3_file_url:
 *                         logger.info("File uploaded to S3 successfully: %s", s3_file_url)             # <<<<<<<<<<<<<<
 *                         file_upload_success = True
 *                     else:
*/
              __pyx_t_6 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6090, __pyx_L12_error)
              __Pyx_GOTREF(__pyx_t_7);
              __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6090, __pyx_L12_error)
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_5))) {
                __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
                assert(__pyx_t_6);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                __Pyx_INCREF(__pyx_t_6);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_File_uploaded_to_S3_successfully, __pyx_cur_scope->__pyx_v_s3_file_url};
                __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6090, __pyx_L12_error)
                __Pyx_GOTREF(__pyx_t_4);
              }
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

              /* "ws_package/controllers/activity_controller.py":6091
 *                     if s3_file_url:
 *                         logger.info("File uploaded to S3 successfully: %s", s3_file_url)
 *                         file_upload_success = True             # <<<<<<<<<<<<<<
 *                     else:
 *                         logger.warning("File upload to S3 failed or returned no URL for file: %s", file_path)
*/
              __pyx_cur_scope->__pyx_v_file_upload_success = 1;

              /* "ws_package/controllers/activity_controller.py":6089
 *                 try:
 *                     s3_file_url = await self._upload_file_to_s3(file_path)
 *                     if s3_file_url:             # <<<<<<<<<<<<<<
 *                         logger.info("File uploaded to S3 successfully: %s", s3_file_url)
 *                         file_upload_success = True
*/
              goto __pyx_L19;
            }

            /* "ws_package/controllers/activity_controller.py":6093
 *                         file_upload_success = True
 *                     else:
 *                         logger.warning("File upload to S3 failed or returned no URL for file: %s", file_path)             # <<<<<<<<<<<<<<
 *                         # Send failure message to Electron immediately
 *                         await self._send_file_upload_failure_to_electron()
*/
            /*else*/ {
              __pyx_t_5 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6093, __pyx_L12_error)
              __Pyx_GOTREF(__pyx_t_6);
              __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6093, __pyx_L12_error)
              __Pyx_GOTREF(__pyx_t_7);
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_7))) {
                __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
                assert(__pyx_t_5);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                __Pyx_INCREF(__pyx_t_5);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_File_upload_to_S3_failed_or_retu, __pyx_cur_scope->__pyx_v_file_path};
                __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6093, __pyx_L12_error)
                __Pyx_GOTREF(__pyx_t_4);
              }
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

              /* "ws_package/controllers/activity_controller.py":6095
 *                         logger.warning("File upload to S3 failed or returned no URL for file: %s", file_path)
 *                         # Send failure message to Electron immediately
 *                         await self._send_file_upload_failure_to_electron()             # <<<<<<<<<<<<<<
 *                 except Exception as e:
 *                     logger.error("Error uploading file to S3: %s", e, exc_info=True)
*/
              __pyx_t_7 = __pyx_cur_scope->__pyx_v_self;
              __Pyx_INCREF(__pyx_t_7);
              __pyx_t_8 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
                __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_send_file_upload_failure_to_ele, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6095, __pyx_L12_error)
                __Pyx_GOTREF(__pyx_t_4);
              }
              __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              if (likely(__pyx_t_9 == PYGEN_NEXT)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_XGIVEREF(__pyx_t_1);
                __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                __Pyx_XGIVEREF(__pyx_t_2);
                __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                __Pyx_XGIVEREF(__pyx_t_3);
                __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                __Pyx_XGIVEREF(__pyx_t_11);
                __pyx_cur_scope->__pyx_t_3 = __pyx_t_11;
                __Pyx_XGIVEREF(__pyx_t_12);
                __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                __Pyx_XGIVEREF(__pyx_t_13);
                __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                __Pyx_XGIVEREF(__pyx_r);
                __Pyx_RefNannyFinishContext();
                __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                /* return from generator, awaiting value */
                __pyx_generator->resume_label = 3;
                return __pyx_r;
                __pyx_L20_resume_from_await:;
                __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                __pyx_cur_scope->__pyx_t_0 = 0;
                __Pyx_XGOTREF(__pyx_t_1);
                __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                __pyx_cur_scope->__pyx_t_1 = 0;
                __Pyx_XGOTREF(__pyx_t_2);
                __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                __pyx_cur_scope->__pyx_t_2 = 0;
                __Pyx_XGOTREF(__pyx_t_3);
                __pyx_t_11 = __pyx_cur_scope->__pyx_t_3;
                __pyx_cur_scope->__pyx_t_3 = 0;
                __Pyx_XGOTREF(__pyx_t_11);
                __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                __pyx_cur_scope->__pyx_t_4 = 0;
                __Pyx_XGOTREF(__pyx_t_12);
                __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                __pyx_cur_scope->__pyx_t_5 = 0;
                __Pyx_XGOTREF(__pyx_t_13);
                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6095, __pyx_L12_error)
              } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_DECREF(__pyx_r); __pyx_r = 0;
              } else {
                __Pyx_XGOTREF(__pyx_r);
                __PYX_ERR(0, 6095, __pyx_L12_error)
              }
            }
            __pyx_L19:;

            /* "ws_package/controllers/activity_controller.py":6087
 *             file_upload_success = False
 *             if file_path:
 *                 try:             # <<<<<<<<<<<<<<
 *                     s3_file_url = await self._upload_file_to_s3(file_path)
 *                     if s3_file_url:
*/
          }
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          goto __pyx_L17_try_end;
          __pyx_L12_error:;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

          /* "ws_package/controllers/activity_controller.py":6096
 *                         # Send failure message to Electron immediately
 *                         await self._send_file_upload_failure_to_electron()
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Error uploading file to S3: %s", e, exc_info=True)
 *                     # Send failure message to Electron immediately
*/
          __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
          if (__pyx_t_14) {
            __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.handle_idle_popup_response", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_7, &__pyx_t_5) < 0) __PYX_ERR(0, 6096, __pyx_L14_except_error)
            __Pyx_XGOTREF(__pyx_t_4);
            __Pyx_XGOTREF(__pyx_t_7);
            __Pyx_XGOTREF(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_7);
            __Pyx_GIVEREF(__pyx_t_7);
            __pyx_cur_scope->__pyx_v_e = __pyx_t_7;
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":6097
 *                         await self._send_file_upload_failure_to_electron()
 *                 except Exception as e:
 *                     logger.error("Error uploading file to S3: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 *                     # Send failure message to Electron immediately
 *                     await self._send_file_upload_failure_to_electron()
*/
              __pyx_t_15 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 6097, __pyx_L26_error)
              __Pyx_GOTREF(__pyx_t_16);
              __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_16, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6097, __pyx_L26_error)
              __Pyx_GOTREF(__pyx_t_17);
              __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
              __pyx_t_8 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_17))) {
                __pyx_t_15 = PyMethod_GET_SELF(__pyx_t_17);
                assert(__pyx_t_15);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
                __Pyx_INCREF(__pyx_t_15);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
                __pyx_t_8 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_15, __pyx_mstate_global->__pyx_kp_u_Error_uploading_file_to_S3_s, __pyx_cur_scope->__pyx_v_e};
                __pyx_t_16 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 6097, __pyx_L26_error)
                __Pyx_GOTREF(__pyx_t_16);
                if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_16, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 6097, __pyx_L26_error)
                __pyx_t_6 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_16);
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6097, __pyx_L26_error)
                __Pyx_GOTREF(__pyx_t_6);
              }
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

              /* "ws_package/controllers/activity_controller.py":6099
 *                     logger.error("Error uploading file to S3: %s", e, exc_info=True)
 *                     # Send failure message to Electron immediately
 *                     await self._send_file_upload_failure_to_electron()             # <<<<<<<<<<<<<<
 *                     # Continue without file - note will be saved without file_path
 * 
*/
              __pyx_t_17 = __pyx_cur_scope->__pyx_v_self;
              __Pyx_INCREF(__pyx_t_17);
              __pyx_t_8 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_17, NULL};
                __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_send_file_upload_failure_to_ele, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6099, __pyx_L26_error)
                __Pyx_GOTREF(__pyx_t_6);
              }
              __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_6, &__pyx_r);
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              if (likely(__pyx_t_9 == PYGEN_NEXT)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_XGIVEREF(__pyx_t_1);
                __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                __Pyx_XGIVEREF(__pyx_t_2);
                __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                __Pyx_XGIVEREF(__pyx_t_3);
                __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                __Pyx_XGIVEREF(__pyx_t_4);
                __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
                __Pyx_XGIVEREF(__pyx_t_5);
                __pyx_cur_scope->__pyx_t_4 = __pyx_t_5;
                __Pyx_XGIVEREF(__pyx_t_7);
                __pyx_cur_scope->__pyx_t_5 = __pyx_t_7;
                __Pyx_XGIVEREF(__pyx_t_11);
                __pyx_cur_scope->__pyx_t_6 = __pyx_t_11;
                __Pyx_XGIVEREF(__pyx_t_12);
                __pyx_cur_scope->__pyx_t_7 = __pyx_t_12;
                __Pyx_XGIVEREF(__pyx_t_13);
                __pyx_cur_scope->__pyx_t_8 = __pyx_t_13;
                __Pyx_XGIVEREF(__pyx_r);
                __Pyx_RefNannyFinishContext();
                __Pyx_Coroutine_SwapException(__pyx_generator);
                /* return from generator, awaiting value */
                __pyx_generator->resume_label = 4;
                return __pyx_r;
                __pyx_L28_resume_from_await:;
                __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                __pyx_cur_scope->__pyx_t_0 = 0;
                __Pyx_XGOTREF(__pyx_t_1);
                __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                __pyx_cur_scope->__pyx_t_1 = 0;
                __Pyx_XGOTREF(__pyx_t_2);
                __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                __pyx_cur_scope->__pyx_t_2 = 0;
                __Pyx_XGOTREF(__pyx_t_3);
                __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
                __pyx_cur_scope->__pyx_t_3 = 0;
                __Pyx_XGOTREF(__pyx_t_4);
                __pyx_t_5 = __pyx_cur_scope->__pyx_t_4;
                __pyx_cur_scope->__pyx_t_4 = 0;
                __Pyx_XGOTREF(__pyx_t_5);
                __pyx_t_7 = __pyx_cur_scope->__pyx_t_5;
                __pyx_cur_scope->__pyx_t_5 = 0;
                __Pyx_XGOTREF(__pyx_t_7);
                __pyx_t_11 = __pyx_cur_scope->__pyx_t_6;
                __pyx_cur_scope->__pyx_t_6 = 0;
                __Pyx_XGOTREF(__pyx_t_11);
                __pyx_t_12 = __pyx_cur_scope->__pyx_t_7;
                __pyx_cur_scope->__pyx_t_7 = 0;
                __Pyx_XGOTREF(__pyx_t_12);
                __pyx_t_13 = __pyx_cur_scope->__pyx_t_8;
                __pyx_cur_scope->__pyx_t_8 = 0;
                __Pyx_XGOTREF(__pyx_t_13);
                if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6099, __pyx_L26_error)
              } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
                __Pyx_GOTREF(__pyx_r);
                __Pyx_DECREF(__pyx_r); __pyx_r = 0;
              } else {
                __Pyx_XGOTREF(__pyx_r);
                __PYX_ERR(0, 6099, __pyx_L26_error)
              }
            }

            /* "ws_package/controllers/activity_controller.py":6096
 *                         # Send failure message to Electron immediately
 *                         await self._send_file_upload_failure_to_electron()
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Error uploading file to S3: %s", e, exc_info=True)
 *                     # Send failure message to Electron immediately
*/
            /*finally:*/ {
              /*normal exit:*/{
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                goto __pyx_L27;
              }
              __pyx_L26_error:;
              /*exception exit:*/{
                __Pyx_PyThreadState_assign
                __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0;
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                 __Pyx_ExceptionSwap(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25);
                if ( unlikely(__Pyx_GetException(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22) < 0)) __Pyx_ErrFetch(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
                __Pyx_XGOTREF(__pyx_t_20);
                __Pyx_XGOTREF(__pyx_t_21);
                __Pyx_XGOTREF(__pyx_t_22);
                __Pyx_XGOTREF(__pyx_t_23);
                __Pyx_XGOTREF(__pyx_t_24);
                __Pyx_XGOTREF(__pyx_t_25);
                __pyx_t_14 = __pyx_lineno; __pyx_t_18 = __pyx_clineno; __pyx_t_19 = __pyx_filename;
                {
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                }
                __Pyx_XGIVEREF(__pyx_t_23);
                __Pyx_XGIVEREF(__pyx_t_24);
                __Pyx_XGIVEREF(__pyx_t_25);
                __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_24, __pyx_t_25);
                __Pyx_XGIVEREF(__pyx_t_20);
                __Pyx_XGIVEREF(__pyx_t_21);
                __Pyx_XGIVEREF(__pyx_t_22);
                __Pyx_ErrRestore(__pyx_t_20, __pyx_t_21, __pyx_t_22);
                __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0; __pyx_t_25 = 0;
                __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_18; __pyx_filename = __pyx_t_19;
                goto __pyx_L14_except_error;
              }
              __pyx_L27:;
            }
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            goto __pyx_L13_exception_handled;
          }
          goto __pyx_L14_except_error;

          /* "ws_package/controllers/activity_controller.py":6087
 *             file_upload_success = False
 *             if file_path:
 *                 try:             # <<<<<<<<<<<<<<
 *                     s3_file_url = await self._upload_file_to_s3(file_path)
 *                     if s3_file_url:
*/
          __pyx_L14_except_error:;
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
          goto __pyx_L4_error;
          __pyx_L13_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
          __pyx_L17_try_end:;
        }

        /* "ws_package/controllers/activity_controller.py":6086
 *             s3_file_url = None
 *             file_upload_success = False
 *             if file_path:             # <<<<<<<<<<<<<<
 *                 try:
 *                     s3_file_url = await self._upload_file_to_s3(file_path)
*/
      }

      /* "ws_package/controllers/activity_controller.py":6104
 *             # Save note and/or file URL to the idle intervals
 *             # We save if there's a note OR if a file was successfully uploaded
 *             if (note is not None and note.strip()) or s3_file_url:             # <<<<<<<<<<<<<<
 *                 # Use empty string for note if only file is provided
 *                 note_text = note if (note is not None and note.strip()) else ""
*/
      __pyx_t_26 = (__pyx_cur_scope->__pyx_v_note != ((PyObject*)Py_None));
      if (!__pyx_t_26) {
        goto __pyx_L35_next_or;
      } else {
      }
      __pyx_t_5 = __Pyx_CallUnboundCMethod0(&__pyx_mstate_global->__pyx_umethod_PyUnicode_Type__strip, __pyx_cur_scope->__pyx_v_note); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6104, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      {
        Py_ssize_t __pyx_temp = __Pyx_PyUnicode_IS_TRUE(__pyx_t_5);
        if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 6104, __pyx_L4_error)
        __pyx_t_26 = (__pyx_temp != 0);
      }

      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (!__pyx_t_26) {
      } else {
        __pyx_t_10 = __pyx_t_26;
        goto __pyx_L34_bool_binop_done;
      }
      __pyx_L35_next_or:;
      __pyx_t_26 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_s3_file_url); if (unlikely((__pyx_t_26 < 0))) __PYX_ERR(0, 6104, __pyx_L4_error)
      __pyx_t_10 = __pyx_t_26;
      __pyx_L34_bool_binop_done:;
      if (__pyx_t_10) {

        /* "ws_package/controllers/activity_controller.py":6106
 *             if (note is not None and note.strip()) or s3_file_url:
 *                 # Use empty string for note if only file is provided
 *                 note_text = note if (note is not None and note.strip()) else ""             # <<<<<<<<<<<<<<
 * 
 *                 # Truncate note to maximum 120 characters
*/
        __pyx_t_26 = (__pyx_cur_scope->__pyx_v_note != ((PyObject*)Py_None));
        if (__pyx_t_26) {
        } else {
          __pyx_t_10 = __pyx_t_26;
          goto __pyx_L37_bool_binop_done;
        }
        __pyx_t_7 = __Pyx_CallUnboundCMethod0(&__pyx_mstate_global->__pyx_umethod_PyUnicode_Type__strip, __pyx_cur_scope->__pyx_v_note); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6106, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        {
          Py_ssize_t __pyx_temp = __Pyx_PyUnicode_IS_TRUE(__pyx_t_7);
          if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 6106, __pyx_L4_error)
          __pyx_t_26 = (__pyx_temp != 0);
        }

        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_10 = __pyx_t_26;
        __pyx_L37_bool_binop_done:;
        if (__pyx_t_10) {
          __Pyx_INCREF(__pyx_cur_scope->__pyx_v_note);
          __pyx_t_5 = __pyx_cur_scope->__pyx_v_note;
        } else {
          __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u__2);
          __pyx_t_5 = __pyx_mstate_global->__pyx_kp_u__2;
        }
        __Pyx_GIVEREF(__pyx_t_5);
        __pyx_cur_scope->__pyx_v_note_text = ((PyObject*)__pyx_t_5);
        __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":6109
 * 
 *                 # Truncate note to maximum 120 characters
 *                 MAX_NOTE_LENGTH = 120             # <<<<<<<<<<<<<<
 *                 if len(note_text) > MAX_NOTE_LENGTH:
 *                     original_length = len(note_text)
*/
        __pyx_cur_scope->__pyx_v_MAX_NOTE_LENGTH = 0x78;

        /* "ws_package/controllers/activity_controller.py":6110
 *                 # Truncate note to maximum 120 characters
 *                 MAX_NOTE_LENGTH = 120
 *                 if len(note_text) > MAX_NOTE_LENGTH:             # <<<<<<<<<<<<<<
 *                     original_length = len(note_text)
 *                     note_text = note_text[:MAX_NOTE_LENGTH]
*/
        if (unlikely(__pyx_cur_scope->__pyx_v_note_text == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
          __PYX_ERR(0, 6110, __pyx_L4_error)
        }
        __pyx_t_27 = __Pyx_PyUnicode_GET_LENGTH(__pyx_cur_scope->__pyx_v_note_text); if (unlikely(__pyx_t_27 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6110, __pyx_L4_error)
        __pyx_t_10 = (__pyx_t_27 > __pyx_cur_scope->__pyx_v_MAX_NOTE_LENGTH);
        if (__pyx_t_10) {

          /* "ws_package/controllers/activity_controller.py":6111
 *                 MAX_NOTE_LENGTH = 120
 *                 if len(note_text) > MAX_NOTE_LENGTH:
 *                     original_length = len(note_text)             # <<<<<<<<<<<<<<
 *                     note_text = note_text[:MAX_NOTE_LENGTH]
 *                     logger.warning("Note truncated from %s to %s characters", original_length, MAX_NOTE_LENGTH)
*/
          if (unlikely(__pyx_cur_scope->__pyx_v_note_text == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
            __PYX_ERR(0, 6111, __pyx_L4_error)
          }
          __pyx_t_27 = __Pyx_PyUnicode_GET_LENGTH(__pyx_cur_scope->__pyx_v_note_text); if (unlikely(__pyx_t_27 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6111, __pyx_L4_error)
          __pyx_cur_scope->__pyx_v_original_length = __pyx_t_27;

          /* "ws_package/controllers/activity_controller.py":6112
 *                 if len(note_text) > MAX_NOTE_LENGTH:
 *                     original_length = len(note_text)
 *                     note_text = note_text[:MAX_NOTE_LENGTH]             # <<<<<<<<<<<<<<
 *                     logger.warning("Note truncated from %s to %s characters", original_length, MAX_NOTE_LENGTH)
 * 
*/
          if (unlikely(__pyx_cur_scope->__pyx_v_note_text == Py_None)) {
            PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
            __PYX_ERR(0, 6112, __pyx_L4_error)
          }
          __pyx_t_5 = __Pyx_PyUnicode_Substring(__pyx_cur_scope->__pyx_v_note_text, 0, __pyx_cur_scope->__pyx_v_MAX_NOTE_LENGTH); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6112, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_note_text);
          __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_note_text, ((PyObject*)__pyx_t_5));
          __Pyx_GIVEREF(__pyx_t_5);
          __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":6113
 *                     original_length = len(note_text)
 *                     note_text = note_text[:MAX_NOTE_LENGTH]
 *                     logger.warning("Note truncated from %s to %s characters", original_length, MAX_NOTE_LENGTH)             # <<<<<<<<<<<<<<
 * 
 *                 await self._save_note_to_idle_intervals(note_text, s3_file_url)
*/
          __pyx_t_7 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6113, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6113, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_4 = PyLong_FromSsize_t(__pyx_cur_scope->__pyx_v_original_length); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6113, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_17 = __Pyx_PyLong_From_long(__pyx_cur_scope->__pyx_v_MAX_NOTE_LENGTH); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6113, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_6))) {
            __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
            assert(__pyx_t_7);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
            __Pyx_INCREF(__pyx_t_7);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[4] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Note_truncated_from_s_to_s_chara, __pyx_t_4, __pyx_t_17};
            __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6113, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":6110
 *                 # Truncate note to maximum 120 characters
 *                 MAX_NOTE_LENGTH = 120
 *                 if len(note_text) > MAX_NOTE_LENGTH:             # <<<<<<<<<<<<<<
 *                     original_length = len(note_text)
 *                     note_text = note_text[:MAX_NOTE_LENGTH]
*/
        }

        /* "ws_package/controllers/activity_controller.py":6115
 *                     logger.warning("Note truncated from %s to %s characters", original_length, MAX_NOTE_LENGTH)
 * 
 *                 await self._save_note_to_idle_intervals(note_text, s3_file_url)             # <<<<<<<<<<<<<<
 *                 logger.info("Note/File saved to idle intervals: note_length=%s, has_file=%s", len(note_text), s3_file_url is not None)
 * 
*/
        __pyx_t_6 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_6);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_cur_scope->__pyx_v_note_text, __pyx_cur_scope->__pyx_v_s3_file_url};
          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_save_note_to_idle_intervals, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6115, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (likely(__pyx_t_9 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_1);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
          __Pyx_XGIVEREF(__pyx_t_2);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
          __Pyx_XGIVEREF(__pyx_t_3);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 5;
          return __pyx_r;
          __pyx_L40_resume_from_await:;
          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_1);
          __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_2);
          __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_3);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6115, __pyx_L4_error)
        } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_DECREF(__pyx_r); __pyx_r = 0;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 6115, __pyx_L4_error)
        }

        /* "ws_package/controllers/activity_controller.py":6116
 * 
 *                 await self._save_note_to_idle_intervals(note_text, s3_file_url)
 *                 logger.info("Note/File saved to idle intervals: note_length=%s, has_file=%s", len(note_text), s3_file_url is not None)             # <<<<<<<<<<<<<<
 * 
 *             # Send success message to Electron ONLY after database queuing
*/
        __pyx_t_6 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6116, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6116, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        if (unlikely(__pyx_cur_scope->__pyx_v_note_text == Py_None)) {
          PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()");
          __PYX_ERR(0, 6116, __pyx_L4_error)
        }
        __pyx_t_27 = __Pyx_PyUnicode_GET_LENGTH(__pyx_cur_scope->__pyx_v_note_text); if (unlikely(__pyx_t_27 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6116, __pyx_L4_error)
        __pyx_t_17 = PyLong_FromSsize_t(__pyx_t_27); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6116, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_10 = (__pyx_cur_scope->__pyx_v_s3_file_url != Py_None);
        __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_t_10); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6116, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
          assert(__pyx_t_6);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[4] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Note_File_saved_to_idle_interval, __pyx_t_17, __pyx_t_7};
          __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6116, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":6104
 *             # Save note and/or file URL to the idle intervals
 *             # We save if there's a note OR if a file was successfully uploaded
 *             if (note is not None and note.strip()) or s3_file_url:             # <<<<<<<<<<<<<<
 *                 # Use empty string for note if only file is provided
 *                 note_text = note if (note is not None and note.strip()) else ""
*/
      }

      /* "ws_package/controllers/activity_controller.py":6119
 * 
 *             # Send success message to Electron ONLY after database queuing
 *             if file_upload_success and s3_file_url:             # <<<<<<<<<<<<<<
 *                 await self._send_file_upload_success_to_electron(s3_file_url)
 *                 logger.info("File upload success message sent to Electron after database queuing")
*/
      if (__pyx_cur_scope->__pyx_v_file_upload_success) {
      } else {
        __pyx_t_10 = __pyx_cur_scope->__pyx_v_file_upload_success;
        goto __pyx_L42_bool_binop_done;
      }
      __pyx_t_26 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_s3_file_url); if (unlikely((__pyx_t_26 < 0))) __PYX_ERR(0, 6119, __pyx_L4_error)
      __pyx_t_10 = __pyx_t_26;
      __pyx_L42_bool_binop_done:;
      if (__pyx_t_10) {

        /* "ws_package/controllers/activity_controller.py":6120
 *             # Send success message to Electron ONLY after database queuing
 *             if file_upload_success and s3_file_url:
 *                 await self._send_file_upload_success_to_electron(s3_file_url)             # <<<<<<<<<<<<<<
 *                 logger.info("File upload success message sent to Electron after database queuing")
 * 
*/
        __pyx_t_4 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_4);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_s3_file_url};
          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_send_file_upload_success_to_ele, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6120, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (likely(__pyx_t_9 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_1);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
          __Pyx_XGIVEREF(__pyx_t_2);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
          __Pyx_XGIVEREF(__pyx_t_3);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 6;
          return __pyx_r;
          __pyx_L44_resume_from_await:;
          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_1);
          __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_2);
          __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_3);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6120, __pyx_L4_error)
        } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_DECREF(__pyx_r); __pyx_r = 0;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 6120, __pyx_L4_error)
        }

        /* "ws_package/controllers/activity_controller.py":6121
 *             if file_upload_success and s3_file_url:
 *                 await self._send_file_upload_success_to_electron(s3_file_url)
 *                 logger.info("File upload success message sent to Electron after database queuing")             # <<<<<<<<<<<<<<
 * 
 *             # Handle reassign action
*/
        __pyx_t_4 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6121, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6121, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_17);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_17))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_17);
          assert(__pyx_t_4);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_File_upload_success_message_sent};
          __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6121, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":6119
 * 
 *             # Send success message to Electron ONLY after database queuing
 *             if file_upload_success and s3_file_url:             # <<<<<<<<<<<<<<
 *                 await self._send_file_upload_success_to_electron(s3_file_url)
 *                 logger.info("File upload success message sent to Electron after database queuing")
*/
      }

      /* "ws_package/controllers/activity_controller.py":6124
 * 
 *             # Handle reassign action
 *             if action == 'reassign':             # <<<<<<<<<<<<<<
 *                 if not project_id:
 *                     logger.error("Reassign action requires project_id - ignoring reassign request")
*/
      __pyx_t_10 = (__Pyx_PyUnicode_Equals(__pyx_cur_scope->__pyx_v_action, __pyx_mstate_global->__pyx_n_u_reassign, Py_EQ)); if (unlikely((__pyx_t_10 < 0))) __PYX_ERR(0, 6124, __pyx_L4_error)
      if (__pyx_t_10) {

        /* "ws_package/controllers/activity_controller.py":6125
 *             # Handle reassign action
 *             if action == 'reassign':
 *                 if not project_id:             # <<<<<<<<<<<<<<
 *                     logger.error("Reassign action requires project_id - ignoring reassign request")
 *                     return
*/
        if (__pyx_cur_scope->__pyx_v_project_id == Py_None) __pyx_t_10 = 0;
        else
        {
          Py_ssize_t __pyx_temp = __Pyx_PyUnicode_IS_TRUE(__pyx_cur_scope->__pyx_v_project_id);
          if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 6125, __pyx_L4_error)
          __pyx_t_10 = (__pyx_temp != 0);
        }

        __pyx_t_26 = (!__pyx_t_10);
        if (__pyx_t_26) {

          /* "ws_package/controllers/activity_controller.py":6126
 *             if action == 'reassign':
 *                 if not project_id:
 *                     logger.error("Reassign action requires project_id - ignoring reassign request")             # <<<<<<<<<<<<<<
 *                     return
 * 
*/
          __pyx_t_17 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6126, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6126, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_7))) {
            __pyx_t_17 = PyMethod_GET_SELF(__pyx_t_7);
            assert(__pyx_t_17);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
            __Pyx_INCREF(__pyx_t_17);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_17, __pyx_mstate_global->__pyx_kp_u_Reassign_action_requires_project};
            __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6126, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

          /* "ws_package/controllers/activity_controller.py":6127
 *                 if not project_id:
 *                     logger.error("Reassign action requires project_id - ignoring reassign request")
 *                     return             # <<<<<<<<<<<<<<
 * 
 *                 # Set current project and task IDs so new intervals after reassign will use these values
*/
          __Pyx_XDECREF(__pyx_r);
          __pyx_r = Py_None; __Pyx_INCREF(Py_None);
          goto __pyx_L8_try_return;

          /* "ws_package/controllers/activity_controller.py":6125
 *             # Handle reassign action
 *             if action == 'reassign':
 *                 if not project_id:             # <<<<<<<<<<<<<<
 *                     logger.error("Reassign action requires project_id - ignoring reassign request")
 *                     return
*/
        }

        /* "ws_package/controllers/activity_controller.py":6130
 * 
 *                 # Set current project and task IDs so new intervals after reassign will use these values
 *                 self.set_project_task_ids(project_id, task_id)             # <<<<<<<<<<<<<<
 *                 logger.info("Set current project_id=%s, task_id=%s after reassign", self.current_project_id, self.current_task_id)
 * 
*/
        __pyx_t_7 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_7);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_7, __pyx_cur_scope->__pyx_v_project_id, __pyx_cur_scope->__pyx_v_task_id};
          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_set_project_task_ids, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6130, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":6131
 *                 # Set current project and task IDs so new intervals after reassign will use these values
 *                 self.set_project_task_ids(project_id, task_id)
 *                 logger.info("Set current project_id=%s, task_id=%s after reassign", self.current_project_id, self.current_task_id)             # <<<<<<<<<<<<<<
 * 
 *                 # Reassign idle intervals to the new project/task
*/
        __pyx_t_7 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6131, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_17, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6131, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_project_id); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6131, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_current_task_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6131, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
          assert(__pyx_t_7);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[4] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Set_current_project_id_s_task_id, __pyx_t_17, __pyx_t_6};
          __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6131, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":6134
 * 
 *                 # Reassign idle intervals to the new project/task
 *                 await self._idle_reassign(project_id, task_id)             # <<<<<<<<<<<<<<
 * 
 *                 # Clear idle popup active flag after handling reassign
*/
        __pyx_t_4 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_4);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_project_id, __pyx_cur_scope->__pyx_v_task_id};
          __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_idle_reassign, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6134, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (likely(__pyx_t_9 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_1);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
          __Pyx_XGIVEREF(__pyx_t_2);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
          __Pyx_XGIVEREF(__pyx_t_3);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 7;
          return __pyx_r;
          __pyx_L47_resume_from_await:;
          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_1);
          __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_2);
          __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_3);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6134, __pyx_L4_error)
        } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_DECREF(__pyx_r); __pyx_r = 0;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 6134, __pyx_L4_error)
        }

        /* "ws_package/controllers/activity_controller.py":6137
 * 
 *                 # Clear idle popup active flag after handling reassign
 *                 self._idle_popup_active = False             # <<<<<<<<<<<<<<
 *                 self._idle_popup_triggered_at = None
 *                 self._api_pause_active = False  # Resume API calls after handling response
*/
        if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_active, Py_False) < (0)) __PYX_ERR(0, 6137, __pyx_L4_error)

        /* "ws_package/controllers/activity_controller.py":6138
 *                 # Clear idle popup active flag after handling reassign
 *                 self._idle_popup_active = False
 *                 self._idle_popup_triggered_at = None             # <<<<<<<<<<<<<<
 *                 self._api_pause_active = False  # Resume API calls after handling response
 *                 logger.info("Cleared idle popup active flag after handling reassign - API calls will resume")
*/
        if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_triggered_at, Py_None) < (0)) __PYX_ERR(0, 6138, __pyx_L4_error)

        /* "ws_package/controllers/activity_controller.py":6139
 *                 self._idle_popup_active = False
 *                 self._idle_popup_triggered_at = None
 *                 self._api_pause_active = False  # Resume API calls after handling response             # <<<<<<<<<<<<<<
 *                 logger.info("Cleared idle popup active flag after handling reassign - API calls will resume")
 *                 return
*/
        if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_api_pause_active, Py_False) < (0)) __PYX_ERR(0, 6139, __pyx_L4_error)

        /* "ws_package/controllers/activity_controller.py":6140
 *                 self._idle_popup_triggered_at = None
 *                 self._api_pause_active = False  # Resume API calls after handling response
 *                 logger.info("Cleared idle popup active flag after handling reassign - API calls will resume")             # <<<<<<<<<<<<<<
 *                 return
 * 
*/
        __pyx_t_4 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6140, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6140, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_17);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_17))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_17);
          assert(__pyx_t_4);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_17);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_17, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Cleared_idle_popup_active_flag_a};
          __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_17, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6140, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":6141
 *                 self._api_pause_active = False  # Resume API calls after handling response
 *                 logger.info("Cleared idle popup active flag after handling reassign - API calls will resume")
 *                 return             # <<<<<<<<<<<<<<
 * 
 *             # NEW: Handle held idle intervals based on keep_idle_time
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
        goto __pyx_L8_try_return;

        /* "ws_package/controllers/activity_controller.py":6124
 * 
 *             # Handle reassign action
 *             if action == 'reassign':             # <<<<<<<<<<<<<<
 *                 if not project_id:
 *                     logger.error("Reassign action requires project_id - ignoring reassign request")
*/
      }

      /* "ws_package/controllers/activity_controller.py":6145
 *             # NEW: Handle held idle intervals based on keep_idle_time
 *             # CRITICAL: Only handle held intervals from current counter
 *             current_counter = self.last_count + 1             # <<<<<<<<<<<<<<
 *             if self._held_idle_intervals:
 *                 # Filter held intervals by current counter
*/
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6145, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_17 = __Pyx_PyLong_AddObjC(__pyx_t_5, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6145, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_17);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GIVEREF(__pyx_t_17);
      __pyx_cur_scope->__pyx_v_current_counter = __pyx_t_17;
      __pyx_t_17 = 0;

      /* "ws_package/controllers/activity_controller.py":6146
 *             # CRITICAL: Only handle held intervals from current counter
 *             current_counter = self.last_count + 1
 *             if self._held_idle_intervals:             # <<<<<<<<<<<<<<
 *                 # Filter held intervals by current counter
 *                 current_counter_held = [iv for iv in self._held_idle_intervals if getattr(iv, 'counter', None) == current_counter]
*/
      __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_held_idle_intervals); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6146, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_17);
      __pyx_t_26 = __Pyx_PyObject_IsTrue(__pyx_t_17); if (unlikely((__pyx_t_26 < 0))) __PYX_ERR(0, 6146, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
      if (__pyx_t_26) {

        /* "ws_package/controllers/activity_controller.py":6148
 *             if self._held_idle_intervals:
 *                 # Filter held intervals by current counter
 *                 current_counter_held = [iv for iv in self._held_idle_intervals if getattr(iv, 'counter', None) == current_counter]             # <<<<<<<<<<<<<<
 *                 if current_counter_held:
 *                     if keep_idle_time:
*/
        { /* enter inner scope */
          __pyx_t_17 = PyList_New(0); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6148, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_17);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_held_idle_intervals); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6148, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) {
            __pyx_t_4 = __pyx_t_5; __Pyx_INCREF(__pyx_t_4);
            __pyx_t_27 = 0;
            __pyx_t_28 = NULL;
          } else {
            __pyx_t_27 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6148, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_28 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 6148, __pyx_L4_error)
          }
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          for (;;) {
            if (likely(!__pyx_t_28)) {
              if (likely(PyList_CheckExact(__pyx_t_4))) {
                {
                  Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4);
                  #if !CYTHON_ASSUME_SAFE_SIZE
                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6148, __pyx_L4_error)
                  #endif
                  if (__pyx_t_27 >= __pyx_temp) break;
                }
                __pyx_t_5 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_4, __pyx_t_27, __Pyx_ReferenceSharing_OwnStrongReference);
                ++__pyx_t_27;
              } else {
                {
                  Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4);
                  #if !CYTHON_ASSUME_SAFE_SIZE
                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6148, __pyx_L4_error)
                  #endif
                  if (__pyx_t_27 >= __pyx_temp) break;
                }
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_5 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_27));
                #else
                __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_27);
                #endif
                ++__pyx_t_27;
              }
              if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6148, __pyx_L4_error)
            } else {
              __pyx_t_5 = __pyx_t_28(__pyx_t_4);
              if (unlikely(!__pyx_t_5)) {
                PyObject* exc_type = PyErr_Occurred();
                if (exc_type) {
                  if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 6148, __pyx_L4_error)
                  PyErr_Clear();
                }
                break;
              }
            }
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_9genexpr22__pyx_v_iv);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_9genexpr22__pyx_v_iv, __pyx_t_5);
            __Pyx_GIVEREF(__pyx_t_5);
            __pyx_t_5 = 0;
            __pyx_t_5 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_9genexpr22__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_counter, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6148, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
            __pyx_t_6 = PyObject_RichCompare(__pyx_t_5, __pyx_cur_scope->__pyx_v_current_counter, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6148, __pyx_L4_error)
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __pyx_t_26 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_26 < 0))) __PYX_ERR(0, 6148, __pyx_L4_error)
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            if (__pyx_t_26) {
              if (unlikely(__Pyx_ListComp_Append(__pyx_t_17, (PyObject*)__pyx_cur_scope->__pyx_9genexpr22__pyx_v_iv))) __PYX_ERR(0, 6148, __pyx_L4_error)
            }
          }
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        } /* exit inner scope */
        __Pyx_GIVEREF(__pyx_t_17);
        __pyx_cur_scope->__pyx_v_current_counter_held = ((PyObject*)__pyx_t_17);
        __pyx_t_17 = 0;

        /* "ws_package/controllers/activity_controller.py":6149
 *                 # Filter held intervals by current counter
 *                 current_counter_held = [iv for iv in self._held_idle_intervals if getattr(iv, 'counter', None) == current_counter]
 *                 if current_counter_held:             # <<<<<<<<<<<<<<
 *                     if keep_idle_time:
 *                         # User wants to keep idle time - held intervals will be sent (is_uploaded=False)
*/
        {
          Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_current_counter_held);
          if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 6149, __pyx_L4_error)
          __pyx_t_26 = (__pyx_temp != 0);
        }

        if (__pyx_t_26) {

          /* "ws_package/controllers/activity_controller.py":6150
 *                 current_counter_held = [iv for iv in self._held_idle_intervals if getattr(iv, 'counter', None) == current_counter]
 *                 if current_counter_held:
 *                     if keep_idle_time:             # <<<<<<<<<<<<<<
 *                         # User wants to keep idle time - held intervals will be sent (is_uploaded=False)
 *                         logger.info("[IdleResponse] User chose to keep idle time - %s held idle interval(s) from current counter (%s) will be sent", len(current_counter_held), current_counter)
*/
          if (__pyx_cur_scope->__pyx_v_keep_idle_time) {

            /* "ws_package/controllers/activity_controller.py":6152
 *                     if keep_idle_time:
 *                         # User wants to keep idle time - held intervals will be sent (is_uploaded=False)
 *                         logger.info("[IdleResponse] User chose to keep idle time - %s held idle interval(s) from current counter (%s) will be sent", len(current_counter_held), current_counter)             # <<<<<<<<<<<<<<
 *                         # Remove current counter intervals from held list (they will be sent in next sync/upload cycle)
 *                         self._held_idle_intervals = [iv for iv in self._held_idle_intervals if getattr(iv, 'counter', None) != current_counter]
*/
            __pyx_t_4 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6152, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6152, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            __pyx_t_27 = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_current_counter_held); if (unlikely(__pyx_t_27 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6152, __pyx_L4_error)
            __pyx_t_6 = PyLong_FromSsize_t(__pyx_t_27); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6152, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_6);
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_5))) {
              __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
              assert(__pyx_t_4);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
              __Pyx_INCREF(__pyx_t_4);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[4] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_IdleResponse_User_chose_to_keep, __pyx_t_6, __pyx_cur_scope->__pyx_v_current_counter};
              __pyx_t_17 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6152, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_17);
            }
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

            /* "ws_package/controllers/activity_controller.py":6154
 *                         logger.info("[IdleResponse] User chose to keep idle time - %s held idle interval(s) from current counter (%s) will be sent", len(current_counter_held), current_counter)
 *                         # Remove current counter intervals from held list (they will be sent in next sync/upload cycle)
 *                         self._held_idle_intervals = [iv for iv in self._held_idle_intervals if getattr(iv, 'counter', None) != current_counter]             # <<<<<<<<<<<<<<
 *                     else:
 *                         # User doesn't want to keep idle time - mark held intervals as uploaded (won't be sent)
*/
            { /* enter inner scope */
              __pyx_t_17 = PyList_New(0); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6154, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_17);
              __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_held_idle_intervals); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6154, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_5);
              if (likely(PyList_CheckExact(__pyx_t_5)) || PyTuple_CheckExact(__pyx_t_5)) {
                __pyx_t_6 = __pyx_t_5; __Pyx_INCREF(__pyx_t_6);
                __pyx_t_27 = 0;
                __pyx_t_28 = NULL;
              } else {
                __pyx_t_27 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6154, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_6);
                __pyx_t_28 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_6); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 6154, __pyx_L4_error)
              }
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              for (;;) {
                if (likely(!__pyx_t_28)) {
                  if (likely(PyList_CheckExact(__pyx_t_6))) {
                    {
                      Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
                      #if !CYTHON_ASSUME_SAFE_SIZE
                      if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6154, __pyx_L4_error)
                      #endif
                      if (__pyx_t_27 >= __pyx_temp) break;
                    }
                    __pyx_t_5 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_6, __pyx_t_27, __Pyx_ReferenceSharing_OwnStrongReference);
                    ++__pyx_t_27;
                  } else {
                    {
                      Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_6);
                      #if !CYTHON_ASSUME_SAFE_SIZE
                      if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6154, __pyx_L4_error)
                      #endif
                      if (__pyx_t_27 >= __pyx_temp) break;
                    }
                    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                    __pyx_t_5 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_27));
                    #else
                    __pyx_t_5 = __Pyx_PySequence_ITEM(__pyx_t_6, __pyx_t_27);
                    #endif
                    ++__pyx_t_27;
                  }
                  if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6154, __pyx_L4_error)
                } else {
                  __pyx_t_5 = __pyx_t_28(__pyx_t_6);
                  if (unlikely(!__pyx_t_5)) {
                    PyObject* exc_type = PyErr_Occurred();
                    if (exc_type) {
                      if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 6154, __pyx_L4_error)
                      PyErr_Clear();
                    }
                    break;
                  }
                }
                __Pyx_GOTREF(__pyx_t_5);
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_9genexpr23__pyx_v_iv);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_9genexpr23__pyx_v_iv, __pyx_t_5);
                __Pyx_GIVEREF(__pyx_t_5);
                __pyx_t_5 = 0;
                __pyx_t_5 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_9genexpr23__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_counter, Py_None); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6154, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_5);
                __pyx_t_4 = PyObject_RichCompare(__pyx_t_5, __pyx_cur_scope->__pyx_v_current_counter, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6154, __pyx_L4_error)
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                __pyx_t_26 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_26 < 0))) __PYX_ERR(0, 6154, __pyx_L4_error)
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                if (__pyx_t_26) {
                  if (unlikely(__Pyx_ListComp_Append(__pyx_t_17, (PyObject*)__pyx_cur_scope->__pyx_9genexpr23__pyx_v_iv))) __PYX_ERR(0, 6154, __pyx_L4_error)
                }
              }
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
            } /* exit inner scope */
            if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_held_idle_intervals, __pyx_t_17) < (0)) __PYX_ERR(0, 6154, __pyx_L4_error)
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

            /* "ws_package/controllers/activity_controller.py":6150
 *                 current_counter_held = [iv for iv in self._held_idle_intervals if getattr(iv, 'counter', None) == current_counter]
 *                 if current_counter_held:
 *                     if keep_idle_time:             # <<<<<<<<<<<<<<
 *                         # User wants to keep idle time - held intervals will be sent (is_uploaded=False)
 *                         logger.info("[IdleResponse] User chose to keep idle time - %s held idle interval(s) from current counter (%s) will be sent", len(current_counter_held), current_counter)
*/
            goto __pyx_L54;
          }

          /* "ws_package/controllers/activity_controller.py":6157
 *                     else:
 *                         # User doesn't want to keep idle time - mark held intervals as uploaded (won't be sent)
 *                         logger.info("[IdleResponse] User chose not to keep idle time - marking %s held idle interval(s) from current counter (%s) as uploaded", len(current_counter_held), current_counter)             # <<<<<<<<<<<<<<
 *                         for interval in current_counter_held:
 *                             try:
*/
          /*else*/ {
            __pyx_t_6 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6157, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6157, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_5);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __pyx_t_27 = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_current_counter_held); if (unlikely(__pyx_t_27 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6157, __pyx_L4_error)
            __pyx_t_4 = PyLong_FromSsize_t(__pyx_t_27); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6157, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_8 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_5))) {
              __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
              assert(__pyx_t_6);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
              __Pyx_INCREF(__pyx_t_6);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
              __pyx_t_8 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[4] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_IdleResponse_User_chose_not_to, __pyx_t_4, __pyx_cur_scope->__pyx_v_current_counter};
              __pyx_t_17 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
              if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6157, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_17);
            }
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

            /* "ws_package/controllers/activity_controller.py":6158
 *                         # User doesn't want to keep idle time - mark held intervals as uploaded (won't be sent)
 *                         logger.info("[IdleResponse] User chose not to keep idle time - marking %s held idle interval(s) from current counter (%s) as uploaded", len(current_counter_held), current_counter)
 *                         for interval in current_counter_held:             # <<<<<<<<<<<<<<
 *                             try:
 *                                 interval.is_uploaded = True
*/
            __pyx_t_17 = __pyx_cur_scope->__pyx_v_current_counter_held; __Pyx_INCREF(__pyx_t_17);
            __pyx_t_27 = 0;
            for (;;) {
              {
                Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_17);
                #if !CYTHON_ASSUME_SAFE_SIZE
                if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6158, __pyx_L4_error)
                #endif
                if (__pyx_t_27 >= __pyx_temp) break;
              }
              __pyx_t_5 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_17, __pyx_t_27, __Pyx_ReferenceSharing_OwnStrongReference);
              ++__pyx_t_27;
              if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6158, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_5);
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_5);
              __Pyx_GIVEREF(__pyx_t_5);
              __pyx_t_5 = 0;

              /* "ws_package/controllers/activity_controller.py":6159
 *                         logger.info("[IdleResponse] User chose not to keep idle time - marking %s held idle interval(s) from current counter (%s) as uploaded", len(current_counter_held), current_counter)
 *                         for interval in current_counter_held:
 *                             try:             # <<<<<<<<<<<<<<
 *                                 interval.is_uploaded = True
 *                                 # Save to database
*/
              {
                __Pyx_ExceptionSave(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
                __Pyx_XGOTREF(__pyx_t_13);
                __Pyx_XGOTREF(__pyx_t_12);
                __Pyx_XGOTREF(__pyx_t_11);
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":6160
 *                         for interval in current_counter_held:
 *                             try:
 *                                 interval.is_uploaded = True             # <<<<<<<<<<<<<<
 *                                 # Save to database
 *                                 db_writer_service.queue_write(interval)
*/
                  if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_is_uploaded, Py_True) < (0)) __PYX_ERR(0, 6160, __pyx_L61_error)

                  /* "ws_package/controllers/activity_controller.py":6162
 *                                 interval.is_uploaded = True
 *                                 # Save to database
 *                                 db_writer_service.queue_write(interval)             # <<<<<<<<<<<<<<
 *                             except Exception as e:
 *                                 logger.error("Error marking held idle interval %s as uploaded: %s", interval.id, e, exc_info=True)
*/
                  __pyx_t_4 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6162, __pyx_L61_error)
                  __Pyx_GOTREF(__pyx_t_6);
                  __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_queue_write); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6162, __pyx_L61_error)
                  __Pyx_GOTREF(__pyx_t_7);
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __pyx_t_8 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_7))) {
                    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7);
                    assert(__pyx_t_4);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                    __Pyx_INCREF(__pyx_t_4);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                    __pyx_t_8 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_interval};
                    __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                    if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6162, __pyx_L61_error)
                    __Pyx_GOTREF(__pyx_t_5);
                  }
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                  /* "ws_package/controllers/activity_controller.py":6159
 *                         logger.info("[IdleResponse] User chose not to keep idle time - marking %s held idle interval(s) from current counter (%s) as uploaded", len(current_counter_held), current_counter)
 *                         for interval in current_counter_held:
 *                             try:             # <<<<<<<<<<<<<<
 *                                 interval.is_uploaded = True
 *                                 # Save to database
*/
                }
                __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
                goto __pyx_L68_try_end;
                __pyx_L61_error:;
                __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

                /* "ws_package/controllers/activity_controller.py":6163
 *                                 # Save to database
 *                                 db_writer_service.queue_write(interval)
 *                             except Exception as e:             # <<<<<<<<<<<<<<
 *                                 logger.error("Error marking held idle interval %s as uploaded: %s", interval.id, e, exc_info=True)
 *                         # Remove current counter intervals from held list
*/
                __pyx_t_18 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                if (__pyx_t_18) {
                  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.handle_idle_popup_response", __pyx_clineno, __pyx_lineno, __pyx_filename);
                  if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_7, &__pyx_t_4) < 0) __PYX_ERR(0, 6163, __pyx_L63_except_error)
                  __Pyx_XGOTREF(__pyx_t_5);
                  __Pyx_XGOTREF(__pyx_t_7);
                  __Pyx_XGOTREF(__pyx_t_4);
                  __Pyx_INCREF(__pyx_t_7);
                  __Pyx_GIVEREF(__pyx_t_7);
                  __pyx_cur_scope->__pyx_v_e = __pyx_t_7;
                  /*try:*/ {

                    /* "ws_package/controllers/activity_controller.py":6164
 *                                 db_writer_service.queue_write(interval)
 *                             except Exception as e:
 *                                 logger.error("Error marking held idle interval %s as uploaded: %s", interval.id, e, exc_info=True)             # <<<<<<<<<<<<<<
 *                         # Remove current counter intervals from held list
 *                         self._held_idle_intervals = [iv for iv in self._held_idle_intervals if getattr(iv, 'counter', None) != current_counter]
*/
                    __pyx_t_16 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 6164, __pyx_L74_error)
                    __Pyx_GOTREF(__pyx_t_15);
                    __pyx_t_29 = __Pyx_PyObject_GetAttrStr(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 6164, __pyx_L74_error)
                    __Pyx_GOTREF(__pyx_t_29);
                    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __pyx_t_15 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 6164, __pyx_L74_error)
                    __Pyx_GOTREF(__pyx_t_15);
                    __pyx_t_8 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_29))) {
                      __pyx_t_16 = PyMethod_GET_SELF(__pyx_t_29);
                      assert(__pyx_t_16);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_29);
                      __Pyx_INCREF(__pyx_t_16);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_29, __pyx__function);
                      __pyx_t_8 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[4 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_16, __pyx_mstate_global->__pyx_kp_u_Error_marking_held_idle_interval, __pyx_t_15, __pyx_cur_scope->__pyx_v_e};
                      __pyx_t_30 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 6164, __pyx_L74_error)
                      __Pyx_GOTREF(__pyx_t_30);
                      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_30, __pyx_callargs+4, 0) < (0)) __PYX_ERR(0, 6164, __pyx_L74_error)
                      __pyx_t_6 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_29, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_30);
                      __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                      __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
                      __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
                      if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6164, __pyx_L74_error)
                      __Pyx_GOTREF(__pyx_t_6);
                    }
                    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  }

                  /* "ws_package/controllers/activity_controller.py":6163
 *                                 # Save to database
 *                                 db_writer_service.queue_write(interval)
 *                             except Exception as e:             # <<<<<<<<<<<<<<
 *                                 logger.error("Error marking held idle interval %s as uploaded: %s", interval.id, e, exc_info=True)
 *                         # Remove current counter intervals from held list
*/
                  /*finally:*/ {
                    /*normal exit:*/{
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                      goto __pyx_L75;
                    }
                    __pyx_L74_error:;
                    /*exception exit:*/{
                      __Pyx_PyThreadState_assign
                      __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0;
                      __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                      __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                      __Pyx_XDECREF(__pyx_t_29); __pyx_t_29 = 0;
                      __Pyx_XDECREF(__pyx_t_30); __pyx_t_30 = 0;
                      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                       __Pyx_ExceptionSwap(&__pyx_t_22, &__pyx_t_21, &__pyx_t_20);
                      if ( unlikely(__Pyx_GetException(&__pyx_t_25, &__pyx_t_24, &__pyx_t_23) < 0)) __Pyx_ErrFetch(&__pyx_t_25, &__pyx_t_24, &__pyx_t_23);
                      __Pyx_XGOTREF(__pyx_t_25);
                      __Pyx_XGOTREF(__pyx_t_24);
                      __Pyx_XGOTREF(__pyx_t_23);
                      __Pyx_XGOTREF(__pyx_t_22);
                      __Pyx_XGOTREF(__pyx_t_21);
                      __Pyx_XGOTREF(__pyx_t_20);
                      __pyx_t_18 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_31 = __pyx_filename;
                      {
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                        __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                      }
                      __Pyx_XGIVEREF(__pyx_t_22);
                      __Pyx_XGIVEREF(__pyx_t_21);
                      __Pyx_XGIVEREF(__pyx_t_20);
                      __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_21, __pyx_t_20);
                      __Pyx_XGIVEREF(__pyx_t_25);
                      __Pyx_XGIVEREF(__pyx_t_24);
                      __Pyx_XGIVEREF(__pyx_t_23);
                      __Pyx_ErrRestore(__pyx_t_25, __pyx_t_24, __pyx_t_23);
                      __pyx_t_25 = 0; __pyx_t_24 = 0; __pyx_t_23 = 0; __pyx_t_22 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0;
                      __pyx_lineno = __pyx_t_18; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_31;
                      goto __pyx_L63_except_error;
                    }
                    __pyx_L75:;
                  }
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                  __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                  goto __pyx_L62_exception_handled;
                }
                goto __pyx_L63_except_error;

                /* "ws_package/controllers/activity_controller.py":6159
 *                         logger.info("[IdleResponse] User chose not to keep idle time - marking %s held idle interval(s) from current counter (%s) as uploaded", len(current_counter_held), current_counter)
 *                         for interval in current_counter_held:
 *                             try:             # <<<<<<<<<<<<<<
 *                                 interval.is_uploaded = True
 *                                 # Save to database
*/
                __pyx_L63_except_error:;
                __Pyx_XGIVEREF(__pyx_t_13);
                __Pyx_XGIVEREF(__pyx_t_12);
                __Pyx_XGIVEREF(__pyx_t_11);
                __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_12, __pyx_t_11);
                goto __pyx_L4_error;
                __pyx_L62_exception_handled:;
                __Pyx_XGIVEREF(__pyx_t_13);
                __Pyx_XGIVEREF(__pyx_t_12);
                __Pyx_XGIVEREF(__pyx_t_11);
                __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_12, __pyx_t_11);
                __pyx_L68_try_end:;
              }

              /* "ws_package/controllers/activity_controller.py":6158
 *                         # User doesn't want to keep idle time - mark held intervals as uploaded (won't be sent)
 *                         logger.info("[IdleResponse] User chose not to keep idle time - marking %s held idle interval(s) from current counter (%s) as uploaded", len(current_counter_held), current_counter)
 *                         for interval in current_counter_held:             # <<<<<<<<<<<<<<
 *                             try:
 *                                 interval.is_uploaded = True
*/
            }
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

            /* "ws_package/controllers/activity_controller.py":6166
 *                                 logger.error("Error marking held idle interval %s as uploaded: %s", interval.id, e, exc_info=True)
 *                         # Remove current counter intervals from held list
 *                         self._held_idle_intervals = [iv for iv in self._held_idle_intervals if getattr(iv, 'counter', None) != current_counter]             # <<<<<<<<<<<<<<
 * 
 *                 # Clear any remaining held intervals from previous counters
*/
            { /* enter inner scope */
              __pyx_t_17 = PyList_New(0); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6166, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_17);
              __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_held_idle_intervals); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6166, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_4);
              if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
                __pyx_t_7 = __pyx_t_4; __Pyx_INCREF(__pyx_t_7);
                __pyx_t_27 = 0;
                __pyx_t_28 = NULL;
              } else {
                __pyx_t_27 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6166, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_7);
                __pyx_t_28 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_7); if (unlikely(!__pyx_t_28)) __PYX_ERR(0, 6166, __pyx_L4_error)
              }
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              for (;;) {
                if (likely(!__pyx_t_28)) {
                  if (likely(PyList_CheckExact(__pyx_t_7))) {
                    {
                      Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_7);
                      #if !CYTHON_ASSUME_SAFE_SIZE
                      if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6166, __pyx_L4_error)
                      #endif
                      if (__pyx_t_27 >= __pyx_temp) break;
                    }
                    __pyx_t_4 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_7, __pyx_t_27, __Pyx_ReferenceSharing_OwnStrongReference);
                    ++__pyx_t_27;
                  } else {
                    {
                      Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_7);
                      #if !CYTHON_ASSUME_SAFE_SIZE
                      if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6166, __pyx_L4_error)
                      #endif
                      if (__pyx_t_27 >= __pyx_temp) break;
                    }
                    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                    __pyx_t_4 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_27));
                    #else
                    __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_7, __pyx_t_27);
                    #endif
                    ++__pyx_t_27;
                  }
                  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6166, __pyx_L4_error)
                } else {
                  __pyx_t_4 = __pyx_t_28(__pyx_t_7);
                  if (unlikely(!__pyx_t_4)) {
                    PyObject* exc_type = PyErr_Occurred();
                    if (exc_type) {
                      if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 6166, __pyx_L4_error)
                      PyErr_Clear();
                    }
                    break;
                  }
                }
                __Pyx_GOTREF(__pyx_t_4);
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_9genexpr24__pyx_v_iv);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_9genexpr24__pyx_v_iv, __pyx_t_4);
                __Pyx_GIVEREF(__pyx_t_4);
                __pyx_t_4 = 0;
                __pyx_t_4 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_9genexpr24__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_counter, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6166, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_t_5 = PyObject_RichCompare(__pyx_t_4, __pyx_cur_scope->__pyx_v_current_counter, Py_NE); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6166, __pyx_L4_error)
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                __pyx_t_26 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_26 < 0))) __PYX_ERR(0, 6166, __pyx_L4_error)
                __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                if (__pyx_t_26) {
                  if (unlikely(__Pyx_ListComp_Append(__pyx_t_17, (PyObject*)__pyx_cur_scope->__pyx_9genexpr24__pyx_v_iv))) __PYX_ERR(0, 6166, __pyx_L4_error)
                }
              }
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            } /* exit inner scope */
            if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_held_idle_intervals, __pyx_t_17) < (0)) __PYX_ERR(0, 6166, __pyx_L4_error)
            __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          }
          __pyx_L54:;

          /* "ws_package/controllers/activity_controller.py":6149
 *                 # Filter held intervals by current counter
 *                 current_counter_held = [iv for iv in self._held_idle_intervals if getattr(iv, 'counter', None) == current_counter]
 *                 if current_counter_held:             # <<<<<<<<<<<<<<
 *                     if keep_idle_time:
 *                         # User wants to keep idle time - held intervals will be sent (is_uploaded=False)
*/
        }

        /* "ws_package/controllers/activity_controller.py":6169
 * 
 *                 # Clear any remaining held intervals from previous counters
 *                 if self._held_idle_intervals:             # <<<<<<<<<<<<<<
 *                     logger.info("[IdleResponse] Clearing %s held idle interval(s) from previous counter(s)", len(self._held_idle_intervals))
 *                     self._held_idle_intervals = []
*/
        __pyx_t_17 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_held_idle_intervals); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6169, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_17);
        __pyx_t_26 = __Pyx_PyObject_IsTrue(__pyx_t_17); if (unlikely((__pyx_t_26 < 0))) __PYX_ERR(0, 6169, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        if (__pyx_t_26) {

          /* "ws_package/controllers/activity_controller.py":6170
 *                 # Clear any remaining held intervals from previous counters
 *                 if self._held_idle_intervals:
 *                     logger.info("[IdleResponse] Clearing %s held idle interval(s) from previous counter(s)", len(self._held_idle_intervals))             # <<<<<<<<<<<<<<
 *                     self._held_idle_intervals = []
 * 
*/
          __pyx_t_7 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6170, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6170, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_held_idle_intervals); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6170, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_27 = PyObject_Length(__pyx_t_5); if (unlikely(__pyx_t_27 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6170, __pyx_L4_error)
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __pyx_t_5 = PyLong_FromSsize_t(__pyx_t_27); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6170, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_4))) {
            __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
            assert(__pyx_t_7);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
            __Pyx_INCREF(__pyx_t_7);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_IdleResponse_Clearing_s_held_id, __pyx_t_5};
            __pyx_t_17 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6170, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_17);
          }
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

          /* "ws_package/controllers/activity_controller.py":6171
 *                 if self._held_idle_intervals:
 *                     logger.info("[IdleResponse] Clearing %s held idle interval(s) from previous counter(s)", len(self._held_idle_intervals))
 *                     self._held_idle_intervals = []             # <<<<<<<<<<<<<<
 * 
 *             # Handle continue/stop actions
*/
          __pyx_t_17 = PyList_New(0); if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6171, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_17);
          if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_held_idle_intervals, __pyx_t_17) < (0)) __PYX_ERR(0, 6171, __pyx_L4_error)
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

          /* "ws_package/controllers/activity_controller.py":6169
 * 
 *                 # Clear any remaining held intervals from previous counters
 *                 if self._held_idle_intervals:             # <<<<<<<<<<<<<<
 *                     logger.info("[IdleResponse] Clearing %s held idle interval(s) from previous counter(s)", len(self._held_idle_intervals))
 *                     self._held_idle_intervals = []
*/
        }

        /* "ws_package/controllers/activity_controller.py":6146
 *             # CRITICAL: Only handle held intervals from current counter
 *             current_counter = self.last_count + 1
 *             if self._held_idle_intervals:             # <<<<<<<<<<<<<<
 *                 # Filter held intervals by current counter
 *                 current_counter_held = [iv for iv in self._held_idle_intervals if getattr(iv, 'counter', None) == current_counter]
*/
      }

      /* "ws_package/controllers/activity_controller.py":6177
 *             # If keep_idle_time is False: set is_uploaded=1 for all consecutive idle intervals
 * 
 *             if keep_idle_time:             # <<<<<<<<<<<<<<
 *                 # User checked "keep" box - keep is_uploaded=false (no action needed)
 *                 logger.info("User checked 'keep' box - idle intervals will remain with is_uploaded=False")
*/
      if (__pyx_cur_scope->__pyx_v_keep_idle_time) {

        /* "ws_package/controllers/activity_controller.py":6179
 *             if keep_idle_time:
 *                 # User checked "keep" box - keep is_uploaded=false (no action needed)
 *                 logger.info("User checked 'keep' box - idle intervals will remain with is_uploaded=False")             # <<<<<<<<<<<<<<
 * 
 *                 # CRITICAL: If user chose to keep idle time and continue, sync immediately
*/
        __pyx_t_4 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6179, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6179, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7);
          assert(__pyx_t_4);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_User_checked_keep_box_idle_inter};
          __pyx_t_17 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6179, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_17);
        }
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

        /* "ws_package/controllers/activity_controller.py":6182
 * 
 *                 # CRITICAL: If user chose to keep idle time and continue, sync immediately
 *                 if action == 'continue':             # <<<<<<<<<<<<<<
 *                     logger.info("Action is 'continue' with keep_idle_time=True - triggering immediate sync")
 *                     await self.sync_activity_immediately()
*/
        __pyx_t_26 = (__Pyx_PyUnicode_Equals(__pyx_cur_scope->__pyx_v_action, __pyx_mstate_global->__pyx_n_u_continue, Py_EQ)); if (unlikely((__pyx_t_26 < 0))) __PYX_ERR(0, 6182, __pyx_L4_error)
        if (__pyx_t_26) {

          /* "ws_package/controllers/activity_controller.py":6183
 *                 # CRITICAL: If user chose to keep idle time and continue, sync immediately
 *                 if action == 'continue':
 *                     logger.info("Action is 'continue' with keep_idle_time=True - triggering immediate sync")             # <<<<<<<<<<<<<<
 *                     await self.sync_activity_immediately()
 *             else:
*/
          __pyx_t_7 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6183, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6183, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_5))) {
            __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
            assert(__pyx_t_7);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
            __Pyx_INCREF(__pyx_t_7);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Action_is_continue_with_keep_idl};
            __pyx_t_17 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6183, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_17);
          }
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

          /* "ws_package/controllers/activity_controller.py":6184
 *                 if action == 'continue':
 *                     logger.info("Action is 'continue' with keep_idle_time=True - triggering immediate sync")
 *                     await self.sync_activity_immediately()             # <<<<<<<<<<<<<<
 *             else:
 *                 # User unchecked "keep" box - mark idle/popup-period intervals as uploaded (is_uploaded=1)
*/
          __pyx_t_5 = __pyx_cur_scope->__pyx_v_self;
          __Pyx_INCREF(__pyx_t_5);
          __pyx_t_8 = 0;
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
            __pyx_t_17 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_sync_activity_immediately, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6184, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_17);
          }
          __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_17, &__pyx_r);
          __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
          if (likely(__pyx_t_9 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_1);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
            __Pyx_XGIVEREF(__pyx_t_2);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
            __Pyx_XGIVEREF(__pyx_t_3);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 8;
            return __pyx_r;
            __pyx_L88_resume_from_await:;
            __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_1);
            __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_2);
            __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_3);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6184, __pyx_L4_error)
          } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_DECREF(__pyx_r); __pyx_r = 0;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 6184, __pyx_L4_error)
          }

          /* "ws_package/controllers/activity_controller.py":6182
 * 
 *                 # CRITICAL: If user chose to keep idle time and continue, sync immediately
 *                 if action == 'continue':             # <<<<<<<<<<<<<<
 *                     logger.info("Action is 'continue' with keep_idle_time=True - triggering immediate sync")
 *                     await self.sync_activity_immediately()
*/
        }

        /* "ws_package/controllers/activity_controller.py":6177
 *             # If keep_idle_time is False: set is_uploaded=1 for all consecutive idle intervals
 * 
 *             if keep_idle_time:             # <<<<<<<<<<<<<<
 *                 # User checked "keep" box - keep is_uploaded=false (no action needed)
 *                 logger.info("User checked 'keep' box - idle intervals will remain with is_uploaded=False")
*/
        goto __pyx_L86;
      }

      /* "ws_package/controllers/activity_controller.py":6187
 *             else:
 *                 # User unchecked "keep" box - mark idle/popup-period intervals as uploaded (is_uploaded=1)
 *                 await self._mark_idle_intervals_as_uploaded()             # <<<<<<<<<<<<<<
 * 
 *             # Clear idle popup active flag after handling response
*/
      /*else*/ {
        __pyx_t_5 = __pyx_cur_scope->__pyx_v_self;
        __Pyx_INCREF(__pyx_t_5);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
          __pyx_t_17 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_mark_idle_intervals_as_uploaded, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6187, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_17);
        }
        __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_17, &__pyx_r);
        __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
        if (likely(__pyx_t_9 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_1);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
          __Pyx_XGIVEREF(__pyx_t_2);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
          __Pyx_XGIVEREF(__pyx_t_3);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 9;
          return __pyx_r;
          __pyx_L89_resume_from_await:;
          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_1);
          __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_2);
          __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_3);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6187, __pyx_L4_error)
        } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_DECREF(__pyx_r); __pyx_r = 0;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 6187, __pyx_L4_error)
        }
      }
      __pyx_L86:;

      /* "ws_package/controllers/activity_controller.py":6190
 * 
 *             # Clear idle popup active flag after handling response
 *             logger.info("[IdleResponse] Clearing popup state and resuming normal operation")             # <<<<<<<<<<<<<<
 *             self._idle_popup_active = False
 *             self._last_idle_resolution_time = datetime.datetime.now()
*/
      __pyx_t_5 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6190, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6190, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
        assert(__pyx_t_5);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_IdleResponse_Clearing_popup_sta};
        __pyx_t_17 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6190, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_17);
      }
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

      /* "ws_package/controllers/activity_controller.py":6191
 *             # Clear idle popup active flag after handling response
 *             logger.info("[IdleResponse] Clearing popup state and resuming normal operation")
 *             self._idle_popup_active = False             # <<<<<<<<<<<<<<
 *             self._last_idle_resolution_time = datetime.datetime.now()
 *             self._idle_popup_triggered_at = None
*/
      if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_active, Py_False) < (0)) __PYX_ERR(0, 6191, __pyx_L4_error)

      /* "ws_package/controllers/activity_controller.py":6192
 *             logger.info("[IdleResponse] Clearing popup state and resuming normal operation")
 *             self._idle_popup_active = False
 *             self._last_idle_resolution_time = datetime.datetime.now()             # <<<<<<<<<<<<<<
 *             self._idle_popup_triggered_at = None
 *             self._api_pause_active = False  # Resume API calls after handling response
*/
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6192, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6192, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_4 = __pyx_t_7;
      __Pyx_INCREF(__pyx_t_4);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
        __pyx_t_17 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6192, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_17);
      }
      if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_idle_resolution_time, __pyx_t_17) < (0)) __PYX_ERR(0, 6192, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

      /* "ws_package/controllers/activity_controller.py":6193
 *             self._idle_popup_active = False
 *             self._last_idle_resolution_time = datetime.datetime.now()
 *             self._idle_popup_triggered_at = None             # <<<<<<<<<<<<<<
 *             self._api_pause_active = False  # Resume API calls after handling response
 *             logger.info("[IdleResponse] State cleared - unsent idle intervals suppressed when keep was unchecked")
*/
      if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_triggered_at, Py_None) < (0)) __PYX_ERR(0, 6193, __pyx_L4_error)

      /* "ws_package/controllers/activity_controller.py":6194
 *             self._last_idle_resolution_time = datetime.datetime.now()
 *             self._idle_popup_triggered_at = None
 *             self._api_pause_active = False  # Resume API calls after handling response             # <<<<<<<<<<<<<<
 *             logger.info("[IdleResponse] State cleared - unsent idle intervals suppressed when keep was unchecked")
 * 
*/
      if (__Pyx_PyObject_SetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_api_pause_active, Py_False) < (0)) __PYX_ERR(0, 6194, __pyx_L4_error)

      /* "ws_package/controllers/activity_controller.py":6195
 *             self._idle_popup_triggered_at = None
 *             self._api_pause_active = False  # Resume API calls after handling response
 *             logger.info("[IdleResponse] State cleared - unsent idle intervals suppressed when keep was unchecked")             # <<<<<<<<<<<<<<
 * 
 *         except Exception as e:
*/
      __pyx_t_7 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6195, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6195, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
        assert(__pyx_t_7);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_IdleResponse_State_cleared_unse};
        __pyx_t_17 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6195, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_17);
      }
      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;

      /* "ws_package/controllers/activity_controller.py":6078
 *             file_path: Optional local file path to upload to S3
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             logger.info("[IdleResponse] Handling idle popup response: keep_idle_time=%s, action=%s, project_id=%s, task_id=%s, file_path=%s", keep_idle_time, action, project_id, task_id, file_path)
 * 
*/
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L9_try_end;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
    __Pyx_XDECREF(__pyx_t_29); __pyx_t_29 = 0;
    __Pyx_XDECREF(__pyx_t_30); __pyx_t_30 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "ws_package/controllers/activity_controller.py":6197
 *             logger.info("[IdleResponse] State cleared - unsent idle intervals suppressed when keep was unchecked")
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error handling idle popup response: %s", e, exc_info=True)
 * 
*/
    __pyx_t_14 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_14) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.handle_idle_popup_response", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_17, &__pyx_t_5, &__pyx_t_7) < 0) __PYX_ERR(0, 6197, __pyx_L6_except_error)
      __Pyx_XGOTREF(__pyx_t_17);
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_INCREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":6198
 * 
 *         except Exception as e:
 *             logger.error("Error handling idle popup response: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *     def handle_idle_popup_shown(self):
*/
        __pyx_t_6 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_29, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 6198, __pyx_L95_error)
        __Pyx_GOTREF(__pyx_t_29);
        __pyx_t_30 = __Pyx_PyObject_GetAttrStr(__pyx_t_29, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 6198, __pyx_L95_error)
        __Pyx_GOTREF(__pyx_t_30);
        __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_30))) {
          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_30);
          assert(__pyx_t_6);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_30);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_30, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Error_handling_idle_popup_respon, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_29 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 6198, __pyx_L95_error)
          __Pyx_GOTREF(__pyx_t_29);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_29, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 6198, __pyx_L95_error)
          __pyx_t_4 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_30, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_29);
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
          __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6198, __pyx_L95_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }

      /* "ws_package/controllers/activity_controller.py":6197
 *             logger.info("[IdleResponse] State cleared - unsent idle intervals suppressed when keep was unchecked")
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error handling idle popup response: %s", e, exc_info=True)
 * 
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          goto __pyx_L96;
        }
        __pyx_L95_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_XDECREF(__pyx_t_29); __pyx_t_29 = 0;
          __Pyx_XDECREF(__pyx_t_30); __pyx_t_30 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_20, &__pyx_t_21, &__pyx_t_22);
          if ( unlikely(__Pyx_GetException(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13) < 0)) __Pyx_ErrFetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_22);
          __pyx_t_14 = __pyx_lineno; __pyx_t_18 = __pyx_clineno; __pyx_t_32 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_ExceptionReset(__pyx_t_20, __pyx_t_21, __pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_ErrRestore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
          __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0;
          __pyx_lineno = __pyx_t_14; __pyx_clineno = __pyx_t_18; __pyx_filename = __pyx_t_32;
          goto __pyx_L6_except_error;
        }
        __pyx_L96:;
      }
      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      goto __pyx_L5_exception_handled;
    }
    goto __pyx_L6_except_error;

    /* "ws_package/controllers/activity_controller.py":6078
 *             file_path: Optional local file path to upload to S3
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             logger.info("[IdleResponse] Handling idle popup response: keep_idle_time=%s, action=%s, project_id=%s, task_id=%s, file_path=%s", keep_idle_time, action, project_id, task_id, file_path)
 * 
*/
    __pyx_L6_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L5_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    __pyx_L9_try_end:;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":6062
 *             return False
 * 
 *     async def handle_idle_popup_response(self, keep_idle_time: bool, action: str, project_id: Optional[str] = None, task_id: Optional[str] = None, note: Optional[str] = None, file_path: Optional[str] = None):             # <<<<<<<<<<<<<<
 *         """
 *         Handle idle popup response from Electron.
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_15);
  __Pyx_XDECREF(__pyx_t_16);
  __Pyx_XDECREF(__pyx_t_17);
  __Pyx_XDECREF(__pyx_t_29);
  __Pyx_XDECREF(__pyx_t_30);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("handle_idle_popup_response", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":6200
 *             logger.error("Error handling idle popup response: %s", e, exc_info=True)
 * 
 *     def handle_idle_popup_shown(self):             # <<<<<<<<<<<<<<
 *         """
 *         Called when Electron confirms the idle popup was shown to the user.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_205handle_idle_popup_shown(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_204handle_idle_popup_shown, "\n        Called when Electron confirms the idle popup was shown to the user.\n        No-op since cooldown was removed; frontend suppresses duplicate popups.\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_205handle_idle_popup_shown = {"handle_idle_popup_shown", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_205handle_idle_popup_shown, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_204handle_idle_popup_shown};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_205handle_idle_popup_shown(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  CYTHON_UNUSED PyObject *__pyx_v_self = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[1] = {0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("handle_idle_popup_shown (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 6200, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 6200, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "handle_idle_popup_shown", 0) < (0)) __PYX_ERR(0, 6200, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("handle_idle_popup_shown", 1, 1, 1, i); __PYX_ERR(0, 6200, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 1)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 6200, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("handle_idle_popup_shown", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 6200, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.handle_idle_popup_shown", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_204handle_idle_popup_shown(__pyx_self, __pyx_v_self);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_204handle_idle_popup_shown(CYTHON_UNUSED PyObject *__pyx_self, CYTHON_UNUSED PyObject *__pyx_v_self) {
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  size_t __pyx_t_5;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("handle_idle_popup_shown", 0);

  /* "ws_package/controllers/activity_controller.py":6205
 *         No-op since cooldown was removed; frontend suppresses duplicate popups.
 *         """
 *         logger.debug("Idle popup shown confirmed by Electron (cooldown removed)")             # <<<<<<<<<<<<<<
 * 
 *     async def sync_activity_immediately(self):
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6205, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6205, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
  __pyx_t_5 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_4))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
    __pyx_t_5 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_Idle_popup_shown_confirmed_by_El};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_5, (2-__pyx_t_5) | (__pyx_t_5*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6205, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

  /* "ws_package/controllers/activity_controller.py":6200
 *             logger.error("Error handling idle popup response: %s", e, exc_info=True)
 * 
 *     def handle_idle_popup_shown(self):             # <<<<<<<<<<<<<<
 *         """
 *         Called when Electron confirms the idle popup was shown to the user.
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.handle_idle_popup_shown", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_208generator44(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":6207
 *         logger.debug("Idle popup shown confirmed by Electron (cooldown removed)")
 * 
 *     async def sync_activity_immediately(self):             # <<<<<<<<<<<<<<
 *         """
 *         Immediately sync all unuploaded activity intervals to the server.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_207sync_activity_immediately(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_206sync_activity_immediately, "\n        Immediately sync all unuploaded activity intervals to the server.\n        Called when user chooses to keep idle time in the popup.\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_207sync_activity_immediately = {"sync_activity_immediately", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_207sync_activity_immediately, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_206sync_activity_immediately};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_207sync_activity_immediately(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[1] = {0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sync_activity_immediately (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 6207, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 6207, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "sync_activity_immediately", 0) < (0)) __PYX_ERR(0, 6207, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("sync_activity_immediately", 1, 1, 1, i); __PYX_ERR(0, 6207, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 1)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 6207, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("sync_activity_immediately", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 6207, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.sync_activity_immediately", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_206sync_activity_immediately(__pyx_self, __pyx_v_self);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_206sync_activity_immediately(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("sync_activity_immediately", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 6207, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_208generator44, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[70]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_sync_activity_immediately, __pyx_mstate_global->__pyx_n_u_ActivityController_sync_activity, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 6207, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.sync_activity_immediately", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_208generator44(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  size_t __pyx_t_8;
  __Pyx_PySendResult __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  int __pyx_t_12;
  int __pyx_t_13;
  Py_ssize_t __pyx_t_14;
  int __pyx_t_15;
  PyObject *(*__pyx_t_16)(PyObject *);
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  int __pyx_t_20;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  int __pyx_t_24;
  char const *__pyx_t_25;
  PyObject *__pyx_t_26 = NULL;
  PyObject *__pyx_t_27 = NULL;
  PyObject *__pyx_t_28 = NULL;
  PyObject *__pyx_t_29 = NULL;
  PyObject *__pyx_t_30 = NULL;
  PyObject *__pyx_t_31 = NULL;
  Py_ssize_t __pyx_t_32;
  PyObject *(*__pyx_t_33)(PyObject *);
  PyObject *__pyx_t_34 = NULL;
  char const *__pyx_t_35;
  char const *__pyx_t_36;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("sync_activity_immediately", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L10_resume_from_await;
    case 2: goto __pyx_L11_resume_from_await;
    case 3: goto __pyx_L12_resume_from_await;
    case 4: goto __pyx_L17_resume_from_await;
    case 5: goto __pyx_L37_resume_from_await;
    case 6: goto __pyx_L63_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 6207, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":6212
 *         Called when user chooses to keep idle time in the popup.
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             logger.info("=== sync_activity_immediately() called ===")
 * 
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":6213
 *         """
 *         try:
 *             logger.info("=== sync_activity_immediately() called ===")             # <<<<<<<<<<<<<<
 * 
 *             # 1. Flush DB queue to ensure all pending intervals are committed
*/
      __pyx_t_5 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6213, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6213, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_5);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_sync_activity_immediately_calle};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6213, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":6216
 * 
 *             # 1. Flush DB queue to ensure all pending intervals are committed
 *             await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 *             await asyncio.sleep(0.5) # Wait for commit visibility
 * 
*/
      __pyx_t_7 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6216, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6216, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
        assert(__pyx_t_7);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6216, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (likely(__pyx_t_9 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
        __Pyx_XGIVEREF(__pyx_t_2);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
        __Pyx_XGIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 1;
        return __pyx_r;
        __pyx_L10_resume_from_await:;
        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_1);
        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_2);
        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_3);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6216, __pyx_L4_error)
      } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_DECREF(__pyx_r); __pyx_r = 0;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 6216, __pyx_L4_error)
      }

      /* "ws_package/controllers/activity_controller.py":6217
 *             # 1. Flush DB queue to ensure all pending intervals are committed
 *             await db_writer_service.process_immediately()
 *             await asyncio.sleep(0.5) # Wait for commit visibility             # <<<<<<<<<<<<<<
 * 
 *             # 2. Get unuploaded intervals from current session only
*/
      __pyx_t_6 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6217, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6217, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
        assert(__pyx_t_6);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_float_0_5};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6217, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (likely(__pyx_t_9 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
        __Pyx_XGIVEREF(__pyx_t_2);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
        __Pyx_XGIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 2;
        return __pyx_r;
        __pyx_L11_resume_from_await:;
        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_1);
        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_2);
        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_3);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6217, __pyx_L4_error)
      } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_DECREF(__pyx_r); __pyx_r = 0;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 6217, __pyx_L4_error)
      }

      /* "ws_package/controllers/activity_controller.py":6221
 *             # 2. Get unuploaded intervals from current session only
 *             # CRITICAL: Filter by current session counter to prevent picking intervals from previous sessions
 *             current_session_counter = self.last_count + 1             # <<<<<<<<<<<<<<
 *             logger.info("Filtering intervals by current session counter=%s for immediate sync", current_session_counter)
 *             intervals = await self.activity_service.get_activity_intervals(self.main_start_date, self.main_end_date, counter=current_session_counter)
*/
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6221, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_5 = __Pyx_PyLong_AddObjC(__pyx_t_4, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6221, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_cur_scope->__pyx_v_current_session_counter = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "ws_package/controllers/activity_controller.py":6222
 *             # CRITICAL: Filter by current session counter to prevent picking intervals from previous sessions
 *             current_session_counter = self.last_count + 1
 *             logger.info("Filtering intervals by current session counter=%s for immediate sync", current_session_counter)             # <<<<<<<<<<<<<<
 *             intervals = await self.activity_service.get_activity_intervals(self.main_start_date, self.main_end_date, counter=current_session_counter)
 * 
*/
      __pyx_t_4 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6222, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6222, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_4);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Filtering_intervals_by_current_s_2, __pyx_cur_scope->__pyx_v_current_session_counter};
        __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6222, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "ws_package/controllers/activity_controller.py":6223
 *             current_session_counter = self.last_count + 1
 *             logger.info("Filtering intervals by current session counter=%s for immediate sync", current_session_counter)
 *             intervals = await self.activity_service.get_activity_intervals(self.main_start_date, self.main_end_date, counter=current_session_counter)             # <<<<<<<<<<<<<<
 * 
 *             if not intervals:
*/
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6223, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = __pyx_t_4;
      __Pyx_INCREF(__pyx_t_7);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_main_start_date); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6223, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_main_end_date); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 6223, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_7, __pyx_t_6, __pyx_t_10};
        __pyx_t_11 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6223, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_11);
        if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_counter, __pyx_cur_scope->__pyx_v_current_session_counter, __pyx_t_11, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 6223, __pyx_L4_error)
        __pyx_t_5 = __Pyx_Object_VectorcallMethod_CallFromBuilder((PyObject*)__pyx_mstate_global->__pyx_n_u_get_activity_intervals, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_11);
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6223, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
      }
      __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      if (likely(__pyx_t_9 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
        __Pyx_XGIVEREF(__pyx_t_2);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
        __Pyx_XGIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 3;
        return __pyx_r;
        __pyx_L12_resume_from_await:;
        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_1);
        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_2);
        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_3);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6223, __pyx_L4_error)
        __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
      } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __pyx_t_5 = __pyx_r; __pyx_r = NULL;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 6223, __pyx_L4_error)
      }
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_cur_scope->__pyx_v_intervals = __pyx_t_5;
      __pyx_t_5 = 0;

      /* "ws_package/controllers/activity_controller.py":6225
 *             intervals = await self.activity_service.get_activity_intervals(self.main_start_date, self.main_end_date, counter=current_session_counter)
 * 
 *             if not intervals:             # <<<<<<<<<<<<<<
 *                 logger.info("No intervals found to sync immediately")
 *                 return
*/
      __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_intervals); if (unlikely((__pyx_t_12 < 0))) __PYX_ERR(0, 6225, __pyx_L4_error)
      __pyx_t_13 = (!__pyx_t_12);
      if (__pyx_t_13) {

        /* "ws_package/controllers/activity_controller.py":6226
 * 
 *             if not intervals:
 *                 logger.info("No intervals found to sync immediately")             # <<<<<<<<<<<<<<
 *                 return
 * 
*/
        __pyx_t_4 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6226, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 6226, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10);
          assert(__pyx_t_4);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_No_intervals_found_to_sync_immed};
          __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6226, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":6227
 *             if not intervals:
 *                 logger.info("No intervals found to sync immediately")
 *                 return             # <<<<<<<<<<<<<<
 * 
 *             intervals = self._filter_intervals_excluding_in_progress_resolving_slot(intervals)
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
        goto __pyx_L8_try_return;

        /* "ws_package/controllers/activity_controller.py":6225
 *             intervals = await self.activity_service.get_activity_intervals(self.main_start_date, self.main_end_date, counter=current_session_counter)
 * 
 *             if not intervals:             # <<<<<<<<<<<<<<
 *                 logger.info("No intervals found to sync immediately")
 *                 return
*/
      }

      /* "ws_package/controllers/activity_controller.py":6229
 *                 return
 * 
 *             intervals = self._filter_intervals_excluding_in_progress_resolving_slot(intervals)             # <<<<<<<<<<<<<<
 * 
 *             if not intervals:
*/
      __pyx_t_10 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_10);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_cur_scope->__pyx_v_intervals};
        __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_filter_intervals_excluding_in_p, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6229, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
      }
      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_intervals);
      __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_intervals, __pyx_t_5);
      __Pyx_GIVEREF(__pyx_t_5);
      __pyx_t_5 = 0;

      /* "ws_package/controllers/activity_controller.py":6231
 *             intervals = self._filter_intervals_excluding_in_progress_resolving_slot(intervals)
 * 
 *             if not intervals:             # <<<<<<<<<<<<<<
 *                 logger.info("No completed intervals to sync immediately")
 *                 return
*/
      __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_intervals); if (unlikely((__pyx_t_13 < 0))) __PYX_ERR(0, 6231, __pyx_L4_error)
      __pyx_t_12 = (!__pyx_t_13);
      if (__pyx_t_12) {

        /* "ws_package/controllers/activity_controller.py":6232
 * 
 *             if not intervals:
 *                 logger.info("No completed intervals to sync immediately")             # <<<<<<<<<<<<<<
 *                 return
 * 
*/
        __pyx_t_10 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6232, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6232, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_11);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_11))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_11);
          assert(__pyx_t_10);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_11);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_11, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_No_completed_intervals_to_sync_i};
          __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_11, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6232, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

        /* "ws_package/controllers/activity_controller.py":6233
 *             if not intervals:
 *                 logger.info("No completed intervals to sync immediately")
 *                 return             # <<<<<<<<<<<<<<
 * 
 *             logger.info("Found %s intervals to sync immediately", len(intervals))
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
        goto __pyx_L8_try_return;

        /* "ws_package/controllers/activity_controller.py":6231
 *             intervals = self._filter_intervals_excluding_in_progress_resolving_slot(intervals)
 * 
 *             if not intervals:             # <<<<<<<<<<<<<<
 *                 logger.info("No completed intervals to sync immediately")
 *                 return
*/
      }

      /* "ws_package/controllers/activity_controller.py":6235
 *                 return
 * 
 *             logger.info("Found %s intervals to sync immediately", len(intervals))             # <<<<<<<<<<<<<<
 * 
 *             # 3. Process and upload using process_intervals_bulk
*/
      __pyx_t_11 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 6235, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6235, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
      __pyx_t_14 = PyObject_Length(__pyx_cur_scope->__pyx_v_intervals); if (unlikely(__pyx_t_14 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6235, __pyx_L4_error)
      __pyx_t_10 = PyLong_FromSsize_t(__pyx_t_14); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 6235, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_10);
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_4);
        assert(__pyx_t_11);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_11);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_11, __pyx_mstate_global->__pyx_kp_u_Found_s_intervals_to_sync_immedi, __pyx_t_10};
        __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6235, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "ws_package/controllers/activity_controller.py":6238
 * 
 *             # 3. Process and upload using process_intervals_bulk
 *             org_id = self.user_entity.org_id             # <<<<<<<<<<<<<<
 *             user_entity = self.user_entity
 * 
*/
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_user_entity); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6238, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_org_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6238, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_cur_scope->__pyx_v_org_id = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":6239
 *             # 3. Process and upload using process_intervals_bulk
 *             org_id = self.user_entity.org_id
 *             user_entity = self.user_entity             # <<<<<<<<<<<<<<
 * 
 *             # process_intervals_bulk is an async generator
*/
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_user_entity); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6239, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_cur_scope->__pyx_v_user_entity = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":6242
 * 
 *             # process_intervals_bulk is an async generator
 *             async for response in self.process_intervals_bulk(intervals, org_id, user_entity):             # <<<<<<<<<<<<<<
 *                 if not response or not isinstance(response, (list, tuple)) or len(response) < 2:
 *                     continue
*/
      __pyx_t_5 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_5);
      __pyx_t_8 = 0;
      {
        PyObject *__pyx_callargs[4] = {__pyx_t_5, __pyx_cur_scope->__pyx_v_intervals, __pyx_cur_scope->__pyx_v_org_id, __pyx_cur_scope->__pyx_v_user_entity};
        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_process_intervals_bulk, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6242, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_t_5 = __Pyx_Coroutine_GetAsyncIter(__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6242, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      for (;;) {
        __pyx_t_4 = __Pyx_Coroutine_AsyncIterNext(__pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6242, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (likely(__pyx_t_9 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_1);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
          __Pyx_XGIVEREF(__pyx_t_2);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
          __Pyx_XGIVEREF(__pyx_t_3);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
          __Pyx_XGIVEREF(__pyx_t_5);
          __pyx_cur_scope->__pyx_t_3 = __pyx_t_5;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 4;
          return __pyx_r;
          __pyx_L17_resume_from_await:;
          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_1);
          __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_2);
          __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_3);
          __pyx_t_5 = __pyx_cur_scope->__pyx_t_3;
          __pyx_cur_scope->__pyx_t_3 = 0;
          __Pyx_XGOTREF(__pyx_t_5);
          if (unlikely(!__pyx_sent_value)) {
            PyObject* exc_type = __Pyx_PyErr_CurrentExceptionType();
            if (unlikely(exc_type && (exc_type == PyExc_StopAsyncIteration || ( exc_type != PyExc_StopIteration && exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopAsyncIteration))))) {
              PyErr_Clear();
              break;
            }
            __PYX_ERR(0, 6242, __pyx_L4_error)
          }
          __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
        } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __pyx_t_4 = __pyx_r; __pyx_r = NULL;
        } else {
          PyObject* exc_type = __Pyx_PyErr_CurrentExceptionType();
          if (unlikely(exc_type && (exc_type == PyExc_StopAsyncIteration || ( exc_type != PyExc_StopIteration && exc_type != PyExc_GeneratorExit && __Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopAsyncIteration))))) {
            PyErr_Clear();
            break;
          }
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 6242, __pyx_L4_error)
        }
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_response);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_response, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":6243
 *             # process_intervals_bulk is an async generator
 *             async for response in self.process_intervals_bulk(intervals, org_id, user_entity):
 *                 if not response or not isinstance(response, (list, tuple)) or len(response) < 2:             # <<<<<<<<<<<<<<
 *                     continue
 * 
*/
        __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_response); if (unlikely((__pyx_t_13 < 0))) __PYX_ERR(0, 6243, __pyx_L4_error)
        __pyx_t_15 = (!__pyx_t_13);
        if (!__pyx_t_15) {
        } else {
          __pyx_t_12 = __pyx_t_15;
          goto __pyx_L19_bool_binop_done;
        }
        __pyx_t_13 = PyList_Check(__pyx_cur_scope->__pyx_v_response); 
        if (!__pyx_t_13) {
        } else {
          __pyx_t_15 = __pyx_t_13;
          goto __pyx_L22_bool_binop_done;
        }
        __pyx_t_13 = PyTuple_Check(__pyx_cur_scope->__pyx_v_response); 
        __pyx_t_15 = __pyx_t_13;
        __pyx_L22_bool_binop_done:;
        __pyx_t_13 = (!__pyx_t_15);
        if (!__pyx_t_13) {
        } else {
          __pyx_t_12 = __pyx_t_13;
          goto __pyx_L19_bool_binop_done;
        }
        __pyx_t_14 = PyObject_Length(__pyx_cur_scope->__pyx_v_response); if (unlikely(__pyx_t_14 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6243, __pyx_L4_error)
        __pyx_t_13 = (__pyx_t_14 < 2);
        __pyx_t_12 = __pyx_t_13;
        __pyx_L19_bool_binop_done:;
        if (__pyx_t_12) {

          /* "ws_package/controllers/activity_controller.py":6244
 *             async for response in self.process_intervals_bulk(intervals, org_id, user_entity):
 *                 if not response or not isinstance(response, (list, tuple)) or len(response) < 2:
 *                     continue             # <<<<<<<<<<<<<<
 * 
 *                 payload = response[0]
*/
          goto __pyx_L15_continue;

          /* "ws_package/controllers/activity_controller.py":6243
 *             # process_intervals_bulk is an async generator
 *             async for response in self.process_intervals_bulk(intervals, org_id, user_entity):
 *                 if not response or not isinstance(response, (list, tuple)) or len(response) < 2:             # <<<<<<<<<<<<<<
 *                     continue
 * 
*/
        }

        /* "ws_package/controllers/activity_controller.py":6246
 *                     continue
 * 
 *                 payload = response[0]             # <<<<<<<<<<<<<<
 *                 batch_intervals = response[1]
 * 
*/
        __pyx_t_4 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_response, 0, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_SharedReference); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6246, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_payload);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_payload, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":6247
 * 
 *                 payload = response[0]
 *                 batch_intervals = response[1]             # <<<<<<<<<<<<<<
 * 
 *                 logger.info("Sending immediate sync payload for %s intervals", len(batch_intervals))
*/
        __pyx_t_4 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_response, 1, long, 1, __Pyx_PyLong_From_long, 0, 0, 0, 1, __Pyx_ReferenceSharing_SharedReference); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6247, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_batch_intervals);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_batch_intervals, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":6249
 *                 batch_intervals = response[1]
 * 
 *                 logger.info("Sending immediate sync payload for %s intervals", len(batch_intervals))             # <<<<<<<<<<<<<<
 * 
 *                 # Send to API
*/
        __pyx_t_10 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6249, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6249, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_14 = PyObject_Length(__pyx_cur_scope->__pyx_v_batch_intervals); if (unlikely(__pyx_t_14 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6249, __pyx_L4_error)
        __pyx_t_11 = PyLong_FromSsize_t(__pyx_t_14); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6249, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_6);
          assert(__pyx_t_10);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_10);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Sending_immediate_sync_payload_f, __pyx_t_11};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6249, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":6252
 * 
 *                 # Send to API
 *                 api_response = self.activity_service.push_activity_logs(payload)             # <<<<<<<<<<<<<<
 *                 logger.info("Immediate sync API response: %s", api_response)
 * 
*/
        __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6252, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_6 = __pyx_t_11;
        __Pyx_INCREF(__pyx_t_6);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_cur_scope->__pyx_v_payload};
          __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_push_activity_logs, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6252, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_api_response);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_api_response, __pyx_t_4);
        __Pyx_GIVEREF(__pyx_t_4);
        __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":6253
 *                 # Send to API
 *                 api_response = self.activity_service.push_activity_logs(payload)
 *                 logger.info("Immediate sync API response: %s", api_response)             # <<<<<<<<<<<<<<
 * 
 *                 if api_response and api_response.get("planStatus") == "active":
*/
        __pyx_t_11 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6253, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 6253, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10);
          assert(__pyx_t_11);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_11, __pyx_mstate_global->__pyx_kp_u_Immediate_sync_API_response_s, __pyx_cur_scope->__pyx_v_api_response};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6253, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

        /* "ws_package/controllers/activity_controller.py":6255
 *                 logger.info("Immediate sync API response: %s", api_response)
 * 
 *                 if api_response and api_response.get("planStatus") == "active":             # <<<<<<<<<<<<<<
 *                     # Mark intervals as uploaded in DB
 *                     for interval in batch_intervals:
*/
        __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_api_response); if (unlikely((__pyx_t_13 < 0))) __PYX_ERR(0, 6255, __pyx_L4_error)
        if (__pyx_t_13) {
        } else {
          __pyx_t_12 = __pyx_t_13;
          goto __pyx_L25_bool_binop_done;
        }
        __pyx_t_10 = __pyx_cur_scope->__pyx_v_api_response;
        __Pyx_INCREF(__pyx_t_10);
        __pyx_t_8 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_10, __pyx_mstate_global->__pyx_n_u_planStatus};
          __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6255, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __pyx_t_13 = (__Pyx_PyUnicode_Equals(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_active, Py_EQ)); if (unlikely((__pyx_t_13 < 0))) __PYX_ERR(0, 6255, __pyx_L4_error)
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_12 = __pyx_t_13;
        __pyx_L25_bool_binop_done:;
        if (__pyx_t_12) {

          /* "ws_package/controllers/activity_controller.py":6257
 *                 if api_response and api_response.get("planStatus") == "active":
 *                     # Mark intervals as uploaded in DB
 *                     for interval in batch_intervals:             # <<<<<<<<<<<<<<
 *                         try:
 *                             await self.activity_service.update_activity_interval(interval)
*/
          if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_batch_intervals)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_batch_intervals)) {
            __pyx_t_4 = __pyx_cur_scope->__pyx_v_batch_intervals; __Pyx_INCREF(__pyx_t_4);
            __pyx_t_14 = 0;
            __pyx_t_16 = NULL;
          } else {
            __pyx_t_14 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_batch_intervals); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6257, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_16 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 6257, __pyx_L4_error)
          }
          for (;;) {
            if (likely(!__pyx_t_16)) {
              if (likely(PyList_CheckExact(__pyx_t_4))) {
                {
                  Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4);
                  #if !CYTHON_ASSUME_SAFE_SIZE
                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6257, __pyx_L4_error)
                  #endif
                  if (__pyx_t_14 >= __pyx_temp) break;
                }
                __pyx_t_10 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_4, __pyx_t_14, __Pyx_ReferenceSharing_OwnStrongReference);
                ++__pyx_t_14;
              } else {
                {
                  Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4);
                  #if !CYTHON_ASSUME_SAFE_SIZE
                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6257, __pyx_L4_error)
                  #endif
                  if (__pyx_t_14 >= __pyx_temp) break;
                }
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_10 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_14));
                #else
                __pyx_t_10 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_14);
                #endif
                ++__pyx_t_14;
              }
              if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 6257, __pyx_L4_error)
            } else {
              __pyx_t_10 = __pyx_t_16(__pyx_t_4);
              if (unlikely(!__pyx_t_10)) {
                PyObject* exc_type = PyErr_Occurred();
                if (exc_type) {
                  if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 6257, __pyx_L4_error)
                  PyErr_Clear();
                }
                break;
              }
            }
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_10);
            __Pyx_GIVEREF(__pyx_t_10);
            __pyx_t_10 = 0;

            /* "ws_package/controllers/activity_controller.py":6258
 *                     # Mark intervals as uploaded in DB
 *                     for interval in batch_intervals:
 *                         try:             # <<<<<<<<<<<<<<
 *                             await self.activity_service.update_activity_interval(interval)
 *                         except Exception as e:
*/
            {
              __Pyx_ExceptionSave(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
              __Pyx_XGOTREF(__pyx_t_17);
              __Pyx_XGOTREF(__pyx_t_18);
              __Pyx_XGOTREF(__pyx_t_19);
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":6259
 *                     for interval in batch_intervals:
 *                         try:
 *                             await self.activity_service.update_activity_interval(interval)             # <<<<<<<<<<<<<<
 *                         except Exception as e:
 *                             logger.error("Error marking interval %s as uploaded: %s", interval.id, e)
*/
                __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6259, __pyx_L29_error)
                __Pyx_GOTREF(__pyx_t_6);
                __pyx_t_11 = __pyx_t_6;
                __Pyx_INCREF(__pyx_t_11);
                __pyx_t_8 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_11, __pyx_cur_scope->__pyx_v_interval};
                  __pyx_t_10 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_update_activity_interval, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
                  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                  if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 6259, __pyx_L29_error)
                  __Pyx_GOTREF(__pyx_t_10);
                }
                __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_10, &__pyx_r);
                __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                if (likely(__pyx_t_9 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_1);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                  __Pyx_XGIVEREF(__pyx_t_2);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                  __Pyx_XGIVEREF(__pyx_t_3);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                  __Pyx_XGIVEREF(__pyx_t_4);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
                  __Pyx_XGIVEREF(__pyx_t_5);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_16;
                  __Pyx_XGIVEREF(__pyx_t_17);
                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_17;
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_18;
                  __Pyx_XGIVEREF(__pyx_t_19);
                  __pyx_cur_scope->__pyx_t_9 = __pyx_t_19;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 5;
                  return __pyx_r;
                  __pyx_L37_resume_from_await:;
                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_1);
                  __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_2);
                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_3);
                  __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_4);
                  __pyx_t_5 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_5);
                  __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_t_16 = __pyx_cur_scope->__pyx_t_6;
                  __pyx_t_17 = __pyx_cur_scope->__pyx_t_7;
                  __pyx_cur_scope->__pyx_t_7 = 0;
                  __Pyx_XGOTREF(__pyx_t_17);
                  __pyx_t_18 = __pyx_cur_scope->__pyx_t_8;
                  __pyx_cur_scope->__pyx_t_8 = 0;
                  __Pyx_XGOTREF(__pyx_t_18);
                  __pyx_t_19 = __pyx_cur_scope->__pyx_t_9;
                  __pyx_cur_scope->__pyx_t_9 = 0;
                  __Pyx_XGOTREF(__pyx_t_19);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6259, __pyx_L29_error)
                } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 6259, __pyx_L29_error)
                }

                /* "ws_package/controllers/activity_controller.py":6258
 *                     # Mark intervals as uploaded in DB
 *                     for interval in batch_intervals:
 *                         try:             # <<<<<<<<<<<<<<
 *                             await self.activity_service.update_activity_interval(interval)
 *                         except Exception as e:
*/
              }
              __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
              __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
              __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
              goto __pyx_L36_try_end;
              __pyx_L29_error:;
              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

              /* "ws_package/controllers/activity_controller.py":6260
 *                         try:
 *                             await self.activity_service.update_activity_interval(interval)
 *                         except Exception as e:             # <<<<<<<<<<<<<<
 *                             logger.error("Error marking interval %s as uploaded: %s", interval.id, e)
 * 
*/
              __pyx_t_20 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
              if (__pyx_t_20) {
                __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.sync_activity_immediately", __pyx_clineno, __pyx_lineno, __pyx_filename);
                if (__Pyx_GetException(&__pyx_t_10, &__pyx_t_6, &__pyx_t_11) < 0) __PYX_ERR(0, 6260, __pyx_L31_except_error)
                __Pyx_XGOTREF(__pyx_t_10);
                __Pyx_XGOTREF(__pyx_t_6);
                __Pyx_XGOTREF(__pyx_t_11);
                __Pyx_INCREF(__pyx_t_6);
                __Pyx_GIVEREF(__pyx_t_6);
                __pyx_cur_scope->__pyx_v_e = __pyx_t_6;
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":6261
 *                             await self.activity_service.update_activity_interval(interval)
 *                         except Exception as e:
 *                             logger.error("Error marking interval %s as uploaded: %s", interval.id, e)             # <<<<<<<<<<<<<<
 * 
 *                     # Update screenshot statuses
*/
                  __pyx_t_21 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6261, __pyx_L43_error)
                  __Pyx_GOTREF(__pyx_t_22);
                  __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6261, __pyx_L43_error)
                  __Pyx_GOTREF(__pyx_t_23);
                  __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                  __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6261, __pyx_L43_error)
                  __Pyx_GOTREF(__pyx_t_22);
                  __pyx_t_8 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_23))) {
                    __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_23);
                    assert(__pyx_t_21);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_23);
                    __Pyx_INCREF(__pyx_t_21);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_23, __pyx__function);
                    __pyx_t_8 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[4] = {__pyx_t_21, __pyx_mstate_global->__pyx_kp_u_Error_marking_interval_s_as_uplo, __pyx_t_22, __pyx_cur_scope->__pyx_v_e};
                    __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_23, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                    __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                    if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6261, __pyx_L43_error)
                    __Pyx_GOTREF(__pyx_t_7);
                  }
                  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                }

                /* "ws_package/controllers/activity_controller.py":6260
 *                         try:
 *                             await self.activity_service.update_activity_interval(interval)
 *                         except Exception as e:             # <<<<<<<<<<<<<<
 *                             logger.error("Error marking interval %s as uploaded: %s", interval.id, e)
 * 
*/
                /*finally:*/ {
                  /*normal exit:*/{
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    goto __pyx_L44;
                  }
                  __pyx_L43_error:;
                  /*exception exit:*/{
                    __Pyx_PyThreadState_assign
                    __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0;
                    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                     __Pyx_ExceptionSwap(&__pyx_t_29, &__pyx_t_30, &__pyx_t_31);
                    if ( unlikely(__Pyx_GetException(&__pyx_t_26, &__pyx_t_27, &__pyx_t_28) < 0)) __Pyx_ErrFetch(&__pyx_t_26, &__pyx_t_27, &__pyx_t_28);
                    __Pyx_XGOTREF(__pyx_t_26);
                    __Pyx_XGOTREF(__pyx_t_27);
                    __Pyx_XGOTREF(__pyx_t_28);
                    __Pyx_XGOTREF(__pyx_t_29);
                    __Pyx_XGOTREF(__pyx_t_30);
                    __Pyx_XGOTREF(__pyx_t_31);
                    __pyx_t_20 = __pyx_lineno; __pyx_t_24 = __pyx_clineno; __pyx_t_25 = __pyx_filename;
                    {
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    }
                    __Pyx_XGIVEREF(__pyx_t_29);
                    __Pyx_XGIVEREF(__pyx_t_30);
                    __Pyx_XGIVEREF(__pyx_t_31);
                    __Pyx_ExceptionReset(__pyx_t_29, __pyx_t_30, __pyx_t_31);
                    __Pyx_XGIVEREF(__pyx_t_26);
                    __Pyx_XGIVEREF(__pyx_t_27);
                    __Pyx_XGIVEREF(__pyx_t_28);
                    __Pyx_ErrRestore(__pyx_t_26, __pyx_t_27, __pyx_t_28);
                    __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0; __pyx_t_29 = 0; __pyx_t_30 = 0; __pyx_t_31 = 0;
                    __pyx_lineno = __pyx_t_20; __pyx_clineno = __pyx_t_24; __pyx_filename = __pyx_t_25;
                    goto __pyx_L31_except_error;
                  }
                  __pyx_L44:;
                }
                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
                goto __pyx_L30_exception_handled;
              }
              goto __pyx_L31_except_error;

              /* "ws_package/controllers/activity_controller.py":6258
 *                     # Mark intervals as uploaded in DB
 *                     for interval in batch_intervals:
 *                         try:             # <<<<<<<<<<<<<<
 *                             await self.activity_service.update_activity_interval(interval)
 *                         except Exception as e:
*/
              __pyx_L31_except_error:;
              __Pyx_XGIVEREF(__pyx_t_17);
              __Pyx_XGIVEREF(__pyx_t_18);
              __Pyx_XGIVEREF(__pyx_t_19);
              __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19);
              goto __pyx_L4_error;
              __pyx_L30_exception_handled:;
              __Pyx_XGIVEREF(__pyx_t_17);
              __Pyx_XGIVEREF(__pyx_t_18);
              __Pyx_XGIVEREF(__pyx_t_19);
              __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19);
              __pyx_L36_try_end:;
            }

            /* "ws_package/controllers/activity_controller.py":6257
 *                 if api_response and api_response.get("planStatus") == "active":
 *                     # Mark intervals as uploaded in DB
 *                     for interval in batch_intervals:             # <<<<<<<<<<<<<<
 *                         try:
 *                             await self.activity_service.update_activity_interval(interval)
*/
          }
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

          /* "ws_package/controllers/activity_controller.py":6264
 * 
 *                     # Update screenshot statuses
 *                     for day_payload in payload:             # <<<<<<<<<<<<<<
 *                         for interval_data in day_payload.get('intervals', []):
 *                             screen_url = interval_data.get("screenUrl")
*/
          if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_payload)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_payload)) {
            __pyx_t_4 = __pyx_cur_scope->__pyx_v_payload; __Pyx_INCREF(__pyx_t_4);
            __pyx_t_14 = 0;
            __pyx_t_16 = NULL;
          } else {
            __pyx_t_14 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_payload); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6264, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_16 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 6264, __pyx_L4_error)
          }
          for (;;) {
            if (likely(!__pyx_t_16)) {
              if (likely(PyList_CheckExact(__pyx_t_4))) {
                {
                  Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4);
                  #if !CYTHON_ASSUME_SAFE_SIZE
                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6264, __pyx_L4_error)
                  #endif
                  if (__pyx_t_14 >= __pyx_temp) break;
                }
                __pyx_t_11 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_4, __pyx_t_14, __Pyx_ReferenceSharing_OwnStrongReference);
                ++__pyx_t_14;
              } else {
                {
                  Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4);
                  #if !CYTHON_ASSUME_SAFE_SIZE
                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6264, __pyx_L4_error)
                  #endif
                  if (__pyx_t_14 >= __pyx_temp) break;
                }
                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                __pyx_t_11 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_14));
                #else
                __pyx_t_11 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_14);
                #endif
                ++__pyx_t_14;
              }
              if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6264, __pyx_L4_error)
            } else {
              __pyx_t_11 = __pyx_t_16(__pyx_t_4);
              if (unlikely(!__pyx_t_11)) {
                PyObject* exc_type = PyErr_Occurred();
                if (exc_type) {
                  if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 6264, __pyx_L4_error)
                  PyErr_Clear();
                }
                break;
              }
            }
            __Pyx_GOTREF(__pyx_t_11);
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_day_payload);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_day_payload, __pyx_t_11);
            __Pyx_GIVEREF(__pyx_t_11);
            __pyx_t_11 = 0;

            /* "ws_package/controllers/activity_controller.py":6265
 *                     # Update screenshot statuses
 *                     for day_payload in payload:
 *                         for interval_data in day_payload.get('intervals', []):             # <<<<<<<<<<<<<<
 *                             screen_url = interval_data.get("screenUrl")
 *                             if screen_url:
*/
            __pyx_t_6 = __pyx_cur_scope->__pyx_v_day_payload;
            __Pyx_INCREF(__pyx_t_6);
            __pyx_t_10 = PyList_New(0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 6265, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_8 = 0;
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_mstate_global->__pyx_n_u_intervals, __pyx_t_10};
              __pyx_t_11 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6265, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_11);
            }
            if (likely(PyList_CheckExact(__pyx_t_11)) || PyTuple_CheckExact(__pyx_t_11)) {
              __pyx_t_10 = __pyx_t_11; __Pyx_INCREF(__pyx_t_10);
              __pyx_t_32 = 0;
              __pyx_t_33 = NULL;
            } else {
              __pyx_t_32 = -1; __pyx_t_10 = PyObject_GetIter(__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 6265, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_10);
              __pyx_t_33 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_10); if (unlikely(!__pyx_t_33)) __PYX_ERR(0, 6265, __pyx_L4_error)
            }
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            for (;;) {
              if (likely(!__pyx_t_33)) {
                if (likely(PyList_CheckExact(__pyx_t_10))) {
                  {
                    Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_10);
                    #if !CYTHON_ASSUME_SAFE_SIZE
                    if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6265, __pyx_L4_error)
                    #endif
                    if (__pyx_t_32 >= __pyx_temp) break;
                  }
                  __pyx_t_11 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_10, __pyx_t_32, __Pyx_ReferenceSharing_OwnStrongReference);
                  ++__pyx_t_32;
                } else {
                  {
                    Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_10);
                    #if !CYTHON_ASSUME_SAFE_SIZE
                    if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6265, __pyx_L4_error)
                    #endif
                    if (__pyx_t_32 >= __pyx_temp) break;
                  }
                  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                  __pyx_t_11 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_10, __pyx_t_32));
                  #else
                  __pyx_t_11 = __Pyx_PySequence_ITEM(__pyx_t_10, __pyx_t_32);
                  #endif
                  ++__pyx_t_32;
                }
                if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6265, __pyx_L4_error)
              } else {
                __pyx_t_11 = __pyx_t_33(__pyx_t_10);
                if (unlikely(!__pyx_t_11)) {
                  PyObject* exc_type = PyErr_Occurred();
                  if (exc_type) {
                    if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 6265, __pyx_L4_error)
                    PyErr_Clear();
                  }
                  break;
                }
              }
              __Pyx_GOTREF(__pyx_t_11);
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval_data);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval_data, __pyx_t_11);
              __Pyx_GIVEREF(__pyx_t_11);
              __pyx_t_11 = 0;

              /* "ws_package/controllers/activity_controller.py":6266
 *                     for day_payload in payload:
 *                         for interval_data in day_payload.get('intervals', []):
 *                             screen_url = interval_data.get("screenUrl")             # <<<<<<<<<<<<<<
 *                             if screen_url:
 *                                 try:
*/
              __pyx_t_6 = __pyx_cur_scope->__pyx_v_interval_data;
              __Pyx_INCREF(__pyx_t_6);
              __pyx_t_8 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_n_u_screenUrl};
                __pyx_t_11 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6266, __pyx_L4_error)
                __Pyx_GOTREF(__pyx_t_11);
              }
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_screen_url);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_screen_url, __pyx_t_11);
              __Pyx_GIVEREF(__pyx_t_11);
              __pyx_t_11 = 0;

              /* "ws_package/controllers/activity_controller.py":6267
 *                         for interval_data in day_payload.get('intervals', []):
 *                             screen_url = interval_data.get("screenUrl")
 *                             if screen_url:             # <<<<<<<<<<<<<<
 *                                 try:
 *                                     await self.screenshot_controller.update_screenshots(screen_url, self.last_count + 1)
*/
              __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_screen_url); if (unlikely((__pyx_t_12 < 0))) __PYX_ERR(0, 6267, __pyx_L4_error)
              if (__pyx_t_12) {

                /* "ws_package/controllers/activity_controller.py":6268
 *                             screen_url = interval_data.get("screenUrl")
 *                             if screen_url:
 *                                 try:             # <<<<<<<<<<<<<<
 *                                     await self.screenshot_controller.update_screenshots(screen_url, self.last_count + 1)
 *                                 except Exception as e:
*/
                {
                  __Pyx_ExceptionSave(&__pyx_t_19, &__pyx_t_18, &__pyx_t_17);
                  __Pyx_XGOTREF(__pyx_t_19);
                  __Pyx_XGOTREF(__pyx_t_18);
                  __Pyx_XGOTREF(__pyx_t_17);
                  /*try:*/ {

                    /* "ws_package/controllers/activity_controller.py":6269
 *                             if screen_url:
 *                                 try:
 *                                     await self.screenshot_controller.update_screenshots(screen_url, self.last_count + 1)             # <<<<<<<<<<<<<<
 *                                 except Exception as e:
 *                                     logger.error("Error updating screenshot status for %s: %s", screen_url, e)
*/
                    __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_screenshot_controller); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6269, __pyx_L55_error)
                    __Pyx_GOTREF(__pyx_t_7);
                    __pyx_t_6 = __pyx_t_7;
                    __Pyx_INCREF(__pyx_t_6);
                    __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6269, __pyx_L55_error)
                    __Pyx_GOTREF(__pyx_t_23);
                    __pyx_t_22 = __Pyx_PyLong_AddObjC(__pyx_t_23, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6269, __pyx_L55_error)
                    __Pyx_GOTREF(__pyx_t_22);
                    __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                    __pyx_t_8 = 0;
                    {
                      PyObject *__pyx_callargs[3] = {__pyx_t_6, __pyx_cur_scope->__pyx_v_screen_url, __pyx_t_22};
                      __pyx_t_11 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_update_screenshots, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                      if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6269, __pyx_L55_error)
                      __Pyx_GOTREF(__pyx_t_11);
                    }
                    __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_11, &__pyx_r);
                    __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
                    if (likely(__pyx_t_9 == PYGEN_NEXT)) {
                      __Pyx_GOTREF(__pyx_r);
                      __Pyx_XGIVEREF(__pyx_t_1);
                      __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                      __Pyx_XGIVEREF(__pyx_t_2);
                      __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                      __Pyx_XGIVEREF(__pyx_t_3);
                      __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                      __Pyx_XGIVEREF(__pyx_t_4);
                      __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
                      __Pyx_XGIVEREF(__pyx_t_5);
                      __pyx_cur_scope->__pyx_t_4 = __pyx_t_5;
                      __Pyx_XGIVEREF(__pyx_t_10);
                      __pyx_cur_scope->__pyx_t_7 = __pyx_t_10;
                      __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                      __pyx_cur_scope->__pyx_t_6 = __pyx_t_16;
                      __Pyx_XGIVEREF(__pyx_t_17);
                      __pyx_cur_scope->__pyx_t_8 = __pyx_t_17;
                      __Pyx_XGIVEREF(__pyx_t_18);
                      __pyx_cur_scope->__pyx_t_9 = __pyx_t_18;
                      __Pyx_XGIVEREF(__pyx_t_19);
                      __pyx_cur_scope->__pyx_t_10 = __pyx_t_19;
                      __pyx_cur_scope->__pyx_t_11 = __pyx_t_32;
                      __pyx_cur_scope->__pyx_t_12 = __pyx_t_33;
                      __Pyx_XGIVEREF(__pyx_r);
                      __Pyx_RefNannyFinishContext();
                      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                      /* return from generator, awaiting value */
                      __pyx_generator->resume_label = 6;
                      return __pyx_r;
                      __pyx_L63_resume_from_await:;
                      __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                      __pyx_cur_scope->__pyx_t_0 = 0;
                      __Pyx_XGOTREF(__pyx_t_1);
                      __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                      __pyx_cur_scope->__pyx_t_1 = 0;
                      __Pyx_XGOTREF(__pyx_t_2);
                      __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                      __pyx_cur_scope->__pyx_t_2 = 0;
                      __Pyx_XGOTREF(__pyx_t_3);
                      __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
                      __pyx_cur_scope->__pyx_t_3 = 0;
                      __Pyx_XGOTREF(__pyx_t_4);
                      __pyx_t_5 = __pyx_cur_scope->__pyx_t_4;
                      __pyx_cur_scope->__pyx_t_4 = 0;
                      __Pyx_XGOTREF(__pyx_t_5);
                      __pyx_t_10 = __pyx_cur_scope->__pyx_t_7;
                      __pyx_cur_scope->__pyx_t_7 = 0;
                      __Pyx_XGOTREF(__pyx_t_10);
                      __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                      __pyx_t_16 = __pyx_cur_scope->__pyx_t_6;
                      __pyx_t_17 = __pyx_cur_scope->__pyx_t_8;
                      __pyx_cur_scope->__pyx_t_8 = 0;
                      __Pyx_XGOTREF(__pyx_t_17);
                      __pyx_t_18 = __pyx_cur_scope->__pyx_t_9;
                      __pyx_cur_scope->__pyx_t_9 = 0;
                      __Pyx_XGOTREF(__pyx_t_18);
                      __pyx_t_19 = __pyx_cur_scope->__pyx_t_10;
                      __pyx_cur_scope->__pyx_t_10 = 0;
                      __Pyx_XGOTREF(__pyx_t_19);
                      __pyx_t_32 = __pyx_cur_scope->__pyx_t_11;
                      __pyx_t_33 = __pyx_cur_scope->__pyx_t_12;
                      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6269, __pyx_L55_error)
                    } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
                      __Pyx_GOTREF(__pyx_r);
                      __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                    } else {
                      __Pyx_XGOTREF(__pyx_r);
                      __PYX_ERR(0, 6269, __pyx_L55_error)
                    }

                    /* "ws_package/controllers/activity_controller.py":6268
 *                             screen_url = interval_data.get("screenUrl")
 *                             if screen_url:
 *                                 try:             # <<<<<<<<<<<<<<
 *                                     await self.screenshot_controller.update_screenshots(screen_url, self.last_count + 1)
 *                                 except Exception as e:
*/
                  }
                  __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                  __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                  __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                  goto __pyx_L62_try_end;
                  __pyx_L55_error:;
                  __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
                  __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                  __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

                  /* "ws_package/controllers/activity_controller.py":6270
 *                                 try:
 *                                     await self.screenshot_controller.update_screenshots(screen_url, self.last_count + 1)
 *                                 except Exception as e:             # <<<<<<<<<<<<<<
 *                                     logger.error("Error updating screenshot status for %s: %s", screen_url, e)
 *                 else:
*/
                  __pyx_t_24 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                  if (__pyx_t_24) {
                    __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.sync_activity_immediately", __pyx_clineno, __pyx_lineno, __pyx_filename);
                    if (__Pyx_GetException(&__pyx_t_11, &__pyx_t_7, &__pyx_t_22) < 0) __PYX_ERR(0, 6270, __pyx_L57_except_error)
                    __Pyx_XGOTREF(__pyx_t_11);
                    __Pyx_XGOTREF(__pyx_t_7);
                    __Pyx_XGOTREF(__pyx_t_22);
                    __Pyx_INCREF(__pyx_t_7);
                    __Pyx_GIVEREF(__pyx_t_7);
                    __pyx_cur_scope->__pyx_v_e = __pyx_t_7;
                    /*try:*/ {

                      /* "ws_package/controllers/activity_controller.py":6271
 *                                     await self.screenshot_controller.update_screenshots(screen_url, self.last_count + 1)
 *                                 except Exception as e:
 *                                     logger.error("Error updating screenshot status for %s: %s", screen_url, e)             # <<<<<<<<<<<<<<
 *                 else:
 *                     logger.warning("Immediate sync API call failed or returned inactive status: %s", api_response)
*/
                      __pyx_t_23 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6271, __pyx_L69_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 6271, __pyx_L69_error)
                      __Pyx_GOTREF(__pyx_t_34);
                      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                      __pyx_t_8 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_34))) {
                        __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_34);
                        assert(__pyx_t_23);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_34);
                        __Pyx_INCREF(__pyx_t_23);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_34, __pyx__function);
                        __pyx_t_8 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[4] = {__pyx_t_23, __pyx_mstate_global->__pyx_kp_u_Error_updating_screenshot_status, __pyx_cur_scope->__pyx_v_screen_url, __pyx_cur_scope->__pyx_v_e};
                        __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_34, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
                        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6271, __pyx_L69_error)
                        __Pyx_GOTREF(__pyx_t_6);
                      }
                      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                    }

                    /* "ws_package/controllers/activity_controller.py":6270
 *                                 try:
 *                                     await self.screenshot_controller.update_screenshots(screen_url, self.last_count + 1)
 *                                 except Exception as e:             # <<<<<<<<<<<<<<
 *                                     logger.error("Error updating screenshot status for %s: %s", screen_url, e)
 *                 else:
*/
                    /*finally:*/ {
                      /*normal exit:*/{
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                        __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                        goto __pyx_L70;
                      }
                      __pyx_L69_error:;
                      /*exception exit:*/{
                        __Pyx_PyThreadState_assign
                        __pyx_t_31 = 0; __pyx_t_30 = 0; __pyx_t_29 = 0; __pyx_t_28 = 0; __pyx_t_27 = 0; __pyx_t_26 = 0;
                        __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                         __Pyx_ExceptionSwap(&__pyx_t_28, &__pyx_t_27, &__pyx_t_26);
                        if ( unlikely(__Pyx_GetException(&__pyx_t_31, &__pyx_t_30, &__pyx_t_29) < 0)) __Pyx_ErrFetch(&__pyx_t_31, &__pyx_t_30, &__pyx_t_29);
                        __Pyx_XGOTREF(__pyx_t_31);
                        __Pyx_XGOTREF(__pyx_t_30);
                        __Pyx_XGOTREF(__pyx_t_29);
                        __Pyx_XGOTREF(__pyx_t_28);
                        __Pyx_XGOTREF(__pyx_t_27);
                        __Pyx_XGOTREF(__pyx_t_26);
                        __pyx_t_24 = __pyx_lineno; __pyx_t_20 = __pyx_clineno; __pyx_t_35 = __pyx_filename;
                        {
                          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                        }
                        __Pyx_XGIVEREF(__pyx_t_28);
                        __Pyx_XGIVEREF(__pyx_t_27);
                        __Pyx_XGIVEREF(__pyx_t_26);
                        __Pyx_ExceptionReset(__pyx_t_28, __pyx_t_27, __pyx_t_26);
                        __Pyx_XGIVEREF(__pyx_t_31);
                        __Pyx_XGIVEREF(__pyx_t_30);
                        __Pyx_XGIVEREF(__pyx_t_29);
                        __Pyx_ErrRestore(__pyx_t_31, __pyx_t_30, __pyx_t_29);
                        __pyx_t_31 = 0; __pyx_t_30 = 0; __pyx_t_29 = 0; __pyx_t_28 = 0; __pyx_t_27 = 0; __pyx_t_26 = 0;
                        __pyx_lineno = __pyx_t_24; __pyx_clineno = __pyx_t_20; __pyx_filename = __pyx_t_35;
                        goto __pyx_L57_except_error;
                      }
                      __pyx_L70:;
                    }
                    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
                    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                    goto __pyx_L56_exception_handled;
                  }
                  goto __pyx_L57_except_error;

                  /* "ws_package/controllers/activity_controller.py":6268
 *                             screen_url = interval_data.get("screenUrl")
 *                             if screen_url:
 *                                 try:             # <<<<<<<<<<<<<<
 *                                     await self.screenshot_controller.update_screenshots(screen_url, self.last_count + 1)
 *                                 except Exception as e:
*/
                  __pyx_L57_except_error:;
                  __Pyx_XGIVEREF(__pyx_t_19);
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __Pyx_XGIVEREF(__pyx_t_17);
                  __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_18, __pyx_t_17);
                  goto __pyx_L4_error;
                  __pyx_L56_exception_handled:;
                  __Pyx_XGIVEREF(__pyx_t_19);
                  __Pyx_XGIVEREF(__pyx_t_18);
                  __Pyx_XGIVEREF(__pyx_t_17);
                  __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_18, __pyx_t_17);
                  __pyx_L62_try_end:;
                }

                /* "ws_package/controllers/activity_controller.py":6267
 *                         for interval_data in day_payload.get('intervals', []):
 *                             screen_url = interval_data.get("screenUrl")
 *                             if screen_url:             # <<<<<<<<<<<<<<
 *                                 try:
 *                                     await self.screenshot_controller.update_screenshots(screen_url, self.last_count + 1)
*/
              }

              /* "ws_package/controllers/activity_controller.py":6265
 *                     # Update screenshot statuses
 *                     for day_payload in payload:
 *                         for interval_data in day_payload.get('intervals', []):             # <<<<<<<<<<<<<<
 *                             screen_url = interval_data.get("screenUrl")
 *                             if screen_url:
*/
            }
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

            /* "ws_package/controllers/activity_controller.py":6264
 * 
 *                     # Update screenshot statuses
 *                     for day_payload in payload:             # <<<<<<<<<<<<<<
 *                         for interval_data in day_payload.get('intervals', []):
 *                             screen_url = interval_data.get("screenUrl")
*/
          }
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

          /* "ws_package/controllers/activity_controller.py":6255
 *                 logger.info("Immediate sync API response: %s", api_response)
 * 
 *                 if api_response and api_response.get("planStatus") == "active":             # <<<<<<<<<<<<<<
 *                     # Mark intervals as uploaded in DB
 *                     for interval in batch_intervals:
*/
          goto __pyx_L24;
        }

        /* "ws_package/controllers/activity_controller.py":6273
 *                                     logger.error("Error updating screenshot status for %s: %s", screen_url, e)
 *                 else:
 *                     logger.warning("Immediate sync API call failed or returned inactive status: %s", api_response)             # <<<<<<<<<<<<<<
 * 
 *             logger.info("=== sync_activity_immediately() completed ===")
*/
        /*else*/ {
          __pyx_t_10 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6273, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_22);
          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6273, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
          __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
          __pyx_t_8 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_7))) {
            __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_7);
            assert(__pyx_t_10);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
            __Pyx_INCREF(__pyx_t_10);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
            __pyx_t_8 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_10, __pyx_mstate_global->__pyx_kp_u_Immediate_sync_API_call_failed_o, __pyx_cur_scope->__pyx_v_api_response};
            __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
            __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
            if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6273, __pyx_L4_error)
            __Pyx_GOTREF(__pyx_t_4);
          }
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        }
        __pyx_L24:;

        /* "ws_package/controllers/activity_controller.py":6242
 * 
 *             # process_intervals_bulk is an async generator
 *             async for response in self.process_intervals_bulk(intervals, org_id, user_entity):             # <<<<<<<<<<<<<<
 *                 if not response or not isinstance(response, (list, tuple)) or len(response) < 2:
 *                     continue
*/
        __pyx_L15_continue:;
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "ws_package/controllers/activity_controller.py":6275
 *                     logger.warning("Immediate sync API call failed or returned inactive status: %s", api_response)
 * 
 *             logger.info("=== sync_activity_immediately() completed ===")             # <<<<<<<<<<<<<<
 * 
 *         except Exception as e:
*/
      __pyx_t_4 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6275, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 6275, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_10))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_10);
        assert(__pyx_t_4);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_sync_activity_immediately_compl};
        __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6275, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
      }
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

      /* "ws_package/controllers/activity_controller.py":6212
 *         Called when user chooses to keep idle time in the popup.
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             logger.info("=== sync_activity_immediately() called ===")
 * 
*/
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L9_try_end;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
    __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "ws_package/controllers/activity_controller.py":6277
 *             logger.info("=== sync_activity_immediately() completed ===")
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error in sync_activity_immediately: %s", e, exc_info=True)
 * 
*/
    __pyx_t_20 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_20) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController.sync_activity_immediately", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_10, &__pyx_t_4) < 0) __PYX_ERR(0, 6277, __pyx_L6_except_error)
      __Pyx_XGOTREF(__pyx_t_5);
      __Pyx_XGOTREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_INCREF(__pyx_t_10);
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_10);
      __Pyx_GIVEREF(__pyx_t_10);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":6278
 * 
 *         except Exception as e:
 *             logger.error("Error in sync_activity_immediately: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *     async def _mark_idle_intervals_as_uploaded(self):
*/
        __pyx_t_22 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6278, __pyx_L83_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6278, __pyx_L83_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_22 = PyMethod_GET_SELF(__pyx_t_6);
          assert(__pyx_t_22);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_22);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_22, __pyx_mstate_global->__pyx_kp_u_Error_in_sync_activity_immediate, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_11 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6278, __pyx_L83_error)
          __Pyx_GOTREF(__pyx_t_11);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_11, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 6278, __pyx_L83_error)
          __pyx_t_7 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_11);
          __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6278, __pyx_L83_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }

      /* "ws_package/controllers/activity_controller.py":6277
 *             logger.info("=== sync_activity_immediately() completed ===")
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error in sync_activity_immediately: %s", e, exc_info=True)
 * 
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          goto __pyx_L84;
        }
        __pyx_L83_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
          __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_26, &__pyx_t_27, &__pyx_t_28);
          if ( unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_17);
          __Pyx_XGOTREF(__pyx_t_18);
          __Pyx_XGOTREF(__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_26);
          __Pyx_XGOTREF(__pyx_t_27);
          __Pyx_XGOTREF(__pyx_t_28);
          __pyx_t_20 = __pyx_lineno; __pyx_t_24 = __pyx_clineno; __pyx_t_36 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_26);
          __Pyx_XGIVEREF(__pyx_t_27);
          __Pyx_XGIVEREF(__pyx_t_28);
          __Pyx_ExceptionReset(__pyx_t_26, __pyx_t_27, __pyx_t_28);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_ErrRestore(__pyx_t_17, __pyx_t_18, __pyx_t_19);
          __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_26 = 0; __pyx_t_27 = 0; __pyx_t_28 = 0;
          __pyx_lineno = __pyx_t_20; __pyx_clineno = __pyx_t_24; __pyx_filename = __pyx_t_36;
          goto __pyx_L6_except_error;
        }
        __pyx_L84:;
      }
      __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
      __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      goto __pyx_L5_exception_handled;
    }
    goto __pyx_L6_except_error;

    /* "ws_package/controllers/activity_controller.py":6212
 *         Called when user chooses to keep idle time in the popup.
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             logger.info("=== sync_activity_immediately() called ===")
 * 
*/
    __pyx_L6_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L5_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    __pyx_L9_try_end:;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":6207
 *         logger.debug("Idle popup shown confirmed by Electron (cooldown removed)")
 * 
 *     async def sync_activity_immediately(self):             # <<<<<<<<<<<<<<
 *         """
 *         Immediately sync all unuploaded activity intervals to the server.
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_XDECREF(__pyx_t_23);
  __Pyx_XDECREF(__pyx_t_34);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("sync_activity_immediately", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_211generator45(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":6280
 *             logger.error("Error in sync_activity_immediately: %s", e, exc_info=True)
 * 
 *     async def _mark_idle_intervals_as_uploaded(self):             # <<<<<<<<<<<<<<
 *         """
 *         Mark idle intervals as is_uploaded=True so they are never sent to the server.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_210_mark_idle_intervals_as_uploaded(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_209_mark_idle_intervals_as_uploaded, "\n        Mark idle intervals as is_uploaded=True so they are never sent to the server.\n        Called when the user unchecks \"Keep idle time\" (Continue/Stop) or on auto-stop.\n\n        Covers:\n        - All unsent intervals from the current idle-popup period (start_time >= triggered_at)\n        - All is_idle=True rows (race where is_idle was not committed yet)\n        - Consecutive zero-activity streak from newest (fallback when flags lag)\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_210_mark_idle_intervals_as_uploaded = {"_mark_idle_intervals_as_uploaded", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_210_mark_idle_intervals_as_uploaded, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_209_mark_idle_intervals_as_uploaded};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_210_mark_idle_intervals_as_uploaded(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[1] = {0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_mark_idle_intervals_as_uploaded (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 6280, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 6280, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_mark_idle_intervals_as_uploaded", 0) < (0)) __PYX_ERR(0, 6280, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 1; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_mark_idle_intervals_as_uploaded", 1, 1, 1, i); __PYX_ERR(0, 6280, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 1)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 6280, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_mark_idle_intervals_as_uploaded", 1, 1, 1, __pyx_nargs); __PYX_ERR(0, 6280, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._mark_idle_intervals_as_uploaded", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_209_mark_idle_intervals_as_uploaded(__pyx_self, __pyx_v_self);

  /* function exit code */
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_209_mark_idle_intervals_as_uploaded(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_mark_idle_intervals_as_uploaded", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 6280, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_211generator45, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[71]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_mark_idle_intervals_as_uploaded, __pyx_mstate_global->__pyx_n_u_ActivityController__mark_idle_in, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 6280, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._mark_idle_intervals_as_uploaded", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_211generator45(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  size_t __pyx_t_8;
  __Pyx_PySendResult __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  int __pyx_t_18;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  Py_ssize_t __pyx_t_26;
  PyObject *(*__pyx_t_27)(PyObject *);
  int __pyx_t_28;
  int __pyx_t_29;
  PyObject *__pyx_t_30 = NULL;
  int __pyx_t_31;
  int __pyx_t_32;
  char const *__pyx_t_33;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_mark_idle_intervals_as_uploaded", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L10_resume_from_await;
    case 2: goto __pyx_L11_resume_from_await;
    case 3: goto __pyx_L23_resume_from_await;
    case 4: goto __pyx_L34_resume_from_await;
    case 5: goto __pyx_L38_resume_from_await;
    case 6: goto __pyx_L42_resume_from_await;
    case 7: goto __pyx_L49_resume_from_await;
    case 8: goto __pyx_L55_resume_from_await;
    case 9: goto __pyx_L56_resume_from_await;
    case 10: goto __pyx_L66_resume_from_await;
    case 11: goto __pyx_L67_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 6280, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":6290
 *         - Consecutive zero-activity streak from newest (fallback when flags lag)
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             await db_writer_service.process_immediately()
 *             await asyncio.sleep(0.5)
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":6291
 *         """
 *         try:
 *             await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 *             await asyncio.sleep(0.5)
 * 
*/
      __pyx_t_5 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6291, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6291, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_5);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6291, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (likely(__pyx_t_9 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
        __Pyx_XGIVEREF(__pyx_t_2);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
        __Pyx_XGIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 1;
        return __pyx_r;
        __pyx_L10_resume_from_await:;
        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_1);
        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_2);
        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_3);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6291, __pyx_L4_error)
      } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_DECREF(__pyx_r); __pyx_r = 0;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 6291, __pyx_L4_error)
      }

      /* "ws_package/controllers/activity_controller.py":6292
 *         try:
 *             await db_writer_service.process_immediately()
 *             await asyncio.sleep(0.5)             # <<<<<<<<<<<<<<
 * 
 *             current_counter = self.last_count + 1
*/
      __pyx_t_7 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6292, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6292, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
        assert(__pyx_t_7);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_mstate_global->__pyx_float_0_5};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6292, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (likely(__pyx_t_9 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
        __Pyx_XGIVEREF(__pyx_t_2);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
        __Pyx_XGIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 2;
        return __pyx_r;
        __pyx_L11_resume_from_await:;
        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_1);
        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_2);
        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_3);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6292, __pyx_L4_error)
      } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_DECREF(__pyx_r); __pyx_r = 0;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 6292, __pyx_L4_error)
      }

      /* "ws_package/controllers/activity_controller.py":6294
 *             await asyncio.sleep(0.5)
 * 
 *             current_counter = self.last_count + 1             # <<<<<<<<<<<<<<
 *             interval_ids = set()
 *             popup_triggered_at = self._idle_popup_triggered_at
*/
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6294, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = __Pyx_PyLong_AddObjC(__pyx_t_4, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6294, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_cur_scope->__pyx_v_current_counter = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":6295
 * 
 *             current_counter = self.last_count + 1
 *             interval_ids = set()             # <<<<<<<<<<<<<<
 *             popup_triggered_at = self._idle_popup_triggered_at
 * 
*/
      __pyx_t_6 = PySet_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6295, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_cur_scope->__pyx_v_interval_ids = ((PyObject*)__pyx_t_6);
      __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":6296
 *             current_counter = self.last_count + 1
 *             interval_ids = set()
 *             popup_triggered_at = self._idle_popup_triggered_at             # <<<<<<<<<<<<<<
 * 
 *             with db_lock_manager.read_lock():
*/
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_triggered_at); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6296, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_cur_scope->__pyx_v_popup_triggered_at = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":6298
 *             popup_triggered_at = self._idle_popup_triggered_at
 * 
 *             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     # 1) Entire idle-popup window (10/5/15 min rows + any with activity during popup)
*/
      /*with:*/ {
        __pyx_t_4 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6298, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6298, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
          assert(__pyx_t_4);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
          __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6298, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __pyx_t_10 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 6298, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_4 = NULL;
        __pyx_t_7 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6298, __pyx_L12_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (likely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7);
          assert(__pyx_t_4);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
          __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6298, __pyx_L12_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        /*try:*/ {
          {
            __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
            __Pyx_XGOTREF(__pyx_t_11);
            __Pyx_XGOTREF(__pyx_t_12);
            __Pyx_XGOTREF(__pyx_t_13);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":6299
 * 
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     # 1) Entire idle-popup window (10/5/15 min rows + any with activity during popup)
 *                     if popup_triggered_at is not None:
*/
              /*with:*/ {
                __pyx_t_5 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6299, __pyx_L16_error)
                __Pyx_GOTREF(__pyx_t_7);
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_7))) {
                  __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
                  assert(__pyx_t_5);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                  __Pyx_INCREF(__pyx_t_5);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                  __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6299, __pyx_L16_error)
                  __Pyx_GOTREF(__pyx_t_6);
                }
                __pyx_t_14 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 6299, __pyx_L16_error)
                __Pyx_GOTREF(__pyx_t_14);
                __pyx_t_5 = NULL;
                __pyx_t_4 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6299, __pyx_L22_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (likely(PyMethod_Check(__pyx_t_4))) {
                  __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
                  assert(__pyx_t_5);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                  __Pyx_INCREF(__pyx_t_5);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                  __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6299, __pyx_L22_error)
                  __Pyx_GOTREF(__pyx_t_7);
                }
                __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7, &__pyx_r);
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                if (likely(__pyx_t_9 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_1);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                  __Pyx_XGIVEREF(__pyx_t_2);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                  __Pyx_XGIVEREF(__pyx_t_3);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                  __Pyx_XGIVEREF(__pyx_t_6);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_6;
                  __Pyx_XGIVEREF(__pyx_t_10);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                  __Pyx_XGIVEREF(__pyx_t_11);
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_t_14);
                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_14;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 3;
                  return __pyx_r;
                  __pyx_L23_resume_from_await:;
                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_1);
                  __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_2);
                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_3);
                  __pyx_t_6 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_6);
                  __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_10);
                  __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = 0;
                  __Pyx_XGOTREF(__pyx_t_11);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
                  __pyx_cur_scope->__pyx_t_6 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_7;
                  __pyx_cur_scope->__pyx_t_7 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  __pyx_t_14 = __pyx_cur_scope->__pyx_t_8;
                  __pyx_cur_scope->__pyx_t_8 = 0;
                  __Pyx_XGOTREF(__pyx_t_14);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6299, __pyx_L22_error)
                  __pyx_t_7 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_7);
                } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __pyx_t_7 = __pyx_r; __pyx_r = NULL;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 6299, __pyx_L22_error)
                }
                __pyx_t_4 = __pyx_t_7;
                __pyx_t_7 = 0;
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                /*try:*/ {
                  {
                    __Pyx_ExceptionSave(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
                    __Pyx_XGOTREF(__pyx_t_15);
                    __Pyx_XGOTREF(__pyx_t_16);
                    __Pyx_XGOTREF(__pyx_t_17);
                    /*try:*/ {
                      __Pyx_GIVEREF(__pyx_t_4);
                      __pyx_cur_scope->__pyx_v_session = __pyx_t_4;
                      __pyx_t_4 = 0;

                      /* "ws_package/controllers/activity_controller.py":6301
 *                 async with async_session() as session:
 *                     # 1) Entire idle-popup window (10/5/15 min rows + any with activity during popup)
 *                     if popup_triggered_at is not None:             # <<<<<<<<<<<<<<
 *                         popup_query = select(ActivityInterval).where(
 *                             and_(
*/
                      __pyx_t_18 = (__pyx_cur_scope->__pyx_v_popup_triggered_at != Py_None);
                      if (__pyx_t_18) {

                        /* "ws_package/controllers/activity_controller.py":6302
 *                     # 1) Entire idle-popup window (10/5/15 min rows + any with activity during popup)
 *                     if popup_triggered_at is not None:
 *                         popup_query = select(ActivityInterval).where(             # <<<<<<<<<<<<<<
 *                             and_(
 *                                 ActivityInterval.counter == current_counter,
*/
                        __pyx_t_5 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6302, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_19);
                        __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6302, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_20);
                        __pyx_t_8 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_19))) {
                          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_19);
                          assert(__pyx_t_5);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_19);
                          __Pyx_INCREF(__pyx_t_5);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_19, __pyx__function);
                          __pyx_t_8 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_20};
                          __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_19, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6302, __pyx_L27_error)
                          __Pyx_GOTREF(__pyx_t_7);
                        }
                        __pyx_t_6 = __pyx_t_7;
                        __Pyx_INCREF(__pyx_t_6);

                        /* "ws_package/controllers/activity_controller.py":6303
 *                     if popup_triggered_at is not None:
 *                         popup_query = select(ActivityInterval).where(
 *                             and_(             # <<<<<<<<<<<<<<
 *                                 ActivityInterval.counter == current_counter,
 *                                 ActivityInterval.is_break == 0,
*/
                        __pyx_t_20 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_and); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6303, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_5);

                        /* "ws_package/controllers/activity_controller.py":6304
 *                         popup_query = select(ActivityInterval).where(
 *                             and_(
 *                                 ActivityInterval.counter == current_counter,             # <<<<<<<<<<<<<<
 *                                 ActivityInterval.is_break == 0,
 *                                 ActivityInterval.start_time >= popup_triggered_at,
*/
                        __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6304, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_21);
                        __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6304, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_22);
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __pyx_t_21 = PyObject_RichCompare(__pyx_t_22, __pyx_cur_scope->__pyx_v_current_counter, Py_EQ); __Pyx_XGOTREF(__pyx_t_21); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6304, __pyx_L27_error)
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;

                        /* "ws_package/controllers/activity_controller.py":6305
 *                             and_(
 *                                 ActivityInterval.counter == current_counter,
 *                                 ActivityInterval.is_break == 0,             # <<<<<<<<<<<<<<
 *                                 ActivityInterval.start_time >= popup_triggered_at,
 *                                 ActivityInterval.is_uploaded == False,
*/
                        __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6305, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_22);
                        __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_is_break); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6305, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_23);
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __pyx_t_22 = __Pyx_PyLong_EqObjC(__pyx_t_23, __pyx_mstate_global->__pyx_int_0, 0, 0); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6305, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_22);
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

                        /* "ws_package/controllers/activity_controller.py":6306
 *                                 ActivityInterval.counter == current_counter,
 *                                 ActivityInterval.is_break == 0,
 *                                 ActivityInterval.start_time >= popup_triggered_at,             # <<<<<<<<<<<<<<
 *                                 ActivityInterval.is_uploaded == False,
 *                             )
*/
                        __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6306, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_23);
                        __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 6306, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_24);
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __pyx_t_23 = PyObject_RichCompare(__pyx_t_24, __pyx_cur_scope->__pyx_v_popup_triggered_at, Py_GE); __Pyx_XGOTREF(__pyx_t_23); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6306, __pyx_L27_error)
                        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;

                        /* "ws_package/controllers/activity_controller.py":6307
 *                                 ActivityInterval.is_break == 0,
 *                                 ActivityInterval.start_time >= popup_triggered_at,
 *                                 ActivityInterval.is_uploaded == False,             # <<<<<<<<<<<<<<
 *                             )
 *                         )
*/
                        __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 6307, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_24);
                        __pyx_t_25 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_is_uploaded); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 6307, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_25);
                        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __pyx_t_24 = PyObject_RichCompare(__pyx_t_25, Py_False, Py_EQ); __Pyx_XGOTREF(__pyx_t_24); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 6307, __pyx_L27_error)
                        __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                        __pyx_t_8 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_5))) {
                          __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_5);
                          assert(__pyx_t_20);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                          __Pyx_INCREF(__pyx_t_20);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                          __pyx_t_8 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[5] = {__pyx_t_20, __pyx_t_21, __pyx_t_22, __pyx_t_23, __pyx_t_24};
                          __pyx_t_19 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                          __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                          __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                          __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                          __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                          if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6303, __pyx_L27_error)
                          __Pyx_GOTREF(__pyx_t_19);
                        }
                        __pyx_t_8 = 0;
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_19};
                          __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6302, __pyx_L27_error)
                          __Pyx_GOTREF(__pyx_t_4);
                        }
                        __Pyx_GIVEREF(__pyx_t_4);
                        __pyx_cur_scope->__pyx_v_popup_query = __pyx_t_4;
                        __pyx_t_4 = 0;

                        /* "ws_package/controllers/activity_controller.py":6310
 *                             )
 *                         )
 *                         popup_result = await session.execute(popup_query)             # <<<<<<<<<<<<<<
 *                         for interval in popup_result.scalars().all():
 *                             interval_ids.add(interval.id)
*/
                        __pyx_t_7 = __pyx_cur_scope->__pyx_v_session;
                        __Pyx_INCREF(__pyx_t_7);
                        __pyx_t_8 = 0;
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_cur_scope->__pyx_v_popup_query};
                          __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6310, __pyx_L27_error)
                          __Pyx_GOTREF(__pyx_t_4);
                        }
                        __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        if (likely(__pyx_t_9 == PYGEN_NEXT)) {
                          __Pyx_GOTREF(__pyx_r);
                          __Pyx_XGIVEREF(__pyx_t_1);
                          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                          __Pyx_XGIVEREF(__pyx_t_2);
                          __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                          __Pyx_XGIVEREF(__pyx_t_3);
                          __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                          __Pyx_XGIVEREF(__pyx_t_10);
                          __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                          __Pyx_XGIVEREF(__pyx_t_11);
                          __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
                          __Pyx_XGIVEREF(__pyx_t_12);
                          __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                          __Pyx_XGIVEREF(__pyx_t_13);
                          __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                          __Pyx_XGIVEREF(__pyx_t_14);
                          __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                          __Pyx_XGIVEREF(__pyx_t_15);
                          __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                          __Pyx_XGIVEREF(__pyx_t_16);
                          __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                          __Pyx_XGIVEREF(__pyx_t_17);
                          __pyx_cur_scope->__pyx_t_10 = __pyx_t_17;
                          __Pyx_XGIVEREF(__pyx_r);
                          __Pyx_RefNannyFinishContext();
                          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                          /* return from generator, awaiting value */
                          __pyx_generator->resume_label = 4;
                          return __pyx_r;
                          __pyx_L34_resume_from_await:;
                          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                          __pyx_cur_scope->__pyx_t_0 = 0;
                          __Pyx_XGOTREF(__pyx_t_1);
                          __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                          __pyx_cur_scope->__pyx_t_1 = 0;
                          __Pyx_XGOTREF(__pyx_t_2);
                          __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                          __pyx_cur_scope->__pyx_t_2 = 0;
                          __Pyx_XGOTREF(__pyx_t_3);
                          __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                          __pyx_cur_scope->__pyx_t_3 = 0;
                          __Pyx_XGOTREF(__pyx_t_10);
                          __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
                          __pyx_cur_scope->__pyx_t_4 = 0;
                          __Pyx_XGOTREF(__pyx_t_11);
                          __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                          __pyx_cur_scope->__pyx_t_5 = 0;
                          __Pyx_XGOTREF(__pyx_t_12);
                          __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                          __pyx_cur_scope->__pyx_t_6 = 0;
                          __Pyx_XGOTREF(__pyx_t_13);
                          __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                          __pyx_cur_scope->__pyx_t_7 = 0;
                          __Pyx_XGOTREF(__pyx_t_14);
                          __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                          __pyx_cur_scope->__pyx_t_8 = 0;
                          __Pyx_XGOTREF(__pyx_t_15);
                          __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                          __pyx_cur_scope->__pyx_t_9 = 0;
                          __Pyx_XGOTREF(__pyx_t_16);
                          __pyx_t_17 = __pyx_cur_scope->__pyx_t_10;
                          __pyx_cur_scope->__pyx_t_10 = 0;
                          __Pyx_XGOTREF(__pyx_t_17);
                          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6310, __pyx_L27_error)
                          __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                        } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
                          __Pyx_GOTREF(__pyx_r);
                          __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                        } else {
                          __Pyx_XGOTREF(__pyx_r);
                          __PYX_ERR(0, 6310, __pyx_L27_error)
                        }
                        __Pyx_GIVEREF(__pyx_t_4);
                        __pyx_cur_scope->__pyx_v_popup_result = __pyx_t_4;
                        __pyx_t_4 = 0;

                        /* "ws_package/controllers/activity_controller.py":6311
 *                         )
 *                         popup_result = await session.execute(popup_query)
 *                         for interval in popup_result.scalars().all():             # <<<<<<<<<<<<<<
 *                             interval_ids.add(interval.id)
 *                         logger.info(
*/
                        __pyx_t_6 = __pyx_cur_scope->__pyx_v_popup_result;
                        __Pyx_INCREF(__pyx_t_6);
                        __pyx_t_8 = 0;
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
                          __pyx_t_19 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalars, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                          if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6311, __pyx_L27_error)
                          __Pyx_GOTREF(__pyx_t_19);
                        }
                        __pyx_t_7 = __pyx_t_19;
                        __Pyx_INCREF(__pyx_t_7);
                        __pyx_t_8 = 0;
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
                          __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_all, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6311, __pyx_L27_error)
                          __Pyx_GOTREF(__pyx_t_4);
                        }
                        if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
                          __pyx_t_19 = __pyx_t_4; __Pyx_INCREF(__pyx_t_19);
                          __pyx_t_26 = 0;
                          __pyx_t_27 = NULL;
                        } else {
                          __pyx_t_26 = -1; __pyx_t_19 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6311, __pyx_L27_error)
                          __Pyx_GOTREF(__pyx_t_19);
                          __pyx_t_27 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_19); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 6311, __pyx_L27_error)
                        }
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        for (;;) {
                          if (likely(!__pyx_t_27)) {
                            if (likely(PyList_CheckExact(__pyx_t_19))) {
                              {
                                Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_19);
                                #if !CYTHON_ASSUME_SAFE_SIZE
                                if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6311, __pyx_L27_error)
                                #endif
                                if (__pyx_t_26 >= __pyx_temp) break;
                              }
                              __pyx_t_4 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_19, __pyx_t_26, __Pyx_ReferenceSharing_OwnStrongReference);
                              ++__pyx_t_26;
                            } else {
                              {
                                Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_19);
                                #if !CYTHON_ASSUME_SAFE_SIZE
                                if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6311, __pyx_L27_error)
                                #endif
                                if (__pyx_t_26 >= __pyx_temp) break;
                              }
                              #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                              __pyx_t_4 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_19, __pyx_t_26));
                              #else
                              __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_19, __pyx_t_26);
                              #endif
                              ++__pyx_t_26;
                            }
                            if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6311, __pyx_L27_error)
                          } else {
                            __pyx_t_4 = __pyx_t_27(__pyx_t_19);
                            if (unlikely(!__pyx_t_4)) {
                              PyObject* exc_type = PyErr_Occurred();
                              if (exc_type) {
                                if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 6311, __pyx_L27_error)
                                PyErr_Clear();
                              }
                              break;
                            }
                          }
                          __Pyx_GOTREF(__pyx_t_4);
                          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
                          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_4);
                          __Pyx_GIVEREF(__pyx_t_4);
                          __pyx_t_4 = 0;

                          /* "ws_package/controllers/activity_controller.py":6312
 *                         popup_result = await session.execute(popup_query)
 *                         for interval in popup_result.scalars().all():
 *                             interval_ids.add(interval.id)             # <<<<<<<<<<<<<<
 *                         logger.info(
 *                             "[IdleUnkeep] Popup-period scan (from %s): %s unsent interval(s)",
*/
                          __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6312, __pyx_L27_error)
                          __Pyx_GOTREF(__pyx_t_4);
                          __pyx_t_28 = PySet_Add(__pyx_cur_scope->__pyx_v_interval_ids, __pyx_t_4); if (unlikely(__pyx_t_28 == ((int)-1))) __PYX_ERR(0, 6312, __pyx_L27_error)
                          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                          /* "ws_package/controllers/activity_controller.py":6311
 *                         )
 *                         popup_result = await session.execute(popup_query)
 *                         for interval in popup_result.scalars().all():             # <<<<<<<<<<<<<<
 *                             interval_ids.add(interval.id)
 *                         logger.info(
*/
                        }
                        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;

                        /* "ws_package/controllers/activity_controller.py":6313
 *                         for interval in popup_result.scalars().all():
 *                             interval_ids.add(interval.id)
 *                         logger.info(             # <<<<<<<<<<<<<<
 *                             "[IdleUnkeep] Popup-period scan (from %s): %s unsent interval(s)",
 *                             popup_triggered_at,
*/
                        __pyx_t_4 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6313, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_7);
                        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6313, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_6);
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

                        /* "ws_package/controllers/activity_controller.py":6316
 *                             "[IdleUnkeep] Popup-period scan (from %s): %s unsent interval(s)",
 *                             popup_triggered_at,
 *                             len(interval_ids),             # <<<<<<<<<<<<<<
 *                         )
 * 
*/
                        __pyx_t_26 = __Pyx_PySet_GET_SIZE(__pyx_cur_scope->__pyx_v_interval_ids); if (unlikely(__pyx_t_26 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6316, __pyx_L27_error)
                        __pyx_t_7 = PyLong_FromSsize_t(__pyx_t_26); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6316, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_7);
                        __pyx_t_8 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_6))) {
                          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
                          assert(__pyx_t_4);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                          __Pyx_INCREF(__pyx_t_4);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                          __pyx_t_8 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[4] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_IdleUnkeep_Popup_period_scan_fr, __pyx_cur_scope->__pyx_v_popup_triggered_at, __pyx_t_7};
                          __pyx_t_19 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                          if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6313, __pyx_L27_error)
                          __Pyx_GOTREF(__pyx_t_19);
                        }
                        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;

                        /* "ws_package/controllers/activity_controller.py":6301
 *                 async with async_session() as session:
 *                     # 1) Entire idle-popup window (10/5/15 min rows + any with activity during popup)
 *                     if popup_triggered_at is not None:             # <<<<<<<<<<<<<<
 *                         popup_query = select(ActivityInterval).where(
 *                             and_(
*/
                      }

                      /* "ws_package/controllers/activity_controller.py":6320
 * 
 *                     # 2) is_idle=True (may overlap popup scan)
 *                     idle_flag_query = select(ActivityInterval).where(             # <<<<<<<<<<<<<<
 *                         ActivityInterval.counter == current_counter,
 *                         ActivityInterval.is_break == 0,
*/
                      __pyx_t_4 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6320, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_5);
                      __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 6320, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_24);
                      __pyx_t_8 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_5))) {
                        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
                        assert(__pyx_t_4);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                        __Pyx_INCREF(__pyx_t_4);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                        __pyx_t_8 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_24};
                        __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6320, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_7);
                      }
                      __pyx_t_6 = __pyx_t_7;
                      __Pyx_INCREF(__pyx_t_6);

                      /* "ws_package/controllers/activity_controller.py":6321
 *                     # 2) is_idle=True (may overlap popup scan)
 *                     idle_flag_query = select(ActivityInterval).where(
 *                         ActivityInterval.counter == current_counter,             # <<<<<<<<<<<<<<
 *                         ActivityInterval.is_break == 0,
 *                         ActivityInterval.is_idle == True,
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6321, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_5);
                      __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 6321, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_24);
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __pyx_t_5 = PyObject_RichCompare(__pyx_t_24, __pyx_cur_scope->__pyx_v_current_counter, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6321, __pyx_L27_error)
                      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;

                      /* "ws_package/controllers/activity_controller.py":6322
 *                     idle_flag_query = select(ActivityInterval).where(
 *                         ActivityInterval.counter == current_counter,
 *                         ActivityInterval.is_break == 0,             # <<<<<<<<<<<<<<
 *                         ActivityInterval.is_idle == True,
 *                         ActivityInterval.is_uploaded == False,
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 6322, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_24);
                      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_is_break); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6322, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                      __pyx_t_24 = __Pyx_PyLong_EqObjC(__pyx_t_4, __pyx_mstate_global->__pyx_int_0, 0, 0); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 6322, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_24);
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                      /* "ws_package/controllers/activity_controller.py":6323
 *                         ActivityInterval.counter == current_counter,
 *                         ActivityInterval.is_break == 0,
 *                         ActivityInterval.is_idle == True,             # <<<<<<<<<<<<<<
 *                         ActivityInterval.is_uploaded == False,
 *                     )
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6323, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_is_idle); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6323, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_23);
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __pyx_t_4 = PyObject_RichCompare(__pyx_t_23, Py_True, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6323, __pyx_L27_error)
                      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

                      /* "ws_package/controllers/activity_controller.py":6324
 *                         ActivityInterval.is_break == 0,
 *                         ActivityInterval.is_idle == True,
 *                         ActivityInterval.is_uploaded == False,             # <<<<<<<<<<<<<<
 *                     )
 *                     idle_flag_result = await session.execute(idle_flag_query)
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6324, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_23);
                      __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_is_uploaded); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6324, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                      __pyx_t_23 = PyObject_RichCompare(__pyx_t_22, Py_False, Py_EQ); __Pyx_XGOTREF(__pyx_t_23); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6324, __pyx_L27_error)
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[5] = {__pyx_t_6, __pyx_t_5, __pyx_t_24, __pyx_t_4, __pyx_t_23};
                        __pyx_t_19 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                        if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6320, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_19);
                      }
                      __Pyx_GIVEREF(__pyx_t_19);
                      __pyx_cur_scope->__pyx_v_idle_flag_query = __pyx_t_19;
                      __pyx_t_19 = 0;

                      /* "ws_package/controllers/activity_controller.py":6326
 *                         ActivityInterval.is_uploaded == False,
 *                     )
 *                     idle_flag_result = await session.execute(idle_flag_query)             # <<<<<<<<<<<<<<
 *                     for interval in idle_flag_result.scalars().all():
 *                         interval_ids.add(interval.id)
*/
                      __pyx_t_7 = __pyx_cur_scope->__pyx_v_session;
                      __Pyx_INCREF(__pyx_t_7);
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_cur_scope->__pyx_v_idle_flag_query};
                        __pyx_t_19 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                        if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6326, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_19);
                      }
                      __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_19, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                      if (likely(__pyx_t_9 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 5;
                        return __pyx_r;
                        __pyx_L38_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6326, __pyx_L27_error)
                        __pyx_t_19 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_19);
                      } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_19 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 6326, __pyx_L27_error)
                      }
                      __Pyx_GIVEREF(__pyx_t_19);
                      __pyx_cur_scope->__pyx_v_idle_flag_result = __pyx_t_19;
                      __pyx_t_19 = 0;

                      /* "ws_package/controllers/activity_controller.py":6327
 *                     )
 *                     idle_flag_result = await session.execute(idle_flag_query)
 *                     for interval in idle_flag_result.scalars().all():             # <<<<<<<<<<<<<<
 *                         interval_ids.add(interval.id)
 * 
*/
                      __pyx_t_4 = __pyx_cur_scope->__pyx_v_idle_flag_result;
                      __Pyx_INCREF(__pyx_t_4);
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
                        __pyx_t_23 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalars, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                        if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6327, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_23);
                      }
                      __pyx_t_7 = __pyx_t_23;
                      __Pyx_INCREF(__pyx_t_7);
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
                        __pyx_t_19 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_all, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6327, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_19);
                      }
                      if (likely(PyList_CheckExact(__pyx_t_19)) || PyTuple_CheckExact(__pyx_t_19)) {
                        __pyx_t_23 = __pyx_t_19; __Pyx_INCREF(__pyx_t_23);
                        __pyx_t_26 = 0;
                        __pyx_t_27 = NULL;
                      } else {
                        __pyx_t_26 = -1; __pyx_t_23 = PyObject_GetIter(__pyx_t_19); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6327, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_23);
                        __pyx_t_27 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_23); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 6327, __pyx_L27_error)
                      }
                      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                      for (;;) {
                        if (likely(!__pyx_t_27)) {
                          if (likely(PyList_CheckExact(__pyx_t_23))) {
                            {
                              Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_23);
                              #if !CYTHON_ASSUME_SAFE_SIZE
                              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6327, __pyx_L27_error)
                              #endif
                              if (__pyx_t_26 >= __pyx_temp) break;
                            }
                            __pyx_t_19 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_23, __pyx_t_26, __Pyx_ReferenceSharing_OwnStrongReference);
                            ++__pyx_t_26;
                          } else {
                            {
                              Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_23);
                              #if !CYTHON_ASSUME_SAFE_SIZE
                              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6327, __pyx_L27_error)
                              #endif
                              if (__pyx_t_26 >= __pyx_temp) break;
                            }
                            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                            __pyx_t_19 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_23, __pyx_t_26));
                            #else
                            __pyx_t_19 = __Pyx_PySequence_ITEM(__pyx_t_23, __pyx_t_26);
                            #endif
                            ++__pyx_t_26;
                          }
                          if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6327, __pyx_L27_error)
                        } else {
                          __pyx_t_19 = __pyx_t_27(__pyx_t_23);
                          if (unlikely(!__pyx_t_19)) {
                            PyObject* exc_type = PyErr_Occurred();
                            if (exc_type) {
                              if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 6327, __pyx_L27_error)
                              PyErr_Clear();
                            }
                            break;
                          }
                        }
                        __Pyx_GOTREF(__pyx_t_19);
                        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
                        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_19);
                        __Pyx_GIVEREF(__pyx_t_19);
                        __pyx_t_19 = 0;

                        /* "ws_package/controllers/activity_controller.py":6328
 *                     idle_flag_result = await session.execute(idle_flag_query)
 *                     for interval in idle_flag_result.scalars().all():
 *                         interval_ids.add(interval.id)             # <<<<<<<<<<<<<<
 * 
 *                     # 3) Consecutive zero-activity from newest (intervals not yet flagged is_idle)
*/
                        __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6328, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_19);
                        __pyx_t_28 = PySet_Add(__pyx_cur_scope->__pyx_v_interval_ids, __pyx_t_19); if (unlikely(__pyx_t_28 == ((int)-1))) __PYX_ERR(0, 6328, __pyx_L27_error)
                        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;

                        /* "ws_package/controllers/activity_controller.py":6327
 *                     )
 *                     idle_flag_result = await session.execute(idle_flag_query)
 *                     for interval in idle_flag_result.scalars().all():             # <<<<<<<<<<<<<<
 *                         interval_ids.add(interval.id)
 * 
*/
                      }
                      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

                      /* "ws_package/controllers/activity_controller.py":6331
 * 
 *                     # 3) Consecutive zero-activity from newest (intervals not yet flagged is_idle)
 *                     all_query = select(ActivityInterval).where(             # <<<<<<<<<<<<<<
 *                         ActivityInterval.counter == current_counter,
 *                         ActivityInterval.is_break == 0,
*/
                      __pyx_t_5 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6331, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_6);
                      __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6331, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __pyx_t_8 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_6))) {
                        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
                        assert(__pyx_t_5);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                        __Pyx_INCREF(__pyx_t_5);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                        __pyx_t_8 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_22};
                        __pyx_t_24 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                        if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 6331, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_24);
                      }
                      __pyx_t_4 = __pyx_t_24;
                      __Pyx_INCREF(__pyx_t_4);

                      /* "ws_package/controllers/activity_controller.py":6332
 *                     # 3) Consecutive zero-activity from newest (intervals not yet flagged is_idle)
 *                     all_query = select(ActivityInterval).where(
 *                         ActivityInterval.counter == current_counter,             # <<<<<<<<<<<<<<
 *                         ActivityInterval.is_break == 0,
 *                         ActivityInterval.is_uploaded == False,
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6332, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_6);
                      __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6332, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                      __pyx_t_6 = PyObject_RichCompare(__pyx_t_22, __pyx_cur_scope->__pyx_v_current_counter, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6332, __pyx_L27_error)
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;

                      /* "ws_package/controllers/activity_controller.py":6333
 *                     all_query = select(ActivityInterval).where(
 *                         ActivityInterval.counter == current_counter,
 *                         ActivityInterval.is_break == 0,             # <<<<<<<<<<<<<<
 *                         ActivityInterval.is_uploaded == False,
 *                     ).order_by(desc(ActivityInterval.start_time))
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6333, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_is_break); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6333, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_5);
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                      __pyx_t_22 = __Pyx_PyLong_EqObjC(__pyx_t_5, __pyx_mstate_global->__pyx_int_0, 0, 0); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6333, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                      /* "ws_package/controllers/activity_controller.py":6334
 *                         ActivityInterval.counter == current_counter,
 *                         ActivityInterval.is_break == 0,
 *                         ActivityInterval.is_uploaded == False,             # <<<<<<<<<<<<<<
 *                     ).order_by(desc(ActivityInterval.start_time))
 *                     all_result = await session.execute(all_query)
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6334, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_5);
                      __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_is_uploaded); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6334, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __pyx_t_5 = PyObject_RichCompare(__pyx_t_21, Py_False, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6334, __pyx_L27_error)
                      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[4] = {__pyx_t_4, __pyx_t_6, __pyx_t_22, __pyx_t_5};
                        __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6331, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_7);
                      }
                      __pyx_t_19 = __pyx_t_7;
                      __Pyx_INCREF(__pyx_t_19);

                      /* "ws_package/controllers/activity_controller.py":6335
 *                         ActivityInterval.is_break == 0,
 *                         ActivityInterval.is_uploaded == False,
 *                     ).order_by(desc(ActivityInterval.start_time))             # <<<<<<<<<<<<<<
 *                     all_result = await session.execute(all_query)
 *                     for interval in all_result.scalars().all():
*/
                      __pyx_t_5 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_desc); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6335, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6335, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_6);
                      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6335, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                      __pyx_t_8 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_22))) {
                        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_22);
                        assert(__pyx_t_5);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_22);
                        __Pyx_INCREF(__pyx_t_5);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_22, __pyx__function);
                        __pyx_t_8 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_5, __pyx_t_4};
                        __pyx_t_24 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_22, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 6335, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_24);
                      }
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_19, __pyx_t_24};
                        __pyx_t_23 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_order_by, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                        if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6335, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_23);
                      }
                      __Pyx_GIVEREF(__pyx_t_23);
                      __pyx_cur_scope->__pyx_v_all_query = __pyx_t_23;
                      __pyx_t_23 = 0;

                      /* "ws_package/controllers/activity_controller.py":6336
 *                         ActivityInterval.is_uploaded == False,
 *                     ).order_by(desc(ActivityInterval.start_time))
 *                     all_result = await session.execute(all_query)             # <<<<<<<<<<<<<<
 *                     for interval in all_result.scalars().all():
 *                         if interval.id in interval_ids:
*/
                      __pyx_t_7 = __pyx_cur_scope->__pyx_v_session;
                      __Pyx_INCREF(__pyx_t_7);
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_cur_scope->__pyx_v_all_query};
                        __pyx_t_23 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                        if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6336, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_23);
                      }
                      __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_23, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                      if (likely(__pyx_t_9 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 6;
                        return __pyx_r;
                        __pyx_L42_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6336, __pyx_L27_error)
                        __pyx_t_23 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_23);
                      } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_23 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 6336, __pyx_L27_error)
                      }
                      __Pyx_GIVEREF(__pyx_t_23);
                      __pyx_cur_scope->__pyx_v_all_result = __pyx_t_23;
                      __pyx_t_23 = 0;

                      /* "ws_package/controllers/activity_controller.py":6337
 *                     ).order_by(desc(ActivityInterval.start_time))
 *                     all_result = await session.execute(all_query)
 *                     for interval in all_result.scalars().all():             # <<<<<<<<<<<<<<
 *                         if interval.id in interval_ids:
 *                             continue
*/
                      __pyx_t_19 = __pyx_cur_scope->__pyx_v_all_result;
                      __Pyx_INCREF(__pyx_t_19);
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_19, NULL};
                        __pyx_t_24 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalars, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                        if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 6337, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_24);
                      }
                      __pyx_t_7 = __pyx_t_24;
                      __Pyx_INCREF(__pyx_t_7);
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
                        __pyx_t_23 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_all, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                        if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6337, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_23);
                      }
                      if (likely(PyList_CheckExact(__pyx_t_23)) || PyTuple_CheckExact(__pyx_t_23)) {
                        __pyx_t_24 = __pyx_t_23; __Pyx_INCREF(__pyx_t_24);
                        __pyx_t_26 = 0;
                        __pyx_t_27 = NULL;
                      } else {
                        __pyx_t_26 = -1; __pyx_t_24 = PyObject_GetIter(__pyx_t_23); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 6337, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_24);
                        __pyx_t_27 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_24); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 6337, __pyx_L27_error)
                      }
                      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                      for (;;) {
                        if (likely(!__pyx_t_27)) {
                          if (likely(PyList_CheckExact(__pyx_t_24))) {
                            {
                              Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_24);
                              #if !CYTHON_ASSUME_SAFE_SIZE
                              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6337, __pyx_L27_error)
                              #endif
                              if (__pyx_t_26 >= __pyx_temp) break;
                            }
                            __pyx_t_23 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_24, __pyx_t_26, __Pyx_ReferenceSharing_OwnStrongReference);
                            ++__pyx_t_26;
                          } else {
                            {
                              Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_24);
                              #if !CYTHON_ASSUME_SAFE_SIZE
                              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6337, __pyx_L27_error)
                              #endif
                              if (__pyx_t_26 >= __pyx_temp) break;
                            }
                            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                            __pyx_t_23 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_24, __pyx_t_26));
                            #else
                            __pyx_t_23 = __Pyx_PySequence_ITEM(__pyx_t_24, __pyx_t_26);
                            #endif
                            ++__pyx_t_26;
                          }
                          if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6337, __pyx_L27_error)
                        } else {
                          __pyx_t_23 = __pyx_t_27(__pyx_t_24);
                          if (unlikely(!__pyx_t_23)) {
                            PyObject* exc_type = PyErr_Occurred();
                            if (exc_type) {
                              if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 6337, __pyx_L27_error)
                              PyErr_Clear();
                            }
                            break;
                          }
                        }
                        __Pyx_GOTREF(__pyx_t_23);
                        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
                        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_23);
                        __Pyx_GIVEREF(__pyx_t_23);
                        __pyx_t_23 = 0;

                        /* "ws_package/controllers/activity_controller.py":6338
 *                     all_result = await session.execute(all_query)
 *                     for interval in all_result.scalars().all():
 *                         if interval.id in interval_ids:             # <<<<<<<<<<<<<<
 *                             continue
 *                         if self._last_idle_resolution_time and interval.end_time <= self._last_idle_resolution_time:
*/
                        __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6338, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_23);
                        __pyx_t_18 = (__Pyx_PySet_ContainsTF(__pyx_t_23, __pyx_cur_scope->__pyx_v_interval_ids, Py_EQ)); if (unlikely((__pyx_t_18 < 0))) __PYX_ERR(0, 6338, __pyx_L27_error)
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        if (__pyx_t_18) {

                          /* "ws_package/controllers/activity_controller.py":6339
 *                     for interval in all_result.scalars().all():
 *                         if interval.id in interval_ids:
 *                             continue             # <<<<<<<<<<<<<<
 *                         if self._last_idle_resolution_time and interval.end_time <= self._last_idle_resolution_time:
 *                             continue
*/
                          goto __pyx_L43_continue;

                          /* "ws_package/controllers/activity_controller.py":6338
 *                     all_result = await session.execute(all_query)
 *                     for interval in all_result.scalars().all():
 *                         if interval.id in interval_ids:             # <<<<<<<<<<<<<<
 *                             continue
 *                         if self._last_idle_resolution_time and interval.end_time <= self._last_idle_resolution_time:
*/
                        }

                        /* "ws_package/controllers/activity_controller.py":6340
 *                         if interval.id in interval_ids:
 *                             continue
 *                         if self._last_idle_resolution_time and interval.end_time <= self._last_idle_resolution_time:             # <<<<<<<<<<<<<<
 *                             continue
 *                         has_zero = await self._has_zero_activity_for_interval(
*/
                        __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_idle_resolution_time); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6340, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_23);
                        __pyx_t_29 = __Pyx_PyObject_IsTrue(__pyx_t_23); if (unlikely((__pyx_t_29 < 0))) __PYX_ERR(0, 6340, __pyx_L27_error)
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        if (__pyx_t_29) {
                        } else {
                          __pyx_t_18 = __pyx_t_29;
                          goto __pyx_L47_bool_binop_done;
                        }
                        __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6340, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_23);
                        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_idle_resolution_time); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6340, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_7);
                        __pyx_t_19 = PyObject_RichCompare(__pyx_t_23, __pyx_t_7, Py_LE); __Pyx_XGOTREF(__pyx_t_19); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6340, __pyx_L27_error)
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                        __pyx_t_29 = __Pyx_PyObject_IsTrue(__pyx_t_19); if (unlikely((__pyx_t_29 < 0))) __PYX_ERR(0, 6340, __pyx_L27_error)
                        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                        __pyx_t_18 = __pyx_t_29;
                        __pyx_L47_bool_binop_done:;
                        if (__pyx_t_18) {

                          /* "ws_package/controllers/activity_controller.py":6341
 *                             continue
 *                         if self._last_idle_resolution_time and interval.end_time <= self._last_idle_resolution_time:
 *                             continue             # <<<<<<<<<<<<<<
 *                         has_zero = await self._has_zero_activity_for_interval(
 *                             interval.start_time, interval.end_time
*/
                          goto __pyx_L43_continue;

                          /* "ws_package/controllers/activity_controller.py":6340
 *                         if interval.id in interval_ids:
 *                             continue
 *                         if self._last_idle_resolution_time and interval.end_time <= self._last_idle_resolution_time:             # <<<<<<<<<<<<<<
 *                             continue
 *                         has_zero = await self._has_zero_activity_for_interval(
*/
                        }

                        /* "ws_package/controllers/activity_controller.py":6342
 *                         if self._last_idle_resolution_time and interval.end_time <= self._last_idle_resolution_time:
 *                             continue
 *                         has_zero = await self._has_zero_activity_for_interval(             # <<<<<<<<<<<<<<
 *                             interval.start_time, interval.end_time
 *                         )
*/
                        __pyx_t_7 = __pyx_cur_scope->__pyx_v_self;
                        __Pyx_INCREF(__pyx_t_7);

                        /* "ws_package/controllers/activity_controller.py":6343
 *                             continue
 *                         has_zero = await self._has_zero_activity_for_interval(
 *                             interval.start_time, interval.end_time             # <<<<<<<<<<<<<<
 *                         )
 *                         if has_zero:
*/
                        __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6343, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_23);
                        __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6343, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_22);
                        __pyx_t_8 = 0;
                        {
                          PyObject *__pyx_callargs[3] = {__pyx_t_7, __pyx_t_23, __pyx_t_22};
                          __pyx_t_19 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_has_zero_activity_for_interval, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                          __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                          __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                          if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6342, __pyx_L27_error)
                          __Pyx_GOTREF(__pyx_t_19);
                        }
                        __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_19, &__pyx_r);
                        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                        if (likely(__pyx_t_9 == PYGEN_NEXT)) {
                          __Pyx_GOTREF(__pyx_r);
                          __Pyx_XGIVEREF(__pyx_t_1);
                          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                          __Pyx_XGIVEREF(__pyx_t_2);
                          __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                          __Pyx_XGIVEREF(__pyx_t_3);
                          __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                          __Pyx_XGIVEREF(__pyx_t_10);
                          __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                          __Pyx_XGIVEREF(__pyx_t_11);
                          __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
                          __Pyx_XGIVEREF(__pyx_t_12);
                          __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                          __Pyx_XGIVEREF(__pyx_t_13);
                          __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                          __Pyx_XGIVEREF(__pyx_t_14);
                          __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                          __Pyx_XGIVEREF(__pyx_t_15);
                          __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                          __Pyx_XGIVEREF(__pyx_t_16);
                          __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                          __Pyx_XGIVEREF(__pyx_t_17);
                          __pyx_cur_scope->__pyx_t_10 = __pyx_t_17;
                          __Pyx_XGIVEREF(__pyx_t_24);
                          __pyx_cur_scope->__pyx_t_11 = __pyx_t_24;
                          __pyx_cur_scope->__pyx_t_12 = __pyx_t_26;
                          __pyx_cur_scope->__pyx_t_13 = __pyx_t_27;
                          __Pyx_XGIVEREF(__pyx_r);
                          __Pyx_RefNannyFinishContext();
                          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                          /* return from generator, awaiting value */
                          __pyx_generator->resume_label = 7;
                          return __pyx_r;
                          __pyx_L49_resume_from_await:;
                          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                          __pyx_cur_scope->__pyx_t_0 = 0;
                          __Pyx_XGOTREF(__pyx_t_1);
                          __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                          __pyx_cur_scope->__pyx_t_1 = 0;
                          __Pyx_XGOTREF(__pyx_t_2);
                          __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                          __pyx_cur_scope->__pyx_t_2 = 0;
                          __Pyx_XGOTREF(__pyx_t_3);
                          __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                          __pyx_cur_scope->__pyx_t_3 = 0;
                          __Pyx_XGOTREF(__pyx_t_10);
                          __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
                          __pyx_cur_scope->__pyx_t_4 = 0;
                          __Pyx_XGOTREF(__pyx_t_11);
                          __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                          __pyx_cur_scope->__pyx_t_5 = 0;
                          __Pyx_XGOTREF(__pyx_t_12);
                          __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                          __pyx_cur_scope->__pyx_t_6 = 0;
                          __Pyx_XGOTREF(__pyx_t_13);
                          __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                          __pyx_cur_scope->__pyx_t_7 = 0;
                          __Pyx_XGOTREF(__pyx_t_14);
                          __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                          __pyx_cur_scope->__pyx_t_8 = 0;
                          __Pyx_XGOTREF(__pyx_t_15);
                          __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                          __pyx_cur_scope->__pyx_t_9 = 0;
                          __Pyx_XGOTREF(__pyx_t_16);
                          __pyx_t_17 = __pyx_cur_scope->__pyx_t_10;
                          __pyx_cur_scope->__pyx_t_10 = 0;
                          __Pyx_XGOTREF(__pyx_t_17);
                          __pyx_t_24 = __pyx_cur_scope->__pyx_t_11;
                          __pyx_cur_scope->__pyx_t_11 = 0;
                          __Pyx_XGOTREF(__pyx_t_24);
                          __pyx_t_26 = __pyx_cur_scope->__pyx_t_12;
                          __pyx_t_27 = __pyx_cur_scope->__pyx_t_13;
                          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6342, __pyx_L27_error)
                          __pyx_t_19 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_19);
                        } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
                          __Pyx_GOTREF(__pyx_r);
                          __pyx_t_19 = __pyx_r; __pyx_r = NULL;
                        } else {
                          __Pyx_XGOTREF(__pyx_r);
                          __PYX_ERR(0, 6342, __pyx_L27_error)
                        }
                        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_has_zero);
                        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_has_zero, __pyx_t_19);
                        __Pyx_GIVEREF(__pyx_t_19);
                        __pyx_t_19 = 0;

                        /* "ws_package/controllers/activity_controller.py":6345
 *                             interval.start_time, interval.end_time
 *                         )
 *                         if has_zero:             # <<<<<<<<<<<<<<
 *                             interval_ids.add(interval.id)
 *                         else:
*/
                        __pyx_t_18 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_has_zero); if (unlikely((__pyx_t_18 < 0))) __PYX_ERR(0, 6345, __pyx_L27_error)
                        if (__pyx_t_18) {

                          /* "ws_package/controllers/activity_controller.py":6346
 *                         )
 *                         if has_zero:
 *                             interval_ids.add(interval.id)             # <<<<<<<<<<<<<<
 *                         else:
 *                             break
*/
                          __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6346, __pyx_L27_error)
                          __Pyx_GOTREF(__pyx_t_19);
                          __pyx_t_28 = PySet_Add(__pyx_cur_scope->__pyx_v_interval_ids, __pyx_t_19); if (unlikely(__pyx_t_28 == ((int)-1))) __PYX_ERR(0, 6346, __pyx_L27_error)
                          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;

                          /* "ws_package/controllers/activity_controller.py":6345
 *                             interval.start_time, interval.end_time
 *                         )
 *                         if has_zero:             # <<<<<<<<<<<<<<
 *                             interval_ids.add(interval.id)
 *                         else:
*/
                          goto __pyx_L50;
                        }

                        /* "ws_package/controllers/activity_controller.py":6348
 *                             interval_ids.add(interval.id)
 *                         else:
 *                             break             # <<<<<<<<<<<<<<
 * 
 *             if not interval_ids:
*/
                        /*else*/ {
                          goto __pyx_L44_break;
                        }
                        __pyx_L50:;

                        /* "ws_package/controllers/activity_controller.py":6337
 *                     ).order_by(desc(ActivityInterval.start_time))
 *                     all_result = await session.execute(all_query)
 *                     for interval in all_result.scalars().all():             # <<<<<<<<<<<<<<
 *                         if interval.id in interval_ids:
 *                             continue
*/
                        __pyx_L43_continue:;
                      }
                      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                      goto __pyx_L51_for_end;
                      __pyx_L44_break:;
                      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                      goto __pyx_L51_for_end;
                      __pyx_L51_for_end:;

                      /* "ws_package/controllers/activity_controller.py":6299
 * 
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     # 1) Entire idle-popup window (10/5/15 min rows + any with activity during popup)
 *                     if popup_triggered_at is not None:
*/
                    }
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                    goto __pyx_L32_try_end;
                    __pyx_L27_error:;
                    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                    __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                    /*except:*/ {
                      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._mark_idle_intervals_as_uploaded", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_24, &__pyx_t_19, &__pyx_t_22) < 0) __PYX_ERR(0, 6299, __pyx_L29_except_error)
                      __Pyx_XGOTREF(__pyx_t_24);
                      __Pyx_XGOTREF(__pyx_t_19);
                      __Pyx_XGOTREF(__pyx_t_22);
                      __pyx_t_23 = PyTuple_Pack(3, __pyx_t_24, __pyx_t_19, __pyx_t_22); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6299, __pyx_L29_except_error)
                      __Pyx_GOTREF(__pyx_t_23);
                      __pyx_t_30 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_23, NULL);
                      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                      if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 6299, __pyx_L29_except_error)
                      __Pyx_GOTREF(__pyx_t_30);
                      __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_30, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
                      if (likely(__pyx_t_9 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_19);
                        __pyx_cur_scope->__pyx_t_11 = __pyx_t_19;
                        __Pyx_XGIVEREF(__pyx_t_22);
                        __pyx_cur_scope->__pyx_t_14 = __pyx_t_22;
                        __Pyx_XGIVEREF(__pyx_t_24);
                        __pyx_cur_scope->__pyx_t_15 = __pyx_t_24;
                        __Pyx_XGIVEREF(__pyx_t_30);
                        __pyx_cur_scope->__pyx_t_16 = __pyx_t_30;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_SwapException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 8;
                        return __pyx_r;
                        __pyx_L55_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_19 = __pyx_cur_scope->__pyx_t_11;
                        __pyx_cur_scope->__pyx_t_11 = 0;
                        __Pyx_XGOTREF(__pyx_t_19);
                        __pyx_t_22 = __pyx_cur_scope->__pyx_t_14;
                        __pyx_cur_scope->__pyx_t_14 = 0;
                        __Pyx_XGOTREF(__pyx_t_22);
                        __pyx_t_24 = __pyx_cur_scope->__pyx_t_15;
                        __pyx_cur_scope->__pyx_t_15 = 0;
                        __Pyx_XGOTREF(__pyx_t_24);
                        __pyx_t_30 = __pyx_cur_scope->__pyx_t_16;
                        __pyx_cur_scope->__pyx_t_16 = 0;
                        __Pyx_XGOTREF(__pyx_t_30);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6299, __pyx_L29_except_error)
                        __pyx_t_23 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_23);
                      } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_23 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 6299, __pyx_L29_except_error)
                      }
                      __pyx_t_30 = __pyx_t_23;
                      __pyx_t_23 = 0;
                      __pyx_t_18 = __Pyx_PyObject_IsTrue(__pyx_t_30);
                      __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
                      if (__pyx_t_18 < (0)) __PYX_ERR(0, 6299, __pyx_L29_except_error)
                      __pyx_t_29 = (!__pyx_t_18);
                      if (unlikely(__pyx_t_29)) {
                        __Pyx_GIVEREF(__pyx_t_24);
                        __Pyx_GIVEREF(__pyx_t_19);
                        __Pyx_XGIVEREF(__pyx_t_22);
                        __Pyx_ErrRestoreWithState(__pyx_t_24, __pyx_t_19, __pyx_t_22);
                        __pyx_t_24 = 0;  __pyx_t_19 = 0;  __pyx_t_22 = 0; 
                        __PYX_ERR(0, 6299, __pyx_L29_except_error)
                      }
                      __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                      __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                      __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                      goto __pyx_L28_exception_handled;
                    }
                    __pyx_L29_except_error:;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
                    goto __pyx_L16_error;
                    __pyx_L28_exception_handled:;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
                    __pyx_L32_try_end:;
                  }
                }
                /*finally:*/ {
                  /*normal exit:*/{
                    if (__pyx_t_14) {
                      __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_mstate_global->__pyx_tuple[7], NULL);
                      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                      if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6299, __pyx_L16_error)
                      __Pyx_GOTREF(__pyx_t_17);
                      __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_17, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                      if (likely(__pyx_t_9 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 9;
                        return __pyx_r;
                        __pyx_L56_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6299, __pyx_L16_error)
                        __pyx_t_22 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_22);
                      } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_22 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 6299, __pyx_L16_error)
                      }
                      __pyx_t_17 = __pyx_t_22;
                      __pyx_t_22 = 0;
                      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                    }
                    goto __pyx_L26;
                  }
                  __pyx_L26:;
                }
                goto __pyx_L57;
                __pyx_L22_error:;
                __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                goto __pyx_L16_error;
                __pyx_L57:;
              }

              /* "ws_package/controllers/activity_controller.py":6298
 *             popup_triggered_at = self._idle_popup_triggered_at
 * 
 *             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     # 1) Entire idle-popup window (10/5/15 min rows + any with activity during popup)
*/
            }
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            goto __pyx_L21_try_end;
            __pyx_L16_error:;
            __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
            __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
            __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
            __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
            __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            /*except:*/ {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._mark_idle_intervals_as_uploaded", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_22, &__pyx_t_19, &__pyx_t_24) < 0) __PYX_ERR(0, 6298, __pyx_L18_except_error)
              __Pyx_XGOTREF(__pyx_t_22);
              __Pyx_XGOTREF(__pyx_t_19);
              __Pyx_XGOTREF(__pyx_t_24);
              __pyx_t_23 = PyTuple_Pack(3, __pyx_t_22, __pyx_t_19, __pyx_t_24); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6298, __pyx_L18_except_error)
              __Pyx_GOTREF(__pyx_t_23);
              __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_23, NULL);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
              if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 6298, __pyx_L18_except_error)
              __Pyx_GOTREF(__pyx_t_14);
              __pyx_t_29 = __Pyx_PyObject_IsTrue(__pyx_t_14);
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              if (__pyx_t_29 < (0)) __PYX_ERR(0, 6298, __pyx_L18_except_error)
              __pyx_t_18 = (!__pyx_t_29);
              if (unlikely(__pyx_t_18)) {
                __Pyx_GIVEREF(__pyx_t_22);
                __Pyx_GIVEREF(__pyx_t_19);
                __Pyx_XGIVEREF(__pyx_t_24);
                __Pyx_ErrRestoreWithState(__pyx_t_22, __pyx_t_19, __pyx_t_24);
                __pyx_t_22 = 0;  __pyx_t_19 = 0;  __pyx_t_24 = 0; 
                __PYX_ERR(0, 6298, __pyx_L18_except_error)
              }
              __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
              __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
              __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
              goto __pyx_L17_exception_handled;
            }
            __pyx_L18_except_error:;
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
            goto __pyx_L4_error;
            __pyx_L17_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
            __pyx_L21_try_end:;
          }
        }
        /*finally:*/ {
          /*normal exit:*/{
            if (__pyx_t_10) {
              __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_mstate_global->__pyx_tuple[7], NULL);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 6298, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_13);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            }
            goto __pyx_L15;
          }
          __pyx_L15:;
        }
        goto __pyx_L61;
        __pyx_L12_error:;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L4_error;
        __pyx_L61:;
      }

      /* "ws_package/controllers/activity_controller.py":6350
 *                             break
 * 
 *             if not interval_ids:             # <<<<<<<<<<<<<<
 *                 logger.warning(
 *                     "[IdleUnkeep] No intervals to mark as uploaded (counter=%s, popup_at=%s)",
*/
      {
        Py_ssize_t __pyx_temp = __Pyx_PySet_GET_SIZE(__pyx_cur_scope->__pyx_v_interval_ids);
        if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 6350, __pyx_L4_error)
        __pyx_t_18 = (__pyx_temp != 0);
      }

      __pyx_t_29 = (!__pyx_t_18);
      if (__pyx_t_29) {

        /* "ws_package/controllers/activity_controller.py":6351
 * 
 *             if not interval_ids:
 *                 logger.warning(             # <<<<<<<<<<<<<<
 *                     "[IdleUnkeep] No intervals to mark as uploaded (counter=%s, popup_at=%s)",
 *                     current_counter,
*/
        __pyx_t_19 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6351, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_22);
        __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6351, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_23);
        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;

        /* "ws_package/controllers/activity_controller.py":6354
 *                     "[IdleUnkeep] No intervals to mark as uploaded (counter=%s, popup_at=%s)",
 *                     current_counter,
 *                     popup_triggered_at,             # <<<<<<<<<<<<<<
 *                 )
 *                 return
*/
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_23))) {
          __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_23);
          assert(__pyx_t_19);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_23);
          __Pyx_INCREF(__pyx_t_19);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_23, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[4] = {__pyx_t_19, __pyx_mstate_global->__pyx_kp_u_IdleUnkeep_No_intervals_to_mark, __pyx_cur_scope->__pyx_v_current_counter, __pyx_cur_scope->__pyx_v_popup_triggered_at};
          __pyx_t_24 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_23, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
          __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
          if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 6351, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_24);
        }
        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;

        /* "ws_package/controllers/activity_controller.py":6356
 *                     popup_triggered_at,
 *                 )
 *                 return             # <<<<<<<<<<<<<<
 * 
 *             interval_id_list = sorted(interval_ids)
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
        goto __pyx_L8_try_return;

        /* "ws_package/controllers/activity_controller.py":6350
 *                             break
 * 
 *             if not interval_ids:             # <<<<<<<<<<<<<<
 *                 logger.warning(
 *                     "[IdleUnkeep] No intervals to mark as uploaded (counter=%s, popup_at=%s)",
*/
      }

      /* "ws_package/controllers/activity_controller.py":6358
 *                 return
 * 
 *             interval_id_list = sorted(interval_ids)             # <<<<<<<<<<<<<<
 *             logger.info(
 *                 "[IdleUnkeep] Marking %s interval(s) as is_uploaded=True: ids=%s%s",
*/
      __pyx_t_24 = PySequence_List(__pyx_cur_scope->__pyx_v_interval_ids); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 6358, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_24);
      if (unlikely((PyList_Sort(__pyx_t_24) < 0))) __PYX_ERR(0, 6358, __pyx_L4_error)
      __Pyx_GIVEREF(__pyx_t_24);
      __pyx_cur_scope->__pyx_v_interval_id_list = __pyx_t_24;
      __pyx_t_24 = 0;

      /* "ws_package/controllers/activity_controller.py":6359
 * 
 *             interval_id_list = sorted(interval_ids)
 *             logger.info(             # <<<<<<<<<<<<<<
 *                 "[IdleUnkeep] Marking %s interval(s) as is_uploaded=True: ids=%s%s",
 *                 len(interval_id_list),
*/
      __pyx_t_23 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6359, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_19);
      __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6359, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_22);
      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;

      /* "ws_package/controllers/activity_controller.py":6361
 *             logger.info(
 *                 "[IdleUnkeep] Marking %s interval(s) as is_uploaded=True: ids=%s%s",
 *                 len(interval_id_list),             # <<<<<<<<<<<<<<
 *                 interval_id_list[:15],
 *                 '...' if len(interval_id_list) > 15 else '',
*/
      __pyx_t_26 = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_interval_id_list); if (unlikely(__pyx_t_26 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6361, __pyx_L4_error)
      __pyx_t_19 = PyLong_FromSsize_t(__pyx_t_26); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6361, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_19);

      /* "ws_package/controllers/activity_controller.py":6362
 *                 "[IdleUnkeep] Marking %s interval(s) as is_uploaded=True: ids=%s%s",
 *                 len(interval_id_list),
 *                 interval_id_list[:15],             # <<<<<<<<<<<<<<
 *                 '...' if len(interval_id_list) > 15 else '',
 *             )
*/
      __pyx_t_7 = __Pyx_PyList_GetSlice(__pyx_cur_scope->__pyx_v_interval_id_list, 0, 15); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6362, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);

      /* "ws_package/controllers/activity_controller.py":6363
 *                 len(interval_id_list),
 *                 interval_id_list[:15],
 *                 '...' if len(interval_id_list) > 15 else '',             # <<<<<<<<<<<<<<
 *             )
 * 
*/
      __pyx_t_26 = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_interval_id_list); if (unlikely(__pyx_t_26 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6363, __pyx_L4_error)
      __pyx_t_29 = (__pyx_t_26 > 15);
      if (__pyx_t_29) {
        __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u__13);
        __pyx_t_4 = __pyx_mstate_global->__pyx_kp_u__13;
      } else {
        __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u__2);
        __pyx_t_4 = __pyx_mstate_global->__pyx_kp_u__2;
      }
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_22))) {
        __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_22);
        assert(__pyx_t_23);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_22);
        __Pyx_INCREF(__pyx_t_23);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_22, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[5] = {__pyx_t_23, __pyx_mstate_global->__pyx_kp_u_IdleUnkeep_Marking_s_interval_s, __pyx_t_19, __pyx_t_7, __pyx_t_4};
        __pyx_t_24 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_22, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
        if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 6359, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_24);
      }
      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;

      /* "ws_package/controllers/activity_controller.py":6366
 *             )
 * 
 *             updates = [{"id": iid, "is_uploaded": True} for iid in interval_id_list]             # <<<<<<<<<<<<<<
 *             db_write_queue.enqueue(
 *                 WriteOperationType.BULK_UPDATE,
*/
      { /* enter inner scope */
        __pyx_t_24 = PyList_New(0); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 6366, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_24);
        __pyx_t_22 = __pyx_cur_scope->__pyx_v_interval_id_list; __Pyx_INCREF(__pyx_t_22);
        __pyx_t_26 = 0;
        for (;;) {
          {
            Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_22);
            #if !CYTHON_ASSUME_SAFE_SIZE
            if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6366, __pyx_L4_error)
            #endif
            if (__pyx_t_26 >= __pyx_temp) break;
          }
          __pyx_t_4 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_22, __pyx_t_26, __Pyx_ReferenceSharing_OwnStrongReference);
          ++__pyx_t_26;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6366, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_9genexpr25__pyx_v_iid);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_9genexpr25__pyx_v_iid, __pyx_t_4);
          __Pyx_GIVEREF(__pyx_t_4);
          __pyx_t_4 = 0;
          __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6366, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
          if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_id, __pyx_cur_scope->__pyx_9genexpr25__pyx_v_iid) < (0)) __PYX_ERR(0, 6366, __pyx_L4_error)
          if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_is_uploaded, Py_True) < (0)) __PYX_ERR(0, 6366, __pyx_L4_error)
          if (unlikely(__Pyx_ListComp_Append(__pyx_t_24, (PyObject*)__pyx_t_4))) __PYX_ERR(0, 6366, __pyx_L4_error)
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        }
        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
      } /* exit inner scope */
      __Pyx_GIVEREF(__pyx_t_24);
      __pyx_cur_scope->__pyx_v_updates = ((PyObject*)__pyx_t_24);
      __pyx_t_24 = 0;

      /* "ws_package/controllers/activity_controller.py":6367
 * 
 *             updates = [{"id": iid, "is_uploaded": True} for iid in interval_id_list]
 *             db_write_queue.enqueue(             # <<<<<<<<<<<<<<
 *                 WriteOperationType.BULK_UPDATE,
 *                 "activity_interval",
*/
      __pyx_t_22 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_db_write_queue); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6367, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_enqueue); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6367, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":6368
 *             updates = [{"id": iid, "is_uploaded": True} for iid in interval_id_list]
 *             db_write_queue.enqueue(
 *                 WriteOperationType.BULK_UPDATE,             # <<<<<<<<<<<<<<
 *                 "activity_interval",
 *                 {"updates": updates},
*/
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_WriteOperationType); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6368, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_BULK_UPDATE); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6368, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_19);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":6370
 *                 WriteOperationType.BULK_UPDATE,
 *                 "activity_interval",
 *                 {"updates": updates},             # <<<<<<<<<<<<<<
 *             )
 * 
*/
      __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6370, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_updates, __pyx_cur_scope->__pyx_v_updates) < (0)) __PYX_ERR(0, 6370, __pyx_L4_error)
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_22 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_22);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_22);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[4] = {__pyx_t_22, __pyx_t_19, __pyx_mstate_global->__pyx_n_u_activity_interval, __pyx_t_4};
        __pyx_t_24 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 6367, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_24);
      }
      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;

      /* "ws_package/controllers/activity_controller.py":6373
 *             )
 * 
 *             await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 *             await asyncio.sleep(0.5)
 *             logger.info("[IdleUnkeep] Committed is_uploaded=True for %s interval(s)", len(updates))
*/
      __pyx_t_7 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6373, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6373, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_19);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_19))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_19);
        assert(__pyx_t_7);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_19);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_19, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
        __pyx_t_24 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_19, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
        if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 6373, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_24);
      }
      __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_24, &__pyx_r);
      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
      if (likely(__pyx_t_9 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
        __Pyx_XGIVEREF(__pyx_t_2);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
        __Pyx_XGIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 10;
        return __pyx_r;
        __pyx_L66_resume_from_await:;
        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_1);
        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_2);
        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_3);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6373, __pyx_L4_error)
      } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_DECREF(__pyx_r); __pyx_r = 0;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 6373, __pyx_L4_error)
      }

      /* "ws_package/controllers/activity_controller.py":6374
 * 
 *             await db_writer_service.process_immediately()
 *             await asyncio.sleep(0.5)             # <<<<<<<<<<<<<<
 *             logger.info("[IdleUnkeep] Committed is_uploaded=True for %s interval(s)", len(updates))
 * 
*/
      __pyx_t_19 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6374, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6374, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_4))) {
        __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_4);
        assert(__pyx_t_19);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
        __Pyx_INCREF(__pyx_t_19);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_19, __pyx_mstate_global->__pyx_float_0_5};
        __pyx_t_24 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 6374, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_24);
      }
      __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_24, &__pyx_r);
      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
      if (likely(__pyx_t_9 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
        __Pyx_XGIVEREF(__pyx_t_2);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
        __Pyx_XGIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 11;
        return __pyx_r;
        __pyx_L67_resume_from_await:;
        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_1);
        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_2);
        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_3);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6374, __pyx_L4_error)
      } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_DECREF(__pyx_r); __pyx_r = 0;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 6374, __pyx_L4_error)
      }

      /* "ws_package/controllers/activity_controller.py":6375
 *             await db_writer_service.process_immediately()
 *             await asyncio.sleep(0.5)
 *             logger.info("[IdleUnkeep] Committed is_uploaded=True for %s interval(s)", len(updates))             # <<<<<<<<<<<<<<
 * 
 *         except Exception as e:
*/
      __pyx_t_4 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6375, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_19);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6375, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
      __pyx_t_26 = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_updates); if (unlikely(__pyx_t_26 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6375, __pyx_L4_error)
      __pyx_t_19 = PyLong_FromSsize_t(__pyx_t_26); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6375, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_19);
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_4);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_IdleUnkeep_Committed_is_uploade, __pyx_t_19};
        __pyx_t_24 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 6375, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_24);
      }
      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;

      /* "ws_package/controllers/activity_controller.py":6290
 *         - Consecutive zero-activity streak from newest (fallback when flags lag)
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             await db_writer_service.process_immediately()
 *             await asyncio.sleep(0.5)
*/
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L9_try_end;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
    __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "ws_package/controllers/activity_controller.py":6377
 *             logger.info("[IdleUnkeep] Committed is_uploaded=True for %s interval(s)", len(updates))
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error marking idle intervals as uploaded: %s", e, exc_info=True)
 * 
*/
    __pyx_t_31 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_31) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._mark_idle_intervals_as_uploaded", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_24, &__pyx_t_7, &__pyx_t_19) < 0) __PYX_ERR(0, 6377, __pyx_L6_except_error)
      __Pyx_XGOTREF(__pyx_t_24);
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_19);
      __Pyx_INCREF(__pyx_t_7);
      __Pyx_GIVEREF(__pyx_t_7);
      __pyx_cur_scope->__pyx_v_e = __pyx_t_7;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":6378
 * 
 *         except Exception as e:
 *             logger.error("Error marking idle intervals as uploaded: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *     async def _upload_file_to_s3(self, local_file_path: str) -> Optional[str]:
*/
        __pyx_t_22 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6378, __pyx_L73_error)
        __Pyx_GOTREF(__pyx_t_23);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6378, __pyx_L73_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_22 = PyMethod_GET_SELF(__pyx_t_5);
          assert(__pyx_t_22);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_22);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_22, __pyx_mstate_global->__pyx_kp_u_Error_marking_idle_intervals_as, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_23 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6378, __pyx_L73_error)
          __Pyx_GOTREF(__pyx_t_23);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_23, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 6378, __pyx_L73_error)
          __pyx_t_4 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_23);
          __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
          __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6378, __pyx_L73_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      }

      /* "ws_package/controllers/activity_controller.py":6377
 *             logger.info("[IdleUnkeep] Committed is_uploaded=True for %s interval(s)", len(updates))
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error marking idle intervals as uploaded: %s", e, exc_info=True)
 * 
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          goto __pyx_L74;
        }
        __pyx_L73_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_10 = 0; __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_14 = 0; __pyx_t_17 = 0;
          __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
          __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
          __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_11, &__pyx_t_14, &__pyx_t_17);
          if ( unlikely(__Pyx_GetException(&__pyx_t_10, &__pyx_t_13, &__pyx_t_12) < 0)) __Pyx_ErrFetch(&__pyx_t_10, &__pyx_t_13, &__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_17);
          __pyx_t_31 = __pyx_lineno; __pyx_t_32 = __pyx_clineno; __pyx_t_33 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_14, __pyx_t_17);
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ErrRestore(__pyx_t_10, __pyx_t_13, __pyx_t_12);
          __pyx_t_10 = 0; __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_14 = 0; __pyx_t_17 = 0;
          __pyx_lineno = __pyx_t_31; __pyx_clineno = __pyx_t_32; __pyx_filename = __pyx_t_33;
          goto __pyx_L6_except_error;
        }
        __pyx_L74:;
      }
      __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
      __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
      goto __pyx_L5_exception_handled;
    }
    goto __pyx_L6_except_error;

    /* "ws_package/controllers/activity_controller.py":6290
 *         - Consecutive zero-activity streak from newest (fallback when flags lag)
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             await db_writer_service.process_immediately()
 *             await asyncio.sleep(0.5)
*/
    __pyx_L6_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L5_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    __pyx_L9_try_end:;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":6280
 *             logger.error("Error in sync_activity_immediately: %s", e, exc_info=True)
 * 
 *     async def _mark_idle_intervals_as_uploaded(self):             # <<<<<<<<<<<<<<
 *         """
 *         Mark idle intervals as is_uploaded=True so they are never sent to the server.
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_XDECREF(__pyx_t_23);
  __Pyx_XDECREF(__pyx_t_24);
  __Pyx_XDECREF(__pyx_t_25);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("_mark_idle_intervals_as_uploaded", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_214generator46(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":6380
 *             logger.error("Error marking idle intervals as uploaded: %s", e, exc_info=True)
 * 
 *     async def _upload_file_to_s3(self, local_file_path: str) -> Optional[str]:             # <<<<<<<<<<<<<<
 *         """
 *         Upload a file to S3 and return the S3 URL.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_213_upload_file_to_s3(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_212_upload_file_to_s3, "\n        Upload a file to S3 and return the S3 URL.\n        \n        Args:\n            local_file_path: Local file path to upload\n            \n        Returns:\n            S3 URL if successful, None otherwise\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_213_upload_file_to_s3 = {"_upload_file_to_s3", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_213_upload_file_to_s3, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_212_upload_file_to_s3};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_213_upload_file_to_s3(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_local_file_path = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_upload_file_to_s3 (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_local_file_path,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 6380, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 6380, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 6380, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_upload_file_to_s3", 0) < (0)) __PYX_ERR(0, 6380, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_upload_file_to_s3", 1, 2, 2, i); __PYX_ERR(0, 6380, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 6380, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 6380, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_local_file_path = ((PyObject*)values[1]);
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_upload_file_to_s3", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 6380, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._upload_file_to_s3", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_local_file_path), (&PyUnicode_Type), 0, "local_file_path", 2))) __PYX_ERR(0, 6380, __pyx_L1_error)
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_212_upload_file_to_s3(__pyx_self, __pyx_v_self, __pyx_v_local_file_path);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  goto __pyx_L7_cleaned_up;
  __pyx_L0:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __pyx_L7_cleaned_up:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_212_upload_file_to_s3(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_local_file_path) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3 *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_upload_file_to_s3", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3 *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3 *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 6380, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_local_file_path = __pyx_v_local_file_path;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_local_file_path);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_local_file_path);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_214generator46, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[72]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_upload_file_to_s3, __pyx_mstate_global->__pyx_n_u_ActivityController__upload_file, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 6380, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._upload_file_to_s3", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_214generator46(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3 *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3 *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  int __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  size_t __pyx_t_10;
  __Pyx_PySendResult __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14[8];
  int __pyx_t_15;
  PyObject *__pyx_t_16 = NULL;
  int __pyx_t_17;
  char const *__pyx_t_18;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_upload_file_to_s3", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L16_resume_from_await;
    case 2: goto __pyx_L19_resume_from_await;
    case 3: goto __pyx_L20_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 6380, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":6390
 *             S3 URL if successful, None otherwise
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # Get user_entity if not available
 *             user_entity = None
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":6392
 *         try:
 *             # Get user_entity if not available
 *             user_entity = None             # <<<<<<<<<<<<<<
 *             if hasattr(self, 'user_entity') and self.user_entity is not None:
 *                 user_entity = self.user_entity
*/
      __Pyx_INCREF(Py_None);
      __Pyx_GIVEREF(Py_None);
      __pyx_cur_scope->__pyx_v_user_entity = Py_None;

      /* "ws_package/controllers/activity_controller.py":6393
 *             # Get user_entity if not available
 *             user_entity = None
 *             if hasattr(self, 'user_entity') and self.user_entity is not None:             # <<<<<<<<<<<<<<
 *                 user_entity = self.user_entity
 * 
*/
      __pyx_t_5 = __Pyx_HasAttr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_user_entity); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 6393, __pyx_L4_error)
      if (__pyx_t_5) {
      } else {
        __pyx_t_4 = __pyx_t_5;
        goto __pyx_L11_bool_binop_done;
      }
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_user_entity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6393, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = (__pyx_t_6 != Py_None);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_4 = __pyx_t_5;
      __pyx_L11_bool_binop_done:;
      if (__pyx_t_4) {

        /* "ws_package/controllers/activity_controller.py":6394
 *             user_entity = None
 *             if hasattr(self, 'user_entity') and self.user_entity is not None:
 *                 user_entity = self.user_entity             # <<<<<<<<<<<<<<
 * 
 *             if user_entity is None:
*/
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_user_entity); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6394, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_user_entity);
        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_user_entity, __pyx_t_6);
        __Pyx_GIVEREF(__pyx_t_6);
        __pyx_t_6 = 0;

        /* "ws_package/controllers/activity_controller.py":6393
 *             # Get user_entity if not available
 *             user_entity = None
 *             if hasattr(self, 'user_entity') and self.user_entity is not None:             # <<<<<<<<<<<<<<
 *                 user_entity = self.user_entity
 * 
*/
      }

      /* "ws_package/controllers/activity_controller.py":6396
 *                 user_entity = self.user_entity
 * 
 *             if user_entity is None:             # <<<<<<<<<<<<<<
 *                 logger.error("Cannot upload file to S3: user_entity is not available and cannot be retrieved from database")
 *                 return None
*/
      __pyx_t_4 = (__pyx_cur_scope->__pyx_v_user_entity == Py_None);
      if (__pyx_t_4) {

        /* "ws_package/controllers/activity_controller.py":6397
 * 
 *             if user_entity is None:
 *                 logger.error("Cannot upload file to S3: user_entity is not available and cannot be retrieved from database")             # <<<<<<<<<<<<<<
 *                 return None
 * 
*/
        __pyx_t_7 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6397, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6397, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9);
          assert(__pyx_t_7);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Cannot_upload_file_to_S3_user_en};
          __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6397, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "ws_package/controllers/activity_controller.py":6398
 *             if user_entity is None:
 *                 logger.error("Cannot upload file to S3: user_entity is not available and cannot be retrieved from database")
 *                 return None             # <<<<<<<<<<<<<<
 * 
 *             # Get org_id from user_entity
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
        goto __pyx_L8_try_return;

        /* "ws_package/controllers/activity_controller.py":6396
 *                 user_entity = self.user_entity
 * 
 *             if user_entity is None:             # <<<<<<<<<<<<<<
 *                 logger.error("Cannot upload file to S3: user_entity is not available and cannot be retrieved from database")
 *                 return None
*/
      }

      /* "ws_package/controllers/activity_controller.py":6401
 * 
 *             # Get org_id from user_entity
 *             org_id = user_entity.org_id             # <<<<<<<<<<<<<<
 *             if org_id is None:
 *                 logger.error("Cannot upload file to S3: org_id is not set in user_entity")
*/
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_org_id); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6401, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_cur_scope->__pyx_v_org_id = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":6402
 *             # Get org_id from user_entity
 *             org_id = user_entity.org_id
 *             if org_id is None:             # <<<<<<<<<<<<<<
 *                 logger.error("Cannot upload file to S3: org_id is not set in user_entity")
 *                 return None
*/
      __pyx_t_4 = (__pyx_cur_scope->__pyx_v_org_id == Py_None);
      if (__pyx_t_4) {

        /* "ws_package/controllers/activity_controller.py":6403
 *             org_id = user_entity.org_id
 *             if org_id is None:
 *                 logger.error("Cannot upload file to S3: org_id is not set in user_entity")             # <<<<<<<<<<<<<<
 *                 return None
 * 
*/
        __pyx_t_9 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6403, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6403, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
          assert(__pyx_t_9);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_mstate_global->__pyx_kp_u_Cannot_upload_file_to_S3_org_id};
          __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6403, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "ws_package/controllers/activity_controller.py":6404
 *             if org_id is None:
 *                 logger.error("Cannot upload file to S3: org_id is not set in user_entity")
 *                 return None             # <<<<<<<<<<<<<<
 * 
 *             logger.info("Using user_entity with org_id: %s, user_id: %s", org_id, user_entity.user_id)
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
        goto __pyx_L8_try_return;

        /* "ws_package/controllers/activity_controller.py":6402
 *             # Get org_id from user_entity
 *             org_id = user_entity.org_id
 *             if org_id is None:             # <<<<<<<<<<<<<<
 *                 logger.error("Cannot upload file to S3: org_id is not set in user_entity")
 *                 return None
*/
      }

      /* "ws_package/controllers/activity_controller.py":6406
 *                 return None
 * 
 *             logger.info("Using user_entity with org_id: %s, user_id: %s", org_id, user_entity.user_id)             # <<<<<<<<<<<<<<
 * 
 *             # Check if file exists
*/
      __pyx_t_8 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6406, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6406, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_user_id); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6406, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_10 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_8);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_10 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[4] = {__pyx_t_8, __pyx_mstate_global->__pyx_kp_u_Using_user_entity_with_org_id_s, __pyx_cur_scope->__pyx_v_org_id, __pyx_t_9};
        __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_10, (4-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6406, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
      }
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":6409
 * 
 *             # Check if file exists
 *             if not os.path.exists(local_file_path):             # <<<<<<<<<<<<<<
 *                 logger.error("Cannot upload file to S3: file does not exist: %s", local_file_path)
 *                 return None
*/
      __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_os); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6409, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_path); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6409, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_7 = __pyx_t_8;
      __Pyx_INCREF(__pyx_t_7);
      __pyx_t_10 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_cur_scope->__pyx_v_local_file_path};
        __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_exists, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6409, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
      }
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 6409, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_5 = (!__pyx_t_4);
      if (__pyx_t_5) {

        /* "ws_package/controllers/activity_controller.py":6410
 *             # Check if file exists
 *             if not os.path.exists(local_file_path):
 *                 logger.error("Cannot upload file to S3: file does not exist: %s", local_file_path)             # <<<<<<<<<<<<<<
 *                 return None
 * 
*/
        __pyx_t_8 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6410, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6410, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_9);
          assert(__pyx_t_8);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_8, __pyx_mstate_global->__pyx_kp_u_Cannot_upload_file_to_S3_file_do, __pyx_cur_scope->__pyx_v_local_file_path};
          __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_10, (3-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6410, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "ws_package/controllers/activity_controller.py":6411
 *             if not os.path.exists(local_file_path):
 *                 logger.error("Cannot upload file to S3: file does not exist: %s", local_file_path)
 *                 return None             # <<<<<<<<<<<<<<
 * 
 *             # Get S3 configuration (refresh STS credentials when expire_time passed)
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
        goto __pyx_L8_try_return;

        /* "ws_package/controllers/activity_controller.py":6409
 * 
 *             # Check if file exists
 *             if not os.path.exists(local_file_path):             # <<<<<<<<<<<<<<
 *                 logger.error("Cannot upload file to S3: file does not exist: %s", local_file_path)
 *                 return None
*/
      }

      /* "ws_package/controllers/activity_controller.py":6414
 * 
 *             # Get S3 configuration (refresh STS credentials when expire_time passed)
 *             s3_config = await s3_detail_for_upload(org_id, user_entity)             # <<<<<<<<<<<<<<
 *             if not s3_config:
 *                 logger.error("Cannot upload file to S3: S3 configuration not found for org_id: %s", org_id)
*/
      __pyx_t_9 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_s3_detail_for_upload); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6414, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_10 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
        assert(__pyx_t_9);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
        __pyx_t_10 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_9, __pyx_cur_scope->__pyx_v_org_id, __pyx_cur_scope->__pyx_v_user_entity};
        __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_10, (3-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6414, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
      }
      __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_6, &__pyx_r);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      if (likely(__pyx_t_11 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
        __Pyx_XGIVEREF(__pyx_t_2);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
        __Pyx_XGIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 1;
        return __pyx_r;
        __pyx_L16_resume_from_await:;
        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_1);
        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_2);
        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_3);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6414, __pyx_L4_error)
        __pyx_t_6 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_6);
      } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __pyx_t_6 = __pyx_r; __pyx_r = NULL;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 6414, __pyx_L4_error)
      }
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_cur_scope->__pyx_v_s3_config = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":6415
 *             # Get S3 configuration (refresh STS credentials when expire_time passed)
 *             s3_config = await s3_detail_for_upload(org_id, user_entity)
 *             if not s3_config:             # <<<<<<<<<<<<<<
 *                 logger.error("Cannot upload file to S3: S3 configuration not found for org_id: %s", org_id)
 *                 return None
*/
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_s3_config); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 6415, __pyx_L4_error)
      __pyx_t_4 = (!__pyx_t_5);
      if (__pyx_t_4) {

        /* "ws_package/controllers/activity_controller.py":6416
 *             s3_config = await s3_detail_for_upload(org_id, user_entity)
 *             if not s3_config:
 *                 logger.error("Cannot upload file to S3: S3 configuration not found for org_id: %s", org_id)             # <<<<<<<<<<<<<<
 *                 return None
 * 
*/
        __pyx_t_8 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6416, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6416, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
          assert(__pyx_t_8);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_8, __pyx_mstate_global->__pyx_kp_u_Cannot_upload_file_to_S3_S3_conf, __pyx_cur_scope->__pyx_v_org_id};
          __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_10, (3-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6416, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;

        /* "ws_package/controllers/activity_controller.py":6417
 *             if not s3_config:
 *                 logger.error("Cannot upload file to S3: S3 configuration not found for org_id: %s", org_id)
 *                 return None             # <<<<<<<<<<<<<<
 * 
 *             # Create S3sync instance
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
        goto __pyx_L8_try_return;

        /* "ws_package/controllers/activity_controller.py":6415
 *             # Get S3 configuration (refresh STS credentials when expire_time passed)
 *             s3_config = await s3_detail_for_upload(org_id, user_entity)
 *             if not s3_config:             # <<<<<<<<<<<<<<
 *                 logger.error("Cannot upload file to S3: S3 configuration not found for org_id: %s", org_id)
 *                 return None
*/
      }

      /* "ws_package/controllers/activity_controller.py":6420
 * 
 *             # Create S3sync instance
 *             s3_sync = S3sync(s3_config)             # <<<<<<<<<<<<<<
 * 
 *             # Generate S3 destination path: notes/{org_id}/{user_id}/{timestamp}-{filename}
*/
      __pyx_t_7 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_S3sync); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6420, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_10 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
        assert(__pyx_t_7);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
        __pyx_t_10 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_cur_scope->__pyx_v_s3_config};
        __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6420, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
      }
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_cur_scope->__pyx_v_s3_sync = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":6423
 * 
 *             # Generate S3 destination path: notes/{org_id}/{user_id}/{timestamp}-{filename}
 *             file_name = os.path.basename(local_file_path)             # <<<<<<<<<<<<<<
 *             timestamp = datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
 *             s3_dest_path = f"notes/{org_id}/{user_entity.user_id}/{timestamp}-{file_name}"
*/
      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_os); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6423, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_path); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6423, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_8 = __pyx_t_9;
      __Pyx_INCREF(__pyx_t_8);
      __pyx_t_10 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_cur_scope->__pyx_v_local_file_path};
        __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_basename, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6423, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
      }
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_cur_scope->__pyx_v_file_name = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":6424
 *             # Generate S3 destination path: notes/{org_id}/{user_id}/{timestamp}-{filename}
 *             file_name = os.path.basename(local_file_path)
 *             timestamp = datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S')             # <<<<<<<<<<<<<<
 *             s3_dest_path = f"notes/{org_id}/{user_entity.user_id}/{timestamp}-{file_name}"
 * 
*/
      __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 6424, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_12);
      __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_datetime); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 6424, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_13);
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
      __pyx_t_7 = __pyx_t_13;
      __Pyx_INCREF(__pyx_t_7);
      __pyx_t_10 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
        __pyx_t_8 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_now, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6424, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_8);
      }
      __pyx_t_9 = __pyx_t_8;
      __Pyx_INCREF(__pyx_t_9);
      __pyx_t_10 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_mstate_global->__pyx_kp_u_Y_m_d_H_M_S_2};
        __pyx_t_6 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strftime, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6424, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
      }
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_cur_scope->__pyx_v_timestamp = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":6425
 *             file_name = os.path.basename(local_file_path)
 *             timestamp = datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S')
 *             s3_dest_path = f"notes/{org_id}/{user_entity.user_id}/{timestamp}-{file_name}"             # <<<<<<<<<<<<<<
 * 
 *             logger.info("Uploading file to S3: %s -> %s", local_file_path, s3_dest_path)
*/
      __pyx_t_6 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_org_id, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6425, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_user_id); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6425, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_PyObject_FormatSimple(__pyx_t_8, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6425, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_8 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_timestamp, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6425, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_13 = __Pyx_PyObject_FormatSimple(__pyx_cur_scope->__pyx_v_file_name, __pyx_mstate_global->__pyx_empty_unicode); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 6425, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_13);
      __pyx_t_14[0] = __pyx_mstate_global->__pyx_kp_u_notes;
      __pyx_t_14[1] = __pyx_t_6;
      __pyx_t_14[2] = __pyx_mstate_global->__pyx_kp_u__9;
      __pyx_t_14[3] = __pyx_t_9;
      __pyx_t_14[4] = __pyx_mstate_global->__pyx_kp_u__9;
      __pyx_t_14[5] = __pyx_t_8;
      __pyx_t_14[6] = __pyx_mstate_global->__pyx_kp_u__14;
      __pyx_t_14[7] = __pyx_t_13;
      __pyx_t_7 = __Pyx_PyUnicode_Join(__pyx_t_14, 8, 6 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_6) + 1 * 3 + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_9) + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_8) + __Pyx_PyUnicode_GET_LENGTH(__pyx_t_13), 127 | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_6) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_9) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_8) | __Pyx_PyUnicode_MAX_CHAR_VALUE(__pyx_t_13));
      if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6425, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
      __Pyx_GIVEREF(__pyx_t_7);
      __pyx_cur_scope->__pyx_v_s3_dest_path = ((PyObject*)__pyx_t_7);
      __pyx_t_7 = 0;

      /* "ws_package/controllers/activity_controller.py":6427
 *             s3_dest_path = f"notes/{org_id}/{user_entity.user_id}/{timestamp}-{file_name}"
 * 
 *             logger.info("Uploading file to S3: %s -> %s", local_file_path, s3_dest_path)             # <<<<<<<<<<<<<<
 * 
 *             # Upload based on bucket type
*/
      __pyx_t_13 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6427, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6427, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_10 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_9);
        assert(__pyx_t_13);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_13);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
        __pyx_t_10 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[4] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Uploading_file_to_S3_s_s, __pyx_cur_scope->__pyx_v_local_file_path, __pyx_cur_scope->__pyx_v_s3_dest_path};
        __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_10, (4-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6427, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "ws_package/controllers/activity_controller.py":6430
 * 
 *             # Upload based on bucket type
 *             if user_entity.bucket == "hetzner":             # <<<<<<<<<<<<<<
 *                 logger.info("Uploading to Hetzner bucket")
 *                 s3_url = await s3_sync.upload_file_to_hetzner(local_file_path, s3_dest_path)
*/
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_user_entity, __pyx_mstate_global->__pyx_n_u_bucket); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6430, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_4 = (__Pyx_PyUnicode_Equals(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_hetzner, Py_EQ)); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 6430, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (__pyx_t_4) {

        /* "ws_package/controllers/activity_controller.py":6431
 *             # Upload based on bucket type
 *             if user_entity.bucket == "hetzner":
 *                 logger.info("Uploading to Hetzner bucket")             # <<<<<<<<<<<<<<
 *                 s3_url = await s3_sync.upload_file_to_hetzner(local_file_path, s3_dest_path)
 *             else:
*/
        __pyx_t_9 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 6431, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6431, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
          assert(__pyx_t_9);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_mstate_global->__pyx_kp_u_Uploading_to_Hetzner_bucket};
          __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6431, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "ws_package/controllers/activity_controller.py":6432
 *             if user_entity.bucket == "hetzner":
 *                 logger.info("Uploading to Hetzner bucket")
 *                 s3_url = await s3_sync.upload_file_to_hetzner(local_file_path, s3_dest_path)             # <<<<<<<<<<<<<<
 *             else:
 *                 logger.info("Uploading to AWS bucket")
*/
        __pyx_t_8 = __pyx_cur_scope->__pyx_v_s3_sync;
        __Pyx_INCREF(__pyx_t_8);
        __pyx_t_10 = 0;
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_8, __pyx_cur_scope->__pyx_v_local_file_path, __pyx_cur_scope->__pyx_v_s3_dest_path};
          __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_upload_file_to_hetzner, __pyx_callargs+__pyx_t_10, (3-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6432, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7, &__pyx_r);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (likely(__pyx_t_11 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_1);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
          __Pyx_XGIVEREF(__pyx_t_2);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
          __Pyx_XGIVEREF(__pyx_t_3);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 2;
          return __pyx_r;
          __pyx_L19_resume_from_await:;
          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_1);
          __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_2);
          __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_3);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6432, __pyx_L4_error)
          __pyx_t_7 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_7);
        } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __pyx_t_7 = __pyx_r; __pyx_r = NULL;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 6432, __pyx_L4_error)
        }
        __Pyx_GIVEREF(__pyx_t_7);
        __pyx_cur_scope->__pyx_v_s3_url = __pyx_t_7;
        __pyx_t_7 = 0;

        /* "ws_package/controllers/activity_controller.py":6430
 * 
 *             # Upload based on bucket type
 *             if user_entity.bucket == "hetzner":             # <<<<<<<<<<<<<<
 *                 logger.info("Uploading to Hetzner bucket")
 *                 s3_url = await s3_sync.upload_file_to_hetzner(local_file_path, s3_dest_path)
*/
        goto __pyx_L18;
      }

      /* "ws_package/controllers/activity_controller.py":6434
 *                 s3_url = await s3_sync.upload_file_to_hetzner(local_file_path, s3_dest_path)
 *             else:
 *                 logger.info("Uploading to AWS bucket")             # <<<<<<<<<<<<<<
 *                 s3_url = await s3_sync.upload_file(local_file_path, s3_dest_path)
 * 
*/
      /*else*/ {
        __pyx_t_8 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6434, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_9);
        __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 6434, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_13);
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_13))) {
          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_13);
          assert(__pyx_t_8);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_13);
          __Pyx_INCREF(__pyx_t_8);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_13, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_mstate_global->__pyx_kp_u_Uploading_to_AWS_bucket};
          __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_13, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6434, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "ws_package/controllers/activity_controller.py":6435
 *             else:
 *                 logger.info("Uploading to AWS bucket")
 *                 s3_url = await s3_sync.upload_file(local_file_path, s3_dest_path)             # <<<<<<<<<<<<<<
 * 
 *             if s3_url:
*/
        __pyx_t_13 = __pyx_cur_scope->__pyx_v_s3_sync;
        __Pyx_INCREF(__pyx_t_13);
        __pyx_t_10 = 0;
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_13, __pyx_cur_scope->__pyx_v_local_file_path, __pyx_cur_scope->__pyx_v_s3_dest_path};
          __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_upload_file, __pyx_callargs+__pyx_t_10, (3-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6435, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7, &__pyx_r);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (likely(__pyx_t_11 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_1);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
          __Pyx_XGIVEREF(__pyx_t_2);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
          __Pyx_XGIVEREF(__pyx_t_3);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 3;
          return __pyx_r;
          __pyx_L20_resume_from_await:;
          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_1);
          __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_2);
          __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_3);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6435, __pyx_L4_error)
          __pyx_t_7 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_7);
        } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __pyx_t_7 = __pyx_r; __pyx_r = NULL;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 6435, __pyx_L4_error)
        }
        __Pyx_GIVEREF(__pyx_t_7);
        __pyx_cur_scope->__pyx_v_s3_url = __pyx_t_7;
        __pyx_t_7 = 0;
      }
      __pyx_L18:;

      /* "ws_package/controllers/activity_controller.py":6437
 *                 s3_url = await s3_sync.upload_file(local_file_path, s3_dest_path)
 * 
 *             if s3_url:             # <<<<<<<<<<<<<<
 *                 logger.info("File uploaded successfully to S3: %s", s3_url)
 *                 return s3_url
*/
      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_s3_url); if (unlikely((__pyx_t_4 < 0))) __PYX_ERR(0, 6437, __pyx_L4_error)
      if (__pyx_t_4) {

        /* "ws_package/controllers/activity_controller.py":6438
 * 
 *             if s3_url:
 *                 logger.info("File uploaded successfully to S3: %s", s3_url)             # <<<<<<<<<<<<<<
 *                 return s3_url
 *             else:
*/
        __pyx_t_13 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6438, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6438, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_9);
          assert(__pyx_t_13);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_13);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_File_uploaded_successfully_to_S3, __pyx_cur_scope->__pyx_v_s3_url};
          __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_10, (3-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6438, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "ws_package/controllers/activity_controller.py":6439
 *             if s3_url:
 *                 logger.info("File uploaded successfully to S3: %s", s3_url)
 *                 return s3_url             # <<<<<<<<<<<<<<
 *             else:
 *                 logger.error("S3 upload returned no URL for file: %s", local_file_path)
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_t_7 = __pyx_cur_scope->__pyx_v_s3_url;
        __Pyx_INCREF(__pyx_t_7);
        if (!(likely(PyUnicode_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None) || __Pyx_RaiseUnexpectedTypeError("str", __pyx_t_7))) __PYX_ERR(0, 6439, __pyx_L4_error)
        __pyx_r = ((PyObject*)__pyx_t_7);
        __pyx_t_7 = 0;
        goto __pyx_L8_try_return;

        /* "ws_package/controllers/activity_controller.py":6437
 *                 s3_url = await s3_sync.upload_file(local_file_path, s3_dest_path)
 * 
 *             if s3_url:             # <<<<<<<<<<<<<<
 *                 logger.info("File uploaded successfully to S3: %s", s3_url)
 *                 return s3_url
*/
      }

      /* "ws_package/controllers/activity_controller.py":6441
 *                 return s3_url
 *             else:
 *                 logger.error("S3 upload returned no URL for file: %s", local_file_path)             # <<<<<<<<<<<<<<
 *                 return None
 *         except Exception as e:
*/
      /*else*/ {
        __pyx_t_9 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 6441, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_13);
        __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6441, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
          assert(__pyx_t_9);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_9);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_9, __pyx_mstate_global->__pyx_kp_u_S3_upload_returned_no_URL_for_fi, __pyx_cur_scope->__pyx_v_local_file_path};
          __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_10, (3-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6441, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "ws_package/controllers/activity_controller.py":6442
 *             else:
 *                 logger.error("S3 upload returned no URL for file: %s", local_file_path)
 *                 return None             # <<<<<<<<<<<<<<
 *         except Exception as e:
 *             logger.error("Error uploading file to S3: %s", e, exc_info=True)
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
        goto __pyx_L8_try_return;
      }

      /* "ws_package/controllers/activity_controller.py":6390
 *             S3 URL if successful, None otherwise
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # Get user_entity if not available
 *             user_entity = None
*/
    }
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "ws_package/controllers/activity_controller.py":6443
 *                 logger.error("S3 upload returned no URL for file: %s", local_file_path)
 *                 return None
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error uploading file to S3: %s", e, exc_info=True)
 *             return None
*/
    __pyx_t_15 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_15) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._upload_file_to_s3", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9) < 0) __PYX_ERR(0, 6443, __pyx_L6_except_error)
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_8);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_INCREF(__pyx_t_8);
      __Pyx_GIVEREF(__pyx_t_8);
      __pyx_cur_scope->__pyx_v_e = __pyx_t_8;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":6444
 *                 return None
 *         except Exception as e:
 *             logger.error("Error uploading file to S3: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 *             return None
 * 
*/
        __pyx_t_6 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 6444, __pyx_L27_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_16 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 6444, __pyx_L27_error)
        __Pyx_GOTREF(__pyx_t_16);
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_16))) {
          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_16);
          assert(__pyx_t_6);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_16);
          __Pyx_INCREF(__pyx_t_6);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_16, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_Error_uploading_file_to_S3_s, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_12 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 6444, __pyx_L27_error)
          __Pyx_GOTREF(__pyx_t_12);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_12, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 6444, __pyx_L27_error)
          __pyx_t_13 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_16, __pyx_callargs+__pyx_t_10, (3-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_12);
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
          if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 6444, __pyx_L27_error)
          __Pyx_GOTREF(__pyx_t_13);
        }
        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;

        /* "ws_package/controllers/activity_controller.py":6445
 *         except Exception as e:
 *             logger.error("Error uploading file to S3: %s", e, exc_info=True)
 *             return None             # <<<<<<<<<<<<<<
 * 
 *     async def _save_note_to_idle_intervals(self, note: str, file_path: Optional[str] = None):
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        goto __pyx_L26_return;
      }

      /* "ws_package/controllers/activity_controller.py":6443
 *                 logger.error("S3 upload returned no URL for file: %s", local_file_path)
 *                 return None
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error uploading file to S3: %s", e, exc_info=True)
 *             return None
*/
      /*finally:*/ {
        __pyx_L27_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
          __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_22, &__pyx_t_23, &__pyx_t_24);
          if ( unlikely(__Pyx_GetException(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21) < 0)) __Pyx_ErrFetch(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_19);
          __Pyx_XGOTREF(__pyx_t_20);
          __Pyx_XGOTREF(__pyx_t_21);
          __Pyx_XGOTREF(__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_23);
          __Pyx_XGOTREF(__pyx_t_24);
          __pyx_t_15 = __pyx_lineno; __pyx_t_17 = __pyx_clineno; __pyx_t_18 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_23);
          __Pyx_XGIVEREF(__pyx_t_24);
          __Pyx_ExceptionReset(__pyx_t_22, __pyx_t_23, __pyx_t_24);
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_XGIVEREF(__pyx_t_20);
          __Pyx_XGIVEREF(__pyx_t_21);
          __Pyx_ErrRestore(__pyx_t_19, __pyx_t_20, __pyx_t_21);
          __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_22 = 0; __pyx_t_23 = 0; __pyx_t_24 = 0;
          __pyx_lineno = __pyx_t_15; __pyx_clineno = __pyx_t_17; __pyx_filename = __pyx_t_18;
          goto __pyx_L6_except_error;
        }
        __pyx_L26_return: {
          __pyx_t_25 = __pyx_r;
          __pyx_r = 0;
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          __pyx_r = __pyx_t_25;
          __pyx_t_25 = 0;
          goto __pyx_L7_except_return;
        }
      }
    }
    goto __pyx_L6_except_error;

    /* "ws_package/controllers/activity_controller.py":6390
 *             S3 URL if successful, None otherwise
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # Get user_entity if not available
 *             user_entity = None
*/
    __pyx_L6_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L7_except_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":6380
 *             logger.error("Error marking idle intervals as uploaded: %s", e, exc_info=True)
 * 
 *     async def _upload_file_to_s3(self, local_file_path: str) -> Optional[str]:             # <<<<<<<<<<<<<<
 *         """
 *         Upload a file to S3 and return the S3 URL.
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_16);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("_upload_file_to_s3", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_217generator47(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":6447
 *             return None
 * 
 *     async def _save_note_to_idle_intervals(self, note: str, file_path: Optional[str] = None):             # <<<<<<<<<<<<<<
 *         """
 *         Save note to Notes table with array of idle interval IDs.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_216_save_note_to_idle_intervals(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_215_save_note_to_idle_intervals, "\n        Save note to Notes table with array of idle interval IDs.\n        This is called when user provides a note for idle time.\n        \n        Args:\n            note: Note text to save\n            file_path: Optional S3 URL of uploaded file\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_216_save_note_to_idle_intervals = {"_save_note_to_idle_intervals", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_216_save_note_to_idle_intervals, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_215_save_note_to_idle_intervals};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_216_save_note_to_idle_intervals(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_note = 0;
  PyObject *__pyx_v_file_path = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_save_note_to_idle_intervals (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_note,&__pyx_mstate_global->__pyx_n_u_file_path,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 6447, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 6447, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 6447, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 6447, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_save_note_to_idle_intervals", 0) < (0)) __PYX_ERR(0, 6447, __pyx_L3_error)
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject*)Py_None));
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_save_note_to_idle_intervals", 0, 2, 3, i); __PYX_ERR(0, 6447, __pyx_L3_error) }
      }
    } else {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 6447, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 6447, __pyx_L3_error)
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 6447, __pyx_L3_error)
        break;
        default: goto __pyx_L5_argtuple_error;
      }
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject*)Py_None));
    }
    __pyx_v_self = values[0];
    __pyx_v_note = ((PyObject*)values[1]);
    __pyx_v_file_path = ((PyObject*)values[2]);
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_save_note_to_idle_intervals", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 6447, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._save_note_to_idle_intervals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_note), (&PyUnicode_Type), 0, "note", 2))) __PYX_ERR(0, 6447, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_file_path), (&PyUnicode_Type), 1, "file_path", 2))) __PYX_ERR(0, 6447, __pyx_L1_error)
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_215_save_note_to_idle_intervals(__pyx_self, __pyx_v_self, __pyx_v_note, __pyx_v_file_path);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  goto __pyx_L7_cleaned_up;
  __pyx_L0:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __pyx_L7_cleaned_up:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_215_save_note_to_idle_intervals(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_note, PyObject *__pyx_v_file_path) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_save_note_to_idle_intervals", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 6447, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_note = __pyx_v_note;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_note);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_note);
  __pyx_cur_scope->__pyx_v_file_path = __pyx_v_file_path;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_file_path);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_file_path);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_217generator47, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[73]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_save_note_to_idle_intervals, __pyx_mstate_global->__pyx_n_u_ActivityController__save_note_to, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 6447, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._save_note_to_idle_intervals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_217generator47(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  size_t __pyx_t_8;
  __Pyx_PySendResult __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  Py_ssize_t __pyx_t_24;
  PyObject *(*__pyx_t_25)(PyObject *);
  int __pyx_t_26;
  int __pyx_t_27;
  int __pyx_t_28;
  PyObject *__pyx_t_29 = NULL;
  int __pyx_t_30;
  int __pyx_t_31;
  char const *__pyx_t_32;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_save_note_to_idle_intervals", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L10_resume_from_await;
    case 2: goto __pyx_L11_resume_from_await;
    case 3: goto __pyx_L23_resume_from_await;
    case 4: goto __pyx_L33_resume_from_await;
    case 5: goto __pyx_L34_resume_from_await;
    case 6: goto __pyx_L37_resume_from_await;
    case 7: goto __pyx_L49_resume_from_await;
    case 8: goto __pyx_L50_resume_from_await;
    case 9: goto __pyx_L51_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 6447, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":6456
 *             file_path: Optional S3 URL of uploaded file
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # Flush queue first
 *             await db_writer_service.process_immediately()
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":6458
 *         try:
 *             # Flush queue first
 *             await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 *             await asyncio.sleep(0.5)  # Increased delay to ensure is_idle updates are committed
 * 
*/
      __pyx_t_5 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6458, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6458, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_5);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6458, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (likely(__pyx_t_9 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
        __Pyx_XGIVEREF(__pyx_t_2);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
        __Pyx_XGIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 1;
        return __pyx_r;
        __pyx_L10_resume_from_await:;
        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_1);
        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_2);
        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_3);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6458, __pyx_L4_error)
      } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_DECREF(__pyx_r); __pyx_r = 0;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 6458, __pyx_L4_error)
      }

      /* "ws_package/controllers/activity_controller.py":6459
 *             # Flush queue first
 *             await db_writer_service.process_immediately()
 *             await asyncio.sleep(0.5)  # Increased delay to ensure is_idle updates are committed             # <<<<<<<<<<<<<<
 * 
 *             current_counter = self.last_count + 1
*/
      __pyx_t_7 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6459, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6459, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_8 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
        assert(__pyx_t_7);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
        __pyx_t_8 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_mstate_global->__pyx_float_0_5};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6459, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (likely(__pyx_t_9 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
        __Pyx_XGIVEREF(__pyx_t_2);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
        __Pyx_XGIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 2;
        return __pyx_r;
        __pyx_L11_resume_from_await:;
        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_1);
        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_2);
        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_3);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6459, __pyx_L4_error)
      } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_DECREF(__pyx_r); __pyx_r = 0;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 6459, __pyx_L4_error)
      }

      /* "ws_package/controllers/activity_controller.py":6461
 *             await asyncio.sleep(0.5)  # Increased delay to ensure is_idle updates are committed
 * 
 *             current_counter = self.last_count + 1             # <<<<<<<<<<<<<<
 * 
 *             with db_lock_manager.read_lock():
*/
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6461, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_6 = __Pyx_PyLong_AddObjC(__pyx_t_4, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6461, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_cur_scope->__pyx_v_current_counter = __pyx_t_6;
      __pyx_t_6 = 0;

      /* "ws_package/controllers/activity_controller.py":6463
 *             current_counter = self.last_count + 1
 * 
 *             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     # First, try to find intervals by is_idle flag (if they've been marked)
*/
      /*with:*/ {
        __pyx_t_4 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6463, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6463, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_5);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_5))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
          assert(__pyx_t_4);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
          __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6463, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __pyx_t_10 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 6463, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_4 = NULL;
        __pyx_t_7 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6463, __pyx_L12_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (likely(PyMethod_Check(__pyx_t_7))) {
          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7);
          assert(__pyx_t_4);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
          __Pyx_INCREF(__pyx_t_4);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
          __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6463, __pyx_L12_error)
          __Pyx_GOTREF(__pyx_t_5);
        }
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        /*try:*/ {
          {
            __Pyx_ExceptionSave(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
            __Pyx_XGOTREF(__pyx_t_11);
            __Pyx_XGOTREF(__pyx_t_12);
            __Pyx_XGOTREF(__pyx_t_13);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":6464
 * 
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     # First, try to find intervals by is_idle flag (if they've been marked)
 *                     query_by_flag = select(ActivityInterval).where(
*/
              /*with:*/ {
                __pyx_t_5 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6464, __pyx_L16_error)
                __Pyx_GOTREF(__pyx_t_7);
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_7))) {
                  __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
                  assert(__pyx_t_5);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                  __Pyx_INCREF(__pyx_t_5);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                  __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                  if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6464, __pyx_L16_error)
                  __Pyx_GOTREF(__pyx_t_6);
                }
                __pyx_t_14 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 6464, __pyx_L16_error)
                __Pyx_GOTREF(__pyx_t_14);
                __pyx_t_5 = NULL;
                __pyx_t_4 = __Pyx_PyObject_LookupSpecial(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6464, __pyx_L22_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_t_8 = 1;
                #if CYTHON_UNPACK_METHODS
                if (likely(PyMethod_Check(__pyx_t_4))) {
                  __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
                  assert(__pyx_t_5);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                  __Pyx_INCREF(__pyx_t_5);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                  __pyx_t_8 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
                  __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6464, __pyx_L22_error)
                  __Pyx_GOTREF(__pyx_t_7);
                }
                __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7, &__pyx_r);
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                if (likely(__pyx_t_9 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_1);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                  __Pyx_XGIVEREF(__pyx_t_2);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                  __Pyx_XGIVEREF(__pyx_t_3);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                  __Pyx_XGIVEREF(__pyx_t_6);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_6;
                  __Pyx_XGIVEREF(__pyx_t_10);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                  __Pyx_XGIVEREF(__pyx_t_11);
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_t_14);
                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_14;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 3;
                  return __pyx_r;
                  __pyx_L23_resume_from_await:;
                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_1);
                  __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_2);
                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_3);
                  __pyx_t_6 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_6);
                  __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_10);
                  __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = 0;
                  __Pyx_XGOTREF(__pyx_t_11);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
                  __pyx_cur_scope->__pyx_t_6 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_7;
                  __pyx_cur_scope->__pyx_t_7 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  __pyx_t_14 = __pyx_cur_scope->__pyx_t_8;
                  __pyx_cur_scope->__pyx_t_8 = 0;
                  __Pyx_XGOTREF(__pyx_t_14);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6464, __pyx_L22_error)
                  __pyx_t_7 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_7);
                } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __pyx_t_7 = __pyx_r; __pyx_r = NULL;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 6464, __pyx_L22_error)
                }
                __pyx_t_4 = __pyx_t_7;
                __pyx_t_7 = 0;
                __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                /*try:*/ {
                  {
                    __Pyx_ExceptionSave(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
                    __Pyx_XGOTREF(__pyx_t_15);
                    __Pyx_XGOTREF(__pyx_t_16);
                    __Pyx_XGOTREF(__pyx_t_17);
                    /*try:*/ {
                      __Pyx_GIVEREF(__pyx_t_4);
                      __pyx_cur_scope->__pyx_v_session = __pyx_t_4;
                      __pyx_t_4 = 0;

                      /* "ws_package/controllers/activity_controller.py":6466
 *                 async with async_session() as session:
 *                     # First, try to find intervals by is_idle flag (if they've been marked)
 *                     query_by_flag = select(ActivityInterval).where(             # <<<<<<<<<<<<<<
 *                         ActivityInterval.counter == current_counter,
 *                         ActivityInterval.is_break == 0,
*/
                      __pyx_t_19 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6466, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_20);
                      __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6466, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __pyx_t_8 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_20))) {
                        __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_20);
                        assert(__pyx_t_19);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_20);
                        __Pyx_INCREF(__pyx_t_19);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_20, __pyx__function);
                        __pyx_t_8 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_19, __pyx_t_21};
                        __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_20, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 6466, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_18);
                      }
                      __pyx_t_5 = __pyx_t_18;
                      __Pyx_INCREF(__pyx_t_5);

                      /* "ws_package/controllers/activity_controller.py":6467
 *                     # First, try to find intervals by is_idle flag (if they've been marked)
 *                     query_by_flag = select(ActivityInterval).where(
 *                         ActivityInterval.counter == current_counter,             # <<<<<<<<<<<<<<
 *                         ActivityInterval.is_break == 0,
 *                         ActivityInterval.is_idle == True,
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6467, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_20);
                      __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6467, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                      __pyx_t_20 = PyObject_RichCompare(__pyx_t_21, __pyx_cur_scope->__pyx_v_current_counter, Py_EQ); __Pyx_XGOTREF(__pyx_t_20); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6467, __pyx_L27_error)
                      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;

                      /* "ws_package/controllers/activity_controller.py":6468
 *                     query_by_flag = select(ActivityInterval).where(
 *                         ActivityInterval.counter == current_counter,
 *                         ActivityInterval.is_break == 0,             # <<<<<<<<<<<<<<
 *                         ActivityInterval.is_idle == True,
 *                         ActivityInterval.is_uploaded == False
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6468, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_is_break); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6468, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_19);
                      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                      __pyx_t_21 = __Pyx_PyLong_EqObjC(__pyx_t_19, __pyx_mstate_global->__pyx_int_0, 0, 0); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6468, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;

                      /* "ws_package/controllers/activity_controller.py":6469
 *                         ActivityInterval.counter == current_counter,
 *                         ActivityInterval.is_break == 0,
 *                         ActivityInterval.is_idle == True,             # <<<<<<<<<<<<<<
 *                         ActivityInterval.is_uploaded == False
 *                     ).order_by(desc(ActivityInterval.start_time))
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6469, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_19);
                      __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_is_idle); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6469, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                      __pyx_t_19 = PyObject_RichCompare(__pyx_t_22, Py_True, Py_EQ); __Pyx_XGOTREF(__pyx_t_19); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6469, __pyx_L27_error)
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;

                      /* "ws_package/controllers/activity_controller.py":6470
 *                         ActivityInterval.is_break == 0,
 *                         ActivityInterval.is_idle == True,
 *                         ActivityInterval.is_uploaded == False             # <<<<<<<<<<<<<<
 *                     ).order_by(desc(ActivityInterval.start_time))
 * 
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6470, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_is_uploaded); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6470, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_23);
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                      __pyx_t_22 = PyObject_RichCompare(__pyx_t_23, Py_False, Py_EQ); __Pyx_XGOTREF(__pyx_t_22); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6470, __pyx_L27_error)
                      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[5] = {__pyx_t_5, __pyx_t_20, __pyx_t_21, __pyx_t_19, __pyx_t_22};
                        __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6466, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_7);
                      }
                      __pyx_t_6 = __pyx_t_7;
                      __Pyx_INCREF(__pyx_t_6);

                      /* "ws_package/controllers/activity_controller.py":6471
 *                         ActivityInterval.is_idle == True,
 *                         ActivityInterval.is_uploaded == False
 *                     ).order_by(desc(ActivityInterval.start_time))             # <<<<<<<<<<<<<<
 * 
 *                     result_by_flag = await session.execute(query_by_flag)
*/
                      __pyx_t_22 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_desc); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6471, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_19);
                      __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6471, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6471, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_20);
                      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                      __pyx_t_8 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_19))) {
                        __pyx_t_22 = PyMethod_GET_SELF(__pyx_t_19);
                        assert(__pyx_t_22);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_19);
                        __Pyx_INCREF(__pyx_t_22);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_19, __pyx__function);
                        __pyx_t_8 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_22, __pyx_t_20};
                        __pyx_t_18 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_19, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                        if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 6471, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_18);
                      }
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_18};
                        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_order_by, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6471, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_4);
                      }
                      __Pyx_GIVEREF(__pyx_t_4);
                      __pyx_cur_scope->__pyx_v_query_by_flag = __pyx_t_4;
                      __pyx_t_4 = 0;

                      /* "ws_package/controllers/activity_controller.py":6473
 *                     ).order_by(desc(ActivityInterval.start_time))
 * 
 *                     result_by_flag = await session.execute(query_by_flag)             # <<<<<<<<<<<<<<
 *                     idle_intervals_by_flag = result_by_flag.scalars().all()
 * 
*/
                      __pyx_t_7 = __pyx_cur_scope->__pyx_v_session;
                      __Pyx_INCREF(__pyx_t_7);
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_cur_scope->__pyx_v_query_by_flag};
                        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6473, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_4);
                      }
                      __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      if (likely(__pyx_t_9 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 4;
                        return __pyx_r;
                        __pyx_L33_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6473, __pyx_L27_error)
                        __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                      } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 6473, __pyx_L27_error)
                      }
                      __Pyx_GIVEREF(__pyx_t_4);
                      __pyx_cur_scope->__pyx_v_result_by_flag = __pyx_t_4;
                      __pyx_t_4 = 0;

                      /* "ws_package/controllers/activity_controller.py":6474
 * 
 *                     result_by_flag = await session.execute(query_by_flag)
 *                     idle_intervals_by_flag = result_by_flag.scalars().all()             # <<<<<<<<<<<<<<
 * 
 *                     # Also find intervals with zero activity that might not be marked as is_idle yet
*/
                      __pyx_t_6 = __pyx_cur_scope->__pyx_v_result_by_flag;
                      __Pyx_INCREF(__pyx_t_6);
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
                        __pyx_t_18 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalars, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                        if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 6474, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_18);
                      }
                      __pyx_t_7 = __pyx_t_18;
                      __Pyx_INCREF(__pyx_t_7);
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
                        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_all, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6474, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_4);
                      }
                      __Pyx_GIVEREF(__pyx_t_4);
                      __pyx_cur_scope->__pyx_v_idle_intervals_by_flag = __pyx_t_4;
                      __pyx_t_4 = 0;

                      /* "ws_package/controllers/activity_controller.py":6478
 *                     # Also find intervals with zero activity that might not be marked as is_idle yet
 *                     # Get all intervals for current counter (excluding breaks)
 *                     query_all = select(ActivityInterval).where(             # <<<<<<<<<<<<<<
 *                         ActivityInterval.counter == current_counter,
 *                         ActivityInterval.is_break == 0,
*/
                      __pyx_t_20 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6478, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6478, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __pyx_t_8 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_22))) {
                        __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_22);
                        assert(__pyx_t_20);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_22);
                        __Pyx_INCREF(__pyx_t_20);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_22, __pyx__function);
                        __pyx_t_8 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_20, __pyx_t_21};
                        __pyx_t_19 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_22, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6478, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_19);
                      }
                      __pyx_t_6 = __pyx_t_19;
                      __Pyx_INCREF(__pyx_t_6);

                      /* "ws_package/controllers/activity_controller.py":6479
 *                     # Get all intervals for current counter (excluding breaks)
 *                     query_all = select(ActivityInterval).where(
 *                         ActivityInterval.counter == current_counter,             # <<<<<<<<<<<<<<
 *                         ActivityInterval.is_break == 0,
 *                         ActivityInterval.is_uploaded == False
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6479, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6479, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                      __pyx_t_22 = PyObject_RichCompare(__pyx_t_21, __pyx_cur_scope->__pyx_v_current_counter, Py_EQ); __Pyx_XGOTREF(__pyx_t_22); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6479, __pyx_L27_error)
                      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;

                      /* "ws_package/controllers/activity_controller.py":6480
 *                     query_all = select(ActivityInterval).where(
 *                         ActivityInterval.counter == current_counter,
 *                         ActivityInterval.is_break == 0,             # <<<<<<<<<<<<<<
 *                         ActivityInterval.is_uploaded == False
 *                     ).order_by(desc(ActivityInterval.start_time))
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6480, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_is_break); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6480, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_20);
                      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                      __pyx_t_21 = __Pyx_PyLong_EqObjC(__pyx_t_20, __pyx_mstate_global->__pyx_int_0, 0, 0); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6480, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;

                      /* "ws_package/controllers/activity_controller.py":6481
 *                         ActivityInterval.counter == current_counter,
 *                         ActivityInterval.is_break == 0,
 *                         ActivityInterval.is_uploaded == False             # <<<<<<<<<<<<<<
 *                     ).order_by(desc(ActivityInterval.start_time))
 * 
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6481, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_20);
                      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_is_uploaded); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6481, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_5);
                      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                      __pyx_t_20 = PyObject_RichCompare(__pyx_t_5, Py_False, Py_EQ); __Pyx_XGOTREF(__pyx_t_20); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6481, __pyx_L27_error)
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[4] = {__pyx_t_6, __pyx_t_22, __pyx_t_21, __pyx_t_20};
                        __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6478, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_7);
                      }
                      __pyx_t_18 = __pyx_t_7;
                      __Pyx_INCREF(__pyx_t_18);

                      /* "ws_package/controllers/activity_controller.py":6482
 *                         ActivityInterval.is_break == 0,
 *                         ActivityInterval.is_uploaded == False
 *                     ).order_by(desc(ActivityInterval.start_time))             # <<<<<<<<<<<<<<
 * 
 *                     result_all = await session.execute(query_all)
*/
                      __pyx_t_20 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_desc); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6482, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6482, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6482, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_6);
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                      __pyx_t_8 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_21))) {
                        __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_21);
                        assert(__pyx_t_20);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_21);
                        __Pyx_INCREF(__pyx_t_20);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_21, __pyx__function);
                        __pyx_t_8 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_20, __pyx_t_6};
                        __pyx_t_19 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_21, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6482, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_19);
                      }
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_18, __pyx_t_19};
                        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_order_by, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6482, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_4);
                      }
                      __Pyx_GIVEREF(__pyx_t_4);
                      __pyx_cur_scope->__pyx_v_query_all = __pyx_t_4;
                      __pyx_t_4 = 0;

                      /* "ws_package/controllers/activity_controller.py":6484
 *                     ).order_by(desc(ActivityInterval.start_time))
 * 
 *                     result_all = await session.execute(query_all)             # <<<<<<<<<<<<<<
 *                     all_intervals = result_all.scalars().all()
 * 
*/
                      __pyx_t_7 = __pyx_cur_scope->__pyx_v_session;
                      __Pyx_INCREF(__pyx_t_7);
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_cur_scope->__pyx_v_query_all};
                        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6484, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_4);
                      }
                      __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      if (likely(__pyx_t_9 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 5;
                        return __pyx_r;
                        __pyx_L34_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6484, __pyx_L27_error)
                        __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                      } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 6484, __pyx_L27_error)
                      }
                      __Pyx_GIVEREF(__pyx_t_4);
                      __pyx_cur_scope->__pyx_v_result_all = __pyx_t_4;
                      __pyx_t_4 = 0;

                      /* "ws_package/controllers/activity_controller.py":6485
 * 
 *                     result_all = await session.execute(query_all)
 *                     all_intervals = result_all.scalars().all()             # <<<<<<<<<<<<<<
 * 
 *                     # Find consecutive zero-activity intervals from newest to oldest
*/
                      __pyx_t_18 = __pyx_cur_scope->__pyx_v_result_all;
                      __Pyx_INCREF(__pyx_t_18);
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_18, NULL};
                        __pyx_t_19 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalars, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                        if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6485, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_19);
                      }
                      __pyx_t_7 = __pyx_t_19;
                      __Pyx_INCREF(__pyx_t_7);
                      __pyx_t_8 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
                        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_all, __pyx_callargs+__pyx_t_8, (1-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6485, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_4);
                      }
                      __Pyx_GIVEREF(__pyx_t_4);
                      __pyx_cur_scope->__pyx_v_all_intervals = __pyx_t_4;
                      __pyx_t_4 = 0;

                      /* "ws_package/controllers/activity_controller.py":6488
 * 
 *                     # Find consecutive zero-activity intervals from newest to oldest
 *                     intervals_to_mark = []             # <<<<<<<<<<<<<<
 *                     for interval in all_intervals:
 *                         # Check if interval has zero activity
*/
                      __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6488, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __Pyx_GIVEREF(__pyx_t_4);
                      __pyx_cur_scope->__pyx_v_intervals_to_mark = ((PyObject*)__pyx_t_4);
                      __pyx_t_4 = 0;

                      /* "ws_package/controllers/activity_controller.py":6489
 *                     # Find consecutive zero-activity intervals from newest to oldest
 *                     intervals_to_mark = []
 *                     for interval in all_intervals:             # <<<<<<<<<<<<<<
 *                         # Check if interval has zero activity
 *                         has_zero_activity = await self._has_zero_activity_for_interval(interval.start_time, interval.end_time)
*/
                      if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_all_intervals)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_all_intervals)) {
                        __pyx_t_4 = __pyx_cur_scope->__pyx_v_all_intervals; __Pyx_INCREF(__pyx_t_4);
                        __pyx_t_24 = 0;
                        __pyx_t_25 = NULL;
                      } else {
                        __pyx_t_24 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_all_intervals); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6489, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_4);
                        __pyx_t_25 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_4); if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 6489, __pyx_L27_error)
                      }
                      for (;;) {
                        if (likely(!__pyx_t_25)) {
                          if (likely(PyList_CheckExact(__pyx_t_4))) {
                            {
                              Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_4);
                              #if !CYTHON_ASSUME_SAFE_SIZE
                              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6489, __pyx_L27_error)
                              #endif
                              if (__pyx_t_24 >= __pyx_temp) break;
                            }
                            __pyx_t_19 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_4, __pyx_t_24, __Pyx_ReferenceSharing_OwnStrongReference);
                            ++__pyx_t_24;
                          } else {
                            {
                              Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_4);
                              #if !CYTHON_ASSUME_SAFE_SIZE
                              if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6489, __pyx_L27_error)
                              #endif
                              if (__pyx_t_24 >= __pyx_temp) break;
                            }
                            #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                            __pyx_t_19 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_24));
                            #else
                            __pyx_t_19 = __Pyx_PySequence_ITEM(__pyx_t_4, __pyx_t_24);
                            #endif
                            ++__pyx_t_24;
                          }
                          if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6489, __pyx_L27_error)
                        } else {
                          __pyx_t_19 = __pyx_t_25(__pyx_t_4);
                          if (unlikely(!__pyx_t_19)) {
                            PyObject* exc_type = PyErr_Occurred();
                            if (exc_type) {
                              if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 6489, __pyx_L27_error)
                              PyErr_Clear();
                            }
                            break;
                          }
                        }
                        __Pyx_GOTREF(__pyx_t_19);
                        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
                        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_19);
                        __Pyx_GIVEREF(__pyx_t_19);
                        __pyx_t_19 = 0;

                        /* "ws_package/controllers/activity_controller.py":6491
 *                     for interval in all_intervals:
 *                         # Check if interval has zero activity
 *                         has_zero_activity = await self._has_zero_activity_for_interval(interval.start_time, interval.end_time)             # <<<<<<<<<<<<<<
 * 
 *                         if has_zero_activity:
*/
                        __pyx_t_7 = __pyx_cur_scope->__pyx_v_self;
                        __Pyx_INCREF(__pyx_t_7);
                        __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 6491, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_18);
                        __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6491, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_21);
                        __pyx_t_8 = 0;
                        {
                          PyObject *__pyx_callargs[3] = {__pyx_t_7, __pyx_t_18, __pyx_t_21};
                          __pyx_t_19 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_has_zero_activity_for_interval, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                          __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                          if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6491, __pyx_L27_error)
                          __Pyx_GOTREF(__pyx_t_19);
                        }
                        __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_19, &__pyx_r);
                        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                        if (likely(__pyx_t_9 == PYGEN_NEXT)) {
                          __Pyx_GOTREF(__pyx_r);
                          __Pyx_XGIVEREF(__pyx_t_1);
                          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                          __Pyx_XGIVEREF(__pyx_t_2);
                          __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                          __Pyx_XGIVEREF(__pyx_t_3);
                          __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                          __Pyx_XGIVEREF(__pyx_t_4);
                          __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
                          __Pyx_XGIVEREF(__pyx_t_10);
                          __pyx_cur_scope->__pyx_t_4 = __pyx_t_10;
                          __Pyx_XGIVEREF(__pyx_t_11);
                          __pyx_cur_scope->__pyx_t_5 = __pyx_t_11;
                          __Pyx_XGIVEREF(__pyx_t_12);
                          __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
                          __Pyx_XGIVEREF(__pyx_t_13);
                          __pyx_cur_scope->__pyx_t_7 = __pyx_t_13;
                          __Pyx_XGIVEREF(__pyx_t_14);
                          __pyx_cur_scope->__pyx_t_8 = __pyx_t_14;
                          __Pyx_XGIVEREF(__pyx_t_15);
                          __pyx_cur_scope->__pyx_t_9 = __pyx_t_15;
                          __Pyx_XGIVEREF(__pyx_t_16);
                          __pyx_cur_scope->__pyx_t_10 = __pyx_t_16;
                          __Pyx_XGIVEREF(__pyx_t_17);
                          __pyx_cur_scope->__pyx_t_11 = __pyx_t_17;
                          __pyx_cur_scope->__pyx_t_12 = __pyx_t_24;
                          __pyx_cur_scope->__pyx_t_13 = __pyx_t_25;
                          __Pyx_XGIVEREF(__pyx_r);
                          __Pyx_RefNannyFinishContext();
                          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                          /* return from generator, awaiting value */
                          __pyx_generator->resume_label = 6;
                          return __pyx_r;
                          __pyx_L37_resume_from_await:;
                          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                          __pyx_cur_scope->__pyx_t_0 = 0;
                          __Pyx_XGOTREF(__pyx_t_1);
                          __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                          __pyx_cur_scope->__pyx_t_1 = 0;
                          __Pyx_XGOTREF(__pyx_t_2);
                          __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                          __pyx_cur_scope->__pyx_t_2 = 0;
                          __Pyx_XGOTREF(__pyx_t_3);
                          __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
                          __pyx_cur_scope->__pyx_t_3 = 0;
                          __Pyx_XGOTREF(__pyx_t_4);
                          __pyx_t_10 = __pyx_cur_scope->__pyx_t_4;
                          __pyx_cur_scope->__pyx_t_4 = 0;
                          __Pyx_XGOTREF(__pyx_t_10);
                          __pyx_t_11 = __pyx_cur_scope->__pyx_t_5;
                          __pyx_cur_scope->__pyx_t_5 = 0;
                          __Pyx_XGOTREF(__pyx_t_11);
                          __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
                          __pyx_cur_scope->__pyx_t_6 = 0;
                          __Pyx_XGOTREF(__pyx_t_12);
                          __pyx_t_13 = __pyx_cur_scope->__pyx_t_7;
                          __pyx_cur_scope->__pyx_t_7 = 0;
                          __Pyx_XGOTREF(__pyx_t_13);
                          __pyx_t_14 = __pyx_cur_scope->__pyx_t_8;
                          __pyx_cur_scope->__pyx_t_8 = 0;
                          __Pyx_XGOTREF(__pyx_t_14);
                          __pyx_t_15 = __pyx_cur_scope->__pyx_t_9;
                          __pyx_cur_scope->__pyx_t_9 = 0;
                          __Pyx_XGOTREF(__pyx_t_15);
                          __pyx_t_16 = __pyx_cur_scope->__pyx_t_10;
                          __pyx_cur_scope->__pyx_t_10 = 0;
                          __Pyx_XGOTREF(__pyx_t_16);
                          __pyx_t_17 = __pyx_cur_scope->__pyx_t_11;
                          __pyx_cur_scope->__pyx_t_11 = 0;
                          __Pyx_XGOTREF(__pyx_t_17);
                          __pyx_t_24 = __pyx_cur_scope->__pyx_t_12;
                          __pyx_t_25 = __pyx_cur_scope->__pyx_t_13;
                          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6491, __pyx_L27_error)
                          __pyx_t_19 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_19);
                        } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
                          __Pyx_GOTREF(__pyx_r);
                          __pyx_t_19 = __pyx_r; __pyx_r = NULL;
                        } else {
                          __Pyx_XGOTREF(__pyx_r);
                          __PYX_ERR(0, 6491, __pyx_L27_error)
                        }
                        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_has_zero_activity);
                        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_has_zero_activity, __pyx_t_19);
                        __Pyx_GIVEREF(__pyx_t_19);
                        __pyx_t_19 = 0;

                        /* "ws_package/controllers/activity_controller.py":6493
 *                         has_zero_activity = await self._has_zero_activity_for_interval(interval.start_time, interval.end_time)
 * 
 *                         if has_zero_activity:             # <<<<<<<<<<<<<<
 *                             # Include if not already in the list
 *                             if interval not in intervals_to_mark:
*/
                        __pyx_t_26 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_has_zero_activity); if (unlikely((__pyx_t_26 < 0))) __PYX_ERR(0, 6493, __pyx_L27_error)
                        if (__pyx_t_26) {

                          /* "ws_package/controllers/activity_controller.py":6495
 *                         if has_zero_activity:
 *                             # Include if not already in the list
 *                             if interval not in intervals_to_mark:             # <<<<<<<<<<<<<<
 *                                 intervals_to_mark.append(interval)
 *                         else:
*/
                          __pyx_t_26 = (__Pyx_PySequence_ContainsTF(__pyx_cur_scope->__pyx_v_interval, __pyx_cur_scope->__pyx_v_intervals_to_mark, Py_NE)); if (unlikely((__pyx_t_26 < 0))) __PYX_ERR(0, 6495, __pyx_L27_error)
                          if (__pyx_t_26) {

                            /* "ws_package/controllers/activity_controller.py":6496
 *                             # Include if not already in the list
 *                             if interval not in intervals_to_mark:
 *                                 intervals_to_mark.append(interval)             # <<<<<<<<<<<<<<
 *                         else:
 *                             # Found activity - stop checking further intervals
*/
                            __pyx_t_27 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_intervals_to_mark, __pyx_cur_scope->__pyx_v_interval); if (unlikely(__pyx_t_27 == ((int)-1))) __PYX_ERR(0, 6496, __pyx_L27_error)

                            /* "ws_package/controllers/activity_controller.py":6495
 *                         if has_zero_activity:
 *                             # Include if not already in the list
 *                             if interval not in intervals_to_mark:             # <<<<<<<<<<<<<<
 *                                 intervals_to_mark.append(interval)
 *                         else:
*/
                          }

                          /* "ws_package/controllers/activity_controller.py":6493
 *                         has_zero_activity = await self._has_zero_activity_for_interval(interval.start_time, interval.end_time)
 * 
 *                         if has_zero_activity:             # <<<<<<<<<<<<<<
 *                             # Include if not already in the list
 *                             if interval not in intervals_to_mark:
*/
                          goto __pyx_L38;
                        }

                        /* "ws_package/controllers/activity_controller.py":6499
 *                         else:
 *                             # Found activity - stop checking further intervals
 *                             break             # <<<<<<<<<<<<<<
 * 
 *                     # Combine both sets (remove duplicates)
*/
                        /*else*/ {
                          goto __pyx_L36_break;
                        }
                        __pyx_L38:;

                        /* "ws_package/controllers/activity_controller.py":6489
 *                     # Find consecutive zero-activity intervals from newest to oldest
 *                     intervals_to_mark = []
 *                     for interval in all_intervals:             # <<<<<<<<<<<<<<
 *                         # Check if interval has zero activity
 *                         has_zero_activity = await self._has_zero_activity_for_interval(interval.start_time, interval.end_time)
*/
                      }
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      goto __pyx_L40_for_end;
                      __pyx_L36_break:;
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      goto __pyx_L40_for_end;
                      __pyx_L40_for_end:;

                      /* "ws_package/controllers/activity_controller.py":6502
 * 
 *                     # Combine both sets (remove duplicates)
 *                     idle_intervals = list(set(idle_intervals_by_flag + intervals_to_mark))             # <<<<<<<<<<<<<<
 * 
 *                     # Debug logging
*/
                      __pyx_t_4 = PyNumber_Add(__pyx_cur_scope->__pyx_v_idle_intervals_by_flag, __pyx_cur_scope->__pyx_v_intervals_to_mark); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6502, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __pyx_t_19 = PySet_New(__pyx_t_4); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6502, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_19);
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __pyx_t_4 = PySequence_List(__pyx_t_19); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6502, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                      __Pyx_GIVEREF(__pyx_t_4);
                      __pyx_cur_scope->__pyx_v_idle_intervals = ((PyObject*)__pyx_t_4);
                      __pyx_t_4 = 0;

                      /* "ws_package/controllers/activity_controller.py":6505
 * 
 *                     # Debug logging
 *                     logger.info("[DEBUG] _save_note_to_idle_intervals: Found %s intervals with is_idle=True, %s intervals with zero activity, %s total unique idle intervals", len(idle_intervals_by_flag), len(intervals_to_mark), len(idle_intervals))             # <<<<<<<<<<<<<<
 * 
 *                     if not idle_intervals:
*/
                      __pyx_t_19 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6505, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 6505, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_18);
                      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                      __pyx_t_24 = PyObject_Length(__pyx_cur_scope->__pyx_v_idle_intervals_by_flag); if (unlikely(__pyx_t_24 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6505, __pyx_L27_error)
                      __pyx_t_21 = PyLong_FromSsize_t(__pyx_t_24); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6505, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __pyx_t_24 = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_intervals_to_mark); if (unlikely(__pyx_t_24 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6505, __pyx_L27_error)
                      __pyx_t_7 = PyLong_FromSsize_t(__pyx_t_24); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6505, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_7);
                      __pyx_t_24 = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_idle_intervals); if (unlikely(__pyx_t_24 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6505, __pyx_L27_error)
                      __pyx_t_6 = PyLong_FromSsize_t(__pyx_t_24); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6505, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_6);
                      __pyx_t_8 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_18))) {
                        __pyx_t_19 = PyMethod_GET_SELF(__pyx_t_18);
                        assert(__pyx_t_19);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_18);
                        __Pyx_INCREF(__pyx_t_19);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_18, __pyx__function);
                        __pyx_t_8 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[5] = {__pyx_t_19, __pyx_mstate_global->__pyx_kp_u_DEBUG__save_note_to_idle_interv, __pyx_t_21, __pyx_t_7, __pyx_t_6};
                        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_18, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6505, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_4);
                      }
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                      /* "ws_package/controllers/activity_controller.py":6507
 *                     logger.info("[DEBUG] _save_note_to_idle_intervals: Found %s intervals with is_idle=True, %s intervals with zero activity, %s total unique idle intervals", len(idle_intervals_by_flag), len(intervals_to_mark), len(idle_intervals))
 * 
 *                     if not idle_intervals:             # <<<<<<<<<<<<<<
 *                         logger.info("No idle intervals found to save note")
 *                         return
*/
                      {
                        Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_idle_intervals);
                        if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 6507, __pyx_L27_error)
                        __pyx_t_26 = (__pyx_temp != 0);
                      }

                      __pyx_t_28 = (!__pyx_t_26);
                      if (__pyx_t_28) {

                        /* "ws_package/controllers/activity_controller.py":6508
 * 
 *                     if not idle_intervals:
 *                         logger.info("No idle intervals found to save note")             # <<<<<<<<<<<<<<
 *                         return
 * 
*/
                        __pyx_t_18 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6508, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_6);
                        __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6508, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_7);
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __pyx_t_8 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_7))) {
                          __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_7);
                          assert(__pyx_t_18);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                          __Pyx_INCREF(__pyx_t_18);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                          __pyx_t_8 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_18, __pyx_mstate_global->__pyx_kp_u_No_idle_intervals_found_to_save};
                          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (2-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6508, __pyx_L27_error)
                          __Pyx_GOTREF(__pyx_t_4);
                        }
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                        /* "ws_package/controllers/activity_controller.py":6509
 *                     if not idle_intervals:
 *                         logger.info("No idle intervals found to save note")
 *                         return             # <<<<<<<<<<<<<<
 * 
 *                     logger.info("Found %s idle intervals to save note: %s, file_path: %s", len(idle_intervals), note, file_path)
*/
                        __Pyx_XDECREF(__pyx_r);
                        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
                        goto __pyx_L31_try_return;

                        /* "ws_package/controllers/activity_controller.py":6507
 *                     logger.info("[DEBUG] _save_note_to_idle_intervals: Found %s intervals with is_idle=True, %s intervals with zero activity, %s total unique idle intervals", len(idle_intervals_by_flag), len(intervals_to_mark), len(idle_intervals))
 * 
 *                     if not idle_intervals:             # <<<<<<<<<<<<<<
 *                         logger.info("No idle intervals found to save note")
 *                         return
*/
                      }

                      /* "ws_package/controllers/activity_controller.py":6511
 *                         return
 * 
 *                     logger.info("Found %s idle intervals to save note: %s, file_path: %s", len(idle_intervals), note, file_path)             # <<<<<<<<<<<<<<
 * 
 *                     # Collect all interval IDs
*/
                      __pyx_t_7 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 6511, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_18);
                      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6511, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_6);
                      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                      __pyx_t_24 = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_idle_intervals); if (unlikely(__pyx_t_24 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6511, __pyx_L27_error)
                      __pyx_t_18 = PyLong_FromSsize_t(__pyx_t_24); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 6511, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_18);
                      __pyx_t_8 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_6))) {
                        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
                        assert(__pyx_t_7);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                        __Pyx_INCREF(__pyx_t_7);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                        __pyx_t_8 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[5] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Found_s_idle_intervals_to_save_n, __pyx_t_18, __pyx_cur_scope->__pyx_v_note, __pyx_cur_scope->__pyx_v_file_path};
                        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6511, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_4);
                      }
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                      /* "ws_package/controllers/activity_controller.py":6514
 * 
 *                     # Collect all interval IDs
 *                     interval_ids = [interval.id for interval in idle_intervals]             # <<<<<<<<<<<<<<
 * 
 *                     # Prepare note data with optional file_path
*/
                      { /* enter inner scope */
                        __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6514, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_4);
                        __pyx_t_6 = __pyx_cur_scope->__pyx_v_idle_intervals; __Pyx_INCREF(__pyx_t_6);
                        __pyx_t_24 = 0;
                        for (;;) {
                          {
                            Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_6);
                            #if !CYTHON_ASSUME_SAFE_SIZE
                            if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6514, __pyx_L27_error)
                            #endif
                            if (__pyx_t_24 >= __pyx_temp) break;
                          }
                          __pyx_t_18 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_6, __pyx_t_24, __Pyx_ReferenceSharing_OwnStrongReference);
                          ++__pyx_t_24;
                          if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 6514, __pyx_L27_error)
                          __Pyx_GOTREF(__pyx_t_18);
                          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_9genexpr26__pyx_v_interval);
                          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_9genexpr26__pyx_v_interval, __pyx_t_18);
                          __Pyx_GIVEREF(__pyx_t_18);
                          __pyx_t_18 = 0;
                          __pyx_t_18 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_9genexpr26__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 6514, __pyx_L27_error)
                          __Pyx_GOTREF(__pyx_t_18);
                          if (unlikely(__Pyx_ListComp_Append(__pyx_t_4, (PyObject*)__pyx_t_18))) __PYX_ERR(0, 6514, __pyx_L27_error)
                          __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                        }
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                      } /* exit inner scope */
                      __Pyx_GIVEREF(__pyx_t_4);
                      __pyx_cur_scope->__pyx_v_interval_ids = ((PyObject*)__pyx_t_4);
                      __pyx_t_4 = 0;

                      /* "ws_package/controllers/activity_controller.py":6518
 *                     # Prepare note data with optional file_path
 *                     note_data = {
 *                         "activity_interval_id": interval_ids,             # <<<<<<<<<<<<<<
 *                         "note": note
 *                     }
*/
                      __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6518, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_activity_interval_id, __pyx_cur_scope->__pyx_v_interval_ids) < (0)) __PYX_ERR(0, 6518, __pyx_L27_error)

                      /* "ws_package/controllers/activity_controller.py":6519
 *                     note_data = {
 *                         "activity_interval_id": interval_ids,
 *                         "note": note             # <<<<<<<<<<<<<<
 *                     }
 *                     if file_path:
*/
                      if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_note, __pyx_cur_scope->__pyx_v_note) < (0)) __PYX_ERR(0, 6518, __pyx_L27_error)
                      __Pyx_GIVEREF(__pyx_t_4);
                      __pyx_cur_scope->__pyx_v_note_data = ((PyObject*)__pyx_t_4);
                      __pyx_t_4 = 0;

                      /* "ws_package/controllers/activity_controller.py":6521
 *                         "note": note
 *                     }
 *                     if file_path:             # <<<<<<<<<<<<<<
 *                         note_data["file_path"] = file_path
 * 
*/
                      if (__pyx_cur_scope->__pyx_v_file_path == Py_None) __pyx_t_28 = 0;
                      else
                      {
                        Py_ssize_t __pyx_temp = __Pyx_PyUnicode_IS_TRUE(__pyx_cur_scope->__pyx_v_file_path);
                        if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 6521, __pyx_L27_error)
                        __pyx_t_28 = (__pyx_temp != 0);
                      }

                      if (__pyx_t_28) {

                        /* "ws_package/controllers/activity_controller.py":6522
 *                     }
 *                     if file_path:
 *                         note_data["file_path"] = file_path             # <<<<<<<<<<<<<<
 * 
 *                     # Queue the insert operation
*/
                        if (unlikely((PyDict_SetItem(__pyx_cur_scope->__pyx_v_note_data, __pyx_mstate_global->__pyx_n_u_file_path, __pyx_cur_scope->__pyx_v_file_path) < 0))) __PYX_ERR(0, 6522, __pyx_L27_error)

                        /* "ws_package/controllers/activity_controller.py":6521
 *                         "note": note
 *                     }
 *                     if file_path:             # <<<<<<<<<<<<<<
 *                         note_data["file_path"] = file_path
 * 
*/
                      }

                      /* "ws_package/controllers/activity_controller.py":6525
 * 
 *                     # Queue the insert operation
 *                     db_write_queue.enqueue(             # <<<<<<<<<<<<<<
 *                         WriteOperationType.NOTES,
 *                         "notes",
*/
                      __pyx_t_6 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_db_write_queue); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 6525, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_18);
                      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_enqueue); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6525, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_7);
                      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

                      /* "ws_package/controllers/activity_controller.py":6526
 *                     # Queue the insert operation
 *                     db_write_queue.enqueue(
 *                         WriteOperationType.NOTES,             # <<<<<<<<<<<<<<
 *                         "notes",
 *                         note_data
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_WriteOperationType); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 6526, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_18);
                      __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_18, __pyx_mstate_global->__pyx_n_u_NOTES); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6526, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;

                      /* "ws_package/controllers/activity_controller.py":6528
 *                         WriteOperationType.NOTES,
 *                         "notes",
 *                         note_data             # <<<<<<<<<<<<<<
 *                     )
 * 
*/
                      __pyx_t_8 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_7))) {
                        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
                        assert(__pyx_t_6);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                        __Pyx_INCREF(__pyx_t_6);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                        __pyx_t_8 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[4] = {__pyx_t_6, __pyx_t_21, __pyx_mstate_global->__pyx_n_u_notes_2, __pyx_cur_scope->__pyx_v_note_data};
                        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_8, (4-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6525, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_4);
                      }
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                      /* "ws_package/controllers/activity_controller.py":6531
 *                     )
 * 
 *                     logger.info("Queued Notes entry with %s interval IDs: %s, file_path: %s", len(interval_ids), interval_ids, file_path)             # <<<<<<<<<<<<<<
 * 
 *         except Exception as e:
*/
                      __pyx_t_7 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6531, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6531, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_6);
                      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                      __pyx_t_24 = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_interval_ids); if (unlikely(__pyx_t_24 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6531, __pyx_L27_error)
                      __pyx_t_21 = PyLong_FromSsize_t(__pyx_t_24); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6531, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __pyx_t_8 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_6))) {
                        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
                        assert(__pyx_t_7);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                        __Pyx_INCREF(__pyx_t_7);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                        __pyx_t_8 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[5] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Queued_Notes_entry_with_s_interv, __pyx_t_21, __pyx_cur_scope->__pyx_v_interval_ids, __pyx_cur_scope->__pyx_v_file_path};
                        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_8, (5-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6531, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_4);
                      }
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                      /* "ws_package/controllers/activity_controller.py":6464
 * 
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     # First, try to find intervals by is_idle flag (if they've been marked)
 *                     query_by_flag = select(ActivityInterval).where(
*/
                    }
                    __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
                    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                    goto __pyx_L32_try_end;
                    __pyx_L27_error:;
                    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                    /*except:*/ {
                      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._save_note_to_idle_intervals", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_21) < 0) __PYX_ERR(0, 6464, __pyx_L29_except_error)
                      __Pyx_XGOTREF(__pyx_t_4);
                      __Pyx_XGOTREF(__pyx_t_6);
                      __Pyx_XGOTREF(__pyx_t_21);
                      __pyx_t_7 = PyTuple_Pack(3, __pyx_t_4, __pyx_t_6, __pyx_t_21); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6464, __pyx_L29_except_error)
                      __Pyx_GOTREF(__pyx_t_7);
                      __pyx_t_29 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_t_7, NULL);
                      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                      if (unlikely(!__pyx_t_29)) __PYX_ERR(0, 6464, __pyx_L29_except_error)
                      __Pyx_GOTREF(__pyx_t_29);
                      __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_29, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
                      if (likely(__pyx_t_9 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_4);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
                        __Pyx_XGIVEREF(__pyx_t_6);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_6;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_11 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_14 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __pyx_cur_scope->__pyx_t_15 = __pyx_t_21;
                        __Pyx_XGIVEREF(__pyx_t_29);
                        __pyx_cur_scope->__pyx_t_16 = __pyx_t_29;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_SwapException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 7;
                        return __pyx_r;
                        __pyx_L49_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_4);
                        __pyx_t_6 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_6);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_11;
                        __pyx_cur_scope->__pyx_t_11 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_14;
                        __pyx_cur_scope->__pyx_t_14 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_21 = __pyx_cur_scope->__pyx_t_15;
                        __pyx_cur_scope->__pyx_t_15 = 0;
                        __Pyx_XGOTREF(__pyx_t_21);
                        __pyx_t_29 = __pyx_cur_scope->__pyx_t_16;
                        __pyx_cur_scope->__pyx_t_16 = 0;
                        __Pyx_XGOTREF(__pyx_t_29);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6464, __pyx_L29_except_error)
                        __pyx_t_7 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_7);
                      } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_7 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 6464, __pyx_L29_except_error)
                      }
                      __pyx_t_29 = __pyx_t_7;
                      __pyx_t_7 = 0;
                      __pyx_t_28 = __Pyx_PyObject_IsTrue(__pyx_t_29);
                      __Pyx_DECREF(__pyx_t_29); __pyx_t_29 = 0;
                      if (__pyx_t_28 < (0)) __PYX_ERR(0, 6464, __pyx_L29_except_error)
                      __pyx_t_26 = (!__pyx_t_28);
                      if (unlikely(__pyx_t_26)) {
                        __Pyx_GIVEREF(__pyx_t_4);
                        __Pyx_GIVEREF(__pyx_t_6);
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __Pyx_ErrRestoreWithState(__pyx_t_4, __pyx_t_6, __pyx_t_21);
                        __pyx_t_4 = 0;  __pyx_t_6 = 0;  __pyx_t_21 = 0; 
                        __PYX_ERR(0, 6464, __pyx_L29_except_error)
                      }
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                      __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                      goto __pyx_L28_exception_handled;
                    }
                    __pyx_L29_except_error:;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
                    goto __pyx_L16_error;
                    __pyx_L31_try_return:;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
                    goto __pyx_L24_return;
                    __pyx_L28_exception_handled:;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
                    __pyx_L32_try_end:;
                  }
                }
                /*finally:*/ {
                  /*normal exit:*/{
                    if (__pyx_t_14) {
                      __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_mstate_global->__pyx_tuple[7], NULL);
                      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                      if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6464, __pyx_L16_error)
                      __Pyx_GOTREF(__pyx_t_17);
                      __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_17, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                      if (likely(__pyx_t_9 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 8;
                        return __pyx_r;
                        __pyx_L50_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6464, __pyx_L16_error)
                        __pyx_t_21 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_21);
                      } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_21 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 6464, __pyx_L16_error)
                      }
                      __pyx_t_17 = __pyx_t_21;
                      __pyx_t_21 = 0;
                      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                    }
                    goto __pyx_L26;
                  }
                  __pyx_L24_return: {
                    __pyx_t_17 = __pyx_r;
                    __pyx_r = 0;
                    if (__pyx_t_14) {
                      __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_14, __pyx_mstate_global->__pyx_tuple[7], NULL);
                      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                      if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 6464, __pyx_L16_error)
                      __Pyx_GOTREF(__pyx_t_16);
                      __pyx_t_9 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_16, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                      if (likely(__pyx_t_9 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_10);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 9;
                        return __pyx_r;
                        __pyx_L51_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_10);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6464, __pyx_L16_error)
                        __pyx_t_21 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_21);
                      } else if (likely(__pyx_t_9 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_21 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 6464, __pyx_L16_error)
                      }
                      __pyx_t_16 = __pyx_t_21;
                      __pyx_t_21 = 0;
                      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                    }
                    __pyx_r = __pyx_t_17;
                    __pyx_t_17 = 0;
                    goto __pyx_L20_try_return;
                  }
                  __pyx_L26:;
                }
                goto __pyx_L52;
                __pyx_L22_error:;
                __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
                goto __pyx_L16_error;
                __pyx_L52:;
              }

              /* "ws_package/controllers/activity_controller.py":6463
 *             current_counter = self.last_count + 1
 * 
 *             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     # First, try to find intervals by is_idle flag (if they've been marked)
*/
            }
            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            goto __pyx_L21_try_end;
            __pyx_L16_error:;
            __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
            __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
            __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
            __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
            __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            /*except:*/ {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._save_note_to_idle_intervals", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_21, &__pyx_t_6, &__pyx_t_4) < 0) __PYX_ERR(0, 6463, __pyx_L18_except_error)
              __Pyx_XGOTREF(__pyx_t_21);
              __Pyx_XGOTREF(__pyx_t_6);
              __Pyx_XGOTREF(__pyx_t_4);
              __pyx_t_7 = PyTuple_Pack(3, __pyx_t_21, __pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6463, __pyx_L18_except_error)
              __Pyx_GOTREF(__pyx_t_7);
              __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_t_7, NULL);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
              if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 6463, __pyx_L18_except_error)
              __Pyx_GOTREF(__pyx_t_14);
              __pyx_t_26 = __Pyx_PyObject_IsTrue(__pyx_t_14);
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
              if (__pyx_t_26 < (0)) __PYX_ERR(0, 6463, __pyx_L18_except_error)
              __pyx_t_28 = (!__pyx_t_26);
              if (unlikely(__pyx_t_28)) {
                __Pyx_GIVEREF(__pyx_t_21);
                __Pyx_GIVEREF(__pyx_t_6);
                __Pyx_XGIVEREF(__pyx_t_4);
                __Pyx_ErrRestoreWithState(__pyx_t_21, __pyx_t_6, __pyx_t_4);
                __pyx_t_21 = 0;  __pyx_t_6 = 0;  __pyx_t_4 = 0; 
                __PYX_ERR(0, 6463, __pyx_L18_except_error)
              }
              __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
              __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              goto __pyx_L17_exception_handled;
            }
            __pyx_L18_except_error:;
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
            goto __pyx_L4_error;
            __pyx_L20_try_return:;
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
            goto __pyx_L13_return;
            __pyx_L17_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_11);
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_12, __pyx_t_13);
            __pyx_L21_try_end:;
          }
        }
        /*finally:*/ {
          /*normal exit:*/{
            if (__pyx_t_10) {
              __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_mstate_global->__pyx_tuple[7], NULL);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 6463, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_13);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            }
            goto __pyx_L15;
          }
          __pyx_L13_return: {
            __pyx_t_13 = __pyx_r;
            __pyx_r = 0;
            if (__pyx_t_10) {
              __pyx_t_12 = __Pyx_PyObject_Call(__pyx_t_10, __pyx_mstate_global->__pyx_tuple[7], NULL);
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 6463, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_12);
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
            }
            __pyx_r = __pyx_t_13;
            __pyx_t_13 = 0;
            goto __pyx_L8_try_return;
          }
          __pyx_L15:;
        }
        goto __pyx_L56;
        __pyx_L12_error:;
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        goto __pyx_L4_error;
        __pyx_L56:;
      }

      /* "ws_package/controllers/activity_controller.py":6456
 *             file_path: Optional S3 URL of uploaded file
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # Flush queue first
 *             await db_writer_service.process_immediately()
*/
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L9_try_end;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "ws_package/controllers/activity_controller.py":6533
 *                     logger.info("Queued Notes entry with %s interval IDs: %s, file_path: %s", len(interval_ids), interval_ids, file_path)
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error saving note to Notes table: %s", e, exc_info=True)
 * 
*/
    __pyx_t_30 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_30) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._save_note_to_idle_intervals", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_6, &__pyx_t_21) < 0) __PYX_ERR(0, 6533, __pyx_L6_except_error)
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_XGOTREF(__pyx_t_6);
      __Pyx_XGOTREF(__pyx_t_21);
      __Pyx_INCREF(__pyx_t_6);
      __Pyx_GIVEREF(__pyx_t_6);
      __pyx_cur_scope->__pyx_v_e = __pyx_t_6;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":6534
 * 
 *         except Exception as e:
 *             logger.error("Error saving note to Notes table: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 *     async def _save_note_to_current_interval(self, note: str, file_path: Optional[str] = None):
*/
        __pyx_t_18 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6534, __pyx_L62_error)
        __Pyx_GOTREF(__pyx_t_19);
        __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6534, __pyx_L62_error)
        __Pyx_GOTREF(__pyx_t_20);
        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
        __pyx_t_8 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_20))) {
          __pyx_t_18 = PyMethod_GET_SELF(__pyx_t_20);
          assert(__pyx_t_18);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_20);
          __Pyx_INCREF(__pyx_t_18);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_20, __pyx__function);
          __pyx_t_8 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_18, __pyx_mstate_global->__pyx_kp_u_Error_saving_note_to_Notes_table, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_19 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6534, __pyx_L62_error)
          __Pyx_GOTREF(__pyx_t_19);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_19, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 6534, __pyx_L62_error)
          __pyx_t_7 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_20, __pyx_callargs+__pyx_t_8, (3-__pyx_t_8) | (__pyx_t_8*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_19);
          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6534, __pyx_L62_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      }

      /* "ws_package/controllers/activity_controller.py":6533
 *                     logger.info("Queued Notes entry with %s interval IDs: %s, file_path: %s", len(interval_ids), interval_ids, file_path)
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error saving note to Notes table: %s", e, exc_info=True)
 * 
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          goto __pyx_L63;
        }
        __pyx_L62_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_10 = 0; __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_14 = 0; __pyx_t_17 = 0;
          __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
          __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
          __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
          __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_11, &__pyx_t_14, &__pyx_t_17);
          if ( unlikely(__Pyx_GetException(&__pyx_t_10, &__pyx_t_13, &__pyx_t_12) < 0)) __Pyx_ErrFetch(&__pyx_t_10, &__pyx_t_13, &__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_10);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_17);
          __pyx_t_30 = __pyx_lineno; __pyx_t_31 = __pyx_clineno; __pyx_t_32 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_XGIVEREF(__pyx_t_17);
          __Pyx_ExceptionReset(__pyx_t_11, __pyx_t_14, __pyx_t_17);
          __Pyx_XGIVEREF(__pyx_t_10);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ErrRestore(__pyx_t_10, __pyx_t_13, __pyx_t_12);
          __pyx_t_10 = 0; __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0; __pyx_t_14 = 0; __pyx_t_17 = 0;
          __pyx_lineno = __pyx_t_30; __pyx_clineno = __pyx_t_31; __pyx_filename = __pyx_t_32;
          goto __pyx_L6_except_error;
        }
        __pyx_L63:;
      }
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
      __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
      goto __pyx_L5_exception_handled;
    }
    goto __pyx_L6_except_error;

    /* "ws_package/controllers/activity_controller.py":6456
 *             file_path: Optional S3 URL of uploaded file
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # Flush queue first
 *             await db_writer_service.process_immediately()
*/
    __pyx_L6_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L5_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    __pyx_L9_try_end:;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":6447
 *             return None
 * 
 *     async def _save_note_to_idle_intervals(self, note: str, file_path: Optional[str] = None):             # <<<<<<<<<<<<<<
 *         """
 *         Save note to Notes table with array of idle interval IDs.
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_18);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_XDECREF(__pyx_t_23);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("_save_note_to_idle_intervals", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_220generator48(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":6536
 *             logger.error("Error saving note to Notes table: %s", e, exc_info=True)
 * 
 *     async def _save_note_to_current_interval(self, note: str, file_path: Optional[str] = None):             # <<<<<<<<<<<<<<
 *         """
 *         Save note to Notes table with current running interval ID.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_219_save_note_to_current_interval(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_218_save_note_to_current_interval, "\n        Save note to Notes table with current running interval ID.\n        This is called when user adds a note while timer is running.\n        \n        Args:\n            note: Note text to save\n            file_path: Optional S3 URL of uploaded file\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_219_save_note_to_current_interval = {"_save_note_to_current_interval", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_219_save_note_to_current_interval, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_218_save_note_to_current_interval};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_219_save_note_to_current_interval(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_note = 0;
  PyObject *__pyx_v_file_path = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_save_note_to_current_interval (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_note,&__pyx_mstate_global->__pyx_n_u_file_path,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 6536, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 6536, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 6536, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 6536, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_save_note_to_current_interval", 0) < (0)) __PYX_ERR(0, 6536, __pyx_L3_error)
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject*)Py_None));
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_save_note_to_current_interval", 0, 2, 3, i); __PYX_ERR(0, 6536, __pyx_L3_error) }
      }
    } else {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 6536, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 6536, __pyx_L3_error)
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 6536, __pyx_L3_error)
        break;
        default: goto __pyx_L5_argtuple_error;
      }
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject*)Py_None));
    }
    __pyx_v_self = values[0];
    __pyx_v_note = ((PyObject*)values[1]);
    __pyx_v_file_path = ((PyObject*)values[2]);
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_save_note_to_current_interval", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 6536, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._save_note_to_current_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_note), (&PyUnicode_Type), 0, "note", 2))) __PYX_ERR(0, 6536, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_file_path), (&PyUnicode_Type), 1, "file_path", 2))) __PYX_ERR(0, 6536, __pyx_L1_error)
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_218_save_note_to_current_interval(__pyx_self, __pyx_v_self, __pyx_v_note, __pyx_v_file_path);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  goto __pyx_L7_cleaned_up;
  __pyx_L0:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __pyx_L7_cleaned_up:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_218_save_note_to_current_interval(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_note, PyObject *__pyx_v_file_path) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_save_note_to_current_interval", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 6536, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_note = __pyx_v_note;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_note);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_note);
  __pyx_cur_scope->__pyx_v_file_path = __pyx_v_file_path;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_file_path);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_file_path);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_220generator48, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[74]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_save_note_to_current_interval, __pyx_mstate_global->__pyx_n_u_ActivityController__save_note_to_2, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 6536, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._save_note_to_current_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_220generator48(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  Py_ssize_t __pyx_t_8;
  size_t __pyx_t_9;
  __Pyx_PySendResult __pyx_t_10;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  int __pyx_t_25;
  int __pyx_t_26;
  PyObject *__pyx_t_27 = NULL;
  int __pyx_t_28;
  int __pyx_t_29;
  char const *__pyx_t_30;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_save_note_to_current_interval", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L10_resume_from_await;
    case 2: goto __pyx_L11_resume_from_await;
    case 3: goto __pyx_L23_resume_from_await;
    case 4: goto __pyx_L33_resume_from_await;
    case 5: goto __pyx_L37_resume_from_await;
    case 6: goto __pyx_L41_resume_from_await;
    case 7: goto __pyx_L42_resume_from_await;
    case 8: goto __pyx_L43_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 6536, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":6545
 *             file_path: Optional S3 URL of uploaded file
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             logger.info("[AddNote] Starting to save note to current interval: note_length=%s", len(note))
 * 
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":6546
 *         """
 *         try:
 *             logger.info("[AddNote] Starting to save note to current interval: note_length=%s", len(note))             # <<<<<<<<<<<<<<
 * 
 *             # Flush queue first to ensure latest intervals are in DB
*/
      __pyx_t_5 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6546, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6546, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_8 = __Pyx_PyUnicode_GET_LENGTH(__pyx_cur_scope->__pyx_v_note); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6546, __pyx_L4_error)
      __pyx_t_6 = PyLong_FromSsize_t(__pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6546, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_9 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_5);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_9 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_AddNote_Starting_to_save_note_t, __pyx_t_6};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_9, (3-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6546, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":6549
 * 
 *             # Flush queue first to ensure latest intervals are in DB
 *             logger.info("[AddNote] Flushing write queue to ensure intervals are committed...")             # <<<<<<<<<<<<<<
 *             await db_writer_service.process_immediately()
 *             await asyncio.sleep(0.5)  # Delay to ensure intervals are committed
*/
      __pyx_t_7 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6549, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6549, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_9 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
        assert(__pyx_t_7);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
        __pyx_t_9 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_AddNote_Flushing_write_queue_to};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6549, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":6550
 *             # Flush queue first to ensure latest intervals are in DB
 *             logger.info("[AddNote] Flushing write queue to ensure intervals are committed...")
 *             await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 *             await asyncio.sleep(0.5)  # Delay to ensure intervals are committed
 * 
*/
      __pyx_t_5 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6550, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6550, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_9 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_6))) {
        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
        assert(__pyx_t_5);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
        __Pyx_INCREF(__pyx_t_5);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
        __pyx_t_9 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_9, (1-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6550, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_t_10 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (likely(__pyx_t_10 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
        __Pyx_XGIVEREF(__pyx_t_2);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
        __Pyx_XGIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 1;
        return __pyx_r;
        __pyx_L10_resume_from_await:;
        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_1);
        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_2);
        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_3);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6550, __pyx_L4_error)
      } else if (likely(__pyx_t_10 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_DECREF(__pyx_r); __pyx_r = 0;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 6550, __pyx_L4_error)
      }

      /* "ws_package/controllers/activity_controller.py":6551
 *             logger.info("[AddNote] Flushing write queue to ensure intervals are committed...")
 *             await db_writer_service.process_immediately()
 *             await asyncio.sleep(0.5)  # Delay to ensure intervals are committed             # <<<<<<<<<<<<<<
 * 
 *             current_counter = self.last_count + 1
*/
      __pyx_t_6 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6551, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6551, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
      __pyx_t_9 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_6);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_6);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_9 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_float_0_5};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6551, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_t_10 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (likely(__pyx_t_10 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
        __Pyx_XGIVEREF(__pyx_t_2);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
        __Pyx_XGIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 2;
        return __pyx_r;
        __pyx_L11_resume_from_await:;
        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_1);
        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_2);
        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_3);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6551, __pyx_L4_error)
      } else if (likely(__pyx_t_10 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_DECREF(__pyx_r); __pyx_r = 0;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 6551, __pyx_L4_error)
      }

      /* "ws_package/controllers/activity_controller.py":6553
 *             await asyncio.sleep(0.5)  # Delay to ensure intervals are committed
 * 
 *             current_counter = self.last_count + 1             # <<<<<<<<<<<<<<
 *             logger.info("[AddNote] Using counter: %s", current_counter)
 * 
*/
      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6553, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      __pyx_t_7 = __Pyx_PyLong_AddObjC(__pyx_t_4, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6553, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_GIVEREF(__pyx_t_7);
      __pyx_cur_scope->__pyx_v_current_counter = __pyx_t_7;
      __pyx_t_7 = 0;

      /* "ws_package/controllers/activity_controller.py":6554
 * 
 *             current_counter = self.last_count + 1
 *             logger.info("[AddNote] Using counter: %s", current_counter)             # <<<<<<<<<<<<<<
 * 
 *             with db_lock_manager.read_lock():
*/
      __pyx_t_4 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6554, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_6);
      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6554, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_5);
      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      __pyx_t_9 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_5))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
        assert(__pyx_t_4);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
        __pyx_t_9 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_AddNote_Using_counter_s, __pyx_cur_scope->__pyx_v_current_counter};
        __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_9, (3-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6554, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "ws_package/controllers/activity_controller.py":6556
 *             logger.info("[AddNote] Using counter: %s", current_counter)
 * 
 *             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     # Find the latest interval with current_counter (regardless of uploaded status)
*/
      /*with:*/ {
        __pyx_t_5 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6556, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6556, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_6);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_9 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_6))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
          assert(__pyx_t_5);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
          __pyx_t_9 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
          __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_9, (1-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6556, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __pyx_t_11 = __Pyx_PyObject_LookupSpecial(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6556, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_11);
        __pyx_t_5 = NULL;
        __pyx_t_4 = __Pyx_PyObject_LookupSpecial(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6556, __pyx_L12_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_9 = 1;
        #if CYTHON_UNPACK_METHODS
        if (likely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
          assert(__pyx_t_5);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_5);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
          __pyx_t_9 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_5, NULL};
          __pyx_t_6 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_9, (1-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6556, __pyx_L12_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        /*try:*/ {
          {
            __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
            __Pyx_XGOTREF(__pyx_t_12);
            __Pyx_XGOTREF(__pyx_t_13);
            __Pyx_XGOTREF(__pyx_t_14);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":6557
 * 
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     # Find the latest interval with current_counter (regardless of uploaded status)
 *                     # The upcoming interval will have ID = latest_interval.id + 1
*/
              /*with:*/ {
                __pyx_t_6 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6557, __pyx_L16_error)
                __Pyx_GOTREF(__pyx_t_4);
                __pyx_t_9 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_4))) {
                  __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
                  assert(__pyx_t_6);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                  __Pyx_INCREF(__pyx_t_6);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                  __pyx_t_9 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
                  __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_9, (1-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6557, __pyx_L16_error)
                  __Pyx_GOTREF(__pyx_t_7);
                }
                __pyx_t_15 = __Pyx_PyObject_LookupSpecial(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 6557, __pyx_L16_error)
                __Pyx_GOTREF(__pyx_t_15);
                __pyx_t_6 = NULL;
                __pyx_t_5 = __Pyx_PyObject_LookupSpecial(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6557, __pyx_L22_error)
                __Pyx_GOTREF(__pyx_t_5);
                __pyx_t_9 = 1;
                #if CYTHON_UNPACK_METHODS
                if (likely(PyMethod_Check(__pyx_t_5))) {
                  __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
                  assert(__pyx_t_6);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_5);
                  __Pyx_INCREF(__pyx_t_6);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_5, __pyx__function);
                  __pyx_t_9 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
                  __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_5, __pyx_callargs+__pyx_t_9, (1-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6557, __pyx_L22_error)
                  __Pyx_GOTREF(__pyx_t_4);
                }
                __pyx_t_10 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                if (likely(__pyx_t_10 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_1);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                  __Pyx_XGIVEREF(__pyx_t_2);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                  __Pyx_XGIVEREF(__pyx_t_3);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                  __Pyx_XGIVEREF(__pyx_t_7);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_7;
                  __Pyx_XGIVEREF(__pyx_t_11);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_t_14);
                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 3;
                  return __pyx_r;
                  __pyx_L23_resume_from_await:;
                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_1);
                  __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_2);
                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_3);
                  __pyx_t_7 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_7);
                  __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_11);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                  __pyx_cur_scope->__pyx_t_6 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                  __pyx_cur_scope->__pyx_t_7 = 0;
                  __Pyx_XGOTREF(__pyx_t_14);
                  __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                  __pyx_cur_scope->__pyx_t_8 = 0;
                  __Pyx_XGOTREF(__pyx_t_15);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6557, __pyx_L22_error)
                  __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                } else if (likely(__pyx_t_10 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 6557, __pyx_L22_error)
                }
                __pyx_t_5 = __pyx_t_4;
                __pyx_t_4 = 0;
                __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                /*try:*/ {
                  {
                    __Pyx_ExceptionSave(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18);
                    __Pyx_XGOTREF(__pyx_t_16);
                    __Pyx_XGOTREF(__pyx_t_17);
                    __Pyx_XGOTREF(__pyx_t_18);
                    /*try:*/ {
                      __Pyx_GIVEREF(__pyx_t_5);
                      __pyx_cur_scope->__pyx_v_session = __pyx_t_5;
                      __pyx_t_5 = 0;

                      /* "ws_package/controllers/activity_controller.py":6560
 *                     # Find the latest interval with current_counter (regardless of uploaded status)
 *                     # The upcoming interval will have ID = latest_interval.id + 1
 *                     query = select(ActivityInterval).where(             # <<<<<<<<<<<<<<
 *                         ActivityInterval.counter == current_counter
 *                     ).order_by(desc(ActivityInterval.id)).limit(1)
*/
                      __pyx_t_22 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6560, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_23);
                      __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 6560, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_24);
                      __pyx_t_9 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_23))) {
                        __pyx_t_22 = PyMethod_GET_SELF(__pyx_t_23);
                        assert(__pyx_t_22);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_23);
                        __Pyx_INCREF(__pyx_t_22);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_23, __pyx__function);
                        __pyx_t_9 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_22, __pyx_t_24};
                        __pyx_t_21 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_23, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6560, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_21);
                      }
                      __pyx_t_20 = __pyx_t_21;
                      __Pyx_INCREF(__pyx_t_20);

                      /* "ws_package/controllers/activity_controller.py":6561
 *                     # The upcoming interval will have ID = latest_interval.id + 1
 *                     query = select(ActivityInterval).where(
 *                         ActivityInterval.counter == current_counter             # <<<<<<<<<<<<<<
 *                     ).order_by(desc(ActivityInterval.id)).limit(1)
 * 
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6561, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_23);
                      __pyx_t_24 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 6561, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_24);
                      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                      __pyx_t_23 = PyObject_RichCompare(__pyx_t_24, __pyx_cur_scope->__pyx_v_current_counter, Py_EQ); __Pyx_XGOTREF(__pyx_t_23); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6561, __pyx_L27_error)
                      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                      __pyx_t_9 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_20, __pyx_t_23};
                        __pyx_t_19 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6560, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_19);
                      }
                      __pyx_t_6 = __pyx_t_19;
                      __Pyx_INCREF(__pyx_t_6);

                      /* "ws_package/controllers/activity_controller.py":6562
 *                     query = select(ActivityInterval).where(
 *                         ActivityInterval.counter == current_counter
 *                     ).order_by(desc(ActivityInterval.id)).limit(1)             # <<<<<<<<<<<<<<
 * 
 *                     result = await session.execute(query)
*/
                      __pyx_t_23 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_desc); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6562, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_20);
                      __Pyx_GetModuleGlobalName(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 6562, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_24);
                      __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_t_24, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6562, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                      __pyx_t_9 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_20))) {
                        __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_20);
                        assert(__pyx_t_23);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_20);
                        __Pyx_INCREF(__pyx_t_23);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_20, __pyx__function);
                        __pyx_t_9 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_23, __pyx_t_22};
                        __pyx_t_21 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_20, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6562, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_21);
                      }
                      __pyx_t_9 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_t_21};
                        __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_order_by, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6562, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_4);
                      }
                      __pyx_t_7 = __pyx_t_4;
                      __Pyx_INCREF(__pyx_t_7);
                      __pyx_t_9 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_7, __pyx_mstate_global->__pyx_int_1};
                        __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_limit, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6562, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_5);
                      }
                      __Pyx_GIVEREF(__pyx_t_5);
                      __pyx_cur_scope->__pyx_v_query = __pyx_t_5;
                      __pyx_t_5 = 0;

                      /* "ws_package/controllers/activity_controller.py":6564
 *                     ).order_by(desc(ActivityInterval.id)).limit(1)
 * 
 *                     result = await session.execute(query)             # <<<<<<<<<<<<<<
 *                     latest_interval = result.scalar_one_or_none()
 * 
*/
                      __pyx_t_4 = __pyx_cur_scope->__pyx_v_session;
                      __Pyx_INCREF(__pyx_t_4);
                      __pyx_t_9 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_cur_scope->__pyx_v_query};
                        __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6564, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_5);
                      }
                      __pyx_t_10 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_5, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      if (likely(__pyx_t_10 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 4;
                        return __pyx_r;
                        __pyx_L33_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6564, __pyx_L27_error)
                        __pyx_t_5 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_5);
                      } else if (likely(__pyx_t_10 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_5 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 6564, __pyx_L27_error)
                      }
                      __Pyx_GIVEREF(__pyx_t_5);
                      __pyx_cur_scope->__pyx_v_result = __pyx_t_5;
                      __pyx_t_5 = 0;

                      /* "ws_package/controllers/activity_controller.py":6565
 * 
 *                     result = await session.execute(query)
 *                     latest_interval = result.scalar_one_or_none()             # <<<<<<<<<<<<<<
 * 
 *                     if not latest_interval:
*/
                      __pyx_t_4 = __pyx_cur_scope->__pyx_v_result;
                      __Pyx_INCREF(__pyx_t_4);
                      __pyx_t_9 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
                        __pyx_t_5 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalar_one_or_none, __pyx_callargs+__pyx_t_9, (1-__pyx_t_9) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                        if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6565, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_5);
                      }
                      __Pyx_GIVEREF(__pyx_t_5);
                      __pyx_cur_scope->__pyx_v_latest_interval = __pyx_t_5;
                      __pyx_t_5 = 0;

                      /* "ws_package/controllers/activity_controller.py":6567
 *                     latest_interval = result.scalar_one_or_none()
 * 
 *                     if not latest_interval:             # <<<<<<<<<<<<<<
 *                         logger.error("[AddNote] No interval found with counter %s", current_counter)
 *                         return
*/
                      __pyx_t_25 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_latest_interval); if (unlikely((__pyx_t_25 < 0))) __PYX_ERR(0, 6567, __pyx_L27_error)
                      __pyx_t_26 = (!__pyx_t_25);
                      if (__pyx_t_26) {

                        /* "ws_package/controllers/activity_controller.py":6568
 * 
 *                     if not latest_interval:
 *                         logger.error("[AddNote] No interval found with counter %s", current_counter)             # <<<<<<<<<<<<<<
 *                         return
 * 
*/
                        __pyx_t_4 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6568, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_7);
                        __pyx_t_19 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6568, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_19);
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                        __pyx_t_9 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_19))) {
                          __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_19);
                          assert(__pyx_t_4);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_19);
                          __Pyx_INCREF(__pyx_t_4);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_19, __pyx__function);
                          __pyx_t_9 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[3] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_AddNote_No_interval_found_with, __pyx_cur_scope->__pyx_v_current_counter};
                          __pyx_t_5 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_19, __pyx_callargs+__pyx_t_9, (3-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                          __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                          if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6568, __pyx_L27_error)
                          __Pyx_GOTREF(__pyx_t_5);
                        }
                        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;

                        /* "ws_package/controllers/activity_controller.py":6569
 *                     if not latest_interval:
 *                         logger.error("[AddNote] No interval found with counter %s", current_counter)
 *                         return             # <<<<<<<<<<<<<<
 * 
 *                     # Use latest interval ID + 1 (upcoming interval that will be created)
*/
                        __Pyx_XDECREF(__pyx_r);
                        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
                        goto __pyx_L31_try_return;

                        /* "ws_package/controllers/activity_controller.py":6567
 *                     latest_interval = result.scalar_one_or_none()
 * 
 *                     if not latest_interval:             # <<<<<<<<<<<<<<
 *                         logger.error("[AddNote] No interval found with counter %s", current_counter)
 *                         return
*/
                      }

                      /* "ws_package/controllers/activity_controller.py":6572
 * 
 *                     # Use latest interval ID + 1 (upcoming interval that will be created)
 *                     target_interval_id = latest_interval.id + 1             # <<<<<<<<<<<<<<
 *                     logger.info("[AddNote] Latest interval found: ID=%s, counter=%s, is_uploaded=%s", latest_interval.id, latest_interval.counter, latest_interval.is_uploaded)
 *                     logger.info("[AddNote] Using target interval ID: %s (latest_id + 1) for upcoming interval", target_interval_id)
*/
                      __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_latest_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6572, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_5);
                      __pyx_t_19 = __Pyx_PyLong_AddObjC(__pyx_t_5, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6572, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_19);
                      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
                      __Pyx_GIVEREF(__pyx_t_19);
                      __pyx_cur_scope->__pyx_v_target_interval_id = __pyx_t_19;
                      __pyx_t_19 = 0;

                      /* "ws_package/controllers/activity_controller.py":6573
 *                     # Use latest interval ID + 1 (upcoming interval that will be created)
 *                     target_interval_id = latest_interval.id + 1
 *                     logger.info("[AddNote] Latest interval found: ID=%s, counter=%s, is_uploaded=%s", latest_interval.id, latest_interval.counter, latest_interval.is_uploaded)             # <<<<<<<<<<<<<<
 *                     logger.info("[AddNote] Using target interval ID: %s (latest_id + 1) for upcoming interval", target_interval_id)
 * 
*/
                      __pyx_t_5 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6573, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6573, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_7);
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_latest_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6573, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_latest_interval, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6573, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_latest_interval, __pyx_mstate_global->__pyx_n_u_is_uploaded); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6573, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_6);
                      __pyx_t_9 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_7))) {
                        __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7);
                        assert(__pyx_t_5);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                        __Pyx_INCREF(__pyx_t_5);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                        __pyx_t_9 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[5] = {__pyx_t_5, __pyx_mstate_global->__pyx_kp_u_AddNote_Latest_interval_found_I, __pyx_t_4, __pyx_t_21, __pyx_t_6};
                        __pyx_t_19 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_9, (5-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                        if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6573, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_19);
                      }
                      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;

                      /* "ws_package/controllers/activity_controller.py":6574
 *                     target_interval_id = latest_interval.id + 1
 *                     logger.info("[AddNote] Latest interval found: ID=%s, counter=%s, is_uploaded=%s", latest_interval.id, latest_interval.counter, latest_interval.is_uploaded)
 *                     logger.info("[AddNote] Using target interval ID: %s (latest_id + 1) for upcoming interval", target_interval_id)             # <<<<<<<<<<<<<<
 * 
 *                     # Prepare note data with target interval ID
*/
                      __pyx_t_7 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6574, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_6);
                      __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6574, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                      __pyx_t_9 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_21))) {
                        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_21);
                        assert(__pyx_t_7);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_21);
                        __Pyx_INCREF(__pyx_t_7);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_21, __pyx__function);
                        __pyx_t_9 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[3] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_AddNote_Using_target_interval_I, __pyx_cur_scope->__pyx_v_target_interval_id};
                        __pyx_t_19 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_21, __pyx_callargs+__pyx_t_9, (3-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6574, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_19);
                      }
                      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;

                      /* "ws_package/controllers/activity_controller.py":6578
 *                     # Prepare note data with target interval ID
 *                     note_data = {
 *                         "activity_interval_id": [target_interval_id],             # <<<<<<<<<<<<<<
 *                         "note": note
 *                     }
*/
                      __pyx_t_19 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6578, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_19);
                      __pyx_t_21 = PyList_New(1); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6578, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_target_interval_id);
                      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_target_interval_id);
                      if (__Pyx_PyList_SET_ITEM(__pyx_t_21, 0, __pyx_cur_scope->__pyx_v_target_interval_id) != (0)) __PYX_ERR(0, 6578, __pyx_L27_error);
                      if (PyDict_SetItem(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_activity_interval_id, __pyx_t_21) < (0)) __PYX_ERR(0, 6578, __pyx_L27_error)
                      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;

                      /* "ws_package/controllers/activity_controller.py":6579
 *                     note_data = {
 *                         "activity_interval_id": [target_interval_id],
 *                         "note": note             # <<<<<<<<<<<<<<
 *                     }
 *                     if file_path:
*/
                      if (PyDict_SetItem(__pyx_t_19, __pyx_mstate_global->__pyx_n_u_note, __pyx_cur_scope->__pyx_v_note) < (0)) __PYX_ERR(0, 6578, __pyx_L27_error)
                      __Pyx_GIVEREF(__pyx_t_19);
                      __pyx_cur_scope->__pyx_v_note_data = ((PyObject*)__pyx_t_19);
                      __pyx_t_19 = 0;

                      /* "ws_package/controllers/activity_controller.py":6581
 *                         "note": note
 *                     }
 *                     if file_path:             # <<<<<<<<<<<<<<
 *                         note_data["file_path"] = file_path
 * 
*/
                      if (__pyx_cur_scope->__pyx_v_file_path == Py_None) __pyx_t_26 = 0;
                      else
                      {
                        Py_ssize_t __pyx_temp = __Pyx_PyUnicode_IS_TRUE(__pyx_cur_scope->__pyx_v_file_path);
                        if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 6581, __pyx_L27_error)
                        __pyx_t_26 = (__pyx_temp != 0);
                      }

                      if (__pyx_t_26) {

                        /* "ws_package/controllers/activity_controller.py":6582
 *                     }
 *                     if file_path:
 *                         note_data["file_path"] = file_path             # <<<<<<<<<<<<<<
 * 
 *                     # Queue the insert operation
*/
                        if (unlikely((PyDict_SetItem(__pyx_cur_scope->__pyx_v_note_data, __pyx_mstate_global->__pyx_n_u_file_path, __pyx_cur_scope->__pyx_v_file_path) < 0))) __PYX_ERR(0, 6582, __pyx_L27_error)

                        /* "ws_package/controllers/activity_controller.py":6581
 *                         "note": note
 *                     }
 *                     if file_path:             # <<<<<<<<<<<<<<
 *                         note_data["file_path"] = file_path
 * 
*/
                      }

                      /* "ws_package/controllers/activity_controller.py":6585
 * 
 *                     # Queue the insert operation
 *                     enqueue_success = db_write_queue.enqueue(             # <<<<<<<<<<<<<<
 *                         WriteOperationType.NOTES,
 *                         "notes",
*/
                      __pyx_t_21 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_db_write_queue); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6585, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_7);
                      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_enqueue); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6585, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_6);
                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

                      /* "ws_package/controllers/activity_controller.py":6586
 *                     # Queue the insert operation
 *                     enqueue_success = db_write_queue.enqueue(
 *                         WriteOperationType.NOTES,             # <<<<<<<<<<<<<<
 *                         "notes",
 *                         note_data
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_WriteOperationType); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6586, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_7);
                      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_NOTES); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6586, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

                      /* "ws_package/controllers/activity_controller.py":6588
 *                         WriteOperationType.NOTES,
 *                         "notes",
 *                         note_data             # <<<<<<<<<<<<<<
 *                     )
 * 
*/
                      __pyx_t_9 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_6))) {
                        __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_6);
                        assert(__pyx_t_21);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                        __Pyx_INCREF(__pyx_t_21);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                        __pyx_t_9 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[4] = {__pyx_t_21, __pyx_t_4, __pyx_mstate_global->__pyx_n_u_notes_2, __pyx_cur_scope->__pyx_v_note_data};
                        __pyx_t_19 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_9, (4-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                        if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6585, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_19);
                      }
                      __Pyx_GIVEREF(__pyx_t_19);
                      __pyx_cur_scope->__pyx_v_enqueue_success = __pyx_t_19;
                      __pyx_t_19 = 0;

                      /* "ws_package/controllers/activity_controller.py":6591
 *                     )
 * 
 *                     if not enqueue_success:             # <<<<<<<<<<<<<<
 *                         logger.error("[AddNote] Failed to enqueue Notes entry - queue may be full")
 *                         return
*/
                      __pyx_t_26 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_enqueue_success); if (unlikely((__pyx_t_26 < 0))) __PYX_ERR(0, 6591, __pyx_L27_error)
                      __pyx_t_25 = (!__pyx_t_26);
                      if (__pyx_t_25) {

                        /* "ws_package/controllers/activity_controller.py":6592
 * 
 *                     if not enqueue_success:
 *                         logger.error("[AddNote] Failed to enqueue Notes entry - queue may be full")             # <<<<<<<<<<<<<<
 *                         return
 * 
*/
                        __pyx_t_6 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6592, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_4);
                        __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6592, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_21);
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __pyx_t_9 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_21))) {
                          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_21);
                          assert(__pyx_t_6);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_21);
                          __Pyx_INCREF(__pyx_t_6);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_21, __pyx__function);
                          __pyx_t_9 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[2] = {__pyx_t_6, __pyx_mstate_global->__pyx_kp_u_AddNote_Failed_to_enqueue_Notes};
                          __pyx_t_19 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_21, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                          __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                          if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6592, __pyx_L27_error)
                          __Pyx_GOTREF(__pyx_t_19);
                        }
                        __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;

                        /* "ws_package/controllers/activity_controller.py":6593
 *                     if not enqueue_success:
 *                         logger.error("[AddNote] Failed to enqueue Notes entry - queue may be full")
 *                         return             # <<<<<<<<<<<<<<
 * 
 *                     logger.info("[AddNote] Successfully queued Notes entry with interval ID: %s", target_interval_id)
*/
                        __Pyx_XDECREF(__pyx_r);
                        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
                        goto __pyx_L31_try_return;

                        /* "ws_package/controllers/activity_controller.py":6591
 *                     )
 * 
 *                     if not enqueue_success:             # <<<<<<<<<<<<<<
 *                         logger.error("[AddNote] Failed to enqueue Notes entry - queue may be full")
 *                         return
*/
                      }

                      /* "ws_package/controllers/activity_controller.py":6595
 *                         return
 * 
 *                     logger.info("[AddNote] Successfully queued Notes entry with interval ID: %s", target_interval_id)             # <<<<<<<<<<<<<<
 * 
 *                     # Force immediate processing of the queue to ensure note is written
*/
                      __pyx_t_21 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6595, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_6);
                      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6595, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                      __pyx_t_9 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_4))) {
                        __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_4);
                        assert(__pyx_t_21);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                        __Pyx_INCREF(__pyx_t_21);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                        __pyx_t_9 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[3] = {__pyx_t_21, __pyx_mstate_global->__pyx_kp_u_AddNote_Successfully_queued_Not, __pyx_cur_scope->__pyx_v_target_interval_id};
                        __pyx_t_19 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_9, (3-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6595, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_19);
                      }
                      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;

                      /* "ws_package/controllers/activity_controller.py":6598
 * 
 *                     # Force immediate processing of the queue to ensure note is written
 *                     logger.info("[AddNote] Processing write queue immediately to save note...")             # <<<<<<<<<<<<<<
 *                     await db_writer_service.process_immediately()
 *                     logger.info("[AddNote] Write queue processed - note should now be in database")
*/
                      __pyx_t_4 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6598, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6598, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_6);
                      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                      __pyx_t_9 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_6))) {
                        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
                        assert(__pyx_t_4);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_6);
                        __Pyx_INCREF(__pyx_t_4);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_6, __pyx__function);
                        __pyx_t_9 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_AddNote_Processing_write_queue};
                        __pyx_t_19 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_6, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                        if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6598, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_19);
                      }
                      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;

                      /* "ws_package/controllers/activity_controller.py":6599
 *                     # Force immediate processing of the queue to ensure note is written
 *                     logger.info("[AddNote] Processing write queue immediately to save note...")
 *                     await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 *                     logger.info("[AddNote] Write queue processed - note should now be in database")
 * 
*/
                      __pyx_t_6 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6599, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6599, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __pyx_t_9 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_21))) {
                        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_21);
                        assert(__pyx_t_6);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_21);
                        __Pyx_INCREF(__pyx_t_6);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_21, __pyx__function);
                        __pyx_t_9 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_6, NULL};
                        __pyx_t_19 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_21, __pyx_callargs+__pyx_t_9, (1-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                        if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6599, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_19);
                      }
                      __pyx_t_10 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_19, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                      if (likely(__pyx_t_10 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 5;
                        return __pyx_r;
                        __pyx_L37_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6599, __pyx_L27_error)
                      } else if (likely(__pyx_t_10 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 6599, __pyx_L27_error)
                      }

                      /* "ws_package/controllers/activity_controller.py":6600
 *                     logger.info("[AddNote] Processing write queue immediately to save note...")
 *                     await db_writer_service.process_immediately()
 *                     logger.info("[AddNote] Write queue processed - note should now be in database")             # <<<<<<<<<<<<<<
 * 
 *         except Exception as e:
*/
                      __pyx_t_21 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6600, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_6);
                      __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6600, __pyx_L27_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                      __pyx_t_9 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_4))) {
                        __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_4);
                        assert(__pyx_t_21);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                        __Pyx_INCREF(__pyx_t_21);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                        __pyx_t_9 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_21, __pyx_mstate_global->__pyx_kp_u_AddNote_Write_queue_processed_n};
                        __pyx_t_19 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_9, (2-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6600, __pyx_L27_error)
                        __Pyx_GOTREF(__pyx_t_19);
                      }
                      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;

                      /* "ws_package/controllers/activity_controller.py":6557
 * 
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     # Find the latest interval with current_counter (regardless of uploaded status)
 *                     # The upcoming interval will have ID = latest_interval.id + 1
*/
                    }
                    __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                    goto __pyx_L32_try_end;
                    __pyx_L27_error:;
                    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
                    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
                    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                    /*except:*/ {
                      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._save_note_to_current_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_19, &__pyx_t_4, &__pyx_t_21) < 0) __PYX_ERR(0, 6557, __pyx_L29_except_error)
                      __Pyx_XGOTREF(__pyx_t_19);
                      __Pyx_XGOTREF(__pyx_t_4);
                      __Pyx_XGOTREF(__pyx_t_21);
                      __pyx_t_6 = PyTuple_Pack(3, __pyx_t_19, __pyx_t_4, __pyx_t_21); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6557, __pyx_L29_except_error)
                      __Pyx_GOTREF(__pyx_t_6);
                      __pyx_t_27 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_t_6, NULL);
                      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
                      if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 6557, __pyx_L29_except_error)
                      __Pyx_GOTREF(__pyx_t_27);
                      __pyx_t_10 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_27, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                      if (likely(__pyx_t_10 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_4);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_11 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_t_19);
                        __pyx_cur_scope->__pyx_t_12 = __pyx_t_19;
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __pyx_cur_scope->__pyx_t_13 = __pyx_t_21;
                        __Pyx_XGIVEREF(__pyx_t_27);
                        __pyx_cur_scope->__pyx_t_14 = __pyx_t_27;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_SwapException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 6;
                        return __pyx_r;
                        __pyx_L41_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_4);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_11;
                        __pyx_cur_scope->__pyx_t_11 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        __pyx_t_19 = __pyx_cur_scope->__pyx_t_12;
                        __pyx_cur_scope->__pyx_t_12 = 0;
                        __Pyx_XGOTREF(__pyx_t_19);
                        __pyx_t_21 = __pyx_cur_scope->__pyx_t_13;
                        __pyx_cur_scope->__pyx_t_13 = 0;
                        __Pyx_XGOTREF(__pyx_t_21);
                        __pyx_t_27 = __pyx_cur_scope->__pyx_t_14;
                        __pyx_cur_scope->__pyx_t_14 = 0;
                        __Pyx_XGOTREF(__pyx_t_27);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6557, __pyx_L29_except_error)
                        __pyx_t_6 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_6);
                      } else if (likely(__pyx_t_10 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_6 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 6557, __pyx_L29_except_error)
                      }
                      __pyx_t_27 = __pyx_t_6;
                      __pyx_t_6 = 0;
                      __pyx_t_25 = __Pyx_PyObject_IsTrue(__pyx_t_27);
                      __Pyx_DECREF(__pyx_t_27); __pyx_t_27 = 0;
                      if (__pyx_t_25 < (0)) __PYX_ERR(0, 6557, __pyx_L29_except_error)
                      __pyx_t_26 = (!__pyx_t_25);
                      if (unlikely(__pyx_t_26)) {
                        __Pyx_GIVEREF(__pyx_t_19);
                        __Pyx_GIVEREF(__pyx_t_4);
                        __Pyx_XGIVEREF(__pyx_t_21);
                        __Pyx_ErrRestoreWithState(__pyx_t_19, __pyx_t_4, __pyx_t_21);
                        __pyx_t_19 = 0;  __pyx_t_4 = 0;  __pyx_t_21 = 0; 
                        __PYX_ERR(0, 6557, __pyx_L29_except_error)
                      }
                      __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                      goto __pyx_L28_exception_handled;
                    }
                    __pyx_L29_except_error:;
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
                    goto __pyx_L16_error;
                    __pyx_L31_try_return:;
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
                    goto __pyx_L24_return;
                    __pyx_L28_exception_handled:;
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __Pyx_ExceptionReset(__pyx_t_16, __pyx_t_17, __pyx_t_18);
                    __pyx_L32_try_end:;
                  }
                }
                /*finally:*/ {
                  /*normal exit:*/{
                    if (__pyx_t_15) {
                      __pyx_t_18 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_mstate_global->__pyx_tuple[7], NULL);
                      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                      if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 6557, __pyx_L16_error)
                      __Pyx_GOTREF(__pyx_t_18);
                      __pyx_t_10 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_18, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                      if (likely(__pyx_t_10 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 7;
                        return __pyx_r;
                        __pyx_L42_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6557, __pyx_L16_error)
                        __pyx_t_21 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_21);
                      } else if (likely(__pyx_t_10 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_21 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 6557, __pyx_L16_error)
                      }
                      __pyx_t_18 = __pyx_t_21;
                      __pyx_t_21 = 0;
                      __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                    }
                    goto __pyx_L26;
                  }
                  __pyx_L24_return: {
                    __pyx_t_18 = __pyx_r;
                    __pyx_r = 0;
                    if (__pyx_t_15) {
                      __pyx_t_17 = __Pyx_PyObject_Call(__pyx_t_15, __pyx_mstate_global->__pyx_tuple[7], NULL);
                      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                      if (unlikely(!__pyx_t_17)) __PYX_ERR(0, 6557, __pyx_L16_error)
                      __Pyx_GOTREF(__pyx_t_17);
                      __pyx_t_10 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_17, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                      if (likely(__pyx_t_10 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_11);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_11;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 8;
                        return __pyx_r;
                        __pyx_L43_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_11 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_11);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6557, __pyx_L16_error)
                        __pyx_t_21 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_21);
                      } else if (likely(__pyx_t_10 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_21 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 6557, __pyx_L16_error)
                      }
                      __pyx_t_17 = __pyx_t_21;
                      __pyx_t_21 = 0;
                      __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
                    }
                    __pyx_r = __pyx_t_18;
                    __pyx_t_18 = 0;
                    goto __pyx_L20_try_return;
                  }
                  __pyx_L26:;
                }
                goto __pyx_L44;
                __pyx_L22_error:;
                __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
                goto __pyx_L16_error;
                __pyx_L44:;
              }

              /* "ws_package/controllers/activity_controller.py":6556
 *             logger.info("[AddNote] Using counter: %s", current_counter)
 * 
 *             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     # Find the latest interval with current_counter (regardless of uploaded status)
*/
            }
            __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            goto __pyx_L21_try_end;
            __pyx_L16_error:;
            __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
            __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
            __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
            __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
            __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            /*except:*/ {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._save_note_to_current_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_21, &__pyx_t_4, &__pyx_t_19) < 0) __PYX_ERR(0, 6556, __pyx_L18_except_error)
              __Pyx_XGOTREF(__pyx_t_21);
              __Pyx_XGOTREF(__pyx_t_4);
              __Pyx_XGOTREF(__pyx_t_19);
              __pyx_t_6 = PyTuple_Pack(3, __pyx_t_21, __pyx_t_4, __pyx_t_19); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6556, __pyx_L18_except_error)
              __Pyx_GOTREF(__pyx_t_6);
              __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_t_6, NULL);
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
              __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
              if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 6556, __pyx_L18_except_error)
              __Pyx_GOTREF(__pyx_t_15);
              __pyx_t_26 = __Pyx_PyObject_IsTrue(__pyx_t_15);
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
              if (__pyx_t_26 < (0)) __PYX_ERR(0, 6556, __pyx_L18_except_error)
              __pyx_t_25 = (!__pyx_t_26);
              if (unlikely(__pyx_t_25)) {
                __Pyx_GIVEREF(__pyx_t_21);
                __Pyx_GIVEREF(__pyx_t_4);
                __Pyx_XGIVEREF(__pyx_t_19);
                __Pyx_ErrRestoreWithState(__pyx_t_21, __pyx_t_4, __pyx_t_19);
                __pyx_t_21 = 0;  __pyx_t_4 = 0;  __pyx_t_19 = 0; 
                __PYX_ERR(0, 6556, __pyx_L18_except_error)
              }
              __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
              goto __pyx_L17_exception_handled;
            }
            __pyx_L18_except_error:;
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
            goto __pyx_L4_error;
            __pyx_L20_try_return:;
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
            goto __pyx_L13_return;
            __pyx_L17_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_12);
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_13, __pyx_t_14);
            __pyx_L21_try_end:;
          }
        }
        /*finally:*/ {
          /*normal exit:*/{
            if (__pyx_t_11) {
              __pyx_t_14 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_mstate_global->__pyx_tuple[7], NULL);
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
              if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 6556, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_14);
              __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
            }
            goto __pyx_L15;
          }
          __pyx_L13_return: {
            __pyx_t_14 = __pyx_r;
            __pyx_r = 0;
            if (__pyx_t_11) {
              __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_mstate_global->__pyx_tuple[7], NULL);
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
              if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 6556, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_13);
              __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
            }
            __pyx_r = __pyx_t_14;
            __pyx_t_14 = 0;
            goto __pyx_L8_try_return;
          }
          __pyx_L15:;
        }
        goto __pyx_L48;
        __pyx_L12_error:;
        __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
        goto __pyx_L4_error;
        __pyx_L48:;
      }

      /* "ws_package/controllers/activity_controller.py":6545
 *             file_path: Optional S3 URL of uploaded file
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             logger.info("[AddNote] Starting to save note to current interval: note_length=%s", len(note))
 * 
*/
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L9_try_end;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;

    /* "ws_package/controllers/activity_controller.py":6602
 *                     logger.info("[AddNote] Write queue processed - note should now be in database")
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("[AddNote] Error saving note to current interval: %s", e, exc_info=True)
 * 
*/
    __pyx_t_28 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_28) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._save_note_to_current_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_19, &__pyx_t_4, &__pyx_t_21) < 0) __PYX_ERR(0, 6602, __pyx_L6_except_error)
      __Pyx_XGOTREF(__pyx_t_19);
      __Pyx_XGOTREF(__pyx_t_4);
      __Pyx_XGOTREF(__pyx_t_21);
      __Pyx_INCREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_cur_scope->__pyx_v_e = __pyx_t_4;
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":6603
 * 
 *         except Exception as e:
 *             logger.error("[AddNote] Error saving note to current interval: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 * 
*/
        __pyx_t_7 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6603, __pyx_L54_error)
        __Pyx_GOTREF(__pyx_t_5);
        __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6603, __pyx_L54_error)
        __Pyx_GOTREF(__pyx_t_20);
        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
        __pyx_t_9 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_20))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_20);
          assert(__pyx_t_7);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_20);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_20, __pyx__function);
          __pyx_t_9 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_AddNote_Error_saving_note_to_cu, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_5 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6603, __pyx_L54_error)
          __Pyx_GOTREF(__pyx_t_5);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_5, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 6603, __pyx_L54_error)
          __pyx_t_6 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_20, __pyx_callargs+__pyx_t_9, (3-__pyx_t_9) | (__pyx_t_9*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_5);
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
          if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6603, __pyx_L54_error)
          __Pyx_GOTREF(__pyx_t_6);
        }
        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
      }

      /* "ws_package/controllers/activity_controller.py":6602
 *                     logger.info("[AddNote] Write queue processed - note should now be in database")
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("[AddNote] Error saving note to current interval: %s", e, exc_info=True)
 * 
*/
      /*finally:*/ {
        /*normal exit:*/{
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          goto __pyx_L55;
        }
        __pyx_L54_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_11 = 0; __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_15 = 0; __pyx_t_18 = 0;
          __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
          __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
          __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
          __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_12, &__pyx_t_15, &__pyx_t_18);
          if ( unlikely(__Pyx_GetException(&__pyx_t_11, &__pyx_t_14, &__pyx_t_13) < 0)) __Pyx_ErrFetch(&__pyx_t_11, &__pyx_t_14, &__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_11);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_13);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_18);
          __pyx_t_28 = __pyx_lineno; __pyx_t_29 = __pyx_clineno; __pyx_t_30 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_XGIVEREF(__pyx_t_18);
          __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_15, __pyx_t_18);
          __Pyx_XGIVEREF(__pyx_t_11);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_XGIVEREF(__pyx_t_13);
          __Pyx_ErrRestore(__pyx_t_11, __pyx_t_14, __pyx_t_13);
          __pyx_t_11 = 0; __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_15 = 0; __pyx_t_18 = 0;
          __pyx_lineno = __pyx_t_28; __pyx_clineno = __pyx_t_29; __pyx_filename = __pyx_t_30;
          goto __pyx_L6_except_error;
        }
        __pyx_L55:;
      }
      __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
      __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
      goto __pyx_L5_exception_handled;
    }
    goto __pyx_L6_except_error;

    /* "ws_package/controllers/activity_controller.py":6545
 *             file_path: Optional S3 URL of uploaded file
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             logger.info("[AddNote] Starting to save note to current interval: note_length=%s", len(note))
 * 
*/
    __pyx_L6_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L5_exception_handled:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    __pyx_L9_try_end:;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":6536
 *             logger.error("Error saving note to Notes table: %s", e, exc_info=True)
 * 
 *     async def _save_note_to_current_interval(self, note: str, file_path: Optional[str] = None):             # <<<<<<<<<<<<<<
 *         """
 *         Save note to Notes table with current running interval ID.
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_19);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_XDECREF(__pyx_t_23);
  __Pyx_XDECREF(__pyx_t_24);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("_save_note_to_current_interval", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_223generator49(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":6606
 * 
 * 
 *     async def _should_pause_api_calls(self, intervals: list) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Check if API calls should be paused.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_222_should_pause_api_calls(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_221_should_pause_api_calls, "\n        Check if API calls should be paused.\n        \n        NEW REQUIREMENT: \n        - While idle popup is active, ALL intervals are considered idle and NOT sent to server.\n        - When 1 idle interval is found, hold it until next non-idle interval found or idle popup handled.\n        \n        Returns True if:\n        1. Idle popup is active (triggered but not yet handled) - BLOCKS ALL UPLOADS\n        2. All intervals have zero activity (single or multiple) - HOLDS until non-idle or popup handled\n        \n        Args:\n            intervals: List of ActivityInterval objects to check\n            \n        Returns:\n            bool: True if API calls should be paused, False otherwise\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_222_should_pause_api_calls = {"_should_pause_api_calls", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_222_should_pause_api_calls, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_221_should_pause_api_calls};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_222_should_pause_api_calls(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_intervals = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[2] = {0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_should_pause_api_calls (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_intervals,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 6606, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 6606, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 6606, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_should_pause_api_calls", 0) < (0)) __PYX_ERR(0, 6606, __pyx_L3_error)
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_should_pause_api_calls", 1, 2, 2, i); __PYX_ERR(0, 6606, __pyx_L3_error) }
      }
    } else if (unlikely(__pyx_nargs != 2)) {
      goto __pyx_L5_argtuple_error;
    } else {
      values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 6606, __pyx_L3_error)
      values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
      if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 6606, __pyx_L3_error)
    }
    __pyx_v_self = values[0];
    __pyx_v_intervals = ((PyObject*)values[1]);
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_should_pause_api_calls", 1, 2, 2, __pyx_nargs); __PYX_ERR(0, 6606, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._should_pause_api_calls", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_intervals), (&PyList_Type), 0, "intervals", 2))) __PYX_ERR(0, 6606, __pyx_L1_error)
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_221_should_pause_api_calls(__pyx_self, __pyx_v_self, __pyx_v_intervals);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  goto __pyx_L7_cleaned_up;
  __pyx_L0:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __pyx_L7_cleaned_up:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23_should_pause_api_calls_2generator68(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":6707
 *                 for interval in idle_intervals:
 *                     # Check if already held (by ID to avoid duplicates)
 *                     if not any(getattr(held, 'id', None) == getattr(interval, 'id', None) for held in self._held_idle_intervals):             # <<<<<<<<<<<<<<
 *                         self._held_idle_intervals.append(interval)
 *                         logger.info("[APIBlock] Holding idle interval (id=%s, counter=%s, start=%s, end=%s) - will send when non-idle interval found or popup handled", interval.id, getattr(interval, 'counter', 'N/A'), interval.start_time, interval.end_time)
*/

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23_should_pause_api_calls_genexpr(PyObject *__pyx_self, PyObject *__pyx_genexpr_arg_0) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("genexpr", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 6707, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_outer_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls *) __pyx_self;
  __Pyx_INCREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  __Pyx_GIVEREF((PyObject *)__pyx_cur_scope->__pyx_outer_scope);
  __pyx_cur_scope->__pyx_genexpr_arg_0 = __pyx_genexpr_arg_0;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_genexpr_arg_0);
  {
    __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23_should_pause_api_calls_2generator68, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[75]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_genexpr, __pyx_mstate_global->__pyx_n_u_ActivityController__should_pause, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 6707, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._should_pause_api_calls.genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23_should_pause_api_calls_2generator68(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  Py_ssize_t __pyx_t_2;
  PyObject *(*__pyx_t_3)(PyObject *);
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  int __pyx_t_7;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("genexpr", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6707, __pyx_L1_error)
  if (unlikely(!__pyx_cur_scope->__pyx_genexpr_arg_0)) { __Pyx_RaiseUnboundLocalError(".0"); __PYX_ERR(0, 6707, __pyx_L1_error) }
  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_genexpr_arg_0)) {
    __pyx_t_1 = __pyx_cur_scope->__pyx_genexpr_arg_0; __Pyx_INCREF(__pyx_t_1);
    __pyx_t_2 = 0;
    __pyx_t_3 = NULL;
  } else {
    __pyx_t_2 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_genexpr_arg_0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6707, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
    __pyx_t_3 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6707, __pyx_L1_error)
  }
  for (;;) {
    if (likely(!__pyx_t_3)) {
      if (likely(PyList_CheckExact(__pyx_t_1))) {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6707, __pyx_L1_error)
          #endif
          if (__pyx_t_2 >= __pyx_temp) break;
        }
        __pyx_t_4 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_1, __pyx_t_2, __Pyx_ReferenceSharing_OwnStrongReference);
        ++__pyx_t_2;
      } else {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6707, __pyx_L1_error)
          #endif
          if (__pyx_t_2 >= __pyx_temp) break;
        }
        #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
        __pyx_t_4 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_2));
        #else
        __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_2);
        #endif
        ++__pyx_t_2;
      }
      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6707, __pyx_L1_error)
    } else {
      __pyx_t_4 = __pyx_t_3(__pyx_t_1);
      if (unlikely(!__pyx_t_4)) {
        PyObject* exc_type = PyErr_Occurred();
        if (exc_type) {
          if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 6707, __pyx_L1_error)
          PyErr_Clear();
        }
        break;
      }
    }
    __Pyx_GOTREF(__pyx_t_4);
    __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_held);
    __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_held, __pyx_t_4);
    __Pyx_GIVEREF(__pyx_t_4);
    __pyx_t_4 = 0;
    __pyx_t_4 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_held, __pyx_mstate_global->__pyx_n_u_id, Py_None); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6707, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
    if (unlikely(!__pyx_cur_scope->__pyx_outer_scope->__pyx_v_interval)) { __Pyx_RaiseClosureNameError("interval"); __PYX_ERR(0, 6707, __pyx_L1_error) }
    __pyx_t_5 = __pyx_cur_scope->__pyx_outer_scope->__pyx_v_interval;
    __Pyx_INCREF(__pyx_t_5);
    __pyx_t_6 = __Pyx_GetAttr3(__pyx_t_5, __pyx_mstate_global->__pyx_n_u_id, Py_None); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 6707, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_6);
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    __pyx_t_5 = PyObject_RichCompare(__pyx_t_4, __pyx_t_6, Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 6707, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely((__pyx_t_7 < 0))) __PYX_ERR(0, 6707, __pyx_L1_error)
    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
    if (__pyx_t_7) {
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_True);
      __pyx_r = Py_True;
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      goto __pyx_L0;
    }
  }
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  /*else*/ {
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_5);
  __Pyx_XDECREF(__pyx_t_6);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("genexpr", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

/* "ws_package/controllers/activity_controller.py":6606
 * 
 * 
 *     async def _should_pause_api_calls(self, intervals: list) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Check if API calls should be paused.
*/

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_221_should_pause_api_calls(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_intervals) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls *__pyx_cur_scope;
  PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23_should_pause_api_calls_2generator68 = 0;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_should_pause_api_calls", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 6606, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_intervals = __pyx_v_intervals;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_intervals);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_intervals);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_223generator49, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[76]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_should_pause_api_calls, __pyx_mstate_global->__pyx_n_u_ActivityController__should_pause_2, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 6606, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._should_pause_api_calls", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_XDECREF(__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_23_should_pause_api_calls_2generator68);
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_223generator49(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  size_t __pyx_t_4;
  int __pyx_t_5;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  int __pyx_t_9;
  PyObject *__pyx_t_10 = NULL;
  PyObject *__pyx_t_11 = NULL;
  PyObject *__pyx_t_12 = NULL;
  Py_ssize_t __pyx_t_13;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  __Pyx_PySendResult __pyx_t_17;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  PyObject *__pyx_t_25 = NULL;
  PyObject *__pyx_t_26 = NULL;
  PyObject *(*__pyx_t_27)(PyObject *);
  double __pyx_t_28;
  int __pyx_t_29;
  PyObject *__pyx_t_30 = NULL;
  int __pyx_t_31;
  int __pyx_t_32;
  char const *__pyx_t_33;
  PyObject *__pyx_t_34 = NULL;
  char const *__pyx_t_35;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_should_pause_api_calls", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L26_resume_from_await;
    case 2: goto __pyx_L27_resume_from_await;
    case 3: goto __pyx_L39_resume_from_await;
    case 4: goto __pyx_L49_resume_from_await;
    case 5: goto __pyx_L70_resume_from_await;
    case 6: goto __pyx_L71_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 6606, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":6624
 *             bool: True if API calls should be paused, False otherwise
 *         """
 *         if is_silent_build():             # <<<<<<<<<<<<<<
 *             return False
 *         try:
*/
  __pyx_t_2 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_is_silent_build); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6624, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_3);
  __pyx_t_4 = 1;
  #if CYTHON_UNPACK_METHODS
  if (unlikely(PyMethod_Check(__pyx_t_3))) {
    __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
    assert(__pyx_t_2);
    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
    __Pyx_INCREF(__pyx_t_2);
    __Pyx_INCREF(__pyx__function);
    __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
    __pyx_t_4 = 0;
  }
  #endif
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
    __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
    if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6624, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_1);
  }
  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 6624, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
  if (__pyx_t_5) {

    /* "ws_package/controllers/activity_controller.py":6625
 *         """
 *         if is_silent_build():
 *             return False             # <<<<<<<<<<<<<<
 *         try:
 *             # Case 1: Check if idle popup is active (triggered but not yet handled)
*/
    __Pyx_XDECREF(__pyx_r);
    __Pyx_INCREF(Py_False);
    __pyx_r = Py_False;
    goto __pyx_L0;

    /* "ws_package/controllers/activity_controller.py":6624
 *             bool: True if API calls should be paused, False otherwise
 *         """
 *         if is_silent_build():             # <<<<<<<<<<<<<<
 *             return False
 *         try:
*/
  }

  /* "ws_package/controllers/activity_controller.py":6626
 *         if is_silent_build():
 *             return False
 *         try:             # <<<<<<<<<<<<<<
 *             # Case 1: Check if idle popup is active (triggered but not yet handled)
 *             # CRITICAL: While popup active, block ALL server uploads
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_6, &__pyx_t_7, &__pyx_t_8);
    __Pyx_XGOTREF(__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_7);
    __Pyx_XGOTREF(__pyx_t_8);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":6629
 *             # Case 1: Check if idle popup is active (triggered but not yet handled)
 *             # CRITICAL: While popup active, block ALL server uploads
 *             if self._idle_popup_active and self._idle_popup_triggered_at is not None:             # <<<<<<<<<<<<<<
 *                 logger.info("[APIBlock] Pausing uploads: Idle popup is active (triggered at %s)", self._idle_popup_triggered_at.isoformat())
 *                 return True
*/
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_active); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6629, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 6629, __pyx_L5_error)
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      if (__pyx_t_9) {
      } else {
        __pyx_t_5 = __pyx_t_9;
        goto __pyx_L12_bool_binop_done;
      }
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_triggered_at); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6629, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_9 = (__pyx_t_1 != Py_None);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __pyx_t_5 = __pyx_t_9;
      __pyx_L12_bool_binop_done:;
      if (__pyx_t_5) {

        /* "ws_package/controllers/activity_controller.py":6630
 *             # CRITICAL: While popup active, block ALL server uploads
 *             if self._idle_popup_active and self._idle_popup_triggered_at is not None:
 *                 logger.info("[APIBlock] Pausing uploads: Idle popup is active (triggered at %s)", self._idle_popup_triggered_at.isoformat())             # <<<<<<<<<<<<<<
 *                 return True
 * 
*/
        __pyx_t_3 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6630, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_2);
        __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 6630, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_10);
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_idle_popup_triggered_at); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 6630, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_11 = __pyx_t_12;
        __Pyx_INCREF(__pyx_t_11);
        __pyx_t_4 = 0;
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_11, NULL};
          __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_isoformat, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6630, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_2);
        }
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_10))) {
          __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_10);
          assert(__pyx_t_3);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_10);
          __Pyx_INCREF(__pyx_t_3);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_10, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_APIBlock_Pausing_uploads_Idle_p, __pyx_t_2};
          __pyx_t_1 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_10, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6630, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

        /* "ws_package/controllers/activity_controller.py":6631
 *             if self._idle_popup_active and self._idle_popup_triggered_at is not None:
 *                 logger.info("[APIBlock] Pausing uploads: Idle popup is active (triggered at %s)", self._idle_popup_triggered_at.isoformat())
 *                 return True             # <<<<<<<<<<<<<<
 * 
 *             # Case 2: Check intervals for idle activity
*/
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_True);
        __pyx_r = Py_True;
        goto __pyx_L9_try_return;

        /* "ws_package/controllers/activity_controller.py":6629
 *             # Case 1: Check if idle popup is active (triggered but not yet handled)
 *             # CRITICAL: While popup active, block ALL server uploads
 *             if self._idle_popup_active and self._idle_popup_triggered_at is not None:             # <<<<<<<<<<<<<<
 *                 logger.info("[APIBlock] Pausing uploads: Idle popup is active (triggered at %s)", self._idle_popup_triggered_at.isoformat())
 *                 return True
*/
      }

      /* "ws_package/controllers/activity_controller.py":6636
 *             # NEW: Hold idle intervals (single or multiple) even if there are non-idle intervals in the list
 *             # This ensures idle intervals are held until non-idle interval found or popup handled
 *             if not intervals:             # <<<<<<<<<<<<<<
 *                 # No intervals - don't pause (nothing to send anyway)
 *                 return False
*/
      {
        Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_intervals);
        if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 6636, __pyx_L5_error)
        __pyx_t_5 = (__pyx_temp != 0);
      }

      __pyx_t_9 = (!__pyx_t_5);
      if (__pyx_t_9) {

        /* "ws_package/controllers/activity_controller.py":6638
 *             if not intervals:
 *                 # No intervals - don't pause (nothing to send anyway)
 *                 return False             # <<<<<<<<<<<<<<
 * 
 *             # CRITICAL: Only process intervals from current counter (filter out intervals from previous counters)
*/
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_False);
        __pyx_r = Py_False;
        goto __pyx_L9_try_return;

        /* "ws_package/controllers/activity_controller.py":6636
 *             # NEW: Hold idle intervals (single or multiple) even if there are non-idle intervals in the list
 *             # This ensures idle intervals are held until non-idle interval found or popup handled
 *             if not intervals:             # <<<<<<<<<<<<<<
 *                 # No intervals - don't pause (nothing to send anyway)
 *                 return False
*/
      }

      /* "ws_package/controllers/activity_controller.py":6641
 * 
 *             # CRITICAL: Only process intervals from current counter (filter out intervals from previous counters)
 *             current_counter = self.last_count + 1             # <<<<<<<<<<<<<<
 *             current_counter_intervals = [iv for iv in intervals if getattr(iv, 'counter', None) == current_counter]
 * 
*/
      __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_last_count); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6641, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_1);
      __pyx_t_10 = __Pyx_PyLong_AddObjC(__pyx_t_1, __pyx_mstate_global->__pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 6641, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_10);
      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      __Pyx_GIVEREF(__pyx_t_10);
      __pyx_cur_scope->__pyx_v_current_counter = __pyx_t_10;
      __pyx_t_10 = 0;

      /* "ws_package/controllers/activity_controller.py":6642
 *             # CRITICAL: Only process intervals from current counter (filter out intervals from previous counters)
 *             current_counter = self.last_count + 1
 *             current_counter_intervals = [iv for iv in intervals if getattr(iv, 'counter', None) == current_counter]             # <<<<<<<<<<<<<<
 * 
 *             if not current_counter_intervals:
*/
      { /* enter inner scope */
        __pyx_t_10 = PyList_New(0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 6642, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_1 = __pyx_cur_scope->__pyx_v_intervals; __Pyx_INCREF(__pyx_t_1);
        __pyx_t_13 = 0;
        for (;;) {
          {
            Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
            #if !CYTHON_ASSUME_SAFE_SIZE
            if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6642, __pyx_L5_error)
            #endif
            if (__pyx_t_13 >= __pyx_temp) break;
          }
          __pyx_t_2 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_1, __pyx_t_13, __Pyx_ReferenceSharing_OwnStrongReference);
          ++__pyx_t_13;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6642, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_9genexpr27__pyx_v_iv);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_9genexpr27__pyx_v_iv, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __pyx_t_2 = 0;
          __pyx_t_2 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_9genexpr27__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_counter, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6642, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, __pyx_cur_scope->__pyx_v_current_counter, Py_EQ); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6642, __pyx_L5_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_9 < 0))) __PYX_ERR(0, 6642, __pyx_L5_error)
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          if (__pyx_t_9) {
            if (unlikely(__Pyx_ListComp_Append(__pyx_t_10, (PyObject*)__pyx_cur_scope->__pyx_9genexpr27__pyx_v_iv))) __PYX_ERR(0, 6642, __pyx_L5_error)
          }
        }
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
      } /* exit inner scope */
      __Pyx_GIVEREF(__pyx_t_10);
      __pyx_cur_scope->__pyx_v_current_counter_intervals = ((PyObject*)__pyx_t_10);
      __pyx_t_10 = 0;

      /* "ws_package/controllers/activity_controller.py":6644
 *             current_counter_intervals = [iv for iv in intervals if getattr(iv, 'counter', None) == current_counter]
 * 
 *             if not current_counter_intervals:             # <<<<<<<<<<<<<<
 *                 # All intervals are from previous counter - don't hold them
 *                 logger.debug("[APIBlock] All intervals are from previous counter (not %s) - not holding", current_counter)
*/
      {
        Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_current_counter_intervals);
        if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 6644, __pyx_L5_error)
        __pyx_t_9 = (__pyx_temp != 0);
      }

      __pyx_t_5 = (!__pyx_t_9);
      if (__pyx_t_5) {

        /* "ws_package/controllers/activity_controller.py":6646
 *             if not current_counter_intervals:
 *                 # All intervals are from previous counter - don't hold them
 *                 logger.debug("[APIBlock] All intervals are from previous counter (not %s) - not holding", current_counter)             # <<<<<<<<<<<<<<
 *                 return False
 * 
*/
        __pyx_t_1 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6646, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6646, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_2))) {
          __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
          assert(__pyx_t_1);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
          __Pyx_INCREF(__pyx_t_1);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_1, __pyx_mstate_global->__pyx_kp_u_APIBlock_All_intervals_are_from, __pyx_cur_scope->__pyx_v_current_counter};
          __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 6646, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_10);
        }
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;

        /* "ws_package/controllers/activity_controller.py":6647
 *                 # All intervals are from previous counter - don't hold them
 *                 logger.debug("[APIBlock] All intervals are from previous counter (not %s) - not holding", current_counter)
 *                 return False             # <<<<<<<<<<<<<<
 * 
 *             # CRITICAL FIX: Also check database for any unsent idle intervals that might not be in the intervals list
*/
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_False);
        __pyx_r = Py_False;
        goto __pyx_L9_try_return;

        /* "ws_package/controllers/activity_controller.py":6644
 *             current_counter_intervals = [iv for iv in intervals if getattr(iv, 'counter', None) == current_counter]
 * 
 *             if not current_counter_intervals:             # <<<<<<<<<<<<<<
 *                 # All intervals are from previous counter - don't hold them
 *                 logger.debug("[APIBlock] All intervals are from previous counter (not %s) - not holding", current_counter)
*/
      }

      /* "ws_package/controllers/activity_controller.py":6651
 *             # CRITICAL FIX: Also check database for any unsent idle intervals that might not be in the intervals list
 *             # This catches newly created idle intervals (e.g., interval 75) that were just saved but not yet in the query results
 *             try:             # <<<<<<<<<<<<<<
 *                 # Flush queue to ensure latest intervals are in DB
 *                 await db_writer_service.process_immediately()
*/
      {
        __Pyx_ExceptionSave(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
        __Pyx_XGOTREF(__pyx_t_14);
        __Pyx_XGOTREF(__pyx_t_15);
        __Pyx_XGOTREF(__pyx_t_16);
        /*try:*/ {

          /* "ws_package/controllers/activity_controller.py":6653
 *             try:
 *                 # Flush queue to ensure latest intervals are in DB
 *                 await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 *                 await asyncio.sleep(0.1)  # Small delay for DB write to complete
 * 
*/
          __pyx_t_2 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6653, __pyx_L20_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6653, __pyx_L20_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          __pyx_t_4 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_3))) {
            __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
            assert(__pyx_t_2);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
            __Pyx_INCREF(__pyx_t_2);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
            __pyx_t_4 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
            __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 6653, __pyx_L20_error)
            __Pyx_GOTREF(__pyx_t_10);
          }
          __pyx_t_17 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_10, &__pyx_r);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (likely(__pyx_t_17 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_6);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
            __Pyx_XGIVEREF(__pyx_t_7);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
            __Pyx_XGIVEREF(__pyx_t_8);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
            __Pyx_XGIVEREF(__pyx_t_14);
            __pyx_cur_scope->__pyx_t_3 = __pyx_t_14;
            __Pyx_XGIVEREF(__pyx_t_15);
            __pyx_cur_scope->__pyx_t_4 = __pyx_t_15;
            __Pyx_XGIVEREF(__pyx_t_16);
            __pyx_cur_scope->__pyx_t_5 = __pyx_t_16;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 1;
            return __pyx_r;
            __pyx_L26_resume_from_await:;
            __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_6);
            __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_7);
            __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_8);
            __pyx_t_14 = __pyx_cur_scope->__pyx_t_3;
            __pyx_cur_scope->__pyx_t_3 = 0;
            __Pyx_XGOTREF(__pyx_t_14);
            __pyx_t_15 = __pyx_cur_scope->__pyx_t_4;
            __pyx_cur_scope->__pyx_t_4 = 0;
            __Pyx_XGOTREF(__pyx_t_15);
            __pyx_t_16 = __pyx_cur_scope->__pyx_t_5;
            __pyx_cur_scope->__pyx_t_5 = 0;
            __Pyx_XGOTREF(__pyx_t_16);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6653, __pyx_L20_error)
          } else if (likely(__pyx_t_17 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_DECREF(__pyx_r); __pyx_r = 0;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 6653, __pyx_L20_error)
          }

          /* "ws_package/controllers/activity_controller.py":6654
 *                 # Flush queue to ensure latest intervals are in DB
 *                 await db_writer_service.process_immediately()
 *                 await asyncio.sleep(0.1)  # Small delay for DB write to complete             # <<<<<<<<<<<<<<
 * 
 *                 with db_lock_manager.read_lock():
*/
          __pyx_t_3 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6654, __pyx_L20_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6654, __pyx_L20_error)
          __Pyx_GOTREF(__pyx_t_1);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_4 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_1))) {
            __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
            assert(__pyx_t_3);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
            __Pyx_INCREF(__pyx_t_3);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
            __pyx_t_4 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_mstate_global->__pyx_float_0_1};
            __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 6654, __pyx_L20_error)
            __Pyx_GOTREF(__pyx_t_10);
          }
          __pyx_t_17 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_10, &__pyx_r);
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          if (likely(__pyx_t_17 == PYGEN_NEXT)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_XGIVEREF(__pyx_t_6);
            __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
            __Pyx_XGIVEREF(__pyx_t_7);
            __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
            __Pyx_XGIVEREF(__pyx_t_8);
            __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
            __Pyx_XGIVEREF(__pyx_t_14);
            __pyx_cur_scope->__pyx_t_3 = __pyx_t_14;
            __Pyx_XGIVEREF(__pyx_t_15);
            __pyx_cur_scope->__pyx_t_4 = __pyx_t_15;
            __Pyx_XGIVEREF(__pyx_t_16);
            __pyx_cur_scope->__pyx_t_5 = __pyx_t_16;
            __Pyx_XGIVEREF(__pyx_r);
            __Pyx_RefNannyFinishContext();
            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
            /* return from generator, awaiting value */
            __pyx_generator->resume_label = 2;
            return __pyx_r;
            __pyx_L27_resume_from_await:;
            __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
            __pyx_cur_scope->__pyx_t_0 = 0;
            __Pyx_XGOTREF(__pyx_t_6);
            __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
            __pyx_cur_scope->__pyx_t_1 = 0;
            __Pyx_XGOTREF(__pyx_t_7);
            __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
            __pyx_cur_scope->__pyx_t_2 = 0;
            __Pyx_XGOTREF(__pyx_t_8);
            __pyx_t_14 = __pyx_cur_scope->__pyx_t_3;
            __pyx_cur_scope->__pyx_t_3 = 0;
            __Pyx_XGOTREF(__pyx_t_14);
            __pyx_t_15 = __pyx_cur_scope->__pyx_t_4;
            __pyx_cur_scope->__pyx_t_4 = 0;
            __Pyx_XGOTREF(__pyx_t_15);
            __pyx_t_16 = __pyx_cur_scope->__pyx_t_5;
            __pyx_cur_scope->__pyx_t_5 = 0;
            __Pyx_XGOTREF(__pyx_t_16);
            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6654, __pyx_L20_error)
          } else if (likely(__pyx_t_17 == PYGEN_RETURN)) {
            __Pyx_GOTREF(__pyx_r);
            __Pyx_DECREF(__pyx_r); __pyx_r = 0;
          } else {
            __Pyx_XGOTREF(__pyx_r);
            __PYX_ERR(0, 6654, __pyx_L20_error)
          }

          /* "ws_package/controllers/activity_controller.py":6656
 *                 await asyncio.sleep(0.1)  # Small delay for DB write to complete
 * 
 *                 with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                     async with async_session() as session:
 *                         # Query for unsent idle intervals from current counter that might not be in intervals list
*/
          /*with:*/ {
            __pyx_t_1 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6656, __pyx_L20_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6656, __pyx_L20_error)
            __Pyx_GOTREF(__pyx_t_2);
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_2))) {
              __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_2);
              assert(__pyx_t_1);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_2);
              __Pyx_INCREF(__pyx_t_1);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_2, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
              __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_2, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
              if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 6656, __pyx_L20_error)
              __Pyx_GOTREF(__pyx_t_10);
            }
            __pyx_t_18 = __Pyx_PyObject_LookupSpecial(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 6656, __pyx_L20_error)
            __Pyx_GOTREF(__pyx_t_18);
            __pyx_t_1 = NULL;
            __pyx_t_3 = __Pyx_PyObject_LookupSpecial(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6656, __pyx_L28_error)
            __Pyx_GOTREF(__pyx_t_3);
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (likely(PyMethod_Check(__pyx_t_3))) {
              __pyx_t_1 = PyMethod_GET_SELF(__pyx_t_3);
              assert(__pyx_t_1);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
              __Pyx_INCREF(__pyx_t_1);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_1, NULL};
              __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
              if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6656, __pyx_L28_error)
              __Pyx_GOTREF(__pyx_t_2);
            }
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            /*try:*/ {
              {
                __Pyx_ExceptionSave(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21);
                __Pyx_XGOTREF(__pyx_t_19);
                __Pyx_XGOTREF(__pyx_t_20);
                __Pyx_XGOTREF(__pyx_t_21);
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":6657
 * 
 *                 with db_lock_manager.read_lock():
 *                     async with async_session() as session:             # <<<<<<<<<<<<<<
 *                         # Query for unsent idle intervals from current counter that might not be in intervals list
 *                         query = select(ActivityInterval).where(
*/
                  /*with:*/ {
                    __pyx_t_2 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6657, __pyx_L32_error)
                    __Pyx_GOTREF(__pyx_t_3);
                    __pyx_t_4 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_3))) {
                      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
                      assert(__pyx_t_2);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_3);
                      __Pyx_INCREF(__pyx_t_2);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_3, __pyx__function);
                      __pyx_t_4 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
                      __pyx_t_10 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_3, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                      if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 6657, __pyx_L32_error)
                      __Pyx_GOTREF(__pyx_t_10);
                    }
                    __pyx_t_22 = __Pyx_PyObject_LookupSpecial(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6657, __pyx_L32_error)
                    __Pyx_GOTREF(__pyx_t_22);
                    __pyx_t_2 = NULL;
                    __pyx_t_1 = __Pyx_PyObject_LookupSpecial(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6657, __pyx_L38_error)
                    __Pyx_GOTREF(__pyx_t_1);
                    __pyx_t_4 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (likely(PyMethod_Check(__pyx_t_1))) {
                      __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
                      assert(__pyx_t_2);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
                      __Pyx_INCREF(__pyx_t_2);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
                      __pyx_t_4 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[2] = {__pyx_t_2, NULL};
                      __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                      if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6657, __pyx_L38_error)
                      __Pyx_GOTREF(__pyx_t_3);
                    }
                    __pyx_t_17 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_3, &__pyx_r);
                    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                    if (likely(__pyx_t_17 == PYGEN_NEXT)) {
                      __Pyx_GOTREF(__pyx_r);
                      __Pyx_XGIVEREF(__pyx_t_6);
                      __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
                      __Pyx_XGIVEREF(__pyx_t_7);
                      __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
                      __Pyx_XGIVEREF(__pyx_t_8);
                      __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
                      __Pyx_XGIVEREF(__pyx_t_10);
                      __pyx_cur_scope->__pyx_t_3 = __pyx_t_10;
                      __Pyx_XGIVEREF(__pyx_t_14);
                      __pyx_cur_scope->__pyx_t_4 = __pyx_t_14;
                      __Pyx_XGIVEREF(__pyx_t_15);
                      __pyx_cur_scope->__pyx_t_5 = __pyx_t_15;
                      __Pyx_XGIVEREF(__pyx_t_16);
                      __pyx_cur_scope->__pyx_t_6 = __pyx_t_16;
                      __Pyx_XGIVEREF(__pyx_t_18);
                      __pyx_cur_scope->__pyx_t_7 = __pyx_t_18;
                      __Pyx_XGIVEREF(__pyx_t_19);
                      __pyx_cur_scope->__pyx_t_8 = __pyx_t_19;
                      __Pyx_XGIVEREF(__pyx_t_20);
                      __pyx_cur_scope->__pyx_t_9 = __pyx_t_20;
                      __Pyx_XGIVEREF(__pyx_t_21);
                      __pyx_cur_scope->__pyx_t_10 = __pyx_t_21;
                      __Pyx_XGIVEREF(__pyx_t_22);
                      __pyx_cur_scope->__pyx_t_11 = __pyx_t_22;
                      __Pyx_XGIVEREF(__pyx_r);
                      __Pyx_RefNannyFinishContext();
                      __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                      /* return from generator, awaiting value */
                      __pyx_generator->resume_label = 3;
                      return __pyx_r;
                      __pyx_L39_resume_from_await:;
                      __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
                      __pyx_cur_scope->__pyx_t_0 = 0;
                      __Pyx_XGOTREF(__pyx_t_6);
                      __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
                      __pyx_cur_scope->__pyx_t_1 = 0;
                      __Pyx_XGOTREF(__pyx_t_7);
                      __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
                      __pyx_cur_scope->__pyx_t_2 = 0;
                      __Pyx_XGOTREF(__pyx_t_8);
                      __pyx_t_10 = __pyx_cur_scope->__pyx_t_3;
                      __pyx_cur_scope->__pyx_t_3 = 0;
                      __Pyx_XGOTREF(__pyx_t_10);
                      __pyx_t_14 = __pyx_cur_scope->__pyx_t_4;
                      __pyx_cur_scope->__pyx_t_4 = 0;
                      __Pyx_XGOTREF(__pyx_t_14);
                      __pyx_t_15 = __pyx_cur_scope->__pyx_t_5;
                      __pyx_cur_scope->__pyx_t_5 = 0;
                      __Pyx_XGOTREF(__pyx_t_15);
                      __pyx_t_16 = __pyx_cur_scope->__pyx_t_6;
                      __pyx_cur_scope->__pyx_t_6 = 0;
                      __Pyx_XGOTREF(__pyx_t_16);
                      __pyx_t_18 = __pyx_cur_scope->__pyx_t_7;
                      __pyx_cur_scope->__pyx_t_7 = 0;
                      __Pyx_XGOTREF(__pyx_t_18);
                      __pyx_t_19 = __pyx_cur_scope->__pyx_t_8;
                      __pyx_cur_scope->__pyx_t_8 = 0;
                      __Pyx_XGOTREF(__pyx_t_19);
                      __pyx_t_20 = __pyx_cur_scope->__pyx_t_9;
                      __pyx_cur_scope->__pyx_t_9 = 0;
                      __Pyx_XGOTREF(__pyx_t_20);
                      __pyx_t_21 = __pyx_cur_scope->__pyx_t_10;
                      __pyx_cur_scope->__pyx_t_10 = 0;
                      __Pyx_XGOTREF(__pyx_t_21);
                      __pyx_t_22 = __pyx_cur_scope->__pyx_t_11;
                      __pyx_cur_scope->__pyx_t_11 = 0;
                      __Pyx_XGOTREF(__pyx_t_22);
                      if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6657, __pyx_L38_error)
                      __pyx_t_3 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_3);
                    } else if (likely(__pyx_t_17 == PYGEN_RETURN)) {
                      __Pyx_GOTREF(__pyx_r);
                      __pyx_t_3 = __pyx_r; __pyx_r = NULL;
                    } else {
                      __Pyx_XGOTREF(__pyx_r);
                      __PYX_ERR(0, 6657, __pyx_L38_error)
                    }
                    __pyx_t_1 = __pyx_t_3;
                    __pyx_t_3 = 0;
                    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
                    /*try:*/ {
                      {
                        __Pyx_ExceptionSave(&__pyx_t_23, &__pyx_t_24, &__pyx_t_25);
                        __Pyx_XGOTREF(__pyx_t_23);
                        __Pyx_XGOTREF(__pyx_t_24);
                        __Pyx_XGOTREF(__pyx_t_25);
                        /*try:*/ {
                          __Pyx_GIVEREF(__pyx_t_1);
                          __pyx_cur_scope->__pyx_v_session = __pyx_t_1;
                          __pyx_t_1 = 0;

                          /* "ws_package/controllers/activity_controller.py":6659
 *                     async with async_session() as session:
 *                         # Query for unsent idle intervals from current counter that might not be in intervals list
 *                         query = select(ActivityInterval).where(             # <<<<<<<<<<<<<<
 *                             ActivityInterval.counter == current_counter,
 *                             ActivityInterval.is_break == 0,
*/
                          __pyx_t_2 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 6659, __pyx_L43_error)
                          __Pyx_GOTREF(__pyx_t_12);
                          __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6659, __pyx_L43_error)
                          __Pyx_GOTREF(__pyx_t_11);
                          __pyx_t_4 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_12))) {
                            __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_12);
                            assert(__pyx_t_2);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
                            __Pyx_INCREF(__pyx_t_2);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
                            __pyx_t_4 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_11};
                            __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
                            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                            if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6659, __pyx_L43_error)
                            __Pyx_GOTREF(__pyx_t_3);
                          }
                          __pyx_t_10 = __pyx_t_3;
                          __Pyx_INCREF(__pyx_t_10);

                          /* "ws_package/controllers/activity_controller.py":6660
 *                         # Query for unsent idle intervals from current counter that might not be in intervals list
 *                         query = select(ActivityInterval).where(
 *                             ActivityInterval.counter == current_counter,             # <<<<<<<<<<<<<<
 *                             ActivityInterval.is_break == 0,
 *                             ActivityInterval.is_uploaded == 0
*/
                          __Pyx_GetModuleGlobalName(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 6660, __pyx_L43_error)
                          __Pyx_GOTREF(__pyx_t_12);
                          __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_12, __pyx_mstate_global->__pyx_n_u_counter); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6660, __pyx_L43_error)
                          __Pyx_GOTREF(__pyx_t_11);
                          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                          __pyx_t_12 = PyObject_RichCompare(__pyx_t_11, __pyx_cur_scope->__pyx_v_current_counter, Py_EQ); __Pyx_XGOTREF(__pyx_t_12); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 6660, __pyx_L43_error)
                          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;

                          /* "ws_package/controllers/activity_controller.py":6661
 *                         query = select(ActivityInterval).where(
 *                             ActivityInterval.counter == current_counter,
 *                             ActivityInterval.is_break == 0,             # <<<<<<<<<<<<<<
 *                             ActivityInterval.is_uploaded == 0
 *                         )
*/
                          __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6661, __pyx_L43_error)
                          __Pyx_GOTREF(__pyx_t_11);
                          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_is_break); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6661, __pyx_L43_error)
                          __Pyx_GOTREF(__pyx_t_2);
                          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
                          __pyx_t_11 = __Pyx_PyLong_EqObjC(__pyx_t_2, __pyx_mstate_global->__pyx_int_0, 0, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6661, __pyx_L43_error)
                          __Pyx_GOTREF(__pyx_t_11);
                          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

                          /* "ws_package/controllers/activity_controller.py":6662
 *                             ActivityInterval.counter == current_counter,
 *                             ActivityInterval.is_break == 0,
 *                             ActivityInterval.is_uploaded == 0             # <<<<<<<<<<<<<<
 *                         )
 *                         result = await session.execute(query)
*/
                          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6662, __pyx_L43_error)
                          __Pyx_GOTREF(__pyx_t_2);
                          __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_is_uploaded); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 6662, __pyx_L43_error)
                          __Pyx_GOTREF(__pyx_t_26);
                          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                          __pyx_t_2 = __Pyx_PyLong_EqObjC(__pyx_t_26, __pyx_mstate_global->__pyx_int_0, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6662, __pyx_L43_error)
                          __Pyx_GOTREF(__pyx_t_2);
                          __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
                          __pyx_t_4 = 0;
                          {
                            PyObject *__pyx_callargs[4] = {__pyx_t_10, __pyx_t_12, __pyx_t_11, __pyx_t_2};
                            __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_4, (4-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                            __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
                            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6659, __pyx_L43_error)
                            __Pyx_GOTREF(__pyx_t_1);
                          }
                          __Pyx_GIVEREF(__pyx_t_1);
                          __pyx_cur_scope->__pyx_v_query = __pyx_t_1;
                          __pyx_t_1 = 0;

                          /* "ws_package/controllers/activity_controller.py":6664
 *                             ActivityInterval.is_uploaded == 0
 *                         )
 *                         result = await session.execute(query)             # <<<<<<<<<<<<<<
 *                         db_intervals = result.scalars().all()
 * 
*/
                          __pyx_t_3 = __pyx_cur_scope->__pyx_v_session;
                          __Pyx_INCREF(__pyx_t_3);
                          __pyx_t_4 = 0;
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_3, __pyx_cur_scope->__pyx_v_query};
                            __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_4, (2-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6664, __pyx_L43_error)
                            __Pyx_GOTREF(__pyx_t_1);
                          }
                          __pyx_t_17 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_1, &__pyx_r);
                          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
                          if (likely(__pyx_t_17 == PYGEN_NEXT)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_XGIVEREF(__pyx_t_6);
                            __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
                            __Pyx_XGIVEREF(__pyx_t_7);
                            __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
                            __Pyx_XGIVEREF(__pyx_t_8);
                            __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
                            __Pyx_XGIVEREF(__pyx_t_14);
                            __pyx_cur_scope->__pyx_t_3 = __pyx_t_14;
                            __Pyx_XGIVEREF(__pyx_t_15);
                            __pyx_cur_scope->__pyx_t_4 = __pyx_t_15;
                            __Pyx_XGIVEREF(__pyx_t_16);
                            __pyx_cur_scope->__pyx_t_5 = __pyx_t_16;
                            __Pyx_XGIVEREF(__pyx_t_18);
                            __pyx_cur_scope->__pyx_t_6 = __pyx_t_18;
                            __Pyx_XGIVEREF(__pyx_t_19);
                            __pyx_cur_scope->__pyx_t_7 = __pyx_t_19;
                            __Pyx_XGIVEREF(__pyx_t_20);
                            __pyx_cur_scope->__pyx_t_8 = __pyx_t_20;
                            __Pyx_XGIVEREF(__pyx_t_21);
                            __pyx_cur_scope->__pyx_t_9 = __pyx_t_21;
                            __Pyx_XGIVEREF(__pyx_t_22);
                            __pyx_cur_scope->__pyx_t_10 = __pyx_t_22;
                            __Pyx_XGIVEREF(__pyx_t_23);
                            __pyx_cur_scope->__pyx_t_11 = __pyx_t_23;
                            __Pyx_XGIVEREF(__pyx_t_24);
                            __pyx_cur_scope->__pyx_t_12 = __pyx_t_24;
                            __Pyx_XGIVEREF(__pyx_t_25);
                            __pyx_cur_scope->__pyx_t_13 = __pyx_t_25;
                            __Pyx_XGIVEREF(__pyx_r);
                            __Pyx_RefNannyFinishContext();
                            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                            /* return from generator, awaiting value */
                            __pyx_generator->resume_label = 4;
                            return __pyx_r;
                            __pyx_L49_resume_from_await:;
                            __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
                            __pyx_cur_scope->__pyx_t_0 = 0;
                            __Pyx_XGOTREF(__pyx_t_6);
                            __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
                            __pyx_cur_scope->__pyx_t_1 = 0;
                            __Pyx_XGOTREF(__pyx_t_7);
                            __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
                            __pyx_cur_scope->__pyx_t_2 = 0;
                            __Pyx_XGOTREF(__pyx_t_8);
                            __pyx_t_14 = __pyx_cur_scope->__pyx_t_3;
                            __pyx_cur_scope->__pyx_t_3 = 0;
                            __Pyx_XGOTREF(__pyx_t_14);
                            __pyx_t_15 = __pyx_cur_scope->__pyx_t_4;
                            __pyx_cur_scope->__pyx_t_4 = 0;
                            __Pyx_XGOTREF(__pyx_t_15);
                            __pyx_t_16 = __pyx_cur_scope->__pyx_t_5;
                            __pyx_cur_scope->__pyx_t_5 = 0;
                            __Pyx_XGOTREF(__pyx_t_16);
                            __pyx_t_18 = __pyx_cur_scope->__pyx_t_6;
                            __pyx_cur_scope->__pyx_t_6 = 0;
                            __Pyx_XGOTREF(__pyx_t_18);
                            __pyx_t_19 = __pyx_cur_scope->__pyx_t_7;
                            __pyx_cur_scope->__pyx_t_7 = 0;
                            __Pyx_XGOTREF(__pyx_t_19);
                            __pyx_t_20 = __pyx_cur_scope->__pyx_t_8;
                            __pyx_cur_scope->__pyx_t_8 = 0;
                            __Pyx_XGOTREF(__pyx_t_20);
                            __pyx_t_21 = __pyx_cur_scope->__pyx_t_9;
                            __pyx_cur_scope->__pyx_t_9 = 0;
                            __Pyx_XGOTREF(__pyx_t_21);
                            __pyx_t_22 = __pyx_cur_scope->__pyx_t_10;
                            __pyx_cur_scope->__pyx_t_10 = 0;
                            __Pyx_XGOTREF(__pyx_t_22);
                            __pyx_t_23 = __pyx_cur_scope->__pyx_t_11;
                            __pyx_cur_scope->__pyx_t_11 = 0;
                            __Pyx_XGOTREF(__pyx_t_23);
                            __pyx_t_24 = __pyx_cur_scope->__pyx_t_12;
                            __pyx_cur_scope->__pyx_t_12 = 0;
                            __Pyx_XGOTREF(__pyx_t_24);
                            __pyx_t_25 = __pyx_cur_scope->__pyx_t_13;
                            __pyx_cur_scope->__pyx_t_13 = 0;
                            __Pyx_XGOTREF(__pyx_t_25);
                            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6664, __pyx_L43_error)
                            __pyx_t_1 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_1);
                          } else if (likely(__pyx_t_17 == PYGEN_RETURN)) {
                            __Pyx_GOTREF(__pyx_r);
                            __pyx_t_1 = __pyx_r; __pyx_r = NULL;
                          } else {
                            __Pyx_XGOTREF(__pyx_r);
                            __PYX_ERR(0, 6664, __pyx_L43_error)
                          }
                          __Pyx_GIVEREF(__pyx_t_1);
                          __pyx_cur_scope->__pyx_v_result = __pyx_t_1;
                          __pyx_t_1 = 0;

                          /* "ws_package/controllers/activity_controller.py":6665
 *                         )
 *                         result = await session.execute(query)
 *                         db_intervals = result.scalars().all()             # <<<<<<<<<<<<<<
 * 
 *                         # Check each DB interval for zero activity and add to current_counter_intervals if not already there
*/
                          __pyx_t_11 = __pyx_cur_scope->__pyx_v_result;
                          __Pyx_INCREF(__pyx_t_11);
                          __pyx_t_4 = 0;
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_11, NULL};
                            __pyx_t_2 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalars, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
                            if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6665, __pyx_L43_error)
                            __Pyx_GOTREF(__pyx_t_2);
                          }
                          __pyx_t_3 = __pyx_t_2;
                          __Pyx_INCREF(__pyx_t_3);
                          __pyx_t_4 = 0;
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_3, NULL};
                            __pyx_t_1 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_all, __pyx_callargs+__pyx_t_4, (1-__pyx_t_4) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                            if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6665, __pyx_L43_error)
                            __Pyx_GOTREF(__pyx_t_1);
                          }
                          __Pyx_GIVEREF(__pyx_t_1);
                          __pyx_cur_scope->__pyx_v_db_intervals = __pyx_t_1;
                          __pyx_t_1 = 0;

                          /* "ws_package/controllers/activity_controller.py":6668
 * 
 *                         # Check each DB interval for zero activity and add to current_counter_intervals if not already there
 *                         interval_ids_in_list = {getattr(iv, 'id', None) for iv in current_counter_intervals}             # <<<<<<<<<<<<<<
 *                         for db_interval in db_intervals:
 *                             # Skip if already in the list
*/
                          { /* enter inner scope */
                            __pyx_t_1 = PySet_New(NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6668, __pyx_L43_error)
                            __Pyx_GOTREF(__pyx_t_1);
                            __pyx_t_2 = __pyx_cur_scope->__pyx_v_current_counter_intervals; __Pyx_INCREF(__pyx_t_2);
                            __pyx_t_13 = 0;
                            for (;;) {
                              {
                                Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_2);
                                #if !CYTHON_ASSUME_SAFE_SIZE
                                if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6668, __pyx_L43_error)
                                #endif
                                if (__pyx_t_13 >= __pyx_temp) break;
                              }
                              __pyx_t_3 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_2, __pyx_t_13, __Pyx_ReferenceSharing_OwnStrongReference);
                              ++__pyx_t_13;
                              if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6668, __pyx_L43_error)
                              __Pyx_GOTREF(__pyx_t_3);
                              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_9genexpr28__pyx_v_iv);
                              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_9genexpr28__pyx_v_iv, __pyx_t_3);
                              __Pyx_GIVEREF(__pyx_t_3);
                              __pyx_t_3 = 0;
                              __pyx_t_3 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_9genexpr28__pyx_v_iv, __pyx_mstate_global->__pyx_n_u_id, Py_None); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6668, __pyx_L43_error)
                              __Pyx_GOTREF(__pyx_t_3);
                              if (unlikely(PySet_Add(__pyx_t_1, (PyObject*)__pyx_t_3))) __PYX_ERR(0, 6668, __pyx_L43_error)
                              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                            }
                            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                          } /* exit inner scope */
                          __Pyx_GIVEREF(__pyx_t_1);
                          __pyx_cur_scope->__pyx_v_interval_ids_in_list = ((PyObject*)__pyx_t_1);
                          __pyx_t_1 = 0;

                          /* "ws_package/controllers/activity_controller.py":6669
 *                         # Check each DB interval for zero activity and add to current_counter_intervals if not already there
 *                         interval_ids_in_list = {getattr(iv, 'id', None) for iv in current_counter_intervals}
 *                         for db_interval in db_intervals:             # <<<<<<<<<<<<<<
 *                             # Skip if already in the list
 *                             if getattr(db_interval, 'id', None) in interval_ids_in_list:
*/
                          if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_db_intervals)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_db_intervals)) {
                            __pyx_t_1 = __pyx_cur_scope->__pyx_v_db_intervals; __Pyx_INCREF(__pyx_t_1);
                            __pyx_t_13 = 0;
                            __pyx_t_27 = NULL;
                          } else {
                            __pyx_t_13 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_db_intervals); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6669, __pyx_L43_error)
                            __Pyx_GOTREF(__pyx_t_1);
                            __pyx_t_27 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_1); if (unlikely(!__pyx_t_27)) __PYX_ERR(0, 6669, __pyx_L43_error)
                          }
                          for (;;) {
                            if (likely(!__pyx_t_27)) {
                              if (likely(PyList_CheckExact(__pyx_t_1))) {
                                {
                                  Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_1);
                                  #if !CYTHON_ASSUME_SAFE_SIZE
                                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6669, __pyx_L43_error)
                                  #endif
                                  if (__pyx_t_13 >= __pyx_temp) break;
                                }
                                __pyx_t_2 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_1, __pyx_t_13, __Pyx_ReferenceSharing_OwnStrongReference);
                                ++__pyx_t_13;
                              } else {
                                {
                                  Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_1);
                                  #if !CYTHON_ASSUME_SAFE_SIZE
                                  if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6669, __pyx_L43_error)
                                  #endif
                                  if (__pyx_t_13 >= __pyx_temp) break;
                                }
                                #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                                __pyx_t_2 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_13));
                                #else
                                __pyx_t_2 = __Pyx_PySequence_ITEM(__pyx_t_1, __pyx_t_13);
                                #endif
                                ++__pyx_t_13;
                              }
                              if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6669, __pyx_L43_error)
                            } else {
                              __pyx_t_2 = __pyx_t_27(__pyx_t_1);
                              if (unlikely(!__pyx_t_2)) {
                                PyObject* exc_type = PyErr_Occurred();
                                if (exc_type) {
                                  if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 6669, __pyx_L43_error)
                                  PyErr_Clear();
                                }
                                break;
                              }
                            }
                            __Pyx_GOTREF(__pyx_t_2);
                            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_db_interval);
                            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_db_interval, __pyx_t_2);
                            __Pyx_GIVEREF(__pyx_t_2);
                            __pyx_t_2 = 0;

                            /* "ws_package/controllers/activity_controller.py":6671
 *                         for db_interval in db_intervals:
 *                             # Skip if already in the list
 *                             if getattr(db_interval, 'id', None) in interval_ids_in_list:             # <<<<<<<<<<<<<<
 *                                 continue
 * 
*/
                            __pyx_t_2 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_db_interval, __pyx_mstate_global->__pyx_n_u_id, Py_None); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6671, __pyx_L43_error)
                            __Pyx_GOTREF(__pyx_t_2);
                            __pyx_t_5 = (__Pyx_PySet_ContainsTF(__pyx_t_2, __pyx_cur_scope->__pyx_v_interval_ids_in_list, Py_EQ)); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 6671, __pyx_L43_error)
                            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                            if (__pyx_t_5) {

                              /* "ws_package/controllers/activity_controller.py":6672
 *                             # Skip if already in the list
 *                             if getattr(db_interval, 'id', None) in interval_ids_in_list:
 *                                 continue             # <<<<<<<<<<<<<<
 * 
 *                             # Check if it has zero activity
*/
                              goto __pyx_L53_continue;

                              /* "ws_package/controllers/activity_controller.py":6671
 *                         for db_interval in db_intervals:
 *                             # Skip if already in the list
 *                             if getattr(db_interval, 'id', None) in interval_ids_in_list:             # <<<<<<<<<<<<<<
 *                                 continue
 * 
*/
                            }

                            /* "ws_package/controllers/activity_controller.py":6675
 * 
 *                             # Check if it has zero activity
 *                             activity_level = db_interval.activityLevel if hasattr(db_interval, 'activityLevel') else {}             # <<<<<<<<<<<<<<
 *                             keyboard = float(activity_level.get('keyboard', '0.0') or '0.0')
 *                             mouse = float(activity_level.get('mouse', '0.0') or '0.0')
*/
                            __pyx_t_5 = __Pyx_HasAttr(__pyx_cur_scope->__pyx_v_db_interval, __pyx_mstate_global->__pyx_n_u_activityLevel); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 6675, __pyx_L43_error)
                            if (__pyx_t_5) {
                              __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_db_interval, __pyx_mstate_global->__pyx_n_u_activityLevel); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6675, __pyx_L43_error)
                              __Pyx_GOTREF(__pyx_t_3);
                              __pyx_t_2 = __pyx_t_3;
                              __pyx_t_3 = 0;
                            } else {
                              __pyx_t_3 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6675, __pyx_L43_error)
                              __Pyx_GOTREF(__pyx_t_3);
                              __pyx_t_2 = __pyx_t_3;
                              __pyx_t_3 = 0;
                            }
                            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_activity_level);
                            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_activity_level, __pyx_t_2);
                            __Pyx_GIVEREF(__pyx_t_2);
                            __pyx_t_2 = 0;

                            /* "ws_package/controllers/activity_controller.py":6676
 *                             # Check if it has zero activity
 *                             activity_level = db_interval.activityLevel if hasattr(db_interval, 'activityLevel') else {}
 *                             keyboard = float(activity_level.get('keyboard', '0.0') or '0.0')             # <<<<<<<<<<<<<<
 *                             mouse = float(activity_level.get('mouse', '0.0') or '0.0')
 *                             average = float(activity_level.get('average', '0.0') or '0.0')
*/
                            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activity_level, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6676, __pyx_L43_error)
                            __Pyx_GOTREF(__pyx_t_3);
                            __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_mstate_global->__pyx_tuple[24], NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6676, __pyx_L43_error)
                            __Pyx_GOTREF(__pyx_t_11);
                            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                            __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 6676, __pyx_L43_error)
                            if (!__pyx_t_5) {
                              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
                            } else {
                              __Pyx_INCREF(__pyx_t_11);
                              __pyx_t_2 = __pyx_t_11;
                              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
                              goto __pyx_L56_bool_binop_done;
                            }
                            __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_0_0);
                            __pyx_t_2 = __pyx_mstate_global->__pyx_kp_u_0_0;
                            __pyx_L56_bool_binop_done:;
                            __pyx_t_28 = __Pyx_PyObject_AsDouble(__pyx_t_2); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_28, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 6676, __pyx_L43_error)
                            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                            __pyx_cur_scope->__pyx_v_keyboard = __pyx_t_28;

                            /* "ws_package/controllers/activity_controller.py":6677
 *                             activity_level = db_interval.activityLevel if hasattr(db_interval, 'activityLevel') else {}
 *                             keyboard = float(activity_level.get('keyboard', '0.0') or '0.0')
 *                             mouse = float(activity_level.get('mouse', '0.0') or '0.0')             # <<<<<<<<<<<<<<
 *                             average = float(activity_level.get('average', '0.0') or '0.0')
 * 
*/
                            __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activity_level, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6677, __pyx_L43_error)
                            __Pyx_GOTREF(__pyx_t_11);
                            __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_11, __pyx_mstate_global->__pyx_tuple[25], NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6677, __pyx_L43_error)
                            __Pyx_GOTREF(__pyx_t_3);
                            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
                            __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 6677, __pyx_L43_error)
                            if (!__pyx_t_5) {
                              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                            } else {
                              __Pyx_INCREF(__pyx_t_3);
                              __pyx_t_2 = __pyx_t_3;
                              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                              goto __pyx_L58_bool_binop_done;
                            }
                            __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_0_0);
                            __pyx_t_2 = __pyx_mstate_global->__pyx_kp_u_0_0;
                            __pyx_L58_bool_binop_done:;
                            __pyx_t_28 = __Pyx_PyObject_AsDouble(__pyx_t_2); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_28, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 6677, __pyx_L43_error)
                            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                            __pyx_cur_scope->__pyx_v_mouse = __pyx_t_28;

                            /* "ws_package/controllers/activity_controller.py":6678
 *                             keyboard = float(activity_level.get('keyboard', '0.0') or '0.0')
 *                             mouse = float(activity_level.get('mouse', '0.0') or '0.0')
 *                             average = float(activity_level.get('average', '0.0') or '0.0')             # <<<<<<<<<<<<<<
 * 
 *                             if keyboard == 0 and mouse == 0 and average == 0:
*/
                            __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activity_level, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6678, __pyx_L43_error)
                            __Pyx_GOTREF(__pyx_t_3);
                            __pyx_t_11 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_mstate_global->__pyx_tuple[26], NULL); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6678, __pyx_L43_error)
                            __Pyx_GOTREF(__pyx_t_11);
                            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                            __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_11); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 6678, __pyx_L43_error)
                            if (!__pyx_t_5) {
                              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
                            } else {
                              __Pyx_INCREF(__pyx_t_11);
                              __pyx_t_2 = __pyx_t_11;
                              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
                              goto __pyx_L60_bool_binop_done;
                            }
                            __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_0_0);
                            __pyx_t_2 = __pyx_mstate_global->__pyx_kp_u_0_0;
                            __pyx_L60_bool_binop_done:;
                            __pyx_t_28 = __Pyx_PyObject_AsDouble(__pyx_t_2); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_28, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 6678, __pyx_L43_error)
                            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
                            __pyx_cur_scope->__pyx_v_average = __pyx_t_28;

                            /* "ws_package/controllers/activity_controller.py":6680
 *                             average = float(activity_level.get('average', '0.0') or '0.0')
 * 
 *                             if keyboard == 0 and mouse == 0 and average == 0:             # <<<<<<<<<<<<<<
 *                                 # Found an idle interval in DB that's not in the list - add it
 *                                 current_counter_intervals.append(db_interval)
*/
                            __pyx_t_9 = (__pyx_cur_scope->__pyx_v_keyboard == 0.0);
                            if (__pyx_t_9) {
                            } else {
                              __pyx_t_5 = __pyx_t_9;
                              goto __pyx_L63_bool_binop_done;
                            }
                            __pyx_t_9 = (__pyx_cur_scope->__pyx_v_mouse == 0.0);
                            if (__pyx_t_9) {
                            } else {
                              __pyx_t_5 = __pyx_t_9;
                              goto __pyx_L63_bool_binop_done;
                            }
                            __pyx_t_9 = (__pyx_cur_scope->__pyx_v_average == 0.0);
                            __pyx_t_5 = __pyx_t_9;
                            __pyx_L63_bool_binop_done:;
                            if (__pyx_t_5) {

                              /* "ws_package/controllers/activity_controller.py":6682
 *                             if keyboard == 0 and mouse == 0 and average == 0:
 *                                 # Found an idle interval in DB that's not in the list - add it
 *                                 current_counter_intervals.append(db_interval)             # <<<<<<<<<<<<<<
 *                                 logger.debug("[APIBlock] Found unsent idle interval in DB (id=%s) that wasn't in intervals list - adding to check", db_interval.id)
 *             except Exception as e:
*/
                              __pyx_t_29 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_current_counter_intervals, __pyx_cur_scope->__pyx_v_db_interval); if (unlikely(__pyx_t_29 == ((int)-1))) __PYX_ERR(0, 6682, __pyx_L43_error)

                              /* "ws_package/controllers/activity_controller.py":6683
 *                                 # Found an idle interval in DB that's not in the list - add it
 *                                 current_counter_intervals.append(db_interval)
 *                                 logger.debug("[APIBlock] Found unsent idle interval in DB (id=%s) that wasn't in intervals list - adding to check", db_interval.id)             # <<<<<<<<<<<<<<
 *             except Exception as e:
 *                 logger.warning("[APIBlock] Error checking database for idle intervals: %s - continuing with intervals list only", e)
*/
                              __pyx_t_11 = NULL;
                              __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6683, __pyx_L43_error)
                              __Pyx_GOTREF(__pyx_t_3);
                              __pyx_t_12 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 6683, __pyx_L43_error)
                              __Pyx_GOTREF(__pyx_t_12);
                              __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                              __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_db_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6683, __pyx_L43_error)
                              __Pyx_GOTREF(__pyx_t_3);
                              __pyx_t_4 = 1;
                              #if CYTHON_UNPACK_METHODS
                              if (unlikely(PyMethod_Check(__pyx_t_12))) {
                                __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_12);
                                assert(__pyx_t_11);
                                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_12);
                                __Pyx_INCREF(__pyx_t_11);
                                __Pyx_INCREF(__pyx__function);
                                __Pyx_DECREF_SET(__pyx_t_12, __pyx__function);
                                __pyx_t_4 = 0;
                              }
                              #endif
                              {
                                PyObject *__pyx_callargs[3] = {__pyx_t_11, __pyx_mstate_global->__pyx_kp_u_APIBlock_Found_unsent_idle_inte, __pyx_t_3};
                                __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_12, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
                                __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                                __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
                                if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6683, __pyx_L43_error)
                                __Pyx_GOTREF(__pyx_t_2);
                              }
                              __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

                              /* "ws_package/controllers/activity_controller.py":6680
 *                             average = float(activity_level.get('average', '0.0') or '0.0')
 * 
 *                             if keyboard == 0 and mouse == 0 and average == 0:             # <<<<<<<<<<<<<<
 *                                 # Found an idle interval in DB that's not in the list - add it
 *                                 current_counter_intervals.append(db_interval)
*/
                            }

                            /* "ws_package/controllers/activity_controller.py":6669
 *                         # Check each DB interval for zero activity and add to current_counter_intervals if not already there
 *                         interval_ids_in_list = {getattr(iv, 'id', None) for iv in current_counter_intervals}
 *                         for db_interval in db_intervals:             # <<<<<<<<<<<<<<
 *                             # Skip if already in the list
 *                             if getattr(db_interval, 'id', None) in interval_ids_in_list:
*/
                            __pyx_L53_continue:;
                          }
                          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;

                          /* "ws_package/controllers/activity_controller.py":6657
 * 
 *                 with db_lock_manager.read_lock():
 *                     async with async_session() as session:             # <<<<<<<<<<<<<<
 *                         # Query for unsent idle intervals from current counter that might not be in intervals list
 *                         query = select(ActivityInterval).where(
*/
                        }
                        __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                        __Pyx_XDECREF(__pyx_t_25); __pyx_t_25 = 0;
                        goto __pyx_L48_try_end;
                        __pyx_L43_error:;
                        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
                        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                        __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                        /*except:*/ {
                          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._should_pause_api_calls", __pyx_clineno, __pyx_lineno, __pyx_filename);
                          if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_12) < 0) __PYX_ERR(0, 6657, __pyx_L45_except_error)
                          __Pyx_XGOTREF(__pyx_t_1);
                          __Pyx_XGOTREF(__pyx_t_2);
                          __Pyx_XGOTREF(__pyx_t_12);
                          __pyx_t_3 = PyTuple_Pack(3, __pyx_t_1, __pyx_t_2, __pyx_t_12); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6657, __pyx_L45_except_error)
                          __Pyx_GOTREF(__pyx_t_3);
                          __pyx_t_30 = __Pyx_PyObject_Call(__pyx_t_22, __pyx_t_3, NULL);
                          __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                          if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 6657, __pyx_L45_except_error)
                          __Pyx_GOTREF(__pyx_t_30);
                          __pyx_t_17 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_30, &__pyx_r);
                          __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
                          if (likely(__pyx_t_17 == PYGEN_NEXT)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_XGIVEREF(__pyx_t_1);
                            __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                            __Pyx_XGIVEREF(__pyx_t_2);
                            __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                            __Pyx_XGIVEREF(__pyx_t_6);
                            __pyx_cur_scope->__pyx_t_2 = __pyx_t_6;
                            __Pyx_XGIVEREF(__pyx_t_7);
                            __pyx_cur_scope->__pyx_t_3 = __pyx_t_7;
                            __Pyx_XGIVEREF(__pyx_t_8);
                            __pyx_cur_scope->__pyx_t_4 = __pyx_t_8;
                            __Pyx_XGIVEREF(__pyx_t_12);
                            __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                            __Pyx_XGIVEREF(__pyx_t_14);
                            __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                            __Pyx_XGIVEREF(__pyx_t_15);
                            __pyx_cur_scope->__pyx_t_7 = __pyx_t_15;
                            __Pyx_XGIVEREF(__pyx_t_16);
                            __pyx_cur_scope->__pyx_t_8 = __pyx_t_16;
                            __Pyx_XGIVEREF(__pyx_t_18);
                            __pyx_cur_scope->__pyx_t_9 = __pyx_t_18;
                            __Pyx_XGIVEREF(__pyx_t_19);
                            __pyx_cur_scope->__pyx_t_10 = __pyx_t_19;
                            __Pyx_XGIVEREF(__pyx_t_20);
                            __pyx_cur_scope->__pyx_t_11 = __pyx_t_20;
                            __Pyx_XGIVEREF(__pyx_t_21);
                            __pyx_cur_scope->__pyx_t_12 = __pyx_t_21;
                            __Pyx_XGIVEREF(__pyx_t_22);
                            __pyx_cur_scope->__pyx_t_13 = __pyx_t_22;
                            __Pyx_XGIVEREF(__pyx_t_23);
                            __pyx_cur_scope->__pyx_t_14 = __pyx_t_23;
                            __Pyx_XGIVEREF(__pyx_t_24);
                            __pyx_cur_scope->__pyx_t_15 = __pyx_t_24;
                            __Pyx_XGIVEREF(__pyx_t_25);
                            __pyx_cur_scope->__pyx_t_16 = __pyx_t_25;
                            __Pyx_XGIVEREF(__pyx_t_30);
                            __pyx_cur_scope->__pyx_t_17 = __pyx_t_30;
                            __Pyx_XGIVEREF(__pyx_r);
                            __Pyx_RefNannyFinishContext();
                            __Pyx_Coroutine_SwapException(__pyx_generator);
                            /* return from generator, awaiting value */
                            __pyx_generator->resume_label = 5;
                            return __pyx_r;
                            __pyx_L70_resume_from_await:;
                            __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                            __pyx_cur_scope->__pyx_t_0 = 0;
                            __Pyx_XGOTREF(__pyx_t_1);
                            __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                            __pyx_cur_scope->__pyx_t_1 = 0;
                            __Pyx_XGOTREF(__pyx_t_2);
                            __pyx_t_6 = __pyx_cur_scope->__pyx_t_2;
                            __pyx_cur_scope->__pyx_t_2 = 0;
                            __Pyx_XGOTREF(__pyx_t_6);
                            __pyx_t_7 = __pyx_cur_scope->__pyx_t_3;
                            __pyx_cur_scope->__pyx_t_3 = 0;
                            __Pyx_XGOTREF(__pyx_t_7);
                            __pyx_t_8 = __pyx_cur_scope->__pyx_t_4;
                            __pyx_cur_scope->__pyx_t_4 = 0;
                            __Pyx_XGOTREF(__pyx_t_8);
                            __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                            __pyx_cur_scope->__pyx_t_5 = 0;
                            __Pyx_XGOTREF(__pyx_t_12);
                            __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                            __pyx_cur_scope->__pyx_t_6 = 0;
                            __Pyx_XGOTREF(__pyx_t_14);
                            __pyx_t_15 = __pyx_cur_scope->__pyx_t_7;
                            __pyx_cur_scope->__pyx_t_7 = 0;
                            __Pyx_XGOTREF(__pyx_t_15);
                            __pyx_t_16 = __pyx_cur_scope->__pyx_t_8;
                            __pyx_cur_scope->__pyx_t_8 = 0;
                            __Pyx_XGOTREF(__pyx_t_16);
                            __pyx_t_18 = __pyx_cur_scope->__pyx_t_9;
                            __pyx_cur_scope->__pyx_t_9 = 0;
                            __Pyx_XGOTREF(__pyx_t_18);
                            __pyx_t_19 = __pyx_cur_scope->__pyx_t_10;
                            __pyx_cur_scope->__pyx_t_10 = 0;
                            __Pyx_XGOTREF(__pyx_t_19);
                            __pyx_t_20 = __pyx_cur_scope->__pyx_t_11;
                            __pyx_cur_scope->__pyx_t_11 = 0;
                            __Pyx_XGOTREF(__pyx_t_20);
                            __pyx_t_21 = __pyx_cur_scope->__pyx_t_12;
                            __pyx_cur_scope->__pyx_t_12 = 0;
                            __Pyx_XGOTREF(__pyx_t_21);
                            __pyx_t_22 = __pyx_cur_scope->__pyx_t_13;
                            __pyx_cur_scope->__pyx_t_13 = 0;
                            __Pyx_XGOTREF(__pyx_t_22);
                            __pyx_t_23 = __pyx_cur_scope->__pyx_t_14;
                            __pyx_cur_scope->__pyx_t_14 = 0;
                            __Pyx_XGOTREF(__pyx_t_23);
                            __pyx_t_24 = __pyx_cur_scope->__pyx_t_15;
                            __pyx_cur_scope->__pyx_t_15 = 0;
                            __Pyx_XGOTREF(__pyx_t_24);
                            __pyx_t_25 = __pyx_cur_scope->__pyx_t_16;
                            __pyx_cur_scope->__pyx_t_16 = 0;
                            __Pyx_XGOTREF(__pyx_t_25);
                            __pyx_t_30 = __pyx_cur_scope->__pyx_t_17;
                            __pyx_cur_scope->__pyx_t_17 = 0;
                            __Pyx_XGOTREF(__pyx_t_30);
                            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6657, __pyx_L45_except_error)
                            __pyx_t_3 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_3);
                          } else if (likely(__pyx_t_17 == PYGEN_RETURN)) {
                            __Pyx_GOTREF(__pyx_r);
                            __pyx_t_3 = __pyx_r; __pyx_r = NULL;
                          } else {
                            __Pyx_XGOTREF(__pyx_r);
                            __PYX_ERR(0, 6657, __pyx_L45_except_error)
                          }
                          __pyx_t_30 = __pyx_t_3;
                          __pyx_t_3 = 0;
                          __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_30);
                          __Pyx_DECREF(__pyx_t_30); __pyx_t_30 = 0;
                          if (__pyx_t_5 < (0)) __PYX_ERR(0, 6657, __pyx_L45_except_error)
                          __pyx_t_9 = (!__pyx_t_5);
                          if (unlikely(__pyx_t_9)) {
                            __Pyx_GIVEREF(__pyx_t_1);
                            __Pyx_GIVEREF(__pyx_t_2);
                            __Pyx_XGIVEREF(__pyx_t_12);
                            __Pyx_ErrRestoreWithState(__pyx_t_1, __pyx_t_2, __pyx_t_12);
                            __pyx_t_1 = 0;  __pyx_t_2 = 0;  __pyx_t_12 = 0; 
                            __PYX_ERR(0, 6657, __pyx_L45_except_error)
                          }
                          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                          goto __pyx_L44_exception_handled;
                        }
                        __pyx_L45_except_error:;
                        __Pyx_XGIVEREF(__pyx_t_23);
                        __Pyx_XGIVEREF(__pyx_t_24);
                        __Pyx_XGIVEREF(__pyx_t_25);
                        __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_24, __pyx_t_25);
                        goto __pyx_L32_error;
                        __pyx_L44_exception_handled:;
                        __Pyx_XGIVEREF(__pyx_t_23);
                        __Pyx_XGIVEREF(__pyx_t_24);
                        __Pyx_XGIVEREF(__pyx_t_25);
                        __Pyx_ExceptionReset(__pyx_t_23, __pyx_t_24, __pyx_t_25);
                        __pyx_L48_try_end:;
                      }
                    }
                    /*finally:*/ {
                      /*normal exit:*/{
                        if (__pyx_t_22) {
                          __pyx_t_25 = __Pyx_PyObject_Call(__pyx_t_22, __pyx_mstate_global->__pyx_tuple[7], NULL);
                          __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                          if (unlikely(!__pyx_t_25)) __PYX_ERR(0, 6657, __pyx_L32_error)
                          __Pyx_GOTREF(__pyx_t_25);
                          __pyx_t_17 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_25, &__pyx_r);
                          __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                          if (likely(__pyx_t_17 == PYGEN_NEXT)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_XGIVEREF(__pyx_t_6);
                            __pyx_cur_scope->__pyx_t_0 = __pyx_t_6;
                            __Pyx_XGIVEREF(__pyx_t_7);
                            __pyx_cur_scope->__pyx_t_1 = __pyx_t_7;
                            __Pyx_XGIVEREF(__pyx_t_8);
                            __pyx_cur_scope->__pyx_t_2 = __pyx_t_8;
                            __Pyx_XGIVEREF(__pyx_t_14);
                            __pyx_cur_scope->__pyx_t_3 = __pyx_t_14;
                            __Pyx_XGIVEREF(__pyx_t_15);
                            __pyx_cur_scope->__pyx_t_4 = __pyx_t_15;
                            __Pyx_XGIVEREF(__pyx_t_16);
                            __pyx_cur_scope->__pyx_t_5 = __pyx_t_16;
                            __Pyx_XGIVEREF(__pyx_t_18);
                            __pyx_cur_scope->__pyx_t_6 = __pyx_t_18;
                            __Pyx_XGIVEREF(__pyx_t_19);
                            __pyx_cur_scope->__pyx_t_7 = __pyx_t_19;
                            __Pyx_XGIVEREF(__pyx_t_20);
                            __pyx_cur_scope->__pyx_t_8 = __pyx_t_20;
                            __Pyx_XGIVEREF(__pyx_t_21);
                            __pyx_cur_scope->__pyx_t_9 = __pyx_t_21;
                            __Pyx_XGIVEREF(__pyx_t_22);
                            __pyx_cur_scope->__pyx_t_10 = __pyx_t_22;
                            __Pyx_XGIVEREF(__pyx_t_25);
                            __pyx_cur_scope->__pyx_t_11 = __pyx_t_25;
                            __Pyx_XGIVEREF(__pyx_r);
                            __Pyx_RefNannyFinishContext();
                            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                            /* return from generator, awaiting value */
                            __pyx_generator->resume_label = 6;
                            return __pyx_r;
                            __pyx_L71_resume_from_await:;
                            __pyx_t_6 = __pyx_cur_scope->__pyx_t_0;
                            __pyx_cur_scope->__pyx_t_0 = 0;
                            __Pyx_XGOTREF(__pyx_t_6);
                            __pyx_t_7 = __pyx_cur_scope->__pyx_t_1;
                            __pyx_cur_scope->__pyx_t_1 = 0;
                            __Pyx_XGOTREF(__pyx_t_7);
                            __pyx_t_8 = __pyx_cur_scope->__pyx_t_2;
                            __pyx_cur_scope->__pyx_t_2 = 0;
                            __Pyx_XGOTREF(__pyx_t_8);
                            __pyx_t_14 = __pyx_cur_scope->__pyx_t_3;
                            __pyx_cur_scope->__pyx_t_3 = 0;
                            __Pyx_XGOTREF(__pyx_t_14);
                            __pyx_t_15 = __pyx_cur_scope->__pyx_t_4;
                            __pyx_cur_scope->__pyx_t_4 = 0;
                            __Pyx_XGOTREF(__pyx_t_15);
                            __pyx_t_16 = __pyx_cur_scope->__pyx_t_5;
                            __pyx_cur_scope->__pyx_t_5 = 0;
                            __Pyx_XGOTREF(__pyx_t_16);
                            __pyx_t_18 = __pyx_cur_scope->__pyx_t_6;
                            __pyx_cur_scope->__pyx_t_6 = 0;
                            __Pyx_XGOTREF(__pyx_t_18);
                            __pyx_t_19 = __pyx_cur_scope->__pyx_t_7;
                            __pyx_cur_scope->__pyx_t_7 = 0;
                            __Pyx_XGOTREF(__pyx_t_19);
                            __pyx_t_20 = __pyx_cur_scope->__pyx_t_8;
                            __pyx_cur_scope->__pyx_t_8 = 0;
                            __Pyx_XGOTREF(__pyx_t_20);
                            __pyx_t_21 = __pyx_cur_scope->__pyx_t_9;
                            __pyx_cur_scope->__pyx_t_9 = 0;
                            __Pyx_XGOTREF(__pyx_t_21);
                            __pyx_t_22 = __pyx_cur_scope->__pyx_t_10;
                            __pyx_cur_scope->__pyx_t_10 = 0;
                            __Pyx_XGOTREF(__pyx_t_22);
                            __pyx_t_25 = __pyx_cur_scope->__pyx_t_11;
                            __pyx_cur_scope->__pyx_t_11 = 0;
                            __Pyx_XGOTREF(__pyx_t_25);
                            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6657, __pyx_L32_error)
                            __pyx_t_12 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_12);
                          } else if (likely(__pyx_t_17 == PYGEN_RETURN)) {
                            __Pyx_GOTREF(__pyx_r);
                            __pyx_t_12 = __pyx_r; __pyx_r = NULL;
                          } else {
                            __Pyx_XGOTREF(__pyx_r);
                            __PYX_ERR(0, 6657, __pyx_L32_error)
                          }
                          __pyx_t_25 = __pyx_t_12;
                          __pyx_t_12 = 0;
                          __Pyx_DECREF(__pyx_t_25); __pyx_t_25 = 0;
                        }
                        goto __pyx_L42;
                      }
                      __pyx_L42:;
                    }
                    goto __pyx_L72;
                    __pyx_L38_error:;
                    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                    goto __pyx_L32_error;
                    __pyx_L72:;
                  }

                  /* "ws_package/controllers/activity_controller.py":6656
 *                 await asyncio.sleep(0.1)  # Small delay for DB write to complete
 * 
 *                 with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                     async with async_session() as session:
 *                         # Query for unsent idle intervals from current counter that might not be in intervals list
*/
                }
                __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                goto __pyx_L37_try_end;
                __pyx_L32_error:;
                __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
                __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
                __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
                __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
                /*except:*/ {
                  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._should_pause_api_calls", __pyx_clineno, __pyx_lineno, __pyx_filename);
                  if (__Pyx_GetException(&__pyx_t_12, &__pyx_t_2, &__pyx_t_1) < 0) __PYX_ERR(0, 6656, __pyx_L34_except_error)
                  __Pyx_XGOTREF(__pyx_t_12);
                  __Pyx_XGOTREF(__pyx_t_2);
                  __Pyx_XGOTREF(__pyx_t_1);
                  __pyx_t_3 = PyTuple_Pack(3, __pyx_t_12, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6656, __pyx_L34_except_error)
                  __Pyx_GOTREF(__pyx_t_3);
                  __pyx_t_22 = __Pyx_PyObject_Call(__pyx_t_18, __pyx_t_3, NULL);
                  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
                  if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6656, __pyx_L34_except_error)
                  __Pyx_GOTREF(__pyx_t_22);
                  __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_22);
                  __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                  if (__pyx_t_9 < (0)) __PYX_ERR(0, 6656, __pyx_L34_except_error)
                  __pyx_t_5 = (!__pyx_t_9);
                  if (unlikely(__pyx_t_5)) {
                    __Pyx_GIVEREF(__pyx_t_12);
                    __Pyx_GIVEREF(__pyx_t_2);
                    __Pyx_XGIVEREF(__pyx_t_1);
                    __Pyx_ErrRestoreWithState(__pyx_t_12, __pyx_t_2, __pyx_t_1);
                    __pyx_t_12 = 0;  __pyx_t_2 = 0;  __pyx_t_1 = 0; 
                    __PYX_ERR(0, 6656, __pyx_L34_except_error)
                  }
                  __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
                  __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
                  __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
                  goto __pyx_L33_exception_handled;
                }
                __pyx_L34_except_error:;
                __Pyx_XGIVEREF(__pyx_t_19);
                __Pyx_XGIVEREF(__pyx_t_20);
                __Pyx_XGIVEREF(__pyx_t_21);
                __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21);
                goto __pyx_L20_error;
                __pyx_L33_exception_handled:;
                __Pyx_XGIVEREF(__pyx_t_19);
                __Pyx_XGIVEREF(__pyx_t_20);
                __Pyx_XGIVEREF(__pyx_t_21);
                __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21);
                __pyx_L37_try_end:;
              }
            }
            /*finally:*/ {
              /*normal exit:*/{
                if (__pyx_t_18) {
                  __pyx_t_21 = __Pyx_PyObject_Call(__pyx_t_18, __pyx_mstate_global->__pyx_tuple[7], NULL);
                  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                  if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6656, __pyx_L20_error)
                  __Pyx_GOTREF(__pyx_t_21);
                  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                }
                goto __pyx_L31;
              }
              __pyx_L31:;
            }
            goto __pyx_L76;
            __pyx_L28_error:;
            __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
            goto __pyx_L20_error;
            __pyx_L76:;
          }

          /* "ws_package/controllers/activity_controller.py":6651
 *             # CRITICAL FIX: Also check database for any unsent idle intervals that might not be in the intervals list
 *             # This catches newly created idle intervals (e.g., interval 75) that were just saved but not yet in the query results
 *             try:             # <<<<<<<<<<<<<<
 *                 # Flush queue to ensure latest intervals are in DB
 *                 await db_writer_service.process_immediately()
*/
        }
        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
        goto __pyx_L25_try_end;
        __pyx_L20_error:;
        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
        __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
        __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
        __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;

        /* "ws_package/controllers/activity_controller.py":6684
 *                                 current_counter_intervals.append(db_interval)
 *                                 logger.debug("[APIBlock] Found unsent idle interval in DB (id=%s) that wasn't in intervals list - adding to check", db_interval.id)
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 logger.warning("[APIBlock] Error checking database for idle intervals: %s - continuing with intervals list only", e)
 * 
*/
        __pyx_t_31 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
        if (__pyx_t_31) {
          __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._should_pause_api_calls", __pyx_clineno, __pyx_lineno, __pyx_filename);
          if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_12) < 0) __PYX_ERR(0, 6684, __pyx_L22_except_error)
          __Pyx_XGOTREF(__pyx_t_1);
          __Pyx_XGOTREF(__pyx_t_2);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_INCREF(__pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __pyx_cur_scope->__pyx_v_e = __pyx_t_2;
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":6685
 *                                 logger.debug("[APIBlock] Found unsent idle interval in DB (id=%s) that wasn't in intervals list - adding to check", db_interval.id)
 *             except Exception as e:
 *                 logger.warning("[APIBlock] Error checking database for idle intervals: %s - continuing with intervals list only", e)             # <<<<<<<<<<<<<<
 * 
 *             # Separate idle and non-idle intervals
*/
            __pyx_t_11 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 6685, __pyx_L82_error)
            __Pyx_GOTREF(__pyx_t_10);
            __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 6685, __pyx_L82_error)
            __Pyx_GOTREF(__pyx_t_26);
            __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_26))) {
              __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_26);
              assert(__pyx_t_11);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_26);
              __Pyx_INCREF(__pyx_t_11);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_26, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_11, __pyx_mstate_global->__pyx_kp_u_APIBlock_Error_checking_databas, __pyx_cur_scope->__pyx_v_e};
              __pyx_t_3 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_26, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
              __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
              if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6685, __pyx_L82_error)
              __Pyx_GOTREF(__pyx_t_3);
            }
            __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          }

          /* "ws_package/controllers/activity_controller.py":6684
 *                                 current_counter_intervals.append(db_interval)
 *                                 logger.debug("[APIBlock] Found unsent idle interval in DB (id=%s) that wasn't in intervals list - adding to check", db_interval.id)
 *             except Exception as e:             # <<<<<<<<<<<<<<
 *                 logger.warning("[APIBlock] Error checking database for idle intervals: %s - continuing with intervals list only", e)
 * 
*/
          /*finally:*/ {
            /*normal exit:*/{
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
              __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
              goto __pyx_L83;
            }
            __pyx_L82_error:;
            /*exception exit:*/{
              __Pyx_PyThreadState_assign
              __pyx_t_18 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_22 = 0; __pyx_t_25 = 0;
              __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
              __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
               __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_22, &__pyx_t_25);
              if ( unlikely(__Pyx_GetException(&__pyx_t_18, &__pyx_t_21, &__pyx_t_20) < 0)) __Pyx_ErrFetch(&__pyx_t_18, &__pyx_t_21, &__pyx_t_20);
              __Pyx_XGOTREF(__pyx_t_18);
              __Pyx_XGOTREF(__pyx_t_21);
              __Pyx_XGOTREF(__pyx_t_20);
              __Pyx_XGOTREF(__pyx_t_19);
              __Pyx_XGOTREF(__pyx_t_22);
              __Pyx_XGOTREF(__pyx_t_25);
              __pyx_t_31 = __pyx_lineno; __pyx_t_32 = __pyx_clineno; __pyx_t_33 = __pyx_filename;
              {
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
              }
              __Pyx_XGIVEREF(__pyx_t_19);
              __Pyx_XGIVEREF(__pyx_t_22);
              __Pyx_XGIVEREF(__pyx_t_25);
              __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_22, __pyx_t_25);
              __Pyx_XGIVEREF(__pyx_t_18);
              __Pyx_XGIVEREF(__pyx_t_21);
              __Pyx_XGIVEREF(__pyx_t_20);
              __Pyx_ErrRestore(__pyx_t_18, __pyx_t_21, __pyx_t_20);
              __pyx_t_18 = 0; __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_19 = 0; __pyx_t_22 = 0; __pyx_t_25 = 0;
              __pyx_lineno = __pyx_t_31; __pyx_clineno = __pyx_t_32; __pyx_filename = __pyx_t_33;
              goto __pyx_L22_except_error;
            }
            __pyx_L83:;
          }
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          goto __pyx_L21_exception_handled;
        }
        goto __pyx_L22_except_error;

        /* "ws_package/controllers/activity_controller.py":6651
 *             # CRITICAL FIX: Also check database for any unsent idle intervals that might not be in the intervals list
 *             # This catches newly created idle intervals (e.g., interval 75) that were just saved but not yet in the query results
 *             try:             # <<<<<<<<<<<<<<
 *                 # Flush queue to ensure latest intervals are in DB
 *                 await db_writer_service.process_immediately()
*/
        __pyx_L22_except_error:;
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_XGIVEREF(__pyx_t_15);
        __Pyx_XGIVEREF(__pyx_t_16);
        __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
        goto __pyx_L5_error;
        __pyx_L21_exception_handled:;
        __Pyx_XGIVEREF(__pyx_t_14);
        __Pyx_XGIVEREF(__pyx_t_15);
        __Pyx_XGIVEREF(__pyx_t_16);
        __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
        __pyx_L25_try_end:;
      }

      /* "ws_package/controllers/activity_controller.py":6688
 * 
 *             # Separate idle and non-idle intervals
 *             idle_intervals = []             # <<<<<<<<<<<<<<
 *             non_idle_intervals = []
 * 
*/
      __pyx_t_12 = PyList_New(0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 6688, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_12);
      __pyx_cur_scope->__pyx_v_idle_intervals = ((PyObject*)__pyx_t_12);
      __pyx_t_12 = 0;

      /* "ws_package/controllers/activity_controller.py":6689
 *             # Separate idle and non-idle intervals
 *             idle_intervals = []
 *             non_idle_intervals = []             # <<<<<<<<<<<<<<
 * 
 *             for interval in current_counter_intervals:
*/
      __pyx_t_12 = PyList_New(0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 6689, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_12);
      __Pyx_GIVEREF(__pyx_t_12);
      __pyx_cur_scope->__pyx_v_non_idle_intervals = ((PyObject*)__pyx_t_12);
      __pyx_t_12 = 0;

      /* "ws_package/controllers/activity_controller.py":6691
 *             non_idle_intervals = []
 * 
 *             for interval in current_counter_intervals:             # <<<<<<<<<<<<<<
 *                 activity_level = interval.activityLevel if hasattr(interval, 'activityLevel') else {}
 *                 keyboard = float(activity_level.get('keyboard', '0.0') or '0.0')
*/
      __pyx_t_12 = __pyx_cur_scope->__pyx_v_current_counter_intervals; __Pyx_INCREF(__pyx_t_12);
      __pyx_t_13 = 0;
      for (;;) {
        {
          Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_12);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6691, __pyx_L5_error)
          #endif
          if (__pyx_t_13 >= __pyx_temp) break;
        }
        __pyx_t_2 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_12, __pyx_t_13, __Pyx_ReferenceSharing_OwnStrongReference);
        ++__pyx_t_13;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6691, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_2);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        __pyx_t_2 = 0;

        /* "ws_package/controllers/activity_controller.py":6692
 * 
 *             for interval in current_counter_intervals:
 *                 activity_level = interval.activityLevel if hasattr(interval, 'activityLevel') else {}             # <<<<<<<<<<<<<<
 *                 keyboard = float(activity_level.get('keyboard', '0.0') or '0.0')
 *                 mouse = float(activity_level.get('mouse', '0.0') or '0.0')
*/
        __pyx_t_1 = __pyx_cur_scope->__pyx_v_interval;
        __Pyx_INCREF(__pyx_t_1);
        __pyx_t_5 = __Pyx_HasAttr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_activityLevel); if (unlikely(__pyx_t_5 == ((int)-1))) __PYX_ERR(0, 6692, __pyx_L5_error)
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        if (__pyx_t_5) {
          __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_activityLevel); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6692, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_2 = __pyx_t_1;
          __pyx_t_1 = 0;
        } else {
          __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6692, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_1);
          __pyx_t_2 = __pyx_t_1;
          __pyx_t_1 = 0;
        }
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_activity_level);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_activity_level, __pyx_t_2);
        __Pyx_GIVEREF(__pyx_t_2);
        __pyx_t_2 = 0;

        /* "ws_package/controllers/activity_controller.py":6693
 *             for interval in current_counter_intervals:
 *                 activity_level = interval.activityLevel if hasattr(interval, 'activityLevel') else {}
 *                 keyboard = float(activity_level.get('keyboard', '0.0') or '0.0')             # <<<<<<<<<<<<<<
 *                 mouse = float(activity_level.get('mouse', '0.0') or '0.0')
 *                 average = float(activity_level.get('average', '0.0') or '0.0')
*/
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activity_level, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6693, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_mstate_global->__pyx_tuple[24], NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6693, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 6693, __pyx_L5_error)
        if (!__pyx_t_5) {
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else {
          __Pyx_INCREF(__pyx_t_3);
          __pyx_t_2 = __pyx_t_3;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          goto __pyx_L90_bool_binop_done;
        }
        __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_0_0);
        __pyx_t_2 = __pyx_mstate_global->__pyx_kp_u_0_0;
        __pyx_L90_bool_binop_done:;
        __pyx_t_28 = __Pyx_PyObject_AsDouble(__pyx_t_2); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_28, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 6693, __pyx_L5_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_cur_scope->__pyx_v_keyboard = __pyx_t_28;

        /* "ws_package/controllers/activity_controller.py":6694
 *                 activity_level = interval.activityLevel if hasattr(interval, 'activityLevel') else {}
 *                 keyboard = float(activity_level.get('keyboard', '0.0') or '0.0')
 *                 mouse = float(activity_level.get('mouse', '0.0') or '0.0')             # <<<<<<<<<<<<<<
 *                 average = float(activity_level.get('average', '0.0') or '0.0')
 * 
*/
        __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activity_level, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6694, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_3);
        __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_mstate_global->__pyx_tuple[25], NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6694, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 6694, __pyx_L5_error)
        if (!__pyx_t_5) {
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        } else {
          __Pyx_INCREF(__pyx_t_1);
          __pyx_t_2 = __pyx_t_1;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          goto __pyx_L92_bool_binop_done;
        }
        __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_0_0);
        __pyx_t_2 = __pyx_mstate_global->__pyx_kp_u_0_0;
        __pyx_L92_bool_binop_done:;
        __pyx_t_28 = __Pyx_PyObject_AsDouble(__pyx_t_2); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_28, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 6694, __pyx_L5_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_cur_scope->__pyx_v_mouse = __pyx_t_28;

        /* "ws_package/controllers/activity_controller.py":6695
 *                 keyboard = float(activity_level.get('keyboard', '0.0') or '0.0')
 *                 mouse = float(activity_level.get('mouse', '0.0') or '0.0')
 *                 average = float(activity_level.get('average', '0.0') or '0.0')             # <<<<<<<<<<<<<<
 * 
 *                 # Check if interval has zero activity
*/
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_activity_level, __pyx_mstate_global->__pyx_n_u_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6695, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_1);
        __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_mstate_global->__pyx_tuple[26], NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6695, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_3);
        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
        __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 6695, __pyx_L5_error)
        if (!__pyx_t_5) {
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
        } else {
          __Pyx_INCREF(__pyx_t_3);
          __pyx_t_2 = __pyx_t_3;
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          goto __pyx_L94_bool_binop_done;
        }
        __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_0_0);
        __pyx_t_2 = __pyx_mstate_global->__pyx_kp_u_0_0;
        __pyx_L94_bool_binop_done:;
        __pyx_t_28 = __Pyx_PyObject_AsDouble(__pyx_t_2); if (unlikely(__PYX_CHECK_FLOAT_EXCEPTION(__pyx_t_28, ((double)((double)-1))) && PyErr_Occurred())) __PYX_ERR(0, 6695, __pyx_L5_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __pyx_cur_scope->__pyx_v_average = __pyx_t_28;

        /* "ws_package/controllers/activity_controller.py":6698
 * 
 *                 # Check if interval has zero activity
 *                 if keyboard == 0 and mouse == 0 and average == 0:             # <<<<<<<<<<<<<<
 *                     idle_intervals.append(interval)
 *                 else:
*/
        __pyx_t_9 = (__pyx_cur_scope->__pyx_v_keyboard == 0.0);
        if (__pyx_t_9) {
        } else {
          __pyx_t_5 = __pyx_t_9;
          goto __pyx_L97_bool_binop_done;
        }
        __pyx_t_9 = (__pyx_cur_scope->__pyx_v_mouse == 0.0);
        if (__pyx_t_9) {
        } else {
          __pyx_t_5 = __pyx_t_9;
          goto __pyx_L97_bool_binop_done;
        }
        __pyx_t_9 = (__pyx_cur_scope->__pyx_v_average == 0.0);
        __pyx_t_5 = __pyx_t_9;
        __pyx_L97_bool_binop_done:;
        if (__pyx_t_5) {

          /* "ws_package/controllers/activity_controller.py":6699
 *                 # Check if interval has zero activity
 *                 if keyboard == 0 and mouse == 0 and average == 0:
 *                     idle_intervals.append(interval)             # <<<<<<<<<<<<<<
 *                 else:
 *                     non_idle_intervals.append(interval)
*/
          __pyx_t_2 = __pyx_cur_scope->__pyx_v_interval;
          __Pyx_INCREF(__pyx_t_2);
          __pyx_t_29 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_idle_intervals, __pyx_t_2); if (unlikely(__pyx_t_29 == ((int)-1))) __PYX_ERR(0, 6699, __pyx_L5_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":6698
 * 
 *                 # Check if interval has zero activity
 *                 if keyboard == 0 and mouse == 0 and average == 0:             # <<<<<<<<<<<<<<
 *                     idle_intervals.append(interval)
 *                 else:
*/
          goto __pyx_L96;
        }

        /* "ws_package/controllers/activity_controller.py":6701
 *                     idle_intervals.append(interval)
 *                 else:
 *                     non_idle_intervals.append(interval)             # <<<<<<<<<<<<<<
 * 
 *             # Hold idle intervals (single or multiple) until non-idle found or popup handled
*/
        /*else*/ {
          __pyx_t_2 = __pyx_cur_scope->__pyx_v_interval;
          __Pyx_INCREF(__pyx_t_2);
          __pyx_t_29 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_non_idle_intervals, __pyx_t_2); if (unlikely(__pyx_t_29 == ((int)-1))) __PYX_ERR(0, 6701, __pyx_L5_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        }
        __pyx_L96:;

        /* "ws_package/controllers/activity_controller.py":6691
 *             non_idle_intervals = []
 * 
 *             for interval in current_counter_intervals:             # <<<<<<<<<<<<<<
 *                 activity_level = interval.activityLevel if hasattr(interval, 'activityLevel') else {}
 *                 keyboard = float(activity_level.get('keyboard', '0.0') or '0.0')
*/
      }
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

      /* "ws_package/controllers/activity_controller.py":6704
 * 
 *             # Hold idle intervals (single or multiple) until non-idle found or popup handled
 *             if idle_intervals:             # <<<<<<<<<<<<<<
 *                 for interval in idle_intervals:
 *                     # Check if already held (by ID to avoid duplicates)
*/
      {
        Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_idle_intervals);
        if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 6704, __pyx_L5_error)
        __pyx_t_5 = (__pyx_temp != 0);
      }

      if (__pyx_t_5) {

        /* "ws_package/controllers/activity_controller.py":6705
 *             # Hold idle intervals (single or multiple) until non-idle found or popup handled
 *             if idle_intervals:
 *                 for interval in idle_intervals:             # <<<<<<<<<<<<<<
 *                     # Check if already held (by ID to avoid duplicates)
 *                     if not any(getattr(held, 'id', None) == getattr(interval, 'id', None) for held in self._held_idle_intervals):
*/
        __pyx_t_12 = __pyx_cur_scope->__pyx_v_idle_intervals; __Pyx_INCREF(__pyx_t_12);
        __pyx_t_13 = 0;
        for (;;) {
          {
            Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_12);
            #if !CYTHON_ASSUME_SAFE_SIZE
            if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6705, __pyx_L5_error)
            #endif
            if (__pyx_t_13 >= __pyx_temp) break;
          }
          __pyx_t_2 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_12, __pyx_t_13, __Pyx_ReferenceSharing_OwnStrongReference);
          ++__pyx_t_13;
          if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6705, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
          __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_2);
          __Pyx_GIVEREF(__pyx_t_2);
          __pyx_t_2 = 0;

          /* "ws_package/controllers/activity_controller.py":6707
 *                 for interval in idle_intervals:
 *                     # Check if already held (by ID to avoid duplicates)
 *                     if not any(getattr(held, 'id', None) == getattr(interval, 'id', None) for held in self._held_idle_intervals):             # <<<<<<<<<<<<<<
 *                         self._held_idle_intervals.append(interval)
 *                         logger.info("[APIBlock] Holding idle interval (id=%s, counter=%s, start=%s, end=%s) - will send when non-idle interval found or popup handled", interval.id, getattr(interval, 'counter', 'N/A'), interval.start_time, interval.end_time)
*/
          __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_held_idle_intervals); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6707, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_3 = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_23_should_pause_api_calls_genexpr(((PyObject*)__pyx_cur_scope), __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 6707, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_3);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_2 = __Pyx_Generator_GetInlinedResult(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6707, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_2);
          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
          __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 6707, __pyx_L5_error)
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_9 = (!__pyx_t_5);
          if (__pyx_t_9) {

            /* "ws_package/controllers/activity_controller.py":6708
 *                     # Check if already held (by ID to avoid duplicates)
 *                     if not any(getattr(held, 'id', None) == getattr(interval, 'id', None) for held in self._held_idle_intervals):
 *                         self._held_idle_intervals.append(interval)             # <<<<<<<<<<<<<<
 *                         logger.info("[APIBlock] Holding idle interval (id=%s, counter=%s, start=%s, end=%s) - will send when non-idle interval found or popup handled", interval.id, getattr(interval, 'counter', 'N/A'), interval.start_time, interval.end_time)
 * 
*/
            __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_held_idle_intervals); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6708, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_2);
            __pyx_t_29 = __Pyx_PyObject_Append(__pyx_t_2, __pyx_cur_scope->__pyx_v_interval); if (unlikely(__pyx_t_29 == ((int)-1))) __PYX_ERR(0, 6708, __pyx_L5_error)
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

            /* "ws_package/controllers/activity_controller.py":6709
 *                     if not any(getattr(held, 'id', None) == getattr(interval, 'id', None) for held in self._held_idle_intervals):
 *                         self._held_idle_intervals.append(interval)
 *                         logger.info("[APIBlock] Holding idle interval (id=%s, counter=%s, start=%s, end=%s) - will send when non-idle interval found or popup handled", interval.id, getattr(interval, 'counter', 'N/A'), interval.start_time, interval.end_time)             # <<<<<<<<<<<<<<
 * 
 *                 if len(idle_intervals) == 1:
*/
            __pyx_t_3 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6709, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 6709, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_26);
            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
            __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6709, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_1);
            __pyx_t_11 = __pyx_cur_scope->__pyx_v_interval;
            __Pyx_INCREF(__pyx_t_11);
            __pyx_t_10 = __Pyx_GetAttr3(__pyx_t_11, __pyx_mstate_global->__pyx_n_u_counter, __pyx_mstate_global->__pyx_kp_u_N_A); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 6709, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_10);
            __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
            __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 6709, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_11);
            __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 6709, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_34);
            __pyx_t_4 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_26))) {
              __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_26);
              assert(__pyx_t_3);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_26);
              __Pyx_INCREF(__pyx_t_3);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_26, __pyx__function);
              __pyx_t_4 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[6] = {__pyx_t_3, __pyx_mstate_global->__pyx_kp_u_APIBlock_Holding_idle_interval, __pyx_t_1, __pyx_t_10, __pyx_t_11, __pyx_t_34};
              __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_26, __pyx_callargs+__pyx_t_4, (6-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
              __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
              __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
              __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
              __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
              __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
              if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6709, __pyx_L5_error)
              __Pyx_GOTREF(__pyx_t_2);
            }
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

            /* "ws_package/controllers/activity_controller.py":6707
 *                 for interval in idle_intervals:
 *                     # Check if already held (by ID to avoid duplicates)
 *                     if not any(getattr(held, 'id', None) == getattr(interval, 'id', None) for held in self._held_idle_intervals):             # <<<<<<<<<<<<<<
 *                         self._held_idle_intervals.append(interval)
 *                         logger.info("[APIBlock] Holding idle interval (id=%s, counter=%s, start=%s, end=%s) - will send when non-idle interval found or popup handled", interval.id, getattr(interval, 'counter', 'N/A'), interval.start_time, interval.end_time)
*/
          }

          /* "ws_package/controllers/activity_controller.py":6705
 *             # Hold idle intervals (single or multiple) until non-idle found or popup handled
 *             if idle_intervals:
 *                 for interval in idle_intervals:             # <<<<<<<<<<<<<<
 *                     # Check if already held (by ID to avoid duplicates)
 *                     if not any(getattr(held, 'id', None) == getattr(interval, 'id', None) for held in self._held_idle_intervals):
*/
        }
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

        /* "ws_package/controllers/activity_controller.py":6711
 *                         logger.info("[APIBlock] Holding idle interval (id=%s, counter=%s, start=%s, end=%s) - will send when non-idle interval found or popup handled", interval.id, getattr(interval, 'counter', 'N/A'), interval.start_time, interval.end_time)
 * 
 *                 if len(idle_intervals) == 1:             # <<<<<<<<<<<<<<
 *                     logger.info("[APIBlock] Holding 1 idle interval (counter=%s) - will send when non-idle interval found or popup handled", current_counter)
 *                 else:
*/
        __pyx_t_13 = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_idle_intervals); if (unlikely(__pyx_t_13 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6711, __pyx_L5_error)
        __pyx_t_9 = (__pyx_t_13 == 1);
        if (__pyx_t_9) {

          /* "ws_package/controllers/activity_controller.py":6712
 * 
 *                 if len(idle_intervals) == 1:
 *                     logger.info("[APIBlock] Holding 1 idle interval (counter=%s) - will send when non-idle interval found or popup handled", current_counter)             # <<<<<<<<<<<<<<
 *                 else:
 *                     logger.info("[APIBlock] Holding %s idle intervals (counter=%s) - will send when non-idle interval found or popup handled", len(idle_intervals), current_counter)
*/
          __pyx_t_2 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 6712, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_26);
          __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_26, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 6712, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_34);
          __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
          __pyx_t_4 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_34))) {
            __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_34);
            assert(__pyx_t_2);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_34);
            __Pyx_INCREF(__pyx_t_2);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_34, __pyx__function);
            __pyx_t_4 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[3] = {__pyx_t_2, __pyx_mstate_global->__pyx_kp_u_APIBlock_Holding_1_idle_interva, __pyx_cur_scope->__pyx_v_current_counter};
            __pyx_t_12 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_34, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
            if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 6712, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_12);
          }
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

          /* "ws_package/controllers/activity_controller.py":6711
 *                         logger.info("[APIBlock] Holding idle interval (id=%s, counter=%s, start=%s, end=%s) - will send when non-idle interval found or popup handled", interval.id, getattr(interval, 'counter', 'N/A'), interval.start_time, interval.end_time)
 * 
 *                 if len(idle_intervals) == 1:             # <<<<<<<<<<<<<<
 *                     logger.info("[APIBlock] Holding 1 idle interval (counter=%s) - will send when non-idle interval found or popup handled", current_counter)
 *                 else:
*/
          goto __pyx_L106;
        }

        /* "ws_package/controllers/activity_controller.py":6714
 *                     logger.info("[APIBlock] Holding 1 idle interval (counter=%s) - will send when non-idle interval found or popup handled", current_counter)
 *                 else:
 *                     logger.info("[APIBlock] Holding %s idle intervals (counter=%s) - will send when non-idle interval found or popup handled", len(idle_intervals), current_counter)             # <<<<<<<<<<<<<<
 * 
 *             # If ALL intervals are idle, pause API calls (don't send anything)
*/
        /*else*/ {
          __pyx_t_34 = NULL;
          __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6714, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_26 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 6714, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_26);
          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
          __pyx_t_13 = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_idle_intervals); if (unlikely(__pyx_t_13 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6714, __pyx_L5_error)
          __pyx_t_2 = PyLong_FromSsize_t(__pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6714, __pyx_L5_error)
          __Pyx_GOTREF(__pyx_t_2);
          __pyx_t_4 = 1;
          #if CYTHON_UNPACK_METHODS
          if (unlikely(PyMethod_Check(__pyx_t_26))) {
            __pyx_t_34 = PyMethod_GET_SELF(__pyx_t_26);
            assert(__pyx_t_34);
            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_26);
            __Pyx_INCREF(__pyx_t_34);
            __Pyx_INCREF(__pyx__function);
            __Pyx_DECREF_SET(__pyx_t_26, __pyx__function);
            __pyx_t_4 = 0;
          }
          #endif
          {
            PyObject *__pyx_callargs[4] = {__pyx_t_34, __pyx_mstate_global->__pyx_kp_u_APIBlock_Holding_s_idle_interva, __pyx_t_2, __pyx_cur_scope->__pyx_v_current_counter};
            __pyx_t_12 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_26, __pyx_callargs+__pyx_t_4, (4-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
            __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
            __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
            __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;
            if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 6714, __pyx_L5_error)
            __Pyx_GOTREF(__pyx_t_12);
          }
          __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        }
        __pyx_L106:;

        /* "ws_package/controllers/activity_controller.py":6704
 * 
 *             # Hold idle intervals (single or multiple) until non-idle found or popup handled
 *             if idle_intervals:             # <<<<<<<<<<<<<<
 *                 for interval in idle_intervals:
 *                     # Check if already held (by ID to avoid duplicates)
*/
      }

      /* "ws_package/controllers/activity_controller.py":6717
 * 
 *             # If ALL intervals are idle, pause API calls (don't send anything)
 *             if not non_idle_intervals:             # <<<<<<<<<<<<<<
 *                 return True
 * 
*/
      {
        Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_non_idle_intervals);
        if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 6717, __pyx_L5_error)
        __pyx_t_9 = (__pyx_temp != 0);
      }

      __pyx_t_5 = (!__pyx_t_9);
      if (__pyx_t_5) {

        /* "ws_package/controllers/activity_controller.py":6718
 *             # If ALL intervals are idle, pause API calls (don't send anything)
 *             if not non_idle_intervals:
 *                 return True             # <<<<<<<<<<<<<<
 * 
 *             # If there are non-idle intervals, don't pause (they will be sent, and held idle intervals will be sent before them in _push_activity_log)
*/
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_True);
        __pyx_r = Py_True;
        goto __pyx_L9_try_return;

        /* "ws_package/controllers/activity_controller.py":6717
 * 
 *             # If ALL intervals are idle, pause API calls (don't send anything)
 *             if not non_idle_intervals:             # <<<<<<<<<<<<<<
 *                 return True
 * 
*/
      }

      /* "ws_package/controllers/activity_controller.py":6721
 * 
 *             # If there are non-idle intervals, don't pause (they will be sent, and held idle intervals will be sent before them in _push_activity_log)
 *             logger.debug("[APIBlock] Non-idle interval(s) found (%s) - held idle intervals will be sent before non-idle intervals", len(non_idle_intervals))             # <<<<<<<<<<<<<<
 *             return False
 * 
*/
      __pyx_t_26 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6721, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_34 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_debug); if (unlikely(!__pyx_t_34)) __PYX_ERR(0, 6721, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_34);
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      __pyx_t_13 = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_non_idle_intervals); if (unlikely(__pyx_t_13 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6721, __pyx_L5_error)
      __pyx_t_2 = PyLong_FromSsize_t(__pyx_t_13); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 6721, __pyx_L5_error)
      __Pyx_GOTREF(__pyx_t_2);
      __pyx_t_4 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_34))) {
        __pyx_t_26 = PyMethod_GET_SELF(__pyx_t_34);
        assert(__pyx_t_26);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_34);
        __Pyx_INCREF(__pyx_t_26);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_34, __pyx__function);
        __pyx_t_4 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[3] = {__pyx_t_26, __pyx_mstate_global->__pyx_kp_u_APIBlock_Non_idle_interval_s_fo, __pyx_t_2};
        __pyx_t_12 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_34, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
        if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 6721, __pyx_L5_error)
        __Pyx_GOTREF(__pyx_t_12);
      }
      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;

      /* "ws_package/controllers/activity_controller.py":6722
 *             # If there are non-idle intervals, don't pause (they will be sent, and held idle intervals will be sent before them in _push_activity_log)
 *             logger.debug("[APIBlock] Non-idle interval(s) found (%s) - held idle intervals will be sent before non-idle intervals", len(non_idle_intervals))
 *             return False             # <<<<<<<<<<<<<<
 * 
 *         except Exception as e:
*/
      __Pyx_XDECREF(__pyx_r);
      __Pyx_INCREF(Py_False);
      __pyx_r = Py_False;
      goto __pyx_L9_try_return;

      /* "ws_package/controllers/activity_controller.py":6626
 *         if is_silent_build():
 *             return False
 *         try:             # <<<<<<<<<<<<<<
 *             # Case 1: Check if idle popup is active (triggered but not yet handled)
 *             # CRITICAL: While popup active, block ALL server uploads
*/
    }
    __pyx_L5_error:;
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
    __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
    __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;

    /* "ws_package/controllers/activity_controller.py":6724
 *             return False
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("[APIBlock] Error checking if API calls should be paused: %s", e, exc_info=True)
 *             return False  # Don't pause on error
*/
    __pyx_t_32 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_32) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._should_pause_api_calls", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_12, &__pyx_t_34, &__pyx_t_2) < 0) __PYX_ERR(0, 6724, __pyx_L7_except_error)
      __Pyx_XGOTREF(__pyx_t_12);
      __Pyx_XGOTREF(__pyx_t_34);
      __Pyx_XGOTREF(__pyx_t_2);
      __Pyx_INCREF(__pyx_t_34);
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_34);
      __Pyx_GIVEREF(__pyx_t_34);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":6725
 * 
 *         except Exception as e:
 *             logger.error("[APIBlock] Error checking if API calls should be paused: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 *             return False  # Don't pause on error
 * 
*/
        __pyx_t_11 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 6725, __pyx_L113_error)
        __Pyx_GOTREF(__pyx_t_10);
        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6725, __pyx_L113_error)
        __Pyx_GOTREF(__pyx_t_1);
        __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
        __pyx_t_4 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_1))) {
          __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_1);
          assert(__pyx_t_11);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_1);
          __Pyx_INCREF(__pyx_t_11);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_1, __pyx__function);
          __pyx_t_4 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_11, __pyx_mstate_global->__pyx_kp_u_APIBlock_Error_checking_if_API, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_10 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 6725, __pyx_L113_error)
          __Pyx_GOTREF(__pyx_t_10);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_10, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 6725, __pyx_L113_error)
          __pyx_t_26 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_1, __pyx_callargs+__pyx_t_4, (3-__pyx_t_4) | (__pyx_t_4*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_10);
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
          if (unlikely(!__pyx_t_26)) __PYX_ERR(0, 6725, __pyx_L113_error)
          __Pyx_GOTREF(__pyx_t_26);
        }
        __Pyx_DECREF(__pyx_t_26); __pyx_t_26 = 0;

        /* "ws_package/controllers/activity_controller.py":6726
 *         except Exception as e:
 *             logger.error("[APIBlock] Error checking if API calls should be paused: %s", e, exc_info=True)
 *             return False  # Don't pause on error             # <<<<<<<<<<<<<<
 * 
 * 
*/
        __Pyx_XDECREF(__pyx_r);
        __Pyx_INCREF(Py_False);
        __pyx_r = Py_False;
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        __Pyx_DECREF(__pyx_t_34); __pyx_t_34 = 0;
        goto __pyx_L112_return;
      }

      /* "ws_package/controllers/activity_controller.py":6724
 *             return False
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("[APIBlock] Error checking if API calls should be paused: %s", e, exc_info=True)
 *             return False  # Don't pause on error
*/
      /*finally:*/ {
        __pyx_L113_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_16 = 0; __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_25 = 0; __pyx_t_22 = 0; __pyx_t_19 = 0;
          __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
          __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
          __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
          __Pyx_XDECREF(__pyx_t_26); __pyx_t_26 = 0;
          __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_25, &__pyx_t_22, &__pyx_t_19);
          if ( unlikely(__Pyx_GetException(&__pyx_t_16, &__pyx_t_15, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_16, &__pyx_t_15, &__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_16);
          __Pyx_XGOTREF(__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_25);
          __Pyx_XGOTREF(__pyx_t_22);
          __Pyx_XGOTREF(__pyx_t_19);
          __pyx_t_32 = __pyx_lineno; __pyx_t_31 = __pyx_clineno; __pyx_t_35 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_25);
          __Pyx_XGIVEREF(__pyx_t_22);
          __Pyx_XGIVEREF(__pyx_t_19);
          __Pyx_ExceptionReset(__pyx_t_25, __pyx_t_22, __pyx_t_19);
          __Pyx_XGIVEREF(__pyx_t_16);
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_ErrRestore(__pyx_t_16, __pyx_t_15, __pyx_t_14);
          __pyx_t_16 = 0; __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_25 = 0; __pyx_t_22 = 0; __pyx_t_19 = 0;
          __pyx_lineno = __pyx_t_32; __pyx_clineno = __pyx_t_31; __pyx_filename = __pyx_t_35;
          goto __pyx_L7_except_error;
        }
        __pyx_L112_return: {
          __pyx_t_19 = __pyx_r;
          __pyx_r = 0;
          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          __pyx_r = __pyx_t_19;
          __pyx_t_19 = 0;
          goto __pyx_L8_except_return;
        }
      }
    }
    goto __pyx_L7_except_error;

    /* "ws_package/controllers/activity_controller.py":6626
 *         if is_silent_build():
 *             return False
 *         try:             # <<<<<<<<<<<<<<
 *             # Case 1: Check if idle popup is active (triggered but not yet handled)
 *             # CRITICAL: While popup active, block ALL server uploads
*/
    __pyx_L7_except_error:;
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
    goto __pyx_L1_error;
    __pyx_L9_try_return:;
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
    goto __pyx_L0;
    __pyx_L8_except_return:;
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_XGIVEREF(__pyx_t_7);
    __Pyx_XGIVEREF(__pyx_t_8);
    __Pyx_ExceptionReset(__pyx_t_6, __pyx_t_7, __pyx_t_8);
    goto __pyx_L0;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":6606
 * 
 * 
 *     async def _should_pause_api_calls(self, intervals: list) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Check if API calls should be paused.
*/

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_1);
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_3);
  __Pyx_XDECREF(__pyx_t_10);
  __Pyx_XDECREF(__pyx_t_11);
  __Pyx_XDECREF(__pyx_t_12);
  __Pyx_XDECREF(__pyx_t_26);
  __Pyx_XDECREF(__pyx_t_34);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("_should_pause_api_calls", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_226generator50(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */

/* "ws_package/controllers/activity_controller.py":6729
 * 
 * 
 *     async def _idle_reassign(self, project_id: str, task_id: Optional[str] = None):             # <<<<<<<<<<<<<<
 *         """
 *         Reassign idle intervals to a new project and task by sending them to the API with the new project/task IDs.
*/

/* Python wrapper */
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_225_idle_reassign(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
); /*proto*/
PyDoc_STRVAR(__pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_224_idle_reassign, "\n        Reassign idle intervals to a new project and task by sending them to the API with the new project/task IDs.\n        \n        Args:\n            project_id: Project ID to assign idle intervals to (mandatory)\n            task_id: Task ID to assign idle intervals to (optional, defaults to \"0\" if not provided)\n        ");
static PyMethodDef __pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_225_idle_reassign = {"_idle_reassign", (PyCFunction)(void(*)(void))(__Pyx_PyCFunction_FastCallWithKeywords)__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_225_idle_reassign, __Pyx_METH_FASTCALL|METH_KEYWORDS, __pyx_doc_10ws_package_11controllers_19activity_controller_18ActivityController_224_idle_reassign};
static PyObject *__pyx_pw_10ws_package_11controllers_19activity_controller_18ActivityController_225_idle_reassign(PyObject *__pyx_self, 
#if CYTHON_METH_FASTCALL
PyObject *const *__pyx_args, Py_ssize_t __pyx_nargs, PyObject *__pyx_kwds
#else
PyObject *__pyx_args, PyObject *__pyx_kwds
#endif
) {
  PyObject *__pyx_v_self = 0;
  PyObject *__pyx_v_project_id = 0;
  PyObject *__pyx_v_task_id = 0;
  #if !CYTHON_METH_FASTCALL
  CYTHON_UNUSED Py_ssize_t __pyx_nargs;
  #endif
  CYTHON_UNUSED PyObject *const *__pyx_kwvalues;
  PyObject* values[3] = {0,0,0};
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  PyObject *__pyx_r = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_idle_reassign (wrapper)", 0);
  #if !CYTHON_METH_FASTCALL
  #if CYTHON_ASSUME_SAFE_SIZE
  __pyx_nargs = PyTuple_GET_SIZE(__pyx_args);
  #else
  __pyx_nargs = PyTuple_Size(__pyx_args); if (unlikely(__pyx_nargs < 0)) return NULL;
  #endif
  #endif
  __pyx_kwvalues = __Pyx_KwValues_FASTCALL(__pyx_args, __pyx_nargs);
  {
    PyObject ** const __pyx_pyargnames[] = {&__pyx_mstate_global->__pyx_n_u_self,&__pyx_mstate_global->__pyx_n_u_project_id,&__pyx_mstate_global->__pyx_n_u_task_id,0};
    const Py_ssize_t __pyx_kwds_len = (__pyx_kwds) ? __Pyx_NumKwargs_FASTCALL(__pyx_kwds) : 0;
    if (unlikely(__pyx_kwds_len < 0)) __PYX_ERR(0, 6729, __pyx_L3_error)
    if (__pyx_kwds_len > 0) {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 6729, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 6729, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  1:
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 6729, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  0: break;
        default: goto __pyx_L5_argtuple_error;
      }
      const Py_ssize_t kwd_pos_args = __pyx_nargs;
      if (__Pyx_ParseKeywords(__pyx_kwds, __pyx_kwvalues, __pyx_pyargnames, 0, values, kwd_pos_args, __pyx_kwds_len, "_idle_reassign", 0) < (0)) __PYX_ERR(0, 6729, __pyx_L3_error)
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject*)Py_None));
      for (Py_ssize_t i = __pyx_nargs; i < 2; i++) {
        if (unlikely(!values[i])) { __Pyx_RaiseArgtupleInvalid("_idle_reassign", 0, 2, 3, i); __PYX_ERR(0, 6729, __pyx_L3_error) }
      }
    } else {
      switch (__pyx_nargs) {
        case  3:
        values[2] = __Pyx_ArgRef_FASTCALL(__pyx_args, 2);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[2])) __PYX_ERR(0, 6729, __pyx_L3_error)
        CYTHON_FALLTHROUGH;
        case  2:
        values[1] = __Pyx_ArgRef_FASTCALL(__pyx_args, 1);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[1])) __PYX_ERR(0, 6729, __pyx_L3_error)
        values[0] = __Pyx_ArgRef_FASTCALL(__pyx_args, 0);
        if (!CYTHON_ASSUME_SAFE_MACROS && unlikely(!values[0])) __PYX_ERR(0, 6729, __pyx_L3_error)
        break;
        default: goto __pyx_L5_argtuple_error;
      }
      if (!values[2]) values[2] = __Pyx_NewRef(((PyObject*)Py_None));
    }
    __pyx_v_self = values[0];
    __pyx_v_project_id = ((PyObject*)values[1]);
    __pyx_v_task_id = ((PyObject*)values[2]);
  }
  goto __pyx_L6_skip;
  __pyx_L5_argtuple_error:;
  __Pyx_RaiseArgtupleInvalid("_idle_reassign", 0, 2, 3, __pyx_nargs); __PYX_ERR(0, 6729, __pyx_L3_error)
  __pyx_L6_skip:;
  goto __pyx_L4_argument_unpacking_done;
  __pyx_L3_error:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._idle_reassign", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __Pyx_RefNannyFinishContext();
  return NULL;
  __pyx_L4_argument_unpacking_done:;
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_project_id), (&PyUnicode_Type), 0, "project_id", 2))) __PYX_ERR(0, 6729, __pyx_L1_error)
  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_task_id), (&PyUnicode_Type), 1, "task_id", 2))) __PYX_ERR(0, 6729, __pyx_L1_error)
  __pyx_r = __pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_224_idle_reassign(__pyx_self, __pyx_v_self, __pyx_v_project_id, __pyx_v_task_id);

  /* function exit code */
  goto __pyx_L0;
  __pyx_L1_error:;
  __pyx_r = NULL;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  goto __pyx_L7_cleaned_up;
  __pyx_L0:;
  for (Py_ssize_t __pyx_temp=0; __pyx_temp < (Py_ssize_t)(sizeof(values)/sizeof(values[0])); ++__pyx_temp) {
    Py_XDECREF(values[__pyx_temp]);
  }
  __pyx_L7_cleaned_up:;
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_pf_10ws_package_11controllers_19activity_controller_18ActivityController_224_idle_reassign(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_project_id, PyObject *__pyx_v_task_id) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign *__pyx_cur_scope;
  PyObject *__pyx_r = NULL;
  __Pyx_RefNannyDeclarations
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("_idle_reassign", 0);
  __pyx_cur_scope = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign(__pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign, __pyx_mstate_global->__pyx_empty_tuple, NULL);
  if (unlikely(!__pyx_cur_scope)) {
    __pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign *)Py_None);
    __Pyx_INCREF(Py_None);
    __PYX_ERR(0, 6729, __pyx_L1_error)
  } else {
    __Pyx_GOTREF((PyObject *)__pyx_cur_scope);
  }
  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
  __pyx_cur_scope->__pyx_v_project_id = __pyx_v_project_id;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_project_id);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_project_id);
  __pyx_cur_scope->__pyx_v_task_id = __pyx_v_task_id;
  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_task_id);
  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_task_id);
  {
    __pyx_CoroutineObject *gen = __Pyx_Coroutine_New((__pyx_coroutine_body_t) __pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_226generator50, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[77]), (PyObject *) __pyx_cur_scope, __pyx_mstate_global->__pyx_n_u_idle_reassign, __pyx_mstate_global->__pyx_n_u_ActivityController__idle_reassig, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity); if (unlikely(!gen)) __PYX_ERR(0, 6729, __pyx_L1_error)
    __Pyx_DECREF(__pyx_cur_scope);
    __Pyx_RefNannyFinishContext();
    return (PyObject *) gen;
  }

  /* function exit code */
  __pyx_L1_error:;
  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._idle_reassign", __pyx_clineno, __pyx_lineno, __pyx_filename);
  __pyx_r = NULL;
  __Pyx_DECREF((PyObject *)__pyx_cur_scope);
  __Pyx_XGIVEREF(__pyx_r);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}

static PyObject *__pyx_gb_10ws_package_11controllers_19activity_controller_18ActivityController_226generator50(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */
{
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign *__pyx_cur_scope = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign *)__pyx_generator->closure);
  PyObject *__pyx_r = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  PyObject *__pyx_t_3 = NULL;
  PyObject *__pyx_t_4 = NULL;
  int __pyx_t_5;
  int __pyx_t_6;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  size_t __pyx_t_10;
  __Pyx_PySendResult __pyx_t_11;
  PyObject *__pyx_t_12 = NULL;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  PyObject *__pyx_t_16 = NULL;
  PyObject *__pyx_t_17 = NULL;
  PyObject *__pyx_t_18 = NULL;
  PyObject *__pyx_t_19 = NULL;
  PyObject *__pyx_t_20 = NULL;
  PyObject *__pyx_t_21 = NULL;
  PyObject *__pyx_t_22 = NULL;
  PyObject *__pyx_t_23 = NULL;
  PyObject *__pyx_t_24 = NULL;
  Py_ssize_t __pyx_t_25;
  Py_ssize_t __pyx_t_26;
  int __pyx_t_27;
  int __pyx_t_28;
  Py_ssize_t __pyx_t_29;
  PyObject *(*__pyx_t_30)(PyObject *);
  PyObject *__pyx_t_31 = NULL;
  PyObject *__pyx_t_32 = NULL;
  PyObject *__pyx_t_33 = NULL;
  PyObject *__pyx_t_34 = NULL;
  PyObject *__pyx_t_35 = NULL;
  Py_ssize_t __pyx_t_36;
  PyObject *(*__pyx_t_37)(PyObject *);
  PyObject *__pyx_t_38 = NULL;
  int __pyx_t_39;
  char const *__pyx_t_40;
  PyObject *(*__pyx_t_41)(PyObject *);
  PyObject *__pyx_t_42 = NULL;
  int __pyx_t_43;
  PyObject *__pyx_t_44 = NULL;
  char const *__pyx_t_45;
  char const *__pyx_t_46;
  char const *__pyx_t_47;
  char const *__pyx_t_48;
  char const *__pyx_t_49;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  __Pyx_RefNannySetupContext("_idle_reassign", 0);
  switch (__pyx_generator->resume_label) {
    case 0: goto __pyx_L3_first_run;
    case 1: goto __pyx_L12_resume_from_await;
    case 2: goto __pyx_L13_resume_from_await;
    case 3: goto __pyx_L25_resume_from_await;
    case 4: goto __pyx_L35_resume_from_await;
    case 5: goto __pyx_L39_resume_from_await;
    case 6: goto __pyx_L40_resume_from_await;
    case 7: goto __pyx_L85_resume_from_await;
    case 8: goto __pyx_L99_resume_from_await;
    case 9: goto __pyx_L112_resume_from_await;
    case 10: goto __pyx_L113_resume_from_await;
    case 11: goto __pyx_L146_resume_from_await;
    case 12: goto __pyx_L147_resume_from_await;
    case 13: goto __pyx_L148_resume_from_await;
    case 14: goto __pyx_L180_resume_from_await;
    case 15: goto __pyx_L216_resume_from_await;
    case 16: goto __pyx_L217_resume_from_await;
    default: /* CPython raises the right error here */
    __Pyx_RefNannyFinishContext();
    return NULL;
  }
  __pyx_L3_first_run:;
  if (unlikely(__pyx_sent_value != Py_None)) {
    if (unlikely(__pyx_sent_value)) PyErr_SetString(PyExc_TypeError, "can't send non-None value to a just-started coroutine");
    __PYX_ERR(0, 6729, __pyx_L1_error)
  }

  /* "ws_package/controllers/activity_controller.py":6737
 *             task_id: Task ID to assign idle intervals to (optional, defaults to "0" if not provided)
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # Convert task_id to string, default to "0" if None
 *             task_id_str = str(task_id) if task_id is not None and task_id != "" else "0"
*/
  {
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_2, &__pyx_t_3);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_2);
    __Pyx_XGOTREF(__pyx_t_3);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":6739
 *         try:
 *             # Convert task_id to string, default to "0" if None
 *             task_id_str = str(task_id) if task_id is not None and task_id != "" else "0"             # <<<<<<<<<<<<<<
 *             project_id_str = str(project_id)
 * 
*/
      __pyx_t_6 = (__pyx_cur_scope->__pyx_v_task_id != ((PyObject*)Py_None));
      if (__pyx_t_6) {
      } else {
        __pyx_t_5 = __pyx_t_6;
        goto __pyx_L10_bool_binop_done;
      }
      __pyx_t_6 = (__Pyx_PyUnicode_Equals(__pyx_cur_scope->__pyx_v_task_id, __pyx_mstate_global->__pyx_kp_u__2, Py_NE)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 6739, __pyx_L4_error)
      __pyx_t_5 = __pyx_t_6;
      __pyx_L10_bool_binop_done:;
      if (__pyx_t_5) {
        __pyx_t_7 = __Pyx_PyUnicode_Unicode(__pyx_cur_scope->__pyx_v_task_id); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6739, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
        __pyx_t_4 = __pyx_t_7;
        __pyx_t_7 = 0;
      } else {
        __Pyx_INCREF(__pyx_mstate_global->__pyx_kp_u_0);
        __pyx_t_4 = __pyx_mstate_global->__pyx_kp_u_0;
      }
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_cur_scope->__pyx_v_task_id_str = ((PyObject*)__pyx_t_4);
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":6740
 *             # Convert task_id to string, default to "0" if None
 *             task_id_str = str(task_id) if task_id is not None and task_id != "" else "0"
 *             project_id_str = str(project_id)             # <<<<<<<<<<<<<<
 * 
 *             logger.info("=== Starting idle interval reassign: project_id=%s, task_id=%s ===", project_id_str, task_id_str)
*/
      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_project_id);
      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_project_id);
      __pyx_cur_scope->__pyx_v_project_id_str = __pyx_cur_scope->__pyx_v_project_id;

      /* "ws_package/controllers/activity_controller.py":6742
 *             project_id_str = str(project_id)
 * 
 *             logger.info("=== Starting idle interval reassign: project_id=%s, task_id=%s ===", project_id_str, task_id_str)             # <<<<<<<<<<<<<<
 * 
 *             # Flush queue first to ensure all pending writes are committed
*/
      __pyx_t_7 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6742, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6742, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_10 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_9))) {
        __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9);
        assert(__pyx_t_7);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
        __Pyx_INCREF(__pyx_t_7);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
        __pyx_t_10 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[4] = {__pyx_t_7, __pyx_mstate_global->__pyx_kp_u_Starting_idle_interval_reassign, __pyx_cur_scope->__pyx_v_project_id_str, __pyx_cur_scope->__pyx_v_task_id_str};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_10, (4-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6742, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":6745
 * 
 *             # Flush queue first to ensure all pending writes are committed
 *             await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 *             await asyncio.sleep(0.3)
 * 
*/
      __pyx_t_9 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6745, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6745, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      __pyx_t_10 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
        assert(__pyx_t_9);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_9);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
        __pyx_t_10 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_9, NULL};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6745, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (likely(__pyx_t_11 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
        __Pyx_XGIVEREF(__pyx_t_2);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
        __Pyx_XGIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 1;
        return __pyx_r;
        __pyx_L12_resume_from_await:;
        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_1);
        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_2);
        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_3);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6745, __pyx_L4_error)
      } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_DECREF(__pyx_r); __pyx_r = 0;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 6745, __pyx_L4_error)
      }

      /* "ws_package/controllers/activity_controller.py":6746
 *             # Flush queue first to ensure all pending writes are committed
 *             await db_writer_service.process_immediately()
 *             await asyncio.sleep(0.3)             # <<<<<<<<<<<<<<
 * 
 *             # Get all idle intervals that are not uploaded
*/
      __pyx_t_8 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6746, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_9);
      __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6746, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_7);
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
      __pyx_t_10 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_7))) {
        __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
        assert(__pyx_t_8);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
        __Pyx_INCREF(__pyx_t_8);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
        __pyx_t_10 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_mstate_global->__pyx_float_0_3};
        __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6746, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
      }
      __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_4, &__pyx_r);
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
      if (likely(__pyx_t_11 == PYGEN_NEXT)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_XGIVEREF(__pyx_t_1);
        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
        __Pyx_XGIVEREF(__pyx_t_2);
        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
        __Pyx_XGIVEREF(__pyx_t_3);
        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
        __Pyx_XGIVEREF(__pyx_r);
        __Pyx_RefNannyFinishContext();
        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
        /* return from generator, awaiting value */
        __pyx_generator->resume_label = 2;
        return __pyx_r;
        __pyx_L13_resume_from_await:;
        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
        __pyx_cur_scope->__pyx_t_0 = 0;
        __Pyx_XGOTREF(__pyx_t_1);
        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
        __pyx_cur_scope->__pyx_t_1 = 0;
        __Pyx_XGOTREF(__pyx_t_2);
        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
        __pyx_cur_scope->__pyx_t_2 = 0;
        __Pyx_XGOTREF(__pyx_t_3);
        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6746, __pyx_L4_error)
      } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
        __Pyx_GOTREF(__pyx_r);
        __Pyx_DECREF(__pyx_r); __pyx_r = 0;
      } else {
        __Pyx_XGOTREF(__pyx_r);
        __PYX_ERR(0, 6746, __pyx_L4_error)
      }

      /* "ws_package/controllers/activity_controller.py":6749
 * 
 *             # Get all idle intervals that are not uploaded
 *             idle_intervals = []             # <<<<<<<<<<<<<<
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:
*/
      __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6749, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_4);
      __Pyx_GIVEREF(__pyx_t_4);
      __pyx_cur_scope->__pyx_v_idle_intervals = __pyx_t_4;
      __pyx_t_4 = 0;

      /* "ws_package/controllers/activity_controller.py":6750
 *             # Get all idle intervals that are not uploaded
 *             idle_intervals = []
 *             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     # Get ALL idle intervals (is_idle=1) that are not uploaded (is_uploaded=0)
*/
      /*with:*/ {
        __pyx_t_7 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6750, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6750, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_9);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_9))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_9);
          assert(__pyx_t_7);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
          __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6750, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_4);
        }
        __pyx_t_12 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 6750, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_12);
        __pyx_t_7 = NULL;
        __pyx_t_8 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6750, __pyx_L14_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (likely(PyMethod_Check(__pyx_t_8))) {
          __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_8);
          assert(__pyx_t_7);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
          __Pyx_INCREF(__pyx_t_7);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_7, NULL};
          __pyx_t_9 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
          if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6750, __pyx_L14_error)
          __Pyx_GOTREF(__pyx_t_9);
        }
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        /*try:*/ {
          {
            __Pyx_ExceptionSave(&__pyx_t_13, &__pyx_t_14, &__pyx_t_15);
            __Pyx_XGOTREF(__pyx_t_13);
            __Pyx_XGOTREF(__pyx_t_14);
            __Pyx_XGOTREF(__pyx_t_15);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":6751
 *             idle_intervals = []
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     # Get ALL idle intervals (is_idle=1) that are not uploaded (is_uploaded=0)
 *                     query = select(ActivityInterval).where(
*/
              /*with:*/ {
                __pyx_t_9 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6751, __pyx_L18_error)
                __Pyx_GOTREF(__pyx_t_8);
                __pyx_t_10 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_8))) {
                  __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_8);
                  assert(__pyx_t_9);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
                  __Pyx_INCREF(__pyx_t_9);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
                  __pyx_t_10 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_9, NULL};
                  __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6751, __pyx_L18_error)
                  __Pyx_GOTREF(__pyx_t_4);
                }
                __pyx_t_16 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 6751, __pyx_L18_error)
                __Pyx_GOTREF(__pyx_t_16);
                __pyx_t_9 = NULL;
                __pyx_t_7 = __Pyx_PyObject_LookupSpecial(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6751, __pyx_L24_error)
                __Pyx_GOTREF(__pyx_t_7);
                __pyx_t_10 = 1;
                #if CYTHON_UNPACK_METHODS
                if (likely(PyMethod_Check(__pyx_t_7))) {
                  __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7);
                  assert(__pyx_t_9);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_7);
                  __Pyx_INCREF(__pyx_t_9);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_7, __pyx__function);
                  __pyx_t_10 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_9, NULL};
                  __pyx_t_8 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_7, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                  if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6751, __pyx_L24_error)
                  __Pyx_GOTREF(__pyx_t_8);
                }
                __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_8, &__pyx_r);
                __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                  __Pyx_GOTREF(__pyx_r);
                  __Pyx_XGIVEREF(__pyx_t_1);
                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                  __Pyx_XGIVEREF(__pyx_t_2);
                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                  __Pyx_XGIVEREF(__pyx_t_3);
                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                  __Pyx_XGIVEREF(__pyx_t_4);
                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_4;
                  __Pyx_XGIVEREF(__pyx_t_12);
                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                  __Pyx_XGIVEREF(__pyx_t_13);
                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                  __Pyx_XGIVEREF(__pyx_t_14);
                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                  __Pyx_XGIVEREF(__pyx_t_15);
                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_15;
                  __Pyx_XGIVEREF(__pyx_t_16);
                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_16;
                  __Pyx_XGIVEREF(__pyx_r);
                  __Pyx_RefNannyFinishContext();
                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                  /* return from generator, awaiting value */
                  __pyx_generator->resume_label = 3;
                  return __pyx_r;
                  __pyx_L25_resume_from_await:;
                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                  __pyx_cur_scope->__pyx_t_0 = 0;
                  __Pyx_XGOTREF(__pyx_t_1);
                  __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                  __pyx_cur_scope->__pyx_t_1 = 0;
                  __Pyx_XGOTREF(__pyx_t_2);
                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                  __pyx_cur_scope->__pyx_t_2 = 0;
                  __Pyx_XGOTREF(__pyx_t_3);
                  __pyx_t_4 = __pyx_cur_scope->__pyx_t_3;
                  __pyx_cur_scope->__pyx_t_3 = 0;
                  __Pyx_XGOTREF(__pyx_t_4);
                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                  __pyx_cur_scope->__pyx_t_4 = 0;
                  __Pyx_XGOTREF(__pyx_t_12);
                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                  __pyx_cur_scope->__pyx_t_5 = 0;
                  __Pyx_XGOTREF(__pyx_t_13);
                  __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                  __pyx_cur_scope->__pyx_t_6 = 0;
                  __Pyx_XGOTREF(__pyx_t_14);
                  __pyx_t_15 = __pyx_cur_scope->__pyx_t_7;
                  __pyx_cur_scope->__pyx_t_7 = 0;
                  __Pyx_XGOTREF(__pyx_t_15);
                  __pyx_t_16 = __pyx_cur_scope->__pyx_t_8;
                  __pyx_cur_scope->__pyx_t_8 = 0;
                  __Pyx_XGOTREF(__pyx_t_16);
                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6751, __pyx_L24_error)
                  __pyx_t_8 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_8);
                } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                  __Pyx_GOTREF(__pyx_r);
                  __pyx_t_8 = __pyx_r; __pyx_r = NULL;
                } else {
                  __Pyx_XGOTREF(__pyx_r);
                  __PYX_ERR(0, 6751, __pyx_L24_error)
                }
                __pyx_t_7 = __pyx_t_8;
                __pyx_t_8 = 0;
                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                /*try:*/ {
                  {
                    __Pyx_ExceptionSave(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
                    __Pyx_XGOTREF(__pyx_t_17);
                    __Pyx_XGOTREF(__pyx_t_18);
                    __Pyx_XGOTREF(__pyx_t_19);
                    /*try:*/ {
                      __Pyx_GIVEREF(__pyx_t_7);
                      __pyx_cur_scope->__pyx_v_session = __pyx_t_7;
                      __pyx_t_7 = 0;

                      /* "ws_package/controllers/activity_controller.py":6753
 *                 async with async_session() as session:
 *                     # Get ALL idle intervals (is_idle=1) that are not uploaded (is_uploaded=0)
 *                     query = select(ActivityInterval).where(             # <<<<<<<<<<<<<<
 *                         ActivityInterval.is_idle == True,
 *                         ActivityInterval.is_uploaded == False
*/
                      __pyx_t_21 = NULL;
                      __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6753, __pyx_L29_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6753, __pyx_L29_error)
                      __Pyx_GOTREF(__pyx_t_23);
                      __pyx_t_10 = 1;
                      #if CYTHON_UNPACK_METHODS
                      if (unlikely(PyMethod_Check(__pyx_t_22))) {
                        __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_22);
                        assert(__pyx_t_21);
                        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_22);
                        __Pyx_INCREF(__pyx_t_21);
                        __Pyx_INCREF(__pyx__function);
                        __Pyx_DECREF_SET(__pyx_t_22, __pyx__function);
                        __pyx_t_10 = 0;
                      }
                      #endif
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_21, __pyx_t_23};
                        __pyx_t_20 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_22, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6753, __pyx_L29_error)
                        __Pyx_GOTREF(__pyx_t_20);
                      }
                      __pyx_t_9 = __pyx_t_20;
                      __Pyx_INCREF(__pyx_t_9);

                      /* "ws_package/controllers/activity_controller.py":6754
 *                     # Get ALL idle intervals (is_idle=1) that are not uploaded (is_uploaded=0)
 *                     query = select(ActivityInterval).where(
 *                         ActivityInterval.is_idle == True,             # <<<<<<<<<<<<<<
 *                         ActivityInterval.is_uploaded == False
 *                     ).order_by(ActivityInterval.start_time)
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6754, __pyx_L29_error)
                      __Pyx_GOTREF(__pyx_t_22);
                      __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_is_idle); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6754, __pyx_L29_error)
                      __Pyx_GOTREF(__pyx_t_23);
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                      __pyx_t_22 = PyObject_RichCompare(__pyx_t_23, Py_True, Py_EQ); __Pyx_XGOTREF(__pyx_t_22); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6754, __pyx_L29_error)
                      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

                      /* "ws_package/controllers/activity_controller.py":6755
 *                     query = select(ActivityInterval).where(
 *                         ActivityInterval.is_idle == True,
 *                         ActivityInterval.is_uploaded == False             # <<<<<<<<<<<<<<
 *                     ).order_by(ActivityInterval.start_time)
 * 
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6755, __pyx_L29_error)
                      __Pyx_GOTREF(__pyx_t_23);
                      __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_is_uploaded); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6755, __pyx_L29_error)
                      __Pyx_GOTREF(__pyx_t_21);
                      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                      __pyx_t_23 = PyObject_RichCompare(__pyx_t_21, Py_False, Py_EQ); __Pyx_XGOTREF(__pyx_t_23); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6755, __pyx_L29_error)
                      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                      __pyx_t_10 = 0;
                      {
                        PyObject *__pyx_callargs[3] = {__pyx_t_9, __pyx_t_22, __pyx_t_23};
                        __pyx_t_8 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_where, __pyx_callargs+__pyx_t_10, (3-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                        if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6753, __pyx_L29_error)
                        __Pyx_GOTREF(__pyx_t_8);
                      }
                      __pyx_t_4 = __pyx_t_8;
                      __Pyx_INCREF(__pyx_t_4);

                      /* "ws_package/controllers/activity_controller.py":6756
 *                         ActivityInterval.is_idle == True,
 *                         ActivityInterval.is_uploaded == False
 *                     ).order_by(ActivityInterval.start_time)             # <<<<<<<<<<<<<<
 * 
 *                     result = await session.execute(query)
*/
                      __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_ActivityInterval); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6756, __pyx_L29_error)
                      __Pyx_GOTREF(__pyx_t_20);
                      __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6756, __pyx_L29_error)
                      __Pyx_GOTREF(__pyx_t_23);
                      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                      __pyx_t_10 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_4, __pyx_t_23};
                        __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_order_by, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6756, __pyx_L29_error)
                        __Pyx_GOTREF(__pyx_t_7);
                      }
                      __Pyx_GIVEREF(__pyx_t_7);
                      __pyx_cur_scope->__pyx_v_query = __pyx_t_7;
                      __pyx_t_7 = 0;

                      /* "ws_package/controllers/activity_controller.py":6758
 *                     ).order_by(ActivityInterval.start_time)
 * 
 *                     result = await session.execute(query)             # <<<<<<<<<<<<<<
 *                     idle_intervals = result.scalars().all()
 * 
*/
                      __pyx_t_8 = __pyx_cur_scope->__pyx_v_session;
                      __Pyx_INCREF(__pyx_t_8);
                      __pyx_t_10 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_cur_scope->__pyx_v_query};
                        __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6758, __pyx_L29_error)
                        __Pyx_GOTREF(__pyx_t_7);
                      }
                      __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
                      if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_t_19);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_19;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 4;
                        return __pyx_r;
                        __pyx_L35_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        __pyx_t_19 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_19);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6758, __pyx_L29_error)
                        __pyx_t_7 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_7);
                      } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_7 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 6758, __pyx_L29_error)
                      }
                      __Pyx_GIVEREF(__pyx_t_7);
                      __pyx_cur_scope->__pyx_v_result = __pyx_t_7;
                      __pyx_t_7 = 0;

                      /* "ws_package/controllers/activity_controller.py":6759
 * 
 *                     result = await session.execute(query)
 *                     idle_intervals = result.scalars().all()             # <<<<<<<<<<<<<<
 * 
 *             if not idle_intervals:
*/
                      __pyx_t_4 = __pyx_cur_scope->__pyx_v_result;
                      __Pyx_INCREF(__pyx_t_4);
                      __pyx_t_10 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
                        __pyx_t_23 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalars, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                        if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6759, __pyx_L29_error)
                        __Pyx_GOTREF(__pyx_t_23);
                      }
                      __pyx_t_8 = __pyx_t_23;
                      __Pyx_INCREF(__pyx_t_8);
                      __pyx_t_10 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
                        __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_all, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6759, __pyx_L29_error)
                        __Pyx_GOTREF(__pyx_t_7);
                      }
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_idle_intervals);
                      __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_idle_intervals, __pyx_t_7);
                      __Pyx_GIVEREF(__pyx_t_7);
                      __pyx_t_7 = 0;

                      /* "ws_package/controllers/activity_controller.py":6751
 *             idle_intervals = []
 *             with db_lock_manager.read_lock():
 *                 async with async_session() as session:             # <<<<<<<<<<<<<<
 *                     # Get ALL idle intervals (is_idle=1) that are not uploaded (is_uploaded=0)
 *                     query = select(ActivityInterval).where(
*/
                    }
                    __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                    __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                    goto __pyx_L34_try_end;
                    __pyx_L29_error:;
                    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                    /*except:*/ {
                      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._idle_reassign", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_23, &__pyx_t_8) < 0) __PYX_ERR(0, 6751, __pyx_L31_except_error)
                      __Pyx_XGOTREF(__pyx_t_7);
                      __Pyx_XGOTREF(__pyx_t_23);
                      __Pyx_XGOTREF(__pyx_t_8);
                      __pyx_t_4 = PyTuple_Pack(3, __pyx_t_7, __pyx_t_23, __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6751, __pyx_L31_except_error)
                      __Pyx_GOTREF(__pyx_t_4);
                      __pyx_t_24 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_t_4, NULL);
                      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                      if (unlikely(!__pyx_t_24)) __PYX_ERR(0, 6751, __pyx_L31_except_error)
                      __Pyx_GOTREF(__pyx_t_24);
                      __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_24, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                      if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_7);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_7;
                        __Pyx_XGIVEREF(__pyx_t_8);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_8;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_17);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_17;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_11 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_t_19);
                        __pyx_cur_scope->__pyx_t_12 = __pyx_t_19;
                        __Pyx_XGIVEREF(__pyx_t_23);
                        __pyx_cur_scope->__pyx_t_13 = __pyx_t_23;
                        __Pyx_XGIVEREF(__pyx_t_24);
                        __pyx_cur_scope->__pyx_t_14 = __pyx_t_24;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_SwapException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 5;
                        return __pyx_r;
                        __pyx_L39_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_7 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_7);
                        __pyx_t_8 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_8);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_17 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_17);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_11;
                        __pyx_cur_scope->__pyx_t_11 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        __pyx_t_19 = __pyx_cur_scope->__pyx_t_12;
                        __pyx_cur_scope->__pyx_t_12 = 0;
                        __Pyx_XGOTREF(__pyx_t_19);
                        __pyx_t_23 = __pyx_cur_scope->__pyx_t_13;
                        __pyx_cur_scope->__pyx_t_13 = 0;
                        __Pyx_XGOTREF(__pyx_t_23);
                        __pyx_t_24 = __pyx_cur_scope->__pyx_t_14;
                        __pyx_cur_scope->__pyx_t_14 = 0;
                        __Pyx_XGOTREF(__pyx_t_24);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6751, __pyx_L31_except_error)
                        __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                      } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 6751, __pyx_L31_except_error)
                      }
                      __pyx_t_24 = __pyx_t_4;
                      __pyx_t_4 = 0;
                      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_24);
                      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
                      if (__pyx_t_5 < (0)) __PYX_ERR(0, 6751, __pyx_L31_except_error)
                      __pyx_t_6 = (!__pyx_t_5);
                      if (unlikely(__pyx_t_6)) {
                        __Pyx_GIVEREF(__pyx_t_7);
                        __Pyx_GIVEREF(__pyx_t_23);
                        __Pyx_XGIVEREF(__pyx_t_8);
                        __Pyx_ErrRestoreWithState(__pyx_t_7, __pyx_t_23, __pyx_t_8);
                        __pyx_t_7 = 0;  __pyx_t_23 = 0;  __pyx_t_8 = 0; 
                        __PYX_ERR(0, 6751, __pyx_L31_except_error)
                      }
                      __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
                      __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                      goto __pyx_L30_exception_handled;
                    }
                    __pyx_L31_except_error:;
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __Pyx_XGIVEREF(__pyx_t_19);
                    __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19);
                    goto __pyx_L18_error;
                    __pyx_L30_exception_handled:;
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __Pyx_XGIVEREF(__pyx_t_19);
                    __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19);
                    __pyx_L34_try_end:;
                  }
                }
                /*finally:*/ {
                  /*normal exit:*/{
                    if (__pyx_t_16) {
                      __pyx_t_19 = __Pyx_PyObject_Call(__pyx_t_16, __pyx_mstate_global->__pyx_tuple[7], NULL);
                      __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                      if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 6751, __pyx_L18_error)
                      __Pyx_GOTREF(__pyx_t_19);
                      __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_19, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                      if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_19);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_19;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 6;
                        return __pyx_r;
                        __pyx_L40_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_19 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_19);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6751, __pyx_L18_error)
                        __pyx_t_8 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_8);
                      } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __pyx_t_8 = __pyx_r; __pyx_r = NULL;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 6751, __pyx_L18_error)
                      }
                      __pyx_t_19 = __pyx_t_8;
                      __pyx_t_8 = 0;
                      __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
                    }
                    goto __pyx_L28;
                  }
                  __pyx_L28:;
                }
                goto __pyx_L41;
                __pyx_L24_error:;
                __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
                goto __pyx_L18_error;
                __pyx_L41:;
              }

              /* "ws_package/controllers/activity_controller.py":6750
 *             # Get all idle intervals that are not uploaded
 *             idle_intervals = []
 *             with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                 async with async_session() as session:
 *                     # Get ALL idle intervals (is_idle=1) that are not uploaded (is_uploaded=0)
*/
            }
            __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
            __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
            __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
            goto __pyx_L23_try_end;
            __pyx_L18_error:;
            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
            __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
            __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
            __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
            __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
            __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
            __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
            /*except:*/ {
              __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._idle_reassign", __pyx_clineno, __pyx_lineno, __pyx_filename);
              if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_23, &__pyx_t_7) < 0) __PYX_ERR(0, 6750, __pyx_L20_except_error)
              __Pyx_XGOTREF(__pyx_t_8);
              __Pyx_XGOTREF(__pyx_t_23);
              __Pyx_XGOTREF(__pyx_t_7);
              __pyx_t_4 = PyTuple_Pack(3, __pyx_t_8, __pyx_t_23, __pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6750, __pyx_L20_except_error)
              __Pyx_GOTREF(__pyx_t_4);
              __pyx_t_16 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_t_4, NULL);
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              if (unlikely(!__pyx_t_16)) __PYX_ERR(0, 6750, __pyx_L20_except_error)
              __Pyx_GOTREF(__pyx_t_16);
              __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_16);
              __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
              if (__pyx_t_6 < (0)) __PYX_ERR(0, 6750, __pyx_L20_except_error)
              __pyx_t_5 = (!__pyx_t_6);
              if (unlikely(__pyx_t_5)) {
                __Pyx_GIVEREF(__pyx_t_8);
                __Pyx_GIVEREF(__pyx_t_23);
                __Pyx_XGIVEREF(__pyx_t_7);
                __Pyx_ErrRestoreWithState(__pyx_t_8, __pyx_t_23, __pyx_t_7);
                __pyx_t_8 = 0;  __pyx_t_23 = 0;  __pyx_t_7 = 0; 
                __PYX_ERR(0, 6750, __pyx_L20_except_error)
              }
              __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
              goto __pyx_L19_exception_handled;
            }
            __pyx_L20_except_error:;
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_XGIVEREF(__pyx_t_15);
            __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
            goto __pyx_L4_error;
            __pyx_L19_exception_handled:;
            __Pyx_XGIVEREF(__pyx_t_13);
            __Pyx_XGIVEREF(__pyx_t_14);
            __Pyx_XGIVEREF(__pyx_t_15);
            __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15);
            __pyx_L23_try_end:;
          }
        }
        /*finally:*/ {
          /*normal exit:*/{
            if (__pyx_t_12) {
              __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_12, __pyx_mstate_global->__pyx_tuple[7], NULL);
              __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
              if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 6750, __pyx_L4_error)
              __Pyx_GOTREF(__pyx_t_15);
              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
            }
            goto __pyx_L17;
          }
          __pyx_L17:;
        }
        goto __pyx_L45;
        __pyx_L14_error:;
        __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
        goto __pyx_L4_error;
        __pyx_L45:;
      }

      /* "ws_package/controllers/activity_controller.py":6761
 *                     idle_intervals = result.scalars().all()
 * 
 *             if not idle_intervals:             # <<<<<<<<<<<<<<
 *                 logger.info("No idle intervals found to reassign")
 *                 return
*/
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_idle_intervals); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 6761, __pyx_L4_error)
      __pyx_t_6 = (!__pyx_t_5);
      if (__pyx_t_6) {

        /* "ws_package/controllers/activity_controller.py":6762
 * 
 *             if not idle_intervals:
 *                 logger.info("No idle intervals found to reassign")             # <<<<<<<<<<<<<<
 *                 return
 * 
*/
        __pyx_t_23 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6762, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_8);
        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6762, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_4);
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_4))) {
          __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_4);
          assert(__pyx_t_23);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
          __Pyx_INCREF(__pyx_t_23);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_23, __pyx_mstate_global->__pyx_kp_u_No_idle_intervals_found_to_reass};
          __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6762, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "ws_package/controllers/activity_controller.py":6763
 *             if not idle_intervals:
 *                 logger.info("No idle intervals found to reassign")
 *                 return             # <<<<<<<<<<<<<<
 * 
 *             logger.info("Found %s idle intervals to reassign to project %s, task %s", len(idle_intervals), project_id_str, task_id_str)
*/
        __Pyx_XDECREF(__pyx_r);
        __pyx_r = Py_None; __Pyx_INCREF(Py_None);
        goto __pyx_L8_try_return;

        /* "ws_package/controllers/activity_controller.py":6761
 *                     idle_intervals = result.scalars().all()
 * 
 *             if not idle_intervals:             # <<<<<<<<<<<<<<
 *                 logger.info("No idle intervals found to reassign")
 *                 return
*/
      }

      /* "ws_package/controllers/activity_controller.py":6765
 *                 return
 * 
 *             logger.info("Found %s idle intervals to reassign to project %s, task %s", len(idle_intervals), project_id_str, task_id_str)             # <<<<<<<<<<<<<<
 * 
 *             # Use process_intervals_bulk to build payloads, but override project/task IDs
*/
      __pyx_t_4 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6765, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_23);
      __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6765, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
      __pyx_t_25 = PyObject_Length(__pyx_cur_scope->__pyx_v_idle_intervals); if (unlikely(__pyx_t_25 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6765, __pyx_L4_error)
      __pyx_t_23 = PyLong_FromSsize_t(__pyx_t_25); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6765, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_23);
      __pyx_t_10 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_8))) {
        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8);
        assert(__pyx_t_4);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
        __Pyx_INCREF(__pyx_t_4);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
        __pyx_t_10 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[5] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Found_s_idle_intervals_to_reassi, __pyx_t_23, __pyx_cur_scope->__pyx_v_project_id_str, __pyx_cur_scope->__pyx_v_task_id_str};
        __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_10, (5-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6765, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "ws_package/controllers/activity_controller.py":6769
 *             # Use process_intervals_bulk to build payloads, but override project/task IDs
 *             # Group intervals by day and process each day separately
 *             grouped_intervals = self.group_intervals_by_day(idle_intervals)             # <<<<<<<<<<<<<<
 * 
 *             success_count = 0
*/
      __pyx_t_8 = __pyx_cur_scope->__pyx_v_self;
      __Pyx_INCREF(__pyx_t_8);
      __pyx_t_10 = 0;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_8, __pyx_cur_scope->__pyx_v_idle_intervals};
        __pyx_t_7 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_group_intervals_by_day, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6769, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
      }
      __Pyx_GIVEREF(__pyx_t_7);
      __pyx_cur_scope->__pyx_v_grouped_intervals = __pyx_t_7;
      __pyx_t_7 = 0;

      /* "ws_package/controllers/activity_controller.py":6771
 *             grouped_intervals = self.group_intervals_by_day(idle_intervals)
 * 
 *             success_count = 0             # <<<<<<<<<<<<<<
 *             failed_count = 0
 * 
*/
      __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_0);
      __pyx_cur_scope->__pyx_v_success_count = __pyx_mstate_global->__pyx_int_0;

      /* "ws_package/controllers/activity_controller.py":6772
 * 
 *             success_count = 0
 *             failed_count = 0             # <<<<<<<<<<<<<<
 * 
 *             for target_date, day_intervals in grouped_intervals.items():
*/
      __Pyx_INCREF(__pyx_mstate_global->__pyx_int_0);
      __Pyx_GIVEREF(__pyx_mstate_global->__pyx_int_0);
      __pyx_cur_scope->__pyx_v_failed_count = __pyx_mstate_global->__pyx_int_0;

      /* "ws_package/controllers/activity_controller.py":6774
 *             failed_count = 0
 * 
 *             for target_date, day_intervals in grouped_intervals.items():             # <<<<<<<<<<<<<<
 *                 try:
 *                     logger.info("Processing %s idle intervals for date %s", len(day_intervals), target_date)
*/
      __pyx_t_25 = 0;
      if (unlikely(__pyx_cur_scope->__pyx_v_grouped_intervals == Py_None)) {
        PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items");
        __PYX_ERR(0, 6774, __pyx_L4_error)
      }
      __pyx_t_8 = __Pyx_dict_iterator(__pyx_cur_scope->__pyx_v_grouped_intervals, 0, __pyx_mstate_global->__pyx_n_u_items, (&__pyx_t_26), (&__pyx_t_27)); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6774, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_8);
      __Pyx_XDECREF(__pyx_t_7);
      __pyx_t_7 = __pyx_t_8;
      __pyx_t_8 = 0;
      while (1) {
        __pyx_t_28 = __Pyx_dict_iter_next(__pyx_t_7, __pyx_t_26, &__pyx_t_25, &__pyx_t_8, &__pyx_t_23, NULL, __pyx_t_27);
        if (unlikely(__pyx_t_28 == 0)) break;
        if (unlikely(__pyx_t_28 == -1)) __PYX_ERR(0, 6774, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_8);
        __Pyx_GOTREF(__pyx_t_23);
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_target_date);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_target_date, __pyx_t_8);
        __Pyx_GIVEREF(__pyx_t_8);
        __pyx_t_8 = 0;
        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_day_intervals);
        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_day_intervals, __pyx_t_23);
        __Pyx_GIVEREF(__pyx_t_23);
        __pyx_t_23 = 0;

        /* "ws_package/controllers/activity_controller.py":6775
 * 
 *             for target_date, day_intervals in grouped_intervals.items():
 *                 try:             # <<<<<<<<<<<<<<
 *                     logger.info("Processing %s idle intervals for date %s", len(day_intervals), target_date)
 * 
*/
        {
          __Pyx_ExceptionSave(&__pyx_t_12, &__pyx_t_15, &__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_14);
          /*try:*/ {

            /* "ws_package/controllers/activity_controller.py":6776
 *             for target_date, day_intervals in grouped_intervals.items():
 *                 try:
 *                     logger.info("Processing %s idle intervals for date %s", len(day_intervals), target_date)             # <<<<<<<<<<<<<<
 * 
 *                     # Edge case: Ensure at most 100 intervals per day
*/
            __pyx_t_8 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6776, __pyx_L49_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6776, __pyx_L49_error)
            __Pyx_GOTREF(__pyx_t_20);
            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
            __pyx_t_29 = PyObject_Length(__pyx_cur_scope->__pyx_v_day_intervals); if (unlikely(__pyx_t_29 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6776, __pyx_L49_error)
            __pyx_t_4 = PyLong_FromSsize_t(__pyx_t_29); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6776, __pyx_L49_error)
            __Pyx_GOTREF(__pyx_t_4);
            __pyx_t_10 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_20))) {
              __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_20);
              assert(__pyx_t_8);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_20);
              __Pyx_INCREF(__pyx_t_8);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_20, __pyx__function);
              __pyx_t_10 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[4] = {__pyx_t_8, __pyx_mstate_global->__pyx_kp_u_Processing_s_idle_intervals_for, __pyx_t_4, __pyx_cur_scope->__pyx_v_target_date};
              __pyx_t_23 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_20, __pyx_callargs+__pyx_t_10, (4-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
              if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6776, __pyx_L49_error)
              __Pyx_GOTREF(__pyx_t_23);
            }
            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

            /* "ws_package/controllers/activity_controller.py":6779
 * 
 *                     # Edge case: Ensure at most 100 intervals per day
 *                     if len(day_intervals) > 100:             # <<<<<<<<<<<<<<
 *                         day_intervals = day_intervals[:100]
 *                         logger.warning("Limited to 100 intervals for date %s", target_date)
*/
            __pyx_t_29 = PyObject_Length(__pyx_cur_scope->__pyx_v_day_intervals); if (unlikely(__pyx_t_29 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6779, __pyx_L49_error)
            __pyx_t_6 = (__pyx_t_29 > 0x64);
            if (__pyx_t_6) {

              /* "ws_package/controllers/activity_controller.py":6780
 *                     # Edge case: Ensure at most 100 intervals per day
 *                     if len(day_intervals) > 100:
 *                         day_intervals = day_intervals[:100]             # <<<<<<<<<<<<<<
 *                         logger.warning("Limited to 100 intervals for date %s", target_date)
 * 
*/
              __pyx_t_23 = __Pyx_PyObject_GetSlice(__pyx_cur_scope->__pyx_v_day_intervals, 0, 0x64, NULL, NULL, &__pyx_mstate_global->__pyx_slice[2], 0, 1, 0); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6780, __pyx_L49_error)
              __Pyx_GOTREF(__pyx_t_23);
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_day_intervals);
              __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_day_intervals, __pyx_t_23);
              __Pyx_GIVEREF(__pyx_t_23);
              __pyx_t_23 = 0;

              /* "ws_package/controllers/activity_controller.py":6781
 *                     if len(day_intervals) > 100:
 *                         day_intervals = day_intervals[:100]
 *                         logger.warning("Limited to 100 intervals for date %s", target_date)             # <<<<<<<<<<<<<<
 * 
 *                     # Get day start time
*/
              __pyx_t_20 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6781, __pyx_L49_error)
              __Pyx_GOTREF(__pyx_t_4);
              __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6781, __pyx_L49_error)
              __Pyx_GOTREF(__pyx_t_8);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __pyx_t_10 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_8))) {
                __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_8);
                assert(__pyx_t_20);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
                __Pyx_INCREF(__pyx_t_20);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
                __pyx_t_10 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_20, __pyx_mstate_global->__pyx_kp_u_Limited_to_100_intervals_for_dat, __pyx_cur_scope->__pyx_v_target_date};
                __pyx_t_23 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_10, (3-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6781, __pyx_L49_error)
                __Pyx_GOTREF(__pyx_t_23);
              }
              __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

              /* "ws_package/controllers/activity_controller.py":6779
 * 
 *                     # Edge case: Ensure at most 100 intervals per day
 *                     if len(day_intervals) > 100:             # <<<<<<<<<<<<<<
 *                         day_intervals = day_intervals[:100]
 *                         logger.warning("Limited to 100 intervals for date %s", target_date)
*/
            }

            /* "ws_package/controllers/activity_controller.py":6784
 * 
 *                     # Get day start time
 *                     day_start_time = self.get_day_start_time(target_date, day_intervals)             # <<<<<<<<<<<<<<
 * 
 *                     # Build interval payloads
*/
            __pyx_t_8 = __pyx_cur_scope->__pyx_v_self;
            __Pyx_INCREF(__pyx_t_8);
            __pyx_t_10 = 0;
            {
              PyObject *__pyx_callargs[3] = {__pyx_t_8, __pyx_cur_scope->__pyx_v_target_date, __pyx_cur_scope->__pyx_v_day_intervals};
              __pyx_t_23 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_day_start_time, __pyx_callargs+__pyx_t_10, (3-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
              if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6784, __pyx_L49_error)
              __Pyx_GOTREF(__pyx_t_23);
            }
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_day_start_time);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_day_start_time, __pyx_t_23);
            __Pyx_GIVEREF(__pyx_t_23);
            __pyx_t_23 = 0;

            /* "ws_package/controllers/activity_controller.py":6787
 * 
 *                     # Build interval payloads
 *                     effective_start_time = day_start_time             # <<<<<<<<<<<<<<
 *                     interval_payloads = []
 *                     # Fetch notes for all intervals in this day from Notes table
*/
            __Pyx_INCREF(__pyx_cur_scope->__pyx_v_day_start_time);
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_effective_start_time);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_effective_start_time, __pyx_cur_scope->__pyx_v_day_start_time);
            __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_day_start_time);

            /* "ws_package/controllers/activity_controller.py":6788
 *                     # Build interval payloads
 *                     effective_start_time = day_start_time
 *                     interval_payloads = []             # <<<<<<<<<<<<<<
 *                     # Fetch notes for all intervals in this day from Notes table
 *                     interval_ids = [interval.id for interval in day_intervals if hasattr(interval, 'id')]
*/
            __pyx_t_23 = PyList_New(0); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6788, __pyx_L49_error)
            __Pyx_GOTREF(__pyx_t_23);
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval_payloads);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval_payloads, ((PyObject*)__pyx_t_23));
            __Pyx_GIVEREF(__pyx_t_23);
            __pyx_t_23 = 0;

            /* "ws_package/controllers/activity_controller.py":6790
 *                     interval_payloads = []
 *                     # Fetch notes for all intervals in this day from Notes table
 *                     interval_ids = [interval.id for interval in day_intervals if hasattr(interval, 'id')]             # <<<<<<<<<<<<<<
 *                     interval_note_map = {}
 * 
*/
            { /* enter inner scope */
              __pyx_t_23 = PyList_New(0); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6790, __pyx_L49_error)
              __Pyx_GOTREF(__pyx_t_23);
              if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_day_intervals)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_day_intervals)) {
                __pyx_t_8 = __pyx_cur_scope->__pyx_v_day_intervals; __Pyx_INCREF(__pyx_t_8);
                __pyx_t_29 = 0;
                __pyx_t_30 = NULL;
              } else {
                __pyx_t_29 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_day_intervals); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6790, __pyx_L49_error)
                __Pyx_GOTREF(__pyx_t_8);
                __pyx_t_30 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_8); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 6790, __pyx_L49_error)
              }
              for (;;) {
                if (likely(!__pyx_t_30)) {
                  if (likely(PyList_CheckExact(__pyx_t_8))) {
                    {
                      Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_8);
                      #if !CYTHON_ASSUME_SAFE_SIZE
                      if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6790, __pyx_L49_error)
                      #endif
                      if (__pyx_t_29 >= __pyx_temp) break;
                    }
                    __pyx_t_20 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_8, __pyx_t_29, __Pyx_ReferenceSharing_OwnStrongReference);
                    ++__pyx_t_29;
                  } else {
                    {
                      Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_8);
                      #if !CYTHON_ASSUME_SAFE_SIZE
                      if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6790, __pyx_L49_error)
                      #endif
                      if (__pyx_t_29 >= __pyx_temp) break;
                    }
                    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                    __pyx_t_20 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_29));
                    #else
                    __pyx_t_20 = __Pyx_PySequence_ITEM(__pyx_t_8, __pyx_t_29);
                    #endif
                    ++__pyx_t_29;
                  }
                  if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6790, __pyx_L49_error)
                } else {
                  __pyx_t_20 = __pyx_t_30(__pyx_t_8);
                  if (unlikely(!__pyx_t_20)) {
                    PyObject* exc_type = PyErr_Occurred();
                    if (exc_type) {
                      if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 6790, __pyx_L49_error)
                      PyErr_Clear();
                    }
                    break;
                  }
                }
                __Pyx_GOTREF(__pyx_t_20);
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_9genexpr30__pyx_v_interval);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_9genexpr30__pyx_v_interval, __pyx_t_20);
                __Pyx_GIVEREF(__pyx_t_20);
                __pyx_t_20 = 0;
                __pyx_t_6 = __Pyx_HasAttr(__pyx_cur_scope->__pyx_9genexpr30__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(__pyx_t_6 == ((int)-1))) __PYX_ERR(0, 6790, __pyx_L49_error)
                if (__pyx_t_6) {
                  __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_9genexpr30__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6790, __pyx_L49_error)
                  __Pyx_GOTREF(__pyx_t_20);
                  if (unlikely(__Pyx_ListComp_Append(__pyx_t_23, (PyObject*)__pyx_t_20))) __PYX_ERR(0, 6790, __pyx_L49_error)
                  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                }
              }
              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            } /* exit inner scope */
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval_ids);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval_ids, ((PyObject*)__pyx_t_23));
            __Pyx_GIVEREF(__pyx_t_23);
            __pyx_t_23 = 0;

            /* "ws_package/controllers/activity_controller.py":6791
 *                     # Fetch notes for all intervals in this day from Notes table
 *                     interval_ids = [interval.id for interval in day_intervals if hasattr(interval, 'id')]
 *                     interval_note_map = {}             # <<<<<<<<<<<<<<
 * 
 *                     # Query Notes table for entries that contain any of these interval IDs
*/
            __pyx_t_23 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6791, __pyx_L49_error)
            __Pyx_GOTREF(__pyx_t_23);
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval_note_map);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval_note_map, ((PyObject*)__pyx_t_23));
            __Pyx_GIVEREF(__pyx_t_23);
            __pyx_t_23 = 0;

            /* "ws_package/controllers/activity_controller.py":6795
 *                     # Query Notes table for entries that contain any of these interval IDs
 *                     # Notes.activity_interval_id is a JSON array, so we need to check if any interval_id is in the array
 *                     try:             # <<<<<<<<<<<<<<
 *                         with db_lock_manager.read_lock():
 *                             async with async_session() as session:
*/
            {
              __Pyx_ExceptionSave(&__pyx_t_13, &__pyx_t_16, &__pyx_t_19);
              __Pyx_XGOTREF(__pyx_t_13);
              __Pyx_XGOTREF(__pyx_t_16);
              __Pyx_XGOTREF(__pyx_t_19);
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":6796
 *                     # Notes.activity_interval_id is a JSON array, so we need to check if any interval_id is in the array
 *                     try:
 *                         with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                             async with async_session() as session:
 *                                 notes_query = select(Notes)
*/
                /*with:*/ {
                  __pyx_t_8 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_db_lock_manager); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6796, __pyx_L62_error)
                  __Pyx_GOTREF(__pyx_t_20);
                  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_read_lock); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6796, __pyx_L62_error)
                  __Pyx_GOTREF(__pyx_t_4);
                  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                  __pyx_t_10 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_4))) {
                    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
                    assert(__pyx_t_8);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                    __Pyx_INCREF(__pyx_t_8);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                    __pyx_t_10 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
                    __pyx_t_23 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6796, __pyx_L62_error)
                    __Pyx_GOTREF(__pyx_t_23);
                  }
                  __pyx_t_18 = __Pyx_PyObject_LookupSpecial(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_exit); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 6796, __pyx_L62_error)
                  __Pyx_GOTREF(__pyx_t_18);
                  __pyx_t_8 = NULL;
                  __pyx_t_20 = __Pyx_PyObject_LookupSpecial(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_enter); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6796, __pyx_L70_error)
                  __Pyx_GOTREF(__pyx_t_20);
                  __pyx_t_10 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (likely(PyMethod_Check(__pyx_t_20))) {
                    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_20);
                    assert(__pyx_t_8);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_20);
                    __Pyx_INCREF(__pyx_t_8);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_20, __pyx__function);
                    __pyx_t_10 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_8, NULL};
                    __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_20, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6796, __pyx_L70_error)
                    __Pyx_GOTREF(__pyx_t_4);
                  }
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                  __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                  /*try:*/ {
                    {
                      __Pyx_ExceptionSave(&__pyx_t_17, &__pyx_t_24, &__pyx_t_31);
                      __Pyx_XGOTREF(__pyx_t_17);
                      __Pyx_XGOTREF(__pyx_t_24);
                      __Pyx_XGOTREF(__pyx_t_31);
                      /*try:*/ {

                        /* "ws_package/controllers/activity_controller.py":6797
 *                     try:
 *                         with db_lock_manager.read_lock():
 *                             async with async_session() as session:             # <<<<<<<<<<<<<<
 *                                 notes_query = select(Notes)
 *                                 notes_result = await session.execute(notes_query)
*/
                        /*with:*/ {
                          __pyx_t_4 = NULL;
                          __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_async_session); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6797, __pyx_L76_error)
                          __Pyx_GOTREF(__pyx_t_20);
                          __pyx_t_10 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (unlikely(PyMethod_Check(__pyx_t_20))) {
                            __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_20);
                            assert(__pyx_t_4);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_20);
                            __Pyx_INCREF(__pyx_t_4);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_20, __pyx__function);
                            __pyx_t_10 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
                            __pyx_t_23 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_20, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                            __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                            if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6797, __pyx_L76_error)
                            __Pyx_GOTREF(__pyx_t_23);
                          }
                          __pyx_t_32 = __Pyx_PyObject_LookupSpecial(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_aexit); if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 6797, __pyx_L76_error)
                          __Pyx_GOTREF(__pyx_t_32);
                          __pyx_t_4 = NULL;
                          __pyx_t_8 = __Pyx_PyObject_LookupSpecial(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_aenter); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6797, __pyx_L84_error)
                          __Pyx_GOTREF(__pyx_t_8);
                          __pyx_t_10 = 1;
                          #if CYTHON_UNPACK_METHODS
                          if (likely(PyMethod_Check(__pyx_t_8))) {
                            __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8);
                            assert(__pyx_t_4);
                            PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
                            __Pyx_INCREF(__pyx_t_4);
                            __Pyx_INCREF(__pyx__function);
                            __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
                            __pyx_t_10 = 0;
                          }
                          #endif
                          {
                            PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
                            __pyx_t_20 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                            __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                            if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6797, __pyx_L84_error)
                            __Pyx_GOTREF(__pyx_t_20);
                          }
                          __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_20, &__pyx_r);
                          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                          if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                            __Pyx_GOTREF(__pyx_r);
                            __Pyx_XGIVEREF(__pyx_t_1);
                            __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                            __Pyx_XGIVEREF(__pyx_t_2);
                            __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                            __Pyx_XGIVEREF(__pyx_t_3);
                            __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                            __Pyx_XGIVEREF(__pyx_t_7);
                            __pyx_cur_scope->__pyx_t_3 = __pyx_t_7;
                            __Pyx_XGIVEREF(__pyx_t_12);
                            __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                            __Pyx_XGIVEREF(__pyx_t_13);
                            __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                            __Pyx_XGIVEREF(__pyx_t_14);
                            __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                            __Pyx_XGIVEREF(__pyx_t_15);
                            __pyx_cur_scope->__pyx_t_7 = __pyx_t_15;
                            __Pyx_XGIVEREF(__pyx_t_16);
                            __pyx_cur_scope->__pyx_t_8 = __pyx_t_16;
                            __Pyx_XGIVEREF(__pyx_t_17);
                            __pyx_cur_scope->__pyx_t_9 = __pyx_t_17;
                            __Pyx_XGIVEREF(__pyx_t_18);
                            __pyx_cur_scope->__pyx_t_10 = __pyx_t_18;
                            __Pyx_XGIVEREF(__pyx_t_19);
                            __pyx_cur_scope->__pyx_t_11 = __pyx_t_19;
                            __Pyx_XGIVEREF(__pyx_t_23);
                            __pyx_cur_scope->__pyx_t_12 = __pyx_t_23;
                            __Pyx_XGIVEREF(__pyx_t_24);
                            __pyx_cur_scope->__pyx_t_13 = __pyx_t_24;
                            __pyx_cur_scope->__pyx_t_15 = __pyx_t_25;
                            __pyx_cur_scope->__pyx_t_16 = __pyx_t_26;
                            __pyx_cur_scope->__pyx_t_17 = __pyx_t_27;
                            __Pyx_XGIVEREF(__pyx_t_31);
                            __pyx_cur_scope->__pyx_t_14 = __pyx_t_31;
                            __Pyx_XGIVEREF(__pyx_t_32);
                            __pyx_cur_scope->__pyx_t_18 = __pyx_t_32;
                            __Pyx_XGIVEREF(__pyx_r);
                            __Pyx_RefNannyFinishContext();
                            __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                            /* return from generator, awaiting value */
                            __pyx_generator->resume_label = 7;
                            return __pyx_r;
                            __pyx_L85_resume_from_await:;
                            __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                            __pyx_cur_scope->__pyx_t_0 = 0;
                            __Pyx_XGOTREF(__pyx_t_1);
                            __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                            __pyx_cur_scope->__pyx_t_1 = 0;
                            __Pyx_XGOTREF(__pyx_t_2);
                            __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                            __pyx_cur_scope->__pyx_t_2 = 0;
                            __Pyx_XGOTREF(__pyx_t_3);
                            __pyx_t_7 = __pyx_cur_scope->__pyx_t_3;
                            __pyx_cur_scope->__pyx_t_3 = 0;
                            __Pyx_XGOTREF(__pyx_t_7);
                            __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                            __pyx_cur_scope->__pyx_t_4 = 0;
                            __Pyx_XGOTREF(__pyx_t_12);
                            __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                            __pyx_cur_scope->__pyx_t_5 = 0;
                            __Pyx_XGOTREF(__pyx_t_13);
                            __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                            __pyx_cur_scope->__pyx_t_6 = 0;
                            __Pyx_XGOTREF(__pyx_t_14);
                            __pyx_t_15 = __pyx_cur_scope->__pyx_t_7;
                            __pyx_cur_scope->__pyx_t_7 = 0;
                            __Pyx_XGOTREF(__pyx_t_15);
                            __pyx_t_16 = __pyx_cur_scope->__pyx_t_8;
                            __pyx_cur_scope->__pyx_t_8 = 0;
                            __Pyx_XGOTREF(__pyx_t_16);
                            __pyx_t_17 = __pyx_cur_scope->__pyx_t_9;
                            __pyx_cur_scope->__pyx_t_9 = 0;
                            __Pyx_XGOTREF(__pyx_t_17);
                            __pyx_t_18 = __pyx_cur_scope->__pyx_t_10;
                            __pyx_cur_scope->__pyx_t_10 = 0;
                            __Pyx_XGOTREF(__pyx_t_18);
                            __pyx_t_19 = __pyx_cur_scope->__pyx_t_11;
                            __pyx_cur_scope->__pyx_t_11 = 0;
                            __Pyx_XGOTREF(__pyx_t_19);
                            __pyx_t_23 = __pyx_cur_scope->__pyx_t_12;
                            __pyx_cur_scope->__pyx_t_12 = 0;
                            __Pyx_XGOTREF(__pyx_t_23);
                            __pyx_t_24 = __pyx_cur_scope->__pyx_t_13;
                            __pyx_cur_scope->__pyx_t_13 = 0;
                            __Pyx_XGOTREF(__pyx_t_24);
                            __pyx_t_25 = __pyx_cur_scope->__pyx_t_15;
                            __pyx_t_26 = __pyx_cur_scope->__pyx_t_16;
                            __pyx_t_27 = __pyx_cur_scope->__pyx_t_17;
                            __pyx_t_31 = __pyx_cur_scope->__pyx_t_14;
                            __pyx_cur_scope->__pyx_t_14 = 0;
                            __Pyx_XGOTREF(__pyx_t_31);
                            __pyx_t_32 = __pyx_cur_scope->__pyx_t_18;
                            __pyx_cur_scope->__pyx_t_18 = 0;
                            __Pyx_XGOTREF(__pyx_t_32);
                            if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6797, __pyx_L84_error)
                            __pyx_t_20 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_20);
                          } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                            __Pyx_GOTREF(__pyx_r);
                            __pyx_t_20 = __pyx_r; __pyx_r = NULL;
                          } else {
                            __Pyx_XGOTREF(__pyx_r);
                            __PYX_ERR(0, 6797, __pyx_L84_error)
                          }
                          __pyx_t_8 = __pyx_t_20;
                          __pyx_t_20 = 0;
                          __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                          /*try:*/ {
                            {
                              __Pyx_ExceptionSave(&__pyx_t_33, &__pyx_t_34, &__pyx_t_35);
                              __Pyx_XGOTREF(__pyx_t_33);
                              __Pyx_XGOTREF(__pyx_t_34);
                              __Pyx_XGOTREF(__pyx_t_35);
                              /*try:*/ {
                                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_session);
                                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_session, __pyx_t_8);
                                __Pyx_GIVEREF(__pyx_t_8);
                                __pyx_t_8 = 0;

                                /* "ws_package/controllers/activity_controller.py":6798
 *                         with db_lock_manager.read_lock():
 *                             async with async_session() as session:
 *                                 notes_query = select(Notes)             # <<<<<<<<<<<<<<
 *                                 notes_result = await session.execute(notes_query)
 *                                 notes_entries = notes_result.scalars().all()
*/
                                __pyx_t_23 = NULL;
                                __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_select); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6798, __pyx_L91_error)
                                __Pyx_GOTREF(__pyx_t_20);
                                __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_Notes); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6798, __pyx_L91_error)
                                __Pyx_GOTREF(__pyx_t_4);
                                __pyx_t_10 = 1;
                                #if CYTHON_UNPACK_METHODS
                                if (unlikely(PyMethod_Check(__pyx_t_20))) {
                                  __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_20);
                                  assert(__pyx_t_23);
                                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_20);
                                  __Pyx_INCREF(__pyx_t_23);
                                  __Pyx_INCREF(__pyx__function);
                                  __Pyx_DECREF_SET(__pyx_t_20, __pyx__function);
                                  __pyx_t_10 = 0;
                                }
                                #endif
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_23, __pyx_t_4};
                                  __pyx_t_8 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_20, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                                  if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6798, __pyx_L91_error)
                                  __Pyx_GOTREF(__pyx_t_8);
                                }
                                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_notes_query);
                                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_notes_query, __pyx_t_8);
                                __Pyx_GIVEREF(__pyx_t_8);
                                __pyx_t_8 = 0;

                                /* "ws_package/controllers/activity_controller.py":6799
 *                             async with async_session() as session:
 *                                 notes_query = select(Notes)
 *                                 notes_result = await session.execute(notes_query)             # <<<<<<<<<<<<<<
 *                                 notes_entries = notes_result.scalars().all()
 * 
*/
                                __pyx_t_20 = __pyx_cur_scope->__pyx_v_session;
                                __Pyx_INCREF(__pyx_t_20);
                                __pyx_t_10 = 0;
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_20, __pyx_cur_scope->__pyx_v_notes_query};
                                  __pyx_t_8 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_execute, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                                  if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6799, __pyx_L91_error)
                                  __Pyx_GOTREF(__pyx_t_8);
                                }
                                __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_8, &__pyx_r);
                                __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                                if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __Pyx_XGIVEREF(__pyx_t_1);
                                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                  __Pyx_XGIVEREF(__pyx_t_2);
                                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                  __Pyx_XGIVEREF(__pyx_t_3);
                                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                  __Pyx_XGIVEREF(__pyx_t_7);
                                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_7;
                                  __Pyx_XGIVEREF(__pyx_t_12);
                                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                                  __Pyx_XGIVEREF(__pyx_t_13);
                                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                                  __Pyx_XGIVEREF(__pyx_t_14);
                                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                                  __Pyx_XGIVEREF(__pyx_t_15);
                                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_15;
                                  __Pyx_XGIVEREF(__pyx_t_16);
                                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_16;
                                  __Pyx_XGIVEREF(__pyx_t_17);
                                  __pyx_cur_scope->__pyx_t_9 = __pyx_t_17;
                                  __Pyx_XGIVEREF(__pyx_t_18);
                                  __pyx_cur_scope->__pyx_t_10 = __pyx_t_18;
                                  __Pyx_XGIVEREF(__pyx_t_19);
                                  __pyx_cur_scope->__pyx_t_11 = __pyx_t_19;
                                  __Pyx_XGIVEREF(__pyx_t_24);
                                  __pyx_cur_scope->__pyx_t_12 = __pyx_t_24;
                                  __pyx_cur_scope->__pyx_t_15 = __pyx_t_25;
                                  __pyx_cur_scope->__pyx_t_16 = __pyx_t_26;
                                  __pyx_cur_scope->__pyx_t_17 = __pyx_t_27;
                                  __Pyx_XGIVEREF(__pyx_t_31);
                                  __pyx_cur_scope->__pyx_t_13 = __pyx_t_31;
                                  __Pyx_XGIVEREF(__pyx_t_32);
                                  __pyx_cur_scope->__pyx_t_14 = __pyx_t_32;
                                  __Pyx_XGIVEREF(__pyx_t_33);
                                  __pyx_cur_scope->__pyx_t_18 = __pyx_t_33;
                                  __Pyx_XGIVEREF(__pyx_t_34);
                                  __pyx_cur_scope->__pyx_t_19 = __pyx_t_34;
                                  __Pyx_XGIVEREF(__pyx_t_35);
                                  __pyx_cur_scope->__pyx_t_20 = __pyx_t_35;
                                  __Pyx_XGIVEREF(__pyx_r);
                                  __Pyx_RefNannyFinishContext();
                                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                                  /* return from generator, awaiting value */
                                  __pyx_generator->resume_label = 8;
                                  return __pyx_r;
                                  __pyx_L99_resume_from_await:;
                                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                  __pyx_cur_scope->__pyx_t_0 = 0;
                                  __Pyx_XGOTREF(__pyx_t_1);
                                  __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                  __pyx_cur_scope->__pyx_t_1 = 0;
                                  __Pyx_XGOTREF(__pyx_t_2);
                                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                  __pyx_cur_scope->__pyx_t_2 = 0;
                                  __Pyx_XGOTREF(__pyx_t_3);
                                  __pyx_t_7 = __pyx_cur_scope->__pyx_t_3;
                                  __pyx_cur_scope->__pyx_t_3 = 0;
                                  __Pyx_XGOTREF(__pyx_t_7);
                                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                                  __pyx_cur_scope->__pyx_t_4 = 0;
                                  __Pyx_XGOTREF(__pyx_t_12);
                                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                                  __pyx_cur_scope->__pyx_t_5 = 0;
                                  __Pyx_XGOTREF(__pyx_t_13);
                                  __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                                  __pyx_cur_scope->__pyx_t_6 = 0;
                                  __Pyx_XGOTREF(__pyx_t_14);
                                  __pyx_t_15 = __pyx_cur_scope->__pyx_t_7;
                                  __pyx_cur_scope->__pyx_t_7 = 0;
                                  __Pyx_XGOTREF(__pyx_t_15);
                                  __pyx_t_16 = __pyx_cur_scope->__pyx_t_8;
                                  __pyx_cur_scope->__pyx_t_8 = 0;
                                  __Pyx_XGOTREF(__pyx_t_16);
                                  __pyx_t_17 = __pyx_cur_scope->__pyx_t_9;
                                  __pyx_cur_scope->__pyx_t_9 = 0;
                                  __Pyx_XGOTREF(__pyx_t_17);
                                  __pyx_t_18 = __pyx_cur_scope->__pyx_t_10;
                                  __pyx_cur_scope->__pyx_t_10 = 0;
                                  __Pyx_XGOTREF(__pyx_t_18);
                                  __pyx_t_19 = __pyx_cur_scope->__pyx_t_11;
                                  __pyx_cur_scope->__pyx_t_11 = 0;
                                  __Pyx_XGOTREF(__pyx_t_19);
                                  __pyx_t_24 = __pyx_cur_scope->__pyx_t_12;
                                  __pyx_cur_scope->__pyx_t_12 = 0;
                                  __Pyx_XGOTREF(__pyx_t_24);
                                  __pyx_t_25 = __pyx_cur_scope->__pyx_t_15;
                                  __pyx_t_26 = __pyx_cur_scope->__pyx_t_16;
                                  __pyx_t_27 = __pyx_cur_scope->__pyx_t_17;
                                  __pyx_t_31 = __pyx_cur_scope->__pyx_t_13;
                                  __pyx_cur_scope->__pyx_t_13 = 0;
                                  __Pyx_XGOTREF(__pyx_t_31);
                                  __pyx_t_32 = __pyx_cur_scope->__pyx_t_14;
                                  __pyx_cur_scope->__pyx_t_14 = 0;
                                  __Pyx_XGOTREF(__pyx_t_32);
                                  __pyx_t_33 = __pyx_cur_scope->__pyx_t_18;
                                  __pyx_cur_scope->__pyx_t_18 = 0;
                                  __Pyx_XGOTREF(__pyx_t_33);
                                  __pyx_t_34 = __pyx_cur_scope->__pyx_t_19;
                                  __pyx_cur_scope->__pyx_t_19 = 0;
                                  __Pyx_XGOTREF(__pyx_t_34);
                                  __pyx_t_35 = __pyx_cur_scope->__pyx_t_20;
                                  __pyx_cur_scope->__pyx_t_20 = 0;
                                  __Pyx_XGOTREF(__pyx_t_35);
                                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6799, __pyx_L91_error)
                                  __pyx_t_8 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_8);
                                } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __pyx_t_8 = __pyx_r; __pyx_r = NULL;
                                } else {
                                  __Pyx_XGOTREF(__pyx_r);
                                  __PYX_ERR(0, 6799, __pyx_L91_error)
                                }
                                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_notes_result);
                                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_notes_result, __pyx_t_8);
                                __Pyx_GIVEREF(__pyx_t_8);
                                __pyx_t_8 = 0;

                                /* "ws_package/controllers/activity_controller.py":6800
 *                                 notes_query = select(Notes)
 *                                 notes_result = await session.execute(notes_query)
 *                                 notes_entries = notes_result.scalars().all()             # <<<<<<<<<<<<<<
 * 
 *                                 # Create a mapping of interval_id -> note
*/
                                __pyx_t_23 = __pyx_cur_scope->__pyx_v_notes_result;
                                __Pyx_INCREF(__pyx_t_23);
                                __pyx_t_10 = 0;
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_23, NULL};
                                  __pyx_t_4 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_scalars, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                                  if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6800, __pyx_L91_error)
                                  __Pyx_GOTREF(__pyx_t_4);
                                }
                                __pyx_t_20 = __pyx_t_4;
                                __Pyx_INCREF(__pyx_t_20);
                                __pyx_t_10 = 0;
                                {
                                  PyObject *__pyx_callargs[2] = {__pyx_t_20, NULL};
                                  __pyx_t_8 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_all, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                  __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                  if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6800, __pyx_L91_error)
                                  __Pyx_GOTREF(__pyx_t_8);
                                }
                                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_notes_entries);
                                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_notes_entries, __pyx_t_8);
                                __Pyx_GIVEREF(__pyx_t_8);
                                __pyx_t_8 = 0;

                                /* "ws_package/controllers/activity_controller.py":6803
 * 
 *                                 # Create a mapping of interval_id -> note
 *                                 for notes_entry in notes_entries:             # <<<<<<<<<<<<<<
 *                                     if notes_entry.activity_interval_id:  # Check if array is not None
 *                                         for interval_id in notes_entry.activity_interval_id:
*/
                                if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_notes_entries)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_notes_entries)) {
                                  __pyx_t_8 = __pyx_cur_scope->__pyx_v_notes_entries; __Pyx_INCREF(__pyx_t_8);
                                  __pyx_t_29 = 0;
                                  __pyx_t_30 = NULL;
                                } else {
                                  __pyx_t_29 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_notes_entries); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6803, __pyx_L91_error)
                                  __Pyx_GOTREF(__pyx_t_8);
                                  __pyx_t_30 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_8); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 6803, __pyx_L91_error)
                                }
                                for (;;) {
                                  if (likely(!__pyx_t_30)) {
                                    if (likely(PyList_CheckExact(__pyx_t_8))) {
                                      {
                                        Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_8);
                                        #if !CYTHON_ASSUME_SAFE_SIZE
                                        if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6803, __pyx_L91_error)
                                        #endif
                                        if (__pyx_t_29 >= __pyx_temp) break;
                                      }
                                      __pyx_t_4 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_8, __pyx_t_29, __Pyx_ReferenceSharing_OwnStrongReference);
                                      ++__pyx_t_29;
                                    } else {
                                      {
                                        Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_8);
                                        #if !CYTHON_ASSUME_SAFE_SIZE
                                        if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6803, __pyx_L91_error)
                                        #endif
                                        if (__pyx_t_29 >= __pyx_temp) break;
                                      }
                                      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                                      __pyx_t_4 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_29));
                                      #else
                                      __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_8, __pyx_t_29);
                                      #endif
                                      ++__pyx_t_29;
                                    }
                                    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6803, __pyx_L91_error)
                                  } else {
                                    __pyx_t_4 = __pyx_t_30(__pyx_t_8);
                                    if (unlikely(!__pyx_t_4)) {
                                      PyObject* exc_type = PyErr_Occurred();
                                      if (exc_type) {
                                        if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 6803, __pyx_L91_error)
                                        PyErr_Clear();
                                      }
                                      break;
                                    }
                                  }
                                  __Pyx_GOTREF(__pyx_t_4);
                                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_notes_entry);
                                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_notes_entry, __pyx_t_4);
                                  __Pyx_GIVEREF(__pyx_t_4);
                                  __pyx_t_4 = 0;

                                  /* "ws_package/controllers/activity_controller.py":6804
 *                                 # Create a mapping of interval_id -> note
 *                                 for notes_entry in notes_entries:
 *                                     if notes_entry.activity_interval_id:  # Check if array is not None             # <<<<<<<<<<<<<<
 *                                         for interval_id in notes_entry.activity_interval_id:
 *                                             if interval_id in interval_ids:
*/
                                  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_notes_entry, __pyx_mstate_global->__pyx_n_u_activity_interval_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6804, __pyx_L91_error)
                                  __Pyx_GOTREF(__pyx_t_4);
                                  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 6804, __pyx_L91_error)
                                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                  if (__pyx_t_6) {

                                    /* "ws_package/controllers/activity_controller.py":6805
 *                                 for notes_entry in notes_entries:
 *                                     if notes_entry.activity_interval_id:  # Check if array is not None
 *                                         for interval_id in notes_entry.activity_interval_id:             # <<<<<<<<<<<<<<
 *                                             if interval_id in interval_ids:
 *                                                 interval_note_map[interval_id] = notes_entry.note
*/
                                    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_notes_entry, __pyx_mstate_global->__pyx_n_u_activity_interval_id); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6805, __pyx_L91_error)
                                    __Pyx_GOTREF(__pyx_t_4);
                                    if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) {
                                      __pyx_t_20 = __pyx_t_4; __Pyx_INCREF(__pyx_t_20);
                                      __pyx_t_36 = 0;
                                      __pyx_t_37 = NULL;
                                    } else {
                                      __pyx_t_36 = -1; __pyx_t_20 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6805, __pyx_L91_error)
                                      __Pyx_GOTREF(__pyx_t_20);
                                      __pyx_t_37 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_20); if (unlikely(!__pyx_t_37)) __PYX_ERR(0, 6805, __pyx_L91_error)
                                    }
                                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                    for (;;) {
                                      if (likely(!__pyx_t_37)) {
                                        if (likely(PyList_CheckExact(__pyx_t_20))) {
                                          {
                                            Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_20);
                                            #if !CYTHON_ASSUME_SAFE_SIZE
                                            if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6805, __pyx_L91_error)
                                            #endif
                                            if (__pyx_t_36 >= __pyx_temp) break;
                                          }
                                          __pyx_t_4 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_20, __pyx_t_36, __Pyx_ReferenceSharing_OwnStrongReference);
                                          ++__pyx_t_36;
                                        } else {
                                          {
                                            Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_20);
                                            #if !CYTHON_ASSUME_SAFE_SIZE
                                            if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6805, __pyx_L91_error)
                                            #endif
                                            if (__pyx_t_36 >= __pyx_temp) break;
                                          }
                                          #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                                          __pyx_t_4 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_20, __pyx_t_36));
                                          #else
                                          __pyx_t_4 = __Pyx_PySequence_ITEM(__pyx_t_20, __pyx_t_36);
                                          #endif
                                          ++__pyx_t_36;
                                        }
                                        if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6805, __pyx_L91_error)
                                      } else {
                                        __pyx_t_4 = __pyx_t_37(__pyx_t_20);
                                        if (unlikely(!__pyx_t_4)) {
                                          PyObject* exc_type = PyErr_Occurred();
                                          if (exc_type) {
                                            if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 6805, __pyx_L91_error)
                                            PyErr_Clear();
                                          }
                                          break;
                                        }
                                      }
                                      __Pyx_GOTREF(__pyx_t_4);
                                      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval_id);
                                      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval_id, __pyx_t_4);
                                      __Pyx_GIVEREF(__pyx_t_4);
                                      __pyx_t_4 = 0;

                                      /* "ws_package/controllers/activity_controller.py":6806
 *                                     if notes_entry.activity_interval_id:  # Check if array is not None
 *                                         for interval_id in notes_entry.activity_interval_id:
 *                                             if interval_id in interval_ids:             # <<<<<<<<<<<<<<
 *                                                 interval_note_map[interval_id] = notes_entry.note
 * 
*/
                                      __pyx_t_6 = (__Pyx_PySequence_ContainsTF(__pyx_cur_scope->__pyx_v_interval_id, __pyx_cur_scope->__pyx_v_interval_ids, Py_EQ)); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 6806, __pyx_L91_error)
                                      if (__pyx_t_6) {

                                        /* "ws_package/controllers/activity_controller.py":6807
 *                                         for interval_id in notes_entry.activity_interval_id:
 *                                             if interval_id in interval_ids:
 *                                                 interval_note_map[interval_id] = notes_entry.note             # <<<<<<<<<<<<<<
 * 
 *                                 if interval_note_map:
*/
                                        __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_notes_entry, __pyx_mstate_global->__pyx_n_u_note); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6807, __pyx_L91_error)
                                        __Pyx_GOTREF(__pyx_t_4);
                                        if (unlikely((PyDict_SetItem(__pyx_cur_scope->__pyx_v_interval_note_map, __pyx_cur_scope->__pyx_v_interval_id, __pyx_t_4) < 0))) __PYX_ERR(0, 6807, __pyx_L91_error)
                                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

                                        /* "ws_package/controllers/activity_controller.py":6806
 *                                     if notes_entry.activity_interval_id:  # Check if array is not None
 *                                         for interval_id in notes_entry.activity_interval_id:
 *                                             if interval_id in interval_ids:             # <<<<<<<<<<<<<<
 *                                                 interval_note_map[interval_id] = notes_entry.note
 * 
*/
                                      }

                                      /* "ws_package/controllers/activity_controller.py":6805
 *                                 for notes_entry in notes_entries:
 *                                     if notes_entry.activity_interval_id:  # Check if array is not None
 *                                         for interval_id in notes_entry.activity_interval_id:             # <<<<<<<<<<<<<<
 *                                             if interval_id in interval_ids:
 *                                                 interval_note_map[interval_id] = notes_entry.note
*/
                                    }
                                    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;

                                    /* "ws_package/controllers/activity_controller.py":6804
 *                                 # Create a mapping of interval_id -> note
 *                                 for notes_entry in notes_entries:
 *                                     if notes_entry.activity_interval_id:  # Check if array is not None             # <<<<<<<<<<<<<<
 *                                         for interval_id in notes_entry.activity_interval_id:
 *                                             if interval_id in interval_ids:
*/
                                  }

                                  /* "ws_package/controllers/activity_controller.py":6803
 * 
 *                                 # Create a mapping of interval_id -> note
 *                                 for notes_entry in notes_entries:             # <<<<<<<<<<<<<<
 *                                     if notes_entry.activity_interval_id:  # Check if array is not None
 *                                         for interval_id in notes_entry.activity_interval_id:
*/
                                }
                                __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

                                /* "ws_package/controllers/activity_controller.py":6809
 *                                                 interval_note_map[interval_id] = notes_entry.note
 * 
 *                                 if interval_note_map:             # <<<<<<<<<<<<<<
 *                                     logger.info("Found notes for %s intervals: %s", len(interval_note_map), list(interval_note_map.keys()))
 *                     except Exception as e:
*/
                                __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_interval_note_map); if (unlikely((__pyx_t_6 < 0))) __PYX_ERR(0, 6809, __pyx_L91_error)
                                if (__pyx_t_6) {

                                  /* "ws_package/controllers/activity_controller.py":6810
 * 
 *                                 if interval_note_map:
 *                                     logger.info("Found notes for %s intervals: %s", len(interval_note_map), list(interval_note_map.keys()))             # <<<<<<<<<<<<<<
 *                     except Exception as e:
 *                         logger.error("Error fetching notes from Notes table: %s", e, exc_info=True)
*/
                                  __pyx_t_20 = NULL;
                                  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6810, __pyx_L91_error)
                                  __Pyx_GOTREF(__pyx_t_4);
                                  __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6810, __pyx_L91_error)
                                  __Pyx_GOTREF(__pyx_t_23);
                                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                  __pyx_t_29 = PyDict_Size(__pyx_cur_scope->__pyx_v_interval_note_map); if (unlikely(__pyx_t_29 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6810, __pyx_L91_error)
                                  __pyx_t_4 = PyLong_FromSsize_t(__pyx_t_29); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6810, __pyx_L91_error)
                                  __Pyx_GOTREF(__pyx_t_4);
                                  __pyx_t_22 = __Pyx_PyDict_Keys(__pyx_cur_scope->__pyx_v_interval_note_map); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6810, __pyx_L91_error)
                                  __Pyx_GOTREF(__pyx_t_22);
                                  __pyx_t_9 = __Pyx_PySequence_ListKeepNew(__pyx_t_22); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6810, __pyx_L91_error)
                                  __Pyx_GOTREF(__pyx_t_9);
                                  __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                                  __pyx_t_10 = 1;
                                  #if CYTHON_UNPACK_METHODS
                                  if (unlikely(PyMethod_Check(__pyx_t_23))) {
                                    __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_23);
                                    assert(__pyx_t_20);
                                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_23);
                                    __Pyx_INCREF(__pyx_t_20);
                                    __Pyx_INCREF(__pyx__function);
                                    __Pyx_DECREF_SET(__pyx_t_23, __pyx__function);
                                    __pyx_t_10 = 0;
                                  }
                                  #endif
                                  {
                                    PyObject *__pyx_callargs[4] = {__pyx_t_20, __pyx_mstate_global->__pyx_kp_u_Found_notes_for_s_intervals_s, __pyx_t_4, __pyx_t_9};
                                    __pyx_t_8 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_23, __pyx_callargs+__pyx_t_10, (4-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                                    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                                    __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                                    if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6810, __pyx_L91_error)
                                    __Pyx_GOTREF(__pyx_t_8);
                                  }
                                  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

                                  /* "ws_package/controllers/activity_controller.py":6809
 *                                                 interval_note_map[interval_id] = notes_entry.note
 * 
 *                                 if interval_note_map:             # <<<<<<<<<<<<<<
 *                                     logger.info("Found notes for %s intervals: %s", len(interval_note_map), list(interval_note_map.keys()))
 *                     except Exception as e:
*/
                                }

                                /* "ws_package/controllers/activity_controller.py":6797
 *                     try:
 *                         with db_lock_manager.read_lock():
 *                             async with async_session() as session:             # <<<<<<<<<<<<<<
 *                                 notes_query = select(Notes)
 *                                 notes_result = await session.execute(notes_query)
*/
                              }
                              __Pyx_XDECREF(__pyx_t_33); __pyx_t_33 = 0;
                              __Pyx_XDECREF(__pyx_t_34); __pyx_t_34 = 0;
                              __Pyx_XDECREF(__pyx_t_35); __pyx_t_35 = 0;
                              goto __pyx_L98_try_end;
                              __pyx_L91_error:;
                              __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                              __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                              __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                              __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                              __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                              /*except:*/ {
                                __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._idle_reassign", __pyx_clineno, __pyx_lineno, __pyx_filename);
                                if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_23, &__pyx_t_9) < 0) __PYX_ERR(0, 6797, __pyx_L93_except_error)
                                __Pyx_XGOTREF(__pyx_t_8);
                                __Pyx_XGOTREF(__pyx_t_23);
                                __Pyx_XGOTREF(__pyx_t_9);
                                __pyx_t_4 = PyTuple_Pack(3, __pyx_t_8, __pyx_t_23, __pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6797, __pyx_L93_except_error)
                                __Pyx_GOTREF(__pyx_t_4);
                                __pyx_t_38 = __Pyx_PyObject_Call(__pyx_t_32, __pyx_t_4, NULL);
                                __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0;
                                __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                                if (unlikely(!__pyx_t_38)) __PYX_ERR(0, 6797, __pyx_L93_except_error)
                                __Pyx_GOTREF(__pyx_t_38);
                                __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_38, &__pyx_r);
                                __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0;
                                if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __Pyx_XGIVEREF(__pyx_t_1);
                                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                  __Pyx_XGIVEREF(__pyx_t_2);
                                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                  __Pyx_XGIVEREF(__pyx_t_3);
                                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                  __Pyx_XGIVEREF(__pyx_t_7);
                                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_7;
                                  __Pyx_XGIVEREF(__pyx_t_8);
                                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_8;
                                  __Pyx_XGIVEREF(__pyx_t_9);
                                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_9;
                                  __Pyx_XGIVEREF(__pyx_t_12);
                                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_12;
                                  __Pyx_XGIVEREF(__pyx_t_13);
                                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_13;
                                  __Pyx_XGIVEREF(__pyx_t_14);
                                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_14;
                                  __Pyx_XGIVEREF(__pyx_t_15);
                                  __pyx_cur_scope->__pyx_t_9 = __pyx_t_15;
                                  __Pyx_XGIVEREF(__pyx_t_16);
                                  __pyx_cur_scope->__pyx_t_10 = __pyx_t_16;
                                  __Pyx_XGIVEREF(__pyx_t_17);
                                  __pyx_cur_scope->__pyx_t_11 = __pyx_t_17;
                                  __Pyx_XGIVEREF(__pyx_t_18);
                                  __pyx_cur_scope->__pyx_t_12 = __pyx_t_18;
                                  __Pyx_XGIVEREF(__pyx_t_19);
                                  __pyx_cur_scope->__pyx_t_13 = __pyx_t_19;
                                  __Pyx_XGIVEREF(__pyx_t_23);
                                  __pyx_cur_scope->__pyx_t_14 = __pyx_t_23;
                                  __Pyx_XGIVEREF(__pyx_t_24);
                                  __pyx_cur_scope->__pyx_t_18 = __pyx_t_24;
                                  __pyx_cur_scope->__pyx_t_15 = __pyx_t_25;
                                  __pyx_cur_scope->__pyx_t_16 = __pyx_t_26;
                                  __pyx_cur_scope->__pyx_t_17 = __pyx_t_27;
                                  __Pyx_XGIVEREF(__pyx_t_31);
                                  __pyx_cur_scope->__pyx_t_19 = __pyx_t_31;
                                  __Pyx_XGIVEREF(__pyx_t_32);
                                  __pyx_cur_scope->__pyx_t_20 = __pyx_t_32;
                                  __Pyx_XGIVEREF(__pyx_t_33);
                                  __pyx_cur_scope->__pyx_t_21 = __pyx_t_33;
                                  __Pyx_XGIVEREF(__pyx_t_34);
                                  __pyx_cur_scope->__pyx_t_22 = __pyx_t_34;
                                  __Pyx_XGIVEREF(__pyx_t_35);
                                  __pyx_cur_scope->__pyx_t_23 = __pyx_t_35;
                                  __Pyx_XGIVEREF(__pyx_t_38);
                                  __pyx_cur_scope->__pyx_t_24 = __pyx_t_38;
                                  __Pyx_XGIVEREF(__pyx_r);
                                  __Pyx_RefNannyFinishContext();
                                  __Pyx_Coroutine_SwapException(__pyx_generator);
                                  /* return from generator, awaiting value */
                                  __pyx_generator->resume_label = 9;
                                  return __pyx_r;
                                  __pyx_L112_resume_from_await:;
                                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                  __pyx_cur_scope->__pyx_t_0 = 0;
                                  __Pyx_XGOTREF(__pyx_t_1);
                                  __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                  __pyx_cur_scope->__pyx_t_1 = 0;
                                  __Pyx_XGOTREF(__pyx_t_2);
                                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                  __pyx_cur_scope->__pyx_t_2 = 0;
                                  __Pyx_XGOTREF(__pyx_t_3);
                                  __pyx_t_7 = __pyx_cur_scope->__pyx_t_3;
                                  __pyx_cur_scope->__pyx_t_3 = 0;
                                  __Pyx_XGOTREF(__pyx_t_7);
                                  __pyx_t_8 = __pyx_cur_scope->__pyx_t_4;
                                  __pyx_cur_scope->__pyx_t_4 = 0;
                                  __Pyx_XGOTREF(__pyx_t_8);
                                  __pyx_t_9 = __pyx_cur_scope->__pyx_t_5;
                                  __pyx_cur_scope->__pyx_t_5 = 0;
                                  __Pyx_XGOTREF(__pyx_t_9);
                                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_6;
                                  __pyx_cur_scope->__pyx_t_6 = 0;
                                  __Pyx_XGOTREF(__pyx_t_12);
                                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_7;
                                  __pyx_cur_scope->__pyx_t_7 = 0;
                                  __Pyx_XGOTREF(__pyx_t_13);
                                  __pyx_t_14 = __pyx_cur_scope->__pyx_t_8;
                                  __pyx_cur_scope->__pyx_t_8 = 0;
                                  __Pyx_XGOTREF(__pyx_t_14);
                                  __pyx_t_15 = __pyx_cur_scope->__pyx_t_9;
                                  __pyx_cur_scope->__pyx_t_9 = 0;
                                  __Pyx_XGOTREF(__pyx_t_15);
                                  __pyx_t_16 = __pyx_cur_scope->__pyx_t_10;
                                  __pyx_cur_scope->__pyx_t_10 = 0;
                                  __Pyx_XGOTREF(__pyx_t_16);
                                  __pyx_t_17 = __pyx_cur_scope->__pyx_t_11;
                                  __pyx_cur_scope->__pyx_t_11 = 0;
                                  __Pyx_XGOTREF(__pyx_t_17);
                                  __pyx_t_18 = __pyx_cur_scope->__pyx_t_12;
                                  __pyx_cur_scope->__pyx_t_12 = 0;
                                  __Pyx_XGOTREF(__pyx_t_18);
                                  __pyx_t_19 = __pyx_cur_scope->__pyx_t_13;
                                  __pyx_cur_scope->__pyx_t_13 = 0;
                                  __Pyx_XGOTREF(__pyx_t_19);
                                  __pyx_t_23 = __pyx_cur_scope->__pyx_t_14;
                                  __pyx_cur_scope->__pyx_t_14 = 0;
                                  __Pyx_XGOTREF(__pyx_t_23);
                                  __pyx_t_24 = __pyx_cur_scope->__pyx_t_18;
                                  __pyx_cur_scope->__pyx_t_18 = 0;
                                  __Pyx_XGOTREF(__pyx_t_24);
                                  __pyx_t_25 = __pyx_cur_scope->__pyx_t_15;
                                  __pyx_t_26 = __pyx_cur_scope->__pyx_t_16;
                                  __pyx_t_27 = __pyx_cur_scope->__pyx_t_17;
                                  __pyx_t_31 = __pyx_cur_scope->__pyx_t_19;
                                  __pyx_cur_scope->__pyx_t_19 = 0;
                                  __Pyx_XGOTREF(__pyx_t_31);
                                  __pyx_t_32 = __pyx_cur_scope->__pyx_t_20;
                                  __pyx_cur_scope->__pyx_t_20 = 0;
                                  __Pyx_XGOTREF(__pyx_t_32);
                                  __pyx_t_33 = __pyx_cur_scope->__pyx_t_21;
                                  __pyx_cur_scope->__pyx_t_21 = 0;
                                  __Pyx_XGOTREF(__pyx_t_33);
                                  __pyx_t_34 = __pyx_cur_scope->__pyx_t_22;
                                  __pyx_cur_scope->__pyx_t_22 = 0;
                                  __Pyx_XGOTREF(__pyx_t_34);
                                  __pyx_t_35 = __pyx_cur_scope->__pyx_t_23;
                                  __pyx_cur_scope->__pyx_t_23 = 0;
                                  __Pyx_XGOTREF(__pyx_t_35);
                                  __pyx_t_38 = __pyx_cur_scope->__pyx_t_24;
                                  __pyx_cur_scope->__pyx_t_24 = 0;
                                  __Pyx_XGOTREF(__pyx_t_38);
                                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6797, __pyx_L93_except_error)
                                  __pyx_t_4 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_4);
                                } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __pyx_t_4 = __pyx_r; __pyx_r = NULL;
                                } else {
                                  __Pyx_XGOTREF(__pyx_r);
                                  __PYX_ERR(0, 6797, __pyx_L93_except_error)
                                }
                                __pyx_t_38 = __pyx_t_4;
                                __pyx_t_4 = 0;
                                __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_38);
                                __Pyx_DECREF(__pyx_t_38); __pyx_t_38 = 0;
                                if (__pyx_t_6 < (0)) __PYX_ERR(0, 6797, __pyx_L93_except_error)
                                __pyx_t_5 = (!__pyx_t_6);
                                if (unlikely(__pyx_t_5)) {
                                  __Pyx_GIVEREF(__pyx_t_8);
                                  __Pyx_GIVEREF(__pyx_t_23);
                                  __Pyx_XGIVEREF(__pyx_t_9);
                                  __Pyx_ErrRestoreWithState(__pyx_t_8, __pyx_t_23, __pyx_t_9);
                                  __pyx_t_8 = 0;  __pyx_t_23 = 0;  __pyx_t_9 = 0; 
                                  __PYX_ERR(0, 6797, __pyx_L93_except_error)
                                }
                                __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                                __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                                __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                                goto __pyx_L92_exception_handled;
                              }
                              __pyx_L93_except_error:;
                              __Pyx_XGIVEREF(__pyx_t_33);
                              __Pyx_XGIVEREF(__pyx_t_34);
                              __Pyx_XGIVEREF(__pyx_t_35);
                              __Pyx_ExceptionReset(__pyx_t_33, __pyx_t_34, __pyx_t_35);
                              goto __pyx_L76_error;
                              __pyx_L92_exception_handled:;
                              __Pyx_XGIVEREF(__pyx_t_33);
                              __Pyx_XGIVEREF(__pyx_t_34);
                              __Pyx_XGIVEREF(__pyx_t_35);
                              __Pyx_ExceptionReset(__pyx_t_33, __pyx_t_34, __pyx_t_35);
                              __pyx_L98_try_end:;
                            }
                          }
                          /*finally:*/ {
                            /*normal exit:*/{
                              if (__pyx_t_32) {
                                __pyx_t_35 = __Pyx_PyObject_Call(__pyx_t_32, __pyx_mstate_global->__pyx_tuple[7], NULL);
                                __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0;
                                if (unlikely(!__pyx_t_35)) __PYX_ERR(0, 6797, __pyx_L76_error)
                                __Pyx_GOTREF(__pyx_t_35);
                                __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_35, &__pyx_r);
                                __Pyx_DECREF(__pyx_t_35); __pyx_t_35 = 0;
                                if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __Pyx_XGIVEREF(__pyx_t_1);
                                  __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                                  __Pyx_XGIVEREF(__pyx_t_2);
                                  __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                                  __Pyx_XGIVEREF(__pyx_t_3);
                                  __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                                  __Pyx_XGIVEREF(__pyx_t_7);
                                  __pyx_cur_scope->__pyx_t_3 = __pyx_t_7;
                                  __Pyx_XGIVEREF(__pyx_t_12);
                                  __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                                  __Pyx_XGIVEREF(__pyx_t_13);
                                  __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                                  __Pyx_XGIVEREF(__pyx_t_14);
                                  __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                                  __Pyx_XGIVEREF(__pyx_t_15);
                                  __pyx_cur_scope->__pyx_t_7 = __pyx_t_15;
                                  __Pyx_XGIVEREF(__pyx_t_16);
                                  __pyx_cur_scope->__pyx_t_8 = __pyx_t_16;
                                  __Pyx_XGIVEREF(__pyx_t_17);
                                  __pyx_cur_scope->__pyx_t_9 = __pyx_t_17;
                                  __Pyx_XGIVEREF(__pyx_t_18);
                                  __pyx_cur_scope->__pyx_t_10 = __pyx_t_18;
                                  __Pyx_XGIVEREF(__pyx_t_19);
                                  __pyx_cur_scope->__pyx_t_11 = __pyx_t_19;
                                  __Pyx_XGIVEREF(__pyx_t_24);
                                  __pyx_cur_scope->__pyx_t_12 = __pyx_t_24;
                                  __pyx_cur_scope->__pyx_t_15 = __pyx_t_25;
                                  __pyx_cur_scope->__pyx_t_16 = __pyx_t_26;
                                  __pyx_cur_scope->__pyx_t_17 = __pyx_t_27;
                                  __Pyx_XGIVEREF(__pyx_t_31);
                                  __pyx_cur_scope->__pyx_t_13 = __pyx_t_31;
                                  __Pyx_XGIVEREF(__pyx_t_32);
                                  __pyx_cur_scope->__pyx_t_14 = __pyx_t_32;
                                  __Pyx_XGIVEREF(__pyx_t_35);
                                  __pyx_cur_scope->__pyx_t_18 = __pyx_t_35;
                                  __Pyx_XGIVEREF(__pyx_r);
                                  __Pyx_RefNannyFinishContext();
                                  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                                  /* return from generator, awaiting value */
                                  __pyx_generator->resume_label = 10;
                                  return __pyx_r;
                                  __pyx_L113_resume_from_await:;
                                  __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                                  __pyx_cur_scope->__pyx_t_0 = 0;
                                  __Pyx_XGOTREF(__pyx_t_1);
                                  __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                                  __pyx_cur_scope->__pyx_t_1 = 0;
                                  __Pyx_XGOTREF(__pyx_t_2);
                                  __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                                  __pyx_cur_scope->__pyx_t_2 = 0;
                                  __Pyx_XGOTREF(__pyx_t_3);
                                  __pyx_t_7 = __pyx_cur_scope->__pyx_t_3;
                                  __pyx_cur_scope->__pyx_t_3 = 0;
                                  __Pyx_XGOTREF(__pyx_t_7);
                                  __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                                  __pyx_cur_scope->__pyx_t_4 = 0;
                                  __Pyx_XGOTREF(__pyx_t_12);
                                  __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                                  __pyx_cur_scope->__pyx_t_5 = 0;
                                  __Pyx_XGOTREF(__pyx_t_13);
                                  __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                                  __pyx_cur_scope->__pyx_t_6 = 0;
                                  __Pyx_XGOTREF(__pyx_t_14);
                                  __pyx_t_15 = __pyx_cur_scope->__pyx_t_7;
                                  __pyx_cur_scope->__pyx_t_7 = 0;
                                  __Pyx_XGOTREF(__pyx_t_15);
                                  __pyx_t_16 = __pyx_cur_scope->__pyx_t_8;
                                  __pyx_cur_scope->__pyx_t_8 = 0;
                                  __Pyx_XGOTREF(__pyx_t_16);
                                  __pyx_t_17 = __pyx_cur_scope->__pyx_t_9;
                                  __pyx_cur_scope->__pyx_t_9 = 0;
                                  __Pyx_XGOTREF(__pyx_t_17);
                                  __pyx_t_18 = __pyx_cur_scope->__pyx_t_10;
                                  __pyx_cur_scope->__pyx_t_10 = 0;
                                  __Pyx_XGOTREF(__pyx_t_18);
                                  __pyx_t_19 = __pyx_cur_scope->__pyx_t_11;
                                  __pyx_cur_scope->__pyx_t_11 = 0;
                                  __Pyx_XGOTREF(__pyx_t_19);
                                  __pyx_t_24 = __pyx_cur_scope->__pyx_t_12;
                                  __pyx_cur_scope->__pyx_t_12 = 0;
                                  __Pyx_XGOTREF(__pyx_t_24);
                                  __pyx_t_25 = __pyx_cur_scope->__pyx_t_15;
                                  __pyx_t_26 = __pyx_cur_scope->__pyx_t_16;
                                  __pyx_t_27 = __pyx_cur_scope->__pyx_t_17;
                                  __pyx_t_31 = __pyx_cur_scope->__pyx_t_13;
                                  __pyx_cur_scope->__pyx_t_13 = 0;
                                  __Pyx_XGOTREF(__pyx_t_31);
                                  __pyx_t_32 = __pyx_cur_scope->__pyx_t_14;
                                  __pyx_cur_scope->__pyx_t_14 = 0;
                                  __Pyx_XGOTREF(__pyx_t_32);
                                  __pyx_t_35 = __pyx_cur_scope->__pyx_t_18;
                                  __pyx_cur_scope->__pyx_t_18 = 0;
                                  __Pyx_XGOTREF(__pyx_t_35);
                                  if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6797, __pyx_L76_error)
                                  __pyx_t_9 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_9);
                                } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                                  __Pyx_GOTREF(__pyx_r);
                                  __pyx_t_9 = __pyx_r; __pyx_r = NULL;
                                } else {
                                  __Pyx_XGOTREF(__pyx_r);
                                  __PYX_ERR(0, 6797, __pyx_L76_error)
                                }
                                __pyx_t_35 = __pyx_t_9;
                                __pyx_t_9 = 0;
                                __Pyx_DECREF(__pyx_t_35); __pyx_t_35 = 0;
                              }
                              goto __pyx_L90;
                            }
                            __pyx_L90:;
                          }
                          goto __pyx_L114;
                          __pyx_L84_error:;
                          __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0;
                          goto __pyx_L76_error;
                          __pyx_L114:;
                        }

                        /* "ws_package/controllers/activity_controller.py":6796
 *                     # Notes.activity_interval_id is a JSON array, so we need to check if any interval_id is in the array
 *                     try:
 *                         with db_lock_manager.read_lock():             # <<<<<<<<<<<<<<
 *                             async with async_session() as session:
 *                                 notes_query = select(Notes)
*/
                      }
                      __Pyx_XDECREF(__pyx_t_17); __pyx_t_17 = 0;
                      __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                      __Pyx_XDECREF(__pyx_t_31); __pyx_t_31 = 0;
                      goto __pyx_L83_try_end;
                      __pyx_L76_error:;
                      __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                      __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                      __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                      __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                      /*except:*/ {
                        __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._idle_reassign", __pyx_clineno, __pyx_lineno, __pyx_filename);
                        if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_23, &__pyx_t_8) < 0) __PYX_ERR(0, 6796, __pyx_L78_except_error)
                        __Pyx_XGOTREF(__pyx_t_9);
                        __Pyx_XGOTREF(__pyx_t_23);
                        __Pyx_XGOTREF(__pyx_t_8);
                        __pyx_t_4 = PyTuple_Pack(3, __pyx_t_9, __pyx_t_23, __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6796, __pyx_L78_except_error)
                        __Pyx_GOTREF(__pyx_t_4);
                        __pyx_t_32 = __Pyx_PyObject_Call(__pyx_t_18, __pyx_t_4, NULL);
                        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                        if (unlikely(!__pyx_t_32)) __PYX_ERR(0, 6796, __pyx_L78_except_error)
                        __Pyx_GOTREF(__pyx_t_32);
                        __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_32);
                        __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0;
                        if (__pyx_t_5 < (0)) __PYX_ERR(0, 6796, __pyx_L78_except_error)
                        __pyx_t_6 = (!__pyx_t_5);
                        if (unlikely(__pyx_t_6)) {
                          __Pyx_GIVEREF(__pyx_t_9);
                          __Pyx_GIVEREF(__pyx_t_23);
                          __Pyx_XGIVEREF(__pyx_t_8);
                          __Pyx_ErrRestoreWithState(__pyx_t_9, __pyx_t_23, __pyx_t_8);
                          __pyx_t_9 = 0;  __pyx_t_23 = 0;  __pyx_t_8 = 0; 
                          __PYX_ERR(0, 6796, __pyx_L78_except_error)
                        }
                        __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                        __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                        goto __pyx_L77_exception_handled;
                      }
                      __pyx_L78_except_error:;
                      __Pyx_XGIVEREF(__pyx_t_17);
                      __Pyx_XGIVEREF(__pyx_t_24);
                      __Pyx_XGIVEREF(__pyx_t_31);
                      __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_24, __pyx_t_31);
                      goto __pyx_L62_error;
                      __pyx_L77_exception_handled:;
                      __Pyx_XGIVEREF(__pyx_t_17);
                      __Pyx_XGIVEREF(__pyx_t_24);
                      __Pyx_XGIVEREF(__pyx_t_31);
                      __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_24, __pyx_t_31);
                      __pyx_L83_try_end:;
                    }
                  }
                  /*finally:*/ {
                    /*normal exit:*/{
                      if (__pyx_t_18) {
                        __pyx_t_31 = __Pyx_PyObject_Call(__pyx_t_18, __pyx_mstate_global->__pyx_tuple[7], NULL);
                        __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                        if (unlikely(!__pyx_t_31)) __PYX_ERR(0, 6796, __pyx_L62_error)
                        __Pyx_GOTREF(__pyx_t_31);
                        __Pyx_DECREF(__pyx_t_31); __pyx_t_31 = 0;
                      }
                      goto __pyx_L75;
                    }
                    __pyx_L75:;
                  }
                  goto __pyx_L118;
                  __pyx_L70_error:;
                  __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
                  goto __pyx_L62_error;
                  __pyx_L118:;
                }

                /* "ws_package/controllers/activity_controller.py":6795
 *                     # Query Notes table for entries that contain any of these interval IDs
 *                     # Notes.activity_interval_id is a JSON array, so we need to check if any interval_id is in the array
 *                     try:             # <<<<<<<<<<<<<<
 *                         with db_lock_manager.read_lock():
 *                             async with async_session() as session:
*/
              }
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
              __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
              goto __pyx_L69_try_end;
              __pyx_L62_error:;
              __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
              __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
              __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
              __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

              /* "ws_package/controllers/activity_controller.py":6811
 *                                 if interval_note_map:
 *                                     logger.info("Found notes for %s intervals: %s", len(interval_note_map), list(interval_note_map.keys()))
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error fetching notes from Notes table: %s", e, exc_info=True)
 * 
*/
              __pyx_t_28 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
              if (__pyx_t_28) {
                __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._idle_reassign", __pyx_clineno, __pyx_lineno, __pyx_filename);
                if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_23, &__pyx_t_9) < 0) __PYX_ERR(0, 6811, __pyx_L64_except_error)
                __Pyx_XGOTREF(__pyx_t_8);
                __Pyx_XGOTREF(__pyx_t_23);
                __Pyx_XGOTREF(__pyx_t_9);
                __Pyx_INCREF(__pyx_t_23);
                __Pyx_GIVEREF(__pyx_t_23);
                __pyx_cur_scope->__pyx_v_e = __pyx_t_23;
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":6812
 *                                     logger.info("Found notes for %s intervals: %s", len(interval_note_map), list(interval_note_map.keys()))
 *                     except Exception as e:
 *                         logger.error("Error fetching notes from Notes table: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 * 
 * 
*/
                  __pyx_t_20 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6812, __pyx_L124_error)
                  __Pyx_GOTREF(__pyx_t_22);
                  __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6812, __pyx_L124_error)
                  __Pyx_GOTREF(__pyx_t_21);
                  __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                  __pyx_t_10 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_21))) {
                    __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_21);
                    assert(__pyx_t_20);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_21);
                    __Pyx_INCREF(__pyx_t_20);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_21, __pyx__function);
                    __pyx_t_10 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_20, __pyx_mstate_global->__pyx_kp_u_Error_fetching_notes_from_Notes, __pyx_cur_scope->__pyx_v_e};
                    __pyx_t_22 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6812, __pyx_L124_error)
                    __Pyx_GOTREF(__pyx_t_22);
                    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_22, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 6812, __pyx_L124_error)
                    __pyx_t_4 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_21, __pyx_callargs+__pyx_t_10, (3-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_22);
                    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6812, __pyx_L124_error)
                    __Pyx_GOTREF(__pyx_t_4);
                  }
                  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                }

                /* "ws_package/controllers/activity_controller.py":6811
 *                                 if interval_note_map:
 *                                     logger.info("Found notes for %s intervals: %s", len(interval_note_map), list(interval_note_map.keys()))
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error fetching notes from Notes table: %s", e, exc_info=True)
 * 
*/
                /*finally:*/ {
                  /*normal exit:*/{
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    goto __pyx_L125;
                  }
                  __pyx_L124_error:;
                  /*exception exit:*/{
                    __Pyx_PyThreadState_assign
                    __pyx_t_18 = 0; __pyx_t_31 = 0; __pyx_t_24 = 0; __pyx_t_17 = 0; __pyx_t_32 = 0; __pyx_t_35 = 0;
                    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                     __Pyx_ExceptionSwap(&__pyx_t_17, &__pyx_t_32, &__pyx_t_35);
                    if ( unlikely(__Pyx_GetException(&__pyx_t_18, &__pyx_t_31, &__pyx_t_24) < 0)) __Pyx_ErrFetch(&__pyx_t_18, &__pyx_t_31, &__pyx_t_24);
                    __Pyx_XGOTREF(__pyx_t_18);
                    __Pyx_XGOTREF(__pyx_t_31);
                    __Pyx_XGOTREF(__pyx_t_24);
                    __Pyx_XGOTREF(__pyx_t_17);
                    __Pyx_XGOTREF(__pyx_t_32);
                    __Pyx_XGOTREF(__pyx_t_35);
                    __pyx_t_28 = __pyx_lineno; __pyx_t_39 = __pyx_clineno; __pyx_t_40 = __pyx_filename;
                    {
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    }
                    __Pyx_XGIVEREF(__pyx_t_17);
                    __Pyx_XGIVEREF(__pyx_t_32);
                    __Pyx_XGIVEREF(__pyx_t_35);
                    __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_32, __pyx_t_35);
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __Pyx_XGIVEREF(__pyx_t_31);
                    __Pyx_XGIVEREF(__pyx_t_24);
                    __Pyx_ErrRestore(__pyx_t_18, __pyx_t_31, __pyx_t_24);
                    __pyx_t_18 = 0; __pyx_t_31 = 0; __pyx_t_24 = 0; __pyx_t_17 = 0; __pyx_t_32 = 0; __pyx_t_35 = 0;
                    __pyx_lineno = __pyx_t_28; __pyx_clineno = __pyx_t_39; __pyx_filename = __pyx_t_40;
                    goto __pyx_L64_except_error;
                  }
                  __pyx_L125:;
                }
                __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                goto __pyx_L63_exception_handled;
              }
              goto __pyx_L64_except_error;

              /* "ws_package/controllers/activity_controller.py":6795
 *                     # Query Notes table for entries that contain any of these interval IDs
 *                     # Notes.activity_interval_id is a JSON array, so we need to check if any interval_id is in the array
 *                     try:             # <<<<<<<<<<<<<<
 *                         with db_lock_manager.read_lock():
 *                             async with async_session() as session:
*/
              __pyx_L64_except_error:;
              __Pyx_XGIVEREF(__pyx_t_13);
              __Pyx_XGIVEREF(__pyx_t_16);
              __Pyx_XGIVEREF(__pyx_t_19);
              __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_16, __pyx_t_19);
              goto __pyx_L49_error;
              __pyx_L63_exception_handled:;
              __Pyx_XGIVEREF(__pyx_t_13);
              __Pyx_XGIVEREF(__pyx_t_16);
              __Pyx_XGIVEREF(__pyx_t_19);
              __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_16, __pyx_t_19);
              __pyx_L69_try_end:;
            }

            /* "ws_package/controllers/activity_controller.py":6815
 * 
 * 
 *                     for interval in day_intervals:             # <<<<<<<<<<<<<<
 *                         try:
 *                             payload_from, payload_to = self._payload_interval_bounds(interval, effective_start_time)
*/
            if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_day_intervals)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_day_intervals)) {
              __pyx_t_9 = __pyx_cur_scope->__pyx_v_day_intervals; __Pyx_INCREF(__pyx_t_9);
              __pyx_t_29 = 0;
              __pyx_t_30 = NULL;
            } else {
              __pyx_t_29 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_day_intervals); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6815, __pyx_L49_error)
              __Pyx_GOTREF(__pyx_t_9);
              __pyx_t_30 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_9); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 6815, __pyx_L49_error)
            }
            for (;;) {
              if (likely(!__pyx_t_30)) {
                if (likely(PyList_CheckExact(__pyx_t_9))) {
                  {
                    Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_9);
                    #if !CYTHON_ASSUME_SAFE_SIZE
                    if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6815, __pyx_L49_error)
                    #endif
                    if (__pyx_t_29 >= __pyx_temp) break;
                  }
                  __pyx_t_23 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_9, __pyx_t_29, __Pyx_ReferenceSharing_OwnStrongReference);
                  ++__pyx_t_29;
                } else {
                  {
                    Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_9);
                    #if !CYTHON_ASSUME_SAFE_SIZE
                    if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6815, __pyx_L49_error)
                    #endif
                    if (__pyx_t_29 >= __pyx_temp) break;
                  }
                  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                  __pyx_t_23 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_29));
                  #else
                  __pyx_t_23 = __Pyx_PySequence_ITEM(__pyx_t_9, __pyx_t_29);
                  #endif
                  ++__pyx_t_29;
                }
                if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6815, __pyx_L49_error)
              } else {
                __pyx_t_23 = __pyx_t_30(__pyx_t_9);
                if (unlikely(!__pyx_t_23)) {
                  PyObject* exc_type = PyErr_Occurred();
                  if (exc_type) {
                    if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 6815, __pyx_L49_error)
                    PyErr_Clear();
                  }
                  break;
                }
              }
              __Pyx_GOTREF(__pyx_t_23);
              __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
              __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_23);
              __Pyx_GIVEREF(__pyx_t_23);
              __pyx_t_23 = 0;

              /* "ws_package/controllers/activity_controller.py":6816
 * 
 *                     for interval in day_intervals:
 *                         try:             # <<<<<<<<<<<<<<
 *                             payload_from, payload_to = self._payload_interval_bounds(interval, effective_start_time)
 *                             if payload_to is not None and payload_from is not None and payload_to <= payload_from:
*/
              {
                __Pyx_ExceptionSave(&__pyx_t_19, &__pyx_t_16, &__pyx_t_13);
                __Pyx_XGOTREF(__pyx_t_19);
                __Pyx_XGOTREF(__pyx_t_16);
                __Pyx_XGOTREF(__pyx_t_13);
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":6817
 *                     for interval in day_intervals:
 *                         try:
 *                             payload_from, payload_to = self._payload_interval_bounds(interval, effective_start_time)             # <<<<<<<<<<<<<<
 *                             if payload_to is not None and payload_from is not None and payload_to <= payload_from:
 *                                 logger.info(
*/
                  __pyx_t_8 = __pyx_cur_scope->__pyx_v_self;
                  __Pyx_INCREF(__pyx_t_8);
                  __pyx_t_10 = 0;
                  {
                    PyObject *__pyx_callargs[3] = {__pyx_t_8, __pyx_cur_scope->__pyx_v_interval, __pyx_cur_scope->__pyx_v_effective_start_time};
                    __pyx_t_23 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_payload_interval_bounds, __pyx_callargs+__pyx_t_10, (3-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                    if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6817, __pyx_L132_error)
                    __Pyx_GOTREF(__pyx_t_23);
                  }
                  if ((likely(PyTuple_CheckExact(__pyx_t_23))) || (PyList_CheckExact(__pyx_t_23))) {
                    PyObject* sequence = __pyx_t_23;
                    Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
                    if (unlikely(size != 2)) {
                      if (size > 2) __Pyx_RaiseTooManyValuesError(2);
                      else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
                      __PYX_ERR(0, 6817, __pyx_L132_error)
                    }
                    #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                    if (likely(PyTuple_CheckExact(sequence))) {
                      __pyx_t_8 = PyTuple_GET_ITEM(sequence, 0);
                      __Pyx_INCREF(__pyx_t_8);
                      __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1);
                      __Pyx_INCREF(__pyx_t_4);
                    } else {
                      __pyx_t_8 = __Pyx_PyList_GET_ITEM_REF(sequence, 0, __Pyx_ReferenceSharing_SharedReference);
                      if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6817, __pyx_L132_error)
                      __Pyx_XGOTREF(__pyx_t_8);
                      __pyx_t_4 = __Pyx_PyList_GET_ITEM_REF(sequence, 1, __Pyx_ReferenceSharing_SharedReference);
                      if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6817, __pyx_L132_error)
                      __Pyx_XGOTREF(__pyx_t_4);
                    }
                    #else
                    __pyx_t_8 = __Pyx_PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6817, __pyx_L132_error)
                    __Pyx_GOTREF(__pyx_t_8);
                    __pyx_t_4 = __Pyx_PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6817, __pyx_L132_error)
                    __Pyx_GOTREF(__pyx_t_4);
                    #endif
                    __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                  } else {
                    Py_ssize_t index = -1;
                    __pyx_t_21 = PyObject_GetIter(__pyx_t_23); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6817, __pyx_L132_error)
                    __Pyx_GOTREF(__pyx_t_21);
                    __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                    __pyx_t_41 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_21);
                    index = 0; __pyx_t_8 = __pyx_t_41(__pyx_t_21); if (unlikely(!__pyx_t_8)) goto __pyx_L140_unpacking_failed;
                    __Pyx_GOTREF(__pyx_t_8);
                    index = 1; __pyx_t_4 = __pyx_t_41(__pyx_t_21); if (unlikely(!__pyx_t_4)) goto __pyx_L140_unpacking_failed;
                    __Pyx_GOTREF(__pyx_t_4);
                    if (__Pyx_IternextUnpackEndCheck(__pyx_t_41(__pyx_t_21), 2) < (0)) __PYX_ERR(0, 6817, __pyx_L132_error)
                    __pyx_t_41 = NULL;
                    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                    goto __pyx_L141_unpacking_done;
                    __pyx_L140_unpacking_failed:;
                    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __pyx_t_41 = NULL;
                    if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
                    __PYX_ERR(0, 6817, __pyx_L132_error)
                    __pyx_L141_unpacking_done:;
                  }
                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_payload_from);
                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_payload_from, __pyx_t_8);
                  __Pyx_GIVEREF(__pyx_t_8);
                  __pyx_t_8 = 0;
                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_payload_to);
                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_payload_to, __pyx_t_4);
                  __Pyx_GIVEREF(__pyx_t_4);
                  __pyx_t_4 = 0;

                  /* "ws_package/controllers/activity_controller.py":6818
 *                         try:
 *                             payload_from, payload_to = self._payload_interval_bounds(interval, effective_start_time)
 *                             if payload_to is not None and payload_from is not None and payload_to <= payload_from:             # <<<<<<<<<<<<<<
 *                                 logger.info(
 *                                     "Skipping idle reassignment interval (id=%s, start=%s, end=%s)  no time left after clipping to payload start %s",
*/
                  __pyx_t_5 = (__pyx_cur_scope->__pyx_v_payload_to != Py_None);
                  if (__pyx_t_5) {
                  } else {
                    __pyx_t_6 = __pyx_t_5;
                    goto __pyx_L143_bool_binop_done;
                  }
                  __pyx_t_5 = (__pyx_cur_scope->__pyx_v_payload_from != Py_None);
                  if (__pyx_t_5) {
                  } else {
                    __pyx_t_6 = __pyx_t_5;
                    goto __pyx_L143_bool_binop_done;
                  }
                  __pyx_t_23 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_payload_to, __pyx_cur_scope->__pyx_v_payload_from, Py_LE); __Pyx_XGOTREF(__pyx_t_23); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6818, __pyx_L132_error)
                  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_23); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 6818, __pyx_L132_error)
                  __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                  __pyx_t_6 = __pyx_t_5;
                  __pyx_L143_bool_binop_done:;
                  if (__pyx_t_6) {

                    /* "ws_package/controllers/activity_controller.py":6819
 *                             payload_from, payload_to = self._payload_interval_bounds(interval, effective_start_time)
 *                             if payload_to is not None and payload_from is not None and payload_to <= payload_from:
 *                                 logger.info(             # <<<<<<<<<<<<<<
 *                                     "Skipping idle reassignment interval (id=%s, start=%s, end=%s)  no time left after clipping to payload start %s",
 *                                     interval.id,
*/
                    __pyx_t_4 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6819, __pyx_L132_error)
                    __Pyx_GOTREF(__pyx_t_8);
                    __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6819, __pyx_L132_error)
                    __Pyx_GOTREF(__pyx_t_21);
                    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

                    /* "ws_package/controllers/activity_controller.py":6821
 *                                 logger.info(
 *                                     "Skipping idle reassignment interval (id=%s, start=%s, end=%s)  no time left after clipping to payload start %s",
 *                                     interval.id,             # <<<<<<<<<<<<<<
 *                                     interval.start_time,
 *                                     interval.end_time,
*/
                    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6821, __pyx_L132_error)
                    __Pyx_GOTREF(__pyx_t_8);

                    /* "ws_package/controllers/activity_controller.py":6822
 *                                     "Skipping idle reassignment interval (id=%s, start=%s, end=%s)  no time left after clipping to payload start %s",
 *                                     interval.id,
 *                                     interval.start_time,             # <<<<<<<<<<<<<<
 *                                     interval.end_time,
 *                                     effective_start_time,
*/
                    __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_start_time); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6822, __pyx_L132_error)
                    __Pyx_GOTREF(__pyx_t_22);

                    /* "ws_package/controllers/activity_controller.py":6823
 *                                     interval.id,
 *                                     interval.start_time,
 *                                     interval.end_time,             # <<<<<<<<<<<<<<
 *                                     effective_start_time,
 *                                 )
*/
                    __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_end_time); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6823, __pyx_L132_error)
                    __Pyx_GOTREF(__pyx_t_20);

                    /* "ws_package/controllers/activity_controller.py":6824
 *                                     interval.start_time,
 *                                     interval.end_time,
 *                                     effective_start_time,             # <<<<<<<<<<<<<<
 *                                 )
 *                                 continue
*/
                    __pyx_t_10 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_21))) {
                      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_21);
                      assert(__pyx_t_4);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_21);
                      __Pyx_INCREF(__pyx_t_4);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_21, __pyx__function);
                      __pyx_t_10 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[6] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Skipping_idle_reassignment_inter, __pyx_t_8, __pyx_t_22, __pyx_t_20, __pyx_cur_scope->__pyx_v_effective_start_time};
                      __pyx_t_23 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_21, __pyx_callargs+__pyx_t_10, (6-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                      __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                      if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6819, __pyx_L132_error)
                      __Pyx_GOTREF(__pyx_t_23);
                    }
                    __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

                    /* "ws_package/controllers/activity_controller.py":6826
 *                                     effective_start_time,
 *                                 )
 *                                 continue             # <<<<<<<<<<<<<<
 *                             screen_url = await self.ss(payload_from, payload_to, self.user_entity)
 *                             activity_level = await self.get_activity_level_from_db(payload_from, payload_to)
*/
                    goto __pyx_L138_try_continue;

                    /* "ws_package/controllers/activity_controller.py":6818
 *                         try:
 *                             payload_from, payload_to = self._payload_interval_bounds(interval, effective_start_time)
 *                             if payload_to is not None and payload_from is not None and payload_to <= payload_from:             # <<<<<<<<<<<<<<
 *                                 logger.info(
 *                                     "Skipping idle reassignment interval (id=%s, start=%s, end=%s)  no time left after clipping to payload start %s",
*/
                  }

                  /* "ws_package/controllers/activity_controller.py":6827
 *                                 )
 *                                 continue
 *                             screen_url = await self.ss(payload_from, payload_to, self.user_entity)             # <<<<<<<<<<<<<<
 *                             activity_level = await self.get_activity_level_from_db(payload_from, payload_to)
 *                             app_and_urls = await self.activity_service.get_apps_urls(payload_from, payload_to, self.appandurlstatus)
*/
                  __pyx_t_21 = __pyx_cur_scope->__pyx_v_self;
                  __Pyx_INCREF(__pyx_t_21);
                  __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_user_entity); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6827, __pyx_L132_error)
                  __Pyx_GOTREF(__pyx_t_20);
                  __pyx_t_10 = 0;
                  {
                    PyObject *__pyx_callargs[4] = {__pyx_t_21, __pyx_cur_scope->__pyx_v_payload_from, __pyx_cur_scope->__pyx_v_payload_to, __pyx_t_20};
                    __pyx_t_23 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_ss, __pyx_callargs+__pyx_t_10, (4-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                    if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6827, __pyx_L132_error)
                    __Pyx_GOTREF(__pyx_t_23);
                  }
                  __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_23, &__pyx_r);
                  __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                  if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_XGIVEREF(__pyx_t_1);
                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                    __Pyx_XGIVEREF(__pyx_t_2);
                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                    __Pyx_XGIVEREF(__pyx_t_3);
                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                    __Pyx_XGIVEREF(__pyx_t_7);
                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_7;
                    __Pyx_XGIVEREF(__pyx_t_9);
                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_9;
                    __Pyx_XGIVEREF(__pyx_t_12);
                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                    __Pyx_XGIVEREF(__pyx_t_13);
                    __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                    __Pyx_XGIVEREF(__pyx_t_14);
                    __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                    __Pyx_XGIVEREF(__pyx_t_19);
                    __pyx_cur_scope->__pyx_t_10 = __pyx_t_19;
                    __pyx_cur_scope->__pyx_t_15 = __pyx_t_25;
                    __pyx_cur_scope->__pyx_t_16 = __pyx_t_26;
                    __pyx_cur_scope->__pyx_t_17 = __pyx_t_27;
                    __pyx_cur_scope->__pyx_t_25 = __pyx_t_29;
                    __pyx_cur_scope->__pyx_t_26 = __pyx_t_30;
                    __Pyx_XGIVEREF(__pyx_r);
                    __Pyx_RefNannyFinishContext();
                    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                    /* return from generator, awaiting value */
                    __pyx_generator->resume_label = 11;
                    return __pyx_r;
                    __pyx_L146_resume_from_await:;
                    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                    __pyx_cur_scope->__pyx_t_0 = 0;
                    __Pyx_XGOTREF(__pyx_t_1);
                    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                    __pyx_cur_scope->__pyx_t_1 = 0;
                    __Pyx_XGOTREF(__pyx_t_2);
                    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                    __pyx_cur_scope->__pyx_t_2 = 0;
                    __Pyx_XGOTREF(__pyx_t_3);
                    __pyx_t_7 = __pyx_cur_scope->__pyx_t_3;
                    __pyx_cur_scope->__pyx_t_3 = 0;
                    __Pyx_XGOTREF(__pyx_t_7);
                    __pyx_t_9 = __pyx_cur_scope->__pyx_t_4;
                    __pyx_cur_scope->__pyx_t_4 = 0;
                    __Pyx_XGOTREF(__pyx_t_9);
                    __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                    __pyx_cur_scope->__pyx_t_5 = 0;
                    __Pyx_XGOTREF(__pyx_t_12);
                    __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                    __pyx_cur_scope->__pyx_t_6 = 0;
                    __Pyx_XGOTREF(__pyx_t_13);
                    __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                    __pyx_cur_scope->__pyx_t_7 = 0;
                    __Pyx_XGOTREF(__pyx_t_14);
                    __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                    __pyx_cur_scope->__pyx_t_8 = 0;
                    __Pyx_XGOTREF(__pyx_t_15);
                    __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                    __pyx_cur_scope->__pyx_t_9 = 0;
                    __Pyx_XGOTREF(__pyx_t_16);
                    __pyx_t_19 = __pyx_cur_scope->__pyx_t_10;
                    __pyx_cur_scope->__pyx_t_10 = 0;
                    __Pyx_XGOTREF(__pyx_t_19);
                    __pyx_t_25 = __pyx_cur_scope->__pyx_t_15;
                    __pyx_t_26 = __pyx_cur_scope->__pyx_t_16;
                    __pyx_t_27 = __pyx_cur_scope->__pyx_t_17;
                    __pyx_t_29 = __pyx_cur_scope->__pyx_t_25;
                    __pyx_t_30 = __pyx_cur_scope->__pyx_t_26;
                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6827, __pyx_L132_error)
                    __pyx_t_23 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_23);
                  } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                    __Pyx_GOTREF(__pyx_r);
                    __pyx_t_23 = __pyx_r; __pyx_r = NULL;
                  } else {
                    __Pyx_XGOTREF(__pyx_r);
                    __PYX_ERR(0, 6827, __pyx_L132_error)
                  }
                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_screen_url);
                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_screen_url, __pyx_t_23);
                  __Pyx_GIVEREF(__pyx_t_23);
                  __pyx_t_23 = 0;

                  /* "ws_package/controllers/activity_controller.py":6828
 *                                 continue
 *                             screen_url = await self.ss(payload_from, payload_to, self.user_entity)
 *                             activity_level = await self.get_activity_level_from_db(payload_from, payload_to)             # <<<<<<<<<<<<<<
 *                             app_and_urls = await self.activity_service.get_apps_urls(payload_from, payload_to, self.appandurlstatus)
 * 
*/
                  __pyx_t_20 = __pyx_cur_scope->__pyx_v_self;
                  __Pyx_INCREF(__pyx_t_20);
                  __pyx_t_10 = 0;
                  {
                    PyObject *__pyx_callargs[3] = {__pyx_t_20, __pyx_cur_scope->__pyx_v_payload_from, __pyx_cur_scope->__pyx_v_payload_to};
                    __pyx_t_23 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_activity_level_from_db, __pyx_callargs+__pyx_t_10, (3-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                    if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6828, __pyx_L132_error)
                    __Pyx_GOTREF(__pyx_t_23);
                  }
                  __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_23, &__pyx_r);
                  __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                  if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_XGIVEREF(__pyx_t_1);
                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                    __Pyx_XGIVEREF(__pyx_t_2);
                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                    __Pyx_XGIVEREF(__pyx_t_3);
                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                    __Pyx_XGIVEREF(__pyx_t_7);
                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_7;
                    __Pyx_XGIVEREF(__pyx_t_9);
                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_9;
                    __Pyx_XGIVEREF(__pyx_t_12);
                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                    __Pyx_XGIVEREF(__pyx_t_13);
                    __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                    __Pyx_XGIVEREF(__pyx_t_14);
                    __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                    __Pyx_XGIVEREF(__pyx_t_19);
                    __pyx_cur_scope->__pyx_t_10 = __pyx_t_19;
                    __pyx_cur_scope->__pyx_t_15 = __pyx_t_25;
                    __pyx_cur_scope->__pyx_t_16 = __pyx_t_26;
                    __pyx_cur_scope->__pyx_t_17 = __pyx_t_27;
                    __pyx_cur_scope->__pyx_t_25 = __pyx_t_29;
                    __pyx_cur_scope->__pyx_t_26 = __pyx_t_30;
                    __Pyx_XGIVEREF(__pyx_r);
                    __Pyx_RefNannyFinishContext();
                    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                    /* return from generator, awaiting value */
                    __pyx_generator->resume_label = 12;
                    return __pyx_r;
                    __pyx_L147_resume_from_await:;
                    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                    __pyx_cur_scope->__pyx_t_0 = 0;
                    __Pyx_XGOTREF(__pyx_t_1);
                    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                    __pyx_cur_scope->__pyx_t_1 = 0;
                    __Pyx_XGOTREF(__pyx_t_2);
                    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                    __pyx_cur_scope->__pyx_t_2 = 0;
                    __Pyx_XGOTREF(__pyx_t_3);
                    __pyx_t_7 = __pyx_cur_scope->__pyx_t_3;
                    __pyx_cur_scope->__pyx_t_3 = 0;
                    __Pyx_XGOTREF(__pyx_t_7);
                    __pyx_t_9 = __pyx_cur_scope->__pyx_t_4;
                    __pyx_cur_scope->__pyx_t_4 = 0;
                    __Pyx_XGOTREF(__pyx_t_9);
                    __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                    __pyx_cur_scope->__pyx_t_5 = 0;
                    __Pyx_XGOTREF(__pyx_t_12);
                    __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                    __pyx_cur_scope->__pyx_t_6 = 0;
                    __Pyx_XGOTREF(__pyx_t_13);
                    __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                    __pyx_cur_scope->__pyx_t_7 = 0;
                    __Pyx_XGOTREF(__pyx_t_14);
                    __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                    __pyx_cur_scope->__pyx_t_8 = 0;
                    __Pyx_XGOTREF(__pyx_t_15);
                    __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                    __pyx_cur_scope->__pyx_t_9 = 0;
                    __Pyx_XGOTREF(__pyx_t_16);
                    __pyx_t_19 = __pyx_cur_scope->__pyx_t_10;
                    __pyx_cur_scope->__pyx_t_10 = 0;
                    __Pyx_XGOTREF(__pyx_t_19);
                    __pyx_t_25 = __pyx_cur_scope->__pyx_t_15;
                    __pyx_t_26 = __pyx_cur_scope->__pyx_t_16;
                    __pyx_t_27 = __pyx_cur_scope->__pyx_t_17;
                    __pyx_t_29 = __pyx_cur_scope->__pyx_t_25;
                    __pyx_t_30 = __pyx_cur_scope->__pyx_t_26;
                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6828, __pyx_L132_error)
                    __pyx_t_23 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_23);
                  } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                    __Pyx_GOTREF(__pyx_r);
                    __pyx_t_23 = __pyx_r; __pyx_r = NULL;
                  } else {
                    __Pyx_XGOTREF(__pyx_r);
                    __PYX_ERR(0, 6828, __pyx_L132_error)
                  }
                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_activity_level);
                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_activity_level, __pyx_t_23);
                  __Pyx_GIVEREF(__pyx_t_23);
                  __pyx_t_23 = 0;

                  /* "ws_package/controllers/activity_controller.py":6829
 *                             screen_url = await self.ss(payload_from, payload_to, self.user_entity)
 *                             activity_level = await self.get_activity_level_from_db(payload_from, payload_to)
 *                             app_and_urls = await self.activity_service.get_apps_urls(payload_from, payload_to, self.appandurlstatus)             # <<<<<<<<<<<<<<
 * 
 *                             interval_payload = {
*/
                  __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6829, __pyx_L132_error)
                  __Pyx_GOTREF(__pyx_t_21);
                  __pyx_t_20 = __pyx_t_21;
                  __Pyx_INCREF(__pyx_t_20);
                  __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_appandurlstatus); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6829, __pyx_L132_error)
                  __Pyx_GOTREF(__pyx_t_22);
                  __pyx_t_10 = 0;
                  {
                    PyObject *__pyx_callargs[4] = {__pyx_t_20, __pyx_cur_scope->__pyx_v_payload_from, __pyx_cur_scope->__pyx_v_payload_to, __pyx_t_22};
                    __pyx_t_23 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_apps_urls, __pyx_callargs+__pyx_t_10, (4-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                    __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                    if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6829, __pyx_L132_error)
                    __Pyx_GOTREF(__pyx_t_23);
                  }
                  __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_23, &__pyx_r);
                  __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                  if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                    __Pyx_GOTREF(__pyx_r);
                    __Pyx_XGIVEREF(__pyx_t_1);
                    __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                    __Pyx_XGIVEREF(__pyx_t_2);
                    __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                    __Pyx_XGIVEREF(__pyx_t_3);
                    __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                    __Pyx_XGIVEREF(__pyx_t_7);
                    __pyx_cur_scope->__pyx_t_3 = __pyx_t_7;
                    __Pyx_XGIVEREF(__pyx_t_9);
                    __pyx_cur_scope->__pyx_t_4 = __pyx_t_9;
                    __Pyx_XGIVEREF(__pyx_t_12);
                    __pyx_cur_scope->__pyx_t_5 = __pyx_t_12;
                    __Pyx_XGIVEREF(__pyx_t_13);
                    __pyx_cur_scope->__pyx_t_6 = __pyx_t_13;
                    __Pyx_XGIVEREF(__pyx_t_14);
                    __pyx_cur_scope->__pyx_t_7 = __pyx_t_14;
                    __Pyx_XGIVEREF(__pyx_t_15);
                    __pyx_cur_scope->__pyx_t_8 = __pyx_t_15;
                    __Pyx_XGIVEREF(__pyx_t_16);
                    __pyx_cur_scope->__pyx_t_9 = __pyx_t_16;
                    __Pyx_XGIVEREF(__pyx_t_19);
                    __pyx_cur_scope->__pyx_t_10 = __pyx_t_19;
                    __pyx_cur_scope->__pyx_t_15 = __pyx_t_25;
                    __pyx_cur_scope->__pyx_t_16 = __pyx_t_26;
                    __pyx_cur_scope->__pyx_t_17 = __pyx_t_27;
                    __pyx_cur_scope->__pyx_t_25 = __pyx_t_29;
                    __pyx_cur_scope->__pyx_t_26 = __pyx_t_30;
                    __Pyx_XGIVEREF(__pyx_r);
                    __Pyx_RefNannyFinishContext();
                    __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                    /* return from generator, awaiting value */
                    __pyx_generator->resume_label = 13;
                    return __pyx_r;
                    __pyx_L148_resume_from_await:;
                    __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                    __pyx_cur_scope->__pyx_t_0 = 0;
                    __Pyx_XGOTREF(__pyx_t_1);
                    __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                    __pyx_cur_scope->__pyx_t_1 = 0;
                    __Pyx_XGOTREF(__pyx_t_2);
                    __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                    __pyx_cur_scope->__pyx_t_2 = 0;
                    __Pyx_XGOTREF(__pyx_t_3);
                    __pyx_t_7 = __pyx_cur_scope->__pyx_t_3;
                    __pyx_cur_scope->__pyx_t_3 = 0;
                    __Pyx_XGOTREF(__pyx_t_7);
                    __pyx_t_9 = __pyx_cur_scope->__pyx_t_4;
                    __pyx_cur_scope->__pyx_t_4 = 0;
                    __Pyx_XGOTREF(__pyx_t_9);
                    __pyx_t_12 = __pyx_cur_scope->__pyx_t_5;
                    __pyx_cur_scope->__pyx_t_5 = 0;
                    __Pyx_XGOTREF(__pyx_t_12);
                    __pyx_t_13 = __pyx_cur_scope->__pyx_t_6;
                    __pyx_cur_scope->__pyx_t_6 = 0;
                    __Pyx_XGOTREF(__pyx_t_13);
                    __pyx_t_14 = __pyx_cur_scope->__pyx_t_7;
                    __pyx_cur_scope->__pyx_t_7 = 0;
                    __Pyx_XGOTREF(__pyx_t_14);
                    __pyx_t_15 = __pyx_cur_scope->__pyx_t_8;
                    __pyx_cur_scope->__pyx_t_8 = 0;
                    __Pyx_XGOTREF(__pyx_t_15);
                    __pyx_t_16 = __pyx_cur_scope->__pyx_t_9;
                    __pyx_cur_scope->__pyx_t_9 = 0;
                    __Pyx_XGOTREF(__pyx_t_16);
                    __pyx_t_19 = __pyx_cur_scope->__pyx_t_10;
                    __pyx_cur_scope->__pyx_t_10 = 0;
                    __Pyx_XGOTREF(__pyx_t_19);
                    __pyx_t_25 = __pyx_cur_scope->__pyx_t_15;
                    __pyx_t_26 = __pyx_cur_scope->__pyx_t_16;
                    __pyx_t_27 = __pyx_cur_scope->__pyx_t_17;
                    __pyx_t_29 = __pyx_cur_scope->__pyx_t_25;
                    __pyx_t_30 = __pyx_cur_scope->__pyx_t_26;
                    if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6829, __pyx_L132_error)
                    __pyx_t_23 = __pyx_sent_value; __Pyx_INCREF(__pyx_t_23);
                  } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                    __Pyx_GOTREF(__pyx_r);
                    __pyx_t_23 = __pyx_r; __pyx_r = NULL;
                  } else {
                    __Pyx_XGOTREF(__pyx_r);
                    __PYX_ERR(0, 6829, __pyx_L132_error)
                  }
                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_app_and_urls);
                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_app_and_urls, __pyx_t_23);
                  __Pyx_GIVEREF(__pyx_t_23);
                  __pyx_t_23 = 0;

                  /* "ws_package/controllers/activity_controller.py":6832
 * 
 *                             interval_payload = {
 *                                 "Entry": interval.id,             # <<<<<<<<<<<<<<
 *                                 "from": payload_from.strftime("%Y-%m-%d %H:%M:%S"),
 *                                 "to": payload_to.strftime("%Y-%m-%d %H:%M:%S"),
*/
                  __pyx_t_23 = __Pyx_PyDict_NewPresized(14); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6832, __pyx_L132_error)
                  __Pyx_GOTREF(__pyx_t_23);
                  __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6832, __pyx_L132_error)
                  __Pyx_GOTREF(__pyx_t_21);
                  if (PyDict_SetItem(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_Entry, __pyx_t_21) < (0)) __PYX_ERR(0, 6832, __pyx_L132_error)
                  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;

                  /* "ws_package/controllers/activity_controller.py":6833
 *                             interval_payload = {
 *                                 "Entry": interval.id,
 *                                 "from": payload_from.strftime("%Y-%m-%d %H:%M:%S"),             # <<<<<<<<<<<<<<
 *                                 "to": payload_to.strftime("%Y-%m-%d %H:%M:%S"),
 *                                 "screenUrl": screen_url,
*/
                  __pyx_t_22 = __pyx_cur_scope->__pyx_v_payload_from;
                  __Pyx_INCREF(__pyx_t_22);
                  __pyx_t_10 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_22, __pyx_mstate_global->__pyx_kp_u_Y_m_d_H_M_S};
                    __pyx_t_21 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strftime, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                    if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6833, __pyx_L132_error)
                    __Pyx_GOTREF(__pyx_t_21);
                  }
                  if (PyDict_SetItem(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_from, __pyx_t_21) < (0)) __PYX_ERR(0, 6832, __pyx_L132_error)
                  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;

                  /* "ws_package/controllers/activity_controller.py":6834
 *                                 "Entry": interval.id,
 *                                 "from": payload_from.strftime("%Y-%m-%d %H:%M:%S"),
 *                                 "to": payload_to.strftime("%Y-%m-%d %H:%M:%S"),             # <<<<<<<<<<<<<<
 *                                 "screenUrl": screen_url,
 *                                 "activityLevel": activity_level,
*/
                  __pyx_t_22 = __pyx_cur_scope->__pyx_v_payload_to;
                  __Pyx_INCREF(__pyx_t_22);
                  __pyx_t_10 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_22, __pyx_mstate_global->__pyx_kp_u_Y_m_d_H_M_S};
                    __pyx_t_21 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strftime, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                    if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6834, __pyx_L132_error)
                    __Pyx_GOTREF(__pyx_t_21);
                  }
                  if (PyDict_SetItem(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_to, __pyx_t_21) < (0)) __PYX_ERR(0, 6832, __pyx_L132_error)
                  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;

                  /* "ws_package/controllers/activity_controller.py":6835
 *                                 "from": payload_from.strftime("%Y-%m-%d %H:%M:%S"),
 *                                 "to": payload_to.strftime("%Y-%m-%d %H:%M:%S"),
 *                                 "screenUrl": screen_url,             # <<<<<<<<<<<<<<
 *                                 "activityLevel": activity_level,
 *                                 "appAndUrls": app_and_urls,
*/
                  if (PyDict_SetItem(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_screenUrl, __pyx_cur_scope->__pyx_v_screen_url) < (0)) __PYX_ERR(0, 6832, __pyx_L132_error)

                  /* "ws_package/controllers/activity_controller.py":6836
 *                                 "to": payload_to.strftime("%Y-%m-%d %H:%M:%S"),
 *                                 "screenUrl": screen_url,
 *                                 "activityLevel": activity_level,             # <<<<<<<<<<<<<<
 *                                 "appAndUrls": app_and_urls,
 *                                 "deviceType": self.get_os_type_caps(),
*/
                  if (PyDict_SetItem(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_activityLevel, __pyx_cur_scope->__pyx_v_activity_level) < (0)) __PYX_ERR(0, 6832, __pyx_L132_error)

                  /* "ws_package/controllers/activity_controller.py":6837
 *                                 "screenUrl": screen_url,
 *                                 "activityLevel": activity_level,
 *                                 "appAndUrls": app_and_urls,             # <<<<<<<<<<<<<<
 *                                 "deviceType": self.get_os_type_caps(),
 *                                 "os_type": self.get_os_type_caps(),
*/
                  if (PyDict_SetItem(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_appAndUrls, __pyx_cur_scope->__pyx_v_app_and_urls) < (0)) __PYX_ERR(0, 6832, __pyx_L132_error)

                  /* "ws_package/controllers/activity_controller.py":6838
 *                                 "activityLevel": activity_level,
 *                                 "appAndUrls": app_and_urls,
 *                                 "deviceType": self.get_os_type_caps(),             # <<<<<<<<<<<<<<
 *                                 "os_type": self.get_os_type_caps(),
 *                                 "note": interval_note_map.get(getattr(interval, 'id', None)),
*/
                  __pyx_t_22 = __pyx_cur_scope->__pyx_v_self;
                  __Pyx_INCREF(__pyx_t_22);
                  __pyx_t_10 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_22, NULL};
                    __pyx_t_21 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type_caps, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                    if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6838, __pyx_L132_error)
                    __Pyx_GOTREF(__pyx_t_21);
                  }
                  if (PyDict_SetItem(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_deviceType, __pyx_t_21) < (0)) __PYX_ERR(0, 6832, __pyx_L132_error)
                  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;

                  /* "ws_package/controllers/activity_controller.py":6839
 *                                 "appAndUrls": app_and_urls,
 *                                 "deviceType": self.get_os_type_caps(),
 *                                 "os_type": self.get_os_type_caps(),             # <<<<<<<<<<<<<<
 *                                 "note": interval_note_map.get(getattr(interval, 'id', None)),
 *                                 "idle_note_url": None,
*/
                  __pyx_t_22 = __pyx_cur_scope->__pyx_v_self;
                  __Pyx_INCREF(__pyx_t_22);
                  __pyx_t_10 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_22, NULL};
                    __pyx_t_21 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type_caps, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                    if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6839, __pyx_L132_error)
                    __Pyx_GOTREF(__pyx_t_21);
                  }
                  if (PyDict_SetItem(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_os_type, __pyx_t_21) < (0)) __PYX_ERR(0, 6832, __pyx_L132_error)
                  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;

                  /* "ws_package/controllers/activity_controller.py":6840
 *                                 "deviceType": self.get_os_type_caps(),
 *                                 "os_type": self.get_os_type_caps(),
 *                                 "note": interval_note_map.get(getattr(interval, 'id', None)),             # <<<<<<<<<<<<<<
 *                                 "idle_note_url": None,
 *                                 "idleInterval": None,
*/
                  __pyx_t_21 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id, Py_None); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6840, __pyx_L132_error)
                  __Pyx_GOTREF(__pyx_t_21);
                  __pyx_t_22 = __Pyx_PyDict_GetItemDefault(__pyx_cur_scope->__pyx_v_interval_note_map, __pyx_t_21, Py_None); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6840, __pyx_L132_error)
                  __Pyx_GOTREF(__pyx_t_22);
                  __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                  if (PyDict_SetItem(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_note, __pyx_t_22) < (0)) __PYX_ERR(0, 6832, __pyx_L132_error)
                  __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;

                  /* "ws_package/controllers/activity_controller.py":6841
 *                                 "os_type": self.get_os_type_caps(),
 *                                 "note": interval_note_map.get(getattr(interval, 'id', None)),
 *                                 "idle_note_url": None,             # <<<<<<<<<<<<<<
 *                                 "idleInterval": None,
 *                                 "location": LocationEntity(
*/
                  if (PyDict_SetItem(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_idle_note_url, Py_None) < (0)) __PYX_ERR(0, 6832, __pyx_L132_error)

                  /* "ws_package/controllers/activity_controller.py":6842
 *                                 "note": interval_note_map.get(getattr(interval, 'id', None)),
 *                                 "idle_note_url": None,
 *                                 "idleInterval": None,             # <<<<<<<<<<<<<<
 *                                 "location": LocationEntity(
 *                                     long="null",
*/
                  if (PyDict_SetItem(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_idleInterval, Py_None) < (0)) __PYX_ERR(0, 6832, __pyx_L132_error)

                  /* "ws_package/controllers/activity_controller.py":6843
 *                                 "idle_note_url": None,
 *                                 "idleInterval": None,
 *                                 "location": LocationEntity(             # <<<<<<<<<<<<<<
 *                                     long="null",
 *                                     lat="null"
*/
                  __pyx_t_8 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_LocationEntity); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6843, __pyx_L132_error)
                  __Pyx_GOTREF(__pyx_t_4);
                  __pyx_t_10 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_4))) {
                    __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4);
                    assert(__pyx_t_8);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                    __Pyx_INCREF(__pyx_t_8);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                    __pyx_t_10 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[2 + ((CYTHON_VECTORCALL) ? 2 : 0)] = {__pyx_t_8, NULL};
                    __pyx_t_42 = __Pyx_MakeVectorcallBuilderKwds(2); if (unlikely(!__pyx_t_42)) __PYX_ERR(0, 6843, __pyx_L132_error)
                    __Pyx_GOTREF(__pyx_t_42);
                    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_long, __pyx_mstate_global->__pyx_n_u_null, __pyx_t_42, __pyx_callargs+1, 0) < (0)) __PYX_ERR(0, 6843, __pyx_L132_error)
                    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_lat, __pyx_mstate_global->__pyx_n_u_null, __pyx_t_42, __pyx_callargs+1, 1) < (0)) __PYX_ERR(0, 6843, __pyx_L132_error)
                    __pyx_t_20 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_42);
                    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                    __Pyx_DECREF(__pyx_t_42); __pyx_t_42 = 0;
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6843, __pyx_L132_error)
                    __Pyx_GOTREF(__pyx_t_20);
                  }
                  __pyx_t_21 = __pyx_t_20;
                  __Pyx_INCREF(__pyx_t_21);
                  __pyx_t_10 = 0;
                  {
                    PyObject *__pyx_callargs[2] = {__pyx_t_21, NULL};
                    __pyx_t_22 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_model_dump, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                    if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6846, __pyx_L132_error)
                    __Pyx_GOTREF(__pyx_t_22);
                  }
                  if (PyDict_SetItem(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_location, __pyx_t_22) < (0)) __PYX_ERR(0, 6832, __pyx_L132_error)
                  __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;

                  /* "ws_package/controllers/activity_controller.py":6847
 *                                     lat="null"
 *                                 ).model_dump(),
 *                                 "interval_time_db": int(self.interval/60),             # <<<<<<<<<<<<<<
 *                                 "has_on_demand_screenshot": getattr(interval, "has_on_demand_screenshot", False),
 *                             }
*/
                  __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6847, __pyx_L132_error)
                  __Pyx_GOTREF(__pyx_t_22);
                  __pyx_t_20 = __Pyx_PyLong_TrueDivideObjC(__pyx_t_22, __pyx_mstate_global->__pyx_int_60, 60, 0, 0); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6847, __pyx_L132_error)
                  __Pyx_GOTREF(__pyx_t_20);
                  __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                  __pyx_t_22 = __Pyx_PyNumber_Int(__pyx_t_20); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6847, __pyx_L132_error)
                  __Pyx_GOTREF(__pyx_t_22);
                  __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                  if (PyDict_SetItem(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_interval_time_db, __pyx_t_22) < (0)) __PYX_ERR(0, 6832, __pyx_L132_error)
                  __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;

                  /* "ws_package/controllers/activity_controller.py":6848
 *                                 ).model_dump(),
 *                                 "interval_time_db": int(self.interval/60),
 *                                 "has_on_demand_screenshot": getattr(interval, "has_on_demand_screenshot", False),             # <<<<<<<<<<<<<<
 *                             }
 *                             interval_payloads.append(interval_payload)
*/
                  __pyx_t_22 = __Pyx_GetAttr3(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_has_on_demand_screenshot, Py_False); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6848, __pyx_L132_error)
                  __Pyx_GOTREF(__pyx_t_22);
                  if (PyDict_SetItem(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_has_on_demand_screenshot, __pyx_t_22) < (0)) __PYX_ERR(0, 6832, __pyx_L132_error)
                  __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval_payload);
                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval_payload, ((PyObject*)__pyx_t_23));
                  __Pyx_GIVEREF(__pyx_t_23);
                  __pyx_t_23 = 0;

                  /* "ws_package/controllers/activity_controller.py":6850
 *                                 "has_on_demand_screenshot": getattr(interval, "has_on_demand_screenshot", False),
 *                             }
 *                             interval_payloads.append(interval_payload)             # <<<<<<<<<<<<<<
 *                         except Exception as e:
 *                             logger.error("Error building payload for interval %s: %s", interval.id, e, exc_info=True)
*/
                  __pyx_t_43 = __Pyx_PyList_Append(__pyx_cur_scope->__pyx_v_interval_payloads, __pyx_cur_scope->__pyx_v_interval_payload); if (unlikely(__pyx_t_43 == ((int)-1))) __PYX_ERR(0, 6850, __pyx_L132_error)

                  /* "ws_package/controllers/activity_controller.py":6816
 * 
 *                     for interval in day_intervals:
 *                         try:             # <<<<<<<<<<<<<<
 *                             payload_from, payload_to = self._payload_interval_bounds(interval, effective_start_time)
 *                             if payload_to is not None and payload_from is not None and payload_to <= payload_from:
*/
                }
                __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
                __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
                __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
                goto __pyx_L139_try_end;
                __pyx_L132_error:;
                __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_XDECREF(__pyx_t_42); __pyx_t_42 = 0;
                __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;

                /* "ws_package/controllers/activity_controller.py":6851
 *                             }
 *                             interval_payloads.append(interval_payload)
 *                         except Exception as e:             # <<<<<<<<<<<<<<
 *                             logger.error("Error building payload for interval %s: %s", interval.id, e, exc_info=True)
 *                             failed_count += 1
*/
                __pyx_t_39 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                if (__pyx_t_39) {
                  __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._idle_reassign", __pyx_clineno, __pyx_lineno, __pyx_filename);
                  if (__Pyx_GetException(&__pyx_t_23, &__pyx_t_22, &__pyx_t_20) < 0) __PYX_ERR(0, 6851, __pyx_L134_except_error)
                  __Pyx_XGOTREF(__pyx_t_23);
                  __Pyx_XGOTREF(__pyx_t_22);
                  __Pyx_XGOTREF(__pyx_t_20);
                  __Pyx_INCREF(__pyx_t_22);
                  __Pyx_GIVEREF(__pyx_t_22);
                  __pyx_cur_scope->__pyx_v_e = __pyx_t_22;
                  /*try:*/ {

                    /* "ws_package/controllers/activity_controller.py":6852
 *                             interval_payloads.append(interval_payload)
 *                         except Exception as e:
 *                             logger.error("Error building payload for interval %s: %s", interval.id, e, exc_info=True)             # <<<<<<<<<<<<<<
 *                             failed_count += 1
 *                             continue
*/
                    __pyx_t_4 = NULL;
                    __Pyx_GetModuleGlobalName(__pyx_t_42, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_42)) __PYX_ERR(0, 6852, __pyx_L154_error)
                    __Pyx_GOTREF(__pyx_t_42);
                    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_42, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6852, __pyx_L154_error)
                    __Pyx_GOTREF(__pyx_t_8);
                    __Pyx_DECREF(__pyx_t_42); __pyx_t_42 = 0;
                    __pyx_t_42 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_42)) __PYX_ERR(0, 6852, __pyx_L154_error)
                    __Pyx_GOTREF(__pyx_t_42);
                    __pyx_t_10 = 1;
                    #if CYTHON_UNPACK_METHODS
                    if (unlikely(PyMethod_Check(__pyx_t_8))) {
                      __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_8);
                      assert(__pyx_t_4);
                      PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_8);
                      __Pyx_INCREF(__pyx_t_4);
                      __Pyx_INCREF(__pyx__function);
                      __Pyx_DECREF_SET(__pyx_t_8, __pyx__function);
                      __pyx_t_10 = 0;
                    }
                    #endif
                    {
                      PyObject *__pyx_callargs[4 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_4, __pyx_mstate_global->__pyx_kp_u_Error_building_payload_for_inter, __pyx_t_42, __pyx_cur_scope->__pyx_v_e};
                      __pyx_t_44 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_44)) __PYX_ERR(0, 6852, __pyx_L154_error)
                      __Pyx_GOTREF(__pyx_t_44);
                      if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_44, __pyx_callargs+4, 0) < (0)) __PYX_ERR(0, 6852, __pyx_L154_error)
                      __pyx_t_21 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_10, (4-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_44);
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_DECREF(__pyx_t_42); __pyx_t_42 = 0;
                      __Pyx_DECREF(__pyx_t_44); __pyx_t_44 = 0;
                      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
                      if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6852, __pyx_L154_error)
                      __Pyx_GOTREF(__pyx_t_21);
                    }
                    __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;

                    /* "ws_package/controllers/activity_controller.py":6853
 *                         except Exception as e:
 *                             logger.error("Error building payload for interval %s: %s", interval.id, e, exc_info=True)
 *                             failed_count += 1             # <<<<<<<<<<<<<<
 *                             continue
 * 
*/
                    __pyx_t_21 = __Pyx_PyLong_AddObjC(__pyx_cur_scope->__pyx_v_failed_count, __pyx_mstate_global->__pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6853, __pyx_L154_error)
                    __Pyx_GOTREF(__pyx_t_21);
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_failed_count);
                    __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_failed_count, __pyx_t_21);
                    __Pyx_GIVEREF(__pyx_t_21);
                    __pyx_t_21 = 0;

                    /* "ws_package/controllers/activity_controller.py":6854
 *                             logger.error("Error building payload for interval %s: %s", interval.id, e, exc_info=True)
 *                             failed_count += 1
 *                             continue             # <<<<<<<<<<<<<<
 * 
 *                     if not interval_payloads:
*/
                    goto __pyx_L151_continue;
                  }

                  /* "ws_package/controllers/activity_controller.py":6851
 *                             }
 *                             interval_payloads.append(interval_payload)
 *                         except Exception as e:             # <<<<<<<<<<<<<<
 *                             logger.error("Error building payload for interval %s: %s", interval.id, e, exc_info=True)
 *                             failed_count += 1
*/
                  /*finally:*/ {
                    __pyx_L154_error:;
                    /*exception exit:*/{
                      __Pyx_PyThreadState_assign
                      __pyx_t_35 = 0; __pyx_t_32 = 0; __pyx_t_17 = 0; __pyx_t_24 = 0; __pyx_t_31 = 0; __pyx_t_18 = 0;
                      __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                      __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                      __Pyx_XDECREF(__pyx_t_42); __pyx_t_42 = 0;
                      __Pyx_XDECREF(__pyx_t_44); __pyx_t_44 = 0;
                      __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                       __Pyx_ExceptionSwap(&__pyx_t_24, &__pyx_t_31, &__pyx_t_18);
                      if ( unlikely(__Pyx_GetException(&__pyx_t_35, &__pyx_t_32, &__pyx_t_17) < 0)) __Pyx_ErrFetch(&__pyx_t_35, &__pyx_t_32, &__pyx_t_17);
                      __Pyx_XGOTREF(__pyx_t_35);
                      __Pyx_XGOTREF(__pyx_t_32);
                      __Pyx_XGOTREF(__pyx_t_17);
                      __Pyx_XGOTREF(__pyx_t_24);
                      __Pyx_XGOTREF(__pyx_t_31);
                      __Pyx_XGOTREF(__pyx_t_18);
                      __pyx_t_39 = __pyx_lineno; __pyx_t_28 = __pyx_clineno; __pyx_t_45 = __pyx_filename;
                      {
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                        __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                      }
                      __Pyx_XGIVEREF(__pyx_t_24);
                      __Pyx_XGIVEREF(__pyx_t_31);
                      __Pyx_XGIVEREF(__pyx_t_18);
                      __Pyx_ExceptionReset(__pyx_t_24, __pyx_t_31, __pyx_t_18);
                      __Pyx_XGIVEREF(__pyx_t_35);
                      __Pyx_XGIVEREF(__pyx_t_32);
                      __Pyx_XGIVEREF(__pyx_t_17);
                      __Pyx_ErrRestore(__pyx_t_35, __pyx_t_32, __pyx_t_17);
                      __pyx_t_35 = 0; __pyx_t_32 = 0; __pyx_t_17 = 0; __pyx_t_24 = 0; __pyx_t_31 = 0; __pyx_t_18 = 0;
                      __pyx_lineno = __pyx_t_39; __pyx_clineno = __pyx_t_28; __pyx_filename = __pyx_t_45;
                      goto __pyx_L134_except_error;
                    }
                    __pyx_L151_continue: {
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                      goto __pyx_L149_except_continue;
                    }
                  }
                  __pyx_L149_except_continue:;
                  __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                  __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                  __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                  goto __pyx_L138_try_continue;
                }
                goto __pyx_L134_except_error;

                /* "ws_package/controllers/activity_controller.py":6816
 * 
 *                     for interval in day_intervals:
 *                         try:             # <<<<<<<<<<<<<<
 *                             payload_from, payload_to = self._payload_interval_bounds(interval, effective_start_time)
 *                             if payload_to is not None and payload_from is not None and payload_to <= payload_from:
*/
                __pyx_L134_except_error:;
                __Pyx_XGIVEREF(__pyx_t_19);
                __Pyx_XGIVEREF(__pyx_t_16);
                __Pyx_XGIVEREF(__pyx_t_13);
                __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_16, __pyx_t_13);
                goto __pyx_L49_error;
                __pyx_L138_try_continue:;
                __Pyx_XGIVEREF(__pyx_t_19);
                __Pyx_XGIVEREF(__pyx_t_16);
                __Pyx_XGIVEREF(__pyx_t_13);
                __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_16, __pyx_t_13);
                goto __pyx_L130_continue;
                __pyx_L139_try_end:;
              }

              /* "ws_package/controllers/activity_controller.py":6815
 * 
 * 
 *                     for interval in day_intervals:             # <<<<<<<<<<<<<<
 *                         try:
 *                             payload_from, payload_to = self._payload_interval_bounds(interval, effective_start_time)
*/
              __pyx_L130_continue:;
            }
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

            /* "ws_package/controllers/activity_controller.py":6856
 *                             continue
 * 
 *                     if not interval_payloads:             # <<<<<<<<<<<<<<
 *                         logger.warning("No interval payloads created for date %s", target_date)
 *                         continue
*/
            {
              Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_interval_payloads);
              if (unlikely(((!CYTHON_ASSUME_SAFE_SIZE) && __pyx_temp < 0))) __PYX_ERR(0, 6856, __pyx_L49_error)
              __pyx_t_6 = (__pyx_temp != 0);
            }

            __pyx_t_5 = (!__pyx_t_6);
            if (__pyx_t_5) {

              /* "ws_package/controllers/activity_controller.py":6857
 * 
 *                     if not interval_payloads:
 *                         logger.warning("No interval payloads created for date %s", target_date)             # <<<<<<<<<<<<<<
 *                         continue
 * 
*/
              __pyx_t_20 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6857, __pyx_L49_error)
              __Pyx_GOTREF(__pyx_t_22);
              __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_warning); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6857, __pyx_L49_error)
              __Pyx_GOTREF(__pyx_t_23);
              __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
              __pyx_t_10 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_23))) {
                __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_23);
                assert(__pyx_t_20);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_23);
                __Pyx_INCREF(__pyx_t_20);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_23, __pyx__function);
                __pyx_t_10 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[3] = {__pyx_t_20, __pyx_mstate_global->__pyx_kp_u_No_interval_payloads_created_for, __pyx_cur_scope->__pyx_v_target_date};
                __pyx_t_9 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_23, __pyx_callargs+__pyx_t_10, (3-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6857, __pyx_L49_error)
                __Pyx_GOTREF(__pyx_t_9);
              }
              __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

              /* "ws_package/controllers/activity_controller.py":6858
 *                     if not interval_payloads:
 *                         logger.warning("No interval payloads created for date %s", target_date)
 *                         continue             # <<<<<<<<<<<<<<
 * 
 *                     # Build the final payload using the provided project_id and task_id
*/
              goto __pyx_L55_try_continue;

              /* "ws_package/controllers/activity_controller.py":6856
 *                             continue
 * 
 *                     if not interval_payloads:             # <<<<<<<<<<<<<<
 *                         logger.warning("No interval payloads created for date %s", target_date)
 *                         continue
*/
            }

            /* "ws_package/controllers/activity_controller.py":6862
 *                     # Build the final payload using the provided project_id and task_id
 *                     payload = [{
 *                         "projectId": project_id_str,             # <<<<<<<<<<<<<<
 *                         "start": effective_start_time.strftime("%Y-%m-%d %H:%M:%S"),
 *                         "stop": None,
*/
            __pyx_t_9 = __Pyx_PyDict_NewPresized(18); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6862, __pyx_L49_error)
            __Pyx_GOTREF(__pyx_t_9);
            if (PyDict_SetItem(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_projectId, __pyx_cur_scope->__pyx_v_project_id_str) < (0)) __PYX_ERR(0, 6862, __pyx_L49_error)

            /* "ws_package/controllers/activity_controller.py":6863
 *                     payload = [{
 *                         "projectId": project_id_str,
 *                         "start": effective_start_time.strftime("%Y-%m-%d %H:%M:%S"),             # <<<<<<<<<<<<<<
 *                         "stop": None,
 *                         "selfi_id": None,
*/
            __pyx_t_20 = __pyx_cur_scope->__pyx_v_effective_start_time;
            __Pyx_INCREF(__pyx_t_20);
            __pyx_t_10 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_20, __pyx_mstate_global->__pyx_kp_u_Y_m_d_H_M_S};
              __pyx_t_23 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_strftime, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
              if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6863, __pyx_L49_error)
              __Pyx_GOTREF(__pyx_t_23);
            }
            if (PyDict_SetItem(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_start, __pyx_t_23) < (0)) __PYX_ERR(0, 6862, __pyx_L49_error)
            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

            /* "ws_package/controllers/activity_controller.py":6864
 *                         "projectId": project_id_str,
 *                         "start": effective_start_time.strftime("%Y-%m-%d %H:%M:%S"),
 *                         "stop": None,             # <<<<<<<<<<<<<<
 *                         "selfi_id": None,
 *                         "timezone": self._normalize_timezone(str(self.timezone_manager.local_timezone) if self.timezone_manager.local_timezone else str(self.get_system_timezone())),
*/
            if (PyDict_SetItem(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_stop, Py_None) < (0)) __PYX_ERR(0, 6862, __pyx_L49_error)

            /* "ws_package/controllers/activity_controller.py":6865
 *                         "start": effective_start_time.strftime("%Y-%m-%d %H:%M:%S"),
 *                         "stop": None,
 *                         "selfi_id": None,             # <<<<<<<<<<<<<<
 *                         "timezone": self._normalize_timezone(str(self.timezone_manager.local_timezone) if self.timezone_manager.local_timezone else str(self.get_system_timezone())),
 *                         "break_id": None,
*/
            if (PyDict_SetItem(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_selfi_id, Py_None) < (0)) __PYX_ERR(0, 6862, __pyx_L49_error)

            /* "ws_package/controllers/activity_controller.py":6866
 *                         "stop": None,
 *                         "selfi_id": None,
 *                         "timezone": self._normalize_timezone(str(self.timezone_manager.local_timezone) if self.timezone_manager.local_timezone else str(self.get_system_timezone())),             # <<<<<<<<<<<<<<
 *                         "break_id": None,
 *                         "deviceType": self.get_os_type_caps(),
*/
            __pyx_t_20 = __pyx_cur_scope->__pyx_v_self;
            __Pyx_INCREF(__pyx_t_20);
            __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_timezone_manager); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6866, __pyx_L49_error)
            __Pyx_GOTREF(__pyx_t_21);
            __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_21, __pyx_mstate_global->__pyx_n_u_local_timezone); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6866, __pyx_L49_error)
            __Pyx_GOTREF(__pyx_t_8);
            __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
            __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 6866, __pyx_L49_error)
            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
            if (__pyx_t_5) {
              __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_timezone_manager); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6866, __pyx_L49_error)
              __Pyx_GOTREF(__pyx_t_8);
              __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_local_timezone); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6866, __pyx_L49_error)
              __Pyx_GOTREF(__pyx_t_21);
              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
              __pyx_t_8 = __Pyx_PyObject_Unicode(__pyx_t_21); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6866, __pyx_L49_error)
              __Pyx_GOTREF(__pyx_t_8);
              __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
              __pyx_t_22 = __pyx_t_8;
              __pyx_t_8 = 0;
            } else {
              __pyx_t_21 = __pyx_cur_scope->__pyx_v_self;
              __Pyx_INCREF(__pyx_t_21);
              __pyx_t_10 = 0;
              {
                PyObject *__pyx_callargs[2] = {__pyx_t_21, NULL};
                __pyx_t_8 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_system_timezone, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 6866, __pyx_L49_error)
                __Pyx_GOTREF(__pyx_t_8);
              }
              __pyx_t_21 = __Pyx_PyObject_Unicode(__pyx_t_8); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6866, __pyx_L49_error)
              __Pyx_GOTREF(__pyx_t_21);
              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
              __pyx_t_22 = __pyx_t_21;
              __pyx_t_21 = 0;
            }
            __pyx_t_10 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_20, __pyx_t_22};
              __pyx_t_23 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_normalize_timezone, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
              __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
              if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6866, __pyx_L49_error)
              __Pyx_GOTREF(__pyx_t_23);
            }
            if (PyDict_SetItem(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_timezone, __pyx_t_23) < (0)) __PYX_ERR(0, 6862, __pyx_L49_error)
            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

            /* "ws_package/controllers/activity_controller.py":6867
 *                         "selfi_id": None,
 *                         "timezone": self._normalize_timezone(str(self.timezone_manager.local_timezone) if self.timezone_manager.local_timezone else str(self.get_system_timezone())),
 *                         "break_id": None,             # <<<<<<<<<<<<<<
 *                         "deviceType": self.get_os_type_caps(),
 *                         "os_type": self.get_os_type_caps(),
*/
            if (PyDict_SetItem(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_break_id, Py_None) < (0)) __PYX_ERR(0, 6862, __pyx_L49_error)

            /* "ws_package/controllers/activity_controller.py":6868
 *                         "timezone": self._normalize_timezone(str(self.timezone_manager.local_timezone) if self.timezone_manager.local_timezone else str(self.get_system_timezone())),
 *                         "break_id": None,
 *                         "deviceType": self.get_os_type_caps(),             # <<<<<<<<<<<<<<
 *                         "os_type": self.get_os_type_caps(),
 *                         "selfiVerification": True,
*/
            __pyx_t_22 = __pyx_cur_scope->__pyx_v_self;
            __Pyx_INCREF(__pyx_t_22);
            __pyx_t_10 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_22, NULL};
              __pyx_t_23 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type_caps, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
              if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6868, __pyx_L49_error)
              __Pyx_GOTREF(__pyx_t_23);
            }
            if (PyDict_SetItem(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_deviceType, __pyx_t_23) < (0)) __PYX_ERR(0, 6862, __pyx_L49_error)
            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

            /* "ws_package/controllers/activity_controller.py":6869
 *                         "break_id": None,
 *                         "deviceType": self.get_os_type_caps(),
 *                         "os_type": self.get_os_type_caps(),             # <<<<<<<<<<<<<<
 *                         "selfiVerification": True,
 *                         "intervals": interval_payloads,
*/
            __pyx_t_22 = __pyx_cur_scope->__pyx_v_self;
            __Pyx_INCREF(__pyx_t_22);
            __pyx_t_10 = 0;
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_22, NULL};
              __pyx_t_23 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_get_os_type_caps, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
              if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6869, __pyx_L49_error)
              __Pyx_GOTREF(__pyx_t_23);
            }
            if (PyDict_SetItem(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_os_type, __pyx_t_23) < (0)) __PYX_ERR(0, 6862, __pyx_L49_error)
            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

            /* "ws_package/controllers/activity_controller.py":6870
 *                         "deviceType": self.get_os_type_caps(),
 *                         "os_type": self.get_os_type_caps(),
 *                         "selfiVerification": True,             # <<<<<<<<<<<<<<
 *                         "intervals": interval_payloads,
 *                         "time_type": "1",
*/
            if (PyDict_SetItem(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_selfiVerification, Py_True) < (0)) __PYX_ERR(0, 6862, __pyx_L49_error)

            /* "ws_package/controllers/activity_controller.py":6871
 *                         "os_type": self.get_os_type_caps(),
 *                         "selfiVerification": True,
 *                         "intervals": interval_payloads,             # <<<<<<<<<<<<<<
 *                         "time_type": "1",
 *                         "interval_time": int(self.interval/60),
*/
            if (PyDict_SetItem(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_intervals, __pyx_cur_scope->__pyx_v_interval_payloads) < (0)) __PYX_ERR(0, 6862, __pyx_L49_error)
            if (PyDict_SetItem(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_time_type, __pyx_mstate_global->__pyx_kp_u_1) < (0)) __PYX_ERR(0, 6862, __pyx_L49_error)

            /* "ws_package/controllers/activity_controller.py":6873
 *                         "intervals": interval_payloads,
 *                         "time_type": "1",
 *                         "interval_time": int(self.interval/60),             # <<<<<<<<<<<<<<
 *                         "source_type": "4",
 *                         "org_id": str(self.user_entity.org_id),
*/
            __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_interval); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6873, __pyx_L49_error)
            __Pyx_GOTREF(__pyx_t_23);
            __pyx_t_22 = __Pyx_PyLong_TrueDivideObjC(__pyx_t_23, __pyx_mstate_global->__pyx_int_60, 60, 0, 0); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6873, __pyx_L49_error)
            __Pyx_GOTREF(__pyx_t_22);
            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
            __pyx_t_23 = __Pyx_PyNumber_Int(__pyx_t_22); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6873, __pyx_L49_error)
            __Pyx_GOTREF(__pyx_t_23);
            __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
            if (PyDict_SetItem(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_interval_time, __pyx_t_23) < (0)) __PYX_ERR(0, 6862, __pyx_L49_error)
            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
            if (PyDict_SetItem(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_source_type, __pyx_mstate_global->__pyx_kp_u_4) < (0)) __PYX_ERR(0, 6862, __pyx_L49_error)

            /* "ws_package/controllers/activity_controller.py":6875
 *                         "interval_time": int(self.interval/60),
 *                         "source_type": "4",
 *                         "org_id": str(self.user_entity.org_id),             # <<<<<<<<<<<<<<
 *                         "todo_id": task_id_str,
 *                         "deviceId": self.system_unique_id,
*/
            __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_user_entity); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6875, __pyx_L49_error)
            __Pyx_GOTREF(__pyx_t_23);
            __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_org_id); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6875, __pyx_L49_error)
            __Pyx_GOTREF(__pyx_t_22);
            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
            __pyx_t_23 = __Pyx_PyObject_Unicode(__pyx_t_22); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6875, __pyx_L49_error)
            __Pyx_GOTREF(__pyx_t_23);
            __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
            if (PyDict_SetItem(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_org_id, __pyx_t_23) < (0)) __PYX_ERR(0, 6862, __pyx_L49_error)
            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

            /* "ws_package/controllers/activity_controller.py":6876
 *                         "source_type": "4",
 *                         "org_id": str(self.user_entity.org_id),
 *                         "todo_id": task_id_str,             # <<<<<<<<<<<<<<
 *                         "deviceId": self.system_unique_id,
 *                         "ip_address": str(get_ip()),
*/
            if (PyDict_SetItem(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_todo_id, __pyx_cur_scope->__pyx_v_task_id_str) < (0)) __PYX_ERR(0, 6862, __pyx_L49_error)

            /* "ws_package/controllers/activity_controller.py":6877
 *                         "org_id": str(self.user_entity.org_id),
 *                         "todo_id": task_id_str,
 *                         "deviceId": self.system_unique_id,             # <<<<<<<<<<<<<<
 *                         "ip_address": str(get_ip()),
 *                         "os_version": get_os_version()
*/
            __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_system_unique_id); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6877, __pyx_L49_error)
            __Pyx_GOTREF(__pyx_t_23);
            if (PyDict_SetItem(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_deviceId, __pyx_t_23) < (0)) __PYX_ERR(0, 6862, __pyx_L49_error)
            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

            /* "ws_package/controllers/activity_controller.py":6878
 *                         "todo_id": task_id_str,
 *                         "deviceId": self.system_unique_id,
 *                         "ip_address": str(get_ip()),             # <<<<<<<<<<<<<<
 *                         "os_version": get_os_version()
 *                     }]
*/
            __pyx_t_22 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_get_ip); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6878, __pyx_L49_error)
            __Pyx_GOTREF(__pyx_t_20);
            __pyx_t_10 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_20))) {
              __pyx_t_22 = PyMethod_GET_SELF(__pyx_t_20);
              assert(__pyx_t_22);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_20);
              __Pyx_INCREF(__pyx_t_22);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_20, __pyx__function);
              __pyx_t_10 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_22, NULL};
              __pyx_t_23 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_20, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
              __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
              if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6878, __pyx_L49_error)
              __Pyx_GOTREF(__pyx_t_23);
            }
            __pyx_t_20 = __Pyx_PyObject_Unicode(__pyx_t_23); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6878, __pyx_L49_error)
            __Pyx_GOTREF(__pyx_t_20);
            __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
            if (PyDict_SetItem(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_ip_address, __pyx_t_20) < (0)) __PYX_ERR(0, 6862, __pyx_L49_error)
            __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;

            /* "ws_package/controllers/activity_controller.py":6879
 *                         "deviceId": self.system_unique_id,
 *                         "ip_address": str(get_ip()),
 *                         "os_version": get_os_version()             # <<<<<<<<<<<<<<
 *                     }]
 * 
*/
            __pyx_t_23 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_get_os_version); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6879, __pyx_L49_error)
            __Pyx_GOTREF(__pyx_t_22);
            __pyx_t_10 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_22))) {
              __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_22);
              assert(__pyx_t_23);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_22);
              __Pyx_INCREF(__pyx_t_23);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_22, __pyx__function);
              __pyx_t_10 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[2] = {__pyx_t_23, NULL};
              __pyx_t_20 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_22, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
              if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6879, __pyx_L49_error)
              __Pyx_GOTREF(__pyx_t_20);
            }
            if (PyDict_SetItem(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_os_version, __pyx_t_20) < (0)) __PYX_ERR(0, 6862, __pyx_L49_error)
            __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;

            /* "ws_package/controllers/activity_controller.py":6861
 * 
 *                     # Build the final payload using the provided project_id and task_id
 *                     payload = [{             # <<<<<<<<<<<<<<
 *                         "projectId": project_id_str,
 *                         "start": effective_start_time.strftime("%Y-%m-%d %H:%M:%S"),
*/
            __pyx_t_20 = PyList_New(1); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6861, __pyx_L49_error)
            __Pyx_GOTREF(__pyx_t_20);
            __Pyx_GIVEREF(__pyx_t_9);
            if (__Pyx_PyList_SET_ITEM(__pyx_t_20, 0, __pyx_t_9) != (0)) __PYX_ERR(0, 6861, __pyx_L49_error);
            __pyx_t_9 = 0;
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_payload);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_payload, ((PyObject*)__pyx_t_20));
            __Pyx_GIVEREF(__pyx_t_20);
            __pyx_t_20 = 0;

            /* "ws_package/controllers/activity_controller.py":6882
 *                     }]
 * 
 *                     logger.info("Sending %s idle intervals to API with project_id=%s, task_id=%s", len(interval_payloads), project_id_str, task_id_str)             # <<<<<<<<<<<<<<
 * 
 *                     # Send to API
*/
            __pyx_t_9 = NULL;
            __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6882, __pyx_L49_error)
            __Pyx_GOTREF(__pyx_t_22);
            __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6882, __pyx_L49_error)
            __Pyx_GOTREF(__pyx_t_23);
            __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
            __pyx_t_29 = __Pyx_PyList_GET_SIZE(__pyx_cur_scope->__pyx_v_interval_payloads); if (unlikely(__pyx_t_29 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6882, __pyx_L49_error)
            __pyx_t_22 = PyLong_FromSsize_t(__pyx_t_29); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6882, __pyx_L49_error)
            __Pyx_GOTREF(__pyx_t_22);
            __pyx_t_10 = 1;
            #if CYTHON_UNPACK_METHODS
            if (unlikely(PyMethod_Check(__pyx_t_23))) {
              __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_23);
              assert(__pyx_t_9);
              PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_23);
              __Pyx_INCREF(__pyx_t_9);
              __Pyx_INCREF(__pyx__function);
              __Pyx_DECREF_SET(__pyx_t_23, __pyx__function);
              __pyx_t_10 = 0;
            }
            #endif
            {
              PyObject *__pyx_callargs[5] = {__pyx_t_9, __pyx_mstate_global->__pyx_kp_u_Sending_s_idle_intervals_to_API, __pyx_t_22, __pyx_cur_scope->__pyx_v_project_id_str, __pyx_cur_scope->__pyx_v_task_id_str};
              __pyx_t_20 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_23, __pyx_callargs+__pyx_t_10, (5-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
              __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
              __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
              __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
              if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6882, __pyx_L49_error)
              __Pyx_GOTREF(__pyx_t_20);
            }
            __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;

            /* "ws_package/controllers/activity_controller.py":6885
 * 
 *                     # Send to API
 *                     try:             # <<<<<<<<<<<<<<
 *                         response = self.activity_service.push_activity_logs(payload)
 *                         logger.info("Successfully sent idle intervals for date %s to API", target_date)
*/
            {
              __Pyx_ExceptionSave(&__pyx_t_13, &__pyx_t_16, &__pyx_t_19);
              __Pyx_XGOTREF(__pyx_t_13);
              __Pyx_XGOTREF(__pyx_t_16);
              __Pyx_XGOTREF(__pyx_t_19);
              /*try:*/ {

                /* "ws_package/controllers/activity_controller.py":6886
 *                     # Send to API
 *                     try:
 *                         response = self.activity_service.push_activity_logs(payload)             # <<<<<<<<<<<<<<
 *                         logger.info("Successfully sent idle intervals for date %s to API", target_date)
 * 
*/
                __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_mstate_global->__pyx_n_u_activity_service); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6886, __pyx_L162_error)
                __Pyx_GOTREF(__pyx_t_22);
                __pyx_t_23 = __pyx_t_22;
                __Pyx_INCREF(__pyx_t_23);
                __pyx_t_10 = 0;
                {
                  PyObject *__pyx_callargs[2] = {__pyx_t_23, __pyx_cur_scope->__pyx_v_payload};
                  __pyx_t_20 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_push_activity_logs, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                  __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
                  if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6886, __pyx_L162_error)
                  __Pyx_GOTREF(__pyx_t_20);
                }
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_response);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_response, __pyx_t_20);
                __Pyx_GIVEREF(__pyx_t_20);
                __pyx_t_20 = 0;

                /* "ws_package/controllers/activity_controller.py":6887
 *                     try:
 *                         response = self.activity_service.push_activity_logs(payload)
 *                         logger.info("Successfully sent idle intervals for date %s to API", target_date)             # <<<<<<<<<<<<<<
 * 
 *                         # Mark intervals as uploaded
*/
                __pyx_t_22 = NULL;
                __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6887, __pyx_L162_error)
                __Pyx_GOTREF(__pyx_t_23);
                __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6887, __pyx_L162_error)
                __Pyx_GOTREF(__pyx_t_9);
                __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
                __pyx_t_10 = 1;
                #if CYTHON_UNPACK_METHODS
                if (unlikely(PyMethod_Check(__pyx_t_9))) {
                  __pyx_t_22 = PyMethod_GET_SELF(__pyx_t_9);
                  assert(__pyx_t_22);
                  PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_9);
                  __Pyx_INCREF(__pyx_t_22);
                  __Pyx_INCREF(__pyx__function);
                  __Pyx_DECREF_SET(__pyx_t_9, __pyx__function);
                  __pyx_t_10 = 0;
                }
                #endif
                {
                  PyObject *__pyx_callargs[3] = {__pyx_t_22, __pyx_mstate_global->__pyx_kp_u_Successfully_sent_idle_intervals, __pyx_cur_scope->__pyx_v_target_date};
                  __pyx_t_20 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_10, (3-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                  __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                  if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6887, __pyx_L162_error)
                  __Pyx_GOTREF(__pyx_t_20);
                }
                __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;

                /* "ws_package/controllers/activity_controller.py":6890
 * 
 *                         # Mark intervals as uploaded
 *                         from ws_package.repositories.activity_repo import activity_manager             # <<<<<<<<<<<<<<
 *                         for interval in day_intervals:
 *                             try:
*/
                {
                  PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_activity_manager};
                  __pyx_t_18 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_repositories_activity, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_18)) __PYX_ERR(0, 6890, __pyx_L162_error)
                }
                __pyx_t_20 = __pyx_t_18;
                __Pyx_GOTREF(__pyx_t_20);
                {
                  PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_activity_manager};
                  __pyx_t_29 = 0; {
                    __pyx_t_9 = __Pyx_ImportFrom(__pyx_t_20, __pyx_imported_names[__pyx_t_29]); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6890, __pyx_L162_error)
                    __Pyx_GOTREF(__pyx_t_9);
                    switch (__pyx_t_29) {
                      case 0:
                      __Pyx_INCREF(__pyx_t_9);
                      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_activity_manager);
                      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_activity_manager, __pyx_t_9);
                      __Pyx_GIVEREF(__pyx_t_9);
                      break;
                      default:;
                    }
                    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                  }
                }
                __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;

                /* "ws_package/controllers/activity_controller.py":6891
 *                         # Mark intervals as uploaded
 *                         from ws_package.repositories.activity_repo import activity_manager
 *                         for interval in day_intervals:             # <<<<<<<<<<<<<<
 *                             try:
 *                                 await activity_manager.update_activity_interval(interval)
*/
                if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_day_intervals)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_day_intervals)) {
                  __pyx_t_20 = __pyx_cur_scope->__pyx_v_day_intervals; __Pyx_INCREF(__pyx_t_20);
                  __pyx_t_29 = 0;
                  __pyx_t_30 = NULL;
                } else {
                  __pyx_t_29 = -1; __pyx_t_20 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_day_intervals); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6891, __pyx_L162_error)
                  __Pyx_GOTREF(__pyx_t_20);
                  __pyx_t_30 = (CYTHON_COMPILING_IN_LIMITED_API) ? PyIter_Next : __Pyx_PyObject_GetIterNextFunc(__pyx_t_20); if (unlikely(!__pyx_t_30)) __PYX_ERR(0, 6891, __pyx_L162_error)
                }
                for (;;) {
                  if (likely(!__pyx_t_30)) {
                    if (likely(PyList_CheckExact(__pyx_t_20))) {
                      {
                        Py_ssize_t __pyx_temp = __Pyx_PyList_GET_SIZE(__pyx_t_20);
                        #if !CYTHON_ASSUME_SAFE_SIZE
                        if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6891, __pyx_L162_error)
                        #endif
                        if (__pyx_t_29 >= __pyx_temp) break;
                      }
                      __pyx_t_9 = __Pyx_PyList_GET_ITEM_REF(__pyx_t_20, __pyx_t_29, __Pyx_ReferenceSharing_OwnStrongReference);
                      ++__pyx_t_29;
                    } else {
                      {
                        Py_ssize_t __pyx_temp = __Pyx_PyTuple_GET_SIZE(__pyx_t_20);
                        #if !CYTHON_ASSUME_SAFE_SIZE
                        if (unlikely((__pyx_temp < 0))) __PYX_ERR(0, 6891, __pyx_L162_error)
                        #endif
                        if (__pyx_t_29 >= __pyx_temp) break;
                      }
                      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                      __pyx_t_9 = __Pyx_NewRef(PyTuple_GET_ITEM(__pyx_t_20, __pyx_t_29));
                      #else
                      __pyx_t_9 = __Pyx_PySequence_ITEM(__pyx_t_20, __pyx_t_29);
                      #endif
                      ++__pyx_t_29;
                    }
                    if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6891, __pyx_L162_error)
                  } else {
                    __pyx_t_9 = __pyx_t_30(__pyx_t_20);
                    if (unlikely(!__pyx_t_9)) {
                      PyObject* exc_type = PyErr_Occurred();
                      if (exc_type) {
                        if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) __PYX_ERR(0, 6891, __pyx_L162_error)
                        PyErr_Clear();
                      }
                      break;
                    }
                  }
                  __Pyx_GOTREF(__pyx_t_9);
                  __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_interval);
                  __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_interval, __pyx_t_9);
                  __Pyx_GIVEREF(__pyx_t_9);
                  __pyx_t_9 = 0;

                  /* "ws_package/controllers/activity_controller.py":6892
 *                         from ws_package.repositories.activity_repo import activity_manager
 *                         for interval in day_intervals:
 *                             try:             # <<<<<<<<<<<<<<
 *                                 await activity_manager.update_activity_interval(interval)
 *                                 success_count += 1
*/
                  {
                    __Pyx_ExceptionSave(&__pyx_t_18, &__pyx_t_31, &__pyx_t_24);
                    __Pyx_XGOTREF(__pyx_t_18);
                    __Pyx_XGOTREF(__pyx_t_31);
                    __Pyx_XGOTREF(__pyx_t_24);
                    /*try:*/ {

                      /* "ws_package/controllers/activity_controller.py":6893
 *                         for interval in day_intervals:
 *                             try:
 *                                 await activity_manager.update_activity_interval(interval)             # <<<<<<<<<<<<<<
 *                                 success_count += 1
 *                             except Exception as e:
*/
                      __pyx_t_22 = __pyx_cur_scope->__pyx_v_activity_manager;
                      __Pyx_INCREF(__pyx_t_22);
                      __pyx_t_10 = 0;
                      {
                        PyObject *__pyx_callargs[2] = {__pyx_t_22, __pyx_cur_scope->__pyx_v_interval};
                        __pyx_t_9 = __Pyx_PyObject_FastCallMethod((PyObject*)__pyx_mstate_global->__pyx_n_u_update_activity_interval, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (1*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
                        __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                        if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6893, __pyx_L172_error)
                        __Pyx_GOTREF(__pyx_t_9);
                      }
                      __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_9, &__pyx_r);
                      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                      if (likely(__pyx_t_11 == PYGEN_NEXT)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_XGIVEREF(__pyx_t_1);
                        __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
                        __Pyx_XGIVEREF(__pyx_t_2);
                        __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
                        __Pyx_XGIVEREF(__pyx_t_3);
                        __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
                        __Pyx_XGIVEREF(__pyx_t_7);
                        __pyx_cur_scope->__pyx_t_3 = __pyx_t_7;
                        __Pyx_XGIVEREF(__pyx_t_12);
                        __pyx_cur_scope->__pyx_t_4 = __pyx_t_12;
                        __Pyx_XGIVEREF(__pyx_t_13);
                        __pyx_cur_scope->__pyx_t_5 = __pyx_t_13;
                        __Pyx_XGIVEREF(__pyx_t_14);
                        __pyx_cur_scope->__pyx_t_6 = __pyx_t_14;
                        __Pyx_XGIVEREF(__pyx_t_15);
                        __pyx_cur_scope->__pyx_t_7 = __pyx_t_15;
                        __Pyx_XGIVEREF(__pyx_t_16);
                        __pyx_cur_scope->__pyx_t_8 = __pyx_t_16;
                        __Pyx_XGIVEREF(__pyx_t_18);
                        __pyx_cur_scope->__pyx_t_9 = __pyx_t_18;
                        __Pyx_XGIVEREF(__pyx_t_19);
                        __pyx_cur_scope->__pyx_t_10 = __pyx_t_19;
                        __Pyx_XGIVEREF(__pyx_t_20);
                        __pyx_cur_scope->__pyx_t_11 = __pyx_t_20;
                        __Pyx_XGIVEREF(__pyx_t_24);
                        __pyx_cur_scope->__pyx_t_12 = __pyx_t_24;
                        __pyx_cur_scope->__pyx_t_15 = __pyx_t_25;
                        __pyx_cur_scope->__pyx_t_16 = __pyx_t_26;
                        __pyx_cur_scope->__pyx_t_17 = __pyx_t_27;
                        __pyx_cur_scope->__pyx_t_25 = __pyx_t_29;
                        __pyx_cur_scope->__pyx_t_26 = __pyx_t_30;
                        __Pyx_XGIVEREF(__pyx_t_31);
                        __pyx_cur_scope->__pyx_t_13 = __pyx_t_31;
                        __Pyx_XGIVEREF(__pyx_r);
                        __Pyx_RefNannyFinishContext();
                        __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
                        /* return from generator, awaiting value */
                        __pyx_generator->resume_label = 14;
                        return __pyx_r;
                        __pyx_L180_resume_from_await:;
                        __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
                        __pyx_cur_scope->__pyx_t_0 = 0;
                        __Pyx_XGOTREF(__pyx_t_1);
                        __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
                        __pyx_cur_scope->__pyx_t_1 = 0;
                        __Pyx_XGOTREF(__pyx_t_2);
                        __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
                        __pyx_cur_scope->__pyx_t_2 = 0;
                        __Pyx_XGOTREF(__pyx_t_3);
                        __pyx_t_7 = __pyx_cur_scope->__pyx_t_3;
                        __pyx_cur_scope->__pyx_t_3 = 0;
                        __Pyx_XGOTREF(__pyx_t_7);
                        __pyx_t_12 = __pyx_cur_scope->__pyx_t_4;
                        __pyx_cur_scope->__pyx_t_4 = 0;
                        __Pyx_XGOTREF(__pyx_t_12);
                        __pyx_t_13 = __pyx_cur_scope->__pyx_t_5;
                        __pyx_cur_scope->__pyx_t_5 = 0;
                        __Pyx_XGOTREF(__pyx_t_13);
                        __pyx_t_14 = __pyx_cur_scope->__pyx_t_6;
                        __pyx_cur_scope->__pyx_t_6 = 0;
                        __Pyx_XGOTREF(__pyx_t_14);
                        __pyx_t_15 = __pyx_cur_scope->__pyx_t_7;
                        __pyx_cur_scope->__pyx_t_7 = 0;
                        __Pyx_XGOTREF(__pyx_t_15);
                        __pyx_t_16 = __pyx_cur_scope->__pyx_t_8;
                        __pyx_cur_scope->__pyx_t_8 = 0;
                        __Pyx_XGOTREF(__pyx_t_16);
                        __pyx_t_18 = __pyx_cur_scope->__pyx_t_9;
                        __pyx_cur_scope->__pyx_t_9 = 0;
                        __Pyx_XGOTREF(__pyx_t_18);
                        __pyx_t_19 = __pyx_cur_scope->__pyx_t_10;
                        __pyx_cur_scope->__pyx_t_10 = 0;
                        __Pyx_XGOTREF(__pyx_t_19);
                        __pyx_t_20 = __pyx_cur_scope->__pyx_t_11;
                        __pyx_cur_scope->__pyx_t_11 = 0;
                        __Pyx_XGOTREF(__pyx_t_20);
                        __pyx_t_24 = __pyx_cur_scope->__pyx_t_12;
                        __pyx_cur_scope->__pyx_t_12 = 0;
                        __Pyx_XGOTREF(__pyx_t_24);
                        __pyx_t_25 = __pyx_cur_scope->__pyx_t_15;
                        __pyx_t_26 = __pyx_cur_scope->__pyx_t_16;
                        __pyx_t_27 = __pyx_cur_scope->__pyx_t_17;
                        __pyx_t_29 = __pyx_cur_scope->__pyx_t_25;
                        __pyx_t_30 = __pyx_cur_scope->__pyx_t_26;
                        __pyx_t_31 = __pyx_cur_scope->__pyx_t_13;
                        __pyx_cur_scope->__pyx_t_13 = 0;
                        __Pyx_XGOTREF(__pyx_t_31);
                        if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6893, __pyx_L172_error)
                      } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
                        __Pyx_GOTREF(__pyx_r);
                        __Pyx_DECREF(__pyx_r); __pyx_r = 0;
                      } else {
                        __Pyx_XGOTREF(__pyx_r);
                        __PYX_ERR(0, 6893, __pyx_L172_error)
                      }

                      /* "ws_package/controllers/activity_controller.py":6894
 *                             try:
 *                                 await activity_manager.update_activity_interval(interval)
 *                                 success_count += 1             # <<<<<<<<<<<<<<
 *                             except Exception as e:
 *                                 logger.error("Error marking interval %s as uploaded: %s", interval.id, e, exc_info=True)
*/
                      __pyx_t_9 = __Pyx_PyLong_AddObjC(__pyx_cur_scope->__pyx_v_success_count, __pyx_mstate_global->__pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6894, __pyx_L172_error)
                      __Pyx_GOTREF(__pyx_t_9);
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_success_count);
                      __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_success_count, __pyx_t_9);
                      __Pyx_GIVEREF(__pyx_t_9);
                      __pyx_t_9 = 0;

                      /* "ws_package/controllers/activity_controller.py":6892
 *                         from ws_package.repositories.activity_repo import activity_manager
 *                         for interval in day_intervals:
 *                             try:             # <<<<<<<<<<<<<<
 *                                 await activity_manager.update_activity_interval(interval)
 *                                 success_count += 1
*/
                    }
                    __Pyx_XDECREF(__pyx_t_18); __pyx_t_18 = 0;
                    __Pyx_XDECREF(__pyx_t_31); __pyx_t_31 = 0;
                    __Pyx_XDECREF(__pyx_t_24); __pyx_t_24 = 0;
                    goto __pyx_L179_try_end;
                    __pyx_L172_error:;
                    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_XDECREF(__pyx_t_42); __pyx_t_42 = 0;
                    __Pyx_XDECREF(__pyx_t_44); __pyx_t_44 = 0;
                    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

                    /* "ws_package/controllers/activity_controller.py":6895
 *                                 await activity_manager.update_activity_interval(interval)
 *                                 success_count += 1
 *                             except Exception as e:             # <<<<<<<<<<<<<<
 *                                 logger.error("Error marking interval %s as uploaded: %s", interval.id, e, exc_info=True)
 *                                 failed_count += 1
*/
                    __pyx_t_28 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
                    if (__pyx_t_28) {
                      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._idle_reassign", __pyx_clineno, __pyx_lineno, __pyx_filename);
                      if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_22, &__pyx_t_23) < 0) __PYX_ERR(0, 6895, __pyx_L174_except_error)
                      __Pyx_XGOTREF(__pyx_t_9);
                      __Pyx_XGOTREF(__pyx_t_22);
                      __Pyx_XGOTREF(__pyx_t_23);
                      __Pyx_INCREF(__pyx_t_22);
                      __Pyx_GIVEREF(__pyx_t_22);
                      __pyx_cur_scope->__pyx_v_e = __pyx_t_22;
                      /*try:*/ {

                        /* "ws_package/controllers/activity_controller.py":6896
 *                                 success_count += 1
 *                             except Exception as e:
 *                                 logger.error("Error marking interval %s as uploaded: %s", interval.id, e, exc_info=True)             # <<<<<<<<<<<<<<
 *                                 failed_count += 1
 * 
*/
                        __pyx_t_8 = NULL;
                        __Pyx_GetModuleGlobalName(__pyx_t_44, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_44)) __PYX_ERR(0, 6896, __pyx_L186_error)
                        __Pyx_GOTREF(__pyx_t_44);
                        __pyx_t_42 = __Pyx_PyObject_GetAttrStr(__pyx_t_44, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_42)) __PYX_ERR(0, 6896, __pyx_L186_error)
                        __Pyx_GOTREF(__pyx_t_42);
                        __Pyx_DECREF(__pyx_t_44); __pyx_t_44 = 0;
                        __pyx_t_44 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_interval, __pyx_mstate_global->__pyx_n_u_id); if (unlikely(!__pyx_t_44)) __PYX_ERR(0, 6896, __pyx_L186_error)
                        __Pyx_GOTREF(__pyx_t_44);
                        __pyx_t_10 = 1;
                        #if CYTHON_UNPACK_METHODS
                        if (unlikely(PyMethod_Check(__pyx_t_42))) {
                          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_42);
                          assert(__pyx_t_8);
                          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_42);
                          __Pyx_INCREF(__pyx_t_8);
                          __Pyx_INCREF(__pyx__function);
                          __Pyx_DECREF_SET(__pyx_t_42, __pyx__function);
                          __pyx_t_10 = 0;
                        }
                        #endif
                        {
                          PyObject *__pyx_callargs[4 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_8, __pyx_mstate_global->__pyx_kp_u_Error_marking_interval_s_as_uplo, __pyx_t_44, __pyx_cur_scope->__pyx_v_e};
                          __pyx_t_4 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6896, __pyx_L186_error)
                          __Pyx_GOTREF(__pyx_t_4);
                          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_4, __pyx_callargs+4, 0) < (0)) __PYX_ERR(0, 6896, __pyx_L186_error)
                          __pyx_t_21 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_42, __pyx_callargs+__pyx_t_10, (4-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_4);
                          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                          __Pyx_DECREF(__pyx_t_44); __pyx_t_44 = 0;
                          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                          __Pyx_DECREF(__pyx_t_42); __pyx_t_42 = 0;
                          if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6896, __pyx_L186_error)
                          __Pyx_GOTREF(__pyx_t_21);
                        }
                        __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;

                        /* "ws_package/controllers/activity_controller.py":6897
 *                             except Exception as e:
 *                                 logger.error("Error marking interval %s as uploaded: %s", interval.id, e, exc_info=True)
 *                                 failed_count += 1             # <<<<<<<<<<<<<<
 * 
 *                     except Exception as e:
*/
                        __pyx_t_21 = __Pyx_PyLong_AddObjC(__pyx_cur_scope->__pyx_v_failed_count, __pyx_mstate_global->__pyx_int_1, 1, 1, 0); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6897, __pyx_L186_error)
                        __Pyx_GOTREF(__pyx_t_21);
                        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_failed_count);
                        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_failed_count, __pyx_t_21);
                        __Pyx_GIVEREF(__pyx_t_21);
                        __pyx_t_21 = 0;
                      }

                      /* "ws_package/controllers/activity_controller.py":6895
 *                                 await activity_manager.update_activity_interval(interval)
 *                                 success_count += 1
 *                             except Exception as e:             # <<<<<<<<<<<<<<
 *                                 logger.error("Error marking interval %s as uploaded: %s", interval.id, e, exc_info=True)
 *                                 failed_count += 1
*/
                      /*finally:*/ {
                        /*normal exit:*/{
                          __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                          __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                          goto __pyx_L187;
                        }
                        __pyx_L186_error:;
                        /*exception exit:*/{
                          __Pyx_PyThreadState_assign
                          __pyx_t_17 = 0; __pyx_t_32 = 0; __pyx_t_35 = 0; __pyx_t_34 = 0; __pyx_t_33 = 0; __pyx_t_38 = 0;
                          __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                          __Pyx_XDECREF(__pyx_t_42); __pyx_t_42 = 0;
                          __Pyx_XDECREF(__pyx_t_44); __pyx_t_44 = 0;
                          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                           __Pyx_ExceptionSwap(&__pyx_t_34, &__pyx_t_33, &__pyx_t_38);
                          if ( unlikely(__Pyx_GetException(&__pyx_t_17, &__pyx_t_32, &__pyx_t_35) < 0)) __Pyx_ErrFetch(&__pyx_t_17, &__pyx_t_32, &__pyx_t_35);
                          __Pyx_XGOTREF(__pyx_t_17);
                          __Pyx_XGOTREF(__pyx_t_32);
                          __Pyx_XGOTREF(__pyx_t_35);
                          __Pyx_XGOTREF(__pyx_t_34);
                          __Pyx_XGOTREF(__pyx_t_33);
                          __Pyx_XGOTREF(__pyx_t_38);
                          __pyx_t_28 = __pyx_lineno; __pyx_t_39 = __pyx_clineno; __pyx_t_46 = __pyx_filename;
                          {
                            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                          }
                          __Pyx_XGIVEREF(__pyx_t_34);
                          __Pyx_XGIVEREF(__pyx_t_33);
                          __Pyx_XGIVEREF(__pyx_t_38);
                          __Pyx_ExceptionReset(__pyx_t_34, __pyx_t_33, __pyx_t_38);
                          __Pyx_XGIVEREF(__pyx_t_17);
                          __Pyx_XGIVEREF(__pyx_t_32);
                          __Pyx_XGIVEREF(__pyx_t_35);
                          __Pyx_ErrRestore(__pyx_t_17, __pyx_t_32, __pyx_t_35);
                          __pyx_t_17 = 0; __pyx_t_32 = 0; __pyx_t_35 = 0; __pyx_t_34 = 0; __pyx_t_33 = 0; __pyx_t_38 = 0;
                          __pyx_lineno = __pyx_t_28; __pyx_clineno = __pyx_t_39; __pyx_filename = __pyx_t_46;
                          goto __pyx_L174_except_error;
                        }
                        __pyx_L187:;
                      }
                      __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                      __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                      __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                      goto __pyx_L173_exception_handled;
                    }
                    goto __pyx_L174_except_error;

                    /* "ws_package/controllers/activity_controller.py":6892
 *                         from ws_package.repositories.activity_repo import activity_manager
 *                         for interval in day_intervals:
 *                             try:             # <<<<<<<<<<<<<<
 *                                 await activity_manager.update_activity_interval(interval)
 *                                 success_count += 1
*/
                    __pyx_L174_except_error:;
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __Pyx_XGIVEREF(__pyx_t_31);
                    __Pyx_XGIVEREF(__pyx_t_24);
                    __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_31, __pyx_t_24);
                    goto __pyx_L162_error;
                    __pyx_L173_exception_handled:;
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __Pyx_XGIVEREF(__pyx_t_31);
                    __Pyx_XGIVEREF(__pyx_t_24);
                    __Pyx_ExceptionReset(__pyx_t_18, __pyx_t_31, __pyx_t_24);
                    __pyx_L179_try_end:;
                  }

                  /* "ws_package/controllers/activity_controller.py":6891
 *                         # Mark intervals as uploaded
 *                         from ws_package.repositories.activity_repo import activity_manager
 *                         for interval in day_intervals:             # <<<<<<<<<<<<<<
 *                             try:
 *                                 await activity_manager.update_activity_interval(interval)
*/
                }
                __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;

                /* "ws_package/controllers/activity_controller.py":6885
 * 
 *                     # Send to API
 *                     try:             # <<<<<<<<<<<<<<
 *                         response = self.activity_service.push_activity_logs(payload)
 *                         logger.info("Successfully sent idle intervals for date %s to API", target_date)
*/
              }
              __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
              __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
              __Pyx_XDECREF(__pyx_t_19); __pyx_t_19 = 0;
              goto __pyx_L169_try_end;
              __pyx_L162_error:;
              __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
              __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
              __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
              __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
              __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_XDECREF(__pyx_t_42); __pyx_t_42 = 0;
              __Pyx_XDECREF(__pyx_t_44); __pyx_t_44 = 0;
              __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
              __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

              /* "ws_package/controllers/activity_controller.py":6899
 *                                 failed_count += 1
 * 
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error sending idle intervals to API for date %s: %s", target_date, e, exc_info=True)
 *                         failed_count += len(day_intervals)
*/
              __pyx_t_39 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
              if (__pyx_t_39) {
                __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._idle_reassign", __pyx_clineno, __pyx_lineno, __pyx_filename);
                if (__Pyx_GetException(&__pyx_t_20, &__pyx_t_23, &__pyx_t_22) < 0) __PYX_ERR(0, 6899, __pyx_L164_except_error)
                __Pyx_XGOTREF(__pyx_t_20);
                __Pyx_XGOTREF(__pyx_t_23);
                __Pyx_XGOTREF(__pyx_t_22);
                __Pyx_INCREF(__pyx_t_23);
                __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
                __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_23);
                __Pyx_GIVEREF(__pyx_t_23);
                /*try:*/ {

                  /* "ws_package/controllers/activity_controller.py":6900
 * 
 *                     except Exception as e:
 *                         logger.error("Error sending idle intervals to API for date %s: %s", target_date, e, exc_info=True)             # <<<<<<<<<<<<<<
 *                         failed_count += len(day_intervals)
 * 
*/
                  __pyx_t_21 = NULL;
                  __Pyx_GetModuleGlobalName(__pyx_t_42, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_42)) __PYX_ERR(0, 6900, __pyx_L198_error)
                  __Pyx_GOTREF(__pyx_t_42);
                  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_42, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6900, __pyx_L198_error)
                  __Pyx_GOTREF(__pyx_t_4);
                  __Pyx_DECREF(__pyx_t_42); __pyx_t_42 = 0;
                  __pyx_t_10 = 1;
                  #if CYTHON_UNPACK_METHODS
                  if (unlikely(PyMethod_Check(__pyx_t_4))) {
                    __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_4);
                    assert(__pyx_t_21);
                    PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_4);
                    __Pyx_INCREF(__pyx_t_21);
                    __Pyx_INCREF(__pyx__function);
                    __Pyx_DECREF_SET(__pyx_t_4, __pyx__function);
                    __pyx_t_10 = 0;
                  }
                  #endif
                  {
                    PyObject *__pyx_callargs[4 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_21, __pyx_mstate_global->__pyx_kp_u_Error_sending_idle_intervals_to, __pyx_cur_scope->__pyx_v_target_date, __pyx_cur_scope->__pyx_v_e};
                    __pyx_t_42 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_42)) __PYX_ERR(0, 6900, __pyx_L198_error)
                    __Pyx_GOTREF(__pyx_t_42);
                    if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_42, __pyx_callargs+4, 0) < (0)) __PYX_ERR(0, 6900, __pyx_L198_error)
                    __pyx_t_9 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_4, __pyx_callargs+__pyx_t_10, (4-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_42);
                    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_DECREF(__pyx_t_42); __pyx_t_42 = 0;
                    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                    if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6900, __pyx_L198_error)
                    __Pyx_GOTREF(__pyx_t_9);
                  }
                  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;

                  /* "ws_package/controllers/activity_controller.py":6901
 *                     except Exception as e:
 *                         logger.error("Error sending idle intervals to API for date %s: %s", target_date, e, exc_info=True)
 *                         failed_count += len(day_intervals)             # <<<<<<<<<<<<<<
 * 
 *                 except Exception as e:
*/
                  __pyx_t_29 = PyObject_Length(__pyx_cur_scope->__pyx_v_day_intervals); if (unlikely(__pyx_t_29 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6901, __pyx_L198_error)
                  __pyx_t_9 = PyLong_FromSsize_t(__pyx_t_29); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 6901, __pyx_L198_error)
                  __Pyx_GOTREF(__pyx_t_9);
                  __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_cur_scope->__pyx_v_failed_count, __pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6901, __pyx_L198_error)
                  __Pyx_GOTREF(__pyx_t_4);
                  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_failed_count);
                  __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_failed_count, __pyx_t_4);
                  __Pyx_GIVEREF(__pyx_t_4);
                  __pyx_t_4 = 0;
                }

                /* "ws_package/controllers/activity_controller.py":6899
 *                                 failed_count += 1
 * 
 *                     except Exception as e:             # <<<<<<<<<<<<<<
 *                         logger.error("Error sending idle intervals to API for date %s: %s", target_date, e, exc_info=True)
 *                         failed_count += len(day_intervals)
*/
                /*finally:*/ {
                  /*normal exit:*/{
                    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                    __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    goto __pyx_L199;
                  }
                  __pyx_L198_error:;
                  /*exception exit:*/{
                    __Pyx_PyThreadState_assign
                    __pyx_t_24 = 0; __pyx_t_31 = 0; __pyx_t_18 = 0; __pyx_t_38 = 0; __pyx_t_33 = 0; __pyx_t_34 = 0;
                    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                    __Pyx_XDECREF(__pyx_t_42); __pyx_t_42 = 0;
                    __Pyx_XDECREF(__pyx_t_44); __pyx_t_44 = 0;
                    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                     __Pyx_ExceptionSwap(&__pyx_t_38, &__pyx_t_33, &__pyx_t_34);
                    if ( unlikely(__Pyx_GetException(&__pyx_t_24, &__pyx_t_31, &__pyx_t_18) < 0)) __Pyx_ErrFetch(&__pyx_t_24, &__pyx_t_31, &__pyx_t_18);
                    __Pyx_XGOTREF(__pyx_t_24);
                    __Pyx_XGOTREF(__pyx_t_31);
                    __Pyx_XGOTREF(__pyx_t_18);
                    __Pyx_XGOTREF(__pyx_t_38);
                    __Pyx_XGOTREF(__pyx_t_33);
                    __Pyx_XGOTREF(__pyx_t_34);
                    __pyx_t_39 = __pyx_lineno; __pyx_t_28 = __pyx_clineno; __pyx_t_47 = __pyx_filename;
                    {
                      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                      __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                    }
                    __Pyx_XGIVEREF(__pyx_t_38);
                    __Pyx_XGIVEREF(__pyx_t_33);
                    __Pyx_XGIVEREF(__pyx_t_34);
                    __Pyx_ExceptionReset(__pyx_t_38, __pyx_t_33, __pyx_t_34);
                    __Pyx_XGIVEREF(__pyx_t_24);
                    __Pyx_XGIVEREF(__pyx_t_31);
                    __Pyx_XGIVEREF(__pyx_t_18);
                    __Pyx_ErrRestore(__pyx_t_24, __pyx_t_31, __pyx_t_18);
                    __pyx_t_24 = 0; __pyx_t_31 = 0; __pyx_t_18 = 0; __pyx_t_38 = 0; __pyx_t_33 = 0; __pyx_t_34 = 0;
                    __pyx_lineno = __pyx_t_39; __pyx_clineno = __pyx_t_28; __pyx_filename = __pyx_t_47;
                    goto __pyx_L164_except_error;
                  }
                  __pyx_L199:;
                }
                __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
                __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
                __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
                goto __pyx_L163_exception_handled;
              }
              goto __pyx_L164_except_error;

              /* "ws_package/controllers/activity_controller.py":6885
 * 
 *                     # Send to API
 *                     try:             # <<<<<<<<<<<<<<
 *                         response = self.activity_service.push_activity_logs(payload)
 *                         logger.info("Successfully sent idle intervals for date %s to API", target_date)
*/
              __pyx_L164_except_error:;
              __Pyx_XGIVEREF(__pyx_t_13);
              __Pyx_XGIVEREF(__pyx_t_16);
              __Pyx_XGIVEREF(__pyx_t_19);
              __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_16, __pyx_t_19);
              goto __pyx_L49_error;
              __pyx_L163_exception_handled:;
              __Pyx_XGIVEREF(__pyx_t_13);
              __Pyx_XGIVEREF(__pyx_t_16);
              __Pyx_XGIVEREF(__pyx_t_19);
              __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_16, __pyx_t_19);
              __pyx_L169_try_end:;
            }

            /* "ws_package/controllers/activity_controller.py":6775
 * 
 *             for target_date, day_intervals in grouped_intervals.items():
 *                 try:             # <<<<<<<<<<<<<<
 *                     logger.info("Processing %s idle intervals for date %s", len(day_intervals), target_date)
 * 
*/
          }
          __Pyx_XDECREF(__pyx_t_12); __pyx_t_12 = 0;
          __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
          __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
          goto __pyx_L56_try_end;
          __pyx_L49_error:;
          __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
          __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
          __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_42); __pyx_t_42 = 0;
          __Pyx_XDECREF(__pyx_t_44); __pyx_t_44 = 0;
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

          /* "ws_package/controllers/activity_controller.py":6903
 *                         failed_count += len(day_intervals)
 * 
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Error processing day %s for reassign: %s", target_date, e, exc_info=True)
 *                     failed_count += len(day_intervals)
*/
          __pyx_t_28 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
          if (__pyx_t_28) {
            __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._idle_reassign", __pyx_clineno, __pyx_lineno, __pyx_filename);
            if (__Pyx_GetException(&__pyx_t_22, &__pyx_t_23, &__pyx_t_20) < 0) __PYX_ERR(0, 6903, __pyx_L51_except_error)
            __Pyx_XGOTREF(__pyx_t_22);
            __Pyx_XGOTREF(__pyx_t_23);
            __Pyx_XGOTREF(__pyx_t_20);
            __Pyx_INCREF(__pyx_t_23);
            __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_23);
            __Pyx_GIVEREF(__pyx_t_23);
            /*try:*/ {

              /* "ws_package/controllers/activity_controller.py":6904
 * 
 *                 except Exception as e:
 *                     logger.error("Error processing day %s for reassign: %s", target_date, e, exc_info=True)             # <<<<<<<<<<<<<<
 *                     failed_count += len(day_intervals)
 * 
*/
              __pyx_t_9 = NULL;
              __Pyx_GetModuleGlobalName(__pyx_t_42, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_42)) __PYX_ERR(0, 6904, __pyx_L209_error)
              __Pyx_GOTREF(__pyx_t_42);
              __pyx_t_21 = __Pyx_PyObject_GetAttrStr(__pyx_t_42, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6904, __pyx_L209_error)
              __Pyx_GOTREF(__pyx_t_21);
              __Pyx_DECREF(__pyx_t_42); __pyx_t_42 = 0;
              __pyx_t_10 = 1;
              #if CYTHON_UNPACK_METHODS
              if (unlikely(PyMethod_Check(__pyx_t_21))) {
                __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_21);
                assert(__pyx_t_9);
                PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_21);
                __Pyx_INCREF(__pyx_t_9);
                __Pyx_INCREF(__pyx__function);
                __Pyx_DECREF_SET(__pyx_t_21, __pyx__function);
                __pyx_t_10 = 0;
              }
              #endif
              {
                PyObject *__pyx_callargs[4 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_9, __pyx_mstate_global->__pyx_kp_u_Error_processing_day_s_for_reass, __pyx_cur_scope->__pyx_v_target_date, __pyx_cur_scope->__pyx_v_e};
                __pyx_t_42 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_42)) __PYX_ERR(0, 6904, __pyx_L209_error)
                __Pyx_GOTREF(__pyx_t_42);
                if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_42, __pyx_callargs+4, 0) < (0)) __PYX_ERR(0, 6904, __pyx_L209_error)
                __pyx_t_4 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_21, __pyx_callargs+__pyx_t_10, (4-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_42);
                __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                __Pyx_DECREF(__pyx_t_42); __pyx_t_42 = 0;
                __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6904, __pyx_L209_error)
                __Pyx_GOTREF(__pyx_t_4);
              }
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

              /* "ws_package/controllers/activity_controller.py":6905
 *                 except Exception as e:
 *                     logger.error("Error processing day %s for reassign: %s", target_date, e, exc_info=True)
 *                     failed_count += len(day_intervals)             # <<<<<<<<<<<<<<
 * 
 *             # Flush queue to ensure all updates are processed
*/
              __pyx_t_29 = PyObject_Length(__pyx_cur_scope->__pyx_v_day_intervals); if (unlikely(__pyx_t_29 == ((Py_ssize_t)-1))) __PYX_ERR(0, 6905, __pyx_L209_error)
              __pyx_t_4 = PyLong_FromSsize_t(__pyx_t_29); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6905, __pyx_L209_error)
              __Pyx_GOTREF(__pyx_t_4);
              __pyx_t_21 = PyNumber_InPlaceAdd(__pyx_cur_scope->__pyx_v_failed_count, __pyx_t_4); if (unlikely(!__pyx_t_21)) __PYX_ERR(0, 6905, __pyx_L209_error)
              __Pyx_GOTREF(__pyx_t_21);
              __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
              __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_failed_count);
              __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_failed_count, __pyx_t_21);
              __Pyx_GIVEREF(__pyx_t_21);
              __pyx_t_21 = 0;
            }

            /* "ws_package/controllers/activity_controller.py":6903
 *                         failed_count += len(day_intervals)
 * 
 *                 except Exception as e:             # <<<<<<<<<<<<<<
 *                     logger.error("Error processing day %s for reassign: %s", target_date, e, exc_info=True)
 *                     failed_count += len(day_intervals)
*/
            /*finally:*/ {
              /*normal exit:*/{
                __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                goto __pyx_L210;
              }
              __pyx_L209_error:;
              /*exception exit:*/{
                __Pyx_PyThreadState_assign
                __pyx_t_19 = 0; __pyx_t_16 = 0; __pyx_t_13 = 0; __pyx_t_34 = 0; __pyx_t_33 = 0; __pyx_t_38 = 0;
                __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
                __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
                __Pyx_XDECREF(__pyx_t_42); __pyx_t_42 = 0;
                __Pyx_XDECREF(__pyx_t_44); __pyx_t_44 = 0;
                __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
                __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
                 __Pyx_ExceptionSwap(&__pyx_t_34, &__pyx_t_33, &__pyx_t_38);
                if ( unlikely(__Pyx_GetException(&__pyx_t_19, &__pyx_t_16, &__pyx_t_13) < 0)) __Pyx_ErrFetch(&__pyx_t_19, &__pyx_t_16, &__pyx_t_13);
                __Pyx_XGOTREF(__pyx_t_19);
                __Pyx_XGOTREF(__pyx_t_16);
                __Pyx_XGOTREF(__pyx_t_13);
                __Pyx_XGOTREF(__pyx_t_34);
                __Pyx_XGOTREF(__pyx_t_33);
                __Pyx_XGOTREF(__pyx_t_38);
                __pyx_t_28 = __pyx_lineno; __pyx_t_39 = __pyx_clineno; __pyx_t_48 = __pyx_filename;
                {
                  __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
                  __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
                }
                __Pyx_XGIVEREF(__pyx_t_34);
                __Pyx_XGIVEREF(__pyx_t_33);
                __Pyx_XGIVEREF(__pyx_t_38);
                __Pyx_ExceptionReset(__pyx_t_34, __pyx_t_33, __pyx_t_38);
                __Pyx_XGIVEREF(__pyx_t_19);
                __Pyx_XGIVEREF(__pyx_t_16);
                __Pyx_XGIVEREF(__pyx_t_13);
                __Pyx_ErrRestore(__pyx_t_19, __pyx_t_16, __pyx_t_13);
                __pyx_t_19 = 0; __pyx_t_16 = 0; __pyx_t_13 = 0; __pyx_t_34 = 0; __pyx_t_33 = 0; __pyx_t_38 = 0;
                __pyx_lineno = __pyx_t_28; __pyx_clineno = __pyx_t_39; __pyx_filename = __pyx_t_48;
                goto __pyx_L51_except_error;
              }
              __pyx_L210:;
            }
            __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
            __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
            __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
            goto __pyx_L50_exception_handled;
          }
          goto __pyx_L51_except_error;

          /* "ws_package/controllers/activity_controller.py":6775
 * 
 *             for target_date, day_intervals in grouped_intervals.items():
 *                 try:             # <<<<<<<<<<<<<<
 *                     logger.info("Processing %s idle intervals for date %s", len(day_intervals), target_date)
 * 
*/
          __pyx_L51_except_error:;
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_15, __pyx_t_14);
          goto __pyx_L4_error;
          __pyx_L55_try_continue:;
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_15, __pyx_t_14);
          goto __pyx_L47_continue;
          __pyx_L50_exception_handled:;
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_ExceptionReset(__pyx_t_12, __pyx_t_15, __pyx_t_14);
          __pyx_L56_try_end:;
        }
        __pyx_L47_continue:;
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "ws_package/controllers/activity_controller.py":6908
 * 
 *             # Flush queue to ensure all updates are processed
 *             if success_count > 0:             # <<<<<<<<<<<<<<
 *                 logger.info("Flushing database write queue to process %s is_uploaded updates...", success_count)
 *                 await db_writer_service.process_immediately()
*/
      __pyx_t_7 = PyObject_RichCompare(__pyx_cur_scope->__pyx_v_success_count, __pyx_mstate_global->__pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6908, __pyx_L4_error)
      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely((__pyx_t_5 < 0))) __PYX_ERR(0, 6908, __pyx_L4_error)
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
      if (__pyx_t_5) {

        /* "ws_package/controllers/activity_controller.py":6909
 *             # Flush queue to ensure all updates are processed
 *             if success_count > 0:
 *                 logger.info("Flushing database write queue to process %s is_uploaded updates...", success_count)             # <<<<<<<<<<<<<<
 *                 await db_writer_service.process_immediately()
 *                 await asyncio.sleep(0.5)
*/
        __pyx_t_20 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6909, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_23);
        __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6909, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_22);
        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_22))) {
          __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_22);
          assert(__pyx_t_20);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_22);
          __Pyx_INCREF(__pyx_t_20);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_22, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3] = {__pyx_t_20, __pyx_mstate_global->__pyx_kp_u_Flushing_database_write_queue_to_2, __pyx_cur_scope->__pyx_v_success_count};
          __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_22, __pyx_callargs+__pyx_t_10, (3-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
          __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6909, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

        /* "ws_package/controllers/activity_controller.py":6910
 *             if success_count > 0:
 *                 logger.info("Flushing database write queue to process %s is_uploaded updates...", success_count)
 *                 await db_writer_service.process_immediately()             # <<<<<<<<<<<<<<
 *                 await asyncio.sleep(0.5)
 * 
*/
        __pyx_t_22 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_db_writer_service); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6910, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_20);
        __pyx_t_23 = __Pyx_PyObject_GetAttrStr(__pyx_t_20, __pyx_mstate_global->__pyx_n_u_process_immediately); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6910, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_23);
        __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_23))) {
          __pyx_t_22 = PyMethod_GET_SELF(__pyx_t_23);
          assert(__pyx_t_22);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_23);
          __Pyx_INCREF(__pyx_t_22);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_23, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_22, NULL};
          __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_23, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
          __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6910, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7, &__pyx_r);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (likely(__pyx_t_11 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_1);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
          __Pyx_XGIVEREF(__pyx_t_2);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
          __Pyx_XGIVEREF(__pyx_t_3);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 15;
          return __pyx_r;
          __pyx_L216_resume_from_await:;
          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_1);
          __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_2);
          __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_3);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6910, __pyx_L4_error)
        } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_DECREF(__pyx_r); __pyx_r = 0;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 6910, __pyx_L4_error)
        }

        /* "ws_package/controllers/activity_controller.py":6911
 *                 logger.info("Flushing database write queue to process %s is_uploaded updates...", success_count)
 *                 await db_writer_service.process_immediately()
 *                 await asyncio.sleep(0.5)             # <<<<<<<<<<<<<<
 * 
 *             logger.info("=== Idle reassign completed: %s intervals reassigned successfully, %s failed ===", success_count, failed_count)
*/
        __pyx_t_23 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_asyncio); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6911, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_22);
        __pyx_t_20 = __Pyx_PyObject_GetAttrStr(__pyx_t_22, __pyx_mstate_global->__pyx_n_u_sleep); if (unlikely(!__pyx_t_20)) __PYX_ERR(0, 6911, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_20);
        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_20))) {
          __pyx_t_23 = PyMethod_GET_SELF(__pyx_t_20);
          assert(__pyx_t_23);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_20);
          __Pyx_INCREF(__pyx_t_23);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_20, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[2] = {__pyx_t_23, __pyx_mstate_global->__pyx_float_0_5};
          __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_20, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
          if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6911, __pyx_L4_error)
          __Pyx_GOTREF(__pyx_t_7);
        }
        __pyx_t_11 = __Pyx_Coroutine_Yield_From(__pyx_generator, __pyx_t_7, &__pyx_r);
        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
        if (likely(__pyx_t_11 == PYGEN_NEXT)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_XGIVEREF(__pyx_t_1);
          __pyx_cur_scope->__pyx_t_0 = __pyx_t_1;
          __Pyx_XGIVEREF(__pyx_t_2);
          __pyx_cur_scope->__pyx_t_1 = __pyx_t_2;
          __Pyx_XGIVEREF(__pyx_t_3);
          __pyx_cur_scope->__pyx_t_2 = __pyx_t_3;
          __Pyx_XGIVEREF(__pyx_r);
          __Pyx_RefNannyFinishContext();
          __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
          /* return from generator, awaiting value */
          __pyx_generator->resume_label = 16;
          return __pyx_r;
          __pyx_L217_resume_from_await:;
          __pyx_t_1 = __pyx_cur_scope->__pyx_t_0;
          __pyx_cur_scope->__pyx_t_0 = 0;
          __Pyx_XGOTREF(__pyx_t_1);
          __pyx_t_2 = __pyx_cur_scope->__pyx_t_1;
          __pyx_cur_scope->__pyx_t_1 = 0;
          __Pyx_XGOTREF(__pyx_t_2);
          __pyx_t_3 = __pyx_cur_scope->__pyx_t_2;
          __pyx_cur_scope->__pyx_t_2 = 0;
          __Pyx_XGOTREF(__pyx_t_3);
          if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 6911, __pyx_L4_error)
        } else if (likely(__pyx_t_11 == PYGEN_RETURN)) {
          __Pyx_GOTREF(__pyx_r);
          __Pyx_DECREF(__pyx_r); __pyx_r = 0;
        } else {
          __Pyx_XGOTREF(__pyx_r);
          __PYX_ERR(0, 6911, __pyx_L4_error)
        }

        /* "ws_package/controllers/activity_controller.py":6908
 * 
 *             # Flush queue to ensure all updates are processed
 *             if success_count > 0:             # <<<<<<<<<<<<<<
 *                 logger.info("Flushing database write queue to process %s is_uploaded updates...", success_count)
 *                 await db_writer_service.process_immediately()
*/
      }

      /* "ws_package/controllers/activity_controller.py":6913
 *                 await asyncio.sleep(0.5)
 * 
 *             logger.info("=== Idle reassign completed: %s intervals reassigned successfully, %s failed ===", success_count, failed_count)             # <<<<<<<<<<<<<<
 * 
 *         except Exception as e:
*/
      __pyx_t_20 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6913, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_23);
      __pyx_t_22 = __Pyx_PyObject_GetAttrStr(__pyx_t_23, __pyx_mstate_global->__pyx_n_u_info); if (unlikely(!__pyx_t_22)) __PYX_ERR(0, 6913, __pyx_L4_error)
      __Pyx_GOTREF(__pyx_t_22);
      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
      __pyx_t_10 = 1;
      #if CYTHON_UNPACK_METHODS
      if (unlikely(PyMethod_Check(__pyx_t_22))) {
        __pyx_t_20 = PyMethod_GET_SELF(__pyx_t_22);
        assert(__pyx_t_20);
        PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_22);
        __Pyx_INCREF(__pyx_t_20);
        __Pyx_INCREF(__pyx__function);
        __Pyx_DECREF_SET(__pyx_t_22, __pyx__function);
        __pyx_t_10 = 0;
      }
      #endif
      {
        PyObject *__pyx_callargs[4] = {__pyx_t_20, __pyx_mstate_global->__pyx_kp_u_Idle_reassign_completed_s_inter, __pyx_cur_scope->__pyx_v_success_count, __pyx_cur_scope->__pyx_v_failed_count};
        __pyx_t_7 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_22, __pyx_callargs+__pyx_t_10, (4-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
        __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
        if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 6913, __pyx_L4_error)
        __Pyx_GOTREF(__pyx_t_7);
      }
      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;

      /* "ws_package/controllers/activity_controller.py":6737
 *             task_id: Task ID to assign idle intervals to (optional, defaults to "0" if not provided)
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # Convert task_id to string, default to "0" if None
 *             task_id_str = str(task_id) if task_id is not None and task_id != "" else "0"
*/
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
    goto __pyx_L9_try_end;
    __pyx_L4_error:;
    __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
    __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
    __Pyx_XDECREF(__pyx_t_22); __pyx_t_22 = 0;
    __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_42); __pyx_t_42 = 0;
    __Pyx_XDECREF(__pyx_t_44); __pyx_t_44 = 0;
    __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "ws_package/controllers/activity_controller.py":6915
 *             logger.info("=== Idle reassign completed: %s intervals reassigned successfully, %s failed ===", success_count, failed_count)
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error in _idle_reassign: %s", e, exc_info=True)
 *             raise
*/
    __pyx_t_27 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_Exception))));
    if (__pyx_t_27) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller.ActivityController._idle_reassign", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_22, &__pyx_t_20) < 0) __PYX_ERR(0, 6915, __pyx_L6_except_error)
      __Pyx_XGOTREF(__pyx_t_7);
      __Pyx_XGOTREF(__pyx_t_22);
      __Pyx_XGOTREF(__pyx_t_20);
      __Pyx_INCREF(__pyx_t_22);
      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e);
      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_22);
      __Pyx_GIVEREF(__pyx_t_22);
      /*try:*/ {

        /* "ws_package/controllers/activity_controller.py":6916
 * 
 *         except Exception as e:
 *             logger.error("Error in _idle_reassign: %s", e, exc_info=True)             # <<<<<<<<<<<<<<
 *             raise
*/
        __pyx_t_21 = NULL;
        __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_logger); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6916, __pyx_L223_error)
        __Pyx_GOTREF(__pyx_t_4);
        __pyx_t_42 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_error); if (unlikely(!__pyx_t_42)) __PYX_ERR(0, 6916, __pyx_L223_error)
        __Pyx_GOTREF(__pyx_t_42);
        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        __pyx_t_10 = 1;
        #if CYTHON_UNPACK_METHODS
        if (unlikely(PyMethod_Check(__pyx_t_42))) {
          __pyx_t_21 = PyMethod_GET_SELF(__pyx_t_42);
          assert(__pyx_t_21);
          PyObject* __pyx__function = PyMethod_GET_FUNCTION(__pyx_t_42);
          __Pyx_INCREF(__pyx_t_21);
          __Pyx_INCREF(__pyx__function);
          __Pyx_DECREF_SET(__pyx_t_42, __pyx__function);
          __pyx_t_10 = 0;
        }
        #endif
        {
          PyObject *__pyx_callargs[3 + ((CYTHON_VECTORCALL) ? 1 : 0)] = {__pyx_t_21, __pyx_mstate_global->__pyx_kp_u_Error_in__idle_reassign_s, __pyx_cur_scope->__pyx_v_e};
          __pyx_t_4 = __Pyx_MakeVectorcallBuilderKwds(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6916, __pyx_L223_error)
          __Pyx_GOTREF(__pyx_t_4);
          if (__Pyx_VectorcallBuilder_AddArg(__pyx_mstate_global->__pyx_n_u_exc_info, Py_True, __pyx_t_4, __pyx_callargs+3, 0) < (0)) __PYX_ERR(0, 6916, __pyx_L223_error)
          __pyx_t_23 = __Pyx_Object_Vectorcall_CallFromBuilder((PyObject*)__pyx_t_42, __pyx_callargs+__pyx_t_10, (3-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET), __pyx_t_4);
          __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_DECREF(__pyx_t_42); __pyx_t_42 = 0;
          if (unlikely(!__pyx_t_23)) __PYX_ERR(0, 6916, __pyx_L223_error)
          __Pyx_GOTREF(__pyx_t_23);
        }
        __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;

        /* "ws_package/controllers/activity_controller.py":6917
 *         except Exception as e:
 *             logger.error("Error in _idle_reassign: %s", e, exc_info=True)
 *             raise             # <<<<<<<<<<<<<<
*/
        __Pyx_GIVEREF(__pyx_t_7);
        __Pyx_GIVEREF(__pyx_t_22);
        __Pyx_XGIVEREF(__pyx_t_20);
        __Pyx_ErrRestoreWithState(__pyx_t_7, __pyx_t_22, __pyx_t_20);
        __pyx_t_7 = 0;  __pyx_t_22 = 0;  __pyx_t_20 = 0; 
        __PYX_ERR(0, 6917, __pyx_L223_error)
      }

      /* "ws_package/controllers/activity_controller.py":6915
 *             logger.info("=== Idle reassign completed: %s intervals reassigned successfully, %s failed ===", success_count, failed_count)
 * 
 *         except Exception as e:             # <<<<<<<<<<<<<<
 *             logger.error("Error in _idle_reassign: %s", e, exc_info=True)
 *             raise
*/
      /*finally:*/ {
        __pyx_L223_error:;
        /*exception exit:*/{
          __Pyx_PyThreadState_assign
          __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_12 = 0; __pyx_t_38 = 0; __pyx_t_33 = 0; __pyx_t_34 = 0;
          __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
          __Pyx_XDECREF(__pyx_t_23); __pyx_t_23 = 0;
          __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
          __Pyx_XDECREF(__pyx_t_42); __pyx_t_42 = 0;
          __Pyx_XDECREF(__pyx_t_44); __pyx_t_44 = 0;
          __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
          __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
           __Pyx_ExceptionSwap(&__pyx_t_38, &__pyx_t_33, &__pyx_t_34);
          if ( unlikely(__Pyx_GetException(&__pyx_t_14, &__pyx_t_15, &__pyx_t_12) < 0)) __Pyx_ErrFetch(&__pyx_t_14, &__pyx_t_15, &__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_14);
          __Pyx_XGOTREF(__pyx_t_15);
          __Pyx_XGOTREF(__pyx_t_12);
          __Pyx_XGOTREF(__pyx_t_38);
          __Pyx_XGOTREF(__pyx_t_33);
          __Pyx_XGOTREF(__pyx_t_34);
          __pyx_t_27 = __pyx_lineno; __pyx_t_39 = __pyx_clineno; __pyx_t_49 = __pyx_filename;
          {
            __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_e);
            __Pyx_DECREF(__pyx_cur_scope->__pyx_v_e); __pyx_cur_scope->__pyx_v_e = 0;
          }
          __Pyx_XGIVEREF(__pyx_t_38);
          __Pyx_XGIVEREF(__pyx_t_33);
          __Pyx_XGIVEREF(__pyx_t_34);
          __Pyx_ExceptionReset(__pyx_t_38, __pyx_t_33, __pyx_t_34);
          __Pyx_XGIVEREF(__pyx_t_14);
          __Pyx_XGIVEREF(__pyx_t_15);
          __Pyx_XGIVEREF(__pyx_t_12);
          __Pyx_ErrRestore(__pyx_t_14, __pyx_t_15, __pyx_t_12);
          __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_12 = 0; __pyx_t_38 = 0; __pyx_t_33 = 0; __pyx_t_34 = 0;
          __pyx_lineno = __pyx_t_27; __pyx_clineno = __pyx_t_39; __pyx_filename = __pyx_t_49;
          goto __pyx_L6_except_error;
        }
      }
    }
    goto __pyx_L6_except_error;

    /* "ws_package/controllers/activity_controller.py":6737
 *             task_id: Task ID to assign idle intervals to (optional, defaults to "0" if not provided)
 *         """
 *         try:             # <<<<<<<<<<<<<<
 *             # Convert task_id to string, default to "0" if None
 *             task_id_str = str(task_id) if task_id is not None and task_id != "" else "0"
*/
    __pyx_L6_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L1_error;
    __pyx_L8_try_return:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_2);
    __Pyx_XGIVEREF(__pyx_t_3);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_2, __pyx_t_3);
    goto __pyx_L0;
    __pyx_L9_try_end:;
  }
  CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);

  /* "ws_package/controllers/activity_controller.py":6729
 * 
 * 
 *     async def _idle_reassign(self, project_id: str, task_id: Optional[str] = None):             # <<<<<<<<<<<<<<
 *         """
 *         Reassign idle intervals to a new project and task by sending them to the API with the new project/task IDs.
*/

  /* function exit code */
  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_7);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_20);
  __Pyx_XDECREF(__pyx_t_21);
  __Pyx_XDECREF(__pyx_t_22);
  __Pyx_XDECREF(__pyx_t_23);
  __Pyx_XDECREF(__pyx_t_42);
  __Pyx_XDECREF(__pyx_t_44);
  if (__Pyx_PyErr_Occurred()) {
    __Pyx_Generator_Replace_StopIteration(0);
    __Pyx_AddTraceback("_idle_reassign", __pyx_clineno, __pyx_lineno, __pyx_filename);
  }
  __pyx_L0:;
  __Pyx_XGIVEREF(__pyx_r);
  #if !CYTHON_USE_EXC_INFO_STACK
  __Pyx_Coroutine_ResetAndClearException(__pyx_generator);
  #endif
  __pyx_generator->resume_label = -1;
  __Pyx_Coroutine_clear((PyObject*)__pyx_generator);
  __Pyx_RefNannyFinishContext();
  return __pyx_r;
}
/* #### Code section: module_exttypes ### */

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_cutoff);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_query);
  Py_CLEAR(p->__pyx_v_result);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_session);
  Py_CLEAR(p->__pyx_v_within_seconds);
  Py_CLEAR(p->__pyx_v_write_counter);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_6);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  Py_CLEAR(p->__pyx_t_9);
  Py_CLEAR(p->__pyx_t_10);
  Py_CLEAR(p->__pyx_t_11);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_cutoff) {
    e = (*v)(p->__pyx_v_cutoff, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_query) {
    e = (*v)(p->__pyx_v_query, a); if (e) return e;
  }
  if (p->__pyx_v_result) {
    e = (*v)(p->__pyx_v_result, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_session) {
    e = (*v)(p->__pyx_v_session, a); if (e) return e;
  }
  if (p->__pyx_v_write_counter) {
    e = (*v)(p->__pyx_v_write_counter, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  if (p->__pyx_t_9) {
    e = (*v)(p->__pyx_t_9, a); if (e) return e;
  }
  if (p->__pyx_t_10) {
    e = (*v)(p->__pyx_t_10, a); if (e) return e;
  }
  if (p->__pyx_t_11) {
    e = (*v)(p->__pyx_t_11, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct__has_recent_intervals_on_write_counter",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct__has_recent_intervals_on_write_counter", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_interval);
  Py_CLEAR(p->__pyx_v_old_end);
  Py_CLEAR(p->__pyx_v_query);
  Py_CLEAR(p->__pyx_v_result);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_session);
  Py_CLEAR(p->__pyx_v_switch_time);
  Py_CLEAR(p->__pyx_v_write_counter);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_6);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  Py_CLEAR(p->__pyx_t_9);
  Py_CLEAR(p->__pyx_t_10);
  Py_CLEAR(p->__pyx_t_11);
  Py_CLEAR(p->__pyx_t_12);
  Py_CLEAR(p->__pyx_t_13);
  Py_CLEAR(p->__pyx_t_14);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_interval) {
    e = (*v)(p->__pyx_v_interval, a); if (e) return e;
  }
  if (p->__pyx_v_old_end) {
    e = (*v)(p->__pyx_v_old_end, a); if (e) return e;
  }
  if (p->__pyx_v_query) {
    e = (*v)(p->__pyx_v_query, a); if (e) return e;
  }
  if (p->__pyx_v_result) {
    e = (*v)(p->__pyx_v_result, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_session) {
    e = (*v)(p->__pyx_v_session, a); if (e) return e;
  }
  if (p->__pyx_v_switch_time) {
    e = (*v)(p->__pyx_v_switch_time, a); if (e) return e;
  }
  if (p->__pyx_v_write_counter) {
    e = (*v)(p->__pyx_v_write_counter, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  if (p->__pyx_t_9) {
    e = (*v)(p->__pyx_t_9, a); if (e) return e;
  }
  if (p->__pyx_t_10) {
    e = (*v)(p->__pyx_t_10, a); if (e) return e;
  }
  if (p->__pyx_t_11) {
    e = (*v)(p->__pyx_t_11, a); if (e) return e;
  }
  if (p->__pyx_t_12) {
    e = (*v)(p->__pyx_t_12, a); if (e) return e;
  }
  if (p->__pyx_t_13) {
    e = (*v)(p->__pyx_t_13, a); if (e) return e;
  }
  if (p->__pyx_t_14) {
    e = (*v)(p->__pyx_t_14, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_1__trim_open_partial_at_project_switch",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_1__trim_open_partial_at_project_switch", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_activity_level);
  Py_CLEAR(p->__pyx_v_current_break_id);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_existing);
  Py_CLEAR(p->__pyx_v_interval_minutes);
  Py_CLEAR(p->__pyx_v_interval_start);
  Py_CLEAR(p->__pyx_v_last_end);
  Py_CLEAR(p->__pyx_v_now);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_session_start);
  Py_CLEAR(p->__pyx_v_slot_end);
  Py_CLEAR(p->__pyx_v_slot_start);
  Py_CLEAR(p->__pyx_v_user_entity);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_activity_level) {
    e = (*v)(p->__pyx_v_activity_level, a); if (e) return e;
  }
  if (p->__pyx_v_current_break_id) {
    e = (*v)(p->__pyx_v_current_break_id, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_existing) {
    e = (*v)(p->__pyx_v_existing, a); if (e) return e;
  }
  if (p->__pyx_v_interval_start) {
    e = (*v)(p->__pyx_v_interval_start, a); if (e) return e;
  }
  if (p->__pyx_v_last_end) {
    e = (*v)(p->__pyx_v_last_end, a); if (e) return e;
  }
  if (p->__pyx_v_now) {
    e = (*v)(p->__pyx_v_now, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_session_start) {
    e = (*v)(p->__pyx_v_session_start, a); if (e) return e;
  }
  if (p->__pyx_v_slot_end) {
    e = (*v)(p->__pyx_v_slot_end, a); if (e) return e;
  }
  if (p->__pyx_v_slot_start) {
    e = (*v)(p->__pyx_v_slot_start, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_2__try_finalize_post_switch_slot_interval",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_2__try_finalize_post_switch_slot_interval", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_current_break_id);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_empty_activity_level);
  Py_CLEAR(p->__pyx_v_processed_count);
  Py_CLEAR(p->__pyx_v_query);
  Py_CLEAR(p->__pyx_v_result);
  Py_CLEAR(p->__pyx_v_segment_start);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_session);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_6);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  Py_CLEAR(p->__pyx_t_9);
  Py_CLEAR(p->__pyx_t_10);
  Py_CLEAR(p->__pyx_t_11);
  Py_CLEAR(p->__pyx_t_12);
  Py_CLEAR(p->__pyx_t_13);
  Py_CLEAR(p->__pyx_t_14);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_current_break_id) {
    e = (*v)(p->__pyx_v_current_break_id, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_empty_activity_level) {
    e = (*v)(p->__pyx_v_empty_activity_level, a); if (e) return e;
  }
  if (p->__pyx_v_processed_count) {
    e = (*v)(p->__pyx_v_processed_count, a); if (e) return e;
  }
  if (p->__pyx_v_query) {
    e = (*v)(p->__pyx_v_query, a); if (e) return e;
  }
  if (p->__pyx_v_result) {
    e = (*v)(p->__pyx_v_result, a); if (e) return e;
  }
  if (p->__pyx_v_segment_start) {
    e = (*v)(p->__pyx_v_segment_start, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_session) {
    e = (*v)(p->__pyx_v_session, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  if (p->__pyx_t_9) {
    e = (*v)(p->__pyx_t_9, a); if (e) return e;
  }
  if (p->__pyx_t_10) {
    e = (*v)(p->__pyx_t_10, a); if (e) return e;
  }
  if (p->__pyx_t_11) {
    e = (*v)(p->__pyx_t_11, a); if (e) return e;
  }
  if (p->__pyx_t_12) {
    e = (*v)(p->__pyx_t_12, a); if (e) return e;
  }
  if (p->__pyx_t_13) {
    e = (*v)(p->__pyx_t_13, a); if (e) return e;
  }
  if (p->__pyx_t_14) {
    e = (*v)(p->__pyx_t_14, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_3__create_segment_dummy_entry",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_3__create_segment_dummy_entry", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_end_date);
  Py_CLEAR(p->__pyx_v_end_date_y);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_start_date);
  Py_CLEAR(p->__pyx_v_start_date_y);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_end_date) {
    e = (*v)(p->__pyx_v_end_date, a); if (e) return e;
  }
  if (p->__pyx_v_end_date_y) {
    e = (*v)(p->__pyx_v_end_date_y, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_start_date) {
    e = (*v)(p->__pyx_v_start_date, a); if (e) return e;
  }
  if (p->__pyx_v_start_date_y) {
    e = (*v)(p->__pyx_v_start_date_y, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_4_inrange",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_4_inrange", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_current_time);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_mode_entity);
  Py_CLEAR(p->__pyx_v_response);
  Py_CLEAR(p->__pyx_v_s_limit_end);
  Py_CLEAR(p->__pyx_v_s_limit_start);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_time_since_last_call);
  Py_CLEAR(p->__pyx_v_user_entity);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_current_time) {
    e = (*v)(p->__pyx_v_current_time, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_mode_entity) {
    e = (*v)(p->__pyx_v_mode_entity, a); if (e) return e;
  }
  if (p->__pyx_v_response) {
    e = (*v)(p->__pyx_v_response, a); if (e) return e;
  }
  if (p->__pyx_v_s_limit_end) {
    e = (*v)(p->__pyx_v_s_limit_end, a); if (e) return e;
  }
  if (p->__pyx_v_s_limit_start) {
    e = (*v)(p->__pyx_v_s_limit_start, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_time_since_last_call) {
    e = (*v)(p->__pyx_v_time_since_last_call, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_5_update_tracking_duration",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_5_update_tracking_duration", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_last_count);
  Py_CLEAR(p->__pyx_v_last_entry);
  Py_CLEAR(p->__pyx_v_query);
  Py_CLEAR(p->__pyx_v_result);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_session);
  Py_CLEAR(p->__pyx_v_user_entity);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_6);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  Py_CLEAR(p->__pyx_t_9);
  Py_CLEAR(p->__pyx_t_10);
  Py_CLEAR(p->__pyx_t_11);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_last_count) {
    e = (*v)(p->__pyx_v_last_count, a); if (e) return e;
  }
  if (p->__pyx_v_last_entry) {
    e = (*v)(p->__pyx_v_last_entry, a); if (e) return e;
  }
  if (p->__pyx_v_query) {
    e = (*v)(p->__pyx_v_query, a); if (e) return e;
  }
  if (p->__pyx_v_result) {
    e = (*v)(p->__pyx_v_result, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_session) {
    e = (*v)(p->__pyx_v_session, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  if (p->__pyx_t_9) {
    e = (*v)(p->__pyx_t_9, a); if (e) return e;
  }
  if (p->__pyx_t_10) {
    e = (*v)(p->__pyx_t_10, a); if (e) return e;
  }
  if (p->__pyx_t_11) {
    e = (*v)(p->__pyx_t_11, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_6_midnight",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_6_midnight", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_credentials_stale);
  Py_CLEAR(p->__pyx_v_current_date);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_last_entry);
  Py_CLEAR(p->__pyx_v_last_entry_date);
  Py_CLEAR(p->__pyx_v_query);
  Py_CLEAR(p->__pyx_v_result);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_session);
  Py_CLEAR(p->__pyx_v_user_entity);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_6);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  Py_CLEAR(p->__pyx_t_9);
  Py_CLEAR(p->__pyx_t_10);
  Py_CLEAR(p->__pyx_t_11);
  Py_CLEAR(p->__pyx_t_12);
  Py_CLEAR(p->__pyx_t_13);
  Py_CLEAR(p->__pyx_t_14);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_credentials_stale) {
    e = (*v)(p->__pyx_v_credentials_stale, a); if (e) return e;
  }
  if (p->__pyx_v_current_date) {
    e = (*v)(p->__pyx_v_current_date, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_last_entry) {
    e = (*v)(p->__pyx_v_last_entry, a); if (e) return e;
  }
  if (p->__pyx_v_last_entry_date) {
    e = (*v)(p->__pyx_v_last_entry_date, a); if (e) return e;
  }
  if (p->__pyx_v_query) {
    e = (*v)(p->__pyx_v_query, a); if (e) return e;
  }
  if (p->__pyx_v_result) {
    e = (*v)(p->__pyx_v_result, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_session) {
    e = (*v)(p->__pyx_v_session, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  if (p->__pyx_t_9) {
    e = (*v)(p->__pyx_t_9, a); if (e) return e;
  }
  if (p->__pyx_t_10) {
    e = (*v)(p->__pyx_t_10, a); if (e) return e;
  }
  if (p->__pyx_t_11) {
    e = (*v)(p->__pyx_t_11, a); if (e) return e;
  }
  if (p->__pyx_t_12) {
    e = (*v)(p->__pyx_t_12, a); if (e) return e;
  }
  if (p->__pyx_t_13) {
    e = (*v)(p->__pyx_t_13, a); if (e) return e;
  }
  if (p->__pyx_t_14) {
    e = (*v)(p->__pyx_t_14, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_7__check_and_update_s3_on_startup",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_7__check_and_update_s3_on_startup", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_credentials_stale);
  Py_CLEAR(p->__pyx_v_current_date);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_last_entry);
  Py_CLEAR(p->__pyx_v_last_entry_date);
  Py_CLEAR(p->__pyx_v_query);
  Py_CLEAR(p->__pyx_v_result);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_session);
  Py_CLEAR(p->__pyx_v_user_entity);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_6);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  Py_CLEAR(p->__pyx_t_9);
  Py_CLEAR(p->__pyx_t_10);
  Py_CLEAR(p->__pyx_t_11);
  Py_CLEAR(p->__pyx_t_12);
  Py_CLEAR(p->__pyx_t_13);
  Py_CLEAR(p->__pyx_t_14);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_credentials_stale) {
    e = (*v)(p->__pyx_v_credentials_stale, a); if (e) return e;
  }
  if (p->__pyx_v_current_date) {
    e = (*v)(p->__pyx_v_current_date, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_last_entry) {
    e = (*v)(p->__pyx_v_last_entry, a); if (e) return e;
  }
  if (p->__pyx_v_last_entry_date) {
    e = (*v)(p->__pyx_v_last_entry_date, a); if (e) return e;
  }
  if (p->__pyx_v_query) {
    e = (*v)(p->__pyx_v_query, a); if (e) return e;
  }
  if (p->__pyx_v_result) {
    e = (*v)(p->__pyx_v_result, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_session) {
    e = (*v)(p->__pyx_v_session, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  if (p->__pyx_t_9) {
    e = (*v)(p->__pyx_t_9, a); if (e) return e;
  }
  if (p->__pyx_t_10) {
    e = (*v)(p->__pyx_t_10, a); if (e) return e;
  }
  if (p->__pyx_t_11) {
    e = (*v)(p->__pyx_t_11, a); if (e) return e;
  }
  if (p->__pyx_t_12) {
    e = (*v)(p->__pyx_t_12, a); if (e) return e;
  }
  if (p->__pyx_t_13) {
    e = (*v)(p->__pyx_t_13, a); if (e) return e;
  }
  if (p->__pyx_t_14) {
    e = (*v)(p->__pyx_t_14, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_8__check_and_update_s3_on_wake",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_8__check_and_update_s3_on_wake", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_existing);
  Py_CLEAR(p->__pyx_v_s3_credentials_expired);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_user_entity);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_existing) {
    e = (*v)(p->__pyx_v_existing, a); if (e) return e;
  }
  if (p->__pyx_v_s3_credentials_expired) {
    e = (*v)(p->__pyx_v_s3_credentials_expired, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_9__s3_credentials_need_refresh",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_9__s3_credentials_need_refresh", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_user_entity);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_10_ensure_s3_credentials_fresh",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_10_ensure_s3_credentials_fresh", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_user_entity);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_11_get_bucket_in_every_interval",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_11_get_bucket_in_every_interval", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_loop);
  Py_CLEAR(p->__pyx_v_normalize_timezone_preference);
  Py_CLEAR(p->__pyx_v_org_entity);
  Py_CLEAR(p->__pyx_v_org_id);
  Py_CLEAR(p->__pyx_v_payload);
  Py_CLEAR(p->__pyx_v_response_data);
  Py_CLEAR(p->__pyx_v_sd_token);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_user_entity);
  Py_CLEAR(p->__pyx_v_user_id);
  Py_CLEAR(p->__pyx_v_weekly_limit_data);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_loop) {
    e = (*v)(p->__pyx_v_loop, a); if (e) return e;
  }
  if (p->__pyx_v_normalize_timezone_preference) {
    e = (*v)(p->__pyx_v_normalize_timezone_preference, a); if (e) return e;
  }
  if (p->__pyx_v_org_entity) {
    e = (*v)(p->__pyx_v_org_entity, a); if (e) return e;
  }
  if (p->__pyx_v_org_id) {
    e = (*v)(p->__pyx_v_org_id, a); if (e) return e;
  }
  if (p->__pyx_v_payload) {
    e = (*v)(p->__pyx_v_payload, a); if (e) return e;
  }
  if (p->__pyx_v_response_data) {
    e = (*v)(p->__pyx_v_response_data, a); if (e) return e;
  }
  if (p->__pyx_v_sd_token) {
    e = (*v)(p->__pyx_v_sd_token, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  if (p->__pyx_v_user_id) {
    e = (*v)(p->__pyx_v_user_id, a); if (e) return e;
  }
  if (p->__pyx_v_weekly_limit_data) {
    e = (*v)(p->__pyx_v_weekly_limit_data, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_12_update_interval",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_12_update_interval", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_query);
  Py_CLEAR(p->__pyx_v_record);
  Py_CLEAR(p->__pyx_v_result);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_session);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_6);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  Py_CLEAR(p->__pyx_t_9);
  Py_CLEAR(p->__pyx_t_10);
  Py_CLEAR(p->__pyx_t_11);
  Py_CLEAR(p->__pyx_t_12);
  Py_CLEAR(p->__pyx_t_13);
  Py_CLEAR(p->__pyx_t_14);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_query) {
    e = (*v)(p->__pyx_v_query, a); if (e) return e;
  }
  if (p->__pyx_v_record) {
    e = (*v)(p->__pyx_v_record, a); if (e) return e;
  }
  if (p->__pyx_v_result) {
    e = (*v)(p->__pyx_v_result, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_session) {
    e = (*v)(p->__pyx_v_session, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  if (p->__pyx_t_9) {
    e = (*v)(p->__pyx_t_9, a); if (e) return e;
  }
  if (p->__pyx_t_10) {
    e = (*v)(p->__pyx_t_10, a); if (e) return e;
  }
  if (p->__pyx_t_11) {
    e = (*v)(p->__pyx_t_11, a); if (e) return e;
  }
  if (p->__pyx_t_12) {
    e = (*v)(p->__pyx_t_12, a); if (e) return e;
  }
  if (p->__pyx_t_13) {
    e = (*v)(p->__pyx_t_13, a); if (e) return e;
  }
  if (p->__pyx_t_14) {
    e = (*v)(p->__pyx_t_14, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_13__load_org_settings_from_db",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_13__load_org_settings_from_db", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_daily_exceeded);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_limit_type);
  Py_CLEAR(p->__pyx_v_limits_check);
  Py_CLEAR(p->__pyx_v_notification_service);
  Py_CLEAR(p->__pyx_v_org_entity);
  Py_CLEAR(p->__pyx_v_report_in_background);
  Py_CLEAR(p->__pyx_v_report_thread);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_today);
  Py_CLEAR(p->__pyx_v_user_entity);
  Py_CLEAR(p->__pyx_v_weekly_exceeded);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_daily_exceeded) {
    e = (*v)(p->__pyx_v_daily_exceeded, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_limits_check) {
    e = (*v)(p->__pyx_v_limits_check, a); if (e) return e;
  }
  if (p->__pyx_v_notification_service) {
    e = (*v)(p->__pyx_v_notification_service, a); if (e) return e;
  }
  if (p->__pyx_v_org_entity) {
    e = (*v)(p->__pyx_v_org_entity, a); if (e) return e;
  }
  if (p->__pyx_v_report_in_background) {
    e = (*v)(p->__pyx_v_report_in_background, a); if (e) return e;
  }
  if (p->__pyx_v_report_thread) {
    e = (*v)(p->__pyx_v_report_thread, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_today) {
    e = (*v)(p->__pyx_v_today, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  if (p->__pyx_v_weekly_exceeded) {
    e = (*v)(p->__pyx_v_weekly_exceeded, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_14__check_and_handle_limits",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_14__check_and_handle_limits", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_stop_event);
  Py_CLEAR(p->__pyx_v_user_entity);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_stop_event) {
    e = (*v)(p->__pyx_v_stop_event, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_15_start_screenshot_activity",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_15_start_screenshot_activity", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_current_loop);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_minute_timer_task);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_stop_event);
  Py_CLEAR(p->__pyx_v_task);
  Py_CLEAR(p->__pyx_v_task_loop);
  Py_CLEAR(p->__pyx_v_user_entity);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_current_loop) {
    e = (*v)(p->__pyx_v_current_loop, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_minute_timer_task) {
    e = (*v)(p->__pyx_v_minute_timer_task, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_stop_event) {
    e = (*v)(p->__pyx_v_stop_event, a); if (e) return e;
  }
  if (p->__pyx_v_task) {
    e = (*v)(p->__pyx_v_task, a); if (e) return e;
  }
  if (p->__pyx_v_task_loop) {
    e = (*v)(p->__pyx_v_task_loop, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_16_start_device_activity",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_16_start_device_activity", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_end_time);
  Py_CLEAR(p->__pyx_v_hr);
  Py_CLEAR(p->__pyx_v_minute);
  Py_CLEAR(p->__pyx_v_next_day);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_start_time);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_end_time) {
    e = (*v)(p->__pyx_v_end_time, a); if (e) return e;
  }
  if (p->__pyx_v_hr) {
    e = (*v)(p->__pyx_v_hr, a); if (e) return e;
  }
  if (p->__pyx_v_minute) {
    e = (*v)(p->__pyx_v_minute, a); if (e) return e;
  }
  if (p->__pyx_v_next_day) {
    e = (*v)(p->__pyx_v_next_day, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_start_time) {
    e = (*v)(p->__pyx_v_start_time, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_17_getStartingSlot",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_17_getStartingSlot", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_end_date);
  Py_CLEAR(p->__pyx_v_minute);
  Py_CLEAR(p->__pyx_v_rounded_minute);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_start_date);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_end_date) {
    e = (*v)(p->__pyx_v_end_date, a); if (e) return e;
  }
  if (p->__pyx_v_minute) {
    e = (*v)(p->__pyx_v_minute, a); if (e) return e;
  }
  if (p->__pyx_v_rounded_minute) {
    e = (*v)(p->__pyx_v_rounded_minute, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_start_date) {
    e = (*v)(p->__pyx_v_start_date, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_18_getCurrentSlot",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_18_getCurrentSlot", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_cleaned_name_lower);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_cleaned_name_lower) {
    e = (*v)(p->__pyx_v_cleaned_name_lower, a); if (e) return e;
  }
  return 0;
}

static int __pyx_tp_clear_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser(PyObject *o) {
  PyObject* tmp;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser *)o;
  tmp = ((PyObject*)p->__pyx_v_cleaned_name_lower);
  p->__pyx_v_cleaned_name_lower = Py_None; Py_INCREF(Py_None);
  Py_XDECREF(tmp);
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser},
  {Py_tp_clear, (void *)__pyx_tp_clear_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_19_is_browser",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_19_is_browser", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser, /*tp_traverse*/
  __pyx_tp_clear_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_genexpr_arg_0);
  Py_CLEAR(p->__pyx_v_c);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_genexpr_arg_0) {
    e = (*v)(p->__pyx_genexpr_arg_0, a); if (e) return e;
  }
  if (p->__pyx_v_c) {
    e = (*v)(p->__pyx_v_c, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_20_genexpr",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_20_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_genexpr_arg_0);
  Py_CLEAR(p->__pyx_v_browser);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_genexpr_arg_0) {
    e = (*v)(p->__pyx_genexpr_arg_0, a); if (e) return e;
  }
  if (p->__pyx_v_browser) {
    e = (*v)(p->__pyx_v_browser, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_21_genexpr",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_21_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v__);
  Py_CLEAR(p->__pyx_v_current_break_id);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_minute_activity_level);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_stop_event);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v__) {
    e = (*v)(p->__pyx_v__, a); if (e) return e;
  }
  if (p->__pyx_v_current_break_id) {
    e = (*v)(p->__pyx_v_current_break_id, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_minute_activity_level) {
    e = (*v)(p->__pyx_v_minute_activity_level, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_stop_event) {
    e = (*v)(p->__pyx_v_stop_event, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_22___start_minute_activity_timer",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_22___start_minute_activity_timer", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_ErrorCode);
  Py_CLEAR(p->__pyx_v__);
  Py_CLEAR(p->__pyx_v__WOT);
  Py_CLEAR(p->__pyx_v__WOT2);
  Py_CLEAR(p->__pyx_v__d);
  Py_CLEAR(p->__pyx_v__d2);
  Py_CLEAR(p->__pyx_v__dwq);
  Py_CLEAR(p->__pyx_v__dwq2);
  Py_CLEAR(p->__pyx_v__on_time_error);
  Py_CLEAR(p->__pyx_v__pe);
  Py_CLEAR(p->__pyx_v__pe2);
  Py_CLEAR(p->__pyx_v__pi);
  Py_CLEAR(p->__pyx_v__pi2);
  Py_CLEAR(p->__pyx_v__ps);
  Py_CLEAR(p->__pyx_v__ps2);
  Py_CLEAR(p->__pyx_v_active_app_ui_task);
  Py_CLEAR(p->__pyx_v_active_app_ui_task_done_callback);
  Py_CLEAR(p->__pyx_v_active_app_url);
  Py_CLEAR(p->__pyx_v_activityLevel);
  Py_CLEAR(p->__pyx_v_activity_error);
  Py_CLEAR(p->__pyx_v_activity_percentage_end);
  Py_CLEAR(p->__pyx_v_activity_percentage_end_seconds);
  Py_CLEAR(p->__pyx_v_activity_percentage_entity);
  Py_CLEAR(p->__pyx_v_activity_percentage_key);
  Py_CLEAR(p->__pyx_v_activity_percentage_start);
  Py_CLEAR(p->__pyx_v_activity_percentage_start_seconds);
  Py_CLEAR(p->__pyx_v_app_listener);
  Py_CLEAR(p->__pyx_v_apply_desktop_key);
  Py_CLEAR(p->__pyx_v_break_intervals);
  Py_CLEAR(p->__pyx_v_break_intervals_after_trim);
  Py_CLEAR(p->__pyx_v_break_start_time);
  Py_CLEAR(p->__pyx_v_break_stop_attr);
  Py_CLEAR(p->__pyx_v_break_stop_time_attr);
  Py_CLEAR(p->__pyx_v_check_idle_after_delay);
  Py_CLEAR(p->__pyx_v_check_query);
  Py_CLEAR(p->__pyx_v_chunk_duration);
  Py_CLEAR(p->__pyx_v_chunks);
  Py_CLEAR(p->__pyx_v_current_break_id);
  Py_CLEAR(p->__pyx_v_current_break_id_slot);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_effective_end);
  Py_CLEAR(p->__pyx_v_effective_start);
  Py_CLEAR(p->__pyx_v_empty_activity_level);
  Py_CLEAR(p->__pyx_v_enable_hourly_log_upload);
  Py_CLEAR(p->__pyx_v_end_date);
  Py_CLEAR(p->__pyx_v_end_date_seconds);
  Py_CLEAR(p->__pyx_v_end_sec);
  Py_CLEAR(p->__pyx_v_enqueued);
  Py_CLEAR(p->__pyx_v_error_data);
  Py_CLEAR(p->__pyx_v_existing);
  Py_CLEAR(p->__pyx_v_existing_dummy);
  Py_CLEAR(p->__pyx_v_existing_interval_in_db);
  Py_CLEAR(p->__pyx_v_existing_record);
  Py_CLEAR(p->__pyx_v_fallback_error);
  Py_CLEAR(p->__pyx_v_first_entry);
  Py_CLEAR(p->__pyx_v_first_entry_note);
  Py_CLEAR(p->__pyx_v_flush_error);
  Py_CLEAR(p->__pyx_v_has_any_activity);
  Py_CLEAR(p->__pyx_v_has_zero_activity);
  Py_CLEAR(p->__pyx_v_headers);
  Py_CLEAR(p->__pyx_v_in_range);
  Py_CLEAR(p->__pyx_v_interval_key);
  Py_CLEAR(p->__pyx_v_is_idle);
  Py_CLEAR(p->__pyx_8genexpr2__pyx_v_iv);
  Py_CLEAR(p->__pyx_8genexpr3__pyx_v_iv);
  Py_CLEAR(p->__pyx_8genexpr4__pyx_v_iv);
  Py_CLEAR(p->__pyx_8genexpr5__pyx_v_iv);
  Py_CLEAR(p->__pyx_8genexpr6__pyx_v_iv);
  Py_CLEAR(p->__pyx_8genexpr7__pyx_v_iv);
  Py_CLEAR(p->__pyx_8genexpr8__pyx_v_iv);
  Py_CLEAR(p->__pyx_8genexpr9__pyx_v_iv);
  Py_CLEAR(p->__pyx_v_keyboard_active);
  Py_CLEAR(p->__pyx_v_keyboard_verified);
  Py_CLEAR(p->__pyx_v_last_app_monitor_time);
  Py_CLEAR(p->__pyx_v_last_end);
  Py_CLEAR(p->__pyx_v_latest_record);
  Py_CLEAR(p->__pyx_v_minimal_activity);
  Py_CLEAR(p->__pyx_v_monitor_active_app_for_ui);
  Py_CLEAR(p->__pyx_v_monitor_active_apps);
  Py_CLEAR(p->__pyx_v_monitor_task);
  Py_CLEAR(p->__pyx_v_mouse_active);
  Py_CLEAR(p->__pyx_v_mouse_verified);
  Py_CLEAR(p->__pyx_v_now);
  Py_CLEAR(p->__pyx_v_overlap_query);
  Py_CLEAR(p->__pyx_v_overlap_query_after_trim);
  Py_CLEAR(p->__pyx_v_overlap_result);
  Py_CLEAR(p->__pyx_v_overlap_result_after_trim);
  Py_CLEAR(p->__pyx_v_overlapping_details);
  Py_CLEAR(p->__pyx_v_overlapping_details_after_trim);
  Py_CLEAR(p->__pyx_v_overlapping_intervals);
  Py_CLEAR(p->__pyx_v_overlapping_intervals_after_trim);
  Py_CLEAR(p->__pyx_v_payload);
  Py_CLEAR(p->__pyx_v_popup_is_active);
  Py_CLEAR(p->__pyx_v_processed_count);
  Py_CLEAR(p->__pyx_v_query);
  Py_CLEAR(p->__pyx_v_queue_size);
  Py_CLEAR(p->__pyx_v_recovery_error);
  Py_CLEAR(p->__pyx_v_regular_intervals);
  Py_CLEAR(p->__pyx_v_regular_intervals_after_trim);
  Py_CLEAR(p->__pyx_v_remove_after_delay);
  Py_CLEAR(p->__pyx_v_resolving_policy);
  Py_CLEAR(p->__pyx_v_response);
  Py_CLEAR(p->__pyx_v_result);
  Py_CLEAR(p->__pyx_v_script_path);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_session);
  Py_CLEAR(p->__pyx_v_session_start);
  Py_CLEAR(p->__pyx_v_sleep_seconds);
  Py_CLEAR(p->__pyx_v_slot_end);
  Py_CLEAR(p->__pyx_v_start_date);
  Py_CLEAR(p->__pyx_v_start_date_seconds);
  Py_CLEAR(p->__pyx_v_start_sec);
  Py_CLEAR(p->__pyx_v_stop_event);
  Py_CLEAR(p->__pyx_v_stop_listeners);
  Py_CLEAR(p->__pyx_v_target_directory);
  Py_CLEAR(p->__pyx_v_target_directory_stealth);
  Py_CLEAR(p->__pyx_v_task_done_callback);
  Py_CLEAR(p->__pyx_v_today);
  Py_CLEAR(p->__pyx_v_total_sleep);
  Py_CLEAR(p->__pyx_v_trim_to);
  Py_CLEAR(p->__pyx_v_url);
  Py_CLEAR(p->__pyx_v_user_entity);
  Py_CLEAR(p->__pyx_v_work_session_start);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_6);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  Py_CLEAR(p->__pyx_t_9);
  Py_CLEAR(p->__pyx_t_10);
  Py_CLEAR(p->__pyx_t_11);
  Py_CLEAR(p->__pyx_t_12);
  Py_CLEAR(p->__pyx_t_13);
  Py_CLEAR(p->__pyx_t_14);
  Py_CLEAR(p->__pyx_t_16);
  Py_CLEAR(p->__pyx_t_17);
  Py_CLEAR(p->__pyx_t_18);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_ErrorCode) {
    e = (*v)(p->__pyx_v_ErrorCode, a); if (e) return e;
  }
  if (p->__pyx_v__) {
    e = (*v)(p->__pyx_v__, a); if (e) return e;
  }
  if (p->__pyx_v__WOT) {
    e = (*v)(p->__pyx_v__WOT, a); if (e) return e;
  }
  if (p->__pyx_v__WOT2) {
    e = (*v)(p->__pyx_v__WOT2, a); if (e) return e;
  }
  if (p->__pyx_v__d) {
    e = (*v)(p->__pyx_v__d, a); if (e) return e;
  }
  if (p->__pyx_v__d2) {
    e = (*v)(p->__pyx_v__d2, a); if (e) return e;
  }
  if (p->__pyx_v__dwq) {
    e = (*v)(p->__pyx_v__dwq, a); if (e) return e;
  }
  if (p->__pyx_v__dwq2) {
    e = (*v)(p->__pyx_v__dwq2, a); if (e) return e;
  }
  if (p->__pyx_v__on_time_error) {
    e = (*v)(p->__pyx_v__on_time_error, a); if (e) return e;
  }
  if (p->__pyx_v__pe) {
    e = (*v)(p->__pyx_v__pe, a); if (e) return e;
  }
  if (p->__pyx_v__pe2) {
    e = (*v)(p->__pyx_v__pe2, a); if (e) return e;
  }
  if (p->__pyx_v__pi) {
    e = (*v)(p->__pyx_v__pi, a); if (e) return e;
  }
  if (p->__pyx_v__pi2) {
    e = (*v)(p->__pyx_v__pi2, a); if (e) return e;
  }
  if (p->__pyx_v__ps) {
    e = (*v)(p->__pyx_v__ps, a); if (e) return e;
  }
  if (p->__pyx_v__ps2) {
    e = (*v)(p->__pyx_v__ps2, a); if (e) return e;
  }
  if (p->__pyx_v_active_app_ui_task) {
    e = (*v)(p->__pyx_v_active_app_ui_task, a); if (e) return e;
  }
  if (p->__pyx_v_active_app_ui_task_done_callback) {
    e = (*v)(p->__pyx_v_active_app_ui_task_done_callback, a); if (e) return e;
  }
  if (p->__pyx_v_active_app_url) {
    e = (*v)(p->__pyx_v_active_app_url, a); if (e) return e;
  }
  if (p->__pyx_v_activityLevel) {
    e = (*v)(p->__pyx_v_activityLevel, a); if (e) return e;
  }
  if (p->__pyx_v_activity_error) {
    e = (*v)(p->__pyx_v_activity_error, a); if (e) return e;
  }
  if (p->__pyx_v_activity_percentage_end) {
    e = (*v)(p->__pyx_v_activity_percentage_end, a); if (e) return e;
  }
  if (p->__pyx_v_activity_percentage_end_seconds) {
    e = (*v)(p->__pyx_v_activity_percentage_end_seconds, a); if (e) return e;
  }
  if (p->__pyx_v_activity_percentage_entity) {
    e = (*v)(p->__pyx_v_activity_percentage_entity, a); if (e) return e;
  }
  if (p->__pyx_v_activity_percentage_key) {
    e = (*v)(p->__pyx_v_activity_percentage_key, a); if (e) return e;
  }
  if (p->__pyx_v_activity_percentage_start) {
    e = (*v)(p->__pyx_v_activity_percentage_start, a); if (e) return e;
  }
  if (p->__pyx_v_activity_percentage_start_seconds) {
    e = (*v)(p->__pyx_v_activity_percentage_start_seconds, a); if (e) return e;
  }
  if (p->__pyx_v_app_listener) {
    e = (*v)(p->__pyx_v_app_listener, a); if (e) return e;
  }
  if (p->__pyx_v_apply_desktop_key) {
    e = (*v)(p->__pyx_v_apply_desktop_key, a); if (e) return e;
  }
  if (p->__pyx_v_break_intervals) {
    e = (*v)(p->__pyx_v_break_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_break_intervals_after_trim) {
    e = (*v)(p->__pyx_v_break_intervals_after_trim, a); if (e) return e;
  }
  if (p->__pyx_v_break_start_time) {
    e = (*v)(p->__pyx_v_break_start_time, a); if (e) return e;
  }
  if (p->__pyx_v_break_stop_attr) {
    e = (*v)(p->__pyx_v_break_stop_attr, a); if (e) return e;
  }
  if (p->__pyx_v_break_stop_time_attr) {
    e = (*v)(p->__pyx_v_break_stop_time_attr, a); if (e) return e;
  }
  if (p->__pyx_v_check_idle_after_delay) {
    e = (*v)(p->__pyx_v_check_idle_after_delay, a); if (e) return e;
  }
  if (p->__pyx_v_check_query) {
    e = (*v)(p->__pyx_v_check_query, a); if (e) return e;
  }
  if (p->__pyx_v_chunk_duration) {
    e = (*v)(p->__pyx_v_chunk_duration, a); if (e) return e;
  }
  if (p->__pyx_v_chunks) {
    e = (*v)(p->__pyx_v_chunks, a); if (e) return e;
  }
  if (p->__pyx_v_current_break_id) {
    e = (*v)(p->__pyx_v_current_break_id, a); if (e) return e;
  }
  if (p->__pyx_v_current_break_id_slot) {
    e = (*v)(p->__pyx_v_current_break_id_slot, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_effective_end) {
    e = (*v)(p->__pyx_v_effective_end, a); if (e) return e;
  }
  if (p->__pyx_v_effective_start) {
    e = (*v)(p->__pyx_v_effective_start, a); if (e) return e;
  }
  if (p->__pyx_v_empty_activity_level) {
    e = (*v)(p->__pyx_v_empty_activity_level, a); if (e) return e;
  }
  if (p->__pyx_v_enable_hourly_log_upload) {
    e = (*v)(p->__pyx_v_enable_hourly_log_upload, a); if (e) return e;
  }
  if (p->__pyx_v_end_date) {
    e = (*v)(p->__pyx_v_end_date, a); if (e) return e;
  }
  if (p->__pyx_v_end_date_seconds) {
    e = (*v)(p->__pyx_v_end_date_seconds, a); if (e) return e;
  }
  if (p->__pyx_v_end_sec) {
    e = (*v)(p->__pyx_v_end_sec, a); if (e) return e;
  }
  if (p->__pyx_v_enqueued) {
    e = (*v)(p->__pyx_v_enqueued, a); if (e) return e;
  }
  if (p->__pyx_v_error_data) {
    e = (*v)(p->__pyx_v_error_data, a); if (e) return e;
  }
  if (p->__pyx_v_existing) {
    e = (*v)(p->__pyx_v_existing, a); if (e) return e;
  }
  if (p->__pyx_v_existing_dummy) {
    e = (*v)(p->__pyx_v_existing_dummy, a); if (e) return e;
  }
  if (p->__pyx_v_existing_interval_in_db) {
    e = (*v)(p->__pyx_v_existing_interval_in_db, a); if (e) return e;
  }
  if (p->__pyx_v_existing_record) {
    e = (*v)(p->__pyx_v_existing_record, a); if (e) return e;
  }
  if (p->__pyx_v_fallback_error) {
    e = (*v)(p->__pyx_v_fallback_error, a); if (e) return e;
  }
  if (p->__pyx_v_first_entry) {
    e = (*v)(p->__pyx_v_first_entry, a); if (e) return e;
  }
  if (p->__pyx_v_flush_error) {
    e = (*v)(p->__pyx_v_flush_error, a); if (e) return e;
  }
  if (p->__pyx_v_has_any_activity) {
    e = (*v)(p->__pyx_v_has_any_activity, a); if (e) return e;
  }
  if (p->__pyx_v_has_zero_activity) {
    e = (*v)(p->__pyx_v_has_zero_activity, a); if (e) return e;
  }
  if (p->__pyx_v_headers) {
    e = (*v)(p->__pyx_v_headers, a); if (e) return e;
  }
  if (p->__pyx_v_in_range) {
    e = (*v)(p->__pyx_v_in_range, a); if (e) return e;
  }
  if (p->__pyx_v_interval_key) {
    e = (*v)(p->__pyx_v_interval_key, a); if (e) return e;
  }
  if (p->__pyx_v_is_idle) {
    e = (*v)(p->__pyx_v_is_idle, a); if (e) return e;
  }
  if (p->__pyx_8genexpr2__pyx_v_iv) {
    e = (*v)(p->__pyx_8genexpr2__pyx_v_iv, a); if (e) return e;
  }
  if (p->__pyx_8genexpr3__pyx_v_iv) {
    e = (*v)(p->__pyx_8genexpr3__pyx_v_iv, a); if (e) return e;
  }
  if (p->__pyx_8genexpr4__pyx_v_iv) {
    e = (*v)(p->__pyx_8genexpr4__pyx_v_iv, a); if (e) return e;
  }
  if (p->__pyx_8genexpr5__pyx_v_iv) {
    e = (*v)(p->__pyx_8genexpr5__pyx_v_iv, a); if (e) return e;
  }
  if (p->__pyx_8genexpr6__pyx_v_iv) {
    e = (*v)(p->__pyx_8genexpr6__pyx_v_iv, a); if (e) return e;
  }
  if (p->__pyx_8genexpr7__pyx_v_iv) {
    e = (*v)(p->__pyx_8genexpr7__pyx_v_iv, a); if (e) return e;
  }
  if (p->__pyx_8genexpr8__pyx_v_iv) {
    e = (*v)(p->__pyx_8genexpr8__pyx_v_iv, a); if (e) return e;
  }
  if (p->__pyx_8genexpr9__pyx_v_iv) {
    e = (*v)(p->__pyx_8genexpr9__pyx_v_iv, a); if (e) return e;
  }
  if (p->__pyx_v_keyboard_active) {
    e = (*v)(p->__pyx_v_keyboard_active, a); if (e) return e;
  }
  if (p->__pyx_v_keyboard_verified) {
    e = (*v)(p->__pyx_v_keyboard_verified, a); if (e) return e;
  }
  if (p->__pyx_v_last_app_monitor_time) {
    e = (*v)(p->__pyx_v_last_app_monitor_time, a); if (e) return e;
  }
  if (p->__pyx_v_last_end) {
    e = (*v)(p->__pyx_v_last_end, a); if (e) return e;
  }
  if (p->__pyx_v_latest_record) {
    e = (*v)(p->__pyx_v_latest_record, a); if (e) return e;
  }
  if (p->__pyx_v_minimal_activity) {
    e = (*v)(p->__pyx_v_minimal_activity, a); if (e) return e;
  }
  if (p->__pyx_v_monitor_active_app_for_ui) {
    e = (*v)(p->__pyx_v_monitor_active_app_for_ui, a); if (e) return e;
  }
  if (p->__pyx_v_monitor_active_apps) {
    e = (*v)(p->__pyx_v_monitor_active_apps, a); if (e) return e;
  }
  if (p->__pyx_v_monitor_task) {
    e = (*v)(p->__pyx_v_monitor_task, a); if (e) return e;
  }
  if (p->__pyx_v_mouse_active) {
    e = (*v)(p->__pyx_v_mouse_active, a); if (e) return e;
  }
  if (p->__pyx_v_mouse_verified) {
    e = (*v)(p->__pyx_v_mouse_verified, a); if (e) return e;
  }
  if (p->__pyx_v_now) {
    e = (*v)(p->__pyx_v_now, a); if (e) return e;
  }
  if (p->__pyx_v_overlap_query) {
    e = (*v)(p->__pyx_v_overlap_query, a); if (e) return e;
  }
  if (p->__pyx_v_overlap_query_after_trim) {
    e = (*v)(p->__pyx_v_overlap_query_after_trim, a); if (e) return e;
  }
  if (p->__pyx_v_overlap_result) {
    e = (*v)(p->__pyx_v_overlap_result, a); if (e) return e;
  }
  if (p->__pyx_v_overlap_result_after_trim) {
    e = (*v)(p->__pyx_v_overlap_result_after_trim, a); if (e) return e;
  }
  if (p->__pyx_v_overlapping_details) {
    e = (*v)(p->__pyx_v_overlapping_details, a); if (e) return e;
  }
  if (p->__pyx_v_overlapping_details_after_trim) {
    e = (*v)(p->__pyx_v_overlapping_details_after_trim, a); if (e) return e;
  }
  if (p->__pyx_v_overlapping_intervals) {
    e = (*v)(p->__pyx_v_overlapping_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_overlapping_intervals_after_trim) {
    e = (*v)(p->__pyx_v_overlapping_intervals_after_trim, a); if (e) return e;
  }
  if (p->__pyx_v_payload) {
    e = (*v)(p->__pyx_v_payload, a); if (e) return e;
  }
  if (p->__pyx_v_popup_is_active) {
    e = (*v)(p->__pyx_v_popup_is_active, a); if (e) return e;
  }
  if (p->__pyx_v_processed_count) {
    e = (*v)(p->__pyx_v_processed_count, a); if (e) return e;
  }
  if (p->__pyx_v_query) {
    e = (*v)(p->__pyx_v_query, a); if (e) return e;
  }
  if (p->__pyx_v_queue_size) {
    e = (*v)(p->__pyx_v_queue_size, a); if (e) return e;
  }
  if (p->__pyx_v_recovery_error) {
    e = (*v)(p->__pyx_v_recovery_error, a); if (e) return e;
  }
  if (p->__pyx_v_regular_intervals) {
    e = (*v)(p->__pyx_v_regular_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_regular_intervals_after_trim) {
    e = (*v)(p->__pyx_v_regular_intervals_after_trim, a); if (e) return e;
  }
  if (p->__pyx_v_remove_after_delay) {
    e = (*v)(p->__pyx_v_remove_after_delay, a); if (e) return e;
  }
  if (p->__pyx_v_resolving_policy) {
    e = (*v)(p->__pyx_v_resolving_policy, a); if (e) return e;
  }
  if (p->__pyx_v_response) {
    e = (*v)(p->__pyx_v_response, a); if (e) return e;
  }
  if (p->__pyx_v_result) {
    e = (*v)(p->__pyx_v_result, a); if (e) return e;
  }
  if (p->__pyx_v_script_path) {
    e = (*v)(p->__pyx_v_script_path, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_session) {
    e = (*v)(p->__pyx_v_session, a); if (e) return e;
  }
  if (p->__pyx_v_session_start) {
    e = (*v)(p->__pyx_v_session_start, a); if (e) return e;
  }
  if (p->__pyx_v_sleep_seconds) {
    e = (*v)(p->__pyx_v_sleep_seconds, a); if (e) return e;
  }
  if (p->__pyx_v_slot_end) {
    e = (*v)(p->__pyx_v_slot_end, a); if (e) return e;
  }
  if (p->__pyx_v_start_date) {
    e = (*v)(p->__pyx_v_start_date, a); if (e) return e;
  }
  if (p->__pyx_v_start_date_seconds) {
    e = (*v)(p->__pyx_v_start_date_seconds, a); if (e) return e;
  }
  if (p->__pyx_v_start_sec) {
    e = (*v)(p->__pyx_v_start_sec, a); if (e) return e;
  }
  if (p->__pyx_v_stop_event) {
    e = (*v)(p->__pyx_v_stop_event, a); if (e) return e;
  }
  if (p->__pyx_v_stop_listeners) {
    e = (*v)(p->__pyx_v_stop_listeners, a); if (e) return e;
  }
  if (p->__pyx_v_target_directory) {
    e = (*v)(p->__pyx_v_target_directory, a); if (e) return e;
  }
  if (p->__pyx_v_target_directory_stealth) {
    e = (*v)(p->__pyx_v_target_directory_stealth, a); if (e) return e;
  }
  if (p->__pyx_v_task_done_callback) {
    e = (*v)(p->__pyx_v_task_done_callback, a); if (e) return e;
  }
  if (p->__pyx_v_today) {
    e = (*v)(p->__pyx_v_today, a); if (e) return e;
  }
  if (p->__pyx_v_total_sleep) {
    e = (*v)(p->__pyx_v_total_sleep, a); if (e) return e;
  }
  if (p->__pyx_v_trim_to) {
    e = (*v)(p->__pyx_v_trim_to, a); if (e) return e;
  }
  if (p->__pyx_v_url) {
    e = (*v)(p->__pyx_v_url, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  if (p->__pyx_v_work_session_start) {
    e = (*v)(p->__pyx_v_work_session_start, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  if (p->__pyx_t_9) {
    e = (*v)(p->__pyx_t_9, a); if (e) return e;
  }
  if (p->__pyx_t_10) {
    e = (*v)(p->__pyx_t_10, a); if (e) return e;
  }
  if (p->__pyx_t_11) {
    e = (*v)(p->__pyx_t_11, a); if (e) return e;
  }
  if (p->__pyx_t_12) {
    e = (*v)(p->__pyx_t_12, a); if (e) return e;
  }
  if (p->__pyx_t_13) {
    e = (*v)(p->__pyx_t_13, a); if (e) return e;
  }
  if (p->__pyx_t_14) {
    e = (*v)(p->__pyx_t_14, a); if (e) return e;
  }
  if (p->__pyx_t_16) {
    e = (*v)(p->__pyx_t_16, a); if (e) return e;
  }
  if (p->__pyx_t_17) {
    e = (*v)(p->__pyx_t_17, a); if (e) return e;
  }
  if (p->__pyx_t_18) {
    e = (*v)(p->__pyx_t_18, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_23___start_device_activity",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_23___start_device_activity", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_active_app_url);
  Py_CLEAR(p->__pyx_v_app_name);
  Py_CLEAR(p->__pyx_v_detected_app);
  Py_CLEAR(p->__pyx_v_display_name);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_i2t);
  Py_CLEAR(p->__pyx_v_row);
  Py_CLEAR(p->__pyx_v_url);
  Py_CLEAR(p->__pyx_v_url_result);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_active_app_url) {
    e = (*v)(p->__pyx_v_active_app_url, a); if (e) return e;
  }
  if (p->__pyx_v_app_name) {
    e = (*v)(p->__pyx_v_app_name, a); if (e) return e;
  }
  if (p->__pyx_v_detected_app) {
    e = (*v)(p->__pyx_v_detected_app, a); if (e) return e;
  }
  if (p->__pyx_v_display_name) {
    e = (*v)(p->__pyx_v_display_name, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_i2t) {
    e = (*v)(p->__pyx_v_i2t, a); if (e) return e;
  }
  if (p->__pyx_v_row) {
    e = (*v)(p->__pyx_v_row, a); if (e) return e;
  }
  if (p->__pyx_v_url) {
    e = (*v)(p->__pyx_v_url, a); if (e) return e;
  }
  if (p->__pyx_v_url_result) {
    e = (*v)(p->__pyx_v_url_result, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_24_monitor_active_apps",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_24_monitor_active_apps", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_v_active_windows);
  Py_CLEAR(p->__pyx_v_app_icon);
  Py_CLEAR(p->__pyx_v_current_app_data);
  Py_CLEAR(p->__pyx_v_current_app_name);
  Py_CLEAR(p->__pyx_v_current_app_path);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_v_active_windows) {
    e = (*v)(p->__pyx_v_active_windows, a); if (e) return e;
  }
  if (p->__pyx_v_app_icon) {
    e = (*v)(p->__pyx_v_app_icon, a); if (e) return e;
  }
  if (p->__pyx_v_current_app_data) {
    e = (*v)(p->__pyx_v_current_app_data, a); if (e) return e;
  }
  if (p->__pyx_v_current_app_name) {
    e = (*v)(p->__pyx_v_current_app_name, a); if (e) return e;
  }
  if (p->__pyx_v_current_app_path) {
    e = (*v)(p->__pyx_v_current_app_path, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_25_monitor_active_app_for_ui",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_25_monitor_active_app_for_ui", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_26_remove_after_delay",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_26_remove_after_delay", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_27_check_idle_after_delay",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_27_check_idle_after_delay", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_28_remove_after_delay",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_28_remove_after_delay", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_29_remove_after_delay",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_29_remove_after_delay", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_30_remove_after_delay",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_30_remove_after_delay", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_31_remove_after_delay",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_31_remove_after_delay", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_32_check_idle_after_delay",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_32_check_idle_after_delay", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_break_id);
  Py_CLEAR(p->__pyx_v_current);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_gap_end);
  Py_CLEAR(p->__pyx_v_gap_level);
  Py_CLEAR(p->__pyx_v_gap_seconds);
  Py_CLEAR(p->__pyx_v_gap_start);
  Py_CLEAR(p->__pyx_v_genexpr);
  Py_CLEAR(p->__pyx_v_interval_end_time);
  Py_CLEAR(p->__pyx_v_missing_intervals);
  Py_CLEAR(p->__pyx_v_overlapping);
  Py_CLEAR(p->__pyx_v_seg_end);
  Py_CLEAR(p->__pyx_v_seg_start);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_sent);
  Py_CLEAR(p->__pyx_v_sleep_minutes);
  Py_CLEAR(p->__pyx_v_start_time);
  Py_CLEAR(p->__pyx_v_sub_segments);
  Py_CLEAR(p->__pyx_v_total_fill_seconds);
  Py_CLEAR(p->__pyx_v_user_entity);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_3);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_break_id) {
    e = (*v)(p->__pyx_v_break_id, a); if (e) return e;
  }
  if (p->__pyx_v_current) {
    e = (*v)(p->__pyx_v_current, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_gap_end) {
    e = (*v)(p->__pyx_v_gap_end, a); if (e) return e;
  }
  if (p->__pyx_v_gap_level) {
    e = (*v)(p->__pyx_v_gap_level, a); if (e) return e;
  }
  if (p->__pyx_v_gap_seconds) {
    e = (*v)(p->__pyx_v_gap_seconds, a); if (e) return e;
  }
  if (p->__pyx_v_gap_start) {
    e = (*v)(p->__pyx_v_gap_start, a); if (e) return e;
  }
  if (p->__pyx_v_genexpr) {
    e = (*v)(p->__pyx_v_genexpr, a); if (e) return e;
  }
  if (p->__pyx_v_interval_end_time) {
    e = (*v)(p->__pyx_v_interval_end_time, a); if (e) return e;
  }
  if (p->__pyx_v_missing_intervals) {
    e = (*v)(p->__pyx_v_missing_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_overlapping) {
    e = (*v)(p->__pyx_v_overlapping, a); if (e) return e;
  }
  if (p->__pyx_v_seg_end) {
    e = (*v)(p->__pyx_v_seg_end, a); if (e) return e;
  }
  if (p->__pyx_v_seg_start) {
    e = (*v)(p->__pyx_v_seg_start, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_sent) {
    e = (*v)(p->__pyx_v_sent, a); if (e) return e;
  }
  if (p->__pyx_v_start_time) {
    e = (*v)(p->__pyx_v_start_time, a); if (e) return e;
  }
  if (p->__pyx_v_sub_segments) {
    e = (*v)(p->__pyx_v_sub_segments, a); if (e) return e;
  }
  if (p->__pyx_v_total_fill_seconds) {
    e = (*v)(p->__pyx_v_total_fill_seconds, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_33_empty_interval",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_33_empty_interval", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_genexpr_arg_0);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_s);
  Py_CLEAR(p->__pyx_t_0);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_genexpr_arg_0) {
    e = (*v)(p->__pyx_genexpr_arg_0, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_s) {
    e = (*v)(p->__pyx_v_s, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_34_genexpr",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_34_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_ErrorCode);
  Py_CLEAR(p->__pyx_v__response);
  Py_CLEAR(p->__pyx_v_active_app_url);
  Py_CLEAR(p->__pyx_v_appVersion);
  Py_CLEAR(p->__pyx_v_apply_desktop_key);
  Py_CLEAR(p->__pyx_v_current_break_id);
  Py_CLEAR(p->__pyx_v_current_counter);
  Py_CLEAR(p->__pyx_v_current_counter_held);
  Py_CLEAR(p->__pyx_v_current_session_counter);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_error_data);
  Py_CLEAR(p->__pyx_v_filtered_intervals);
  Py_CLEAR(p->__pyx_v_force_upload_after_pause_cap);
  Py_CLEAR(p->__pyx_v_headers);
  Py_CLEAR(p->__pyx_9genexpr13__pyx_v_held);
  Py_CLEAR(p->__pyx_v_held_interval_ids);
  Py_CLEAR(p->__pyx_v_held_intervals);
  Py_CLEAR(p->__pyx_v_held_sent_count);
  Py_CLEAR(p->__pyx_v_idle_popup_blocking);
  Py_CLEAR(p->__pyx_v_interval);
  Py_CLEAR(p->__pyx_v_interval_payload);
  Py_CLEAR(p->__pyx_v_intervals);
  Py_CLEAR(p->__pyx_9genexpr11__pyx_v_iv);
  Py_CLEAR(p->__pyx_9genexpr12__pyx_v_iv);
  Py_CLEAR(p->__pyx_9genexpr14__pyx_v_iv);
  Py_CLEAR(p->__pyx_v_last_wake_time);
  Py_CLEAR(p->__pyx_v_org_id);
  Py_CLEAR(p->__pyx_v_os_type);
  Py_CLEAR(p->__pyx_v_payload);
  Py_CLEAR(p->__pyx_v_prev_day_unsent);
  Py_CLEAR(p->__pyx_v_response);
  Py_CLEAR(p->__pyx_v_screen_url);
  Py_CLEAR(p->__pyx_v_sd_token);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_sending_held_intervals);
  Py_CLEAR(p->__pyx_v_sending_intervals);
  Py_CLEAR(p->__pyx_v_should_pause_api);
  Py_CLEAR(p->__pyx_v_start);
  Py_CLEAR(p->__pyx_v_stop_event);
  Py_CLEAR(p->__pyx_v_time_since_wake);
  Py_CLEAR(p->__pyx_v_timeout_reached);
  Py_CLEAR(p->__pyx_v_url);
  Py_CLEAR(p->__pyx_v_user_entity);
  Py_CLEAR(p->__pyx_v_user_id);
  Py_CLEAR(p->__pyx_v_wake_detector);
  Py_CLEAR(p->__pyx_v_wake_stats);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_ErrorCode) {
    e = (*v)(p->__pyx_v_ErrorCode, a); if (e) return e;
  }
  if (p->__pyx_v__response) {
    e = (*v)(p->__pyx_v__response, a); if (e) return e;
  }
  if (p->__pyx_v_active_app_url) {
    e = (*v)(p->__pyx_v_active_app_url, a); if (e) return e;
  }
  if (p->__pyx_v_appVersion) {
    e = (*v)(p->__pyx_v_appVersion, a); if (e) return e;
  }
  if (p->__pyx_v_apply_desktop_key) {
    e = (*v)(p->__pyx_v_apply_desktop_key, a); if (e) return e;
  }
  if (p->__pyx_v_current_break_id) {
    e = (*v)(p->__pyx_v_current_break_id, a); if (e) return e;
  }
  if (p->__pyx_v_current_counter) {
    e = (*v)(p->__pyx_v_current_counter, a); if (e) return e;
  }
  if (p->__pyx_v_current_counter_held) {
    e = (*v)(p->__pyx_v_current_counter_held, a); if (e) return e;
  }
  if (p->__pyx_v_current_session_counter) {
    e = (*v)(p->__pyx_v_current_session_counter, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_error_data) {
    e = (*v)(p->__pyx_v_error_data, a); if (e) return e;
  }
  if (p->__pyx_v_filtered_intervals) {
    e = (*v)(p->__pyx_v_filtered_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_force_upload_after_pause_cap) {
    e = (*v)(p->__pyx_v_force_upload_after_pause_cap, a); if (e) return e;
  }
  if (p->__pyx_v_headers) {
    e = (*v)(p->__pyx_v_headers, a); if (e) return e;
  }
  if (p->__pyx_9genexpr13__pyx_v_held) {
    e = (*v)(p->__pyx_9genexpr13__pyx_v_held, a); if (e) return e;
  }
  if (p->__pyx_v_held_interval_ids) {
    e = (*v)(p->__pyx_v_held_interval_ids, a); if (e) return e;
  }
  if (p->__pyx_v_held_intervals) {
    e = (*v)(p->__pyx_v_held_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_held_sent_count) {
    e = (*v)(p->__pyx_v_held_sent_count, a); if (e) return e;
  }
  if (p->__pyx_v_idle_popup_blocking) {
    e = (*v)(p->__pyx_v_idle_popup_blocking, a); if (e) return e;
  }
  if (p->__pyx_v_interval) {
    e = (*v)(p->__pyx_v_interval, a); if (e) return e;
  }
  if (p->__pyx_v_interval_payload) {
    e = (*v)(p->__pyx_v_interval_payload, a); if (e) return e;
  }
  if (p->__pyx_v_intervals) {
    e = (*v)(p->__pyx_v_intervals, a); if (e) return e;
  }
  if (p->__pyx_9genexpr11__pyx_v_iv) {
    e = (*v)(p->__pyx_9genexpr11__pyx_v_iv, a); if (e) return e;
  }
  if (p->__pyx_9genexpr12__pyx_v_iv) {
    e = (*v)(p->__pyx_9genexpr12__pyx_v_iv, a); if (e) return e;
  }
  if (p->__pyx_9genexpr14__pyx_v_iv) {
    e = (*v)(p->__pyx_9genexpr14__pyx_v_iv, a); if (e) return e;
  }
  if (p->__pyx_v_last_wake_time) {
    e = (*v)(p->__pyx_v_last_wake_time, a); if (e) return e;
  }
  if (p->__pyx_v_org_id) {
    e = (*v)(p->__pyx_v_org_id, a); if (e) return e;
  }
  if (p->__pyx_v_os_type) {
    e = (*v)(p->__pyx_v_os_type, a); if (e) return e;
  }
  if (p->__pyx_v_payload) {
    e = (*v)(p->__pyx_v_payload, a); if (e) return e;
  }
  if (p->__pyx_v_prev_day_unsent) {
    e = (*v)(p->__pyx_v_prev_day_unsent, a); if (e) return e;
  }
  if (p->__pyx_v_response) {
    e = (*v)(p->__pyx_v_response, a); if (e) return e;
  }
  if (p->__pyx_v_screen_url) {
    e = (*v)(p->__pyx_v_screen_url, a); if (e) return e;
  }
  if (p->__pyx_v_sd_token) {
    e = (*v)(p->__pyx_v_sd_token, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_sending_held_intervals) {
    e = (*v)(p->__pyx_v_sending_held_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_sending_intervals) {
    e = (*v)(p->__pyx_v_sending_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_should_pause_api) {
    e = (*v)(p->__pyx_v_should_pause_api, a); if (e) return e;
  }
  if (p->__pyx_v_start) {
    e = (*v)(p->__pyx_v_start, a); if (e) return e;
  }
  if (p->__pyx_v_stop_event) {
    e = (*v)(p->__pyx_v_stop_event, a); if (e) return e;
  }
  if (p->__pyx_v_time_since_wake) {
    e = (*v)(p->__pyx_v_time_since_wake, a); if (e) return e;
  }
  if (p->__pyx_v_timeout_reached) {
    e = (*v)(p->__pyx_v_timeout_reached, a); if (e) return e;
  }
  if (p->__pyx_v_url) {
    e = (*v)(p->__pyx_v_url, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  if (p->__pyx_v_user_id) {
    e = (*v)(p->__pyx_v_user_id, a); if (e) return e;
  }
  if (p->__pyx_v_wake_detector) {
    e = (*v)(p->__pyx_v_wake_detector, a); if (e) return e;
  }
  if (p->__pyx_v_wake_stats) {
    e = (*v)(p->__pyx_v_wake_stats, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_35__push_activity_log",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_35__push_activity_log", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_ans_array);
  Py_CLEAR(p->__pyx_v_del_e);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_error_message);
  Py_CLEAR(p->__pyx_v_interval_end_time);
  Py_CLEAR(p->__pyx_v_interval_start_time);
  Py_CLEAR(p->__pyx_v_particular_timestamp);
  Py_CLEAR(p->__pyx_v_response);
  Py_CLEAR(p->__pyx_v_s3_upload_link);
  Py_CLEAR(p->__pyx_v_screenshot_dir);
  Py_CLEAR(p->__pyx_v_screenshot_entity);
  Py_CLEAR(p->__pyx_v_screenshot_name);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_ss);
  Py_CLEAR(p->__pyx_v_ss_array);
  Py_CLEAR(p->__pyx_v_task);
  Py_CLEAR(p->__pyx_v_user_entity);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_6);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_ans_array) {
    e = (*v)(p->__pyx_v_ans_array, a); if (e) return e;
  }
  if (p->__pyx_v_del_e) {
    e = (*v)(p->__pyx_v_del_e, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_interval_end_time) {
    e = (*v)(p->__pyx_v_interval_end_time, a); if (e) return e;
  }
  if (p->__pyx_v_interval_start_time) {
    e = (*v)(p->__pyx_v_interval_start_time, a); if (e) return e;
  }
  if (p->__pyx_v_particular_timestamp) {
    e = (*v)(p->__pyx_v_particular_timestamp, a); if (e) return e;
  }
  if (p->__pyx_v_response) {
    e = (*v)(p->__pyx_v_response, a); if (e) return e;
  }
  if (p->__pyx_v_s3_upload_link) {
    e = (*v)(p->__pyx_v_s3_upload_link, a); if (e) return e;
  }
  if (p->__pyx_v_screenshot_dir) {
    e = (*v)(p->__pyx_v_screenshot_dir, a); if (e) return e;
  }
  if (p->__pyx_v_screenshot_entity) {
    e = (*v)(p->__pyx_v_screenshot_entity, a); if (e) return e;
  }
  if (p->__pyx_v_screenshot_name) {
    e = (*v)(p->__pyx_v_screenshot_name, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_ss) {
    e = (*v)(p->__pyx_v_ss, a); if (e) return e;
  }
  if (p->__pyx_v_ss_array) {
    e = (*v)(p->__pyx_v_ss_array, a); if (e) return e;
  }
  if (p->__pyx_v_task) {
    e = (*v)(p->__pyx_v_task, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_36_ss",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_36_ss", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_app_data);
  Py_CLEAR(p->__pyx_v_current_time);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_end_time);
  Py_CLEAR(p->__pyx_v_idle_time_ns);
  Py_CLEAR(p->__pyx_v_ioreg_output);
  Py_CLEAR(p->__pyx_v_line);
  Py_CLEAR(p->__pyx_v_period_duration);
  Py_CLEAR(p->__pyx_v_query);
  Py_CLEAR(p->__pyx_v_result);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_session);
  Py_CLEAR(p->__pyx_v_start_time);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_6);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  Py_CLEAR(p->__pyx_t_9);
  Py_CLEAR(p->__pyx_t_10);
  Py_CLEAR(p->__pyx_t_11);
  Py_CLEAR(p->__pyx_t_12);
  Py_CLEAR(p->__pyx_t_13);
  Py_CLEAR(p->__pyx_t_14);
  Py_CLEAR(p->__pyx_t_15);
  Py_CLEAR(p->__pyx_t_16);
  Py_CLEAR(p->__pyx_t_17);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_app_data) {
    e = (*v)(p->__pyx_v_app_data, a); if (e) return e;
  }
  if (p->__pyx_v_current_time) {
    e = (*v)(p->__pyx_v_current_time, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_end_time) {
    e = (*v)(p->__pyx_v_end_time, a); if (e) return e;
  }
  if (p->__pyx_v_ioreg_output) {
    e = (*v)(p->__pyx_v_ioreg_output, a); if (e) return e;
  }
  if (p->__pyx_v_line) {
    e = (*v)(p->__pyx_v_line, a); if (e) return e;
  }
  if (p->__pyx_v_period_duration) {
    e = (*v)(p->__pyx_v_period_duration, a); if (e) return e;
  }
  if (p->__pyx_v_query) {
    e = (*v)(p->__pyx_v_query, a); if (e) return e;
  }
  if (p->__pyx_v_result) {
    e = (*v)(p->__pyx_v_result, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_session) {
    e = (*v)(p->__pyx_v_session, a); if (e) return e;
  }
  if (p->__pyx_v_start_time) {
    e = (*v)(p->__pyx_v_start_time, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  if (p->__pyx_t_9) {
    e = (*v)(p->__pyx_t_9, a); if (e) return e;
  }
  if (p->__pyx_t_10) {
    e = (*v)(p->__pyx_t_10, a); if (e) return e;
  }
  if (p->__pyx_t_11) {
    e = (*v)(p->__pyx_t_11, a); if (e) return e;
  }
  if (p->__pyx_t_12) {
    e = (*v)(p->__pyx_t_12, a); if (e) return e;
  }
  if (p->__pyx_t_13) {
    e = (*v)(p->__pyx_t_13, a); if (e) return e;
  }
  if (p->__pyx_t_14) {
    e = (*v)(p->__pyx_t_14, a); if (e) return e;
  }
  if (p->__pyx_t_15) {
    e = (*v)(p->__pyx_t_15, a); if (e) return e;
  }
  if (p->__pyx_t_16) {
    e = (*v)(p->__pyx_t_16, a); if (e) return e;
  }
  if (p->__pyx_t_17) {
    e = (*v)(p->__pyx_t_17, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_37__verify_user_activity_during_period",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_37__verify_user_activity_during_period", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_end_time);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_start_time);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_end_time) {
    e = (*v)(p->__pyx_v_end_time, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_start_time) {
    e = (*v)(p->__pyx_v_start_time, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_38_get_activity_level_from_db",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_38_get_activity_level_from_db", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_app_monitor_time);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_time_diff);
  Py_CLEAR(p->__pyx_v_wake_time);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_app_monitor_time) {
    e = (*v)(p->__pyx_v_app_monitor_time, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_time_diff) {
    e = (*v)(p->__pyx_v_time_diff, a); if (e) return e;
  }
  if (p->__pyx_v_wake_time) {
    e = (*v)(p->__pyx_v_wake_time, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_39__is_app_monitor_data_stale",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_39__is_app_monitor_data_stale", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_app_data);
  Py_CLEAR(p->__pyx_v_counter);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_end_time);
  Py_CLEAR(p->__pyx_v_query);
  Py_CLEAR(p->__pyx_v_result);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_session);
  Py_CLEAR(p->__pyx_v_start_time);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_6);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  Py_CLEAR(p->__pyx_t_9);
  Py_CLEAR(p->__pyx_t_10);
  Py_CLEAR(p->__pyx_t_11);
  Py_CLEAR(p->__pyx_t_12);
  Py_CLEAR(p->__pyx_t_13);
  Py_CLEAR(p->__pyx_t_14);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_app_data) {
    e = (*v)(p->__pyx_v_app_data, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_end_time) {
    e = (*v)(p->__pyx_v_end_time, a); if (e) return e;
  }
  if (p->__pyx_v_query) {
    e = (*v)(p->__pyx_v_query, a); if (e) return e;
  }
  if (p->__pyx_v_result) {
    e = (*v)(p->__pyx_v_result, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_session) {
    e = (*v)(p->__pyx_v_session, a); if (e) return e;
  }
  if (p->__pyx_v_start_time) {
    e = (*v)(p->__pyx_v_start_time, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  if (p->__pyx_t_9) {
    e = (*v)(p->__pyx_t_9, a); if (e) return e;
  }
  if (p->__pyx_t_10) {
    e = (*v)(p->__pyx_t_10, a); if (e) return e;
  }
  if (p->__pyx_t_11) {
    e = (*v)(p->__pyx_t_11, a); if (e) return e;
  }
  if (p->__pyx_t_12) {
    e = (*v)(p->__pyx_t_12, a); if (e) return e;
  }
  if (p->__pyx_t_13) {
    e = (*v)(p->__pyx_t_13, a); if (e) return e;
  }
  if (p->__pyx_t_14) {
    e = (*v)(p->__pyx_t_14, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_40__has_any_activity_in_interval",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_40__has_any_activity_in_interval", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v__dt_match);
  Py_CLEAR(p->__pyx_v_activity_level);
  Py_CLEAR(p->__pyx_v_align_stop);
  Py_CLEAR(p->__pyx_v_day_intervals);
  Py_CLEAR(p->__pyx_v_day_start_time);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_e2);
  Py_CLEAR(p->__pyx_v_effective_start_time);
  Py_CLEAR(p->__pyx_v_file_path);
  Py_CLEAR(p->__pyx_v_filtered_count);
  Py_CLEAR(p->__pyx_v_filtered_intervals);
  Py_CLEAR(p->__pyx_v_force_stop_time);
  Py_CLEAR(p->__pyx_v_gap_seconds);
  Py_CLEAR(p->__pyx_v_genexpr);
  Py_CLEAR(p->__pyx_v_grouped_intervals);
  Py_CLEAR(p->__pyx_v_idle_note_url);
  Py_CLEAR(p->__pyx_9genexpr15__pyx_v_interval);
  Py_CLEAR(p->__pyx_v_interval);
  Py_CLEAR(p->__pyx_v_interval_file_map);
  Py_CLEAR(p->__pyx_v_interval_id);
  Py_CLEAR(p->__pyx_v_interval_ids);
  Py_CLEAR(p->__pyx_v_interval_note_map);
  Py_CLEAR(p->__pyx_v_interval_payload);
  Py_CLEAR(p->__pyx_v_interval_payloads);
  Py_CLEAR(p->__pyx_v_intervals);
  Py_CLEAR(p->__pyx_v_last_in_this_day);
  Py_CLEAR(p->__pyx_v_last_interval);
  Py_CLEAR(p->__pyx_v_last_match);
  Py_CLEAR(p->__pyx_v_notes_entries);
  Py_CLEAR(p->__pyx_v_notes_entry);
  Py_CLEAR(p->__pyx_v_notes_query);
  Py_CLEAR(p->__pyx_v_notes_result);
  Py_CLEAR(p->__pyx_v_org_id);
  Py_CLEAR(p->__pyx_v_payload);
  Py_CLEAR(p->__pyx_v_payload_from);
  Py_CLEAR(p->__pyx_v_payload_project_id);
  Py_CLEAR(p->__pyx_v_payload_task_id);
  Py_CLEAR(p->__pyx_v_payload_to);
  Py_CLEAR(p->__pyx_v_pinned_start);
  Py_CLEAR(p->__pyx_v_project_id);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_session);
  Py_CLEAR(p->__pyx_v_ss_end_time);
  Py_CLEAR(p->__pyx_v_stop_dt);
  Py_CLEAR(p->__pyx_v_stop_dt_for_intervals);
  Py_CLEAR(p->__pyx_v_stop_value);
  Py_CLEAR(p->__pyx_v_target_date);
  Py_CLEAR(p->__pyx_v_task_id);
  Py_CLEAR(p->__pyx_v_user_entity);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_6);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  Py_CLEAR(p->__pyx_t_9);
  Py_CLEAR(p->__pyx_t_10);
  Py_CLEAR(p->__pyx_t_11);
  Py_CLEAR(p->__pyx_t_12);
  Py_CLEAR(p->__pyx_t_13);
  Py_CLEAR(p->__pyx_t_14);
  Py_CLEAR(p->__pyx_t_15);
  Py_CLEAR(p->__pyx_t_16);
  Py_CLEAR(p->__pyx_t_17);
  Py_CLEAR(p->__pyx_t_18);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v__dt_match) {
    e = (*v)(p->__pyx_v__dt_match, a); if (e) return e;
  }
  if (p->__pyx_v_activity_level) {
    e = (*v)(p->__pyx_v_activity_level, a); if (e) return e;
  }
  if (p->__pyx_v_align_stop) {
    e = (*v)(p->__pyx_v_align_stop, a); if (e) return e;
  }
  if (p->__pyx_v_day_intervals) {
    e = (*v)(p->__pyx_v_day_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_day_start_time) {
    e = (*v)(p->__pyx_v_day_start_time, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_e2) {
    e = (*v)(p->__pyx_v_e2, a); if (e) return e;
  }
  if (p->__pyx_v_effective_start_time) {
    e = (*v)(p->__pyx_v_effective_start_time, a); if (e) return e;
  }
  if (p->__pyx_v_file_path) {
    e = (*v)(p->__pyx_v_file_path, a); if (e) return e;
  }
  if (p->__pyx_v_filtered_count) {
    e = (*v)(p->__pyx_v_filtered_count, a); if (e) return e;
  }
  if (p->__pyx_v_filtered_intervals) {
    e = (*v)(p->__pyx_v_filtered_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_force_stop_time) {
    e = (*v)(p->__pyx_v_force_stop_time, a); if (e) return e;
  }
  if (p->__pyx_v_gap_seconds) {
    e = (*v)(p->__pyx_v_gap_seconds, a); if (e) return e;
  }
  if (p->__pyx_v_genexpr) {
    e = (*v)(p->__pyx_v_genexpr, a); if (e) return e;
  }
  if (p->__pyx_v_grouped_intervals) {
    e = (*v)(p->__pyx_v_grouped_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_idle_note_url) {
    e = (*v)(p->__pyx_v_idle_note_url, a); if (e) return e;
  }
  if (p->__pyx_9genexpr15__pyx_v_interval) {
    e = (*v)(p->__pyx_9genexpr15__pyx_v_interval, a); if (e) return e;
  }
  if (p->__pyx_v_interval) {
    e = (*v)(p->__pyx_v_interval, a); if (e) return e;
  }
  if (p->__pyx_v_interval_file_map) {
    e = (*v)(p->__pyx_v_interval_file_map, a); if (e) return e;
  }
  if (p->__pyx_v_interval_id) {
    e = (*v)(p->__pyx_v_interval_id, a); if (e) return e;
  }
  if (p->__pyx_v_interval_ids) {
    e = (*v)(p->__pyx_v_interval_ids, a); if (e) return e;
  }
  if (p->__pyx_v_interval_note_map) {
    e = (*v)(p->__pyx_v_interval_note_map, a); if (e) return e;
  }
  if (p->__pyx_v_interval_payload) {
    e = (*v)(p->__pyx_v_interval_payload, a); if (e) return e;
  }
  if (p->__pyx_v_interval_payloads) {
    e = (*v)(p->__pyx_v_interval_payloads, a); if (e) return e;
  }
  if (p->__pyx_v_intervals) {
    e = (*v)(p->__pyx_v_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_last_in_this_day) {
    e = (*v)(p->__pyx_v_last_in_this_day, a); if (e) return e;
  }
  if (p->__pyx_v_last_interval) {
    e = (*v)(p->__pyx_v_last_interval, a); if (e) return e;
  }
  if (p->__pyx_v_last_match) {
    e = (*v)(p->__pyx_v_last_match, a); if (e) return e;
  }
  if (p->__pyx_v_notes_entries) {
    e = (*v)(p->__pyx_v_notes_entries, a); if (e) return e;
  }
  if (p->__pyx_v_notes_entry) {
    e = (*v)(p->__pyx_v_notes_entry, a); if (e) return e;
  }
  if (p->__pyx_v_notes_query) {
    e = (*v)(p->__pyx_v_notes_query, a); if (e) return e;
  }
  if (p->__pyx_v_notes_result) {
    e = (*v)(p->__pyx_v_notes_result, a); if (e) return e;
  }
  if (p->__pyx_v_org_id) {
    e = (*v)(p->__pyx_v_org_id, a); if (e) return e;
  }
  if (p->__pyx_v_payload) {
    e = (*v)(p->__pyx_v_payload, a); if (e) return e;
  }
  if (p->__pyx_v_payload_from) {
    e = (*v)(p->__pyx_v_payload_from, a); if (e) return e;
  }
  if (p->__pyx_v_payload_to) {
    e = (*v)(p->__pyx_v_payload_to, a); if (e) return e;
  }
  if (p->__pyx_v_pinned_start) {
    e = (*v)(p->__pyx_v_pinned_start, a); if (e) return e;
  }
  if (p->__pyx_v_project_id) {
    e = (*v)(p->__pyx_v_project_id, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_session) {
    e = (*v)(p->__pyx_v_session, a); if (e) return e;
  }
  if (p->__pyx_v_ss_end_time) {
    e = (*v)(p->__pyx_v_ss_end_time, a); if (e) return e;
  }
  if (p->__pyx_v_stop_dt) {
    e = (*v)(p->__pyx_v_stop_dt, a); if (e) return e;
  }
  if (p->__pyx_v_stop_dt_for_intervals) {
    e = (*v)(p->__pyx_v_stop_dt_for_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_stop_value) {
    e = (*v)(p->__pyx_v_stop_value, a); if (e) return e;
  }
  if (p->__pyx_v_target_date) {
    e = (*v)(p->__pyx_v_target_date, a); if (e) return e;
  }
  if (p->__pyx_v_task_id) {
    e = (*v)(p->__pyx_v_task_id, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  if (p->__pyx_t_9) {
    e = (*v)(p->__pyx_t_9, a); if (e) return e;
  }
  if (p->__pyx_t_10) {
    e = (*v)(p->__pyx_t_10, a); if (e) return e;
  }
  if (p->__pyx_t_11) {
    e = (*v)(p->__pyx_t_11, a); if (e) return e;
  }
  if (p->__pyx_t_12) {
    e = (*v)(p->__pyx_t_12, a); if (e) return e;
  }
  if (p->__pyx_t_13) {
    e = (*v)(p->__pyx_t_13, a); if (e) return e;
  }
  if (p->__pyx_t_14) {
    e = (*v)(p->__pyx_t_14, a); if (e) return e;
  }
  if (p->__pyx_t_15) {
    e = (*v)(p->__pyx_t_15, a); if (e) return e;
  }
  if (p->__pyx_t_16) {
    e = (*v)(p->__pyx_t_16, a); if (e) return e;
  }
  if (p->__pyx_t_17) {
    e = (*v)(p->__pyx_t_17, a); if (e) return e;
  }
  if (p->__pyx_t_18) {
    e = (*v)(p->__pyx_t_18, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_41_process_intervals_bulk",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_41_process_intervals_bulk", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_genexpr_arg_0);
  Py_CLEAR(p->__pyx_v_iv);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_genexpr_arg_0) {
    e = (*v)(p->__pyx_genexpr_arg_0, a); if (e) return e;
  }
  if (p->__pyx_v_iv) {
    e = (*v)(p->__pyx_v_iv, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_42_genexpr",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_42_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_file_location);
  Py_CLEAR(p->__pyx_v_file_name);
  Py_CLEAR(p->__pyx_v_idx);
  Py_CLEAR(p->__pyx_v_old_screenshots);
  Py_CLEAR(p->__pyx_v_result);
  Py_CLEAR(p->__pyx_9genexpr17__pyx_v_s);
  Py_CLEAR(p->__pyx_v_screenshot);
  Py_CLEAR(p->__pyx_v_screenshot_data);
  Py_CLEAR(p->__pyx_v_screenshot_ids);
  Py_CLEAR(p->__pyx_v_screenshot_query);
  Py_CLEAR(p->__pyx_v_screenshots_to_delete);
  Py_CLEAR(p->__pyx_v_script_path);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_session);
  Py_CLEAR(p->__pyx_v_seven_days_ago);
  Py_CLEAR(p->__pyx_v_target_directory);
  Py_CLEAR(p->__pyx_v_target_directory_mac);
  Py_CLEAR(p->__pyx_v_target_directory_stealth);
  Py_CLEAR(p->__pyx_v_target_directoryw);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_6);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  Py_CLEAR(p->__pyx_t_9);
  Py_CLEAR(p->__pyx_t_10);
  Py_CLEAR(p->__pyx_t_11);
  Py_CLEAR(p->__pyx_t_12);
  Py_CLEAR(p->__pyx_t_13);
  Py_CLEAR(p->__pyx_t_14);
  Py_CLEAR(p->__pyx_t_15);
  Py_CLEAR(p->__pyx_t_16);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_file_location) {
    e = (*v)(p->__pyx_v_file_location, a); if (e) return e;
  }
  if (p->__pyx_v_file_name) {
    e = (*v)(p->__pyx_v_file_name, a); if (e) return e;
  }
  if (p->__pyx_v_idx) {
    e = (*v)(p->__pyx_v_idx, a); if (e) return e;
  }
  if (p->__pyx_v_old_screenshots) {
    e = (*v)(p->__pyx_v_old_screenshots, a); if (e) return e;
  }
  if (p->__pyx_v_result) {
    e = (*v)(p->__pyx_v_result, a); if (e) return e;
  }
  if (p->__pyx_9genexpr17__pyx_v_s) {
    e = (*v)(p->__pyx_9genexpr17__pyx_v_s, a); if (e) return e;
  }
  if (p->__pyx_v_screenshot) {
    e = (*v)(p->__pyx_v_screenshot, a); if (e) return e;
  }
  if (p->__pyx_v_screenshot_data) {
    e = (*v)(p->__pyx_v_screenshot_data, a); if (e) return e;
  }
  if (p->__pyx_v_screenshot_ids) {
    e = (*v)(p->__pyx_v_screenshot_ids, a); if (e) return e;
  }
  if (p->__pyx_v_screenshot_query) {
    e = (*v)(p->__pyx_v_screenshot_query, a); if (e) return e;
  }
  if (p->__pyx_v_screenshots_to_delete) {
    e = (*v)(p->__pyx_v_screenshots_to_delete, a); if (e) return e;
  }
  if (p->__pyx_v_script_path) {
    e = (*v)(p->__pyx_v_script_path, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_session) {
    e = (*v)(p->__pyx_v_session, a); if (e) return e;
  }
  if (p->__pyx_v_seven_days_ago) {
    e = (*v)(p->__pyx_v_seven_days_ago, a); if (e) return e;
  }
  if (p->__pyx_v_target_directory) {
    e = (*v)(p->__pyx_v_target_directory, a); if (e) return e;
  }
  if (p->__pyx_v_target_directory_mac) {
    e = (*v)(p->__pyx_v_target_directory_mac, a); if (e) return e;
  }
  if (p->__pyx_v_target_directory_stealth) {
    e = (*v)(p->__pyx_v_target_directory_stealth, a); if (e) return e;
  }
  if (p->__pyx_v_target_directoryw) {
    e = (*v)(p->__pyx_v_target_directoryw, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  if (p->__pyx_t_9) {
    e = (*v)(p->__pyx_t_9, a); if (e) return e;
  }
  if (p->__pyx_t_10) {
    e = (*v)(p->__pyx_t_10, a); if (e) return e;
  }
  if (p->__pyx_t_11) {
    e = (*v)(p->__pyx_t_11, a); if (e) return e;
  }
  if (p->__pyx_t_12) {
    e = (*v)(p->__pyx_t_12, a); if (e) return e;
  }
  if (p->__pyx_t_13) {
    e = (*v)(p->__pyx_t_13, a); if (e) return e;
  }
  if (p->__pyx_t_14) {
    e = (*v)(p->__pyx_t_14, a); if (e) return e;
  }
  if (p->__pyx_t_15) {
    e = (*v)(p->__pyx_t_15, a); if (e) return e;
  }
  if (p->__pyx_t_16) {
    e = (*v)(p->__pyx_t_16, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_43_delete_old_data_and_screenshots",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_43_delete_old_data_and_screenshots", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_ErrorCode);
  Py_CLEAR(p->__pyx_v__);
  Py_CLEAR(p->__pyx_v_chunk_duration);
  Py_CLEAR(p->__pyx_v_chunks);
  Py_CLEAR(p->__pyx_v_cleanup_enabled);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_logs_path);
  Py_CLEAR(p->__pyx_v_mac_log);
  Py_CLEAR(p->__pyx_v_perform_comprehensive_log_cleanup);
  Py_CLEAR(p->__pyx_v_s3_key);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_stop_event);
  Py_CLEAR(p->__pyx_v_task);
  Py_CLEAR(p->__pyx_v_timestamp);
  Py_CLEAR(p->__pyx_v_total_sleep);
  Py_CLEAR(p->__pyx_v_user_entity);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  Py_CLEAR(p->__pyx_t_9);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_ErrorCode) {
    e = (*v)(p->__pyx_v_ErrorCode, a); if (e) return e;
  }
  if (p->__pyx_v__) {
    e = (*v)(p->__pyx_v__, a); if (e) return e;
  }
  if (p->__pyx_v_chunk_duration) {
    e = (*v)(p->__pyx_v_chunk_duration, a); if (e) return e;
  }
  if (p->__pyx_v_chunks) {
    e = (*v)(p->__pyx_v_chunks, a); if (e) return e;
  }
  if (p->__pyx_v_cleanup_enabled) {
    e = (*v)(p->__pyx_v_cleanup_enabled, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_logs_path) {
    e = (*v)(p->__pyx_v_logs_path, a); if (e) return e;
  }
  if (p->__pyx_v_mac_log) {
    e = (*v)(p->__pyx_v_mac_log, a); if (e) return e;
  }
  if (p->__pyx_v_perform_comprehensive_log_cleanup) {
    e = (*v)(p->__pyx_v_perform_comprehensive_log_cleanup, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_stop_event) {
    e = (*v)(p->__pyx_v_stop_event, a); if (e) return e;
  }
  if (p->__pyx_v_task) {
    e = (*v)(p->__pyx_v_task, a); if (e) return e;
  }
  if (p->__pyx_v_timestamp) {
    e = (*v)(p->__pyx_v_timestamp, a); if (e) return e;
  }
  if (p->__pyx_v_total_sleep) {
    e = (*v)(p->__pyx_v_total_sleep, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  if (p->__pyx_t_9) {
    e = (*v)(p->__pyx_t_9, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_44_start_status_activity",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_44_start_status_activity", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_copy_error);
  Py_CLEAR(p->__pyx_v_copy_size);
  Py_CLEAR(p->__pyx_v_database_dir);
  Py_CLEAR(p->__pyx_v_database_server);
  Py_CLEAR(p->__pyx_v_dt_obj);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_original_size);
  Py_CLEAR(p->__pyx_v_result);
  Py_CLEAR(p->__pyx_v_script_path);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_target_directory);
  Py_CLEAR(p->__pyx_v_temp_file);
  Py_CLEAR(p->__pyx_v_temp_file_path);
  Py_CLEAR(p->__pyx_v_timestamp_db);
  Py_CLEAR(p->__pyx_v_unix_timestamp);
  Py_CLEAR(p->__pyx_v_upload_error);
  Py_CLEAR(p->__pyx_v_user_entity);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_6);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_copy_error) {
    e = (*v)(p->__pyx_v_copy_error, a); if (e) return e;
  }
  if (p->__pyx_v_copy_size) {
    e = (*v)(p->__pyx_v_copy_size, a); if (e) return e;
  }
  if (p->__pyx_v_database_dir) {
    e = (*v)(p->__pyx_v_database_dir, a); if (e) return e;
  }
  if (p->__pyx_v_dt_obj) {
    e = (*v)(p->__pyx_v_dt_obj, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_original_size) {
    e = (*v)(p->__pyx_v_original_size, a); if (e) return e;
  }
  if (p->__pyx_v_result) {
    e = (*v)(p->__pyx_v_result, a); if (e) return e;
  }
  if (p->__pyx_v_script_path) {
    e = (*v)(p->__pyx_v_script_path, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_target_directory) {
    e = (*v)(p->__pyx_v_target_directory, a); if (e) return e;
  }
  if (p->__pyx_v_temp_file) {
    e = (*v)(p->__pyx_v_temp_file, a); if (e) return e;
  }
  if (p->__pyx_v_temp_file_path) {
    e = (*v)(p->__pyx_v_temp_file_path, a); if (e) return e;
  }
  if (p->__pyx_v_timestamp_db) {
    e = (*v)(p->__pyx_v_timestamp_db, a); if (e) return e;
  }
  if (p->__pyx_v_upload_error) {
    e = (*v)(p->__pyx_v_upload_error, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_45_db_to_server",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_45_db_to_server", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_current_counter);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_first_date);
  Py_CLEAR(p->__pyx_v_first_entry);
  Py_CLEAR(p->__pyx_v_first_entry_counter);
  Py_CLEAR(p->__pyx_v_intervals);
  Py_CLEAR(p->__pyx_v_query);
  Py_CLEAR(p->__pyx_v_result);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_session);
  Py_CLEAR(p->__pyx_v_today);
  Py_CLEAR(p->__pyx_v_user_entity);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_6);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  Py_CLEAR(p->__pyx_t_9);
  Py_CLEAR(p->__pyx_t_10);
  Py_CLEAR(p->__pyx_t_11);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_current_counter) {
    e = (*v)(p->__pyx_v_current_counter, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_first_date) {
    e = (*v)(p->__pyx_v_first_date, a); if (e) return e;
  }
  if (p->__pyx_v_first_entry) {
    e = (*v)(p->__pyx_v_first_entry, a); if (e) return e;
  }
  if (p->__pyx_v_first_entry_counter) {
    e = (*v)(p->__pyx_v_first_entry_counter, a); if (e) return e;
  }
  if (p->__pyx_v_intervals) {
    e = (*v)(p->__pyx_v_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_query) {
    e = (*v)(p->__pyx_v_query, a); if (e) return e;
  }
  if (p->__pyx_v_result) {
    e = (*v)(p->__pyx_v_result, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_session) {
    e = (*v)(p->__pyx_v_session, a); if (e) return e;
  }
  if (p->__pyx_v_today) {
    e = (*v)(p->__pyx_v_today, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  if (p->__pyx_t_9) {
    e = (*v)(p->__pyx_t_9, a); if (e) return e;
  }
  if (p->__pyx_t_10) {
    e = (*v)(p->__pyx_t_10, a); if (e) return e;
  }
  if (p->__pyx_t_11) {
    e = (*v)(p->__pyx_t_11, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_46_getting_unsent_interval",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_46_getting_unsent_interval", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v__response);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_final_payload);
  Py_CLEAR(p->__pyx_v_interval);
  Py_CLEAR(p->__pyx_v_interval_id);
  Py_CLEAR(p->__pyx_v_interval_payload);
  Py_CLEAR(p->__pyx_v_org_id);
  Py_CLEAR(p->__pyx_v_payload);
  Py_CLEAR(p->__pyx_v_prev_day_unsent);
  Py_CLEAR(p->__pyx_v_project_id);
  Py_CLEAR(p->__pyx_v_response);
  Py_CLEAR(p->__pyx_v_screen_url);
  Py_CLEAR(p->__pyx_v_sd_token);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_start);
  Py_CLEAR(p->__pyx_v_task_id);
  Py_CLEAR(p->__pyx_v_user_entity);
  Py_CLEAR(p->__pyx_v_user_id);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v__response) {
    e = (*v)(p->__pyx_v__response, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_final_payload) {
    e = (*v)(p->__pyx_v_final_payload, a); if (e) return e;
  }
  if (p->__pyx_v_interval) {
    e = (*v)(p->__pyx_v_interval, a); if (e) return e;
  }
  if (p->__pyx_v_interval_id) {
    e = (*v)(p->__pyx_v_interval_id, a); if (e) return e;
  }
  if (p->__pyx_v_interval_payload) {
    e = (*v)(p->__pyx_v_interval_payload, a); if (e) return e;
  }
  if (p->__pyx_v_org_id) {
    e = (*v)(p->__pyx_v_org_id, a); if (e) return e;
  }
  if (p->__pyx_v_payload) {
    e = (*v)(p->__pyx_v_payload, a); if (e) return e;
  }
  if (p->__pyx_v_prev_day_unsent) {
    e = (*v)(p->__pyx_v_prev_day_unsent, a); if (e) return e;
  }
  if (p->__pyx_v_project_id) {
    e = (*v)(p->__pyx_v_project_id, a); if (e) return e;
  }
  if (p->__pyx_v_response) {
    e = (*v)(p->__pyx_v_response, a); if (e) return e;
  }
  if (p->__pyx_v_screen_url) {
    e = (*v)(p->__pyx_v_screen_url, a); if (e) return e;
  }
  if (p->__pyx_v_sd_token) {
    e = (*v)(p->__pyx_v_sd_token, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_start) {
    e = (*v)(p->__pyx_v_start, a); if (e) return e;
  }
  if (p->__pyx_v_task_id) {
    e = (*v)(p->__pyx_v_task_id, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  if (p->__pyx_v_user_id) {
    e = (*v)(p->__pyx_v_user_id, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_47_sending_unsent_intervals",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_47_sending_unsent_intervals", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_close_time);
  Py_CLEAR(p->__pyx_v_payload_project_id);
  Py_CLEAR(p->__pyx_v_payload_task_id);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_user_entity);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_close_time) {
    e = (*v)(p->__pyx_v_close_time, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_48_last_api_call",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_48_last_api_call", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v__response);
  Py_CLEAR(p->__pyx_v_activityLevel);
  Py_CLEAR(p->__pyx_v_activity_level);
  Py_CLEAR(p->__pyx_v_activity_queue_size);
  Py_CLEAR(p->__pyx_v_already_in_list);
  Py_CLEAR(p->__pyx_v_attempt);
  Py_CLEAR(p->__pyx_v_break_start_time);
  Py_CLEAR(p->__pyx_v_close_time);
  Py_CLEAR(p->__pyx_v_current_break_id);
  Py_CLEAR(p->__pyx_v_current_session_counter);
  Py_CLEAR(p->__pyx_v_current_session_counter_for_last);
  Py_CLEAR(p->__pyx_v_datetime_matches);
  Py_CLEAR(p->__pyx_v_datetime_matches_final);
  Py_CLEAR(p->__pyx_v_db_interval);
  Py_CLEAR(p->__pyx_v_db_last);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_end_date);
  Py_CLEAR(p->__pyx_v_et);
  Py_CLEAR(p->__pyx_v_fallback_error);
  Py_CLEAR(p->__pyx_v_gap_seconds);
  Py_CLEAR(p->__pyx_v_genexpr);
  Py_CLEAR(p->__pyx_v_has_zero_activity);
  Py_CLEAR(p->__pyx_v_idx);
  Py_CLEAR(p->__pyx_v_interval);
  Py_CLEAR(p->__pyx_v_interval_end_date);
  Py_CLEAR(p->__pyx_v_interval_payload);
  Py_CLEAR(p->__pyx_v_interval_to_update);
  Py_CLEAR(p->__pyx_v_intervals);
  Py_CLEAR(p->__pyx_v_intervals_to_update);
  Py_CLEAR(p->__pyx_v_intervals_updated_count);
  Py_CLEAR(p->__pyx_v_is_idle);
  Py_CLEAR(p->__pyx_v_last_interval);
  Py_CLEAR(p->__pyx_v_last_interval_end);
  Py_CLEAR(p->__pyx_v_last_interval_found);
  Py_CLEAR(p->__pyx_v_last_interval_id);
  Py_CLEAR(p->__pyx_v_last_interval_in_list);
  Py_CLEAR(p->__pyx_v_last_interval_obj);
  Py_CLEAR(p->__pyx_v_last_interval_was_sent);
  Py_CLEAR(p->__pyx_v_last_ss_urls);
  Py_CLEAR(p->__pyx_v_max_retries);
  Py_CLEAR(p->__pyx_v_max_verification_retries);
  Py_CLEAR(p->__pyx_v_payload_project_id);
  Py_CLEAR(p->__pyx_v_payload_task_id);
  Py_CLEAR(p->__pyx_v_popup_is_active);
  Py_CLEAR(p->__pyx_v_processed_count);
  Py_CLEAR(p->__pyx_v_q);
  Py_CLEAR(p->__pyx_v_query);
  Py_CLEAR(p->__pyx_v_res);
  Py_CLEAR(p->__pyx_v_response);
  Py_CLEAR(p->__pyx_v_result);
  Py_CLEAR(p->__pyx_v_retry_delays);
  Py_CLEAR(p->__pyx_v_screen_url);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_sending_intervals);
  Py_CLEAR(p->__pyx_v_session);
  Py_CLEAR(p->__pyx_v_st);
  Py_CLEAR(p->__pyx_v_start_date);
  Py_CLEAR(p->__pyx_v_time_diff_seconds);
  Py_CLEAR(p->__pyx_v_tol);
  Py_CLEAR(p->__pyx_v_total_queue_size);
  Py_CLEAR(p->__pyx_v_trimmed_partial);
  Py_CLEAR(p->__pyx_v_unsent_intervals);
  Py_CLEAR(p->__pyx_v_updated_interval_ids);
  Py_CLEAR(p->__pyx_v_user_entity);
  Py_CLEAR(p->__pyx_v_verify_attempt);
  Py_CLEAR(p->__pyx_v_verify_error);
  Py_CLEAR(p->__pyx_v_work_stop);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_6);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  Py_CLEAR(p->__pyx_t_9);
  Py_CLEAR(p->__pyx_t_10);
  Py_CLEAR(p->__pyx_t_11);
  Py_CLEAR(p->__pyx_t_12);
  Py_CLEAR(p->__pyx_t_13);
  Py_CLEAR(p->__pyx_t_14);
  Py_CLEAR(p->__pyx_t_15);
  Py_CLEAR(p->__pyx_t_16);
  Py_CLEAR(p->__pyx_t_17);
  Py_CLEAR(p->__pyx_t_19);
  Py_CLEAR(p->__pyx_t_20);
  Py_CLEAR(p->__pyx_t_21);
  Py_CLEAR(p->__pyx_t_22);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v__response) {
    e = (*v)(p->__pyx_v__response, a); if (e) return e;
  }
  if (p->__pyx_v_activityLevel) {
    e = (*v)(p->__pyx_v_activityLevel, a); if (e) return e;
  }
  if (p->__pyx_v_activity_level) {
    e = (*v)(p->__pyx_v_activity_level, a); if (e) return e;
  }
  if (p->__pyx_v_activity_queue_size) {
    e = (*v)(p->__pyx_v_activity_queue_size, a); if (e) return e;
  }
  if (p->__pyx_v_already_in_list) {
    e = (*v)(p->__pyx_v_already_in_list, a); if (e) return e;
  }
  if (p->__pyx_v_attempt) {
    e = (*v)(p->__pyx_v_attempt, a); if (e) return e;
  }
  if (p->__pyx_v_break_start_time) {
    e = (*v)(p->__pyx_v_break_start_time, a); if (e) return e;
  }
  if (p->__pyx_v_close_time) {
    e = (*v)(p->__pyx_v_close_time, a); if (e) return e;
  }
  if (p->__pyx_v_current_break_id) {
    e = (*v)(p->__pyx_v_current_break_id, a); if (e) return e;
  }
  if (p->__pyx_v_current_session_counter) {
    e = (*v)(p->__pyx_v_current_session_counter, a); if (e) return e;
  }
  if (p->__pyx_v_current_session_counter_for_last) {
    e = (*v)(p->__pyx_v_current_session_counter_for_last, a); if (e) return e;
  }
  if (p->__pyx_v_datetime_matches) {
    e = (*v)(p->__pyx_v_datetime_matches, a); if (e) return e;
  }
  if (p->__pyx_v_datetime_matches_final) {
    e = (*v)(p->__pyx_v_datetime_matches_final, a); if (e) return e;
  }
  if (p->__pyx_v_db_interval) {
    e = (*v)(p->__pyx_v_db_interval, a); if (e) return e;
  }
  if (p->__pyx_v_db_last) {
    e = (*v)(p->__pyx_v_db_last, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_end_date) {
    e = (*v)(p->__pyx_v_end_date, a); if (e) return e;
  }
  if (p->__pyx_v_et) {
    e = (*v)(p->__pyx_v_et, a); if (e) return e;
  }
  if (p->__pyx_v_fallback_error) {
    e = (*v)(p->__pyx_v_fallback_error, a); if (e) return e;
  }
  if (p->__pyx_v_gap_seconds) {
    e = (*v)(p->__pyx_v_gap_seconds, a); if (e) return e;
  }
  if (p->__pyx_v_genexpr) {
    e = (*v)(p->__pyx_v_genexpr, a); if (e) return e;
  }
  if (p->__pyx_v_has_zero_activity) {
    e = (*v)(p->__pyx_v_has_zero_activity, a); if (e) return e;
  }
  if (p->__pyx_v_idx) {
    e = (*v)(p->__pyx_v_idx, a); if (e) return e;
  }
  if (p->__pyx_v_interval) {
    e = (*v)(p->__pyx_v_interval, a); if (e) return e;
  }
  if (p->__pyx_v_interval_end_date) {
    e = (*v)(p->__pyx_v_interval_end_date, a); if (e) return e;
  }
  if (p->__pyx_v_interval_payload) {
    e = (*v)(p->__pyx_v_interval_payload, a); if (e) return e;
  }
  if (p->__pyx_v_interval_to_update) {
    e = (*v)(p->__pyx_v_interval_to_update, a); if (e) return e;
  }
  if (p->__pyx_v_intervals) {
    e = (*v)(p->__pyx_v_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_intervals_to_update) {
    e = (*v)(p->__pyx_v_intervals_to_update, a); if (e) return e;
  }
  if (p->__pyx_v_intervals_updated_count) {
    e = (*v)(p->__pyx_v_intervals_updated_count, a); if (e) return e;
  }
  if (p->__pyx_v_is_idle) {
    e = (*v)(p->__pyx_v_is_idle, a); if (e) return e;
  }
  if (p->__pyx_v_last_interval) {
    e = (*v)(p->__pyx_v_last_interval, a); if (e) return e;
  }
  if (p->__pyx_v_last_interval_end) {
    e = (*v)(p->__pyx_v_last_interval_end, a); if (e) return e;
  }
  if (p->__pyx_v_last_interval_found) {
    e = (*v)(p->__pyx_v_last_interval_found, a); if (e) return e;
  }
  if (p->__pyx_v_last_interval_id) {
    e = (*v)(p->__pyx_v_last_interval_id, a); if (e) return e;
  }
  if (p->__pyx_v_last_interval_in_list) {
    e = (*v)(p->__pyx_v_last_interval_in_list, a); if (e) return e;
  }
  if (p->__pyx_v_last_interval_obj) {
    e = (*v)(p->__pyx_v_last_interval_obj, a); if (e) return e;
  }
  if (p->__pyx_v_last_interval_was_sent) {
    e = (*v)(p->__pyx_v_last_interval_was_sent, a); if (e) return e;
  }
  if (p->__pyx_v_last_ss_urls) {
    e = (*v)(p->__pyx_v_last_ss_urls, a); if (e) return e;
  }
  if (p->__pyx_v_max_retries) {
    e = (*v)(p->__pyx_v_max_retries, a); if (e) return e;
  }
  if (p->__pyx_v_max_verification_retries) {
    e = (*v)(p->__pyx_v_max_verification_retries, a); if (e) return e;
  }
  if (p->__pyx_v_popup_is_active) {
    e = (*v)(p->__pyx_v_popup_is_active, a); if (e) return e;
  }
  if (p->__pyx_v_processed_count) {
    e = (*v)(p->__pyx_v_processed_count, a); if (e) return e;
  }
  if (p->__pyx_v_q) {
    e = (*v)(p->__pyx_v_q, a); if (e) return e;
  }
  if (p->__pyx_v_query) {
    e = (*v)(p->__pyx_v_query, a); if (e) return e;
  }
  if (p->__pyx_v_res) {
    e = (*v)(p->__pyx_v_res, a); if (e) return e;
  }
  if (p->__pyx_v_response) {
    e = (*v)(p->__pyx_v_response, a); if (e) return e;
  }
  if (p->__pyx_v_result) {
    e = (*v)(p->__pyx_v_result, a); if (e) return e;
  }
  if (p->__pyx_v_retry_delays) {
    e = (*v)(p->__pyx_v_retry_delays, a); if (e) return e;
  }
  if (p->__pyx_v_screen_url) {
    e = (*v)(p->__pyx_v_screen_url, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_sending_intervals) {
    e = (*v)(p->__pyx_v_sending_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_session) {
    e = (*v)(p->__pyx_v_session, a); if (e) return e;
  }
  if (p->__pyx_v_st) {
    e = (*v)(p->__pyx_v_st, a); if (e) return e;
  }
  if (p->__pyx_v_start_date) {
    e = (*v)(p->__pyx_v_start_date, a); if (e) return e;
  }
  if (p->__pyx_v_time_diff_seconds) {
    e = (*v)(p->__pyx_v_time_diff_seconds, a); if (e) return e;
  }
  if (p->__pyx_v_tol) {
    e = (*v)(p->__pyx_v_tol, a); if (e) return e;
  }
  if (p->__pyx_v_total_queue_size) {
    e = (*v)(p->__pyx_v_total_queue_size, a); if (e) return e;
  }
  if (p->__pyx_v_trimmed_partial) {
    e = (*v)(p->__pyx_v_trimmed_partial, a); if (e) return e;
  }
  if (p->__pyx_v_unsent_intervals) {
    e = (*v)(p->__pyx_v_unsent_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_updated_interval_ids) {
    e = (*v)(p->__pyx_v_updated_interval_ids, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  if (p->__pyx_v_verify_attempt) {
    e = (*v)(p->__pyx_v_verify_attempt, a); if (e) return e;
  }
  if (p->__pyx_v_verify_error) {
    e = (*v)(p->__pyx_v_verify_error, a); if (e) return e;
  }
  if (p->__pyx_v_work_stop) {
    e = (*v)(p->__pyx_v_work_stop, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  if (p->__pyx_t_9) {
    e = (*v)(p->__pyx_t_9, a); if (e) return e;
  }
  if (p->__pyx_t_10) {
    e = (*v)(p->__pyx_t_10, a); if (e) return e;
  }
  if (p->__pyx_t_11) {
    e = (*v)(p->__pyx_t_11, a); if (e) return e;
  }
  if (p->__pyx_t_12) {
    e = (*v)(p->__pyx_t_12, a); if (e) return e;
  }
  if (p->__pyx_t_13) {
    e = (*v)(p->__pyx_t_13, a); if (e) return e;
  }
  if (p->__pyx_t_14) {
    e = (*v)(p->__pyx_t_14, a); if (e) return e;
  }
  if (p->__pyx_t_15) {
    e = (*v)(p->__pyx_t_15, a); if (e) return e;
  }
  if (p->__pyx_t_16) {
    e = (*v)(p->__pyx_t_16, a); if (e) return e;
  }
  if (p->__pyx_t_17) {
    e = (*v)(p->__pyx_t_17, a); if (e) return e;
  }
  if (p->__pyx_t_19) {
    e = (*v)(p->__pyx_t_19, a); if (e) return e;
  }
  if (p->__pyx_t_20) {
    e = (*v)(p->__pyx_t_20, a); if (e) return e;
  }
  if (p->__pyx_t_21) {
    e = (*v)(p->__pyx_t_21, a); if (e) return e;
  }
  if (p->__pyx_t_22) {
    e = (*v)(p->__pyx_t_22, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_49__last_api_call_impl",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_49__last_api_call_impl", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_genexpr_arg_0);
  Py_CLEAR(p->__pyx_v_interval);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_genexpr_arg_0) {
    e = (*v)(p->__pyx_genexpr_arg_0, a); if (e) return e;
  }
  if (p->__pyx_v_interval) {
    e = (*v)(p->__pyx_v_interval, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_50_genexpr",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_50_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_genexpr_arg_0);
  Py_CLEAR(p->__pyx_v_interval);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_genexpr_arg_0) {
    e = (*v)(p->__pyx_genexpr_arg_0, a); if (e) return e;
  }
  if (p->__pyx_v_interval) {
    e = (*v)(p->__pyx_v_interval, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_51_genexpr",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_51_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_genexpr_arg_0);
  Py_CLEAR(p->__pyx_v_interval);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_genexpr_arg_0) {
    e = (*v)(p->__pyx_genexpr_arg_0, a); if (e) return e;
  }
  if (p->__pyx_v_interval) {
    e = (*v)(p->__pyx_v_interval, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_52_genexpr",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_52_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_genexpr_arg_0);
  Py_CLEAR(p->__pyx_v_interval);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_genexpr_arg_0) {
    e = (*v)(p->__pyx_genexpr_arg_0, a); if (e) return e;
  }
  if (p->__pyx_v_interval) {
    e = (*v)(p->__pyx_v_interval, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_53_genexpr",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_53_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_break_error);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_query);
  Py_CLEAR(p->__pyx_v_remaining_break_intervals);
  Py_CLEAR(p->__pyx_v_result);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_session);
  Py_CLEAR(p->__pyx_v_time_since_break_stop);
  Py_CLEAR(p->__pyx_v_user_entity);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_6);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  Py_CLEAR(p->__pyx_t_9);
  Py_CLEAR(p->__pyx_t_10);
  Py_CLEAR(p->__pyx_t_11);
  Py_CLEAR(p->__pyx_t_12);
  Py_CLEAR(p->__pyx_t_13);
  Py_CLEAR(p->__pyx_t_14);
  Py_CLEAR(p->__pyx_t_15);
  Py_CLEAR(p->__pyx_t_16);
  Py_CLEAR(p->__pyx_t_17);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_break_error) {
    e = (*v)(p->__pyx_v_break_error, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_query) {
    e = (*v)(p->__pyx_v_query, a); if (e) return e;
  }
  if (p->__pyx_v_remaining_break_intervals) {
    e = (*v)(p->__pyx_v_remaining_break_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_result) {
    e = (*v)(p->__pyx_v_result, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_session) {
    e = (*v)(p->__pyx_v_session, a); if (e) return e;
  }
  if (p->__pyx_v_time_since_break_stop) {
    e = (*v)(p->__pyx_v_time_since_break_stop, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  if (p->__pyx_t_9) {
    e = (*v)(p->__pyx_t_9, a); if (e) return e;
  }
  if (p->__pyx_t_10) {
    e = (*v)(p->__pyx_t_10, a); if (e) return e;
  }
  if (p->__pyx_t_11) {
    e = (*v)(p->__pyx_t_11, a); if (e) return e;
  }
  if (p->__pyx_t_12) {
    e = (*v)(p->__pyx_t_12, a); if (e) return e;
  }
  if (p->__pyx_t_13) {
    e = (*v)(p->__pyx_t_13, a); if (e) return e;
  }
  if (p->__pyx_t_14) {
    e = (*v)(p->__pyx_t_14, a); if (e) return e;
  }
  if (p->__pyx_t_15) {
    e = (*v)(p->__pyx_t_15, a); if (e) return e;
  }
  if (p->__pyx_t_16) {
    e = (*v)(p->__pyx_t_16, a); if (e) return e;
  }
  if (p->__pyx_t_17) {
    e = (*v)(p->__pyx_t_17, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_54_stop_event",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_54_stop_event", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_app_icon);
  Py_CLEAR(p->__pyx_v_app_name);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_electron_comm);
  Py_CLEAR(p->__pyx_v_message_data);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_success);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_electron_comm) {
    e = (*v)(p->__pyx_v_electron_comm, a); if (e) return e;
  }
  if (p->__pyx_v_message_data) {
    e = (*v)(p->__pyx_v_message_data, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_success) {
    e = (*v)(p->__pyx_v_success, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_55__send_active_app_update_to_electron",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_55__send_active_app_update_to_electron", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_electron_comm);
  Py_CLEAR(p->__pyx_v_message_data);
  Py_CLEAR(p->__pyx_v_s3_url);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_success);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_electron_comm) {
    e = (*v)(p->__pyx_v_electron_comm, a); if (e) return e;
  }
  if (p->__pyx_v_message_data) {
    e = (*v)(p->__pyx_v_message_data, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_success) {
    e = (*v)(p->__pyx_v_success, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_56__send_file_upload_success_to_electron",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_56__send_file_upload_success_to_electron", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_electron_comm);
  Py_CLEAR(p->__pyx_v_message_data);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_success);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_electron_comm) {
    e = (*v)(p->__pyx_v_electron_comm, a); if (e) return e;
  }
  if (p->__pyx_v_message_data) {
    e = (*v)(p->__pyx_v_message_data, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_success) {
    e = (*v)(p->__pyx_v_success, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_57__send_file_upload_failure_to_electron",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_57__send_file_upload_failure_to_electron", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_activity_count);
  Py_CLEAR(p->__pyx_v_all_intervals);
  Py_CLEAR(p->__pyx_v_current_time);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_elapsed_seconds);
  Py_CLEAR(p->__pyx_v_electron_comm);
  Py_CLEAR(p->__pyx_v_idle_count);
  Py_CLEAR(p->__pyx_v_interval);
  Py_CLEAR(p->__pyx_v_interval_ids);
  Py_CLEAR(p->__pyx_v_query);
  Py_CLEAR(p->__pyx_v_result);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_session);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_6);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  Py_CLEAR(p->__pyx_t_9);
  Py_CLEAR(p->__pyx_t_10);
  Py_CLEAR(p->__pyx_t_11);
  Py_CLEAR(p->__pyx_t_12);
  Py_CLEAR(p->__pyx_t_13);
  Py_CLEAR(p->__pyx_t_14);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_activity_count) {
    e = (*v)(p->__pyx_v_activity_count, a); if (e) return e;
  }
  if (p->__pyx_v_all_intervals) {
    e = (*v)(p->__pyx_v_all_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_current_time) {
    e = (*v)(p->__pyx_v_current_time, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_elapsed_seconds) {
    e = (*v)(p->__pyx_v_elapsed_seconds, a); if (e) return e;
  }
  if (p->__pyx_v_electron_comm) {
    e = (*v)(p->__pyx_v_electron_comm, a); if (e) return e;
  }
  if (p->__pyx_v_idle_count) {
    e = (*v)(p->__pyx_v_idle_count, a); if (e) return e;
  }
  if (p->__pyx_v_interval) {
    e = (*v)(p->__pyx_v_interval, a); if (e) return e;
  }
  if (p->__pyx_v_interval_ids) {
    e = (*v)(p->__pyx_v_interval_ids, a); if (e) return e;
  }
  if (p->__pyx_v_query) {
    e = (*v)(p->__pyx_v_query, a); if (e) return e;
  }
  if (p->__pyx_v_result) {
    e = (*v)(p->__pyx_v_result, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_session) {
    e = (*v)(p->__pyx_v_session, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  if (p->__pyx_t_9) {
    e = (*v)(p->__pyx_t_9, a); if (e) return e;
  }
  if (p->__pyx_t_10) {
    e = (*v)(p->__pyx_t_10, a); if (e) return e;
  }
  if (p->__pyx_t_11) {
    e = (*v)(p->__pyx_t_11, a); if (e) return e;
  }
  if (p->__pyx_t_12) {
    e = (*v)(p->__pyx_t_12, a); if (e) return e;
  }
  if (p->__pyx_t_13) {
    e = (*v)(p->__pyx_t_13, a); if (e) return e;
  }
  if (p->__pyx_t_14) {
    e = (*v)(p->__pyx_t_14, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_58_check_idle_popup_timeout",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_58_check_idle_popup_timeout", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_attempt);
  Py_CLEAR(p->__pyx_v_consecutive_idle_count);
  Py_CLEAR(p->__pyx_v_current_break_id);
  Py_CLEAR(p->__pyx_v_current_time);
  Py_CLEAR(p->__pyx_v_delay);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_electron_comm);
  Py_CLEAR(p->__pyx_v_is_connected);
  Py_CLEAR(p->__pyx_v_max_retries);
  Py_CLEAR(p->__pyx_v_retry_delays);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_success);
  Py_CLEAR(p->__pyx_v_timeout_reached);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_attempt) {
    e = (*v)(p->__pyx_v_attempt, a); if (e) return e;
  }
  if (p->__pyx_v_consecutive_idle_count) {
    e = (*v)(p->__pyx_v_consecutive_idle_count, a); if (e) return e;
  }
  if (p->__pyx_v_current_break_id) {
    e = (*v)(p->__pyx_v_current_break_id, a); if (e) return e;
  }
  if (p->__pyx_v_current_time) {
    e = (*v)(p->__pyx_v_current_time, a); if (e) return e;
  }
  if (p->__pyx_v_delay) {
    e = (*v)(p->__pyx_v_delay, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_electron_comm) {
    e = (*v)(p->__pyx_v_electron_comm, a); if (e) return e;
  }
  if (p->__pyx_v_is_connected) {
    e = (*v)(p->__pyx_v_is_connected, a); if (e) return e;
  }
  if (p->__pyx_v_max_retries) {
    e = (*v)(p->__pyx_v_max_retries, a); if (e) return e;
  }
  if (p->__pyx_v_retry_delays) {
    e = (*v)(p->__pyx_v_retry_delays, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_success) {
    e = (*v)(p->__pyx_v_success, a); if (e) return e;
  }
  if (p->__pyx_v_timeout_reached) {
    e = (*v)(p->__pyx_v_timeout_reached, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_59_arise_idle_popup",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_59_arise_idle_popup", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_activityLevel);
  Py_CLEAR(p->__pyx_v_activity_percentage);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_end_date);
  Py_CLEAR(p->__pyx_v_has_activity_level_activity);
  Py_CLEAR(p->__pyx_v_has_activity_percentage_activity);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_start_date);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_activityLevel) {
    e = (*v)(p->__pyx_v_activityLevel, a); if (e) return e;
  }
  if (p->__pyx_v_activity_percentage) {
    e = (*v)(p->__pyx_v_activity_percentage, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_end_date) {
    e = (*v)(p->__pyx_v_end_date, a); if (e) return e;
  }
  if (p->__pyx_v_has_activity_level_activity) {
    e = (*v)(p->__pyx_v_has_activity_level_activity, a); if (e) return e;
  }
  if (p->__pyx_v_has_activity_percentage_activity) {
    e = (*v)(p->__pyx_v_has_activity_percentage_activity, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_start_date) {
    e = (*v)(p->__pyx_v_start_date, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_60__has_zero_activity_for_interval",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_60__has_zero_activity_for_interval", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_action);
  Py_CLEAR(p->__pyx_v_current_counter);
  Py_CLEAR(p->__pyx_v_current_counter_held);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_file_path);
  Py_CLEAR(p->__pyx_v_interval);
  Py_CLEAR(p->__pyx_9genexpr22__pyx_v_iv);
  Py_CLEAR(p->__pyx_9genexpr23__pyx_v_iv);
  Py_CLEAR(p->__pyx_9genexpr24__pyx_v_iv);
  Py_CLEAR(p->__pyx_v_note);
  Py_CLEAR(p->__pyx_v_note_text);
  Py_CLEAR(p->__pyx_v_project_id);
  Py_CLEAR(p->__pyx_v_s3_file_url);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_task_id);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_6);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_current_counter) {
    e = (*v)(p->__pyx_v_current_counter, a); if (e) return e;
  }
  if (p->__pyx_v_current_counter_held) {
    e = (*v)(p->__pyx_v_current_counter_held, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_interval) {
    e = (*v)(p->__pyx_v_interval, a); if (e) return e;
  }
  if (p->__pyx_9genexpr22__pyx_v_iv) {
    e = (*v)(p->__pyx_9genexpr22__pyx_v_iv, a); if (e) return e;
  }
  if (p->__pyx_9genexpr23__pyx_v_iv) {
    e = (*v)(p->__pyx_9genexpr23__pyx_v_iv, a); if (e) return e;
  }
  if (p->__pyx_9genexpr24__pyx_v_iv) {
    e = (*v)(p->__pyx_9genexpr24__pyx_v_iv, a); if (e) return e;
  }
  if (p->__pyx_v_s3_file_url) {
    e = (*v)(p->__pyx_v_s3_file_url, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_61_handle_idle_popup_response",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_61_handle_idle_popup_response", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_api_response);
  Py_CLEAR(p->__pyx_v_batch_intervals);
  Py_CLEAR(p->__pyx_v_current_session_counter);
  Py_CLEAR(p->__pyx_v_day_payload);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_interval);
  Py_CLEAR(p->__pyx_v_interval_data);
  Py_CLEAR(p->__pyx_v_intervals);
  Py_CLEAR(p->__pyx_v_org_id);
  Py_CLEAR(p->__pyx_v_payload);
  Py_CLEAR(p->__pyx_v_response);
  Py_CLEAR(p->__pyx_v_screen_url);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_user_entity);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  Py_CLEAR(p->__pyx_t_9);
  Py_CLEAR(p->__pyx_t_10);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_api_response) {
    e = (*v)(p->__pyx_v_api_response, a); if (e) return e;
  }
  if (p->__pyx_v_batch_intervals) {
    e = (*v)(p->__pyx_v_batch_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_current_session_counter) {
    e = (*v)(p->__pyx_v_current_session_counter, a); if (e) return e;
  }
  if (p->__pyx_v_day_payload) {
    e = (*v)(p->__pyx_v_day_payload, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_interval) {
    e = (*v)(p->__pyx_v_interval, a); if (e) return e;
  }
  if (p->__pyx_v_interval_data) {
    e = (*v)(p->__pyx_v_interval_data, a); if (e) return e;
  }
  if (p->__pyx_v_intervals) {
    e = (*v)(p->__pyx_v_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_org_id) {
    e = (*v)(p->__pyx_v_org_id, a); if (e) return e;
  }
  if (p->__pyx_v_payload) {
    e = (*v)(p->__pyx_v_payload, a); if (e) return e;
  }
  if (p->__pyx_v_response) {
    e = (*v)(p->__pyx_v_response, a); if (e) return e;
  }
  if (p->__pyx_v_screen_url) {
    e = (*v)(p->__pyx_v_screen_url, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  if (p->__pyx_t_9) {
    e = (*v)(p->__pyx_t_9, a); if (e) return e;
  }
  if (p->__pyx_t_10) {
    e = (*v)(p->__pyx_t_10, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_62_sync_activity_immediately",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_62_sync_activity_immediately", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_all_query);
  Py_CLEAR(p->__pyx_v_all_result);
  Py_CLEAR(p->__pyx_v_current_counter);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_has_zero);
  Py_CLEAR(p->__pyx_v_idle_flag_query);
  Py_CLEAR(p->__pyx_v_idle_flag_result);
  Py_CLEAR(p->__pyx_9genexpr25__pyx_v_iid);
  Py_CLEAR(p->__pyx_v_interval);
  Py_CLEAR(p->__pyx_v_interval_id_list);
  Py_CLEAR(p->__pyx_v_interval_ids);
  Py_CLEAR(p->__pyx_v_popup_query);
  Py_CLEAR(p->__pyx_v_popup_result);
  Py_CLEAR(p->__pyx_v_popup_triggered_at);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_session);
  Py_CLEAR(p->__pyx_v_updates);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_6);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  Py_CLEAR(p->__pyx_t_9);
  Py_CLEAR(p->__pyx_t_10);
  Py_CLEAR(p->__pyx_t_11);
  Py_CLEAR(p->__pyx_t_14);
  Py_CLEAR(p->__pyx_t_15);
  Py_CLEAR(p->__pyx_t_16);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_all_query) {
    e = (*v)(p->__pyx_v_all_query, a); if (e) return e;
  }
  if (p->__pyx_v_all_result) {
    e = (*v)(p->__pyx_v_all_result, a); if (e) return e;
  }
  if (p->__pyx_v_current_counter) {
    e = (*v)(p->__pyx_v_current_counter, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_has_zero) {
    e = (*v)(p->__pyx_v_has_zero, a); if (e) return e;
  }
  if (p->__pyx_v_idle_flag_query) {
    e = (*v)(p->__pyx_v_idle_flag_query, a); if (e) return e;
  }
  if (p->__pyx_v_idle_flag_result) {
    e = (*v)(p->__pyx_v_idle_flag_result, a); if (e) return e;
  }
  if (p->__pyx_9genexpr25__pyx_v_iid) {
    e = (*v)(p->__pyx_9genexpr25__pyx_v_iid, a); if (e) return e;
  }
  if (p->__pyx_v_interval) {
    e = (*v)(p->__pyx_v_interval, a); if (e) return e;
  }
  if (p->__pyx_v_interval_id_list) {
    e = (*v)(p->__pyx_v_interval_id_list, a); if (e) return e;
  }
  if (p->__pyx_v_interval_ids) {
    e = (*v)(p->__pyx_v_interval_ids, a); if (e) return e;
  }
  if (p->__pyx_v_popup_query) {
    e = (*v)(p->__pyx_v_popup_query, a); if (e) return e;
  }
  if (p->__pyx_v_popup_result) {
    e = (*v)(p->__pyx_v_popup_result, a); if (e) return e;
  }
  if (p->__pyx_v_popup_triggered_at) {
    e = (*v)(p->__pyx_v_popup_triggered_at, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_session) {
    e = (*v)(p->__pyx_v_session, a); if (e) return e;
  }
  if (p->__pyx_v_updates) {
    e = (*v)(p->__pyx_v_updates, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  if (p->__pyx_t_9) {
    e = (*v)(p->__pyx_t_9, a); if (e) return e;
  }
  if (p->__pyx_t_10) {
    e = (*v)(p->__pyx_t_10, a); if (e) return e;
  }
  if (p->__pyx_t_11) {
    e = (*v)(p->__pyx_t_11, a); if (e) return e;
  }
  if (p->__pyx_t_14) {
    e = (*v)(p->__pyx_t_14, a); if (e) return e;
  }
  if (p->__pyx_t_15) {
    e = (*v)(p->__pyx_t_15, a); if (e) return e;
  }
  if (p->__pyx_t_16) {
    e = (*v)(p->__pyx_t_16, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_63__mark_idle_intervals_as_uploaded",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_63__mark_idle_intervals_as_uploaded", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3 > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3 *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3 *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_file_name);
  Py_CLEAR(p->__pyx_v_local_file_path);
  Py_CLEAR(p->__pyx_v_org_id);
  Py_CLEAR(p->__pyx_v_s3_config);
  Py_CLEAR(p->__pyx_v_s3_dest_path);
  Py_CLEAR(p->__pyx_v_s3_sync);
  Py_CLEAR(p->__pyx_v_s3_url);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_timestamp);
  Py_CLEAR(p->__pyx_v_user_entity);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3 < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3 *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3 *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3 *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_file_name) {
    e = (*v)(p->__pyx_v_file_name, a); if (e) return e;
  }
  if (p->__pyx_v_org_id) {
    e = (*v)(p->__pyx_v_org_id, a); if (e) return e;
  }
  if (p->__pyx_v_s3_config) {
    e = (*v)(p->__pyx_v_s3_config, a); if (e) return e;
  }
  if (p->__pyx_v_s3_sync) {
    e = (*v)(p->__pyx_v_s3_sync, a); if (e) return e;
  }
  if (p->__pyx_v_s3_url) {
    e = (*v)(p->__pyx_v_s3_url, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_timestamp) {
    e = (*v)(p->__pyx_v_timestamp, a); if (e) return e;
  }
  if (p->__pyx_v_user_entity) {
    e = (*v)(p->__pyx_v_user_entity, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_64__upload_file_to_s3",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3 = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_64__upload_file_to_s3", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_all_intervals);
  Py_CLEAR(p->__pyx_v_current_counter);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_file_path);
  Py_CLEAR(p->__pyx_v_has_zero_activity);
  Py_CLEAR(p->__pyx_v_idle_intervals);
  Py_CLEAR(p->__pyx_v_idle_intervals_by_flag);
  Py_CLEAR(p->__pyx_9genexpr26__pyx_v_interval);
  Py_CLEAR(p->__pyx_v_interval);
  Py_CLEAR(p->__pyx_v_interval_ids);
  Py_CLEAR(p->__pyx_v_intervals_to_mark);
  Py_CLEAR(p->__pyx_v_note);
  Py_CLEAR(p->__pyx_v_note_data);
  Py_CLEAR(p->__pyx_v_query_all);
  Py_CLEAR(p->__pyx_v_query_by_flag);
  Py_CLEAR(p->__pyx_v_result_all);
  Py_CLEAR(p->__pyx_v_result_by_flag);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_session);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_6);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  Py_CLEAR(p->__pyx_t_9);
  Py_CLEAR(p->__pyx_t_10);
  Py_CLEAR(p->__pyx_t_11);
  Py_CLEAR(p->__pyx_t_14);
  Py_CLEAR(p->__pyx_t_15);
  Py_CLEAR(p->__pyx_t_16);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_all_intervals) {
    e = (*v)(p->__pyx_v_all_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_current_counter) {
    e = (*v)(p->__pyx_v_current_counter, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_has_zero_activity) {
    e = (*v)(p->__pyx_v_has_zero_activity, a); if (e) return e;
  }
  if (p->__pyx_v_idle_intervals) {
    e = (*v)(p->__pyx_v_idle_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_idle_intervals_by_flag) {
    e = (*v)(p->__pyx_v_idle_intervals_by_flag, a); if (e) return e;
  }
  if (p->__pyx_9genexpr26__pyx_v_interval) {
    e = (*v)(p->__pyx_9genexpr26__pyx_v_interval, a); if (e) return e;
  }
  if (p->__pyx_v_interval) {
    e = (*v)(p->__pyx_v_interval, a); if (e) return e;
  }
  if (p->__pyx_v_interval_ids) {
    e = (*v)(p->__pyx_v_interval_ids, a); if (e) return e;
  }
  if (p->__pyx_v_intervals_to_mark) {
    e = (*v)(p->__pyx_v_intervals_to_mark, a); if (e) return e;
  }
  if (p->__pyx_v_note_data) {
    e = (*v)(p->__pyx_v_note_data, a); if (e) return e;
  }
  if (p->__pyx_v_query_all) {
    e = (*v)(p->__pyx_v_query_all, a); if (e) return e;
  }
  if (p->__pyx_v_query_by_flag) {
    e = (*v)(p->__pyx_v_query_by_flag, a); if (e) return e;
  }
  if (p->__pyx_v_result_all) {
    e = (*v)(p->__pyx_v_result_all, a); if (e) return e;
  }
  if (p->__pyx_v_result_by_flag) {
    e = (*v)(p->__pyx_v_result_by_flag, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_session) {
    e = (*v)(p->__pyx_v_session, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  if (p->__pyx_t_9) {
    e = (*v)(p->__pyx_t_9, a); if (e) return e;
  }
  if (p->__pyx_t_10) {
    e = (*v)(p->__pyx_t_10, a); if (e) return e;
  }
  if (p->__pyx_t_11) {
    e = (*v)(p->__pyx_t_11, a); if (e) return e;
  }
  if (p->__pyx_t_14) {
    e = (*v)(p->__pyx_t_14, a); if (e) return e;
  }
  if (p->__pyx_t_15) {
    e = (*v)(p->__pyx_t_15, a); if (e) return e;
  }
  if (p->__pyx_t_16) {
    e = (*v)(p->__pyx_t_16, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_65__save_note_to_idle_intervals",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_65__save_note_to_idle_intervals", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_current_counter);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_enqueue_success);
  Py_CLEAR(p->__pyx_v_file_path);
  Py_CLEAR(p->__pyx_v_latest_interval);
  Py_CLEAR(p->__pyx_v_note);
  Py_CLEAR(p->__pyx_v_note_data);
  Py_CLEAR(p->__pyx_v_query);
  Py_CLEAR(p->__pyx_v_result);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_session);
  Py_CLEAR(p->__pyx_v_target_interval_id);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_6);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  Py_CLEAR(p->__pyx_t_9);
  Py_CLEAR(p->__pyx_t_10);
  Py_CLEAR(p->__pyx_t_11);
  Py_CLEAR(p->__pyx_t_12);
  Py_CLEAR(p->__pyx_t_13);
  Py_CLEAR(p->__pyx_t_14);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_current_counter) {
    e = (*v)(p->__pyx_v_current_counter, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_enqueue_success) {
    e = (*v)(p->__pyx_v_enqueue_success, a); if (e) return e;
  }
  if (p->__pyx_v_latest_interval) {
    e = (*v)(p->__pyx_v_latest_interval, a); if (e) return e;
  }
  if (p->__pyx_v_note_data) {
    e = (*v)(p->__pyx_v_note_data, a); if (e) return e;
  }
  if (p->__pyx_v_query) {
    e = (*v)(p->__pyx_v_query, a); if (e) return e;
  }
  if (p->__pyx_v_result) {
    e = (*v)(p->__pyx_v_result, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_session) {
    e = (*v)(p->__pyx_v_session, a); if (e) return e;
  }
  if (p->__pyx_v_target_interval_id) {
    e = (*v)(p->__pyx_v_target_interval_id, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  if (p->__pyx_t_9) {
    e = (*v)(p->__pyx_t_9, a); if (e) return e;
  }
  if (p->__pyx_t_10) {
    e = (*v)(p->__pyx_t_10, a); if (e) return e;
  }
  if (p->__pyx_t_11) {
    e = (*v)(p->__pyx_t_11, a); if (e) return e;
  }
  if (p->__pyx_t_12) {
    e = (*v)(p->__pyx_t_12, a); if (e) return e;
  }
  if (p->__pyx_t_13) {
    e = (*v)(p->__pyx_t_13, a); if (e) return e;
  }
  if (p->__pyx_t_14) {
    e = (*v)(p->__pyx_t_14, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_66__save_note_to_current_interval",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_66__save_note_to_current_interval", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_activity_level);
  Py_CLEAR(p->__pyx_v_current_counter);
  Py_CLEAR(p->__pyx_v_current_counter_intervals);
  Py_CLEAR(p->__pyx_v_db_interval);
  Py_CLEAR(p->__pyx_v_db_intervals);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_genexpr);
  Py_CLEAR(p->__pyx_v_idle_intervals);
  Py_CLEAR(p->__pyx_v_interval);
  Py_CLEAR(p->__pyx_v_interval_ids_in_list);
  Py_CLEAR(p->__pyx_v_intervals);
  Py_CLEAR(p->__pyx_9genexpr27__pyx_v_iv);
  Py_CLEAR(p->__pyx_9genexpr28__pyx_v_iv);
  Py_CLEAR(p->__pyx_v_non_idle_intervals);
  Py_CLEAR(p->__pyx_v_query);
  Py_CLEAR(p->__pyx_v_result);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_session);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_6);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  Py_CLEAR(p->__pyx_t_9);
  Py_CLEAR(p->__pyx_t_10);
  Py_CLEAR(p->__pyx_t_11);
  Py_CLEAR(p->__pyx_t_12);
  Py_CLEAR(p->__pyx_t_13);
  Py_CLEAR(p->__pyx_t_14);
  Py_CLEAR(p->__pyx_t_15);
  Py_CLEAR(p->__pyx_t_16);
  Py_CLEAR(p->__pyx_t_17);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_activity_level) {
    e = (*v)(p->__pyx_v_activity_level, a); if (e) return e;
  }
  if (p->__pyx_v_current_counter) {
    e = (*v)(p->__pyx_v_current_counter, a); if (e) return e;
  }
  if (p->__pyx_v_current_counter_intervals) {
    e = (*v)(p->__pyx_v_current_counter_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_db_interval) {
    e = (*v)(p->__pyx_v_db_interval, a); if (e) return e;
  }
  if (p->__pyx_v_db_intervals) {
    e = (*v)(p->__pyx_v_db_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_genexpr) {
    e = (*v)(p->__pyx_v_genexpr, a); if (e) return e;
  }
  if (p->__pyx_v_idle_intervals) {
    e = (*v)(p->__pyx_v_idle_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_interval) {
    e = (*v)(p->__pyx_v_interval, a); if (e) return e;
  }
  if (p->__pyx_v_interval_ids_in_list) {
    e = (*v)(p->__pyx_v_interval_ids_in_list, a); if (e) return e;
  }
  if (p->__pyx_v_intervals) {
    e = (*v)(p->__pyx_v_intervals, a); if (e) return e;
  }
  if (p->__pyx_9genexpr27__pyx_v_iv) {
    e = (*v)(p->__pyx_9genexpr27__pyx_v_iv, a); if (e) return e;
  }
  if (p->__pyx_9genexpr28__pyx_v_iv) {
    e = (*v)(p->__pyx_9genexpr28__pyx_v_iv, a); if (e) return e;
  }
  if (p->__pyx_v_non_idle_intervals) {
    e = (*v)(p->__pyx_v_non_idle_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_query) {
    e = (*v)(p->__pyx_v_query, a); if (e) return e;
  }
  if (p->__pyx_v_result) {
    e = (*v)(p->__pyx_v_result, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_session) {
    e = (*v)(p->__pyx_v_session, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  if (p->__pyx_t_9) {
    e = (*v)(p->__pyx_t_9, a); if (e) return e;
  }
  if (p->__pyx_t_10) {
    e = (*v)(p->__pyx_t_10, a); if (e) return e;
  }
  if (p->__pyx_t_11) {
    e = (*v)(p->__pyx_t_11, a); if (e) return e;
  }
  if (p->__pyx_t_12) {
    e = (*v)(p->__pyx_t_12, a); if (e) return e;
  }
  if (p->__pyx_t_13) {
    e = (*v)(p->__pyx_t_13, a); if (e) return e;
  }
  if (p->__pyx_t_14) {
    e = (*v)(p->__pyx_t_14, a); if (e) return e;
  }
  if (p->__pyx_t_15) {
    e = (*v)(p->__pyx_t_15, a); if (e) return e;
  }
  if (p->__pyx_t_16) {
    e = (*v)(p->__pyx_t_16, a); if (e) return e;
  }
  if (p->__pyx_t_17) {
    e = (*v)(p->__pyx_t_17, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_67__should_pause_api_calls",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_67__should_pause_api_calls", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_outer_scope);
  Py_CLEAR(p->__pyx_genexpr_arg_0);
  Py_CLEAR(p->__pyx_v_held);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_outer_scope) {
    e = (*v)(((PyObject *)p->__pyx_outer_scope), a); if (e) return e;
  }
  if (p->__pyx_genexpr_arg_0) {
    e = (*v)(p->__pyx_genexpr_arg_0, a); if (e) return e;
  }
  if (p->__pyx_v_held) {
    e = (*v)(p->__pyx_v_held, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_68_genexpr",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_68_genexpr", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyObject *__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
  PyObject *o;
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign > 0) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(t, __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign))))
  {
    o = (PyObject*)__pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign[--__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign];
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(Py_TYPE(o));
    #endif
    memset(o, 0, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign));
    #if CYTHON_COMPILING_IN_LIMITED_API
    (void) PyObject_Init(o, t);
    #else
    (void) PyObject_INIT(o, t);
    #endif
    PyObject_GC_Track(o);
  } else
  #endif
  {
    o = __Pyx_AllocateExtensionType(t, 1);
    if (unlikely(!o)) return 0;
  }
  return o;
}

static void __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign(PyObject *o) {
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign *)o;
  #if CYTHON_USE_TP_FINALIZE
  if (unlikely(__Pyx_PyObject_GetSlot(o, tp_finalize, destructor)) && !__Pyx_PyObject_GC_IsFinalized(o)) {
    if (__Pyx_PyObject_GetSlot(o, tp_dealloc, destructor) == __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign) {
      if (PyObject_CallFinalizerFromDealloc(o)) return;
    }
  }
  #endif
  PyObject_GC_UnTrack(o);
  Py_CLEAR(p->__pyx_v_activity_level);
  Py_CLEAR(p->__pyx_v_activity_manager);
  Py_CLEAR(p->__pyx_v_app_and_urls);
  Py_CLEAR(p->__pyx_v_day_intervals);
  Py_CLEAR(p->__pyx_v_day_start_time);
  Py_CLEAR(p->__pyx_v_e);
  Py_CLEAR(p->__pyx_v_effective_start_time);
  Py_CLEAR(p->__pyx_v_failed_count);
  Py_CLEAR(p->__pyx_v_grouped_intervals);
  Py_CLEAR(p->__pyx_v_idle_intervals);
  Py_CLEAR(p->__pyx_9genexpr30__pyx_v_interval);
  Py_CLEAR(p->__pyx_v_interval);
  Py_CLEAR(p->__pyx_v_interval_id);
  Py_CLEAR(p->__pyx_v_interval_ids);
  Py_CLEAR(p->__pyx_v_interval_note_map);
  Py_CLEAR(p->__pyx_v_interval_payload);
  Py_CLEAR(p->__pyx_v_interval_payloads);
  Py_CLEAR(p->__pyx_v_notes_entries);
  Py_CLEAR(p->__pyx_v_notes_entry);
  Py_CLEAR(p->__pyx_v_notes_query);
  Py_CLEAR(p->__pyx_v_notes_result);
  Py_CLEAR(p->__pyx_v_payload);
  Py_CLEAR(p->__pyx_v_payload_from);
  Py_CLEAR(p->__pyx_v_payload_to);
  Py_CLEAR(p->__pyx_v_project_id);
  Py_CLEAR(p->__pyx_v_project_id_str);
  Py_CLEAR(p->__pyx_v_query);
  Py_CLEAR(p->__pyx_v_response);
  Py_CLEAR(p->__pyx_v_result);
  Py_CLEAR(p->__pyx_v_screen_url);
  Py_CLEAR(p->__pyx_v_self);
  Py_CLEAR(p->__pyx_v_session);
  Py_CLEAR(p->__pyx_v_success_count);
  Py_CLEAR(p->__pyx_v_target_date);
  Py_CLEAR(p->__pyx_v_task_id);
  Py_CLEAR(p->__pyx_v_task_id_str);
  Py_CLEAR(p->__pyx_t_0);
  Py_CLEAR(p->__pyx_t_1);
  Py_CLEAR(p->__pyx_t_2);
  Py_CLEAR(p->__pyx_t_3);
  Py_CLEAR(p->__pyx_t_4);
  Py_CLEAR(p->__pyx_t_5);
  Py_CLEAR(p->__pyx_t_6);
  Py_CLEAR(p->__pyx_t_7);
  Py_CLEAR(p->__pyx_t_8);
  Py_CLEAR(p->__pyx_t_9);
  Py_CLEAR(p->__pyx_t_10);
  Py_CLEAR(p->__pyx_t_11);
  Py_CLEAR(p->__pyx_t_12);
  Py_CLEAR(p->__pyx_t_13);
  Py_CLEAR(p->__pyx_t_14);
  Py_CLEAR(p->__pyx_t_18);
  Py_CLEAR(p->__pyx_t_19);
  Py_CLEAR(p->__pyx_t_20);
  Py_CLEAR(p->__pyx_t_21);
  Py_CLEAR(p->__pyx_t_22);
  Py_CLEAR(p->__pyx_t_23);
  Py_CLEAR(p->__pyx_t_24);
  #if CYTHON_USE_FREELISTS
  if (likely((int)(__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign < 8) & __PYX_CHECK_FINAL_TYPE_FOR_FREELISTS(Py_TYPE(o), __pyx_mstate_global->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign, sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign))))
  {
    __pyx_mstate_global->__pyx_freelist_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign[__pyx_mstate_global->__pyx_freecount_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign++] = ((struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign *)o);
  } else
  #endif
  {
    PyTypeObject *tp = Py_TYPE(o);
    #if CYTHON_USE_TYPE_SLOTS
    (*tp->tp_free)(o);
    #else
    {
      freefunc tp_free = (freefunc)PyType_GetSlot(tp, Py_tp_free);
      if (tp_free) tp_free(o);
    }
    #endif
    #if CYTHON_USE_TYPE_SPECS
    Py_DECREF(tp);
    #endif
  }
}

static int __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign(PyObject *o, visitproc v, void *a) {
  int e;
  struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign *p = (struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign *)o;
  {
    e = __Pyx_call_type_traverse(o, 1, v, a);
    if (e) return e;
  }
  if (p->__pyx_v_activity_level) {
    e = (*v)(p->__pyx_v_activity_level, a); if (e) return e;
  }
  if (p->__pyx_v_activity_manager) {
    e = (*v)(p->__pyx_v_activity_manager, a); if (e) return e;
  }
  if (p->__pyx_v_app_and_urls) {
    e = (*v)(p->__pyx_v_app_and_urls, a); if (e) return e;
  }
  if (p->__pyx_v_day_intervals) {
    e = (*v)(p->__pyx_v_day_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_day_start_time) {
    e = (*v)(p->__pyx_v_day_start_time, a); if (e) return e;
  }
  if (p->__pyx_v_e) {
    e = (*v)(p->__pyx_v_e, a); if (e) return e;
  }
  if (p->__pyx_v_effective_start_time) {
    e = (*v)(p->__pyx_v_effective_start_time, a); if (e) return e;
  }
  if (p->__pyx_v_failed_count) {
    e = (*v)(p->__pyx_v_failed_count, a); if (e) return e;
  }
  if (p->__pyx_v_grouped_intervals) {
    e = (*v)(p->__pyx_v_grouped_intervals, a); if (e) return e;
  }
  if (p->__pyx_v_idle_intervals) {
    e = (*v)(p->__pyx_v_idle_intervals, a); if (e) return e;
  }
  if (p->__pyx_9genexpr30__pyx_v_interval) {
    e = (*v)(p->__pyx_9genexpr30__pyx_v_interval, a); if (e) return e;
  }
  if (p->__pyx_v_interval) {
    e = (*v)(p->__pyx_v_interval, a); if (e) return e;
  }
  if (p->__pyx_v_interval_id) {
    e = (*v)(p->__pyx_v_interval_id, a); if (e) return e;
  }
  if (p->__pyx_v_interval_ids) {
    e = (*v)(p->__pyx_v_interval_ids, a); if (e) return e;
  }
  if (p->__pyx_v_interval_note_map) {
    e = (*v)(p->__pyx_v_interval_note_map, a); if (e) return e;
  }
  if (p->__pyx_v_interval_payload) {
    e = (*v)(p->__pyx_v_interval_payload, a); if (e) return e;
  }
  if (p->__pyx_v_interval_payloads) {
    e = (*v)(p->__pyx_v_interval_payloads, a); if (e) return e;
  }
  if (p->__pyx_v_notes_entries) {
    e = (*v)(p->__pyx_v_notes_entries, a); if (e) return e;
  }
  if (p->__pyx_v_notes_entry) {
    e = (*v)(p->__pyx_v_notes_entry, a); if (e) return e;
  }
  if (p->__pyx_v_notes_query) {
    e = (*v)(p->__pyx_v_notes_query, a); if (e) return e;
  }
  if (p->__pyx_v_notes_result) {
    e = (*v)(p->__pyx_v_notes_result, a); if (e) return e;
  }
  if (p->__pyx_v_payload) {
    e = (*v)(p->__pyx_v_payload, a); if (e) return e;
  }
  if (p->__pyx_v_payload_from) {
    e = (*v)(p->__pyx_v_payload_from, a); if (e) return e;
  }
  if (p->__pyx_v_payload_to) {
    e = (*v)(p->__pyx_v_payload_to, a); if (e) return e;
  }
  if (p->__pyx_v_query) {
    e = (*v)(p->__pyx_v_query, a); if (e) return e;
  }
  if (p->__pyx_v_response) {
    e = (*v)(p->__pyx_v_response, a); if (e) return e;
  }
  if (p->__pyx_v_result) {
    e = (*v)(p->__pyx_v_result, a); if (e) return e;
  }
  if (p->__pyx_v_screen_url) {
    e = (*v)(p->__pyx_v_screen_url, a); if (e) return e;
  }
  if (p->__pyx_v_self) {
    e = (*v)(p->__pyx_v_self, a); if (e) return e;
  }
  if (p->__pyx_v_session) {
    e = (*v)(p->__pyx_v_session, a); if (e) return e;
  }
  if (p->__pyx_v_success_count) {
    e = (*v)(p->__pyx_v_success_count, a); if (e) return e;
  }
  if (p->__pyx_v_target_date) {
    e = (*v)(p->__pyx_v_target_date, a); if (e) return e;
  }
  if (p->__pyx_t_0) {
    e = (*v)(p->__pyx_t_0, a); if (e) return e;
  }
  if (p->__pyx_t_1) {
    e = (*v)(p->__pyx_t_1, a); if (e) return e;
  }
  if (p->__pyx_t_2) {
    e = (*v)(p->__pyx_t_2, a); if (e) return e;
  }
  if (p->__pyx_t_3) {
    e = (*v)(p->__pyx_t_3, a); if (e) return e;
  }
  if (p->__pyx_t_4) {
    e = (*v)(p->__pyx_t_4, a); if (e) return e;
  }
  if (p->__pyx_t_5) {
    e = (*v)(p->__pyx_t_5, a); if (e) return e;
  }
  if (p->__pyx_t_6) {
    e = (*v)(p->__pyx_t_6, a); if (e) return e;
  }
  if (p->__pyx_t_7) {
    e = (*v)(p->__pyx_t_7, a); if (e) return e;
  }
  if (p->__pyx_t_8) {
    e = (*v)(p->__pyx_t_8, a); if (e) return e;
  }
  if (p->__pyx_t_9) {
    e = (*v)(p->__pyx_t_9, a); if (e) return e;
  }
  if (p->__pyx_t_10) {
    e = (*v)(p->__pyx_t_10, a); if (e) return e;
  }
  if (p->__pyx_t_11) {
    e = (*v)(p->__pyx_t_11, a); if (e) return e;
  }
  if (p->__pyx_t_12) {
    e = (*v)(p->__pyx_t_12, a); if (e) return e;
  }
  if (p->__pyx_t_13) {
    e = (*v)(p->__pyx_t_13, a); if (e) return e;
  }
  if (p->__pyx_t_14) {
    e = (*v)(p->__pyx_t_14, a); if (e) return e;
  }
  if (p->__pyx_t_18) {
    e = (*v)(p->__pyx_t_18, a); if (e) return e;
  }
  if (p->__pyx_t_19) {
    e = (*v)(p->__pyx_t_19, a); if (e) return e;
  }
  if (p->__pyx_t_20) {
    e = (*v)(p->__pyx_t_20, a); if (e) return e;
  }
  if (p->__pyx_t_21) {
    e = (*v)(p->__pyx_t_21, a); if (e) return e;
  }
  if (p->__pyx_t_22) {
    e = (*v)(p->__pyx_t_22, a); if (e) return e;
  }
  if (p->__pyx_t_23) {
    e = (*v)(p->__pyx_t_23, a); if (e) return e;
  }
  if (p->__pyx_t_24) {
    e = (*v)(p->__pyx_t_24, a); if (e) return e;
  }
  return 0;
}
#if CYTHON_USE_TYPE_SPECS
static PyType_Slot __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign_slots[] = {
  {Py_tp_dealloc, (void *)__pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign},
  {Py_tp_traverse, (void *)__pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign},
  {Py_tp_new, (void *)__pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign},
  {0, 0},
};
static PyType_Spec __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign_spec = {
  "ws_package.controllers.activity_controller.__pyx_scope_struct_69__idle_reassign",
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign),
  0,
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC,
  __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign_slots,
};
#else

static PyTypeObject __pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign = {
  PyVarObject_HEAD_INIT(0, 0)
  "ws_package.controllers.activity_controller.""__pyx_scope_struct_69__idle_reassign", /*tp_name*/
  sizeof(struct __pyx_obj_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign), /*tp_basicsize*/
  0, /*tp_itemsize*/
  __pyx_tp_dealloc_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign, /*tp_dealloc*/
  0, /*tp_vectorcall_offset*/
  0, /*tp_getattr*/
  0, /*tp_setattr*/
  0, /*tp_as_async*/
  0, /*tp_repr*/
  0, /*tp_as_number*/
  0, /*tp_as_sequence*/
  0, /*tp_as_mapping*/
  0, /*tp_hash*/
  0, /*tp_call*/
  0, /*tp_str*/
  0, /*tp_getattro*/
  0, /*tp_setattro*/
  0, /*tp_as_buffer*/
  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
  0, /*tp_doc*/
  __pyx_tp_traverse_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign, /*tp_traverse*/
  0, /*tp_clear*/
  0, /*tp_richcompare*/
  0, /*tp_weaklistoffset*/
  0, /*tp_iter*/
  0, /*tp_iternext*/
  0, /*tp_methods*/
  0, /*tp_members*/
  0, /*tp_getset*/
  0, /*tp_base*/
  0, /*tp_dict*/
  0, /*tp_descr_get*/
  0, /*tp_descr_set*/
  #if !CYTHON_USE_TYPE_SPECS
  0, /*tp_dictoffset*/
  #endif
  0, /*tp_init*/
  0, /*tp_alloc*/
  __pyx_tp_new_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign, /*tp_new*/
  0, /*tp_free*/
  0, /*tp_is_gc*/
  0, /*tp_bases*/
  0, /*tp_mro*/
  0, /*tp_cache*/
  0, /*tp_subclasses*/
  0, /*tp_weaklist*/
  0, /*tp_del*/
  0, /*tp_version_tag*/
  #if CYTHON_USE_TP_FINALIZE
  0, /*tp_finalize*/
  #else
  NULL, /*tp_finalize*/
  #endif
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07030800
  0, /*tp_vectorcall*/
  #endif
  #if __PYX_NEED_TP_PRINT_SLOT == 1
  0, /*tp_print*/
  #endif
  #if PY_VERSION_HEX >= 0x030C0000
  0, /*tp_watched*/
  #endif
  #if PY_VERSION_HEX >= 0x030d00A4
  0, /*tp_versions_used*/
  #endif
  #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX >= 0x03090000 && PY_VERSION_HEX < 0x030a0000
  0, /*tp_pypy_flags*/
  #endif
};
#endif

static PyMethodDef __pyx_methods[] = {
  {0, 0, 0, 0}
};
/* #### Code section: initfunc_declarations ### */
static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(__pyx_mstatetype *__pyx_mstate); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_InitConstants(__pyx_mstatetype *__pyx_mstate); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(__pyx_mstatetype *__pyx_mstate); /*proto*/
static CYTHON_SMALL_CODE int __Pyx_CreateCodeObjects(__pyx_mstatetype *__pyx_mstate); /*proto*/
/* #### Code section: init_module ### */

static int __Pyx_modinit_global_init_code(__pyx_mstatetype *__pyx_mstate) {
  __Pyx_RefNannyDeclarations
  CYTHON_UNUSED_VAR(__pyx_mstate);
  __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
  /*--- Global init code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_variable_export_code(__pyx_mstatetype *__pyx_mstate) {
  __Pyx_RefNannyDeclarations
  CYTHON_UNUSED_VAR(__pyx_mstate);
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
  /*--- Variable export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_export_code(__pyx_mstatetype *__pyx_mstate) {
  __Pyx_RefNannyDeclarations
  CYTHON_UNUSED_VAR(__pyx_mstate);
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
  /*--- Function export code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_type_init_code(__pyx_mstatetype *__pyx_mstate) {
  __Pyx_RefNannyDeclarations
  CYTHON_UNUSED_VAR(__pyx_mstate);
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
  /*--- Type init code ---*/
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter)) __PYX_ERR(0, 554, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter) < (0)) __PYX_ERR(0, 554, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter) < (0)) __PYX_ERR(0, 554, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct__has_recent_intervals_on_write_counter->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch)) __PYX_ERR(0, 608, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch) < (0)) __PYX_ERR(0, 608, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch) < (0)) __PYX_ERR(0, 608, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_1__trim_open_partial_at_project_switch->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval)) __PYX_ERR(0, 654, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval) < (0)) __PYX_ERR(0, 654, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval) < (0)) __PYX_ERR(0, 654, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_2__try_finalize_post_switch_slot_interval->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry)) __PYX_ERR(0, 721, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry) < (0)) __PYX_ERR(0, 721, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry) < (0)) __PYX_ERR(0, 721, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_3__create_segment_dummy_entry->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange)) __PYX_ERR(0, 779, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange) < (0)) __PYX_ERR(0, 779, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange) < (0)) __PYX_ERR(0, 779, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_4_inrange->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration)) __PYX_ERR(0, 836, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration) < (0)) __PYX_ERR(0, 836, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration) < (0)) __PYX_ERR(0, 836, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_5_update_tracking_duration->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight)) __PYX_ERR(0, 941, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight) < (0)) __PYX_ERR(0, 941, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight) < (0)) __PYX_ERR(0, 941, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_6_midnight->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup)) __PYX_ERR(0, 1035, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup) < (0)) __PYX_ERR(0, 1035, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup) < (0)) __PYX_ERR(0, 1035, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_7__check_and_update_s3_on_startup->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake)) __PYX_ERR(0, 1080, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake) < (0)) __PYX_ERR(0, 1080, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake) < (0)) __PYX_ERR(0, 1080, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_8__check_and_update_s3_on_wake->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh)) __PYX_ERR(0, 1125, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh) < (0)) __PYX_ERR(0, 1125, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh) < (0)) __PYX_ERR(0, 1125, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_9__s3_credentials_need_refresh->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh)) __PYX_ERR(0, 1134, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh) < (0)) __PYX_ERR(0, 1134, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh) < (0)) __PYX_ERR(0, 1134, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_10_ensure_s3_credentials_fresh->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval)) __PYX_ERR(0, 1138, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval) < (0)) __PYX_ERR(0, 1138, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval) < (0)) __PYX_ERR(0, 1138, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_11_get_bucket_in_every_interval->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval)) __PYX_ERR(0, 1149, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval) < (0)) __PYX_ERR(0, 1149, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval) < (0)) __PYX_ERR(0, 1149, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_12_update_interval->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db)) __PYX_ERR(0, 1301, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db) < (0)) __PYX_ERR(0, 1301, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db) < (0)) __PYX_ERR(0, 1301, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_13__load_org_settings_from_db->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits)) __PYX_ERR(0, 1342, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits) < (0)) __PYX_ERR(0, 1342, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits) < (0)) __PYX_ERR(0, 1342, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_14__check_and_handle_limits->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity)) __PYX_ERR(0, 1466, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity) < (0)) __PYX_ERR(0, 1466, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity) < (0)) __PYX_ERR(0, 1466, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_15_start_screenshot_activity->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity)) __PYX_ERR(0, 1481, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity) < (0)) __PYX_ERR(0, 1481, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity) < (0)) __PYX_ERR(0, 1481, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_16_start_device_activity->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot)) __PYX_ERR(0, 1554, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot) < (0)) __PYX_ERR(0, 1554, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot) < (0)) __PYX_ERR(0, 1554, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_17_getStartingSlot->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot)) __PYX_ERR(0, 1592, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot) < (0)) __PYX_ERR(0, 1592, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot) < (0)) __PYX_ERR(0, 1592, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_18_getCurrentSlot->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser)) __PYX_ERR(0, 1625, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser) < (0)) __PYX_ERR(0, 1625, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser) < (0)) __PYX_ERR(0, 1625, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_19_is_browser->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr)) __PYX_ERR(0, 1628, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr) < (0)) __PYX_ERR(0, 1628, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr) < (0)) __PYX_ERR(0, 1628, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_20_genexpr->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr)) __PYX_ERR(0, 1636, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr) < (0)) __PYX_ERR(0, 1636, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr) < (0)) __PYX_ERR(0, 1636, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_21_genexpr->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer)) __PYX_ERR(0, 1638, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer) < (0)) __PYX_ERR(0, 1638, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer) < (0)) __PYX_ERR(0, 1638, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_22___start_minute_activity_timer->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity)) __PYX_ERR(0, 1686, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity) < (0)) __PYX_ERR(0, 1686, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity) < (0)) __PYX_ERR(0, 1686, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_23___start_device_activity->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps)) __PYX_ERR(0, 1810, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps) < (0)) __PYX_ERR(0, 1810, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps) < (0)) __PYX_ERR(0, 1810, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_24_monitor_active_apps->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui)) __PYX_ERR(0, 1976, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui) < (0)) __PYX_ERR(0, 1976, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui) < (0)) __PYX_ERR(0, 1976, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_25_monitor_active_app_for_ui->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay)) __PYX_ERR(0, 2454, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay) < (0)) __PYX_ERR(0, 2454, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay) < (0)) __PYX_ERR(0, 2454, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_26_remove_after_delay->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay)) __PYX_ERR(0, 2644, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay) < (0)) __PYX_ERR(0, 2644, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay) < (0)) __PYX_ERR(0, 2644, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_27_check_idle_after_delay->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay)) __PYX_ERR(0, 2655, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay) < (0)) __PYX_ERR(0, 2655, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay) < (0)) __PYX_ERR(0, 2655, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_28_remove_after_delay->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay)) __PYX_ERR(0, 2655, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay) < (0)) __PYX_ERR(0, 2655, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay) < (0)) __PYX_ERR(0, 2655, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_29_remove_after_delay->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay)) __PYX_ERR(0, 2849, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay) < (0)) __PYX_ERR(0, 2849, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay) < (0)) __PYX_ERR(0, 2849, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_30_remove_after_delay->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay)) __PYX_ERR(0, 2849, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay) < (0)) __PYX_ERR(0, 2849, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay) < (0)) __PYX_ERR(0, 2849, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_31_remove_after_delay->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay)) __PYX_ERR(0, 2897, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay) < (0)) __PYX_ERR(0, 2897, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay) < (0)) __PYX_ERR(0, 2897, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_32_check_idle_after_delay->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval)) __PYX_ERR(0, 2969, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval) < (0)) __PYX_ERR(0, 2969, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval) < (0)) __PYX_ERR(0, 2969, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_33_empty_interval->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr)) __PYX_ERR(0, 2997, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr) < (0)) __PYX_ERR(0, 2997, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr) < (0)) __PYX_ERR(0, 2997, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_34_genexpr->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log)) __PYX_ERR(0, 3086, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log) < (0)) __PYX_ERR(0, 3086, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log) < (0)) __PYX_ERR(0, 3086, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_35__push_activity_log->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss)) __PYX_ERR(0, 3414, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss) < (0)) __PYX_ERR(0, 3414, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss) < (0)) __PYX_ERR(0, 3414, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_36_ss->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period)) __PYX_ERR(0, 3606, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period) < (0)) __PYX_ERR(0, 3606, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period) < (0)) __PYX_ERR(0, 3606, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_37__verify_user_activity_during_period->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db)) __PYX_ERR(0, 3769, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db) < (0)) __PYX_ERR(0, 3769, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db) < (0)) __PYX_ERR(0, 3769, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_38_get_activity_level_from_db->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale)) __PYX_ERR(0, 3772, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale) < (0)) __PYX_ERR(0, 3772, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale) < (0)) __PYX_ERR(0, 3772, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_39__is_app_monitor_data_stale->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval)) __PYX_ERR(0, 3790, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval) < (0)) __PYX_ERR(0, 3790, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval) < (0)) __PYX_ERR(0, 3790, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_40__has_any_activity_in_interval->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk)) __PYX_ERR(0, 3836, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk) < (0)) __PYX_ERR(0, 3836, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk) < (0)) __PYX_ERR(0, 3836, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_41_process_intervals_bulk->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr)) __PYX_ERR(0, 4076, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr) < (0)) __PYX_ERR(0, 4076, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr) < (0)) __PYX_ERR(0, 4076, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_42_genexpr->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots)) __PYX_ERR(0, 4132, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots) < (0)) __PYX_ERR(0, 4132, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots) < (0)) __PYX_ERR(0, 4132, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_43_delete_old_data_and_screenshots->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity)) __PYX_ERR(0, 4291, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity) < (0)) __PYX_ERR(0, 4291, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity) < (0)) __PYX_ERR(0, 4291, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_44_start_status_activity->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server)) __PYX_ERR(0, 4400, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server) < (0)) __PYX_ERR(0, 4400, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server) < (0)) __PYX_ERR(0, 4400, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_45_db_to_server->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval)) __PYX_ERR(0, 4512, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval) < (0)) __PYX_ERR(0, 4512, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval) < (0)) __PYX_ERR(0, 4512, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_46_getting_unsent_interval->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals)) __PYX_ERR(0, 4608, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals) < (0)) __PYX_ERR(0, 4608, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals) < (0)) __PYX_ERR(0, 4608, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_47_sending_unsent_intervals->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call)) __PYX_ERR(0, 4831, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call) < (0)) __PYX_ERR(0, 4831, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call) < (0)) __PYX_ERR(0, 4831, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_48_last_api_call->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl)) __PYX_ERR(0, 4850, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl) < (0)) __PYX_ERR(0, 4850, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl) < (0)) __PYX_ERR(0, 4850, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_49__last_api_call_impl->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr)) __PYX_ERR(0, 5173, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr) < (0)) __PYX_ERR(0, 5173, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr) < (0)) __PYX_ERR(0, 5173, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_50_genexpr->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr)) __PYX_ERR(0, 5258, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr) < (0)) __PYX_ERR(0, 5258, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr) < (0)) __PYX_ERR(0, 5258, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_51_genexpr->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr)) __PYX_ERR(0, 5299, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr) < (0)) __PYX_ERR(0, 5299, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr) < (0)) __PYX_ERR(0, 5299, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_52_genexpr->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr)) __PYX_ERR(0, 5472, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr) < (0)) __PYX_ERR(0, 5472, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr) < (0)) __PYX_ERR(0, 5472, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_53_genexpr->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event)) __PYX_ERR(0, 5643, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event) < (0)) __PYX_ERR(0, 5643, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event) < (0)) __PYX_ERR(0, 5643, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_54_stop_event->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron)) __PYX_ERR(0, 5716, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron) < (0)) __PYX_ERR(0, 5716, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron) < (0)) __PYX_ERR(0, 5716, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_55__send_active_app_update_to_electron->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron)) __PYX_ERR(0, 5752, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron) < (0)) __PYX_ERR(0, 5752, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron) < (0)) __PYX_ERR(0, 5752, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_56__send_file_upload_success_to_electron->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron)) __PYX_ERR(0, 5783, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron) < (0)) __PYX_ERR(0, 5783, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron) < (0)) __PYX_ERR(0, 5783, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_57__send_file_upload_failure_to_electron->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout)) __PYX_ERR(0, 5813, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout) < (0)) __PYX_ERR(0, 5813, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout) < (0)) __PYX_ERR(0, 5813, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_58_check_idle_popup_timeout->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup)) __PYX_ERR(0, 5906, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup) < (0)) __PYX_ERR(0, 5906, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup) < (0)) __PYX_ERR(0, 5906, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_59_arise_idle_popup->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval)) __PYX_ERR(0, 6021, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval) < (0)) __PYX_ERR(0, 6021, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval) < (0)) __PYX_ERR(0, 6021, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_60__has_zero_activity_for_interval->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response)) __PYX_ERR(0, 6062, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response) < (0)) __PYX_ERR(0, 6062, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response) < (0)) __PYX_ERR(0, 6062, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_61_handle_idle_popup_response->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately)) __PYX_ERR(0, 6207, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately) < (0)) __PYX_ERR(0, 6207, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately) < (0)) __PYX_ERR(0, 6207, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_62_sync_activity_immediately->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded)) __PYX_ERR(0, 6280, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded) < (0)) __PYX_ERR(0, 6280, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded) < (0)) __PYX_ERR(0, 6280, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_63__mark_idle_intervals_as_uploaded->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3 = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3)) __PYX_ERR(0, 6380, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3) < (0)) __PYX_ERR(0, 6380, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3 = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3) < (0)) __PYX_ERR(0, 6380, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_64__upload_file_to_s3->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals)) __PYX_ERR(0, 6447, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals) < (0)) __PYX_ERR(0, 6447, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals) < (0)) __PYX_ERR(0, 6447, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_65__save_note_to_idle_intervals->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval)) __PYX_ERR(0, 6536, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval) < (0)) __PYX_ERR(0, 6536, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval) < (0)) __PYX_ERR(0, 6536, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_66__save_note_to_current_interval->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls)) __PYX_ERR(0, 6606, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls) < (0)) __PYX_ERR(0, 6606, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls) < (0)) __PYX_ERR(0, 6606, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_67__should_pause_api_calls->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr)) __PYX_ERR(0, 6707, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr) < (0)) __PYX_ERR(0, 6707, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr) < (0)) __PYX_ERR(0, 6707, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_68_genexpr->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  #if CYTHON_USE_TYPE_SPECS
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign = (PyTypeObject *) __Pyx_PyType_FromModuleAndSpec(__pyx_m, &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign_spec, NULL); if (unlikely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign)) __PYX_ERR(0, 6729, __pyx_L1_error)
  if (__Pyx_fix_up_extension_type_from_spec(&__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign_spec, __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign) < (0)) __PYX_ERR(0, 6729, __pyx_L1_error)
  #else
  __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign = &__pyx_type_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign;
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  #endif
  #if !CYTHON_USE_TYPE_SPECS
  if (__Pyx_PyType_Ready(__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign) < (0)) __PYX_ERR(0, 6729, __pyx_L1_error)
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount((PyObject*)__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign);
  #endif
  #if !CYTHON_COMPILING_IN_LIMITED_API
  if ((CYTHON_USE_TYPE_SLOTS && CYTHON_USE_PYTYPE_LOOKUP) && likely(!__pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign->tp_dictoffset && __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign->tp_getattro == PyObject_GenericGetAttr)) {
    __pyx_mstate->__pyx_ptype_10ws_package_11controllers_19activity_controller___pyx_scope_struct_69__idle_reassign->tp_getattro = PyObject_GenericGetAttr;
  }
  #endif
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}

static int __Pyx_modinit_type_import_code(__pyx_mstatetype *__pyx_mstate) {
  __Pyx_RefNannyDeclarations
  CYTHON_UNUSED_VAR(__pyx_mstate);
  __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
  /*--- Type import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_variable_import_code(__pyx_mstatetype *__pyx_mstate) {
  __Pyx_RefNannyDeclarations
  CYTHON_UNUSED_VAR(__pyx_mstate);
  __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
  /*--- Variable import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

static int __Pyx_modinit_function_import_code(__pyx_mstatetype *__pyx_mstate) {
  __Pyx_RefNannyDeclarations
  CYTHON_UNUSED_VAR(__pyx_mstate);
  __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
  /*--- Function import code ---*/
  __Pyx_RefNannyFinishContext();
  return 0;
}

#if CYTHON_PEP489_MULTI_PHASE_INIT
static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
static int __pyx_pymod_exec_activity_controller(PyObject* module); /*proto*/
static PyModuleDef_Slot __pyx_moduledef_slots[] = {
  {Py_mod_create, (void*)__pyx_pymod_create},
  {Py_mod_exec, (void*)__pyx_pymod_exec_activity_controller},
  #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  {Py_mod_gil, __Pyx_FREETHREADING_COMPATIBLE},
  #endif
  #if PY_VERSION_HEX >= 0x030C0000 && CYTHON_USE_MODULE_STATE
  {Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
  #endif
  {0, NULL}
};
#endif

#ifdef __cplusplus
namespace {
  struct PyModuleDef __pyx_moduledef =
  #else
  static struct PyModuleDef __pyx_moduledef =
  #endif
  {
      PyModuleDef_HEAD_INIT,
      "activity_controller",
      0, /* m_doc */
    #if CYTHON_USE_MODULE_STATE
      sizeof(__pyx_mstatetype), /* m_size */
    #else
      (CYTHON_PEP489_MULTI_PHASE_INIT) ? 0 : -1, /* m_size */
    #endif
      __pyx_methods /* m_methods */,
    #if CYTHON_PEP489_MULTI_PHASE_INIT
      __pyx_moduledef_slots, /* m_slots */
    #else
      NULL, /* m_reload */
    #endif
    #if CYTHON_USE_MODULE_STATE
      __pyx_m_traverse, /* m_traverse */
      __pyx_m_clear, /* m_clear */
      NULL /* m_free */
    #else
      NULL, /* m_traverse */
      NULL, /* m_clear */
      NULL /* m_free */
    #endif
  };
  #ifdef __cplusplus
} /* anonymous namespace */
#endif

/* PyModInitFuncType */
#ifndef CYTHON_NO_PYINIT_EXPORT
  #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
#else
  #ifdef __cplusplus
  #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
  #else
  #define __Pyx_PyMODINIT_FUNC PyObject *
  #endif
#endif

__Pyx_PyMODINIT_FUNC PyInit_activity_controller(void) CYTHON_SMALL_CODE; /*proto*/
__Pyx_PyMODINIT_FUNC PyInit_activity_controller(void)
#if CYTHON_PEP489_MULTI_PHASE_INIT
{
  return PyModuleDef_Init(&__pyx_moduledef);
}
/* ModuleCreationPEP489 */
#if CYTHON_COMPILING_IN_LIMITED_API && (__PYX_LIMITED_VERSION_HEX < 0x03090000\
      || ((defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)) && __PYX_LIMITED_VERSION_HEX < 0x030A0000))
static PY_INT64_T __Pyx_GetCurrentInterpreterId(void) {
    {
        PyObject *module = PyImport_ImportModule("_interpreters"); // 3.13+ I think
        if (!module) {
            PyErr_Clear(); // just try the 3.8-3.12 version
            module = PyImport_ImportModule("_xxsubinterpreters");
            if (!module) goto bad;
        }
        PyObject *current = PyObject_CallMethod(module, "get_current", NULL);
        Py_DECREF(module);
        if (!current) goto bad;
        if (PyTuple_Check(current)) {
            PyObject *new_current = PySequence_GetItem(current, 0);
            Py_DECREF(current);
            current = new_current;
            if (!new_current) goto bad;
        }
        long long as_c_int = PyLong_AsLongLong(current);
        Py_DECREF(current);
        return as_c_int;
    }
  bad:
    PySys_WriteStderr("__Pyx_GetCurrentInterpreterId failed. Try setting the C define CYTHON_PEP489_MULTI_PHASE_INIT=0\n");
    return -1;
}
#endif
#if !CYTHON_USE_MODULE_STATE
static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
    static PY_INT64_T main_interpreter_id = -1;
#if CYTHON_COMPILING_IN_GRAAL && defined(GRAALPY_VERSION_NUM) && GRAALPY_VERSION_NUM > 0x19000000
    PY_INT64_T current_id = GraalPyInterpreterState_GetIDFromThreadState(PyThreadState_Get());
#elif CYTHON_COMPILING_IN_GRAAL
    PY_INT64_T current_id = PyInterpreterState_GetIDFromThreadState(PyThreadState_Get());
#elif CYTHON_COMPILING_IN_LIMITED_API && (__PYX_LIMITED_VERSION_HEX < 0x03090000\
      || ((defined(_WIN32) || defined(WIN32) || defined(MS_WINDOWS)) && __PYX_LIMITED_VERSION_HEX < 0x030A0000))
    PY_INT64_T current_id = __Pyx_GetCurrentInterpreterId();
#elif CYTHON_COMPILING_IN_LIMITED_API
    PY_INT64_T current_id = PyInterpreterState_GetID(PyInterpreterState_Get());
#else
    PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
#endif
    if (unlikely(current_id == -1)) {
        return -1;
    }
    if (main_interpreter_id == -1) {
        main_interpreter_id = current_id;
        return 0;
    } else if (unlikely(main_interpreter_id != current_id)) {
        PyErr_SetString(
            PyExc_ImportError,
            "Interpreter change detected - this module can only be loaded into one interpreter per process.");
        return -1;
    }
    return 0;
}
#endif
static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none)
{
    PyObject *value = PyObject_GetAttrString(spec, from_name);
    int result = 0;
    if (likely(value)) {
        if (allow_none || value != Py_None) {
            result = PyDict_SetItemString(moddict, to_name, value);
        }
        Py_DECREF(value);
    } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
        PyErr_Clear();
    } else {
        result = -1;
    }
    return result;
}
static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def) {
    PyObject *module = NULL, *moddict, *modname;
    CYTHON_UNUSED_VAR(def);
    #if !CYTHON_USE_MODULE_STATE
    if (__Pyx_check_single_interpreter())
        return NULL;
    #endif
    if (__pyx_m)
        return __Pyx_NewRef(__pyx_m);
    modname = PyObject_GetAttrString(spec, "name");
    if (unlikely(!modname)) goto bad;
    module = PyModule_NewObject(modname);
    Py_DECREF(modname);
    if (unlikely(!module)) goto bad;
    moddict = PyModule_GetDict(module);
    if (unlikely(!moddict)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
    if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
    return module;
bad:
    Py_XDECREF(module);
    return NULL;
}


static CYTHON_SMALL_CODE int __pyx_pymod_exec_activity_controller(PyObject *__pyx_pyinit_module)
#endif
{
  int stringtab_initialized = 0;
  #if CYTHON_USE_MODULE_STATE
  int pystate_addmodule_run = 0;
  #endif
  __pyx_mstatetype *__pyx_mstate = NULL;
  PyObject *__pyx_t_1 = NULL;
  PyObject *__pyx_t_2 = NULL;
  Py_ssize_t __pyx_t_3;
  PyObject *__pyx_t_4 = NULL;
  PyObject *__pyx_t_5 = NULL;
  PyObject *__pyx_t_6 = NULL;
  PyObject *__pyx_t_7 = NULL;
  PyObject *__pyx_t_8 = NULL;
  PyObject *__pyx_t_9 = NULL;
  size_t __pyx_t_10;
  int __pyx_t_11;
  int __pyx_t_12;
  PyObject *__pyx_t_13 = NULL;
  PyObject *__pyx_t_14 = NULL;
  PyObject *__pyx_t_15 = NULL;
  int __pyx_lineno = 0;
  const char *__pyx_filename = NULL;
  int __pyx_clineno = 0;
  __Pyx_RefNannyDeclarations
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  if (__pyx_m) {
    if (__pyx_m == __pyx_pyinit_module) return 0;
    PyErr_SetString(PyExc_RuntimeError, "Module 'activity_controller' has already been imported. Re-initialisation is not supported.");
    return -1;
  }
  #else
  if (__pyx_m) return __Pyx_NewRef(__pyx_m);
  #endif
  /*--- Module creation code ---*/
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  __pyx_t_1 = __pyx_pyinit_module;
  Py_INCREF(__pyx_t_1);
  #else
  __pyx_t_1 = PyModule_Create(&__pyx_moduledef); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
  #endif
  #if CYTHON_USE_MODULE_STATE
  {
    int add_module_result = __Pyx_State_AddModule(__pyx_t_1, &__pyx_moduledef);
    __pyx_t_1 = 0; /* transfer ownership from __pyx_t_1 to "activity_controller" pseudovariable */
    if (unlikely((add_module_result < 0))) __PYX_ERR(0, 1, __pyx_L1_error)
    pystate_addmodule_run = 1;
  }
  #else
  __pyx_m = __pyx_t_1;
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  PyUnstable_Module_SetGIL(__pyx_m, Py_MOD_GIL_USED);
  #endif
  __pyx_mstate = __pyx_mstate_global;
  CYTHON_UNUSED_VAR(__pyx_t_1);
  __pyx_mstate->__pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_mstate->__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
  Py_INCREF(__pyx_mstate->__pyx_d);
  __pyx_mstate->__pyx_b = __Pyx_PyImport_AddModuleRef(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_mstate->__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_mstate->__pyx_cython_runtime = __Pyx_PyImport_AddModuleRef("cython_runtime"); if (unlikely(!__pyx_mstate->__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_mstate->__pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
  /* ImportRefnannyAPI */
  #if CYTHON_REFNANNY
  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
  if (!__Pyx_RefNanny) {
    PyErr_Clear();
    __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
    if (!__Pyx_RefNanny)
        Py_FatalError("failed to import 'refnanny' module");
  }
  #endif
  
__Pyx_RefNannySetupContext("PyInit_activity_controller", 0);
  __Pyx_init_runtime_version();
  if (__Pyx_check_binary_version(__PYX_LIMITED_VERSION_HEX, __Pyx_get_runtime_version(), CYTHON_COMPILING_IN_LIMITED_API) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_mstate->__pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_mstate->__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_mstate->__pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_mstate->__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
  __pyx_mstate->__pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_mstate->__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Library function declarations ---*/
  /*--- Initialize various global constants etc. ---*/
  if (__Pyx_InitConstants(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  stringtab_initialized = 1;
  if (__Pyx_InitGlobals() < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__pyx_module_is_main_ws_package__controllers__activity_controller) {
    if (PyObject_SetAttr(__pyx_m, __pyx_mstate_global->__pyx_n_u_name_2, __pyx_mstate_global->__pyx_n_u_main) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  }
  {
    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
    if (!PyDict_GetItemString(modules, "ws_package.controllers.activity_controller")) {
      if (unlikely((PyDict_SetItemString(modules, "ws_package.controllers.activity_controller", __pyx_m) < 0))) __PYX_ERR(0, 1, __pyx_L1_error)
    }
  }
  /*--- Builtin init code ---*/
  if (__Pyx_InitCachedBuiltins(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Constants init code ---*/
  if (__Pyx_InitCachedConstants(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  if (__Pyx_CreateCodeObjects(__pyx_mstate) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  /*--- Global type/function init code ---*/
  (void)__Pyx_modinit_global_init_code(__pyx_mstate);
  (void)__Pyx_modinit_variable_export_code(__pyx_mstate);
  (void)__Pyx_modinit_function_export_code(__pyx_mstate);
  if (unlikely((__Pyx_modinit_type_init_code(__pyx_mstate) < 0))) __PYX_ERR(0, 1, __pyx_L1_error)
  (void)__Pyx_modinit_type_import_code(__pyx_mstate);
  (void)__Pyx_modinit_variable_import_code(__pyx_mstate);
  (void)__Pyx_modinit_function_import_code(__pyx_mstate);
  /*--- Execution code ---*/

  /* "ws_package/controllers/activity_controller.py":3
 * # cython: language_level=3
 * # ws_package/controllers/activity_controller.py
 * import asyncio             # <<<<<<<<<<<<<<
 * import datetime
 * import os
*/
  __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_asyncio, 0, 0, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error)
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_asyncio, __pyx_t_2) < (0)) __PYX_ERR(0, 3, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":4
 * # ws_package/controllers/activity_controller.py
 * import asyncio
 * import datetime             # <<<<<<<<<<<<<<
 * import os
 * import platform
*/
  __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_datetime, 0, 0, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error)
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_datetime, __pyx_t_2) < (0)) __PYX_ERR(0, 4, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":5
 * import asyncio
 * import datetime
 * import os             # <<<<<<<<<<<<<<
 * import platform
 * import threading
*/
  __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_os, 0, 0, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error)
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_os, __pyx_t_2) < (0)) __PYX_ERR(0, 5, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":6
 * import datetime
 * import os
 * import platform             # <<<<<<<<<<<<<<
 * import threading
 * from pathlib import Path
*/
  __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_platform, 0, 0, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_platform, __pyx_t_2) < (0)) __PYX_ERR(0, 6, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":7
 * import os
 * import platform
 * import threading             # <<<<<<<<<<<<<<
 * from pathlib import Path
 * import subprocess
*/
  __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_threading, 0, 0, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 7, __pyx_L1_error)
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_threading, __pyx_t_2) < (0)) __PYX_ERR(0, 7, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":8
 * import platform
 * import threading
 * from pathlib import Path             # <<<<<<<<<<<<<<
 * import subprocess
 * from tzlocal import get_localzone, reload_localzone
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_Path};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_pathlib, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_Path};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 8, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 8, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":9
 * import threading
 * from pathlib import Path
 * import subprocess             # <<<<<<<<<<<<<<
 * from tzlocal import get_localzone, reload_localzone
 * # NOTE: Do NOT add `from datetime import datetime, timedelta` here  it would
*/
  __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_subprocess, 0, 0, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error)
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_subprocess, __pyx_t_2) < (0)) __PYX_ERR(0, 9, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":10
 * from pathlib import Path
 * import subprocess
 * from tzlocal import get_localzone, reload_localzone             # <<<<<<<<<<<<<<
 * # NOTE: Do NOT add `from datetime import datetime, timedelta` here  it would
 * # shadow the `datetime` module imported above and break every `datetime.datetime`
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_get_localzone,__pyx_mstate_global->__pyx_n_u_reload_localzone};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_tzlocal, __pyx_imported_names, 2, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_get_localzone,__pyx_mstate_global->__pyx_n_u_reload_localzone};
    for (__pyx_t_3=0; __pyx_t_3 < 2; __pyx_t_3++) {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 10, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 10, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":14
 * # shadow the `datetime` module imported above and break every `datetime.datetime`
 * # / `datetime.timedelta` usage throughout the file.
 * from datetime import date             # <<<<<<<<<<<<<<
 * from collections import defaultdict
 * from typing import List, Tuple, Optional
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_date};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_datetime, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_date};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 14, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 14, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":15
 * # / `datetime.timedelta` usage throughout the file.
 * from datetime import date
 * from collections import defaultdict             # <<<<<<<<<<<<<<
 * from typing import List, Tuple, Optional
 * from sqlalchemy import select, delete, and_, func, desc, or_
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_defaultdict};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_collections, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 15, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_defaultdict};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 15, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 15, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":16
 * from datetime import date
 * from collections import defaultdict
 * from typing import List, Tuple, Optional             # <<<<<<<<<<<<<<
 * from sqlalchemy import select, delete, and_, func, desc, or_
 * from ws_package.models.base import async_session
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_List,__pyx_mstate_global->__pyx_n_u_Tuple,__pyx_mstate_global->__pyx_n_u_Optional};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_typing, __pyx_imported_names, 3, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_List,__pyx_mstate_global->__pyx_n_u_Tuple,__pyx_mstate_global->__pyx_n_u_Optional};
    for (__pyx_t_3=0; __pyx_t_3 < 3; __pyx_t_3++) {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 16, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 16, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":17
 * from collections import defaultdict
 * from typing import List, Tuple, Optional
 * from sqlalchemy import select, delete, and_, func, desc, or_             # <<<<<<<<<<<<<<
 * from ws_package.models.base import async_session
 * from ws_package.services.activity_service import ActivityService
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_select,__pyx_mstate_global->__pyx_n_u_delete,__pyx_mstate_global->__pyx_n_u_and,__pyx_mstate_global->__pyx_n_u_func_2,__pyx_mstate_global->__pyx_n_u_desc,__pyx_mstate_global->__pyx_n_u_or};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_sqlalchemy, __pyx_imported_names, 6, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 17, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_select,__pyx_mstate_global->__pyx_n_u_delete,__pyx_mstate_global->__pyx_n_u_and,__pyx_mstate_global->__pyx_n_u_func_2,__pyx_mstate_global->__pyx_n_u_desc,__pyx_mstate_global->__pyx_n_u_or};
    for (__pyx_t_3=0; __pyx_t_3 < 6; __pyx_t_3++) {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 17, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 17, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":18
 * from typing import List, Tuple, Optional
 * from sqlalchemy import select, delete, and_, func, desc, or_
 * from ws_package.models.base import async_session             # <<<<<<<<<<<<<<
 * from ws_package.services.activity_service import ActivityService
 * from ws_package.services.mode_service import FixedService
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_async_session};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_models_base, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 18, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_async_session};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 18, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 18, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":19
 * from sqlalchemy import select, delete, and_, func, desc, or_
 * from ws_package.models.base import async_session
 * from ws_package.services.activity_service import ActivityService             # <<<<<<<<<<<<<<
 * from ws_package.services.mode_service import FixedService
 * from ws_package.entities.user_entity import UserEntity
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ActivityService};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_services_activity_ser, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 19, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ActivityService};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 19, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 19, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":20
 * from ws_package.models.base import async_session
 * from ws_package.services.activity_service import ActivityService
 * from ws_package.services.mode_service import FixedService             # <<<<<<<<<<<<<<
 * from ws_package.entities.user_entity import UserEntity
 * from ws_package.entities.mode_entity import ModeEntity
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_FixedService};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_services_mode_service, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 20, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_FixedService};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 20, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 20, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":21
 * from ws_package.services.activity_service import ActivityService
 * from ws_package.services.mode_service import FixedService
 * from ws_package.entities.user_entity import UserEntity             # <<<<<<<<<<<<<<
 * from ws_package.entities.mode_entity import ModeEntity
 * from ws_package.entities.activity_entity import LocationEntity
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_UserEntity};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_entities_user_entity, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 21, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_UserEntity};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 21, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 21, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":22
 * from ws_package.services.mode_service import FixedService
 * from ws_package.entities.user_entity import UserEntity
 * from ws_package.entities.mode_entity import ModeEntity             # <<<<<<<<<<<<<<
 * from ws_package.entities.activity_entity import LocationEntity
 * from ws_package.entities.org_entity import OrgEntity
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ModeEntity};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_entities_mode_entity, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ModeEntity};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 22, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 22, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":23
 * from ws_package.entities.user_entity import UserEntity
 * from ws_package.entities.mode_entity import ModeEntity
 * from ws_package.entities.activity_entity import LocationEntity             # <<<<<<<<<<<<<<
 * from ws_package.entities.org_entity import OrgEntity
 * from ws_package.entities.s3bucket_entity import S3BucketEntity
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_LocationEntity};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_entities_activity_ent, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_LocationEntity};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 23, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 23, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":24
 * from ws_package.entities.mode_entity import ModeEntity
 * from ws_package.entities.activity_entity import LocationEntity
 * from ws_package.entities.org_entity import OrgEntity             # <<<<<<<<<<<<<<
 * from ws_package.entities.s3bucket_entity import S3BucketEntity
 * from ws_package.entities.screenshot_entity import ScreenshotEntity
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_OrgEntity};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_entities_org_entity, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_OrgEntity};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 24, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 24, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":25
 * from ws_package.entities.activity_entity import LocationEntity
 * from ws_package.entities.org_entity import OrgEntity
 * from ws_package.entities.s3bucket_entity import S3BucketEntity             # <<<<<<<<<<<<<<
 * from ws_package.entities.screenshot_entity import ScreenshotEntity
 * from ws_package.configs import config
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_S3BucketEntity};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_entities_s3bucket_ent, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_S3BucketEntity};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 25, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 25, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":26
 * from ws_package.entities.org_entity import OrgEntity
 * from ws_package.entities.s3bucket_entity import S3BucketEntity
 * from ws_package.entities.screenshot_entity import ScreenshotEntity             # <<<<<<<<<<<<<<
 * from ws_package.configs import config
 * from ws_package.utils.tracker_status import get_tracker_status, is_tracking_enabled
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ScreenshotEntity};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_entities_screenshot_e, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 26, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ScreenshotEntity};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 26, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 26, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":27
 * from ws_package.entities.s3bucket_entity import S3BucketEntity
 * from ws_package.entities.screenshot_entity import ScreenshotEntity
 * from ws_package.configs import config             # <<<<<<<<<<<<<<
 * from ws_package.utils.tracker_status import get_tracker_status, is_tracking_enabled
 * 
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_config};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_configs, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 27, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_config};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 27, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 27, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":28
 * from ws_package.entities.screenshot_entity import ScreenshotEntity
 * from ws_package.configs import config
 * from ws_package.utils.tracker_status import get_tracker_status, is_tracking_enabled             # <<<<<<<<<<<<<<
 * 
 * from ws_package.services.user_service import UserService
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_get_tracker_status,__pyx_mstate_global->__pyx_n_u_is_tracking_enabled};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_utils_tracker_status, __pyx_imported_names, 2, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 28, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_get_tracker_status,__pyx_mstate_global->__pyx_n_u_is_tracking_enabled};
    for (__pyx_t_3=0; __pyx_t_3 < 2; __pyx_t_3++) {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 28, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 28, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":30
 * from ws_package.utils.tracker_status import get_tracker_status, is_tracking_enabled
 * 
 * from ws_package.services.user_service import UserService             # <<<<<<<<<<<<<<
 * from ws_package.controllers.server_controller import ServerController
 * from ws_package.controllers.status_controller import StatusController
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_UserService};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_services_user_service, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_UserService};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 30, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 30, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":31
 * 
 * from ws_package.services.user_service import UserService
 * from ws_package.controllers.server_controller import ServerController             # <<<<<<<<<<<<<<
 * from ws_package.controllers.status_controller import StatusController
 * from ws_package.utils.system import get_ip, get_os_version, guid, precise_sleep
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ServerController};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_controllers_server_co, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 31, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ServerController};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 31, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 31, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":32
 * from ws_package.services.user_service import UserService
 * from ws_package.controllers.server_controller import ServerController
 * from ws_package.controllers.status_controller import StatusController             # <<<<<<<<<<<<<<
 * from ws_package.utils.system import get_ip, get_os_version, guid, precise_sleep
 * from ws_package.utils.browser_url_detector import get_browser_url_with_fallback
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_StatusController};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_controllers_status_co, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 32, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_StatusController};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 32, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 32, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":33
 * from ws_package.controllers.server_controller import ServerController
 * from ws_package.controllers.status_controller import StatusController
 * from ws_package.utils.system import get_ip, get_os_version, guid, precise_sleep             # <<<<<<<<<<<<<<
 * from ws_package.utils.browser_url_detector import get_browser_url_with_fallback
 * from ws_package.log.writer import LogWriter
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_get_ip,__pyx_mstate_global->__pyx_n_u_get_os_version,__pyx_mstate_global->__pyx_n_u_guid,__pyx_mstate_global->__pyx_n_u_precise_sleep};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_utils_system, __pyx_imported_names, 4, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 33, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_get_ip,__pyx_mstate_global->__pyx_n_u_get_os_version,__pyx_mstate_global->__pyx_n_u_guid,__pyx_mstate_global->__pyx_n_u_precise_sleep};
    for (__pyx_t_3=0; __pyx_t_3 < 4; __pyx_t_3++) {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 33, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 33, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":34
 * from ws_package.controllers.status_controller import StatusController
 * from ws_package.utils.system import get_ip, get_os_version, guid, precise_sleep
 * from ws_package.utils.browser_url_detector import get_browser_url_with_fallback             # <<<<<<<<<<<<<<
 * from ws_package.log.writer import LogWriter
 * from ws_package.utils import logs
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_get_browser_url_with_fallback};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_utils_browser_url_det, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 34, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_get_browser_url_with_fallback};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 34, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 34, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":35
 * from ws_package.utils.system import get_ip, get_os_version, guid, precise_sleep
 * from ws_package.utils.browser_url_detector import get_browser_url_with_fallback
 * from ws_package.log.writer import LogWriter             # <<<<<<<<<<<<<<
 * from ws_package.utils import logs
 * from ws_package.utils.api_log_policy import (
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_LogWriter};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_log_writer, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 35, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_LogWriter};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 35, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 35, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":36
 * from ws_package.utils.browser_url_detector import get_browser_url_with_fallback
 * from ws_package.log.writer import LogWriter
 * from ws_package.utils import logs             # <<<<<<<<<<<<<<
 * from ws_package.utils.api_log_policy import (
 *     api_name_from_url,
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_logs};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_utils, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_logs};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 36, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 36, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":37
 * from ws_package.log.writer import LogWriter
 * from ws_package.utils import logs
 * from ws_package.utils.api_log_policy import (             # <<<<<<<<<<<<<<
 *     api_name_from_url,
 *     log_api_response_summary,
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_api_name_from_url,__pyx_mstate_global->__pyx_n_u_log_api_response_summary,__pyx_mstate_global->__pyx_n_u_log_testing_request_headers};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_utils_api_log_policy, __pyx_imported_names, 3, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_api_name_from_url,__pyx_mstate_global->__pyx_n_u_log_api_response_summary,__pyx_mstate_global->__pyx_n_u_log_testing_request_headers};
    for (__pyx_t_3=0; __pyx_t_3 < 3; __pyx_t_3++) {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 37, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 37, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":42
 *     log_testing_request_headers,
 * )
 * from ws_package.services.api_request_service import APIRequest             # <<<<<<<<<<<<<<
 * from ws_package.utils.db_lock_manager import db_lock_manager
 * from ws_package.exceptions.custom_exceptions import (
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_APIRequest};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_services_api_request, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 42, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_APIRequest};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 42, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 42, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":43
 * )
 * from ws_package.services.api_request_service import APIRequest
 * from ws_package.utils.db_lock_manager import db_lock_manager             # <<<<<<<<<<<<<<
 * from ws_package.exceptions.custom_exceptions import (
 *     FileSystemError, ValidationError, APIError, NetworkError,
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_db_lock_manager};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_utils_db_lock_manager, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 43, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_db_lock_manager};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 43, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 43, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":44
 * from ws_package.services.api_request_service import APIRequest
 * from ws_package.utils.db_lock_manager import db_lock_manager
 * from ws_package.exceptions.custom_exceptions import (             # <<<<<<<<<<<<<<
 *     FileSystemError, ValidationError, APIError, NetworkError,
 *     ScreenshotError, ActivityMonitoringError
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_FileSystemError,__pyx_mstate_global->__pyx_n_u_ValidationError,__pyx_mstate_global->__pyx_n_u_APIError,__pyx_mstate_global->__pyx_n_u_NetworkError,__pyx_mstate_global->__pyx_n_u_ScreenshotError,__pyx_mstate_global->__pyx_n_u_ActivityMonitoringError};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_exceptions_custom_exc, __pyx_imported_names, 6, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_FileSystemError,__pyx_mstate_global->__pyx_n_u_ValidationError,__pyx_mstate_global->__pyx_n_u_APIError,__pyx_mstate_global->__pyx_n_u_NetworkError,__pyx_mstate_global->__pyx_n_u_ScreenshotError,__pyx_mstate_global->__pyx_n_u_ActivityMonitoringError};
    for (__pyx_t_3=0; __pyx_t_3 < 6; __pyx_t_3++) {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 44, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 44, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":48
 *     ScreenshotError, ActivityMonitoringError
 * )
 * from ws_package.entities.activity_entity import ActivityPercentageEntity             # <<<<<<<<<<<<<<
 * from ws_package.repositories.activity_percentage_repo import activity_percentage_manager
 * from ws_package.services.activity_percentage_service import activity_percentage_service
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ActivityPercentageEntity};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_entities_activity_ent, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 48, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ActivityPercentageEntity};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 48, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 48, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":49
 * )
 * from ws_package.entities.activity_entity import ActivityPercentageEntity
 * from ws_package.repositories.activity_percentage_repo import activity_percentage_manager             # <<<<<<<<<<<<<<
 * from ws_package.services.activity_percentage_service import activity_percentage_service
 * from ws_package.services.db_writer_service import db_writer_service
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_activity_percentage_manager};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_repositories_activity_2, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_activity_percentage_manager};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 49, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 49, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":50
 * from ws_package.entities.activity_entity import ActivityPercentageEntity
 * from ws_package.repositories.activity_percentage_repo import activity_percentage_manager
 * from ws_package.services.activity_percentage_service import activity_percentage_service             # <<<<<<<<<<<<<<
 * from ws_package.services.db_writer_service import db_writer_service
 * from ws_package.utils.ipc_server import is_ipc_ready
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_activity_percentage_service};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_services_activity_per, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_activity_percentage_service};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 50, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 50, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":51
 * from ws_package.repositories.activity_percentage_repo import activity_percentage_manager
 * from ws_package.services.activity_percentage_service import activity_percentage_service
 * from ws_package.services.db_writer_service import db_writer_service             # <<<<<<<<<<<<<<
 * from ws_package.utils.ipc_server import is_ipc_ready
 * from ws_package.utils.db_write_queue import db_write_queue, WriteOperationType
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_db_writer_service};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_services_db_writer_se, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 51, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_db_writer_service};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 51, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 51, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":52
 * from ws_package.services.activity_percentage_service import activity_percentage_service
 * from ws_package.services.db_writer_service import db_writer_service
 * from ws_package.utils.ipc_server import is_ipc_ready             # <<<<<<<<<<<<<<
 * from ws_package.utils.db_write_queue import db_write_queue, WriteOperationType
 * from ws_package.utils.s3 import s3_detail, S3sync, s3_detail_for_upload
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_is_ipc_ready};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_utils_ipc_server, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 52, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_is_ipc_ready};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 52, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 52, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":53
 * from ws_package.services.db_writer_service import db_writer_service
 * from ws_package.utils.ipc_server import is_ipc_ready
 * from ws_package.utils.db_write_queue import db_write_queue, WriteOperationType             # <<<<<<<<<<<<<<
 * from ws_package.utils.s3 import s3_detail, S3sync, s3_detail_for_upload
 * from ws_package.utils.system_wake_detector import get_system_wake_detector
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_db_write_queue,__pyx_mstate_global->__pyx_n_u_WriteOperationType};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_utils_db_write_queue, __pyx_imported_names, 2, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 53, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_db_write_queue,__pyx_mstate_global->__pyx_n_u_WriteOperationType};
    for (__pyx_t_3=0; __pyx_t_3 < 2; __pyx_t_3++) {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 53, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 53, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":54
 * from ws_package.utils.ipc_server import is_ipc_ready
 * from ws_package.utils.db_write_queue import db_write_queue, WriteOperationType
 * from ws_package.utils.s3 import s3_detail, S3sync, s3_detail_for_upload             # <<<<<<<<<<<<<<
 * from ws_package.utils.system_wake_detector import get_system_wake_detector
 * from ws_package.utils.build_mode import is_silent_build
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_s3_detail,__pyx_mstate_global->__pyx_n_u_S3sync,__pyx_mstate_global->__pyx_n_u_s3_detail_for_upload};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_utils_s3, __pyx_imported_names, 3, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_s3_detail,__pyx_mstate_global->__pyx_n_u_S3sync,__pyx_mstate_global->__pyx_n_u_s3_detail_for_upload};
    for (__pyx_t_3=0; __pyx_t_3 < 3; __pyx_t_3++) {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 54, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 54, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":55
 * from ws_package.utils.db_write_queue import db_write_queue, WriteOperationType
 * from ws_package.utils.s3 import s3_detail, S3sync, s3_detail_for_upload
 * from ws_package.utils.system_wake_detector import get_system_wake_detector             # <<<<<<<<<<<<<<
 * from ws_package.utils.build_mode import is_silent_build
 * from ws_package.services.weekly_limit_notification_service import get_weekly_limit_notification_service
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_get_system_wake_detector};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_utils_system_wake_det, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_get_system_wake_detector};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 55, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 55, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":56
 * from ws_package.utils.s3 import s3_detail, S3sync, s3_detail_for_upload
 * from ws_package.utils.system_wake_detector import get_system_wake_detector
 * from ws_package.utils.build_mode import is_silent_build             # <<<<<<<<<<<<<<
 * from ws_package.services.weekly_limit_notification_service import get_weekly_limit_notification_service
 * 
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_is_silent_build};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_utils_build_mode, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 56, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_is_silent_build};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 56, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 56, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":57
 * from ws_package.utils.system_wake_detector import get_system_wake_detector
 * from ws_package.utils.build_mode import is_silent_build
 * from ws_package.services.weekly_limit_notification_service import get_weekly_limit_notification_service             # <<<<<<<<<<<<<<
 * 
 * import re
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_get_weekly_limit_notification_se};
    __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_services_weekly_limit, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 57, __pyx_L1_error)
  }
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_get_weekly_limit_notification_se};
    __pyx_t_3 = 0; {
      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 57, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_4);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 57, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":59
 * from ws_package.services.weekly_limit_notification_service import get_weekly_limit_notification_service
 * 
 * import re             # <<<<<<<<<<<<<<
 * import unicodedata
 * import time
*/
  __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_re, 0, 0, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 59, __pyx_L1_error)
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_re, __pyx_t_2) < (0)) __PYX_ERR(0, 59, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":60
 * 
 * import re
 * import unicodedata             # <<<<<<<<<<<<<<
 * import time
 * import base64
*/
  __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_unicodedata, 0, 0, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 60, __pyx_L1_error)
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_unicodedata, __pyx_t_2) < (0)) __PYX_ERR(0, 60, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":61
 * import re
 * import unicodedata
 * import time             # <<<<<<<<<<<<<<
 * import base64
 * import sys
*/
  __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_time, 0, 0, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error)
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_time, __pyx_t_2) < (0)) __PYX_ERR(0, 61, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":62
 * import unicodedata
 * import time
 * import base64             # <<<<<<<<<<<<<<
 * import sys
 * import psutil
*/
  __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_base64, 0, 0, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 62, __pyx_L1_error)
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_base64, __pyx_t_2) < (0)) __PYX_ERR(0, 62, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":63
 * import time
 * import base64
 * import sys             # <<<<<<<<<<<<<<
 * import psutil
 * import zoneinfo
*/
  __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_sys, 0, 0, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error)
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_sys, __pyx_t_2) < (0)) __PYX_ERR(0, 63, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":64
 * import base64
 * import sys
 * import psutil             # <<<<<<<<<<<<<<
 * import zoneinfo
 * import requests
*/
  __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_psutil, 0, 0, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 64, __pyx_L1_error)
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_psutil, __pyx_t_2) < (0)) __PYX_ERR(0, 64, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":65
 * import sys
 * import psutil
 * import zoneinfo             # <<<<<<<<<<<<<<
 * import requests
 * import json
*/
  __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_zoneinfo, 0, 0, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error)
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_zoneinfo, __pyx_t_2) < (0)) __PYX_ERR(0, 65, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":66
 * import psutil
 * import zoneinfo
 * import requests             # <<<<<<<<<<<<<<
 * import json
 * import traceback
*/
  __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_requests, 0, 0, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L1_error)
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_requests, __pyx_t_2) < (0)) __PYX_ERR(0, 66, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":67
 * import zoneinfo
 * import requests
 * import json             # <<<<<<<<<<<<<<
 * import traceback
 * import tempfile
*/
  __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_json, 0, 0, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 67, __pyx_L1_error)
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_json, __pyx_t_2) < (0)) __PYX_ERR(0, 67, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":68
 * import requests
 * import json
 * import traceback             # <<<<<<<<<<<<<<
 * import tempfile
 * import shutil
*/
  __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_traceback, 0, 0, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error)
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_traceback, __pyx_t_2) < (0)) __PYX_ERR(0, 68, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":69
 * import json
 * import traceback
 * import tempfile             # <<<<<<<<<<<<<<
 * import shutil
 * 
*/
  __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_tempfile, 0, 0, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error)
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_tempfile, __pyx_t_2) < (0)) __PYX_ERR(0, 69, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":70
 * import traceback
 * import tempfile
 * import shutil             # <<<<<<<<<<<<<<
 * 
 * try:
*/
  __pyx_t_1 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_shutil, 0, 0, NULL, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 70, __pyx_L1_error)
  __pyx_t_2 = __pyx_t_1;
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_shutil, __pyx_t_2) < (0)) __PYX_ERR(0, 70, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":72
 * import shutil
 * 
 * try:             # <<<<<<<<<<<<<<
 *     from ws_package.monitoring.windows import Window
 *     from ws_package.models.base import Appmonitor, FixedMode, OrgConfigurations, Screenshots, ActivityInterval, Notes
*/
  {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    __Pyx_ExceptionSave(&__pyx_t_1, &__pyx_t_5, &__pyx_t_6);
    __Pyx_XGOTREF(__pyx_t_1);
    __Pyx_XGOTREF(__pyx_t_5);
    __Pyx_XGOTREF(__pyx_t_6);
    /*try:*/ {

      /* "ws_package/controllers/activity_controller.py":73
 * 
 * try:
 *     from ws_package.monitoring.windows import Window             # <<<<<<<<<<<<<<
 *     from ws_package.models.base import Appmonitor, FixedMode, OrgConfigurations, Screenshots, ActivityInterval, Notes
 * 
*/
      {
        PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_Window};
        __pyx_t_7 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_monitoring_windows, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 73, __pyx_L2_error)
      }
      __pyx_t_2 = __pyx_t_7;
      __Pyx_GOTREF(__pyx_t_2);
      {
        PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_Window};
        __pyx_t_3 = 0; {
          __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 73, __pyx_L2_error)
          __Pyx_GOTREF(__pyx_t_4);
          if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 73, __pyx_L2_error)
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "ws_package/controllers/activity_controller.py":74
 * try:
 *     from ws_package.monitoring.windows import Window
 *     from ws_package.models.base import Appmonitor, FixedMode, OrgConfigurations, Screenshots, ActivityInterval, Notes             # <<<<<<<<<<<<<<
 * 
 *     if platform.system() == "Windows":
*/
      {
        PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_Appmonitor,__pyx_mstate_global->__pyx_n_u_FixedMode,__pyx_mstate_global->__pyx_n_u_OrgConfigurations,__pyx_mstate_global->__pyx_n_u_Screenshots,__pyx_mstate_global->__pyx_n_u_ActivityInterval,__pyx_mstate_global->__pyx_n_u_Notes};
        __pyx_t_7 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_models_base, __pyx_imported_names, 6, NULL, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 74, __pyx_L2_error)
      }
      __pyx_t_2 = __pyx_t_7;
      __Pyx_GOTREF(__pyx_t_2);
      {
        PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_Appmonitor,__pyx_mstate_global->__pyx_n_u_FixedMode,__pyx_mstate_global->__pyx_n_u_OrgConfigurations,__pyx_mstate_global->__pyx_n_u_Screenshots,__pyx_mstate_global->__pyx_n_u_ActivityInterval,__pyx_mstate_global->__pyx_n_u_Notes};
        for (__pyx_t_3=0; __pyx_t_3 < 6; __pyx_t_3++) {
          __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 74, __pyx_L2_error)
          __Pyx_GOTREF(__pyx_t_4);
          if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_4) < (0)) __PYX_ERR(0, 74, __pyx_L2_error)
          __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
        }
      }
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

      /* "ws_package/controllers/activity_controller.py":76
 *     from ws_package.models.base import Appmonitor, FixedMode, OrgConfigurations, Screenshots, ActivityInterval, Notes
 * 
 *     if platform.system() == "Windows":             # <<<<<<<<<<<<<<
 *         import winreg
 *         from ws_package.monitoring.listeners_windows import DeviceListener
*/
      __pyx_t_4 = NULL;
      __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_platform); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 76, __pyx_L2_error)
      __Pyx_GOTREF(__pyx_t_8);
      __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_system); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 76, __pyx_L2_error)
      __Pyx_GOTREF(__pyx_t_9);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __pyx_t_10 = 1;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_4, NULL};
        __pyx_t_2 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_9, __pyx_callargs+__pyx_t_10, (1-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
        if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 76, __pyx_L2_error)
        __Pyx_GOTREF(__pyx_t_2);
      }
      __pyx_t_11 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_Windows, Py_EQ)); if (unlikely((__pyx_t_11 < 0))) __PYX_ERR(0, 76, __pyx_L2_error)
      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      if (__pyx_t_11) {

        /* "ws_package/controllers/activity_controller.py":77
 * 
 *     if platform.system() == "Windows":
 *         import winreg             # <<<<<<<<<<<<<<
 *         from ws_package.monitoring.listeners_windows import DeviceListener
 *         from ws_package.monitoring.time_monitor import OptimizedWindowsTimeMonitor
*/
        __pyx_t_7 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_winreg, 0, 0, NULL, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 77, __pyx_L2_error)
        __pyx_t_2 = __pyx_t_7;
        __Pyx_GOTREF(__pyx_t_2);
        if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_winreg, __pyx_t_2) < (0)) __PYX_ERR(0, 77, __pyx_L2_error)
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "ws_package/controllers/activity_controller.py":78
 *     if platform.system() == "Windows":
 *         import winreg
 *         from ws_package.monitoring.listeners_windows import DeviceListener             # <<<<<<<<<<<<<<
 *         from ws_package.monitoring.time_monitor import OptimizedWindowsTimeMonitor
 *     else:
*/
        {
          PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_DeviceListener};
          __pyx_t_7 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_monitoring_listeners, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 78, __pyx_L2_error)
        }
        __pyx_t_2 = __pyx_t_7;
        __Pyx_GOTREF(__pyx_t_2);
        {
          PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_DeviceListener};
          __pyx_t_3 = 0; {
            __pyx_t_9 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 78, __pyx_L2_error)
            __Pyx_GOTREF(__pyx_t_9);
            if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_9) < (0)) __PYX_ERR(0, 78, __pyx_L2_error)
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "ws_package/controllers/activity_controller.py":79
 *         import winreg
 *         from ws_package.monitoring.listeners_windows import DeviceListener
 *         from ws_package.monitoring.time_monitor import OptimizedWindowsTimeMonitor             # <<<<<<<<<<<<<<
 *     else:
 *         from ws_package.monitoring.listeners import DeviceListener
*/
        {
          PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_OptimizedWindowsTimeMonitor};
          __pyx_t_7 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_monitoring_time_monit, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 79, __pyx_L2_error)
        }
        __pyx_t_2 = __pyx_t_7;
        __Pyx_GOTREF(__pyx_t_2);
        {
          PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_OptimizedWindowsTimeMonitor};
          __pyx_t_3 = 0; {
            __pyx_t_9 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 79, __pyx_L2_error)
            __Pyx_GOTREF(__pyx_t_9);
            if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_9) < (0)) __PYX_ERR(0, 79, __pyx_L2_error)
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

        /* "ws_package/controllers/activity_controller.py":76
 *     from ws_package.models.base import Appmonitor, FixedMode, OrgConfigurations, Screenshots, ActivityInterval, Notes
 * 
 *     if platform.system() == "Windows":             # <<<<<<<<<<<<<<
 *         import winreg
 *         from ws_package.monitoring.listeners_windows import DeviceListener
*/
        goto __pyx_L8;
      }

      /* "ws_package/controllers/activity_controller.py":81
 *         from ws_package.monitoring.time_monitor import OptimizedWindowsTimeMonitor
 *     else:
 *         from ws_package.monitoring.listeners import DeviceListener             # <<<<<<<<<<<<<<
 * except ImportError:
 *     raise RuntimeError("Error in importing Activity Controller file either in listeners or windows")
*/
      /*else*/ {
        {
          PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_DeviceListener};
          __pyx_t_7 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_monitoring_listeners_2, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 81, __pyx_L2_error)
        }
        __pyx_t_2 = __pyx_t_7;
        __Pyx_GOTREF(__pyx_t_2);
        {
          PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_DeviceListener};
          __pyx_t_3 = 0; {
            __pyx_t_9 = __Pyx_ImportFrom(__pyx_t_2, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 81, __pyx_L2_error)
            __Pyx_GOTREF(__pyx_t_9);
            if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_9) < (0)) __PYX_ERR(0, 81, __pyx_L2_error)
            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
          }
        }
        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
      }
      __pyx_L8:;

      /* "ws_package/controllers/activity_controller.py":72
 * import shutil
 * 
 * try:             # <<<<<<<<<<<<<<
 *     from ws_package.monitoring.windows import Window
 *     from ws_package.models.base import Appmonitor, FixedMode, OrgConfigurations, Screenshots, ActivityInterval, Notes
*/
    }
    __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
    __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
    __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
    goto __pyx_L7_try_end;
    __pyx_L2_error:;
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
    __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;

    /* "ws_package/controllers/activity_controller.py":82
 *     else:
 *         from ws_package.monitoring.listeners import DeviceListener
 * except ImportError:             # <<<<<<<<<<<<<<
 *     raise RuntimeError("Error in importing Activity Controller file either in listeners or windows")
 * 
*/
    __pyx_t_12 = __Pyx_PyErr_ExceptionMatches(((PyObject *)(((PyTypeObject*)PyExc_ImportError))));
    if (__pyx_t_12) {
      __Pyx_AddTraceback("ws_package.controllers.activity_controller", __pyx_clineno, __pyx_lineno, __pyx_filename);
      if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_9, &__pyx_t_4) < 0) __PYX_ERR(0, 82, __pyx_L4_except_error)
      __Pyx_XGOTREF(__pyx_t_2);
      __Pyx_XGOTREF(__pyx_t_9);
      __Pyx_XGOTREF(__pyx_t_4);

      /* "ws_package/controllers/activity_controller.py":83
 *         from ws_package.monitoring.listeners import DeviceListener
 * except ImportError:
 *     raise RuntimeError("Error in importing Activity Controller file either in listeners or windows")             # <<<<<<<<<<<<<<
 * 
 * from ws_package.controllers.screenshot_controller import ScreenshotController
*/
      __pyx_t_13 = NULL;
      __pyx_t_10 = 1;
      {
        PyObject *__pyx_callargs[2] = {__pyx_t_13, __pyx_mstate_global->__pyx_kp_u_Error_in_importing_Activity_Cont};
        __pyx_t_8 = __Pyx_PyObject_FastCall((PyObject*)(((PyTypeObject*)PyExc_RuntimeError)), __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
        __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0;
        if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 83, __pyx_L4_except_error)
        __Pyx_GOTREF(__pyx_t_8);
      }
      __Pyx_Raise(__pyx_t_8, 0, 0, 0);
      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
      __PYX_ERR(0, 83, __pyx_L4_except_error)
    }
    goto __pyx_L4_except_error;

    /* "ws_package/controllers/activity_controller.py":72
 * import shutil
 * 
 * try:             # <<<<<<<<<<<<<<
 *     from ws_package.monitoring.windows import Window
 *     from ws_package.models.base import Appmonitor, FixedMode, OrgConfigurations, Screenshots, ActivityInterval, Notes
*/
    __pyx_L4_except_error:;
    __Pyx_XGIVEREF(__pyx_t_1);
    __Pyx_XGIVEREF(__pyx_t_5);
    __Pyx_XGIVEREF(__pyx_t_6);
    __Pyx_ExceptionReset(__pyx_t_1, __pyx_t_5, __pyx_t_6);
    goto __pyx_L1_error;
    __pyx_L7_try_end:;
  }

  /* "ws_package/controllers/activity_controller.py":85
 *     raise RuntimeError("Error in importing Activity Controller file either in listeners or windows")
 * 
 * from ws_package.controllers.screenshot_controller import ScreenshotController             # <<<<<<<<<<<<<<
 * from ws_package.managers import TimezoneManager, ScreenshotManager, ActivityManager, DataManager
 * 
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ScreenshotController};
    __pyx_t_6 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_controllers_screensho, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 85, __pyx_L1_error)
  }
  __pyx_t_4 = __pyx_t_6;
  __Pyx_GOTREF(__pyx_t_4);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ScreenshotController};
    __pyx_t_3 = 0; {
      __pyx_t_9 = __Pyx_ImportFrom(__pyx_t_4, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 85, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_9) < (0)) __PYX_ERR(0, 85, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":86
 * 
 * from ws_package.controllers.screenshot_controller import ScreenshotController
 * from ws_package.managers import TimezoneManager, ScreenshotManager, ActivityManager, DataManager             # <<<<<<<<<<<<<<
 * 
 * from ws_package.controllers.activity_screenshot_mixin import ActivityScreenshotMixin
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_TimezoneManager,__pyx_mstate_global->__pyx_n_u_ScreenshotManager,__pyx_mstate_global->__pyx_n_u_ActivityManager,__pyx_mstate_global->__pyx_n_u_DataManager};
    __pyx_t_6 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_managers, __pyx_imported_names, 4, NULL, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 86, __pyx_L1_error)
  }
  __pyx_t_4 = __pyx_t_6;
  __Pyx_GOTREF(__pyx_t_4);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_TimezoneManager,__pyx_mstate_global->__pyx_n_u_ScreenshotManager,__pyx_mstate_global->__pyx_n_u_ActivityManager,__pyx_mstate_global->__pyx_n_u_DataManager};
    for (__pyx_t_3=0; __pyx_t_3 < 4; __pyx_t_3++) {
      __pyx_t_9 = __Pyx_ImportFrom(__pyx_t_4, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 86, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_9) < (0)) __PYX_ERR(0, 86, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":88
 * from ws_package.managers import TimezoneManager, ScreenshotManager, ActivityManager, DataManager
 * 
 * from ws_package.controllers.activity_screenshot_mixin import ActivityScreenshotMixin             # <<<<<<<<<<<<<<
 * from ws_package.controllers.activity_break_mixin import ActivityBreakMixin
 * from ws_package.controllers.activity_idle_mixin import ActivityIdleMixin
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ActivityScreenshotMixin};
    __pyx_t_6 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity_2, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 88, __pyx_L1_error)
  }
  __pyx_t_4 = __pyx_t_6;
  __Pyx_GOTREF(__pyx_t_4);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ActivityScreenshotMixin};
    __pyx_t_3 = 0; {
      __pyx_t_9 = __Pyx_ImportFrom(__pyx_t_4, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 88, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_9) < (0)) __PYX_ERR(0, 88, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":89
 * 
 * from ws_package.controllers.activity_screenshot_mixin import ActivityScreenshotMixin
 * from ws_package.controllers.activity_break_mixin import ActivityBreakMixin             # <<<<<<<<<<<<<<
 * from ws_package.controllers.activity_idle_mixin import ActivityIdleMixin
 * from ws_package.controllers.activity_timezone_mixin import ActivityTimezoneMixin
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ActivityBreakMixin};
    __pyx_t_6 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity_3, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 89, __pyx_L1_error)
  }
  __pyx_t_4 = __pyx_t_6;
  __Pyx_GOTREF(__pyx_t_4);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ActivityBreakMixin};
    __pyx_t_3 = 0; {
      __pyx_t_9 = __Pyx_ImportFrom(__pyx_t_4, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 89, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_9) < (0)) __PYX_ERR(0, 89, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":90
 * from ws_package.controllers.activity_screenshot_mixin import ActivityScreenshotMixin
 * from ws_package.controllers.activity_break_mixin import ActivityBreakMixin
 * from ws_package.controllers.activity_idle_mixin import ActivityIdleMixin             # <<<<<<<<<<<<<<
 * from ws_package.controllers.activity_timezone_mixin import ActivityTimezoneMixin
 * from ws_package.controllers.activity_interval_mixin import ActivityIntervalMixin
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ActivityIdleMixin};
    __pyx_t_6 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity_4, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 90, __pyx_L1_error)
  }
  __pyx_t_4 = __pyx_t_6;
  __Pyx_GOTREF(__pyx_t_4);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ActivityIdleMixin};
    __pyx_t_3 = 0; {
      __pyx_t_9 = __Pyx_ImportFrom(__pyx_t_4, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 90, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_9) < (0)) __PYX_ERR(0, 90, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":91
 * from ws_package.controllers.activity_break_mixin import ActivityBreakMixin
 * from ws_package.controllers.activity_idle_mixin import ActivityIdleMixin
 * from ws_package.controllers.activity_timezone_mixin import ActivityTimezoneMixin             # <<<<<<<<<<<<<<
 * from ws_package.controllers.activity_interval_mixin import ActivityIntervalMixin
 * from ws_package.controllers.activity_push_mixin import ActivityPushMixin
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ActivityTimezoneMixin};
    __pyx_t_6 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity_5, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 91, __pyx_L1_error)
  }
  __pyx_t_4 = __pyx_t_6;
  __Pyx_GOTREF(__pyx_t_4);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ActivityTimezoneMixin};
    __pyx_t_3 = 0; {
      __pyx_t_9 = __Pyx_ImportFrom(__pyx_t_4, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 91, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_9) < (0)) __PYX_ERR(0, 91, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":92
 * from ws_package.controllers.activity_idle_mixin import ActivityIdleMixin
 * from ws_package.controllers.activity_timezone_mixin import ActivityTimezoneMixin
 * from ws_package.controllers.activity_interval_mixin import ActivityIntervalMixin             # <<<<<<<<<<<<<<
 * from ws_package.controllers.activity_push_mixin import ActivityPushMixin
 * 
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ActivityIntervalMixin};
    __pyx_t_6 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity_6, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 92, __pyx_L1_error)
  }
  __pyx_t_4 = __pyx_t_6;
  __Pyx_GOTREF(__pyx_t_4);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ActivityIntervalMixin};
    __pyx_t_3 = 0; {
      __pyx_t_9 = __Pyx_ImportFrom(__pyx_t_4, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 92, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_9) < (0)) __PYX_ERR(0, 92, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":93
 * from ws_package.controllers.activity_timezone_mixin import ActivityTimezoneMixin
 * from ws_package.controllers.activity_interval_mixin import ActivityIntervalMixin
 * from ws_package.controllers.activity_push_mixin import ActivityPushMixin             # <<<<<<<<<<<<<<
 * 
 * 
*/
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ActivityPushMixin};
    __pyx_t_6 = __Pyx_Import(__pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity_7, __pyx_imported_names, 1, NULL, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 93, __pyx_L1_error)
  }
  __pyx_t_4 = __pyx_t_6;
  __Pyx_GOTREF(__pyx_t_4);
  {
    PyObject* const __pyx_imported_names[] = {__pyx_mstate_global->__pyx_n_u_ActivityPushMixin};
    __pyx_t_3 = 0; {
      __pyx_t_9 = __Pyx_ImportFrom(__pyx_t_4, __pyx_imported_names[__pyx_t_3]); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 93, __pyx_L1_error)
      __Pyx_GOTREF(__pyx_t_9);
      if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_imported_names[__pyx_t_3], __pyx_t_9) < (0)) __PYX_ERR(0, 93, __pyx_L1_error)
      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
    }
  }
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":97
 * 
 * 
 * logger = LogWriter.file(__name__)             # <<<<<<<<<<<<<<
 * 
 * 
*/
  __pyx_t_9 = NULL;
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_LogWriter); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_file_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 97, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_name_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __pyx_t_10 = 1;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_9, __pyx_t_2};
    __pyx_t_4 = __Pyx_PyObject_FastCall((PyObject*)__pyx_t_8, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 97, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_4);
  }
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_logger, __pyx_t_4) < (0)) __PYX_ERR(0, 97, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":100
 * 
 * 
 * def _to_int(val, default=0):             # <<<<<<<<<<<<<<
 *     """Cast an API or DB value to int safely.
 * 
*/
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_1_to_int, 0, __pyx_mstate_global->__pyx_n_u_to_int, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[78])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 100, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_mstate_global->__pyx_tuple[31]);
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_to_int, __pyx_t_4) < (0)) __PYX_ERR(0, 100, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":118
 * 
 * 
 * def _get_electron_comm_lazy():             # <<<<<<<<<<<<<<
 *     """Lazy import to avoid circular imports. Returns the global Electron communicator instance."""
 *     from ws_package.utils.electron_comm import get_electron_comm
*/
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_3_get_electron_comm_lazy, 0, __pyx_mstate_global->__pyx_n_u_get_electron_comm_lazy, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[79])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 118, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_get_electron_comm_lazy, __pyx_t_4) < (0)) __PYX_ERR(0, 118, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":125
 * 
 * class ActivityController(
 *     ActivityScreenshotMixin,             # <<<<<<<<<<<<<<
 *     ActivityBreakMixin,
 *     ActivityIdleMixin,
*/
  __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_ActivityScreenshotMixin); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 125, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "ws_package/controllers/activity_controller.py":126
 * class ActivityController(
 *     ActivityScreenshotMixin,
 *     ActivityBreakMixin,             # <<<<<<<<<<<<<<
 *     ActivityIdleMixin,
 *     ActivityTimezoneMixin,
*/
  __Pyx_GetModuleGlobalName(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_ActivityBreakMixin); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 126, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);

  /* "ws_package/controllers/activity_controller.py":127
 *     ActivityScreenshotMixin,
 *     ActivityBreakMixin,
 *     ActivityIdleMixin,             # <<<<<<<<<<<<<<
 *     ActivityTimezoneMixin,
 *     ActivityIntervalMixin,
*/
  __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_ActivityIdleMixin); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 127, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "ws_package/controllers/activity_controller.py":128
 *     ActivityBreakMixin,
 *     ActivityIdleMixin,
 *     ActivityTimezoneMixin,             # <<<<<<<<<<<<<<
 *     ActivityIntervalMixin,
 *     ActivityPushMixin,
*/
  __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_ActivityTimezoneMixin); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 128, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);

  /* "ws_package/controllers/activity_controller.py":129
 *     ActivityIdleMixin,
 *     ActivityTimezoneMixin,
 *     ActivityIntervalMixin,             # <<<<<<<<<<<<<<
 *     ActivityPushMixin,
 * ):
*/
  __Pyx_GetModuleGlobalName(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_ActivityIntervalMixin); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 129, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);

  /* "ws_package/controllers/activity_controller.py":130
 *     ActivityTimezoneMixin,
 *     ActivityIntervalMixin,
 *     ActivityPushMixin,             # <<<<<<<<<<<<<<
 * ):
 *     """
*/
  __Pyx_GetModuleGlobalName(__pyx_t_14, __pyx_mstate_global->__pyx_n_u_ActivityPushMixin); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 130, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);

  /* "ws_package/controllers/activity_controller.py":124
 * 
 * 
 * class ActivityController(             # <<<<<<<<<<<<<<
 *     ActivityScreenshotMixin,
 *     ActivityBreakMixin,
*/
  __pyx_t_15 = PyTuple_Pack(6, __pyx_t_4, __pyx_t_8, __pyx_t_2, __pyx_t_9, __pyx_t_13, __pyx_t_14); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 124, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
  __pyx_t_14 = __Pyx_PEP560_update_bases(__pyx_t_15); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 124, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  __pyx_t_13 = __Pyx_CalculateMetaclass(NULL, __pyx_t_14); if (unlikely(!__pyx_t_13)) __PYX_ERR(0, 124, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_13);
  __pyx_t_9 = __Pyx_Py3MetaclassPrepare(__pyx_t_13, __pyx_t_14, __pyx_mstate_global->__pyx_n_u_ActivityController, __pyx_mstate_global->__pyx_n_u_ActivityController, (PyObject *) NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_kp_u_Orchestrates_activity_monitorin); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 124, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_9);
  if (__pyx_t_14 != __pyx_t_15) {
    if (unlikely((PyDict_SetItemString(__pyx_t_9, "__orig_bases__", __pyx_t_15) < 0))) __PYX_ERR(0, 124, __pyx_L1_error)
  }
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":158
 *     """
 * 
 *     def __init__(self, last_count: int) -> None:             # <<<<<<<<<<<<<<
 *         """
 *         Initialize ActivityController with configuration and managers.
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_last_count, __pyx_mstate_global->__pyx_n_u_int) < (0)) __PYX_ERR(0, 158, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_None) < (0)) __PYX_ERR(0, 158, __pyx_L1_error)
  __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_1__init__, 0, __pyx_mstate_global->__pyx_n_u_ActivityController___init, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[80])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 158, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_init, __pyx_t_2) < (0)) __PYX_ERR(0, 158, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":406
 *             logger.warning("Could not register sleep/wake callbacks: %s", e)
 * 
 *     def _handle_wake_session_counter(self) -> None:             # <<<<<<<<<<<<<<
 *         """After system sleep, next timer/monitoring start must use a new counter."""
 *         self._bump_counter_on_next_monitoring_start = True
*/
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_None) < (0)) __PYX_ERR(0, 406, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_3_handle_wake_session_counter, 0, __pyx_mstate_global->__pyx_n_u_ActivityController__handle_wake, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[81])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 406, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_handle_wake_session_counter, __pyx_t_15) < (0)) __PYX_ERR(0, 406, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":414
 *         )
 * 
 *     def _get_electron_comm(self):             # <<<<<<<<<<<<<<
 *         """Return the global Electron communicator instance (lazy-loaded)."""
 *         return _get_electron_comm_lazy()
*/
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_5_get_electron_comm, 0, __pyx_mstate_global->__pyx_n_u_ActivityController__get_electron, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[82])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_get_electron_comm_2, __pyx_t_15) < (0)) __PYX_ERR(0, 414, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":418
 *         return _get_electron_comm_lazy()
 * 
 *     def _send_to_electron_if_connected(self, channel: str, data: dict) -> bool:             # <<<<<<<<<<<<<<
 *         """Send message to Electron if communicator is available and connected. Returns True if sent."""
 *         electron_comm = self._get_electron_comm()
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 418, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_channel, __pyx_mstate_global->__pyx_n_u_str) < (0)) __PYX_ERR(0, 418, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_data, __pyx_mstate_global->__pyx_n_u_dict) < (0)) __PYX_ERR(0, 418, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_bool) < (0)) __PYX_ERR(0, 418, __pyx_L1_error)
  __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_7_send_to_electron_if_connected, 0, __pyx_mstate_global->__pyx_n_u_ActivityController__send_to_elec, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[83])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 418, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_send_to_electron_if_connected, __pyx_t_2) < (0)) __PYX_ERR(0, 418, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":425
 *         return electron_comm.send_to_electron(channel, data)
 * 
 *     def _is_system_sleeping(self) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Check if system is currently sleeping.
*/
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_bool) < (0)) __PYX_ERR(0, 425, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_9_is_system_sleeping, 0, __pyx_mstate_global->__pyx_n_u_ActivityController__is_system_sl, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[84])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 425, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_is_system_sleeping, __pyx_t_15) < (0)) __PYX_ERR(0, 425, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":504
 *             return False
 * 
 *     def boundary_time(self, interval):             # <<<<<<<<<<<<<<
 *         """
 *         Returns how many seconds are left until the next aligned interval boundary.
*/
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_11boundary_time, 0, __pyx_mstate_global->__pyx_n_u_ActivityController_boundary_time, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[85])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 504, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_boundary_time, __pyx_t_15) < (0)) __PYX_ERR(0, 504, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":517
 *         return interval - remainder if remainder != 0 else 0
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def _seconds_until_datetime(target: datetime.datetime) -> float:
 *         """Seconds until ``target``; 0 if target is None or already passed."""
*/
  __pyx_t_2 = NULL;
  __pyx_t_8 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 517, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_target, __pyx_mstate_global->__pyx_kp_u_datetime_datetime) < (0)) __PYX_ERR(0, 517, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_float) < (0)) __PYX_ERR(0, 517, __pyx_L1_error)
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_13_seconds_until_datetime, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_mstate_global->__pyx_n_u_ActivityController__seconds_unti, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[86])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 517, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_8);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __pyx_t_10 = 1;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_4};
    __pyx_t_15 = __Pyx_PyObject_FastCall((PyObject*)__pyx_builtin_staticmethod, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
    if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 517, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
  }
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_seconds_until_datetime, __pyx_t_15) < (0)) __PYX_ERR(0, 517, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":524
 *         return max(0.0, (target - datetime.datetime.now()).total_seconds())
 * 
 *     def increment_session_counter(self, reason: str = "new_session") -> int:             # <<<<<<<<<<<<<<
 *         """Bump last_count for a new timer session and sync dependent managers."""
 *         old_counter = self.last_count
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 524, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_reason, __pyx_mstate_global->__pyx_n_u_str) < (0)) __PYX_ERR(0, 524, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_int) < (0)) __PYX_ERR(0, 524, __pyx_L1_error)
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_15increment_session_counter, 0, __pyx_mstate_global->__pyx_n_u_ActivityController_increment_ses, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[87])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 524, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_mstate_global->__pyx_tuple[32]);
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_increment_session_counter, __pyx_t_4) < (0)) __PYX_ERR(0, 524, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":545
 *         return self.last_count
 * 
 *     def should_skip_counter_bump_dedup(self, within_seconds: int = 12) -> bool:             # <<<<<<<<<<<<<<
 *         """Skip duplicate bump when the same start wave retried IPC within a few seconds."""
 *         if getattr(self, '_bump_counter_on_next_monitoring_start', False):
*/
  __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 545, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_within_seconds, __pyx_mstate_global->__pyx_n_u_int) < (0)) __PYX_ERR(0, 545, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_bool) < (0)) __PYX_ERR(0, 545, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_17should_skip_counter_bump_dedup, 0, __pyx_mstate_global->__pyx_n_u_ActivityController_should_skip_c, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[88])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 545, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_15, __pyx_mstate_global->__pyx_tuple[33]);
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_should_skip_counter_bump_dedup, __pyx_t_15) < (0)) __PYX_ERR(0, 545, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":554
 *         return (datetime.datetime.now() - last_bump).total_seconds() < within_seconds
 * 
 *     async def has_recent_intervals_on_write_counter(self, within_seconds: int = 45) -> bool:             # <<<<<<<<<<<<<<
 *         """True if the current write counter already has intervals ended very recently (start retry)."""
 *         DB_OPERATION_TIMEOUT = 5.0
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 554, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_within_seconds, __pyx_mstate_global->__pyx_n_u_int) < (0)) __PYX_ERR(0, 554, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_bool) < (0)) __PYX_ERR(0, 554, __pyx_L1_error)
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_19has_recent_intervals_on_write_counter, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_has_recent_in, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[0])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 554, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_mstate_global->__pyx_tuple[34]);
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_has_recent_intervals_on_write_co, __pyx_t_4) < (0)) __PYX_ERR(0, 554, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":585
 *                     return False
 * 
 *     def set_project_task_ids(             # <<<<<<<<<<<<<<
 *         self,
 *         project_id: Optional[str],
*/
  __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 585, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "ws_package/controllers/activity_controller.py":590
 *         task_id: Optional[str],
 *         *,
 *         update_segment_start: bool = True,             # <<<<<<<<<<<<<<
 *     ) -> None:
 *         """
*/
  __pyx_t_15 = __Pyx_PyBool_FromLong(((int)1)); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 590, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_update_segment_start, __pyx_t_15) < (0)) __PYX_ERR(0, 585, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":585
 *                     return False
 * 
 *     def set_project_task_ids(             # <<<<<<<<<<<<<<
 *         self,
 *         project_id: Optional[str],
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 585, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_project_id, __pyx_mstate_global->__pyx_kp_u_Optional_str) < (0)) __PYX_ERR(0, 585, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_task_id, __pyx_mstate_global->__pyx_kp_u_Optional_str) < (0)) __PYX_ERR(0, 585, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_update_segment_start, __pyx_mstate_global->__pyx_n_u_bool) < (0)) __PYX_ERR(0, 585, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_None) < (0)) __PYX_ERR(0, 585, __pyx_L1_error)
  __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_22set_project_task_ids, 0, __pyx_mstate_global->__pyx_n_u_ActivityController_set_project_t, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[89])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 585, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2);
  #endif
  __Pyx_CyFunction_SetDefaultsKwDict(__pyx_t_2, __pyx_t_4);
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_set_project_task_ids, __pyx_t_2) < (0)) __PYX_ERR(0, 585, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":608
 *         )
 * 
 *     async def _trim_open_partial_at_project_switch(             # <<<<<<<<<<<<<<
 *         self, switch_time: datetime.datetime
 *     ):
*/
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 608, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_switch_time, __pyx_mstate_global->__pyx_kp_u_datetime_datetime) < (0)) __PYX_ERR(0, 608, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_24_trim_open_partial_at_project_switch, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController__trim_open_pa, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[1])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 608, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_trim_open_partial_at_project_sw, __pyx_t_15) < (0)) __PYX_ERR(0, 608, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":654
 *             return None
 * 
 *     async def _try_finalize_post_switch_slot_interval(             # <<<<<<<<<<<<<<
 *         self, user_entity: UserEntity
 *     ) -> bool:
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 654, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_mstate_global->__pyx_n_u_UserEntity) < (0)) __PYX_ERR(0, 654, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_bool) < (0)) __PYX_ERR(0, 654, __pyx_L1_error)
  __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_27_try_finalize_post_switch_slot_interval, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController__try_finalize, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[2])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 654, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_try_finalize_post_switch_slot_i, __pyx_t_2) < (0)) __PYX_ERR(0, 654, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":721
 *         return True
 * 
 *     async def _create_segment_dummy_entry(self, segment_start: datetime.datetime) -> None:             # <<<<<<<<<<<<<<
 *         """Create is_uploaded=True marker interval at a new session boundary (project switch, etc.)."""
 *         empty_activity_level = {"mouse": "1", "keyboard": "0.0", "average": "0.0"}
*/
  __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 721, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_segment_start, __pyx_mstate_global->__pyx_kp_u_datetime_datetime) < (0)) __PYX_ERR(0, 721, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_None) < (0)) __PYX_ERR(0, 721, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_30_create_segment_dummy_entry, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController__create_segme, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[3])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 721, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_create_segment_dummy_entry, __pyx_t_15) < (0)) __PYX_ERR(0, 721, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":762
 *         )
 * 
 *     def get_os_type_caps(self) -> str:             # <<<<<<<<<<<<<<
 *         platform_name = platform.system()
 *         if platform_name == "Darwin":
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 762, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_str) < (0)) __PYX_ERR(0, 762, __pyx_L1_error)
  __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_33get_os_type_caps, 0, __pyx_mstate_global->__pyx_n_u_ActivityController_get_os_type_c, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[90])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 762, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_get_os_type_caps, __pyx_t_2) < (0)) __PYX_ERR(0, 762, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":768
 *         return platform_name
 * 
 *     def handle_s3_time_error(self, error_message: str):             # <<<<<<<<<<<<<<
 *         """Handle S3 RequestTimeTooSkewed (clock skew vs AWS). Log only  not a timezone mismatch."""
 *         try:
*/
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 768, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_error_message, __pyx_mstate_global->__pyx_n_u_str) < (0)) __PYX_ERR(0, 768, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_35handle_s3_time_error, 0, __pyx_mstate_global->__pyx_n_u_ActivityController_handle_s3_tim, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[91])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 768, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_handle_s3_time_error, __pyx_t_15) < (0)) __PYX_ERR(0, 768, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":779
 *             logger.error("Error handling S3 time error: %s", e)
 * 
 *     async def inrange(self, start_date, end_date):             # <<<<<<<<<<<<<<
 *         if start_date is None or end_date is None:
 *             logger.info("Start date or end date is None")
*/
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_37inrange, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_inrange, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[4])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 779, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_inrange, __pyx_t_15) < (0)) __PYX_ERR(0, 779, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":794
 *         return False
 * 
 *     @staticmethod             # <<<<<<<<<<<<<<
 *     def _normalize_hhmmss(value) -> Optional[str]:
 *         """Normalize API time strings to HH:MM:SS for strptime."""
*/
  __pyx_t_2 = NULL;
  __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 794, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_kp_u_Optional_str) < (0)) __PYX_ERR(0, 794, __pyx_L1_error)
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_40_normalize_hhmmss, __Pyx_CYFUNCTION_STATICMETHOD, __pyx_mstate_global->__pyx_n_u_ActivityController__normalize_hh, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[92])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 794, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_8);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_10 = 1;
  {
    PyObject *__pyx_callargs[2] = {__pyx_t_2, __pyx_t_8};
    __pyx_t_15 = __Pyx_PyObject_FastCall((PyObject*)__pyx_builtin_staticmethod, __pyx_callargs+__pyx_t_10, (2-__pyx_t_10) | (__pyx_t_10*__Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET));
    __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
    if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 794, __pyx_L1_error)
    __Pyx_GOTREF(__pyx_t_15);
  }
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_normalize_hhmmss, __pyx_t_15) < (0)) __PYX_ERR(0, 794, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":810
 *         return None
 * 
 *     def _parse_fixed_mode_window(self, response: dict):             # <<<<<<<<<<<<<<
 *         """
 *         Read fixed-mode (stealth) start/end from API  same for silent and visible builds.
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 810, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_response, __pyx_mstate_global->__pyx_n_u_dict) < (0)) __PYX_ERR(0, 810, __pyx_L1_error)
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_42_parse_fixed_mode_window, 0, __pyx_mstate_global->__pyx_n_u_ActivityController__parse_fixed, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[93])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 810, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_8);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_parse_fixed_mode_window, __pyx_t_8) < (0)) __PYX_ERR(0, 810, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "ws_package/controllers/activity_controller.py":836
 *         return s_limit_start, s_limit_end
 * 
 *     async def update_tracking_duration(self, user_entity:UserEntity):             # <<<<<<<<<<<<<<
 *         """
 *         Update tracking duration from stealth mode API.
*/
  __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 836, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_mstate_global->__pyx_n_u_UserEntity) < (0)) __PYX_ERR(0, 836, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_44update_tracking_duration, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_update_tracki, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[5])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 836, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_8);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_update_tracking_duration, __pyx_t_15) < (0)) __PYX_ERR(0, 836, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":941
 *                 logger.info("No tracking scenerio found")
 * 
 *     async def midnight(self, user_entity: UserEntity, last_count):             # <<<<<<<<<<<<<<
 *         # Use centralized read lock for database read operations
 *         # Database operation timeout constant
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 941, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_mstate_global->__pyx_n_u_UserEntity) < (0)) __PYX_ERR(0, 941, __pyx_L1_error)
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_47midnight, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_midnight, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[6])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 941, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_8);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_midnight, __pyx_t_8) < (0)) __PYX_ERR(0, 941, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "ws_package/controllers/activity_controller.py":977
 *         logger.debug("ORG check at every interval")
 * 
 *     def decrypt(self, encrypted_key) -> str:             # <<<<<<<<<<<<<<
 *         """Decrypt encrypted key with improved error handling."""
 *         if not encrypted_key or not isinstance(encrypted_key, str):
*/
  __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 977, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_str) < (0)) __PYX_ERR(0, 977, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_50decrypt, 0, __pyx_mstate_global->__pyx_n_u_ActivityController_decrypt, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[94])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 977, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_8);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_decrypt, __pyx_t_15) < (0)) __PYX_ERR(0, 977, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":1005
 *             raise ValidationError(f"Unexpected error decrypting key: {e}", context={"encrypted_key": encrypted_key[:50]})
 * 
 *     def _handle_wake_s3_update(self):             # <<<<<<<<<<<<<<
 *         """
 *         Handle system wake event - check if new day and update S3 bucket config.
*/
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_52_handle_wake_s3_update, 0, __pyx_mstate_global->__pyx_n_u_ActivityController__handle_wake_2, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[95])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1005, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_handle_wake_s3_update, __pyx_t_15) < (0)) __PYX_ERR(0, 1005, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":1035
 *             logger.error("[WAKE] Error handling S3 bucket update on wake: %s", e, exc_info=True)
 * 
 *     async def _check_and_update_s3_on_startup(self, user_entity):             # <<<<<<<<<<<<<<
 *         """
 *         Check if it's a new day on app startup and update S3 bucket config if needed.
*/
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_54_check_and_update_s3_on_startup, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController__check_and_up, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[7])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1035, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_check_and_update_s3_on_startup, __pyx_t_15) < (0)) __PYX_ERR(0, 1035, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":1080
 *             logger.error("[STARTUP] Error checking/updating S3 bucket on startup: %s", e, exc_info=True)
 * 
 *     async def _check_and_update_s3_on_wake(self, user_entity):             # <<<<<<<<<<<<<<
 *         """
 *         Check if it's a new day and update S3 bucket config if needed.
*/
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_57_check_and_update_s3_on_wake, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController__check_and_up_2, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[8])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1080, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_check_and_update_s3_on_wake, __pyx_t_15) < (0)) __PYX_ERR(0, 1080, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":1125
 *             logger.error("[WAKE] Error checking/updating S3 bucket on wake: %s", e, exc_info=True)
 * 
 *     async def _s3_credentials_need_refresh(self, user_entity: UserEntity) -> bool:             # <<<<<<<<<<<<<<
 *         """True when stored STS credentials are missing or past expire_time."""
 *         if user_entity is None:
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1125, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_mstate_global->__pyx_n_u_UserEntity) < (0)) __PYX_ERR(0, 1125, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_bool) < (0)) __PYX_ERR(0, 1125, __pyx_L1_error)
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_60_s3_credentials_need_refresh, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController__s3_credentia, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[9])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1125, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_8);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_s3_credentials_need_refresh, __pyx_t_8) < (0)) __PYX_ERR(0, 1125, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "ws_package/controllers/activity_controller.py":1134
 *         return existing is None or s3_credentials_expired(existing)
 * 
 *     async def ensure_s3_credentials_fresh(self, user_entity: UserEntity) -> S3BucketEntity | None:             # <<<<<<<<<<<<<<
 *         """Refresh S3 credentials from sts/keys when expire_time has passed."""
 *         return await self.server_controller.ensure_fresh_s3_bucket(user_entity)
*/
  __pyx_t_8 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_mstate_global->__pyx_n_u_UserEntity) < (0)) __PYX_ERR(0, 1134, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_kp_u_S3BucketEntity_None) < (0)) __PYX_ERR(0, 1134, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_63ensure_s3_credentials_fresh, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_ensure_s3_cre, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[10])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1134, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_8);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_ensure_s3_credentials_fresh, __pyx_t_15) < (0)) __PYX_ERR(0, 1134, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":1138
 *         return await self.server_controller.ensure_fresh_s3_bucket(user_entity)
 * 
 *     async def get_bucket_in_every_interval(self, user_entity: UserEntity) -> S3BucketEntity | None:             # <<<<<<<<<<<<<<
 *         """Refresh S3 bucket credentials from the remote API when needed.
 * 
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_mstate_global->__pyx_n_u_UserEntity) < (0)) __PYX_ERR(0, 1138, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_kp_u_S3BucketEntity_None) < (0)) __PYX_ERR(0, 1138, __pyx_L1_error)
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_66get_bucket_in_every_interval, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_get_bucket_in, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[11])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1138, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_8);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_get_bucket_in_every_interval, __pyx_t_8) < (0)) __PYX_ERR(0, 1138, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "ws_package/controllers/activity_controller.py":1149
 *         return await self.ensure_s3_credentials_fresh(user_entity)
 * 
 *     async def update_interval(self, user_entity: UserEntity):             # <<<<<<<<<<<<<<
 *         """Refresh org settings (interval, screenshot frequency, limits) from the remote API.
 * 
*/
  __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_mstate_global->__pyx_n_u_UserEntity) < (0)) __PYX_ERR(0, 1149, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_69update_interval, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_update_interv, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[12])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1149, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_8);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_update_interval, __pyx_t_15) < (0)) __PYX_ERR(0, 1149, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":1268
 *             await self._check_and_handle_limits(user_entity, org_entity)
 * 
 *     def _apply_org_timezone_preference(self, preference, user_entity: UserEntity = None) -> None:             # <<<<<<<<<<<<<<
 *         """Apply timezone_preference from org settings and toggle time monitor if it flips."""
 *         from ws_package.entities.org_entity import normalize_timezone_preference
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1268, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_mstate_global->__pyx_n_u_UserEntity) < (0)) __PYX_ERR(0, 1268, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_None) < (0)) __PYX_ERR(0, 1268, __pyx_L1_error)
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_72_apply_org_timezone_preference, 0, __pyx_mstate_global->__pyx_n_u_ActivityController__apply_org_ti, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[96])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1268, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_8);
  #endif
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_8, __pyx_mstate_global->__pyx_tuple[21]);
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_apply_org_timezone_preference, __pyx_t_8) < (0)) __PYX_ERR(0, 1268, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "ws_package/controllers/activity_controller.py":1301
 *             logger.warning("[TimezonePref] Failed to toggle time monitor: %s", e)
 * 
 *     async def _load_org_settings_from_db(self):             # <<<<<<<<<<<<<<
 *         """Load organization settings from local database as fallback."""
 *         try:
*/
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_74_load_org_settings_from_db, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController__load_org_set, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[13])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1301, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_8);
  #endif
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_load_org_settings_from_db, __pyx_t_8) < (0)) __PYX_ERR(0, 1301, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "ws_package/controllers/activity_controller.py":1342
 *             return False
 * 
 *     async def _check_and_handle_limits(self, user_entity: UserEntity, org_entity: OrgEntity):             # <<<<<<<<<<<<<<
 *         """
 *         Check if daily or weekly limits are exceeded and handle accordingly.
*/
  __pyx_t_8 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_mstate_global->__pyx_n_u_UserEntity) < (0)) __PYX_ERR(0, 1342, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_org_entity, __pyx_mstate_global->__pyx_n_u_OrgEntity) < (0)) __PYX_ERR(0, 1342, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_77_check_and_handle_limits, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController__check_and_ha, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[14])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1342, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_8);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_check_and_handle_limits, __pyx_t_15) < (0)) __PYX_ERR(0, 1342, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":1446
 *             logger.error("Error checking and handling limits (fail-safe): %s", e)
 * 
 *     def _send_subscription_expired_popup(self, _response=None):             # <<<<<<<<<<<<<<
 *         """Send subscription-expired popup to Electron (same message for token expired or plan deactivated). All OSes."""
 *         try:
*/
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_80_send_subscription_expired_popup, 0, __pyx_mstate_global->__pyx_n_u_ActivityController__send_subscri, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[97])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1446, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_15, __pyx_mstate_global->__pyx_tuple[21]);
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_send_subscription_expired_popup, __pyx_t_15) < (0)) __PYX_ERR(0, 1446, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":1466
 *             logger.error("Failed to send subscription expiration error to Electron: %s", e)
 * 
 *     async def start_screenshot_activity(self, user_entity: UserEntity, stop_event=None):             # <<<<<<<<<<<<<<
 *         await precise_sleep(10)
 *         logger.info("Starting screenshot activity with interval: %s and ss frequency: %s blur intensity: %s status: %s limit start: %s limit end: %s no of days: %s", self.interval, self.screenshot_interval, self.blur_intensity, self.status, self.limit_start, self.limit_end, self.no_of_days)
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1466, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_mstate_global->__pyx_n_u_UserEntity) < (0)) __PYX_ERR(0, 1466, __pyx_L1_error)
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_82start_screenshot_activity, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_start_screens, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[16])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1466, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_8);
  #endif
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_8, __pyx_mstate_global->__pyx_tuple[21]);
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_start_screenshot_activity, __pyx_t_8) < (0)) __PYX_ERR(0, 1466, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "ws_package/controllers/activity_controller.py":1481
 *         )
 * 
 *     async def start_device_activity(self, user_entity: UserEntity, stop_event: Optional[asyncio.Event] = None) -> None:             # <<<<<<<<<<<<<<
 *         self.user_entity = user_entity
 *         """
*/
  __pyx_t_8 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1481, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_mstate_global->__pyx_n_u_UserEntity) < (0)) __PYX_ERR(0, 1481, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_stop_event, __pyx_mstate_global->__pyx_kp_u_Optional_asyncio_Event) < (0)) __PYX_ERR(0, 1481, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_None) < (0)) __PYX_ERR(0, 1481, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_85start_device_activity, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_start_device, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[17])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1481, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_15, __pyx_mstate_global->__pyx_tuple[21]);
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_8);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_start_device_activity, __pyx_t_15) < (0)) __PYX_ERR(0, 1481, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":1554
 *     # This method is no longer needed - reminder logic is now handled entirely in the Electron renderer
 * 
 *     async def getStartingSlot(self) -> Tuple[datetime.datetime, datetime.datetime]:             # <<<<<<<<<<<<<<
 *         """
 *         Calculate the starting time slot for activity monitoring.
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1554, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_kp_u_Tuple_datetime_datetime_datetime) < (0)) __PYX_ERR(0, 1554, __pyx_L1_error)
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_88getStartingSlot, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_getStartingSl, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[18])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1554, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_8);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_getStartingSlot, __pyx_t_8) < (0)) __PYX_ERR(0, 1554, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "ws_package/controllers/activity_controller.py":1592
 *         return start_time,end_time
 * 
 *     async def getCurrentSlot(self):             # <<<<<<<<<<<<<<
 *         start_date = datetime.datetime.now()
 *         self.tzmain = start_date
*/
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_91getCurrentSlot, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_getCurrentSlo, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[19])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1592, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_8);
  #endif
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_getCurrentSlot, __pyx_t_8) < (0)) __PYX_ERR(0, 1592, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "ws_package/controllers/activity_controller.py":1604
 *         return end_date
 * 
 *     def _align_to_interval_boundary(self, time: datetime.datetime) -> datetime.datetime:             # <<<<<<<<<<<<<<
 *         """
 *         Align a given time to the nearest interval boundary (round down).
*/
  __pyx_t_8 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1604, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_time, __pyx_mstate_global->__pyx_kp_u_datetime_datetime) < (0)) __PYX_ERR(0, 1604, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_kp_u_datetime_datetime) < (0)) __PYX_ERR(0, 1604, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_94_align_to_interval_boundary, 0, __pyx_mstate_global->__pyx_n_u_ActivityController__align_to_int, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[98])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1604, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_8);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_align_to_interval_boundary, __pyx_t_15) < (0)) __PYX_ERR(0, 1604, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":1625
 *         return aligned_time
 * 
 *     def is_browser(self, app_name):             # <<<<<<<<<<<<<<
 *         # Normalize and clean string
 *         normalized_name = unicodedata.normalize("NFKD", app_name)
*/
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_96is_browser, 0, __pyx_mstate_global->__pyx_n_u_ActivityController_is_browser, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[99])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1625, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_is_browser, __pyx_t_15) < (0)) __PYX_ERR(0, 1625, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":1638
 *         return any(browser.lower() in cleaned_name_lower for browser in browsers)
 * 
 *     async def __start_minute_activity_timer(self, stop_event):             # <<<<<<<<<<<<<<
 *         """Start minute-by-minute activity rolling average timer"""
 *         logger.info("Starting minute-by-minute activity rolling average timer")
*/
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_98__start_minute_activity_timer, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController___start_minut, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[22])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1638, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_ActivityController__start_minut, __pyx_t_15) < (0)) __PYX_ERR(0, 1638, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":1686
 *         logger.info("Minute activity timer stopped")
 * 
 *     async def __start_device_activity(self, user_entity:UserEntity, stop_event):             # <<<<<<<<<<<<<<
 * 
 *         # Update start_date to actual timer start time (when user clicks Start)
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 1686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_mstate_global->__pyx_n_u_UserEntity) < (0)) __PYX_ERR(0, 1686, __pyx_L1_error)
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_101__start_device_activity, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController___start_devic, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[23])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 1686, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_8);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_ActivityController__start_devic, __pyx_t_8) < (0)) __PYX_ERR(0, 1686, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "ws_package/controllers/activity_controller.py":2969
 *                 continue
 * 
 *     async def empty_interval(self, user_entity: UserEntity):             # <<<<<<<<<<<<<<
 *         logger.info("Running push empty intervals")
 *         current = self.last_count + 1
*/
  __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 2969, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_mstate_global->__pyx_n_u_UserEntity) < (0)) __PYX_ERR(0, 2969, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_104empty_interval, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_empty_interva_2, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[37])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 2969, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_8);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_empty_interval, __pyx_t_15) < (0)) __PYX_ERR(0, 2969, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":3086
 * 
 * 
 *     async def _push_activity_log(self, user_entity: UserEntity, stop_event=None):             # <<<<<<<<<<<<<<
 *         while not stop_event.is_set():
 *             try:
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3086, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_mstate_global->__pyx_n_u_UserEntity) < (0)) __PYX_ERR(0, 3086, __pyx_L1_error)
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_107_push_activity_log, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController__push_activit, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[38])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3086, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_8);
  #endif
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_8, __pyx_mstate_global->__pyx_tuple[21]);
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_push_activity_log, __pyx_t_8) < (0)) __PYX_ERR(0, 3086, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "ws_package/controllers/activity_controller.py":3407
 *                 continue
 * 
 *     def is_link(self, url):             # <<<<<<<<<<<<<<
 *         """Check if the given string is a valid HTTP/HTTPS URL."""
 *         return self.screenshot_manager.is_link(url)
*/
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_110is_link, 0, __pyx_mstate_global->__pyx_n_u_ActivityController_is_link, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[100])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3407, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_8);
  #endif
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_is_link, __pyx_t_8) < (0)) __PYX_ERR(0, 3407, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "ws_package/controllers/activity_controller.py":3411
 *         return self.screenshot_manager.is_link(url)
 * 
 *     def forward_ss(self, ss):             # <<<<<<<<<<<<<<
 *         return self.screenshot_manager.forward_ss(ss)
 * 
*/
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_112forward_ss, 0, __pyx_mstate_global->__pyx_n_u_ActivityController_forward_ss, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[101])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3411, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_8);
  #endif
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_forward_ss, __pyx_t_8) < (0)) __PYX_ERR(0, 3411, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "ws_package/controllers/activity_controller.py":3414
 *         return self.screenshot_manager.forward_ss(ss)
 * 
 *     async def ss(self, interval_start_time, interval_end_time, user_entity: UserEntity): # This is a validator chck if screenshot is link or not everytime and renaming before uploading             # <<<<<<<<<<<<<<
 *         ss_array = await self.activity_service.get_screenshots(interval_start_time, interval_end_time)
 *         ans_array = []
*/
  __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_mstate_global->__pyx_n_u_UserEntity) < (0)) __PYX_ERR(0, 3414, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_114ss, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_ss, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[39])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3414, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_8);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_ss, __pyx_t_15) < (0)) __PYX_ERR(0, 3414, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":3533
 *         return ans_array
 * 
 *     def group_intervals_by_day(self, intervals):             # <<<<<<<<<<<<<<
 *         """Group intervals by their start date."""
 *         grouped_intervals = defaultdict(list)
*/
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_117group_intervals_by_day, 0, __pyx_mstate_global->__pyx_n_u_ActivityController_group_interva_2, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[102])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3533, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_group_intervals_by_day, __pyx_t_15) < (0)) __PYX_ERR(0, 3533, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":3544
 *         return grouped_intervals
 * 
 *     def _calculate_gap_seconds(self, prev_interval, current_interval) -> float:             # <<<<<<<<<<<<<<
 *         """Return the time gap (in seconds) between two consecutive intervals."""
 *         if not prev_interval or not current_interval:
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3544, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_float) < (0)) __PYX_ERR(0, 3544, __pyx_L1_error)
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_119_calculate_gap_seconds, 0, __pyx_mstate_global->__pyx_n_u_ActivityController__calculate_ga, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[103])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3544, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_8);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_calculate_gap_seconds, __pyx_t_8) < (0)) __PYX_ERR(0, 3544, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "ws_package/controllers/activity_controller.py":3554
 *             return 0.0
 * 
 *     def _determine_sleep_reason(self, gap_seconds: float) -> str:             # <<<<<<<<<<<<<<
 *         """
 *         Provide a descriptive reason for large gaps.
*/
  __pyx_t_8 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3554, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_gap_seconds, __pyx_mstate_global->__pyx_n_u_float) < (0)) __PYX_ERR(0, 3554, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_str) < (0)) __PYX_ERR(0, 3554, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_121_determine_sleep_reason, 0, __pyx_mstate_global->__pyx_n_u_ActivityController__determine_sl, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[104])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3554, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_8);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_determine_sleep_reason, __pyx_t_15) < (0)) __PYX_ERR(0, 3554, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":3569
 *         return "linux_sleep_or_shutdown" if gap_seconds >= idle_threshold else "linux_idle_gap"
 * 
 *     def _log_session_split_reason(self, reason: str, prev_interval, current_interval, gap_seconds: float) -> None:             # <<<<<<<<<<<<<<
 *         """Log session split metadata for diagnostics."""
 *         gap_minutes = gap_seconds / 60 if gap_seconds else 0.0
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3569, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_reason, __pyx_mstate_global->__pyx_n_u_str) < (0)) __PYX_ERR(0, 3569, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_gap_seconds, __pyx_mstate_global->__pyx_n_u_float) < (0)) __PYX_ERR(0, 3569, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_None) < (0)) __PYX_ERR(0, 3569, __pyx_L1_error)
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_123_log_session_split_reason, 0, __pyx_mstate_global->__pyx_n_u_ActivityController__log_session, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[105])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3569, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_8);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_log_session_split_reason, __pyx_t_8) < (0)) __PYX_ERR(0, 3569, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "ws_package/controllers/activity_controller.py":3583
 *         )
 * 
 *     def _should_start_new_session(self, prev_interval, current_interval) -> bool:             # <<<<<<<<<<<<<<
 *         """Determine whether a new session should begin based on counters and gaps."""
 *         if not prev_interval:
*/
  __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3583, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_bool) < (0)) __PYX_ERR(0, 3583, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_125_should_start_new_session, 0, __pyx_mstate_global->__pyx_n_u_ActivityController__should_start, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[106])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3583, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_8);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_should_start_new_session, __pyx_t_15) < (0)) __PYX_ERR(0, 3583, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":3606
 *         return False
 * 
 *     async def _verify_user_activity_during_period(self, start_time: datetime.datetime, end_time: datetime.datetime) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Verify if there was actual user activity (keyboard/mouse) during a time period.
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3606, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_start_time, __pyx_mstate_global->__pyx_kp_u_datetime_datetime) < (0)) __PYX_ERR(0, 3606, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_end_time, __pyx_mstate_global->__pyx_kp_u_datetime_datetime) < (0)) __PYX_ERR(0, 3606, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_bool) < (0)) __PYX_ERR(0, 3606, __pyx_L1_error)
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_127_verify_user_activity_during_period, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController__verify_user, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[40])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3606, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_8);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_verify_user_activity_during_per, __pyx_t_8) < (0)) __PYX_ERR(0, 3606, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "ws_package/controllers/activity_controller.py":3691
 *             return False
 * 
 *     def is_idle_interval(self, interval) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Our idle definition: keyboard AND mouse activity are zero for the whole interval.
*/
  __pyx_t_8 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3691, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_bool) < (0)) __PYX_ERR(0, 3691, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_130is_idle_interval, 0, __pyx_mstate_global->__pyx_n_u_ActivityController_is_idle_inter, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[107])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3691, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_8);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_is_idle_interval, __pyx_t_15) < (0)) __PYX_ERR(0, 3691, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":3711
 *             return False
 * 
 *     def group_intervals_by_session(self, intervals):             # <<<<<<<<<<<<<<
 *         """
 *         Group intervals into logical sessions.
*/
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_132group_intervals_by_session, 0, __pyx_mstate_global->__pyx_n_u_ActivityController_group_interva_3, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[108])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3711, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_group_intervals_by_session, __pyx_t_15) < (0)) __PYX_ERR(0, 3711, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":3743
 *         return sessions
 * 
 *     def get_day_start_time(self, target_date, intervals_for_day):             # <<<<<<<<<<<<<<
 *         """
 *         Returns the appropriate start time for a given day's intervals.
*/
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_134get_day_start_time, 0, __pyx_mstate_global->__pyx_n_u_ActivityController_get_day_start, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[109])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3743, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_get_day_start_time, __pyx_t_15) < (0)) __PYX_ERR(0, 3743, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":3766
 *             return datetime.datetime.combine(target_date, datetime.time.min)
 * 
 *     def _get_activity_level_from_interval(self, interval) -> dict:             # <<<<<<<<<<<<<<
 *         return ActivityIntervalMixin._get_activity_level_from_interval(self, interval)
 * 
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3766, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_dict) < (0)) __PYX_ERR(0, 3766, __pyx_L1_error)
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_136_get_activity_level_from_interval, 0, __pyx_mstate_global->__pyx_n_u_ActivityController__get_activity, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[110])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3766, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_8);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_get_activity_level_from_interva, __pyx_t_8) < (0)) __PYX_ERR(0, 3766, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "ws_package/controllers/activity_controller.py":3769
 *         return ActivityIntervalMixin._get_activity_level_from_interval(self, interval)
 * 
 *     async def get_activity_level_from_db(self, start_time, end_time):             # <<<<<<<<<<<<<<
 *         return await ActivityIntervalMixin.get_activity_level_from_db(self, start_time, end_time)
 * 
*/
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_138get_activity_level_from_db, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_get_activity, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[42])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3769, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_8);
  #endif
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_get_activity_level_from_db, __pyx_t_8) < (0)) __PYX_ERR(0, 3769, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "ws_package/controllers/activity_controller.py":3772
 *         return await ActivityIntervalMixin.get_activity_level_from_db(self, start_time, end_time)
 * 
 *     async def _is_app_monitor_data_stale(self, app_monitor_time: datetime.datetime, wake_time: Optional[datetime.datetime]) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Check if app monitor data is stale (from before system wake).
*/
  __pyx_t_8 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3772, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_app_monitor_time, __pyx_mstate_global->__pyx_kp_u_datetime_datetime) < (0)) __PYX_ERR(0, 3772, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_wake_time, __pyx_mstate_global->__pyx_kp_u_Optional_datetime_datetime) < (0)) __PYX_ERR(0, 3772, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_bool) < (0)) __PYX_ERR(0, 3772, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_141_is_app_monitor_data_stale, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController__is_app_monit, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[43])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3772, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_8);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_is_app_monitor_data_stale, __pyx_t_15) < (0)) __PYX_ERR(0, 3772, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":3790
 *         return time_diff < 30  # Within 30 seconds of wake = likely stale
 * 
 *     async def _has_any_activity_in_interval(self, start_time: datetime.datetime, end_time: datetime.datetime, counter: int) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Check if there was ANY activity (keyboard, mouse, or app monitor) during an interval.
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3790, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_start_time, __pyx_mstate_global->__pyx_kp_u_datetime_datetime) < (0)) __PYX_ERR(0, 3790, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_end_time, __pyx_mstate_global->__pyx_kp_u_datetime_datetime) < (0)) __PYX_ERR(0, 3790, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_counter, __pyx_mstate_global->__pyx_n_u_int) < (0)) __PYX_ERR(0, 3790, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_bool) < (0)) __PYX_ERR(0, 3790, __pyx_L1_error)
  __pyx_t_8 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_144_has_any_activity_in_interval, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController__has_any_acti, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[44])); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3790, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_8);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_8, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_has_any_activity_in_interval, __pyx_t_8) < (0)) __PYX_ERR(0, 3790, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;

  /* "ws_package/controllers/activity_controller.py":3836
 *             return False  # Fail-safe: if we can't check, assume no activity
 * 
 *     async def process_intervals_bulk(             # <<<<<<<<<<<<<<
 *         self,
 *         intervals,
*/
  __pyx_t_8 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 3836, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);

  /* "ws_package/controllers/activity_controller.py":3843
 *         last_interval=None,
 *         *,
 *         payload_project_id: Optional[str] = None,             # <<<<<<<<<<<<<<
 *         payload_task_id: Optional[str] = None,
 *         force_stop_time: Optional[datetime.datetime] = None,
*/
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_payload_project_id, Py_None) < (0)) __PYX_ERR(0, 3836, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":3844
 *         *,
 *         payload_project_id: Optional[str] = None,
 *         payload_task_id: Optional[str] = None,             # <<<<<<<<<<<<<<
 *         force_stop_time: Optional[datetime.datetime] = None,
 *     ):
*/
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_payload_task_id, Py_None) < (0)) __PYX_ERR(0, 3836, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":3845
 *         payload_project_id: Optional[str] = None,
 *         payload_task_id: Optional[str] = None,
 *         force_stop_time: Optional[datetime.datetime] = None,             # <<<<<<<<<<<<<<
 *     ):
 *         if intervals is None or len(intervals) == 0:
*/
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_force_stop_time, Py_None) < (0)) __PYX_ERR(0, 3836, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":3836
 *             return False  # Fail-safe: if we can't check, assume no activity
 * 
 *     async def process_intervals_bulk(             # <<<<<<<<<<<<<<
 *         self,
 *         intervals,
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 3836, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_mstate_global->__pyx_n_u_UserEntity) < (0)) __PYX_ERR(0, 3836, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_payload_project_id, __pyx_mstate_global->__pyx_kp_u_Optional_str) < (0)) __PYX_ERR(0, 3836, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_payload_task_id, __pyx_mstate_global->__pyx_kp_u_Optional_str) < (0)) __PYX_ERR(0, 3836, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_force_stop_time, __pyx_mstate_global->__pyx_kp_u_Optional_datetime_datetime) < (0)) __PYX_ERR(0, 3836, __pyx_L1_error)
  __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_147process_intervals_bulk, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_process_inter_2, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[46])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 3836, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2);
  #endif
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_2, __pyx_mstate_global->__pyx_tuple[21]);
  __Pyx_CyFunction_SetDefaultsKwDict(__pyx_t_2, __pyx_t_8);
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_process_intervals_bulk, __pyx_t_2) < (0)) __PYX_ERR(0, 3836, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":4132
 *             yield payload, day_intervals
 * 
 *     async def delete_old_data_and_screenshots(self):             # <<<<<<<<<<<<<<
 *         """
 *         Delete old data and screenshots older than 7 days.
*/
  __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_150delete_old_data_and_screenshots, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_delete_old_da, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[49])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4132, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2);
  #endif
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_delete_old_data_and_screenshots, __pyx_t_2) < (0)) __PYX_ERR(0, 4132, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":4291
 *             logger.error("Error in deleting old data and screenshots: %s", e, exc_info=True)
 * 
 *     async def start_status_activity(self, user_entity: UserEntity, stop_event):             # <<<<<<<<<<<<<<
 *         if user_entity is None:
 *             logger.error("start_status_activity called with None user_entity, cannot proceed")
*/
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_mstate_global->__pyx_n_u_UserEntity) < (0)) __PYX_ERR(0, 4291, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_153start_status_activity, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_start_status, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[50])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4291, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_start_status_activity, __pyx_t_15) < (0)) __PYX_ERR(0, 4291, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":4396
 *                 continue
 * 
 *     def set_local_timezone(self, user_entity):             # <<<<<<<<<<<<<<
 *         """Set local_timezone from user_entity, fallback to system timezone if not available."""
 *         self.timezone_manager.set_local_timezone(user_entity)
*/
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_156set_local_timezone, 0, __pyx_mstate_global->__pyx_n_u_ActivityController_set_local_tim, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[111])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4396, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_set_local_timezone, __pyx_t_15) < (0)) __PYX_ERR(0, 4396, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":4400
 *         self.timezone_manager.set_local_timezone(user_entity)
 * 
 *     async def db_to_server(self, user_entity: UserEntity):             # <<<<<<<<<<<<<<
 *         logger.info("Running db to server")
 *         if getattr(sys, 'frozen', False) and platform.system() == "Linux":
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4400, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_mstate_global->__pyx_n_u_UserEntity) < (0)) __PYX_ERR(0, 4400, __pyx_L1_error)
  __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_158db_to_server, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_db_to_server, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[51])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4400, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_db_to_server, __pyx_t_2) < (0)) __PYX_ERR(0, 4400, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":4512
 *             # Continue processing - don't fail the entire operation
 * 
 *     async def getting_unsent_interval(self, user_entity: UserEntity):             # <<<<<<<<<<<<<<
 *         """Return unsent (``is_uploaded=False``) non-break activity intervals eligible for upload.
 * 
*/
  __pyx_t_2 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4512, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_mstate_global->__pyx_n_u_UserEntity) < (0)) __PYX_ERR(0, 4512, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_161getting_unsent_interval, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_getting_unsen, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[52])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4512, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_getting_unsent_interval, __pyx_t_15) < (0)) __PYX_ERR(0, 4512, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":4608
 *                     return []
 * 
 *     async def sending_unsent_intervals(self, start, prev_day_unsent, user_entity: UserEntity):             # <<<<<<<<<<<<<<
 *         logger.info("Sending previous day unsent intervals")
 *         try:
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4608, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_mstate_global->__pyx_n_u_UserEntity) < (0)) __PYX_ERR(0, 4608, __pyx_L1_error)
  __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_164sending_unsent_intervals, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_sending_unsen, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[53])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4608, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_sending_unsent_intervals, __pyx_t_2) < (0)) __PYX_ERR(0, 4608, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":4745
 *             logger.error("Traceback: %s", traceback.format_exc())
 * 
 *     def log_system_resources(self):             # <<<<<<<<<<<<<<
 *         """Log CPU and memory usage at every interval"""
 *         try:
*/
  __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_167log_system_resources, 0, __pyx_mstate_global->__pyx_n_u_ActivityController_log_system_re, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[112])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4745, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2);
  #endif
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_log_system_resources, __pyx_t_2) < (0)) __PYX_ERR(0, 4745, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":4786
 *             return None
 * 
 *     def check_memory_usage(self):             # <<<<<<<<<<<<<<
 *         """Check if memory usage is approaching limits"""
 *         try:
*/
  __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_169check_memory_usage, 0, __pyx_mstate_global->__pyx_n_u_ActivityController_check_memory, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[113])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4786, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2);
  #endif
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_check_memory_usage, __pyx_t_2) < (0)) __PYX_ERR(0, 4786, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":4801
 *             return False
 * 
 *     def _finalize_work_stop_time(             # <<<<<<<<<<<<<<
 *         self,
 *         last_interval=None,
*/
  __pyx_t_2 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4801, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_fallback_end, __pyx_mstate_global->__pyx_kp_u_Optional_datetime_datetime) < (0)) __PYX_ERR(0, 4801, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_kp_u_datetime_datetime) < (0)) __PYX_ERR(0, 4801, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_171_finalize_work_stop_time, 0, __pyx_mstate_global->__pyx_n_u_ActivityController__finalize_wor, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[114])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4801, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_15, __pyx_mstate_global->__pyx_tuple[7]);
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_2);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_finalize_work_stop_time, __pyx_t_15) < (0)) __PYX_ERR(0, 4801, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":4826
 *         return self._last_work_stop_time
 * 
 *     def _break_start_after_work_stop(self) -> datetime.datetime:             # <<<<<<<<<<<<<<
 *         """Break session must start strictly after work stop (work_stop + 1 second)."""
 *         work_stop = self._last_work_stop_time or datetime.datetime.now()
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4826, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_kp_u_datetime_datetime) < (0)) __PYX_ERR(0, 4826, __pyx_L1_error)
  __pyx_t_2 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_173_break_start_after_work_stop, 0, __pyx_mstate_global->__pyx_n_u_ActivityController__break_start, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[115])); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4826, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_2);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_2, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_break_start_after_work_stop, __pyx_t_2) < (0)) __PYX_ERR(0, 4826, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;

  /* "ws_package/controllers/activity_controller.py":4834
 *         self,
 *         user_entity: UserEntity,
 *         keep_idle_time: bool = True,             # <<<<<<<<<<<<<<
 *         *,
 *         close_time: Optional[datetime.datetime] = None,
*/
  __pyx_t_2 = __Pyx_PyBool_FromLong(((int)1)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4834, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "ws_package/controllers/activity_controller.py":4831
 *         return work_stop.replace(microsecond=0) + datetime.timedelta(seconds=1)
 * 
 *     async def last_api_call(             # <<<<<<<<<<<<<<
 *         self,
 *         user_entity: UserEntity,
*/
  __pyx_t_15 = PyTuple_Pack(1, __pyx_t_2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4831, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __pyx_t_2 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4831, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);

  /* "ws_package/controllers/activity_controller.py":4836
 *         keep_idle_time: bool = True,
 *         *,
 *         close_time: Optional[datetime.datetime] = None,             # <<<<<<<<<<<<<<
 *         payload_project_id: Optional[str] = None,
 *         payload_task_id: Optional[str] = None,
*/
  if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_close_time, Py_None) < (0)) __PYX_ERR(0, 4831, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":4837
 *         *,
 *         close_time: Optional[datetime.datetime] = None,
 *         payload_project_id: Optional[str] = None,             # <<<<<<<<<<<<<<
 *         payload_task_id: Optional[str] = None,
 *     ):
*/
  if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_payload_project_id, Py_None) < (0)) __PYX_ERR(0, 4831, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":4838
 *         close_time: Optional[datetime.datetime] = None,
 *         payload_project_id: Optional[str] = None,
 *         payload_task_id: Optional[str] = None,             # <<<<<<<<<<<<<<
 *     ):
 *         """Save last activity interval to DB (serialized with project switch)."""
*/
  if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_payload_task_id, Py_None) < (0)) __PYX_ERR(0, 4831, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":4831
 *         return work_stop.replace(microsecond=0) + datetime.timedelta(seconds=1)
 * 
 *     async def last_api_call(             # <<<<<<<<<<<<<<
 *         self,
 *         user_entity: UserEntity,
*/
  __pyx_t_8 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4831, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_mstate_global->__pyx_n_u_UserEntity) < (0)) __PYX_ERR(0, 4831, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_keep_idle_time, __pyx_mstate_global->__pyx_n_u_bool) < (0)) __PYX_ERR(0, 4831, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_close_time, __pyx_mstate_global->__pyx_kp_u_Optional_datetime_datetime) < (0)) __PYX_ERR(0, 4831, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_payload_project_id, __pyx_mstate_global->__pyx_kp_u_Optional_str) < (0)) __PYX_ERR(0, 4831, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_8, __pyx_mstate_global->__pyx_n_u_payload_task_id, __pyx_mstate_global->__pyx_kp_u_Optional_str) < (0)) __PYX_ERR(0, 4831, __pyx_L1_error)
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_175last_api_call, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_last_api_call, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[54])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4831, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_t_15);
  __Pyx_CyFunction_SetDefaultsKwDict(__pyx_t_4, __pyx_t_2);
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_8);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_last_api_call, __pyx_t_4) < (0)) __PYX_ERR(0, 4831, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":4853
 *         self,
 *         user_entity: UserEntity,
 *         keep_idle_time: bool = True,             # <<<<<<<<<<<<<<
 *         *,
 *         close_time: Optional[datetime.datetime] = None,
*/
  __pyx_t_4 = __Pyx_PyBool_FromLong(((int)1)); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4853, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "ws_package/controllers/activity_controller.py":4850
 *             )
 * 
 *     async def _last_api_call_impl(             # <<<<<<<<<<<<<<
 *         self,
 *         user_entity: UserEntity,
*/
  __pyx_t_8 = PyTuple_Pack(1, __pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 4850, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_8);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __pyx_t_4 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 4850, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);

  /* "ws_package/controllers/activity_controller.py":4855
 *         keep_idle_time: bool = True,
 *         *,
 *         close_time: Optional[datetime.datetime] = None,             # <<<<<<<<<<<<<<
 *         payload_project_id: Optional[str] = None,
 *         payload_task_id: Optional[str] = None,
*/
  if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_close_time, Py_None) < (0)) __PYX_ERR(0, 4850, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":4856
 *         *,
 *         close_time: Optional[datetime.datetime] = None,
 *         payload_project_id: Optional[str] = None,             # <<<<<<<<<<<<<<
 *         payload_task_id: Optional[str] = None,
 *     ):
*/
  if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_payload_project_id, Py_None) < (0)) __PYX_ERR(0, 4850, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":4857
 *         close_time: Optional[datetime.datetime] = None,
 *         payload_project_id: Optional[str] = None,
 *         payload_task_id: Optional[str] = None,             # <<<<<<<<<<<<<<
 *     ):
 *         """Internal implementation of last_api_call (caller must hold _session_close_lock)."""
*/
  if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_payload_task_id, Py_None) < (0)) __PYX_ERR(0, 4850, __pyx_L1_error)

  /* "ws_package/controllers/activity_controller.py":4850
 *             )
 * 
 *     async def _last_api_call_impl(             # <<<<<<<<<<<<<<
 *         self,
 *         user_entity: UserEntity,
*/
  __pyx_t_2 = __Pyx_PyDict_NewPresized(5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 4850, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_mstate_global->__pyx_n_u_UserEntity) < (0)) __PYX_ERR(0, 4850, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_keep_idle_time, __pyx_mstate_global->__pyx_n_u_bool) < (0)) __PYX_ERR(0, 4850, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_close_time, __pyx_mstate_global->__pyx_kp_u_Optional_datetime_datetime) < (0)) __PYX_ERR(0, 4850, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_payload_project_id, __pyx_mstate_global->__pyx_kp_u_Optional_str) < (0)) __PYX_ERR(0, 4850, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_2, __pyx_mstate_global->__pyx_n_u_payload_task_id, __pyx_mstate_global->__pyx_kp_u_Optional_str) < (0)) __PYX_ERR(0, 4850, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_178_last_api_call_impl, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController__last_api_cal_2, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[59])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 4850, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_15, __pyx_t_8);
  __Pyx_CyFunction_SetDefaultsKwDict(__pyx_t_15, __pyx_t_4);
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_2);
  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_last_api_call_impl, __pyx_t_15) < (0)) __PYX_ERR(0, 4850, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":5643
 *             raise  # Re-raise to let caller know it failed
 * 
 *     async def stop_event(self, user_entity: UserEntity, keep_idle_time: bool = True):             # <<<<<<<<<<<<<<
 *         """Stop all activity monitoring and cleanup resources"""
 *         try:
*/
  __pyx_t_15 = __Pyx_PyBool_FromLong(((int)1)); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5643, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  __pyx_t_2 = PyTuple_Pack(1, __pyx_t_15); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 5643, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_2);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  __pyx_t_15 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5643, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_user_entity, __pyx_mstate_global->__pyx_n_u_UserEntity) < (0)) __PYX_ERR(0, 5643, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_keep_idle_time, __pyx_mstate_global->__pyx_n_u_bool) < (0)) __PYX_ERR(0, 5643, __pyx_L1_error)
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_181stop_event, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_stop_event, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[62])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5643, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_t_2);
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_stop_event, __pyx_t_4) < (0)) __PYX_ERR(0, 5643, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":5716
 *             return False
 * 
 *     async def _send_active_app_update_to_electron(self, app_name: str, app_icon: Optional[str] = None):             # <<<<<<<<<<<<<<
 *         """
 *         Send active app update to Electron for UI display.
*/
  __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5716, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_app_name, __pyx_mstate_global->__pyx_n_u_str) < (0)) __PYX_ERR(0, 5716, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_app_icon, __pyx_mstate_global->__pyx_kp_u_Optional_str) < (0)) __PYX_ERR(0, 5716, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_184_send_active_app_update_to_electron, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController__send_active, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[63])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5716, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_15, __pyx_mstate_global->__pyx_tuple[21]);
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_send_active_app_update_to_elect, __pyx_t_15) < (0)) __PYX_ERR(0, 5716, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":5752
 *             logger.error("Error sending active app update to Electron: %s", e, exc_info=True)
 * 
 *     async def _send_file_upload_success_to_electron(self, s3_url: str):             # <<<<<<<<<<<<<<
 *         """Sends file upload success message to Electron for UI notification."""
 *         try:
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5752, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_s3_url, __pyx_mstate_global->__pyx_n_u_str) < (0)) __PYX_ERR(0, 5752, __pyx_L1_error)
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_187_send_file_upload_success_to_electron, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController__send_file_up, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[64])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5752, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_send_file_upload_success_to_ele, __pyx_t_4) < (0)) __PYX_ERR(0, 5752, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":5783
 *             return False
 * 
 *     async def _send_file_upload_failure_to_electron(self):             # <<<<<<<<<<<<<<
 *         """Sends file upload failure message to Electron for UI notification."""
 *         try:
*/
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_190_send_file_upload_failure_to_electron, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController__send_file_up_2, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[65])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5783, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_send_file_upload_failure_to_ele, __pyx_t_4) < (0)) __PYX_ERR(0, 5783, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":5813
 *             return False
 * 
 *     async def check_idle_popup_timeout(self) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Check if 60 minutes have passed since idle popup was triggered.
*/
  __pyx_t_4 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 5813, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_bool) < (0)) __PYX_ERR(0, 5813, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_193check_idle_popup_timeout, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_check_idle_po, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[66])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5813, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_check_idle_popup_timeout, __pyx_t_15) < (0)) __PYX_ERR(0, 5813, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":5906
 *             return False
 * 
 *     async def arise_idle_popup(self):             # <<<<<<<<<<<<<<
 *         """
 *         Trigger idle popup in Electron app.
*/
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_196arise_idle_popup, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_arise_idle_po, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[67])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 5906, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_arise_idle_popup, __pyx_t_15) < (0)) __PYX_ERR(0, 5906, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":6021
 *             logger.error("Error triggering idle popup: %s", e, exc_info=True)
 * 
 *     async def _has_zero_activity_for_interval(self, start_date: datetime.datetime, end_date: datetime.datetime) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Check if an interval has zero activity in both activityLevel and activity_percentage.
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(3); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 6021, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_start_date, __pyx_mstate_global->__pyx_kp_u_datetime_datetime) < (0)) __PYX_ERR(0, 6021, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_end_date, __pyx_mstate_global->__pyx_kp_u_datetime_datetime) < (0)) __PYX_ERR(0, 6021, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_bool) < (0)) __PYX_ERR(0, 6021, __pyx_L1_error)
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_199_has_zero_activity_for_interval, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController__has_zero_act, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[68])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6021, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_has_zero_activity_for_interval, __pyx_t_4) < (0)) __PYX_ERR(0, 6021, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":6062
 *             return False
 * 
 *     async def handle_idle_popup_response(self, keep_idle_time: bool, action: str, project_id: Optional[str] = None, task_id: Optional[str] = None, note: Optional[str] = None, file_path: Optional[str] = None):             # <<<<<<<<<<<<<<
 *         """
 *         Handle idle popup response from Electron.
*/
  __pyx_t_4 = __Pyx_PyDict_NewPresized(6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6062, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_keep_idle_time, __pyx_mstate_global->__pyx_n_u_bool) < (0)) __PYX_ERR(0, 6062, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_action, __pyx_mstate_global->__pyx_n_u_str) < (0)) __PYX_ERR(0, 6062, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_project_id, __pyx_mstate_global->__pyx_kp_u_Optional_str) < (0)) __PYX_ERR(0, 6062, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_task_id, __pyx_mstate_global->__pyx_kp_u_Optional_str) < (0)) __PYX_ERR(0, 6062, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_note, __pyx_mstate_global->__pyx_kp_u_Optional_str) < (0)) __PYX_ERR(0, 6062, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_file_path, __pyx_mstate_global->__pyx_kp_u_Optional_str) < (0)) __PYX_ERR(0, 6062, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_202handle_idle_popup_response, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_handle_idle_p, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[69])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 6062, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_15, __pyx_mstate_global->__pyx_tuple[35]);
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_handle_idle_popup_response, __pyx_t_15) < (0)) __PYX_ERR(0, 6062, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":6200
 *             logger.error("Error handling idle popup response: %s", e, exc_info=True)
 * 
 *     def handle_idle_popup_shown(self):             # <<<<<<<<<<<<<<
 *         """
 *         Called when Electron confirms the idle popup was shown to the user.
*/
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_205handle_idle_popup_shown, 0, __pyx_mstate_global->__pyx_n_u_ActivityController_handle_idle_p_2, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[116])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 6200, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_handle_idle_popup_shown, __pyx_t_15) < (0)) __PYX_ERR(0, 6200, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":6207
 *         logger.debug("Idle popup shown confirmed by Electron (cooldown removed)")
 * 
 *     async def sync_activity_immediately(self):             # <<<<<<<<<<<<<<
 *         """
 *         Immediately sync all unuploaded activity intervals to the server.
*/
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_207sync_activity_immediately, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController_sync_activity, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[70])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 6207, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_sync_activity_immediately, __pyx_t_15) < (0)) __PYX_ERR(0, 6207, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":6280
 *             logger.error("Error in sync_activity_immediately: %s", e, exc_info=True)
 * 
 *     async def _mark_idle_intervals_as_uploaded(self):             # <<<<<<<<<<<<<<
 *         """
 *         Mark idle intervals as is_uploaded=True so they are never sent to the server.
*/
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_210_mark_idle_intervals_as_uploaded, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController__mark_idle_in, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[71])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 6280, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_mark_idle_intervals_as_uploaded, __pyx_t_15) < (0)) __PYX_ERR(0, 6280, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":6380
 *             logger.error("Error marking idle intervals as uploaded: %s", e, exc_info=True)
 * 
 *     async def _upload_file_to_s3(self, local_file_path: str) -> Optional[str]:             # <<<<<<<<<<<<<<
 *         """
 *         Upload a file to S3 and return the S3 URL.
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 6380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_local_file_path, __pyx_mstate_global->__pyx_n_u_str) < (0)) __PYX_ERR(0, 6380, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_kp_u_Optional_str) < (0)) __PYX_ERR(0, 6380, __pyx_L1_error)
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_213_upload_file_to_s3, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController__upload_file, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[72])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6380, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_upload_file_to_s3, __pyx_t_4) < (0)) __PYX_ERR(0, 6380, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":6447
 *             return None
 * 
 *     async def _save_note_to_idle_intervals(self, note: str, file_path: Optional[str] = None):             # <<<<<<<<<<<<<<
 *         """
 *         Save note to Notes table with array of idle interval IDs.
*/
  __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6447, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_note, __pyx_mstate_global->__pyx_n_u_str) < (0)) __PYX_ERR(0, 6447, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_file_path, __pyx_mstate_global->__pyx_kp_u_Optional_str) < (0)) __PYX_ERR(0, 6447, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_216_save_note_to_idle_intervals, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController__save_note_to, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[73])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 6447, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_15, __pyx_mstate_global->__pyx_tuple[21]);
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_save_note_to_idle_intervals, __pyx_t_15) < (0)) __PYX_ERR(0, 6447, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":6536
 *             logger.error("Error saving note to Notes table: %s", e, exc_info=True)
 * 
 *     async def _save_note_to_current_interval(self, note: str, file_path: Optional[str] = None):             # <<<<<<<<<<<<<<
 *         """
 *         Save note to Notes table with current running interval ID.
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 6536, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_note, __pyx_mstate_global->__pyx_n_u_str) < (0)) __PYX_ERR(0, 6536, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_file_path, __pyx_mstate_global->__pyx_kp_u_Optional_str) < (0)) __PYX_ERR(0, 6536, __pyx_L1_error)
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_219_save_note_to_current_interval, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController__save_note_to_2, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[74])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6536, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_mstate_global->__pyx_tuple[21]);
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_save_note_to_current_interval, __pyx_t_4) < (0)) __PYX_ERR(0, 6536, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":6606
 * 
 * 
 *     async def _should_pause_api_calls(self, intervals: list) -> bool:             # <<<<<<<<<<<<<<
 *         """
 *         Check if API calls should be paused.
*/
  __pyx_t_4 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6606, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_intervals, __pyx_mstate_global->__pyx_n_u_list) < (0)) __PYX_ERR(0, 6606, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_4, __pyx_mstate_global->__pyx_n_u_return, __pyx_mstate_global->__pyx_n_u_bool) < (0)) __PYX_ERR(0, 6606, __pyx_L1_error)
  __pyx_t_15 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_222_should_pause_api_calls, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController__should_pause_2, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[76])); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 6606, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_15);
  #endif
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_15, __pyx_t_4);
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_should_pause_api_calls, __pyx_t_15) < (0)) __PYX_ERR(0, 6606, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;

  /* "ws_package/controllers/activity_controller.py":6729
 * 
 * 
 *     async def _idle_reassign(self, project_id: str, task_id: Optional[str] = None):             # <<<<<<<<<<<<<<
 *         """
 *         Reassign idle intervals to a new project and task by sending them to the API with the new project/task IDs.
*/
  __pyx_t_15 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_15)) __PYX_ERR(0, 6729, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_15);
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_project_id, __pyx_mstate_global->__pyx_n_u_str) < (0)) __PYX_ERR(0, 6729, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_15, __pyx_mstate_global->__pyx_n_u_task_id, __pyx_mstate_global->__pyx_kp_u_Optional_str) < (0)) __PYX_ERR(0, 6729, __pyx_L1_error)
  __pyx_t_4 = __Pyx_CyFunction_New(&__pyx_mdef_10ws_package_11controllers_19activity_controller_18ActivityController_225_idle_reassign, __Pyx_CYFUNCTION_COROUTINE, __pyx_mstate_global->__pyx_n_u_ActivityController__idle_reassig, NULL, __pyx_mstate_global->__pyx_n_u_ws_package_controllers_activity, __pyx_mstate_global->__pyx_d, ((PyObject *)__pyx_mstate_global->__pyx_codeobj_tab[77])); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 6729, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_4, __pyx_mstate_global->__pyx_tuple[21]);
  __Pyx_CyFunction_SetAnnotationsDict(__pyx_t_4, __pyx_t_15);
  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
  if (__Pyx_SetNameInClass(__pyx_t_9, __pyx_mstate_global->__pyx_n_u_idle_reassign, __pyx_t_4) < (0)) __PYX_ERR(0, 6729, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;

  /* "ws_package/controllers/activity_controller.py":124
 * 
 * 
 * class ActivityController(             # <<<<<<<<<<<<<<
 *     ActivityScreenshotMixin,
 *     ActivityBreakMixin,
*/
  __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_13, __pyx_mstate_global->__pyx_n_u_ActivityController, __pyx_t_14, __pyx_t_9, NULL, 0, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 124, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_4);
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030E0000
  PyUnstable_Object_EnableDeferredRefcount(__pyx_t_4);
  #endif
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_ActivityController, __pyx_t_4) < (0)) __PYX_ERR(0, 124, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /* "ws_package/controllers/activity_controller.py":1
 * # cython: language_level=3             # <<<<<<<<<<<<<<
 * # ws_package/controllers/activity_controller.py
 * import asyncio
*/
  __pyx_t_14 = __Pyx_PyDict_NewPresized(2); if (unlikely(!__pyx_t_14)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_t_14);
  if (PyDict_SetItem(__pyx_t_14, __pyx_mstate_global->__pyx_kp_u_ActivityController___init___line, __pyx_mstate_global->__pyx_kp_u_Initialize_ActivityController_w) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_t_14, __pyx_mstate_global->__pyx_kp_u_ActivityController_getStartingSl_2, __pyx_mstate_global->__pyx_kp_u_Calculate_the_starting_time_slo) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  if (PyDict_SetItem(__pyx_mstate_global->__pyx_d, __pyx_mstate_global->__pyx_n_u_test, __pyx_t_14) < (0)) __PYX_ERR(0, 1, __pyx_L1_error)
  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;

  /*--- Wrapped vars code ---*/

  goto __pyx_L0;
  __pyx_L1_error:;
  __Pyx_XDECREF(__pyx_t_2);
  __Pyx_XDECREF(__pyx_t_4);
  __Pyx_XDECREF(__pyx_t_8);
  __Pyx_XDECREF(__pyx_t_9);
  __Pyx_XDECREF(__pyx_t_13);
  __Pyx_XDECREF(__pyx_t_14);
  __Pyx_XDECREF(__pyx_t_15);
  if (__pyx_m) {
    if (__pyx_mstate->__pyx_d && stringtab_initialized) {
      __Pyx_AddTraceback("init ws_package.controllers.activity_controller", __pyx_clineno, __pyx_lineno, __pyx_filename);
    }
    #if !CYTHON_USE_MODULE_STATE
    Py_CLEAR(__pyx_m);
    #else
    Py_DECREF(__pyx_m);
    if (pystate_addmodule_run) {
      PyObject *tp, *value, *tb;
      PyErr_Fetch(&tp, &value, &tb);
      PyState_RemoveModule(&__pyx_moduledef);
      PyErr_Restore(tp, value, tb);
    }
    #endif
  } else if (!PyErr_Occurred()) {
    PyErr_SetString(PyExc_ImportError, "init ws_package.controllers.activity_controller");
  }
  __pyx_L0:;
  __Pyx_RefNannyFinishContext();
  #if CYTHON_PEP489_MULTI_PHASE_INIT
  return (__pyx_m != NULL) ? 0 : -1;
  #else
  return __pyx_m;
  #endif
}
/* #### Code section: pystring_table ### */
/* #### Code section: cached_builtins ### */

static int __Pyx_InitCachedBuiltins(__pyx_mstatetype *__pyx_mstate) {
  CYTHON_UNUSED_VAR(__pyx_mstate);
  __pyx_builtin_staticmethod = __Pyx_GetBuiltinName(__pyx_mstate->__pyx_n_u_staticmethod); if (!__pyx_builtin_staticmethod) __PYX_ERR(0, 517, __pyx_L1_error)
  __pyx_builtin_sum = __Pyx_GetBuiltinName(__pyx_mstate->__pyx_n_u_sum); if (!__pyx_builtin_sum) __PYX_ERR(0, 2997, __pyx_L1_error)
  __pyx_builtin_sorted = __Pyx_GetBuiltinName(__pyx_mstate->__pyx_n_u_sorted); if (!__pyx_builtin_sorted) __PYX_ERR(0, 3724, __pyx_L1_error)
  __pyx_builtin_enumerate = __Pyx_GetBuiltinName(__pyx_mstate->__pyx_n_u_enumerate); if (!__pyx_builtin_enumerate) __PYX_ERR(0, 4189, __pyx_L1_error)

  /* Cached unbound methods */
  __pyx_mstate->__pyx_umethod_PyDict_Type_get.type = (PyObject*)&PyDict_Type;
  __pyx_mstate->__pyx_umethod_PyDict_Type_get.method_name = &__pyx_mstate->__pyx_n_u_get;
  __pyx_mstate->__pyx_umethod_PyDict_Type_items.type = (PyObject*)&PyDict_Type;
  __pyx_mstate->__pyx_umethod_PyDict_Type_items.method_name = &__pyx_mstate->__pyx_n_u_items;
  __pyx_mstate->__pyx_umethod_PyDict_Type_keys.type = (PyObject*)&PyDict_Type;
  __pyx_mstate->__pyx_umethod_PyDict_Type_keys.method_name = &__pyx_mstate->__pyx_n_u_keys;
  __pyx_mstate->__pyx_umethod_PyDict_Type_pop.type = (PyObject*)&PyDict_Type;
  __pyx_mstate->__pyx_umethod_PyDict_Type_pop.method_name = &__pyx_mstate->__pyx_n_u_pop;
  __pyx_mstate->__pyx_umethod_PyDict_Type_values.type = (PyObject*)&PyDict_Type;
  __pyx_mstate->__pyx_umethod_PyDict_Type_values.method_name = &__pyx_mstate->__pyx_n_u_values;
  __pyx_mstate->__pyx_umethod_PyList_Type__copy.type = (PyObject*)(&PyList_Type);
  __pyx_mstate->__pyx_umethod_PyList_Type__copy.method_name = &__pyx_mstate->__pyx_n_u_copy;
  __pyx_mstate->__pyx_umethod_PyUnicode_Type__strip.type = (PyObject*)(&PyUnicode_Type);
  __pyx_mstate->__pyx_umethod_PyUnicode_Type__strip.method_name = &__pyx_mstate->__pyx_n_u_strip;
  __pyx_mstate->__pyx_umethod_PyUnicode_Type__upper.type = (PyObject*)(&PyUnicode_Type);
  __pyx_mstate->__pyx_umethod_PyUnicode_Type__upper.method_name = &__pyx_mstate->__pyx_n_u_upper;
  return 0;
  __pyx_L1_error:;
  return -1;
}
/* #### Code section: cached_constants ### */

static int __Pyx_InitCachedConstants(__pyx_mstatetype *__pyx_mstate) {
  __Pyx_RefNannyDeclarations
  CYTHON_UNUSED_VAR(__pyx_mstate);
  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);

  /* "ws_package/controllers/activity_controller.py":205
 *         # Get session gap threshold with graceful fallback (config may not exist)
 *         try:
 *             session_gap_minutes = config('session_gap_threshold_minutes', 'ActivityMonitor', dtype='int')             # <<<<<<<<<<<<<<
 *             if session_gap_minutes is None or session_gap_minutes <= 0:
 *                 session_gap_minutes = 60  # Default to 1 hour between sessions
*/
  __pyx_mstate_global->__pyx_tuple[0] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_n_u_session_gap_threshold_minutes, __pyx_mstate_global->__pyx_n_u_ActivityMonitor); if (unlikely(!__pyx_mstate_global->__pyx_tuple[0])) __PYX_ERR(0, 205, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[0]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[0]);

  /* "ws_package/controllers/activity_controller.py":213
 *         self.session_gap_threshold_minutes: int = int(session_gap_minutes)
 *         self.session_gap_threshold_seconds: int = session_gap_minutes * 60
 *         self.s3_screenshot_path: str = config('s3_screenshot_path', 'Sync')             # <<<<<<<<<<<<<<
 *         self.s3_logs_path: str = config('s3_logs_path', 'Sync')
 *         self.has_on_demand: bool = False
*/
  __pyx_mstate_global->__pyx_tuple[1] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_n_u_s3_screenshot_path, __pyx_mstate_global->__pyx_n_u_Sync); if (unlikely(!__pyx_mstate_global->__pyx_tuple[1])) __PYX_ERR(0, 213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[1]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[1]);

  /* "ws_package/controllers/activity_controller.py":214
 *         self.session_gap_threshold_seconds: int = session_gap_minutes * 60
 *         self.s3_screenshot_path: str = config('s3_screenshot_path', 'Sync')
 *         self.s3_logs_path: str = config('s3_logs_path', 'Sync')             # <<<<<<<<<<<<<<
 *         self.has_on_demand: bool = False
 *         # Break status - set from Electron via ws_engine
*/
  __pyx_mstate_global->__pyx_tuple[2] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_n_u_s3_logs_path, __pyx_mstate_global->__pyx_n_u_Sync); if (unlikely(!__pyx_mstate_global->__pyx_tuple[2])) __PYX_ERR(0, 214, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[2]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[2]);

  /* "ws_package/controllers/activity_controller.py":251
 * 
 *         # Time settings
 *         self.limit_start: datetime.time = datetime.datetime.strptime("00:00:00", "%H:%M:%S").time()             # <<<<<<<<<<<<<<
 *         self.limit_end: datetime.time = datetime.datetime.strptime("23:59:59", "%H:%M:%S").time()
 *         self.no_of_days: List[str] = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
*/
  __pyx_mstate_global->__pyx_tuple[3] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_kp_u_00_00_00, __pyx_mstate_global->__pyx_kp_u_H_M_S); if (unlikely(!__pyx_mstate_global->__pyx_tuple[3])) __PYX_ERR(0, 251, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[3]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[3]);

  /* "ws_package/controllers/activity_controller.py":252
 *         # Time settings
 *         self.limit_start: datetime.time = datetime.datetime.strptime("00:00:00", "%H:%M:%S").time()
 *         self.limit_end: datetime.time = datetime.datetime.strptime("23:59:59", "%H:%M:%S").time()             # <<<<<<<<<<<<<<
 *         self.no_of_days: List[str] = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
 * 
*/
  __pyx_mstate_global->__pyx_tuple[4] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_kp_u_23_59_59, __pyx_mstate_global->__pyx_kp_u_H_M_S); if (unlikely(!__pyx_mstate_global->__pyx_tuple[4])) __PYX_ERR(0, 252, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[4]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[4]);

  /* "ws_package/controllers/activity_controller.py":294
 *         # Writable screenshot dir (frozen Windows cannot use cwd-relative "screenshots").
 *         from ws_package.utils.system import resolve_screenshot_directory
 *         screenshot_folder = config('save_dir', 'Screenshot') or "screenshots"             # <<<<<<<<<<<<<<
 *         try:
 *             self.save_dir = resolve_screenshot_directory(screenshot_folder)
*/
  __pyx_mstate_global->__pyx_tuple[5] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_n_u_save_dir, __pyx_mstate_global->__pyx_n_u_Screenshot); if (unlikely(!__pyx_mstate_global->__pyx_tuple[5])) __PYX_ERR(0, 294, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[5]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[5]);

  /* "ws_package/controllers/activity_controller.py":310
 *             )
 * 
 *         self.img_format = config('img_format', 'Screenshot') or 'JPEG'             # <<<<<<<<<<<<<<
 *         self.img_quality = 100
 *         self.blur_intensity = 1
*/
  __pyx_mstate_global->__pyx_tuple[6] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_n_u_img_format, __pyx_mstate_global->__pyx_n_u_Screenshot); if (unlikely(!__pyx_mstate_global->__pyx_tuple[6])) __PYX_ERR(0, 310, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[6]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[6]);

  /* "ws_package/controllers/activity_controller.py":560
 *         cutoff = datetime.datetime.now() - datetime.timedelta(seconds=within_seconds)
 *         with db_lock_manager.read_lock():
 *             async with async_session() as session:             # <<<<<<<<<<<<<<
 *                 try:
 *                     query = (
*/
  __pyx_mstate_global->__pyx_tuple[7] = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_mstate_global->__pyx_tuple[7])) __PYX_ERR(0, 560, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[7]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[7]);

  /* "ws_package/controllers/activity_controller.py":802
 *         if not text:
 *             return None
 *         for fmt in ("%H:%M:%S", "%H:%M"):             # <<<<<<<<<<<<<<
 *             try:
 *                 parsed = datetime.datetime.strptime(text, fmt).time()
*/
  __pyx_mstate_global->__pyx_tuple[8] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_kp_u_H_M_S, __pyx_mstate_global->__pyx_kp_u_H_M); if (unlikely(!__pyx_mstate_global->__pyx_tuple[8])) __PYX_ERR(0, 802, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[8]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[8]);

  /* "ws_package/controllers/activity_controller.py":832
 *                 raw_end,
 *             )
 *             return "00:00:00", "23:59:59"             # <<<<<<<<<<<<<<
 * 
 *         return s_limit_start, s_limit_end
*/
  __pyx_mstate_global->__pyx_tuple[9] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_kp_u_00_00_00, __pyx_mstate_global->__pyx_kp_u_23_59_59); if (unlikely(!__pyx_mstate_global->__pyx_tuple[9])) __PYX_ERR(0, 832, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[9]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[9]);

  /* "ws_package/controllers/activity_controller.py":985
 *             position_of_dollar = encrypted_key.find('$')
 *             if position_of_dollar == -1:
 *                 raise ValidationError("Invalid encrypted key format: missing '$' delimiter", context={"encrypted_key": encrypted_key[:50]})             # <<<<<<<<<<<<<<
 * 
 *             new_string = encrypted_key[position_of_dollar + 1:]
*/
  __pyx_mstate_global->__pyx_slice[0] = PySlice_New(Py_None, __pyx_mstate_global->__pyx_int_50, Py_None); if (unlikely(!__pyx_mstate_global->__pyx_slice[0])) __PYX_ERR(0, 985, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_slice[0]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_slice[0]);

  /* "ws_package/controllers/activity_controller.py":991
 *                 raise ValidationError("Invalid encrypted key format: empty data after '$'", context={"encrypted_key": encrypted_key[:50]})
 * 
 *             new_string = new_string[::-1]             # <<<<<<<<<<<<<<
 *             decrypted_data = base64.b64decode(new_string).decode()
 *             return decrypted_data
*/
  __pyx_mstate_global->__pyx_slice[1] = PySlice_New(Py_None, Py_None, __pyx_mstate_global->__pyx_int_neg_1); if (unlikely(!__pyx_mstate_global->__pyx_slice[1])) __PYX_ERR(0, 991, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_slice[1]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_slice[1]);

  /* "ws_package/controllers/activity_controller.py":1202
 *             else:
 *                 # API did not return weekly_limit; leave limit_action unset so OrgEntity uses its default
 *                 response_data.setdefault("limit_action", None)             # <<<<<<<<<<<<<<
 * 
 *             # Extract idle_time_limit_in_seconds from API response
*/
  __pyx_mstate_global->__pyx_tuple[10] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_n_u_limit_action, Py_None); if (unlikely(!__pyx_mstate_global->__pyx_tuple[10])) __PYX_ERR(0, 1202, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[10]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[10]);

  /* "ws_package/controllers/activity_controller.py":1206
 *             # Extract idle_time_limit_in_seconds from API response
 *             if "idle_time_limit_in_seconds" in response_data:
 *                 response_data["idle_time_limit_in_seconds"] = response_data.get("idle_time_limit_in_seconds", 3600)             # <<<<<<<<<<<<<<
 *             else:
 *                 response_data["idle_time_limit_in_seconds"] = 3600  # Default fallback
*/
  __pyx_mstate_global->__pyx_tuple[11] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_n_u_idle_time_limit_in_seconds, __pyx_mstate_global->__pyx_int_3600); if (unlikely(!__pyx_mstate_global->__pyx_tuple[11])) __PYX_ERR(0, 1206, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[11]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[11]);

  /* "ws_package/controllers/activity_controller.py":1213
 * 
 *             response_data["timezone_preference"] = normalize_timezone_preference(
 *                 response_data.get("timezone_preference", 1)             # <<<<<<<<<<<<<<
 *             )
 * 
*/
  __pyx_mstate_global->__pyx_tuple[12] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_n_u_timezone_preference, __pyx_mstate_global->__pyx_int_1); if (unlikely(!__pyx_mstate_global->__pyx_tuple[12])) __PYX_ERR(0, 1213, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[12]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[12]);

  /* "ws_package/controllers/activity_controller.py":1363
 *             )
 * 
 *             daily_exceeded = limits_check.get('daily_exceeded', False)             # <<<<<<<<<<<<<<
 *             weekly_exceeded = limits_check.get('weekly_exceeded', False)
 * 
*/
  __pyx_mstate_global->__pyx_tuple[13] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_n_u_daily_exceeded, Py_False); if (unlikely(!__pyx_mstate_global->__pyx_tuple[13])) __PYX_ERR(0, 1363, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[13]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[13]);

  /* "ws_package/controllers/activity_controller.py":1364
 * 
 *             daily_exceeded = limits_check.get('daily_exceeded', False)
 *             weekly_exceeded = limits_check.get('weekly_exceeded', False)             # <<<<<<<<<<<<<<
 * 
 *             if daily_exceeded or weekly_exceeded:
*/
  __pyx_mstate_global->__pyx_tuple[14] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_n_u_weekly_exceeded, Py_False); if (unlikely(!__pyx_mstate_global->__pyx_tuple[14])) __PYX_ERR(0, 1364, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[14]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[14]);

  /* "ws_package/controllers/activity_controller.py":1669
 *                 # Pass interval_minutes to ensure minute counter is capped correctly
 *                 await activity_percentage_service.calculate_and_store_rolling_average(
 *                     keyboard_percentage=float(minute_activity_level.get('keyboard', 0)),             # <<<<<<<<<<<<<<
 *                     mouse_percentage=float(minute_activity_level.get('mouse', 0)),
 *                     average_percentage=float(minute_activity_level.get('average', 0)),
*/
  __pyx_mstate_global->__pyx_tuple[15] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_n_u_keyboard, __pyx_mstate_global->__pyx_int_0); if (unlikely(!__pyx_mstate_global->__pyx_tuple[15])) __PYX_ERR(0, 1669, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[15]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[15]);

  /* "ws_package/controllers/activity_controller.py":1670
 *                 await activity_percentage_service.calculate_and_store_rolling_average(
 *                     keyboard_percentage=float(minute_activity_level.get('keyboard', 0)),
 *                     mouse_percentage=float(minute_activity_level.get('mouse', 0)),             # <<<<<<<<<<<<<<
 *                     average_percentage=float(minute_activity_level.get('average', 0)),
 *                     interval_minutes=int(self.interval / 60)  # 5, 10, or 15 minutes
*/
  __pyx_mstate_global->__pyx_tuple[16] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_n_u_mouse, __pyx_mstate_global->__pyx_int_0); if (unlikely(!__pyx_mstate_global->__pyx_tuple[16])) __PYX_ERR(0, 1670, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[16]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[16]);

  /* "ws_package/controllers/activity_controller.py":1671
 *                     keyboard_percentage=float(minute_activity_level.get('keyboard', 0)),
 *                     mouse_percentage=float(minute_activity_level.get('mouse', 0)),
 *                     average_percentage=float(minute_activity_level.get('average', 0)),             # <<<<<<<<<<<<<<
 *                     interval_minutes=int(self.interval / 60)  # 5, 10, or 15 minutes
 *                 )
*/
  __pyx_mstate_global->__pyx_tuple[17] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_n_u_average, __pyx_mstate_global->__pyx_int_0); if (unlikely(!__pyx_mstate_global->__pyx_tuple[17])) __PYX_ERR(0, 1671, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[17]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[17]);

  /* "ws_package/controllers/activity_controller.py":1886
 *                             # Apps + URLs mode (2) or full mode (3): resolve URL from browser DB.
 *                             row = active_app_url[0]
 *                             i2t = row.get('url') or row.get('active_app', '')             # <<<<<<<<<<<<<<
 *                             display_name = row.get('app_display_name') or row.get('active_app', '')
 * 
*/
  __pyx_mstate_global->__pyx_tuple[18] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_n_u_active_app, __pyx_mstate_global->__pyx_kp_u__2); if (unlikely(!__pyx_mstate_global->__pyx_tuple[18])) __PYX_ERR(0, 1886, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[18]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[18]);

  /* "ws_package/controllers/activity_controller.py":1890
 * 
 *                             # get_active_windows_ms() already reads Chrome History  reuse URL when present
 *                             if i2t.startswith(('http://', 'https://')):             # <<<<<<<<<<<<<<
 *                                 pass
 *                             elif self.is_browser(display_name) or self.is_browser(i2t):
*/
  __pyx_mstate_global->__pyx_tuple[19] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_kp_u_http, __pyx_mstate_global->__pyx_kp_u_https); if (unlikely(!__pyx_mstate_global->__pyx_tuple[19])) __PYX_ERR(0, 1890, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[19]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[19]);

  /* "ws_package/controllers/activity_controller.py":1993
 *                     if active_windows and len(active_windows) > 0:
 *                         current_app_data = active_windows[0]
 *                         current_app_name = current_app_data.get('app_display_name') or current_app_data.get('active_app', 'Unknown')             # <<<<<<<<<<<<<<
 *                         current_app_path = current_app_data.get('app_path')
 * 
*/
  __pyx_mstate_global->__pyx_tuple[20] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_n_u_active_app, __pyx_mstate_global->__pyx_n_u_Unknown); if (unlikely(!__pyx_mstate_global->__pyx_tuple[20])) __PYX_ERR(0, 1993, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[20]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[20]);

  /* "ws_package/controllers/activity_controller.py":1727
 *             try:
 *                 logger.info("Starting time monitor (%s)...", platform.system())
 *                 def _on_time_error(error_type=None):             # <<<<<<<<<<<<<<
 *                     if not self._timezone_checks_enabled():
 *                         logger.info(
*/
  __pyx_mstate_global->__pyx_tuple[21] = PyTuple_Pack(1, Py_None); if (unlikely(!__pyx_mstate_global->__pyx_tuple[21])) __PYX_ERR(0, 1727, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[21]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[21]);

  /* "ws_package/controllers/activity_controller.py":2276
 * 
 *                         logger.info("save last active app as true because of wrong timezone deteceted so next last min save can't be wrong from activity")
 *                         url = config('timezone_mismatch', 'Application')             # <<<<<<<<<<<<<<
 *                         headers = {
 *                             "Content-Type": "application/json",
*/
  __pyx_mstate_global->__pyx_tuple[22] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_n_u_timezone_mismatch_2, __pyx_mstate_global->__pyx_n_u_Application); if (unlikely(!__pyx_mstate_global->__pyx_tuple[22])) __PYX_ERR(0, 2276, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[22]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[22]);

  /* "ws_package/controllers/activity_controller.py":2688
 *                         for _pi in _dwq.get_pending_items(_WOT.ACTIVITY_INTERVAL):
 *                             _d = _pi.data
 *                             if (_d.get('is_break', 0) != 0 and             # <<<<<<<<<<<<<<
 *                                     _d.get('counter') == self.last_count + 1):
 *                                 _ps = _d.get('start_time')
*/
  __pyx_mstate_global->__pyx_tuple[23] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_n_u_is_break, __pyx_mstate_global->__pyx_int_0); if (unlikely(!__pyx_mstate_global->__pyx_tuple[23])) __PYX_ERR(0, 2688, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[23]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[23]);

  /* "ws_package/controllers/activity_controller.py":2842
 *                             logger.info("[IdleInterval] Regular interval (in range) - break_id=%s, is_break=%s, status=%s, will save as is_break=%s", current_break_id, getattr(self, 'is_break', 0), self.status, current_break_id if current_break_id else 0)
 *                             logger.info("[IdleInterval] Saving: break_id=%s, is_idle=%s", current_break_id, is_idle)
 *                             logger.info("[IdleInterval] ActivityLevel: Keyboard=%s%%, Mouse=%s%%, Average=%s%%", activityLevel.get('keyboard', '0.0'), activityLevel.get('mouse', '0.0'), activityLevel.get('average', '0.0'))             # <<<<<<<<<<<<<<
 *                             if is_idle:
 *                                 logger.info("[IdleInterval]  Interval marked as IDLE - will NOT be sent to server until popup handled")
*/
  __pyx_mstate_global->__pyx_tuple[24] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_n_u_keyboard, __pyx_mstate_global->__pyx_kp_u_0_0); if (unlikely(!__pyx_mstate_global->__pyx_tuple[24])) __PYX_ERR(0, 2842, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[24]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[24]);
  __pyx_mstate_global->__pyx_tuple[25] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_n_u_mouse, __pyx_mstate_global->__pyx_kp_u_0_0); if (unlikely(!__pyx_mstate_global->__pyx_tuple[25])) __PYX_ERR(0, 2842, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[25]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[25]);
  __pyx_mstate_global->__pyx_tuple[26] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_n_u_average, __pyx_mstate_global->__pyx_kp_u_0_0); if (unlikely(!__pyx_mstate_global->__pyx_tuple[26])) __PYX_ERR(0, 2842, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[26]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[26]);

  /* "ws_package/controllers/activity_controller.py":3200
 *                 if self.no_of_days is not None and self.get_today_weekday() in self.no_of_days:
 * 
 *                     self.activity_service.application_activity_log_url = config('application_activity_log_url', 'Application')             # <<<<<<<<<<<<<<
 *                     prev_day_unsent = await self.getting_unsent_interval(user_entity)
 *                     logger.info("Previous day unsent intervals %s", prev_day_unsent)
*/
  __pyx_mstate_global->__pyx_tuple[27] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_n_u_application_activity_log_url, __pyx_mstate_global->__pyx_n_u_Application); if (unlikely(!__pyx_mstate_global->__pyx_tuple[27])) __PYX_ERR(0, 3200, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[27]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[27]);

  /* "ws_package/controllers/activity_controller.py":3858
 *             # Edge case: Ensure the intervals array contains at most 100 objects per day
 *             if len(day_intervals) > 100:
 *                 day_intervals = day_intervals[:100]             # <<<<<<<<<<<<<<
 *             logger.info("Target date of intervals %s", target_date)
 *             # Get the appropriate start time for this day
*/
  __pyx_mstate_global->__pyx_slice[2] = PySlice_New(Py_None, __pyx_mstate_global->__pyx_int_100, Py_None); if (unlikely(!__pyx_mstate_global->__pyx_slice[2])) __PYX_ERR(0, 3858, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_slice[2]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_slice[2]);

  /* "ws_package/controllers/activity_controller.py":3941
 *                 ss_end_time = interval.end_time
 *                 if last_interval is not None:
 *                     def _dt_match(a, b, tol=1.0):             # <<<<<<<<<<<<<<
 *                         if a is None or b is None:
 *                             return a == b
*/
  __pyx_mstate_global->__pyx_tuple[28] = PyTuple_Pack(1, ((PyObject*)__pyx_mstate_global->__pyx_float_1_0)); if (unlikely(!__pyx_mstate_global->__pyx_tuple[28])) __PYX_ERR(0, 3941, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[28]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[28]);

  /* "ws_package/controllers/activity_controller.py":4333
 *                     try:
 *                         from ws_package.utils.logs import perform_comprehensive_log_cleanup
 *                         cleanup_enabled = config('log_cleanup_enabled', 'System', dtype='bool')             # <<<<<<<<<<<<<<
 *                         if cleanup_enabled is None or cleanup_enabled:
 *                             perform_comprehensive_log_cleanup()
*/
  __pyx_mstate_global->__pyx_tuple[29] = PyTuple_Pack(2, __pyx_mstate_global->__pyx_n_u_log_cleanup_enabled, __pyx_mstate_global->__pyx_n_u_System); if (unlikely(!__pyx_mstate_global->__pyx_tuple[29])) __PYX_ERR(0, 4333, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[29]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[29]);

  /* "ws_package/controllers/activity_controller.py":5146
 * 
 *             # Query all unsent intervals from current session only (counter filter applied at database level)
 *             intervals = await self.activity_service.get_activity_intervals(None, None, counter=current_session_counter)             # <<<<<<<<<<<<<<
 *             logger.info("Found %s unsent intervals from current session (counter=%s)", len(intervals) if intervals else 0, current_session_counter)
 * 
*/
  __pyx_mstate_global->__pyx_tuple[30] = PyTuple_Pack(2, Py_None, Py_None); if (unlikely(!__pyx_mstate_global->__pyx_tuple[30])) __PYX_ERR(0, 5146, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[30]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[30]);

  /* "ws_package/controllers/activity_controller.py":5195
 *                         if intervals:
 *                             logger.info("Intervals found in database (first 5):")
 *                             for idx, interval in enumerate(intervals[:5]):             # <<<<<<<<<<<<<<
 *                                 logger.info("  Interval %s: start_time=%s, end_time=%s, is_uploaded=%s, counter=%s", idx+1, getattr(interval, 'start_time', 'N/A'), getattr(interval, 'end_time', 'N/A'), getattr(interval, 'is_uploaded', 'N/A'), getattr(interval, 'counter', 'N/A'))
 *                         else:
*/
  __pyx_mstate_global->__pyx_slice[3] = PySlice_New(Py_None, __pyx_mstate_global->__pyx_int_5, Py_None); if (unlikely(!__pyx_mstate_global->__pyx_slice[3])) __PYX_ERR(0, 5195, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_slice[3]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_slice[3]);

  /* "ws_package/controllers/activity_controller.py":100
 * 
 * 
 * def _to_int(val, default=0):             # <<<<<<<<<<<<<<
 *     """Cast an API or DB value to int safely.
 * 
*/
  __pyx_mstate_global->__pyx_tuple[31] = PyTuple_Pack(1, ((PyObject*)__pyx_mstate_global->__pyx_int_0)); if (unlikely(!__pyx_mstate_global->__pyx_tuple[31])) __PYX_ERR(0, 100, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[31]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[31]);

  /* "ws_package/controllers/activity_controller.py":524
 *         return max(0.0, (target - datetime.datetime.now()).total_seconds())
 * 
 *     def increment_session_counter(self, reason: str = "new_session") -> int:             # <<<<<<<<<<<<<<
 *         """Bump last_count for a new timer session and sync dependent managers."""
 *         old_counter = self.last_count
*/
  __pyx_mstate_global->__pyx_tuple[32] = PyTuple_Pack(1, ((PyObject*)__pyx_mstate_global->__pyx_n_u_new_session)); if (unlikely(!__pyx_mstate_global->__pyx_tuple[32])) __PYX_ERR(0, 524, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[32]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[32]);

  /* "ws_package/controllers/activity_controller.py":545
 *         return self.last_count
 * 
 *     def should_skip_counter_bump_dedup(self, within_seconds: int = 12) -> bool:             # <<<<<<<<<<<<<<
 *         """Skip duplicate bump when the same start wave retried IPC within a few seconds."""
 *         if getattr(self, '_bump_counter_on_next_monitoring_start', False):
*/
  __pyx_mstate_global->__pyx_tuple[33] = PyTuple_Pack(1, ((PyObject*)__pyx_mstate_global->__pyx_int_12)); if (unlikely(!__pyx_mstate_global->__pyx_tuple[33])) __PYX_ERR(0, 545, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[33]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[33]);

  /* "ws_package/controllers/activity_controller.py":554
 *         return (datetime.datetime.now() - last_bump).total_seconds() < within_seconds
 * 
 *     async def has_recent_intervals_on_write_counter(self, within_seconds: int = 45) -> bool:             # <<<<<<<<<<<<<<
 *         """True if the current write counter already has intervals ended very recently (start retry)."""
 *         DB_OPERATION_TIMEOUT = 5.0
*/
  __pyx_mstate_global->__pyx_tuple[34] = PyTuple_Pack(1, ((PyObject*)__pyx_mstate_global->__pyx_int_45)); if (unlikely(!__pyx_mstate_global->__pyx_tuple[34])) __PYX_ERR(0, 554, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[34]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[34]);

  /* "ws_package/controllers/activity_controller.py":6062
 *             return False
 * 
 *     async def handle_idle_popup_response(self, keep_idle_time: bool, action: str, project_id: Optional[str] = None, task_id: Optional[str] = None, note: Optional[str] = None, file_path: Optional[str] = None):             # <<<<<<<<<<<<<<
 *         """
 *         Handle idle popup response from Electron.
*/
  __pyx_mstate_global->__pyx_tuple[35] = PyTuple_Pack(4, Py_None, Py_None, Py_None, Py_None); if (unlikely(!__pyx_mstate_global->__pyx_tuple[35])) __PYX_ERR(0, 6062, __pyx_L1_error)
  __Pyx_GOTREF(__pyx_mstate_global->__pyx_tuple[35]);
  __Pyx_GIVEREF(__pyx_mstate_global->__pyx_tuple[35]);
  #if CYTHON_IMMORTAL_CONSTANTS
  {
    PyObject **table = __pyx_mstate->__pyx_tuple;
    for (Py_ssize_t i=0; i<36; ++i) {
      #if PY_VERSION_HEX >= 0x030F0000
      PyUnstable_SetImmortal(table[i]);
      #elif CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
      if ((PY_SSIZE_T_MAX <= _Py_IMMORTAL_REFCNT_LOCAL)) break;
      #if PY_VERSION_HEX < 0x030E0000
      if (_Py_IsOwnedByCurrentThread(table[i]) && Py_REFCNT(table[i]) == 1)
      #else
      if (PyUnstable_Object_IsUniquelyReferenced(table[i]))
      #endif
      {
        Py_SET_REFCNT(table[i], ((Py_ssize_t)_Py_IMMORTAL_REFCNT_LOCAL + 1));
      }
      #else
      if ((PY_SSIZE_T_MAX < _Py_IMMORTAL_INITIAL_REFCNT)) break;
      Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT);
      #endif
    }
  }
  #endif
  #if CYTHON_IMMORTAL_CONSTANTS
  {
    PyObject **table = __pyx_mstate->__pyx_slice;
    for (Py_ssize_t i=0; i<4; ++i) {
      #if PY_VERSION_HEX >= 0x030F0000
      PyUnstable_SetImmortal(table[i]);
      #elif CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
      if ((PY_SSIZE_T_MAX <= _Py_IMMORTAL_REFCNT_LOCAL)) break;
      #if PY_VERSION_HEX < 0x030E0000
      if (_Py_IsOwnedByCurrentThread(table[i]) && Py_REFCNT(table[i]) == 1)
      #else
      if (PyUnstable_Object_IsUniquelyReferenced(table[i]))
      #endif
      {
        Py_SET_REFCNT(table[i], ((Py_ssize_t)_Py_IMMORTAL_REFCNT_LOCAL + 1));
      }
      #else
      if ((PY_SSIZE_T_MAX < _Py_IMMORTAL_INITIAL_REFCNT)) break;
      Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT);
      #endif
    }
  }
  #endif
  __Pyx_RefNannyFinishContext();
  return 0;
  __pyx_L1_error:;
  __Pyx_RefNannyFinishContext();
  return -1;
}
/* #### Code section: init_constants ### */

static int __Pyx_InitConstants(__pyx_mstatetype *__pyx_mstate) {
  CYTHON_UNUSED_VAR(__pyx_mstate);
  {
    const struct { const unsigned int length: 11; } index[] = {{1},{1},{8},{3},{3},{1},{4},{7},{3},{8},{1},{6},{3},{57},{75},{73},{103},{73},{87},{95},{59},{78},{99},{105},{128},{107},{115},{103},{66},{94},{53},{37},{29},{18},{73},{28},{67},{38},{46},{85},{96},{101},{51},{59},{67},{66},{43},{60},{67},{62},{27},{76},{64},{46},{65},{131},{151},{82},{53},{57},{125},{61},{87},{68},{39},{50},{52},{49},{46},{55},{52},{7},{13},{63},{59},{153},{107},{125},{138},{131},{125},{86},{99},{67},{653},{87},{55},{45},{43},{67},{49},{58},{92},{53},{50},{38},{35},{78},{20},{75},{12},{25},{27},{43},{54},{54},{75},{59},{38},{46},{68},{83},{58},{60},{43},{40},{40},{50},{65},{114},{83},{42},{103},{21},{172},{99},{102},{139},{15},{37},{38},{73},{46},{54},{51},{64},{61},{26},{34},{56},{31},{93},{37},{31},{38},{39},{31},{13},{34},{136},{103},{88},{62},{64},{40},{176},{42},{36},{39},{60},{50},{47},{76},{84},{90},{31},{35},{38},{52},{45},{32},{35},{37},{47},{47},{49},{41},{27},{57},{59},{52},{39},{66},{67},{54},{41},{53},{60},{47},{42},{39},{31},{33},{34},{32},{38},{27},{42},{28},{25},{38},{46},{29},{28},{36},{74},{34},{38},{35},{39},{23},{38},{31},{35},{38},{34},{42},{51},{44},{41},{68},{40},{40},{45},{65},{49},{53},{68},{36},{47},{57},{57},{51},{45},{31},{31},{35},{43},{33},{30},{61},{47},{18},{68},{76},{63},{63},{35},{45},{32},{41},{49},{49},{38},{36},{33},{48},{70},{61},{41},{53},{48},{80},{107},{59},{60},{51},{64},{53},{26},{61},{18},{67},{56},{26},{36},{36},{80},{58},{49},{68},{90},{101},{92},{94},{53},{94},{61},{90},{64},{79},{71},{72},{59},{66},{70},{34},{41},{71},{69},{28},{32},{58},{55},{93},{38},{95},{59},{53},{65},{52},{30},{13},{5},{8},{48},{79},{90},{46},{61},{61},{49},{64},{64},{59},{64},{68},{48},{58},{52},{69},{91},{106},{110},{46},{64},{92},{49},{105},{64},{82},{54},{66},{65},{93},{69},{94},{65},{73},{114},{87},{120},{109},{120},{54},{51},{60},{128},{47},{67},{76},{58},{65},{71},{63},{112},{57},{80},{70},{62},{31},{28},{366},{79},{46},{69},{38},{37},{38},{50},{51},{245},{42},{56},{69},{64},{61},{49},{62},{73},{87},{76},{47},{70},{83},{89},{94},{178},{75},{104},{113},{83},{85},{69},{81},{50},{71},{83},{38},{64},{52},{16},{14},{36},{57},{49},{40},{44},{50},{54},{65},{68},{76},{14},{29},{15},{3},{55},{53},{53},{41},{7},{50},{42},{35},{36},{38},{20},{40},{44},{58},{38},{55},{51},{40},{20},{81},{67},{56},{136},{52},{53},{52},{26},{27},{58},{31},{4},{20},{62},{179},{39},{27},{38},{76},{23},{27},{13},{1279},{32},{85},{115},{47},{32},{68},{40},{48},{66},{106},{11},{83},{78},{44},{63},{57},{58},{76},{63},{127},{55},{72},{36},{12},{76},{58},{88},{62},{20},{39},{28},{17},{95},{56},{78},{21},{123},{55},{38},{75},{40},{124},{58},{78},{65},{71},{53},{46},{61},{60},{88},{55},{52},{44},{44},{54},{67},{94},{83},{29},{34},{32},{38},{38},{40},{51},{49},{49},{58},{47},{26},{37},{63},{38},{50},{63},{44},{133},{52},{110},{35},{71},{24},{60},{87},{74},{78},{68},{62},{90},{91},{62},{113},{96},{98},{88},{105},{82},{96},{50},{58},{39},{82},{111},{136},{133},{132},{97},{129},{79},{63},{10},{129},{45},{52},{30},{30},{46},{66},{36},{56},{142},{29},{72},{60},{68},{49},{52},{51},{81},{22},{27},{48},{80},{28},{71},{23},{48},{59},{93},{63},{48},{71},{72},{56},{14},{26},{38},{63},{80},{85},{62},{33},{61},{63},{39},{65},{42},{43},{42},{51},{55},{36},{16},{13},{60},{74},{94},{57},{59},{76},{81},{65},{70},{32},{69},{77},{74},{43},{50},{58},{33},{58},{56},{34},{44},{38},{53},{55},{17},{15},{30},{23},{27},{75},{38},{15},{68},{46},{43},{70},{63},{46},{39},{29},{71},{51},{85},{54},{52},{50},{75},{60},{55},{54},{38},{62},{68},{115},{127},{78},{59},{16},{72},{114},{121},{105},{142},{72},{90},{58},{20},{16},{15},{17},{17},{17},{149},{80},{136},{85},{178},{1},{1},{1},{3},{1},{1},{0},{1},{80},{5},{200},{3},{1},{8},{14},{16},{113},{2},{44},{42},{9},{17},{3},{7},{6},{50},{2},{149},{7},{8},{9},{44},{32},{85},{9},{6},{68},{6},{66},{64},{66},{96},{2},{25},{23},{6},{115},{12},{12},{90},{89},{86},{66},{47},{55},{42},{45},{21},{11},{141},{38},{55},{47},{39},{11},{12},{13},{45},{17},{19},{8},{10},{6},{12},{18},{18},{27},{42},{71},{77},{70},{74},{66},{70},{84},{48},{46},{49},{47},{41},{43},{73},{50},{47},{46},{42},{43},{52},{37},{47},{41},{48},{50},{33},{45},{38},{55},{38},{64},{70},{45},{44},{51},{36},{43},{37},{47},{47},{49},{42},{54},{56},{56},{51},{49},{59},{42},{44},{42},{48},{55},{58},{37},{54},{35},{32},{43},{37},{31},{26},{50},{50},{33},{46},{29},{33},{34},{45},{47},{37},{35},{42},{63},{41},{45},{45},{42},{39},{56},{44},{26},{29},{46},{35},{26},{32},{39},{27},{58},{41},{60},{43},{37},{39},{49},{21},{40},{44},{40},{29},{44},{34},{43},{17},{16},{21},{15},{15},{23},{24},{17},{23},{15},{21},{11},{10},{13},{11},{14},{6},{20},{20},{7},{6},{11},{8},{14},{5},{9},{15},{7},{9},{12},{4},{3},{19},{11},{11},{4},{5},{4},{14},{9},{21},{15},{3},{10},{3},{6},{4},{5},{7},{18},{12},{4},{5},{5},{27},{8},{17},{9},{5},{4},{16},{4},{7},{20},{5},{4},{16},{20},{14},{17},{6},{7},{18},{6},{3},{10},{20},{16},{15},{17},{11},{16},{16},{3},{4},{6},{6},{3},{7},{12},{15},{3},{5},{24},{7},{10},{6},{11},{15},{4},{5},{3},{23},{6},{7},{18},{1},{1},{6},{6},{6},{10},{17},{18},{32},{14},{14},{8},{13},{14},{14},{17},{20},{14},{28},{27},{16},{19},{23},{31},{26},{23},{27},{27},{25},{33},{19},{16},{21},{3},{17},{10},{9},{10},{27},{12},{3},{13},{9},{10},{15},{4},{12},{9},{13},{17},{17},{17},{12},{10},{10},{12},{8},{16},{8},{12},{28},{16},{8},{8},{15},{6},{28},{26},{19},{17},{30},{33},{16},{3},{5},{13},{7},{18},{29},{7},{7},{16},{18},{9},{1},{9},{17},{6},{8},{15},{4},{14},{4},{13},{11},{8},{23},{15},{26},{24},{16},{28},{16},{15},{16},{16},{20},{13},{7},{8},{6},{38},{1},{24},{35},{22},{6},{9},{15},{7},{24},{31},{28},{23},{22},{20},{24},{21},{18},{12},{11},{17},{14},{6},{17},{12},{18},{15},{17},{18},{5},{10},{4},{11},{7},{6},{6},{22},{7},{8},{4},{5},{10},{9},{7},{11},{27},{11},{30},{19},{17},{7},{19},{24},{24},{16},{16},{16},{16},{21},{15},{20},{25},{12},{17},{16},{12},{18},{26},{15},{23},{32},{26},{15},{12},{17},{6},{2},{3},{6},{5},{14},{11},{6},{4},{12},{12},{15},{4},{8},{14},{16},{22},{18},{3},{13},{8},{11},{14},{4},{11},{12},{7},{15},{12},{14},{17},{5},{6},{7},{14},{7},{11},{5},{5},{6},{31},{17},{4},{12},{23},{8},{10},{9},{15},{21},{20},{11},{4},{7},{7},{12},{7},{4},{3},{3},{9},{6},{5},{4},{5},{1},{2},{13},{15},{20},{15},{13},{20},{14},{24},{24},{13},{8},{16},{10},{7},{8},{7},{15},{8},{27},{22},{27},{9},{9},{5},{10},{13},{10},{6},{2},{5},{8},{9},{10},{8},{10},{7},{8},{14},{23},{15},{6},{8},{30},{12},{12},{14},{8},{17},{14},{8},{4},{13},{9},{9},{9},{19},{27},{54},{14},{18},{13},{24},{4},{23},{36},{5},{10},{11},{19},{16},{10},{5},{5},{11},{3},{6},{10},{15},{28},{10},{14},{10},{4},{6},{8},{4},{7},{9},{11},{11},{9},{7},{3},{14},{15},{18},{22},{18},{26},{33},{12},{13},{29},{28},{27},{18},{17},{18},{23},{14},{15},{31},{6},{26},{30},{13},{8},{11},{16},{14},{17},{38},{14},{16},{12},{15},{9},{19},{24},{17},{20},{18},{11},{37},{6},{10},{16},{23},{22},{26},{17},{4},{26},{23},{20},{19},{18},{22},{28},{27},{32},{16},{29},{13},{24},{37},{8},{17},{31},{7},{4},{20},{17},{14},{15},{7},{4},{4},{2},{4},{1},{3},{2},{12},{10},{24},{24},{15},{16},{14},{22},{13},{18},{19},{28},{27},{18},{24},{14},{20},{14},{26},{12},{17},{22},{3},{6},{3},{9},{10},{10},{11},{3},{8},{16},{25},{4},{8},{15},{13},{7},{3},{8},{13},{13},{17},{17},{15},{17},{11},{16},{12},{20},{20},{12},{16},{17},{16},{17},{14},{19},{13},{16},{18},{17},{9},{17},{17},{19},{23},{5},{12},{10},{3},{10},{26},{8},{17},{10},{12},{13},{14},{7},{16},{12},{7},{10},{14},{6},{15},{17},{34},{19},{19},{11},{13},{9},{9},{11},{5},{2},{4},{14},{3},{8},{15},{17},{24},{26},{19},{17},{4},{8},{27},{13},{19},{21},{23},{27},{9},{10},{21},{8},{10},{15},{29},{26},{16},{13},{17},{19},{16},{21},{17},{21},{22},{20},{10},{11},{15},{12},{22},{14},{20},{3},{15},{13},{5},{12},{9},{11},{18},{10},{12},{4},{5},{14},{23},{4},{26},{5},{15},{14},{8},{24},{19},{25},{20},{27},{27},{6},{4},{9},{4},{4},{5},{7},{14},{23},{8},{13},{15},{32},{46},{11},{24},{21},{11},{15},{9},{14},{7},{12},{13},{11},{8},{3},{16},{15},{6},{21},{17},{7},{17},{6},{4},{11},{10},{6},{10},{25},{19},{12},{5},{12},{14},{21},{23},{16},{14},{15},{4},{8},{14},{11},{10},{4},{8},{10},{4},{18},{9},{29},{17},{19},{29},{10},{15},{4},{9},{9},{5},{13},{11},{11},{12},{20},{19},{3},{6},{4},{7},{11},{11},{7},{15},{14},{14},{3},{8},{16},{10},{6},{18},{15},{13},{2},{7},{7},{10},{13},{24},{14},{25},{11},{19},{30},{21},{32},{7},{24},{6},{20},{4},{7},{7},{12},{24},{18},{15},{10},{3},{4},{33},{15},{46},{3},{4},{6},{12},{10},{8},{13},{3},{15},{11},{12},{18},{18},{4},{13},{10},{11},{15},{13},{8},{7},{19},{22},{15},{29},{9},{10},{14},{27},{3},{4},{6},{18},{18},{30},{1},{12},{5},{9},{13},{10},{11},{7},{9},{2},{9},{6},{8},{6},{11},{14},{33},{23},{22},{25},{17},{28},{16},{9},{25},{19},{18},{7},{20},{21},{13},{8},{3},{7},{28},{16},{8},{9},{13},{17},{6},{10},{14},{12},{6},{8},{14},{3},{3},{6},{3},{15},{18},{21},{9},{22},{28},{12},{9},{20},{11},{6},{12},{18},{7},{14},{6},{1},{11},{13},{17},{17},{8},{23},{15},{30},{28},{13},{6},{18},{7},{9},{10},{10},{21},{15},{15},{14},{17},{17},{14},{19},{18},{15},{16},{18},{20},{11},{21},{11},{8},{6},{7},{23},{7},{9},{13},{6},{4},{17},{8},{4},{35},{37},{37},{32},{16},{30},{22},{17},{24},{4},{17},{14},{7},{19},{19},{29},{29},{13},{8},{8},{14},{18},{12},{26},{20},{10},{14},{16},{23},{14},{28},{30},{25},{13},{6},{5},{15},{13},{13},{15},{4},{8},{10},{6},{16},{6},{11},{5},{10},{10},{2},{8},{11},{17},{2},{7},{5},{28},{10},{18},{12},{21},{23},{29},{16},{25},{9},{21},{10},{10},{4},{12},{5},{6},{11},{17},{6},{27},{4},{7},{21},{10},{14},{15},{10},{10},{3},{8},{5},{8},{3},{12},{10},{20},{31},{7},{13},{6},{3},{11},{4},{25},{11},{3},{6},{18},{20},{11},{16},{9},{10},{6},{11},{16},{20},{24},{17},{18},{4},{18},{7},{11},{9},{9},{14},{8},{8},{4},{12},{9},{5},{4},{12},{9},{17},{16},{12},{21},{20},{16},{15},{9},{16},{22},{9},{7},{15},{9},{12},{9},{8},{24},{14},{16},{18},{17},{19},{5},{2},{7},{5},{7},{3},{17},{18},{16},{13},{11},{9},{14},{8},{14},{24},{17},{36},{7},{15},{20},{39},{6},{7},{6},{11},{19},{14},{6},{16},{24},{15},{18},{20},{24},{20},{7},{12},{11},{22},{18},{5},{3},{10},{12},{17},{11},{21},{7},{12},{13},{3},{5},{6},{18},{14},{12},{35},{8},{13},{10},{9},{14},{7},{6},{15},{12},{17},{18},{5},{8},{7},{16},{24},{6},{14},{18},{9},{24},{23},{37},{13},{10},{10},{18},{42},{48},{43},{42},{46},{46},{42},{44},{40},{40},{35},{31},{30},{35},{37},{31},{39},{21},{19},{22},{39},{31},{34},{29},{37},{48},{47},{36},{39},{37},{32},{32},{53},{16},{31},{37},{27},{32},{31},{28},{30},{28},{27},{21},{19},{23},{37},{31},{38},{1},{8},{74},{95},{157},{5},{6},{5},{2},{140},{84},{73},{73},{63},{40},{97},{7},{345},{55},{80},{13},{5},{9},{7},{5},{1579},{7},{5},{64},{238},{9},{7},{16},{15},{25},{145},{173},{153},{99},{25},{47},{89},{10},{202},{42},{109},{13},{54},{198},{95},{63},{156},{16},{16},{5},{10},{12},{69},{11},{10},{5},{132},{2},{348},{20},{9},{6},{51},{9},{5},{8},{2},{5},{2},{2},{2},{2},{2},{2},{2},{2},{5},{23},{48},{3},{7},{3},{7},{5},{2},{18},{33},{174},{64},{29},{12},{9},{3},{120},{19}};
    #if (CYTHON_COMPRESS_STRINGS) == 2 /* compression: bz2 (21832 bytes) */
const char* const cstring = "BZh91AY&SYp?\252\212\000\0246\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\301@\334T@@@@D@@@P\000\300\000`l_ww\337\033e;\335\365J\373\275y\356\003\312\333\004\003\267v\203v\000\000\000\000\"(z\001\345\037\001>\276\206\217s\347\016\203`f\353\267\014\256\3124\000\r\n\024(\031$\330\035z\032\000\320\006\203\333\257\242\321\214i\254\007\332\354\367c\256\367^\275\330\2334}oe[a;\252\367\273\317s\354=UQ\333\003\355X\003h\275{\222'\273\207\336]\267\025\276m\365\367|\345\336\366\373\337{o{\317J\250s\340\016\356\251\256\337N_w\032}\007w\331\317\251\366VN\334\327u\212\335\327Zt\325\335\256\343\201\364\366\346\340\000VC7\201\232]{\336\356\373|\000\212{\333\272\244\213\355\357>S\336s\336b\013\313\337wjx\365\355\352\367{\276q\367\262J\274\371\356\275\351\356\307wv\272Y\353\331\333\357k\255\254\2662\324\256\353\341\273}\236=\366\371\000\000\001\320|\240$%4\204\020\023&@\032\000\000FL# L\002x &&\206\232\032\023MOT\3744\230\221\232\232\233\004\364h\247\250\362\230i\220 \211\241\023Bjd4\2314\003S\32412\031\031\r\000h\000\014\200\000\000\r\000\001\240\000\t\004\210\220\247\251\2014\233M#M#cT\331\250\232\032h\000\323F@z\201\352\000h\r\000\r\003A\2404\000\310\001\nD\202\004\32052\233E<\247\352\232'\352\217\024a0\000M\003&#\010\3102\014\200a4\300\004h\31042\030\002$\210\004\320&\200\202e5O\323\322\236T\317SS\323\324\365\032\236\247\3514\237\2451\003@\000\r\000\000\000\006\203@\000\000\022j\"\023M\004\020\004d\325<\212~\250\374\244z\236\247\243SOH\036\240\000\000\000\000\000\r\000\000\000\000\007\377\241=\234N~\236\334[=m\335\013\007>x1\360d?\365\232\024\322\232_\220\273\006\306\306\231\363\276dG\362\3777\320\377\257\367\027\374\257\366\372G\323Z\250Z>\236fff\246\266&*%\333\376\223\t\0036\010\016\036\232\355\005\377$&\261+\376`\311g\213Iq\261\337\357\236/k\332\362|_7\343\374\251\261j\371\232\301\374\352{\266+\330\215\213\026,U\252`\027\377\346\363\177\234\301\201\320\204\007\270\356\035\r3.^\376\333X\267\314+\353\257\243\007\r\361\003}\330\310+\273\014\211\252""\"\226\212hh\241\211\010\200(\002\202\232\026*\"\246\242\030\202\251\244\210\244\252&\n\231\250\226*\203\027\2570\236\232\325\207\242\260\222@\315^y\347\330\316\031\253\263Z\376\034\237\207\374\177\326\227\272\265[\365r\320\312U\373\220\3739\177\262\330\037\356\333\216\233\226\304\345\303\002\304-c\274V\023\366^\036\205%\236(\267.\377X{A\370\240\246*\026f\222\224\nB\222\250\026\t\271\030\021\004d\345E\r\006Y\"\006N \036\2773\333{\212\205\317Z\342\\\330\372h\\hX\230\226\374\006#\206\327\202(\230\210\230Z\370\336\2724\037K\303\275\017\ti*!\242\225\240\242\352`S4D1\331\3149\314\304\200\037\226\236r{w\2344r$\tnl9\324U3U\024\200C\361\245\365\216\262\230\025\350\311\006kZ=R\3303\235F\256S\273\347u\002:\340\354a\251\371\370\234G\025\312)\"\355$(\252$\320\3217x;\033\032\030\374~<x\240(\214\021X\247@ZC\257Sa^\235\r\315\303\016.\037a\257P6;d\345\226\272\353\320\351\277\337C\246\3666\206\305A\224Q\276\346\357\353|N\323M\236|\212\260\262\333\266\333G\224\345\306\236~\217\315\355\304\362A\210\233\325IG\027>;\224Q\306\305\255\002\334yt2\310\371z\352\255M]u$&\207C\247\326\231=\371\344\3544\361\323\216\246W9&\203\347\271\303\204\255\247\354\355:g\033x\2609\000\250\201\373\016<\270w\340\344\361\316\233{\316\365yR\215\303\270\337p\375-\3613\201\t\323ck_\256O~\207Ly~\211\3154\333\317\326e\351\320\331\371{\245BaTL:N\343\253u-\307\025\231\2005Xf33\376\037\355\246\264'-h\233\017g\320\236^\276\265\327\360\217h\333\237D\210\254\350\342\033m\364\205a\246~;.\200\227\307\373\306\200y\237\342\277\351\366\037\307#\210M\260\233\375\256\361\245\262b\234fB\265\304\230\343\335I\266\334:\315Q\336p\235\265\263\251\305\311q\2546Vl(zs\275\333\376+\234~\0238.\241\311'<[\371m\030%0R\0342\331cA\217GL\356\275\007@\327\031\257+\241B\034\231l\200O\367\342\237\275\024\307\035\364\271\334^\326j6\212d\353$(\277\375\361\271u\332#\300\206\204\254\260L{\007M\371\307~\264\032#\372\266\020\340\035\373\3061\265\376\365{=\350*\344K\211_*\376\304\313`\221D\332\024\004\241\317\373k\326&\\\270\375\005\002\004-\020\336""\333\200\022\303\210\037\317\303\274\227\000\374\351\022\005\036\010\255\0242e\374\366\3439\255\201\004`\260\177\336\254\234\002F\347\366\363\352\034`f\377~\371\340ip\372\324*\032\322\327\366\360\375T\2141\313\347\274\207\230B\320\244\203\317\372~\216\343\332\2512\266\377\347(\177\233\215>\177J\265\342B\225\177{\327C\337y\373\020({N\177\251\340|\361R}\330wo\231M\211\034\205\034\031.m\273?\227i\025W\035\2350\230\343\250\022fIM\242+\336\273\360\345zO\226\242\223\222\035[\177\002\203Me3\262\014*\231\364\346\347\024\026j,\335\027\271\223\"\212\327#E1*\330\263\234\247j\230\277\2628\223\275\014\353v\341\002\n9h\377\355\223\013\034\257\374\365K\212\336$\373\375\255`\021\333?\202~;\034\357\177\026^L\226\224\016a\304~\020\201\361,\325,N,\340\344V\375\225:4\rB\n\326\257\263+\222P\312\233\023\366\337R\222\242\305ufX\002\366\262 \\(4?\202\034\363z\301\356\361\245k\313\277\362\265\003\374\230U\370_\237]q\rq\225\247\376\277*\307\316\2632>\\\0040[|\230\332\343\0375\362\340\313\330\372 \275\374\275=![\366\304\264\r1|Z\373\236\345\312\324\225)x\242\251\217\035\033\334\332\326\202T\322\307\332_Z\300\375s@0m\340\263\241R\325\020\325\232\362\2221\375\347iV\211\223\215#7N{J|\033\020\033A^\300\264\2456.f%\014\323\340\375\273\262\032\330\252\330\327\273L\246\022f\314\322\276\374q0\263m\032\367\256-8\261j{%\270}\230\2631+\323B(H.\311\255\301\264\210\3766\243\202\214`M\201\200b>6\263\340\374\215}s\336\255\237\n\315%y\356(\310\311\276\235\235eI\355\344\220\302\250j\314:j\252\233\266\365\265\345\027\275>\225\231\241\265V\321\037A\353\226\374E\343\311\205~\347\rG\214RM\363\205\230\335\nx\013\333a\017c\016\026\005}\t\334\274r\377X[\307\253\247\336\243xP@\223[\277H\236\037\033\305.7\025\213Z\343\243\\\253\340G\026\033\324\341\332_\000\210\270\334\242\364\266\204\027)$\021j\220\361e\016\240\\\332m\230\343\274\310\330[\032rN\322\034\275\347\303\214%\300\342\"}-]\323j\365\376*\356\333B6tw\023\010j\370v\034l5\216 >\230g~\2627\214\224\344\264\227\004\361\003\311\313\023Y.{\300\356u9\326W0(\022\002Gqy""\220\206Ng\221\365\377\035\367\331g\034N\217\264\017\236D\300N \212L\344\217\264\231\001\224\271Y\010\267B\303\270\361(n\036c\301\023\214=~\227~\270\363\315\363/\312\306\354\274\306p\363\374\031\320\037r\276\247nA\355\365\036\321\r\360\236\2653\217\232\314l\3257/\260J^\213\256Sd\351\301\214Y\344_B\370\327b\233\214\225J\315\207\014C\303\034N[\342o15\311\364\2523.|#\367a\353\3579\356\371N\021q\213\256\301\017\225\374=\325\325\017\244_\267\245|\355\244;\237B\007\274F:\357\327N\007\036|o\034S\r\304\312_}\302\314\326\nv\254\3465S\036\206*\340\275\364\232\222\315G\265v8\3172\032\t\211a>j\207B\2612\004\330pF\207vj\200\211gA}\003\342\332\033\031p\330#B\304\343A\001\276q<\234t\002\375/\265\271\241\2226.29(\026\2153S\200\023r\360\304\";\t#\022\033W\221k\263b\307\331\0340\177\322\365\010o8C\005\333\322z\201\307b*.C\202\324w\363\306\207\313\273c\333\032\034\361,A_\210\363\"y\372\352\260\201\277J\360{|\316.\030.\366\007\216f\265\324\273r\343\201\200\302\311o\240\255\213K\365\343\351n\206\343\371\031p=\234g-\373xc\225\341\271\303\207\002\347+\333\220\374\221\321\302H\315w\r\016\270\255\013\333H#KT)\337y^4\217\335\350\241\303\226\352(\252\237\263\033\276Yx\0168\036\032\002\000\215\366\264\303\240ZFF(+\037`|=t3z\371\222?\247\337\222\033\323\246\355K\255l(\347\241\336\366\017Qb\032\007\014\n \224D\032T=\315\364\\\277\327\3737\256\265\201\3469\206=\256\017\205Gf\245\200\247#\243\247w\374\263\036\3606(\357\000\275l\361\350\240\035\325\207\177yMK#\352\207\030v1 \255)t\037\340\235\304\372<\315\302\252\205\275\202\252k\262\031/\204#\023\245\245pT\014x\364\201\274k\250E\"QF\002b\311\214\027\007\330\300\215\t\017\260[\220y\n\355\241\230\343\034D`\300\261\016\223\352}\210\234\341\234\217\326WL\320x]Z\266\022\332+\260\367\304\037^\037\"\203\366\r\355<o\350\277\276\003\021\200#PW\206\221\351Zgq:\347Z\202\341\250\341\341Xw.\321\306UZ\016LS9$_@\276\343|\010\031\304\214\276\311\3673\341\332A\360pvi\321\tC\263\225\2100\002-\320!J\363k.\244\200\244Yh\302\264\035\250;\303\274EIn\213\007h36o\257""\255\001\317\tv\t\225\323\036\203\341\330XN\364\014R\0250\204G\317\274{\365\"8\316`l\227\033q\020!\306L\322\0337|\304v\006\331i\342\020:X,\300\214\022\r\351T\004\0174\000\220I\321\r\323\240\327\271X,\034%\016u\211\365\343[\267\255\270\2024m\320\005\360\206\301\323A\217\301\270\306>\227\277\327.\347\266\244X\201Q\334\227\005X\356(\266+\242\367\364b\033\210C\035\356s\212\020'\0268\222\0348;X\267\241]\222\2065\202\376&1\000\273\220X\232\300\310\023g\343\234\027\267\314\322\317\236s[\007\031\307\014\017E\223d\263\363\016\031\331\206\276\017\030\301\356B\350\257S\333\262\024\005Fw\266\031\310\334\336D\3276\035\227\351)3\352\020~56H\300\225@\202\270\374\027\373\317\355\213\347\360\365]hy\367\006=T'\256\216]\2447gL\272\237\2373\240\010\237G\232\3744\004D\004\356\002.sv\260\244\217\304\366<\003\342:\221\221\254\325\002\001n\302Fl]V\246\211 \223\262pb>@\313\001\257\033\343\360'\246\245\221\333/\362\004\220\304\217\230r~r\251\270\350xp<p\336\357\025U\273\377\257\3108}\372\037\26008\036)}a\303}8m\n\347\327#'\327\305\271\246\220\033\346a\302\226\351\017N0\200!\360:\2700\271d\371\341,E<8\276D\201\350 <w\252&X9~C\201\034\240\na\022\007\2343\270\365\353\017\312I`P\262^TO\315.E\323\226\036p\201\360+\235I\337\262\360\257k\300\367\300\347 \014q\307\231\357p\356\031s\030\363\365\264;\277\346?\033M\351\204lC\347\\u9\360\302\375\337p\256\304h|p\0316\207\263\267\202\324X\220Y\372\025\346\006\007vl5E@\21641\351+\201\333\222+$E\007\256\273\256:^\276_\274\311m3r\303@\262t\302\312$vA\026\035\270\000&\002\275\344\345\"_Q\366\210\033j\364\325\236\363\341-\310\325\004\314p\007\301\273n\030+\010Z\320\007:\227\314\035\221\030\365\316>\337>\310\306\362\274\2170/\221CZ\240\t\017\3337~\200\300B\236J\035\357K\250\316B\032Mi\2313\302Uqr\316\326\272\310 j\230z\221s\200\344\202\350\006p8\305\360\220\035}\351\301\372\215\314\356xo\333\345G>!\201\205\002t\266\035yY\306\347\206GmV\303\205u\326\271x\2770\014(M\315\t\325\234\010x_\\\350\374o\217\221\267M\361\3566\223\252_|\225X\360\263\016\335C\035w\364\311:""3\330\265\037-\325\316\337\022#\352?\020y\365\254Oz0:\271\201\016\367kd_f\307|\021\000z\374l\207\260o;\356;\357\363\276\315Y\357\217sg\352\246\010\206\" e%Iw\001\331\3663\232\370\323&\347\271\032\177-\303\010\321\246\273\372\274\361\036*\340\255\252\010\367\373<g\341\343\227;/\3060^38\366\026WL\264J8\240\373Y\234\316\2434a\352\236\314\\gc\225\\r\273\02047S\326\241\207\301\303z\013\274\003\3501\034H8U#5C_7-\036\221\253\214\014\261\340y\227\202\027\221\371\031\320\205Hh\222;\017\224\255\241\340\002\007|\260=\246>\232\212\330\224\226\206\177\003\254!\361\256o\341b7)\347\352f0\026\372\3130\010\200\006\310\000\3415\355j\r\016\223r\035\234\240H\244\222\203gc;Z0\270\357<R\215/\024\333*Z\226Gv\272\343Z\324\326q\225d\214\313\2000D;\222\337\363Ee\304\262\277\374LO\273\327\336\372l\360/\352W'\342#E\r\211\237U\230\363\263\262\037\325\360\010\331\025\330\004\335\263\337\r\345\242\244\254R\301\353K\230U\250\215\253\223\301\271\373\267\314\306\325\240@\354\305vK\327jFq\367\334\214r4\330m\256\206,\307\303T\315\220\027\311\331\227\341\330@\207*V\361(\260!\201\357\001\253Bk\250\217\273C\322'\344\301kR=\207u_~\313>@\307=\010\010vt\207_j\366\334s\255g\333\327\270\2403\317\335\346\236>\271\010\374\035\317\330\330\033\307L\013y*\217=\222\"\003\221t\320\327O\024zw\036D|\263\365\256g\026\231u\001M\361B\007\230p3\177\201\251i,+8\207v\037v\035\321r\004\237\253G\313\327e\211v\275,QK\237\007\037\201\220\337\254\334\232j\257q]p\215\376\013\310QD\320h\222\225\310\315af\031]gj\273x\035\246:\265\007>0\360\365\321w\000H^\030\214\203\303\352o/\322\245\030\320\326.\034Hti\377FE\207\t\340\320\223\001\346\240\024j\245\351`C\312\214\240\236g\232D\237j\2636B\364\327\256\3373\277\340\356\212\305j\325\376I\274UKv\333\323\361\023\025\237\275\010@\261f0\262Yk6K\254Y\327/\237\3679|5[\013\321\246\352\275p\255Z\373\366{\330M\2323\263t\317\307\005!\325\243s\321\257\0377NBd\224\333\372\245XG\275Eh:\n\303\265T\031$BQIK@P\024\024%1.\302\000rA\310\023$$\226\211=\332\312\247LDf\024r\323\242)\"R\203\013-F\263Zi\311f""\252s\020\306 \244\240\010a\030\202$(X\222\224\241h*\n\020\313\211\321\t^\022\344\224\20214\324\324\3224\0215JD\024\245!BD5L%\021\205\220\205m$\300\220\351\220\220\222l\246\3050\313\213'\033\340\206+b\230\270\255\241\2177\343`\300,\260\326X\2635\203\350),\033\370\242j\332\330\021n\202XW\315\235\033MDN\324Gg\333\253\006\017HY\207n\307\363\2737\361\356\245\035\r\277.\245\203\217)H\255\340\t\371\214\001\266\306gN\003nN\343Xb\301\\\255\221\251\362lFR\305l\255\203,\317\267\340\374W=h\257\217\311\035R\037\242vV\007\275\000\366\262\033A\r\222\037\205\204\300\375\250J\n\242\241k\303\036\r<\233\035\343\010B\251.\t\351\237\303\tEy|\316[U\2127`\305\274\307\255'\353*\313\322\207L\222\365\270\352\371lv\234!\027\264\347\271\n\2024\227\227\001\311\354hg\0130\3143'&\356v\000\354\326\276\314\237\222c\\\0236\"H5\371\273\332\302\374]\357\350\203\333\326\211P\346\375\030?5$\3128X\267\026\261\203\221\2008\202\010C\273^\307\312\334\213\005\"\037\227Z\024\2611\205D$@\370i_\221\003\030\251\2069\331\267\311C\254\225Q\301\247L\3153U%\004P\340\352\353];8\274\353\275\247\301[o\217\322\311\275\021\276\201\220\303\001g\365\035\223\221\276V\371\271\267(\rW\305\326\353cb\262\305s\031A3u\\\275\267\177\016l\306\204\n*L\206\254B\264\203+\037\256\264\357\366\262{\026n,\373\n\032U\360\240_\314\345\372\300\241\307\333\304\272R=}\265\202\004/\323;,K>2\235q\355\023\033Ty\255\006\r\371\037\310\374\277\347}\343\017\222LW\362\037\036\263\312u|\361\211\205\317\037\024\260j\276{\205>>>Z\326\t\226*\233iSxC\204\200\244\007$\224\277\243\242\354\326C|Aa\225\262\305\006\240\243\214\250\202\013\250\216\243P\311!40\234`a\206\005q(\034\361\003\030\315q\n5\260\007L\213\332}\214}\205\257\275\275\261\233j\270q\035<\234\026\303/\326SON$\256\252\2740Q\244'\"\235\364\351\242\006t\314p\r\342\377\326&\022\302\301\206&\026\244u\372\270\032?\270\213\301f\350\312\027\243\027\207XQA\216\324\020N\34149,Y\r\233v\311\213\014\310IR\212V\215h@\226,\301\202fu\0344\031\234\302\013\356\257K\301\343\270\n\335\314f+\362Vk\014\326\002\300""\362\214 \361\2323L\246\021j-\005\205!\374\021t\312e\253\361\336b\344c\010\310\203\021RT\2510a)\246\036\022J\022&\232\017z\357\250\302\306\370\260\264\265\177\266\2361\247\357\303\335\324V\314\013go\023\034\316\307\177\n\366Xc\232\231\264\353\271\202\235\206d\214\202\301a\251\252\335\327\306\257\221k\227_\277\377^X\032\014\026K#Y)k'1\265\253\223\317\261\341\311\267}\023d\357\320X::\364j\254\303\311r\200\263\224\336_l\306\224\212m\320\021\"\326.\324\023s\033\026\356\006YR\243T*b\342\325\271_g\241\370\312\337j\361h\263f\313Y\341\251R\232\336?4k\341`\343\367\357i!\037\312\033z\373\177\026\350\377?\216\231\3719\363\034\372e5\nxq\367\352\311\364s\356\357\344\360o|\352\237)\367\213\243\2404\367q\331\361\315`\3031\227\233\035~\214(\020f _\226@W\357$\335\220\346?{\205`\215\324\027\017\036\206\014\363[\270n\251H\341\350m\342)\377a\031\347n?vw\246\235\275\036\306\270\226G|s\030\367>\3612\234f\004d\221\216o3D\277\272\326o\232&\017*\035J)\031EP\321\205\231x>\377t\335v\315\343w\020{s\324dc\230\336\210\231\372\221\207\316z\260G9\342\375 Y\236\317T\213\214\372\330\251\307\225\035g\371/\032[\222\2619\361\330N\320\261\31089\304\333\3278\364\335g\213\004\034\010c\243\352b\374\353?\305o\230w\307\355\007Nz\373F\250i\207\0177CK\230i\026\261l\326/W\342\257\326\351pY\372\253\254\340\227\005t\300\\con\263v\352\340\256o\ti\217\021\363+-\000N<\024,6\236\203\342\020P\325C\301\341\336Z\212\372\372\335s\202\220\036\275y\r\020\215\2641\246\326B/-\224\215\025\212\272\323\354*\201\316\025\241\177%)Q\037\212`\214\002\376\314YP\323\032\344\034\235w\234X8\327^5\005K\276Og\246\366\231\275\034\340\304&\004P!9\010\303\342\303\311\202\020\304\327j\310\246\307x\031hi\217\334\314\003\351\361\333\347\344Y>N\210\205\206\311Q\246h\224\213\1776}\336\343s\253\233\360\365oD(\034\n\354\003\214\340\220\247;\300\360>-5\240\326=\212\372\323\275kt\224Y\264z\347\320U4=\005$|\347\2047\016\227\364k\246\247\253VQ\237\3207\344\r\376\307\344\323\000\244{\323\263\032\010\035\025\231\232mX@\255P\241\216k\035\205b\277\331'""\370\252\026\313\251k\220\022\371\021mh\353\271\226\202\027\370\\\305\005\332\215\331<v9\323\224\274#\270\373\223\356\302\004]c\362\251\377\177Z\257\353Z\374\213\315\267\030\325\233\277\314\232\307\270\332\302\274?\254\216f\347\356?~d\350\004c\301\265\230\334Q\340\345\250\341\363\344z\242L\025\246T\\\034\217\256\314\025\270\325\203%*\2231\230\323I-\271aiV\220t\316pt\315\346nf\376\357@\333\336\347\0345\025\013C\365|\017\305\270\256_\375Yk\213j\"\000b\256L>T\320X\207\206\240\0218FN.k\212\332oZq\036_\206\233\370\255O\223\005\337\366\215/K\017c\322v|T\232v\013\3024\320\224\263fP\315&\037PQ\267p\267\205\213\222\377o\253dt3Zj\274\215#\3726\356\343)\250\373\177M,v1d\005Nd\265T\237\027_\025#\027T\235\243u\310<\210\305\262\3170\317\035\325\370o\224\002S\215Q\210\323\r\r\260z\037\263\344<\213\310h7\311\221\254\334\322<\337\341\200\314c\244%\\2\3043Z\305\216&sN\323piBc\362N/\024\317\255\023\017\247\252\354b\363\314\210R#a\307\313\314L\360k\203C`\212\314\267\231k\330\3146\257T\312\316\2273++\013\027d\307\346\363!\016e\376P\037w\261\006\203&\233B\254iT\303\301\232\323\300&d\3304`I\021?D\013\242)\313\200@\373\207\254.\263\334\204{L!\266\354\030\\\032\253,q0\314\226\302\316\312\317Q\201\224c\345\204\352|\310\n\0148\200d\231\263\027\002`h$\201\263jV\233\2536\215wUkd\354\225\244\246n\336vq\265\265\247\336\323\357\327\355\350^\256l\233#\376\216\206\246?WR\235\315\016u|\334F\256\222\014\3631\340,\205$A\034l\351$\211>\364\320\317\317\234T\275+G\271PuF{\312w`\373\235\324\263\336H\214k\017S\263\031\347$t\225}H\264(\263\240hhhvz]#\345\364QA\245\244e\233\253/=\303y\255_\360\256\256\316\310X\273t\346\265\253\357;\033\334\\\315sY\001\257\220\302\262Y\262V>K\036\325\347=\236\2430t\3233W6\271l\206\277\260\372/\263\n(\314\0313{\r\033\271\323\0134\337\t\372\265\347\201A\265\267-\254\371\021\"\341\354\\\261n\371\353\265\361p\013\000E\252T4\225\225\321\006\332\023\001\204\201\266\343\320\236\374\2073\250\340\221Jb\352+A\227\260\302\004\310\236/\3619\325\321\3176:^\016\265\216\rz(\347S?\243S\202""\316\006f\221\316C\032;Y\370\032\250-l\205\273}\336=&2\325v4+g\366\006\276m\213s_48\033\316\344*0l\364\253ma\231\372\272&\355A\316\263\204\374\314}\350\315R\n\020[\353`!\274\274*$]\375\235\263\263jR\265z\026)\316:Y\306v\277\037\036\325~\244\330\375V\262\214I\262\263\337\311~h\266\177O\022\0012\n\331\346\303\304:\213\017\332\306\307\216u\207a\321\004\334o\331\321\236\021Q\214a\303=B\024u\030[\361p\227W72\333g\367\260\021v\274\001\321\220MT\016u\347\275>=\001<'\310w\344zG\221\371\337rN\263\263\341J\327\241\341\274d=o\026\361\314#2\311\t\211\032\250&P\222\2231\006#\215\206\315\277\253\215\332\334\2777*`_\363\334\200\357\02220K\356\216\236~qT\247\241\n\354\334\250\025\214\254\222\265+\007O\027{\334\345\027r\202\3259=\231^\347\231\033\177ok\262_\231\031 \032\2467\345o*l\223U\230\t\204\304\241\2571M\371{5\353\025\320\246)\241z0p\365\"tDe363\255\314\247\232\"S\242\202\353\353.x\020\264\020\211Az\361\270d\007\264\276O\273'\267\275\233\246V\361\230Ss.p\370\302k.:\267\276=\356\210\310\242w\204\357D'\236rl61+\331X\2211\211\r\301\034\223\"\340;\023\206D\242C~\245\335=\250\014\221S\215\366\343(M\2242\310K\251,\250\203\340b\266'\364\315\366{\360/\355\363\260H`\234\357`\224/\367n\214\026\3235\274\375\036\305\004\3713\345\275u^0F\221e\250A\323\214B\362\003\250\\\211:2\305\"\210@!RR\250U\330\234\357\334veq3>^M\324\207\205f6\243\211\246\356z\032\303]\356'\237\3469\246\332\320\344\017F*\336B\244\210\262'\002=\2422t\272\201\t\225\032\017\303\032\364\306\220L\320\256\346\316\212O2\2613\264\313\017i\333\202\305\334\215\2269\241\250\032\203s[W4\177^g\216'G\311\233~\331\271\340m\007W\003Rq\246@iMU\367!\026\243\254\202z\222N\3655\372\300W&\210WJ\211\312\240V\221Y\244\212\3416\271P\004T'l\263Z07\026b\357\251\n\302\316P\313\247D\271=\335\001u\354\317]\336\276za\362\2705,\303\314\t\371s\237c\254\247W\010\"\035\032\263\032\3145I\375\332\363\371\354\313T\325\r]V!\251\374|&Q\324Mw2 \264\243\225\237c\240\020\266\306\316yZR*M\234bw \3512\250\032o\001\263r0\3730\221=\351f`I\212d\213\320|~\276\325""\371\252\032\332\300+\205\026V\372z\257\246s+\347gt\362\245A\250\314e\2722\213\001\253^A\346P\275(>5,\317\340\206%3\036VO\322Z\267.\\\271\204\326Kb\231\246\233\241\325\357\316\371\345\345\016\006\334\306b\261\224\004\356B\377\020\271\233h\265h\321\340\370\365\375\316\227\236\313Rv0|\232M\271k/\231\226\371\375t<\027E\314$\356\342L\361r+\234a\271\345ZIW\230\330r\2116Y\301\335\274\306\2162)\344~\255\334\013\227\016O\3603\220\003\210=\306z\347A*\355\2651\310\340<i\207\3659\337\202\261!\306DuQ\022;$\311\362\345G\217C\371\177\006\037.C\265H=\022\344\316\275\347\320\376>\372\361\320\026\257\321\267\327\351>\256\311\354rh\177\274\315\223\3237\014\370\030~xs\255B\367\016u+E\246\242b1)#%\315\347\223\306/t\361PT\024d\223T\201Y\241\260\214\316g\216y\347{\031\314av\236!\304\nT0x\t\023\016+\215\214F0\207\232\300\252X\221\236\302\256\331o\003\220D\036\3231\274v\375\343\353\232\307\273m$l\303\322\003\0247\233\273\355be\373?\252s'\334\321\354\234\314m8bk\306l\223$ d\345cT\304\243w6\234\313\036\\\n\374>\2175\022\261Es!\341w6Q\313\036o\004<z4\312l\331\261g\336<\223D\367(\234\260\356\037[\\\201\365\375\236\372\311\235^\262\223\231\r!\235\010\211\365V\343\321\000\363\231\273\000\201\003\007\263\004)\314\327\3418\022c\304e\373\301R\346\374#\346@\301\302S\\\372@\025\0334A\006{\334\317\253z\266P\023c\r\315\206cM\263\311 \026\216\020e@\204I,\334p\2309\217\315-[#!+TE\234\326\372\242VjY\006k\t^:\252\343hha\227)\017\210(\017DAM\244\231\377?\327Yvf l\311p-3\304\216\307\005\363\n+\241\320\357\031A\257\274\366\373\226y\340\346\035\335\370.8\004\017\024\377\367\216\\\253\t\004T\230>\266\345\214\225\263\323\276t\317H\\\337\227\244\337~\265S\251\241T\367\301\261h\252\021\217V\211 \230L\211D\207C\245\\@\336\272e\245\266\2601<\026\\\267q\206\346s\323\200\266\0302WM\372\035!k\345\373\272\310\327Xg\235p=8c\311\314 \254\213\363\351\003\3018P\206\3572x\374\365\243\337\320\006\310\210\351\335\304v\342\241\211ef\332\246\334!\301K\336\233|\260\321\000\360P\3547\230>\344\361\256\275z\201%{\353\206\355\255""\342\3648\266\035\210>\323\210\222j\370##\332\265\005\272\"X\371x\304\207\207\313\003\037O\245E\214\024\nC+\221\362\3370\010!\036\177\215\205\320\320\323=+\325x\307M\375:\315\346\235\345\321\240i\344HY\025\216\225M2\234\2666\301\007\000\370p2\034k\247\342\3067\247\003\031/\270\371\373@\337fl\014\306N\221\371\020\356\264\227<hW h\323\007\004\210v\210\367ni\265\355\217p\032\231\020\027\245\313\210\006A<\0170 w(\027\007e:\353\010\220\362\275w\017\272\275\352G\305\302\215V$x\003\001\026\203m\343\306s\025\236{#\242h\236k\017\022\260\245\342\005\256\271\203\310\364\310\356\267\326\353W\036\370\375n\362\004\337\203\004c\205\327\211\354{H\317p\007$I\312R\0139MI\306\274:\220H\262l\274\216`\007\235\204\205\223\356\250qDx\177s\217%\245\244\216s\035\275\301\303\375\023G\314\216\017\036\352\016\001\030\363\201\215\t\202\006<\216\001G,\024a\344\372\313\014`\034\006\3262\034`f\250\211\361\230\264o.}l\303\266 z\363=Eq\001\263\271\016c\254\303\323}\035\272\2345\275\210U\370\2354\315\271\257\023\211l\303\246\370[nER\203\306dH\333m\210\212$/\022\006\326{o\235\300\307}\177\022\204\020\315\264\206c#:\234\\\203\202\000\004\200\313\310\356\362\260\n\243\311\003\260\357\326\367\276\361\250\270\023\211\265c\201\216#\327(\231m\017/g\267b7s\322\270\303\370\032\241J'\215G:\227\016\363\361\276o\323P<\364\200\023U1\361[\235\341\n\357\356P\302\022\346\373\005\362\3275\213\267\302\214<B\022\"\\\023\360\305\231$\222V;\n>\253\23764\204C\273\230\201\365\020\211bOp\217\265b\025\217x\335\216G\261\360\334\211\341\206Kx;=\332\250\017h\023\036\366q|{\301\311\007\3108c\361\364\341C\201)\004\017\206`KP\275A=\215\333\301\335\275\236\252n\274\2532H$\331n\234\262\254\372\212\335\220\310\200H/E\305\014\226\350\201I*a\357\330~\342\002'\324f\365K\350_.\374\266\247\246\336>\006,\330hR\211D\227D\264J\357\212\361}\036\222\344a\206Vs\231L%\302YQ\322\304\323I\026\021O8\346=.z[\356\304,k!\372\225U\215\373H\356\010pBH\016\303\322\"\004\266b\316\350\007\336V\032\265\320\007\335\302`\263\352\364-,eD\027@e\216\206\330u6=""\006\300\300\324v\354'\200;s\306\240\005\206`\316TW*\216\344'\025\\,r8-\342\365\345N\264y:\033\\\265\201\324\010pq]\271\260\364\001\237K\201/Al\"\323\215\215\257\264lot{|\230\315b\373\030pY)\323\273 F\010\255\246i\237\273\030@5\017$\243K+\302R\252\221\243W\303\325\366A\016g\305L]\177O\355x\304\222y\n{T\031\210\004>\200\201J\004]\366,\244\247\341\314\355\345\271.\036\014\202\205\240\363`|>m,\252\250wy\303\314(_\270\225\377\014!\251\226Y#\344\214\247\257\342]4Wz\nd\272\355a\353d\014\272\215\361\333sm\235\263z\2064L-\312\272\003i\247\347\376\341!\252H\304\"\010\244\213 \335o\306/@\327\312\311\t\252dH.F\220PHMt\317\333\3709\233@7E\016H\371\207\231\304\336\020\347\245A\326k\0332\25312N\372\254QS\272\325H\303\034\314\350\371\213\363\032~\264\030%\226!\3709\274>8S\213\350\017\324\023\352E\002P'\260\367\312'\323O\215\364w`4\213\250\324\211\2475\327`j\036\262\024\256\3448\327-l\216R\343\nf\2149\302\272'p\005\007\023\211+\232\312\rS\010\032\351Q\211%\263(RX\2154\030\004\303*=\253\350b\226d\030O\317+\343=\376v\034\350\343\230\207\002\"U\357\0261\227E(\034'\243\227]\317<\301=\010P\212*\023=\312Ct&\325|\242\007*Wr\n\006(\021V\244$#\"\232\t\0255\002Z^r\213G\023\221\346@~\354SQ=\357Z\034\277\034!\231\302\253\237\210D=\013\276\023\250-\342\260\323\263D\205\276\304\037\261\236\357z\367\275\240nR\031\214\372Fs;\252!\327\364\270om7N0\r\207\014\035\207\224\220`E\332\312\372@\370\362\242\2478\232\031\032)\211\207v-C\345\203yx\3570\227\222!\210\364o\272K+\341e\367\322S\024[\2074\235\252\245)T\020\333\351\222|\007.K\337\301\223_\232\001\356\263\317\036\356\335\203\276\014\204\"\233\362\350M\331\301\032\237\263\314\025\002\002\005\252\000\367\372\274\222)\353\336\366^\246q\314\311\"\210\233\033*(\036z\036\3317\206'_W\0372\372%JQ5\035\233P:p<\274\nq^\314\037\302\002)\210(\230\222 \250\244\242$(\021\324\275~\237\372~\317.\213\341R\327\211\342\374\271\237\014a\347S\325\000R\323\014\005P$J\373a\365\033\026\242\023\025\360\365\023\313Z\320\370\374\375\350\207\320y`\030zG\226\227\203\236%\0136""\231^\n\221\3142\221\354\204=d\331\"\214\257=\363q\034\230\323`N,KO\302\343B\275\364\370\276q\036F\344\334\310\"\302\022\004\207\3766\244\331\260\2754\240\3514\261\302\206\265\306f\233\217R\333#\323\211\344\2161H\345\241\005\327\313k\254\207\360\241\355\317\2543\031\230\000z@znA8\340\030\204_O$\341\003\322'\244\n\212\270<\362\366p\256\270\347\006\030\364542\206\177G\267\261\263!!\023\327I\331\201\010:UH\235F\031\016\200PwB\345\361\255\260\364;v\030\207m\367\240F\035j\317\037d\2254<\t\316iK\271\230n33.\267\2324\335\221\231\326yO\203\024\361\004\027\301\264\274\221\274\002O\003\305\241\266\n\r\375(\002\217\253\373\037=\356\343\231\251\344m\200\211\353\"\206\020\371e\350\302\276\006\205\343! \215\261\307\323\217\264\320\367'\276)\302e\237.\264[~Q\240\016\260a\014\310\244\211\200\275,B\311\2631\325;=\204)\300#>}\253\344\353\234%6*l\232\313\373\367\002\363\024u\373\371\004\323L/\010\204N!3\212q\272\036\300\365\342x0\255\025\020$\002v\034m\2048&\304Cb-\230\340\020\255a\2059H\223\322\357\321\301\204S\025P\022CD4\020pp\t\234z\232g\255\206\221,u\324\223l\335\204\331$F\217O\342\342\210\325\006J\030XS\352\354\366{z!\332\022\230\0308\264,T\231\0022Cj\333\324\273\236\303\010^\303H\351\032\226\2341\241.8S\247\013\262#\241\302\304Q$\303\nC\020\334\271\360\006U\324\000\264yr\215\343\264\271\261Bf\311\034@\243\317\247\252\264\303;\366\353zf\366\325\010_\231JV7&\252\233\320wI\240\317\303\313^\232\\\327\202]g\317\201\215NfT\3532(\215Xb\266\001\022\030K\210\214@\031\352\010\226\224\3054\021\020KD\3213CA$:\234\314p)\3142\313\273\237\304\354V\230\241\337\275^G\204\226\351\322\274z\301Db\316\276n\221u\035\275V\033E\230d\244\212\346Yl\000B\374\037;&Y.+\345U\204~\355R\332b'\346\331m\343Ts\217\347wpG\014\371\367\231\027<\312\256\310\014F\304\311I\"C&\023\234!d\2355\240\216\314\003\266\035\022\244\236z\037\240Q!32L#\001\010\nC\230 {\217\023s\020T\025z0D\272\304il0\024\260\315O\272u&f\rT\001\220\031\000\020@\345JR%$A@\004\242\261R\021\020*b\275 S\036=\300y\267u\355|\320\217F\372s\1773\370^""\261\223c\317\036\373\307|\340A\343\3250\026g\233\035\355\270N\017\327\037d}/\341\377{\257i\357\272\304R@U\024h\314\013<\372s\263\n\3431\024\313%0\311\337\345e\246UsEx\3251AIB1\r01\217Z+\030\r\215\270\230D\231\220\302Ni\205])\205\026eg'3Xr\307\"\345ih\326Q%M\005A\2702(\324r\207PT\323\021\244H\221\225\004\252\010\033i\222]B\267\221\232\212\003\033\322\200\367\243\007@`\321PL\344\tf\024\2054],\033l\341\306\232\305\010\300r\002y\026:\321\217\030\251\226\366\3437\0234j*8(Y\265\013\234bR\r\334\254\264,\204Ie\216\330\rF\244uAJ\031\034G\020\361\016dI\256\211\026\241\214(\333@s#5\036Dp\372?33\253\025|\010\214\351\325\233K\002E\024#\324d\032'C\244(f\240F\270\303)\201\270c+\300\215I\030n\350\246\251\255\014\225\021\001\031\032\037\206\205\r\017~\261\2763\237S\305)\341h\360\202\355\016Z\300\023\276\007\264\265\3049w\3302\371Y\206f&f\0219\014\244\014I\022\307u\212r\260\" \"\267\360\037V}3\242\360\3416\035\rb\242N\000\031\r\271a\364z \r.\372\352;\221_/\274\017\r\240\364s,\243\263\313\320\357\214\275\307d\326v\266\256\313\331>\001;\314#\366p\206\010\343\355\020\013BD2\005\231\0206\334\316\037\357\376\315s=P\031\304mK\037\024 a\212(\214\365\362\261\316%\370\016\323\344cr\3666.\355\254\262\003e\373|]\265\355\027\001\206m\331x\342^\\\200!\275y\004\236\347\263\326%\264\343\251Z\222\244a\021>8\264\222\021\\\372X^\033y\336\331\314\332\373\253\361\274\374\365\360A\302\355\231\256\347b-u\276\344\215\036\032\241YS\266\005DN\232\331IX\254\241\2353N\275\240\223\222^\316\t\360\240\337/^\236n\r=\231'\266h\024\210)(H\032\000%t\022\223\000\301#)\026\3448\343\263\200\317/\016\316\340\351\213R\002\307$\240\030c2\021\334l\304\361\245\003)1\332\026]\210\310%\246\320i\204\344\223\"\220\236\372e\306\331\303Q\323\334\363\227\251\245\211\273\364\273\003\221\244P\302\000F0hL\344\r\353X^\210\027\303<\332m\247\246D\355c\333\346\2130\014!\324\021\200\236\343\214\354\214\255\361\235\016\261\320\367\\!\212\205\002aC\323\257\236\004\374\253\365\227\215\315\350\353\355\366\034];\014\355\020\360\341=\350\220[*""\222\341]P\2543rlBb\262\023\234\333X\033\002u\251\031t2,l\224\033%8\206\033\216\037\347Y\0063\226\353H?n\034?\t\325\214U\014\300\340\321\005sNF\364,Xr\312!\t\333s\031|?\033\335\357i\254\333smu\241*\203v\220-\226\303,%\354&\325\305\266i\013\020\006\001\323\000\264.\303\332k\2740\236\220\370\356\003\007\221`\300\026\365\3302g\250b\205\327\257>\275v\334\201\215\241sbJ\330\n\311|\205\215\366\"\314\252b\342Hk\215,=l\316\366\321\271\246\030\311w\033n\347O\307\014\244D\336\262G\2323)\321\325\306$\314#\314\252J\322\361\303\305\3030\250\316\363u\274e\005\3361k\"\342\304[a\202[\300\307\355z\026\272\3448\324\327\223\267-\360\310o#'\304@\014\270\327\303\351\263\224s\324\326`N\010\200\373~mF\010t\\\271\013R:g\231\262\325\330Gh\326\034\220\347\004\022\004\204\3103pY\240\270\245\212}\304\3009\316\0212'/\270\271C&\326\255\360\341N\260\260\033\032\240I\3158T\341*f.\370\271D\313\274\340\342D\006&\230\214:\367Q\304}g=j\234\302c\331\322\r6\n\214\345\007Z\304M\270\256N8\330\320\223c\313\235M\314\353\205\305\312H`(\260\307:\213\303\201\301\306\302\226\323\021\024\3531l\230>\261a\035\t\000g\002E\2049\346\206\3046\327!\353\234\201\221\000\030\325\210 \206\036\213\235\345\320 \211lA!(\314\342\352D\001\004\026t\010\3250O-.\033\265\342\341\200\030\024\030v\300\206\262/\263@\016;\n\3146\317\005\261\221V3`v\321\003c\032\316\3019p*lm\213\004D\220\021\016\343\034\007m\223)\210-\201\262\354\317\265\275 \"x\02228\221\246\374Z%\265g\0307bo\310\241Q7\270\034\024\327{]\273\370\242b\275\321\032\212\017\n\374a\304\3247\337\323\3159\026\205\344:;\270\362z\311 ^\274\212O+\220\016\354A\351\007\005\277\332\005\34092D\325k\235\206\210B\324\024]R\250\310V\276\240l\022\026B\032?\177\212\315O\3017#\257\244\317\216Wv\262\310\370\325F\r\302\005}\267\306\024\227-\334\337z\241\037\037AO\261\364\361\216\332\241$l\200\221W\272@e@\241\223\335M\211\004\035\263S \303\243\201up\340\261\302\033\316\206\004\215\230\246g\262q\337\"@\343\256N\271\0223\230\0008@\366\007\331\305\273T\262Z(\277\031\031\003\025\332\344\007\000""\2003\035\335\203L\216v\375\342\016sy\310!\261Bx\261b\021<\337h\020du\212\304\265\226\350\333-5\271\214\234Hh3\264\314\323i@\343!\303\301!\0207/\210>'\274\267\036\377m6H\360\207{\343\275H\353\315l\016\2518\301IY\023<\300\354\006\00702<\003\212\256avi\3166}<\307'\320\362\030}\214c\034\000;\361\216(0\021\221\036\017\022\264 \023\343\035L\354\342\017s\336\233\335\372\212\036X\202\010\020{\374\002\020\016^u\035\315\267\355\215\321\007\266\010\302)$ \210 \310\222\035t\363\272\366\350\032\367\002\241=\365\337\356k{k\350o\034\336W\216\2402\302d~1\341i|\316\334\266\251\333 \346\035\372)\304or$\"\026\206\263\3256\327\211X\346d\302\334q\207>\006\236i\261\226\226\022\312g\320\241\316\370\006\260\300\r<\204<\315\375\026|\3645\266@x\310\305\220\013\r\225\273\350\353\3143\336\362i \0340\014AC\311&'\215x\2455\234_ho\272L\326+\023\320\3241\323\020\315u\215\2323n\227l\316\005\252\3270R\307\213\020P\021\253\257vq/\243\347G_\032\3408\267\325\343\t\220\327\347\n\322\"A\2105\303\023\210\220k\245\366\360\312\026\305@9\247\371\342\235\215z\2057>\274)\271RWtZ\206)\213T\334O\323%\264e\013\346<\336^\331\355\313\037J\333\246\263/\032D\034\237#\027\017;\344x\035jyU\222\216\014.]\275\262\326\331\330\310\310\324j\341X\320\246\307\2723H\323E\034C\315L\014#\204\363\355\001\310\257\021ltc(\311\244\314d\204\010T\270\215\217gv\312l5\302\001\":g\231WK\221B!\241\205\364\2668v\351\205zR\247@\003\224P5\203-\245\001cI\024\205'\264\220\216S\3421\351\240\204o\317\264y\004\360\303\0249`\3201\276Y\003\032\254\355'\206\250\326\232\221\250JUs\211\303\261\220\345\231wE\2666\332\247!\ty\301$)r\264\010r\027B(\207K\026\246E\322\213\201\231\"\020\211\002\030\nj\030\026\035\263\241Ad\214vj\"]R\347Y\266\206rL\324JS\276\271\02140r\367b9g@y\304O\216\356\272\311\245\370\355\2168\320R\303\037\202=\260\333\236<\370ocOni\366\0221[\270\360)\206)`u\327\024\003\013\362\3115\354%I\303\2113<\225|\244!\017>\357K>\220d\t\016\200r\235\352N\023\255\270aU\207q\271\327\241\206\207\216sKc\242\210\256\250\372\243$`\2053\230\\\273<\251bH""\231\205\372\2168\007\2629\344\363\005\347\275\316\216\315CN>\316\220\364\302HzM\246\3302\036\233\266x\344W\230aa\276\207vv\363\256-\363\214bOe\234\261\342\3624c]\216\266\212a\204\325\001\326\007\t\350$d\234\315b\001\336\220\361d\0039\307\t\332\316\n\205\nRV\322M!j\206\352\207\217&\365;s\201\324#.\273u\337}\207u.\336\355t\245PTg\275\365hh\201\255\312e\226\022a\021\014\302dz9\366\001\335\236\305\374RLs\310\014\205\367\221d\002\014JS\264]l\024a\215\346\201\252\222#\341yF\"c\216r\335\273\216\362\t~\221\351\034\341\010\221\013G\206\t\217\277\361'\342\362<\204\034\267:r\324>\326>\236\216_a\022E\220y\271<\327\344\027\n\217g\260)(\"\252\004\350\034\003\361\364M\270\304\345F\033r\0359W\221\307\210D\366\374|.i\360\255r\370\355@z{\255\347\206\0027\204\370\022u\000\305\001\242 \363\216\374\td\206C\274\007\313\030\23135\300\000\3541\262\315\270nnu\372\335\217\357\262\370x\272\231N\2232\0042Lpm\336\340n\264\353A\223\222\274\305$)\035\361)C\022\304\034d\311\210&\304\275\033\333\223\201\366\357s@\272\271\271\361\240\333\204$\300>\335|1)\027\035h\367\213d\002\236nfb\264\362\261F\212\333M\266\306u\220!\3500\207v\351\315\205\344\263U\375\2577\006\223\"|Zv\036\256\303\016\020ay\010D;\263\002PI\243\316\327\025\200\267]3\330\331\337\336\357\261\317!\330\320\226S\252\235K\300\251,\312\n\004.\006+\351\366{=\0359\036\217XB~\251D\003\267N\001\302H\260\203\271^Y\241\362|\237 p\313\354\256\310\256\360\003\224\020\240\026 (Z\024\032S\274\200u\n\352\322\020\030H\230@\230M\010\372\311\014\207v\340\25586\313-\006\316\260`VX\020\204\211n\023\300\3406\304\256D\360\335M\225h\201\036\242\224b\201\272\273R\361u\370\357\202\370\243\322A\270\374N\277\037r\036\014\022R\311\010\265\330B\031,>\300\242\225P\360\207\273\022\301\006\014\"\030\036\306r\304\341v\340:\265\037}6\366\200\177$}_\2421/\2440^5\214\314\251\017\214\247I\373e\306\335P\345\302\271o\230tP\237Lz\3310\265\031\2342\"\347\205\357W\007!\013C\362\035L\003\214\225\357\332\345\344\363\221N<\323\303\226\310\033\"T\262\344\023\010@\356\342 \354""\343[\312\252\300Hh\27666\236\231\356\344eQ\212d\004\035\3659\014deR\276\3158\2722\261q\262\260\253JR6H\333l\222\"\022HE\033p\033 w\374o\267\326\326}\336\313\207}\342\232\t\245\025\027\037\003\022\337\325\333\313m0\304\362\322\355\3164lM!t\347\200\217\336\2654\320\274-\020\024r\023\345\326\230\333\343_`\217-\235\342\"wt\215\340\316\232\274\241h\031$\346\211\211\3601S\353\020\327H\365\262L\230\t$\300sM\320B\3033\220\204\231 \236\270\344P%u\221H\353\352\354\321\002S5\0329\r\220\031\031\033\030\235M\003\342\370\350\330\367\334\022D,\300\371S\220\2468\346!\355\346\223\362\333\205\334B\342\032\302HH\222B\016`\201\205\206\376\323\323\321\371\377;\352\330\323=\003\233\323+\336F\215\020\236\370\220\230\204\261\304\016{\034\036Y\225\203\327N\227.\017\334a\"\310\241*\223X\214\240\326\016\263/~\337\013\241R\361\367\307\010\205\340\027\203\246w-!\320\"^#\341\335\343\353\003$0:\304\222<\227\223\3254n\222 \207\343\226\211 \030\214P\370\363\n6\007\223\002\023\360\355Y\001\256\274vO\307#P\372\323\220\367\311\366\360\322RA,J\233\024'\355u\240\373\307\314\232E$!\020\370\2407\017\256\031\340\254I%\032F\016\335\243\350\003\315\351\346\241\365PDL\201J\215\023\010$I\t\rLR\005(M\025RDP\304K\010\372\257V\200\371M\255Q@\024\206\371\251\353\037\"\211\214{`\300\325gS\005\355\252c\262\025>\022=\2640\250{w\251o\304\362\330#\216q\031\357NH\036\314\024lyy\250p\250z\303\001\355H}\227\200\343\034\257\3630{E\221\210\311\351:\251\356\362wK\333\270\355\317\321\367~\245\003\005\302\3659\000\212\370\233\271e^\321\211\202H\3314\246\303\202\355Y\373\307\025\r&LB\014\220\276N\"\006\330E\311\026x\315\234#<\016\000\006\334iNK\341\001%\006\034:\023BNZ\001#\210\rL\32641\230\027\234\3428r\024\331P\373\017Bu)\2560F\314\214P|Ql\271\"\032%\332\010\331\314+\023i\310\316\206!\226\025\307\321\274\203<Rv\340\271\022\235KX1\274\332\030\260\332\247\346Y\331\300&\203h!\010\200b\244\t\224O\276\260\245\236 h\322^2\310U\271\342\031\340\324\250\372\304O{R2\337:<\207\211B\363\322\345\216\2310\233\302o\014\205\t\032\310\025""\273\000Tk\227\017L(\224\034\351L#\227\2245.,8\021j\032\301\273\251dq\261\206Xbh\370\201\343]\232\362+\265\034C\014\302\336xv\320\276\376\300\224\366f\n\375\376\261\022\2212Uw\"P\006\212\204i\006,\006\034\364\242\366)\357S\273\303\234W\202\016|\354\3034\305\031\3073\333\274\204\334=\025B\230\201\2208\203\247\247\226\205\351(S\250\033\370|\352\250C\340\035g\331\361'\220{\204P\234\273\nF\0054\313#5SBA\000RD\224\024\255)P\020A!\001\005\001\021DDI B\036\271\350\0172\243\307\312R\251\261\0231=\003\300\356\006!\362\036\357q\2664\311\021K\354W\342\204\211\244\232\206\010m\260!\270,\333\3708\347\232\271\266\024\2767\346\036\363\347\237\030R#@0\371\026\265\324\335\355\341\333\275\363\363\027'z\003p\362|\373\254\225\005(\346\267R\313\252!y\347\003=#T\275\2626\365\"\031Z\202\326\315G*+\034H\036\305!~b\225\3030\351\341|\020\311T\267\350\024f\2673\035Gn<\313\237kn<\235AL\210\243}ba\020\356\n\316\206\344G\006\024#0\312\326#\310\215IE\"\255QLKJ\320 Udj5DC\271M\333\212R\240\t \361\"t\226\200\252\023\362}\236\305\330\366S\007\207\2100g\253!VT\241\204I\307fZ\332\332\275\246\347w\2633\265\201\232\353\345`\342`t\273v\257\030\311\220\327\205\322\312\014%pb\001\300d\360H\314$i6\325%F\215\346\273\254\241c\313\2149l\316R9%!\211\306jt\342\024\264\321UX\354\215\006\2239Z\203E\2742\314\301\334\032\206\211\253F\340G-\230\253\275BR\362\313\016\027\007\316HOi\247\000\231\0142)\327&\0338A}[E:x\231j\350'{\004L\020\261\021=HS!n\207P\246\031\242\010*\n*\"\t\223}\274tC\317\301\216\331\003k\250\270F\300h\367\321X\326\275\323\357\236\377\177\247\333\324\350$>\362D\302\036\3102\"\240\226\240p\260I(\031\3269\254\007\030\306iL\201\255a\224\221PPR\230a\201,L'\323\343bd\004CLHP\332\300\017(\334ox}\006\004\345\013\222\356J\006\251\023Yg\236\\\270\212\265\243BV\254\010\rC\264\212*\224\311\007dm\200IE\253\255z\276\263m\037\205\317\3069\\\240\016Fu )S9m\214P\030\306\014A\306\327N\3053\270\353c\323;V\216\226NL\n&\251\251k\375\262\303\336=\350+-\3346B\325\274\355\250Y,\201ap\0037\275\3742 m\257\026\010\242\023tm(""\207j!bY(\030\333y\025;\330v\375O\226+H(\234#\210@\342 !\265`\221\275n\216\327f\021\032\306z\312\344\201Hn\010\316\245\243r<B\032+3\006\001\245e \345\366qK'\366\215\315\267>\342\2450\":\330\326\032\353`\224Q\020mE\014\246\264\232\311\210\367\375LS2\224\020\022\005\001\232\363\234\371n\345\246&\3145U^\206T!\312\366\252\327\256hhI\026B\027\225\"\026\264\270\350\245\337H\234\022w\346+\247\007\004\014s^\375+Z\375t\003\263|Sy\271i\241\277\337\327S\270'F\221\326o\307\336\323\236\346'\001\246\246\020\022\027\305\024\363O9\311C\330\237s\213\241\263\024\306\202\303\014D\244\235Y\t7\243\214\357\220u1's\202\0105\222\353J\240\224\242\003\001AqY\323\334*\021\004BF\220&7\324\321\240\253\306\304{\240\023 \3111\2223\277\337\177\037\2133\313\334\201\364\331\341\336~\331[\033G\350\330#\037\013O\036V[[\211g\002\025M3\363r\245\275\337d\313\354<:d\246\001\361\307\222\350\236\350\310\230\010\237f\376\014\353B\024\211\360\310\231\005\000P\325\236\251_\r\200c\002n\027 MJD\305J\315\021\215\2420\255@\031}$\032d\021@\217V\370\332\306$vV/\207\203\212\032Q\350\007\300c\"B\020\311\3238\006\276//\215t1E\0375\001\304\301G\305\231\\\312(\252\241\313H\256\211\336\315kl\301t\271z\030\334\374\237\322}\263\354\317P6\030\033 \211#\n\210\203M\264\330\376\3758\357_\233\021\350f]#\036\206Y\223Fj\241m-\236\351\373m=\375\375\246\332k\024\277\251h'\323\260h\300\371\235u\202\375\017\203\321\330j\002)\223\337)f\371'4\342(7\026I\207\022\346V\301|\01415,E!\021\013AG\235R\226H\001I@\025\022\025OC\250b\311\2560\323\010k\004E\313!\256\272\343\347,\327^\363\327\305\n\"\010\336\362A@9\241O93\267\267\001\014\333\231\357\301l\0008fs\335\367\267\3309\272\327Y\260\035t\372yt\361\346v\322|\316\\\002\036\306P\010\261\207\235v\340:)\022%\t\001q\261\316<\313\346\322\237\326 \rL\017\274\260I\360\330\354\251;ysY\343W~\326\262\027\245\023\002\026\314\335J\347a\274.\014\270E\254\204\351KF\223\272a\326\235\036\372\203\304\220\242\326$\013\337\305{\211I\232R\340\312\223`{#H\206sE\3408\236\377\203\274\343p\267\263\2608IN\260{d\3064""\331\230\301\2502cc><\010\307\2372]j*\221\303J8\310\201\214L\222UR\264\254J\014\331@\227\030\264\216\210\036\306\\4\326\264Ln2A\301\204\220\331 \353#Ll1\307\221@y\231\032\363\372\364\t\262JNU\000`\331\005'=d\025\003h+\342q\333\206n$\2117F1+ 406\315T\242\301\2211\351\221*\302\r-H\020\220\326D0T\230\213E`\320P\300/\277'\322%\241\326\251\014J\232N\3105\024\372\261#\241\031\221\024\303M\342\322\003\267G}\2547\272\210.\030G\024 \355\025\340\312\231q\212\252\242\010\233\001\242D\2076%\312Lu\023\216\004D\205\025\237\321\326hBy\022\"l\255$D=\272\214rD\355\217\016\330\tc5\202FK\306\365\2006\364c\0244\205\r\230\273\002vH\251$\024\001\027\337$\341gl\3324\347\354\357\330B\346\331j|9\214\213UJ\026-&\030\236\251\225\377Qw\314r\017VU\303$\rEJ\004\002\200\001\244\020;\325p\306\212\000\346\311\313N\355\253\003\3001w\211\r5\246\321\204:L\363n\246\223e@\261\231a\240\313\035vu\304\272dI0\334\320(\222\354\016\353G\203\320\212\212\311\333\276\362\314%\314\346\273\3262\300\354\200U\024\"\024\311\024)\" *\010\214\226\231\344\201w?+cs\307\\\223[u\351\202v\367\362\370xjz\322\215\274*\375\036Y\3025V\316\250\023(\030\207\233\020\303H\203z\374\332u\021\323\263C\253\221t\201L\225i\003\212\010LYP\240\240\014\336\264\243Zy\333\330\013\262\000\320\233\205\n\240)\006\250Z\246\200\212\204\010\204\002\204\244\210\t\032\224ZE\241\002\220\006\234\333&\300\246\003Z\0034/)\250`\r@H\010@\231\013\252\337!`;\275\267\032\332N\234`(\0043\206\346\206\346D\256\214\314+C\261\335@\006\030\230\021\351q\324\024\241A\301`D\207\205\217\026V\276\035\232\330\221\024D%\"d\021dE\023\312^D^\007\313\264\3302\006P2\212c\016\212\t\365\304@\373h\027\257\003*\302 \311\0240\002\0350\032\340\202cA\002GH\250\026\233<@t\267\024,\214C\265\025\254\323b\313\350\035\376\200\207q\327\314\352w\020\212\001l\213\344\317\030\310\017\342\020\223\304\316N\274\200\345\270j\343\207\203D\257\331\311\233\241\360r\323\267Z\004C\016\010P#Q!j3\326\254\2161\003\316\367[\010\t\236z\312MJ\233\214%\347\033 \302\0035\211\205\231\200Aj\017H\237\004\030""\233\227\205\246(;(\307\025\365\311\2213\315*\"\014\030z^,\2756kC\201\t\204L\324\310n\3478z\365\202\007\364;H\245H\250\365\306\023\020As\361L\\\224\311{.\274\304\363\021\221\332\331\326\355\020\357\245\220(\245i{\264^\t\311:IN\315\300y\32546Q\021\233d:\3460(R\r%\013\010k\324}\377\264\333\334\241\351=s\020\024)S\025\020\255\334z\030\355\213{h\224;\265\255\025\244\373(\022\226R\024\316\210^J\024\207,1\305\naj\n\310y\231Z4Fb\341\010C\250\304H\014\223\010\2022\t\314\250\2100\214Ie\321\226\265C\241\326\03112h\214\314\321E\024MRQL\224$\305\254\212\014\351\362\346;p65g7>\273t\265\235\026\230\300\306\352\235j\271\231w\346\354.\237U\0375\267\372/!{\207\235\216\026\316\217v>\355\017l\224\216\177H>\352B$\232\253\305\340Y\016\236\207\236^R{\212\273sh\303\316'\024\245\"\214\247\032\352\364\236\013\320\365\023M\253\234\274\357d\3048\324))a*\212\000TPH\2212\027\343\234\215H\324\244j\034\2158\024\221 PURU\334|$\006\315\233\263\211\252%!fb\244\323\2542\rI\275\210n\240\363\366gy>\341)$\363\222?\000\036\204\240\016Xc\2118C\224|)e\234\3219\220\210Yq?\0014\251\032\354\223\335\024\365)\361vc\001\2570<!\364\024\211\261\346V/w\023\366\031\362\360\360\313c\023\035y\372LlK\251D\230\352\232'\276+\301\341j\335\024\323\331\223\t=\302Y\004\037O\250\257?\313>\277\254\366>\323\216\317s\363=\277_\332\212y#\205+\221wg\2435M8:\365T\365\032\336\362\326\3424&V\203)6\021Fd\221o.d\006\330\306T]\330\322\314\21262\356\307I\017%\333\241\255\335\201\021\006a\242\303\033\030\332\\]]]+\251\252\3355SL\321\206\342F\023\000\332\r\001\2432\021e\025k*\213\013FA\260\221E\202\256\247 `\257\274H\024\0037O[\306\210\036(r\312\227\274fq-\026+0\236\271D|\356V\333\232V\324*}\310\243\276>\340&\337X\033\200c\202Q\242M\234\256}XH\026n\221\023\366\274,\037\034\276\325\362oW\034\203\\y\275\323\266\270\002(\027z\254\204\232\364\253@[i\227]\3649)\3004\310\357\265N\214x0\010\001\300L\222\331\340\225\200\013\326,\212\004\213 B\007\034\223\034(\266\356J;j\251h\"+;\351\213; tNS3!X\243S#\361\263\360\360$$\222)\317\321\336\256\237\003J""\270A\020\322j&J\0031\212\002^&\216\0142~W\2047\343\212\022tC\201\253\247\010\001\363&\255\033Rp\037Y\255@7d\373\t\236lH@Av.\0040\220\236\t\366\370{\310\215\246,\235\307K\010\274\036\177z\370m\326^}\035\013}\334\260\014\013\333\307\322\260\230\270%\230P\\i.\031\221_\2013P\016)\367\272\237[\343\362\3616\337\224\236\2648\277\216\357-\316\301\240|:\204\307\207\276\245\314%C,\017e0\304\002\242\204b\003\2508\236\030\372\031\375\256\334\026\231\247\001\022h\351\305\372D_\354\335\005\365bq\035f\t\204HH[\234A\320\200\370\326L<\020\024\276\325\213\034V\032c\214\324\306\331o9\315\271)\340\365$B(2'\311\216Y\031\005\031\201\204\326a\216X\344&DR\004\025-\t\021\020\322\037q\2061\021\024D\00103\nD\006\240\366\211\247\003\034\300\230\"bj\230mZ\264HMT\241Q\0244TQj\203\014JX\232\232j\242\"\206\212 \212d\267\236\342\334*\356\244ZP\230\252\021*\217\022,\307\013\030\211)\202(b\242\220\334dL\024PB@LA\010U&\363\224Z,L\314\307xbD\237%\205o\014\206\002\244\242\203\353\270\031\t\246\230\224\210\003{\332\322\372\204<\274\213\327\276\017\237\037\252\303\215\323\3366\202*\252_\352o\356v3\266\206j\005\245\022J\017\252\355gj\030\304PP+\223itSLsM\264\027\031\032\210\312\021\220\355\341xp\212`\357\366\001\255\3203\341\000\233~!\346R\242\250\"\020\202(\026\tE\331a\365\320R(\247\227\335!\367\322x%\010\214\t\200\314\355P\244M+\311\016\236\036I\016\357\216\"8\023\016\005E\"\033\200I\365\006\302\330\330\320!\334W\311\316\326\022\254q\310\333\034~X\234\"o\235\033\206\214!&\032@\001f\246\204\362\2649d\346\205#\221z.X\267\022v\014&E\025:\361a\2422..\341n=\323\257L\303\246\224\002\275=\225\r\260\005-\022\364\207]\005\362\200\355\363T\365\307\347JA\002v\201q\237J\306/\207O\247\034\264\017)\340gA\241\022E\241\016\260\n\366\305d\271\000\302\245u\320\267\333\026\026aM\216\264kK\013\270\302\310h\3350\200\334\362\002\254\374\340}Q$Y\000\271~\306\235u\316,\313D\004\310\324\206\207\205\010\205\212>\256\2731][rD\371\306&Vh9F\320\367w\275d\240f\n\033J\204\212\225\323D\004<|\247\251\005\360%\304N\275Kr\324\357D\023n""\343N\344=\220\014\214>'\335\007\035{q\306\214\251\354\000\021\372\301&\n\222B\030\002`B\241\222b\n!\246\245M@h%f\362\270\2621\267)g\216\266\211pYs\370\267\243\350\234\300N\214\212\314\255*\362\224\302R1T\267\240\336/\217u\274\017\022xM5D\020 jP\321\007\260+l\205#@\332!\002\251#%p\254v\264\353\231\205\204\344h\213F\265e\023S\032\261\362F\335?0g\350\350\206\226f\035\0272\263k\340i\006\024\317~G~q\324I\232\374\251\002\222\227'CN\232nW\253La&\210:Pa\326\235j\340\304\231Dwu}\262lsy\340\270\037\021\246^*J\343\214g\330<bWZ\351s\362\032g\335\301\334\2657\321\310\2009nZ'\200O?Nq\333\r\230\t\241?\345v\313N\246\340\004\320u\313kBp\370\336-\270\032\300\316H\naK9\021\330\263ps\202)\300\0245\000\3542\215t\341\332\346\234qgn]\004\200\230\231\013j\216r\316\372\2012\001\211\\\263\224\024\207\256[\227\325\3430@\013 \241\022&%\244\016\357\276V4\010\0265\207q\335O7\260\210\321\006\360\3001,\000\220OH\210\215Jr\310z\263\243\005\254\353\352\275Y(\310\331\202\220\017\275|3\262\244NR\371\247'\030\017\362s\307\350\300|xd\024\324\227~\007|\246\245\240\343\245\201\337.\313z\304^\331^ WX\240\220\275\363nZ\235\234g:#\345\234jd<=5\253\260\242*\272S2\224\301\006\351*v\272M\203\033\335\225\224\360\3722\270\240\372\266n\276\024B\"\014\245}\252\342\246\305Jk\016\234*\330\356\305\243R\310\345.\366\322\276\250JZH6a\326\034w0\336H\236\026\213\261<\355b\206\366\204 \315e0\001\n\304\327\232\020\246\"b\211\000h\214\026f\243&\213`\021&\3133X\204\232\260$\313\025\020\266\031@9b\207z\276\265\276(\206x\240\224\250l\220\247)\311\220\346\373\020\226\231B\034\"\300\325\354$)\273\272\333S\241\350\035\203\255\314\0351;\\\201D9\032\332\034\345i\334D\320\314\310\270n\303\3450\303\341\322\035\316e\310\0160\235\306b\204\331pm\264\355,\3002\320\346\261ae\310\324 1\2558\235`@\3614\005\010p\003`\021Z\241m ri\232\2605\367\237\251\271f \2227\033\345\306+\322)\203Yf\355\323\366^\301\236Y\230y\330\342\305\346\270\353\274nZb=5\301\246`\326@#\237n&2\361\356_\231\233\270;\255'\t\230\223\370\337\232V0\202\2055\364\311\347\257""\276\261{\276=\336\345\307\322'\212\005DFS/\331\213\223\014\305\342P+\0051H\325\244m<*%K\034d\202\250\035\356\233Xm\353Y0\310v\336\321\265\001\217\300\322\306$\305\335\333\345{r\265\365 \327\342\343\276\374\303\230\275\223\215\261\234\324\370\346\363\333\256\206X\006\306\3100wh|\244\337\207\262\323G:\245ey\340\326\273\003\305\230\275\322\020\246\251R\005\341\210>\271\221\027\216\235.\005,\023W\216 *6#\323\303\275Leb\217\230\030\363\267\236\347\006\257;\352\327;\005\016\233\364}\034\371B\033q\327&\332'ka4\020Y\021\331\223\306\353\246y6\\\200H\307dA\334M\336\376>]=x\030\345\0323!\266f\3565\302\345\266\023X\315!\322\241\321|\302\222\212\352\334F\332(\252\207}\270\233\\S\030\220\316\200d$$\010\346\354\276\316\034\020\350+T\305\032M\212_tW\273\006D\326HZ<!\372\334s\336u\313R/<\300\262\006\343\3133`n9\371<\017:\326F|\2750\031o\332\022C\334\310\0364':\320\\\214\340\006h\305c\247\247\354E\277~\250@\371\331\217\0050!\272(\202\314};{D\020d\340\242\303t-\300E\230V\244\367\343\252n\372@X%8r\365\336\032\355\2049O%`\347\021$\310\024\242r\336\032\353\263\2169\276_\030w\300\215f\264\305\300\363\207\001\267\014\314\t`\0309\227YM\024&\003a\014\220B\215\266\234,B\222\"\007H\270#\2706\257\035\347\214\232\217\\d\324C\363\302O+\230\343\205*\204\336\217\252\353\270\201\312\366\307\272\360\200\247t\313;3\036\252\316q\364\340\353B\300q\370xr\266dQc\206\004`f\004bF5)\251\305z=\365\211\364\263\242\007z\205z\242\274\322\236\310Q\2323\254\357\307+\345\201\236:X\357\357\230y\354\030\006 \206*6\213\2054\2363\312\006\360&\007o\275q\0213\241\017D\0140\301\263\301\351\302\207z.\345\324\251|;&\220\006\013\005\244\313\311\020\375\237\331\273\310\374\230\357^7\221*;\227\226\014\273}\303\352\330\266hS\226\344\272\n\212\003^\237\034\204-\307\346\370g\341<t\345\353\2226#5\234\311\313\242\254\031Jj\2705\251\245*\365eq\334\2523f\240<I\2612\261\360\"\232\372\2338\262`\267nS\r\220\357Ua>\373l\206\310l\354\364M\240\304\350\362>IZ\350^\306\317\027\253\207\216\005\016L\276\002\363\311\365\007\030\213\206\2315""\256=\274\2578\335\310z\260\353K\\\033\346\256\031v\271\310\203\327\303Vj \347\216\240\242f\032\n\253{\212\2355Qz6\206\331b8\230*\321\203B\330\3725\330|\376\003F\371\347f\372-\333\206\240rA\247\211\244\3343\020\314\263\0306(>\270\303``\014\000\371\030\373\371\247\235\022//\212\231!\225qV\306\320\231\304kU\272q\273q\363\302\304\213\274\010\326@.\226\235\025e4\3522\001\2077\2368\013\275\205$GS\316'A\262Vm\261\365\204\200\346@:\266\031\211R\002|\306\202\276\001\252#\004\007.\220\000\244\366\035\227V\016G2\207!\310Bk\021\315\3056v\361\0336\341\206\035!x\343\005X\371\301m\272\267\305\202}\035\354\243\242Z\326Z^aGSsNl\202\350\364\214\310\371\345 \272\232\350\316*J\023h\024\020\025b\003\227\r.#Jy\212',\300\212(H\261b\206\261\363\031\003\031\030\3065,\034#\343\257\203x\236\210\315\3643\227LcOn\232EE\0204\025s\003#a4\035\344Xq\032\010\311\270\232\"j<\354\330r\355\254\323;\2248\034\246d\205 \211s.Q\330!\315\010\007\300\307=\256\350\330\310Q\010\330\016\342\220\3307\210e\026\371K{}\373\351\317\344\255\004\375\030\022)\"\242\310\244\211\022\021 \216\206\236\357\222\226\275\360\371\354=\326Kr\244\266f\222=+\247]iM\312\304\211@\322wy[:\372\364\320G\230\304\263\022Y$A)\017p(\200X\026q\237k\315J\031\334z\305C\350h1\"L/INs\251t,\353\226\rnr\2313\031\302\264\201\334\260M\241\230\016\253\02029\212\220#J\334\242\3061f\260*\263!\007}m\346\205 \342\212m\262\245\021\244\333Lj\372\035h\202\246\236\213oV\302-\030]al\314b\205\201\033\333\325\267M\273\220\352\223\243\016\203\014kcB\352\004k\005\253\364\303^\373p\0271\314\343\020v\331\322\305O \250\261\"%+\221\341\t\240\357\221N\204\232\013\315Q\2329`\321\232n4\310\r\017\200}\274\304$$\266\271\014g@\"\265]\341\227\030f\004j\235\346\223`\226q\302\304\315\276\233\370\rwy\331\273z\220\007Z`\236\317\2022\024}\300\274\305\006\217\226\300\322\316:o3Ivd\320=\2417\355\215\003\304\326\025\234\007.+\0350\212\"\316\000\2521+\360\337\035\361\030%\224\333\237\204)\003\206\322\004\214\345JzD\017\232\305n1pP\2430p\371\264yw\355\325\304RK\356\303\307\347r""\270\332l'\216\205J\317M\244\235\010?B\036\032(1\246jAq\003(\355j\366|\364b\221\210G\036\026\267\266P\306\264\245\327M\372\230\\\361t\240\355mI\344kT^\036\231\037\013!X\307\234\004\311\270\341\246<\306aK\271\227:Pi\230\342\206,\"_\252\006$\331\"\201\254H\207\313\241H\"B\014j\273`\341\024a\032\006\321\004\310\271\221\245\321\231\230)c\214\256\262\270=\353u\321u\310\000h\004\312,\000A\002\0043\313\025\260ru\305M+\204\371\315\370\200\251\361\036;\215\216\"4\033S\316\036\313\340Zg\327\246\006T\372D\204Q<H\250t\023\272\010\024\365\241\034\241R\003\251}\202rW\033\364Z\2373\260\340_\256\200\\\374\035\203\007\003\347>/\334\336\3646/\256\242\000\234G\231\"\342\032\236\224\311DX\371P\347\353\246\351\230v\321\001\010D\307f\216\262dd-\301\216\215\026=\275\017]\351\233\263oU\224\240\234P\323\305\315\213\226t\230As0\312\314\020E\272\250\036\353[\234@\2016\362\376 K\303\361`\010f\374\240Xy\237jffK\270\226\025\331\262M{\t3\002N\310\037n8\316\214\036=82\210\301I\025e\002\024\200\r\"I*\007\243\320\371\341\310;v\207\226Tj\272\203j\001\250\332\206\246\236\034\3011o\277\034Cq\260\356\030\3460%\304\230\025\272\006g\3361\017r\237Y\020\272\273\367\302\014s\225\235\350\265Z\316POF\271<\223E\366\331\310\227p\270\017\370\241M@t\250\035I\020Y\025\253\347\247?R\372oy\033je\246?\214\304\017z\025\240\211\310\322\027\263\000\372!\300#\010\277n\026\205\232\022i\006\274|O\217*~\253\255\205Zc\r'3\207?\033\317\035\177|2D\272\006I\360\232\212\245\223\034{9\267\267\004\342\002>c\027UQ\347\2002\340\344\230\342\030HhM\030MP\360\252>\257\301\355\3009\2439\347x\300#[\262\200\324}\023\256=\307\304\364\357Wj\007J\351>\210\361\227iAL\251\000\211\026I\267\323\342\345\323\201\3162,\364\341\352 \302Z\351\211\304\205\2060\300\227\301\\vo\001\260\033\340\031\217\331\220\310#\010\013\245\346[FX\210\257\202\0243\314u5\243^\313\014%Q\"\014\305\027'\017\333\246K\003\334\327\227\250\272\263\266/O\010~>\252\254h(\204\024\314w\247\003x\373O\330\364\261q>'J\3740\264\221C\t~\342\376n\020\251\"TZ\200}\035\375\025\306fo\246""\203\305\316H\025\t\203\256\253\360>c\3639v\017\243Q\365\002\002f\235\341H\202a^U\343\2639\243\314\250\210\210\t\"JHI\213\274\3012F\242Hx\307&\331\026b\233\214\r\"L\t\371\360\n\307\010\2430\346E\261l\264{kLHz\267\261c\025\002\215y\334\023\236\372B\344\014\304\026@I\006\321\206\351IPh\033\372\246(\252\027(\374\223\251\364\037\212c\237\350G\202BB\006\224\022U\034\237\205\001\367\031;`\252;$]|h\226{r\023\272a\366\352Xy\371\357~\356\237+\317m\324\235RN\004\t\317\251Z\214\317[<\0369o\244\206\260S\003k`\276\310\342\030\313\342\225\247\313\317\023\253\014\371\224\216f\034h\312;\340Md\233\033\373\270g$f\344\272{\245kM\222\261\213Z\3721\206\276\253\274\344\316\001:\305n\2763m66V.n\236\256N\335i\223\245\2202V\023\305;\337g2\030J\222%\322\037\024\t\216\245\036!rWP\373$}\036\2579k?u\356\327\315\317r\250\350Xw\315\0144DPx\244\020\306\2322SI\223\314D\201\205S4S\nzi\020\326\300\331M\214\367\357\2725}\031\263\242\010\030\327\r\n\256`\267\271\215.&\321\306p\321\233\031\211]8:\2472\2331\020\243ZQS\234\245\306P\243c\rIdm'\024F\341\326Y\314\307\254\256[L\3073\203\242\272y\275\022\222,j\213\363z8\335lJH\342\304+VFY\033\236\366\331\323\272\354bp:\334\350^o\236LM&!8\272\212,9\2412Z\026\204b\255\272JJ\200\254+Z\033\336\226\226\004\207\005\244f\003\363\020\000\005\342\000\2441\002\276\237\257\305~\342\233A\311f\331%\261\013\231\305\342B7;\001>\306\023\030;f\371\314_\332\243\024%uI2\367\243ufqA\327~\331581\030\221P@9m\366\371Hon\022\201\250\253)\260\366\314\316\216&\365\346\006\313E\335d\\\031\340EYb\303\0035\245BgV\254X4\014\254\222\326\366\301S?C\267p\253W?\006R\030\260Wj\371\233v\312\240\325I\237\367\027lA\213\373%[\370\322JX\230\225\333\305\202\213\376\203\307\350\365;\303\201\377\323\014\037\343\357\371\274\377-3\3776=EJ\220\376\314\224\232\377\372\177\325\017\364\014'\374eLc\3414\374\022\342~\254>\377\335?Y\377\240\004\211P~?\364\237\251\032\212\374\251\375\253X\177V\177\206\005\205\024\204\351\216\242\364\223?\354q\277\343-\271a\370\374\277xFf>\317\353\313\375\334\031\323x\223{\307""\366\236\254\377\n\277u\263\352\334H\371\177\277\n\364\370j\177\332?\365\007\367\000\036\237\317B\327\316\367\027\361\227\342d'\312\201\246\243_6\300\376\243\313\367\223\346\373\244/\357|\377\211\356\306\247\321wh{{D\274\207\337\356\255\301\340?\374\375P\231\277t\234'@\204\216\035\376\177As\335\367\320~\230E\252\t\337\261\004\363!\340\366\204t`\343\212+\243\301\367\374r\350\243\376\301\275d\321\212\355~\023\365\246\222&\037\213\257\006 u\243\327^\270\177\210\365\341\"-'\211\376>\270K\375\234K\376\346\177\347\334\355qv?\317r\223\274K\311\017\275T\231\351@\377\312-\007\036i\372\221\377=\307\342\343\263\001(\361\247&&\342\200I\022\371\336t\224\004\336v\003\376xN^\353\267\3508\223_)K\206\023\271%)I&\356\365\373\207\334\036\216z\034\356\361\023\377Y\233\362\237\222\034\256\352\016\357\376\206\207\024\334~\311\373\3107\300\242\271%\364\302*\013\367\256$q\367\210o\361{0\200p\210\344E\244\220\353\275\017\204\236'\305;\313\276#\213\225\267\\\356\277!\027\267\027\341\341\345\204\270H\224\305L\363\303\237_\326z\275\237\343.\353\273\246\233\217\217\221(\223~t\357\364\377\227d\344\374\345~\217f\034\234\\n\271jD\343\241\250eV\035\017\203\213\223\222\0218\255\22090NI\241/\337\370Fo\337\n\265(\352\027\333\277\265q\213\363\203\362\241\343\361\t\341\373\324\273\3368\037\211\374\017\311\274\034\277\037\203\3017\257\301G\207\323X\360\272M\341\\i\224\027{\325\362K\301!\341D\010p\360\363\305\302\355\302o8\374\\\237\353\275\374\356\223OA\335;\276\311\003\211(\273\243\217\356\345\237\227\370\314\023\372\267~\305\361\362\362\037!\342\224\274\007\206\205<\241\031\337\327vU(<^9\241\343\252\347\037C\301\341\365\301\327\366\357\273w\374R!\342\366\276\325\t\217\"\360|?\237+\237\203/\034\274\336\t\374Q\232\205\342G\216\225\032!\345\225J\027\316\377\324\371\221\343<N\351|\351(x\324\177G3\225\t1\311\337;\3768F(\177\030\210Fyz\337c\324\231|\243\236.\374<Q;\335\365?\301\305\305\362qqFA\377\266\217\256\036$x\2747M!|\274?\\Z<\236\007]\351x&\362q\372{z]\323\274}\035~\223\366\221\201\036\271(\235\304""\377'\272\334\026\237\252\267\3241\230\335\370_\341\337~\322\372Q\316\363\036\224\353y\t.\007\350\374SC\256\267\274\233\206\377>\021_B\350\377V\224\363\364=>\022\375|\034\367Pyt\034\356\356-\245\270\267G\365\234\375\357\224\366\374\316\333xG\276o\372\024\233\227k\317\345\337\371|\376\347F\037\251\274\211p\013\312\376\374\177\376n\375\373\376c\333O\320\376\275\036\345\355\324\036[~\33486\217\233\322{p\335\373^\077\077l\237|\2141\317\037\225\333\333w\351{i\036\334<\235\234S\203\270sM\247s\t.\307\350\327p\331Z\335.\377\247\256\321\335_Vw/\317\371\370\035\216gU\264\327\327\253\300\033\334zz\344nf\350o\037Gi;}\036\367k/;\317\265\337>ddfo\321\345\320Wbf\375\217ak\023\3619\356T\363M\207r\256\365\023\315\300\232\315\t\345Y\354\330\233;\325*\2215\352M\366\336\275XSH\3044\224$@\325)M\024'\340\370c~\326/\355;\037B\265q\274b\372fo\271\332]\347\367\370\376\007:}\177\243\000\017Rb\247\302b\177\275\360\347\235\276u\350\021\212\205p<\347\310g/\035\314k\231\265\313\377J\270\\\202\355 \3011\357\373|\303D\266t\357\276\253\357\272\315\203\273o\010\261\356\364?M\215\273\036\337\326{\253\352\255\324\370\275G\233\277\345\341\350\177~e\350\373\332\032\233\\=\214\270}<\247\336{\rW\261\372\3555\361\342^\344~\277Y\237\275\330\365\374\334G\350\365\207w\301\366~\221\260\003\316\037\201\346c\230z>\323\213\334\016\371\203\347/\375>\237\237\363\3404\276\206\316<$z\237Ku/j\374\345O\177\334\356v\266\253C:s\347\205_\237@\376\024\304\302'\375k\362\1772\261\23351\211\257\3058\254\"h9\250\274X\315\010 \210\373\024\037\006f\342\013\302\311\243\223\n\034P\271\207t\367qa\342\242\374#M\023\321\033\364kCs2yO\201\267\013\n\274\241\002\265\234\t\2078\343Ru9C\236[\004r[\340\016\212T\2138\275\314}\272\017J\252\002[\272\230\310\251`I!\2462\256\203\215\326j\236\251\022VsQ\217|\270|;\240g:}d\326\257&\242f\252\262(Q\302W\371A\3574\370\202\343\371\030\020\325\220\265\004C\223\374\234\306~\345.'\357\2520\025.\325\003_\241\232\341M\373\361\254\321sw\251K#\230z\233l\034Jy\261\200k\024\"\311\006-\323\327\364b\0018\036""\241j\376\312X\005*\311\030\323\354\257\363\014c\202m\305\r\237\356>3\032K&\017\346\254\034\213S\372\031y*\277\207z\300\325\321r\024\304H|\037\306\364\305\032:.-\020\263%g\373\370}a|W\370\373b\3155O=\207m\370\331SK\343\025i\346!4\032\3665\215\351<\357>\024nVl\034\311\247\216#0\037\330\3749\320U\335\240d'\2227\377#\3600\031\267w_\032\301v\373\010\270h\345L\243\203\t^\214!\200\277;\032\021?\033\316)\307\315\177\243\300\261\366\357\017\317jq\017\307\377\305\334\221N\024$\034\017\352\242\200";
    PyObject *data = __Pyx_DecompressString(cstring, 21832, 2);
    if (unlikely(!data)) __PYX_ERR(0, 1, __pyx_L1_error)
    const char* const bytes = __Pyx_PyBytes_AsString(data);
    #if !CYTHON_ASSUME_SAFE_MACROS
    if (likely(bytes)); else { Py_DECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) }
    #endif
    #elif (CYTHON_COMPRESS_STRINGS) != 0 /* compression: zlib (23450 bytes) */
const char* const cstring = "x\332\335\275K{\023W\2720\032\322\354\275\tM\272\241C\022\222\220\244Hp\260\323X\306\220\244\023'$\333\3302\270\343\033\226\034B\023v\235\262T\226\253\221TBU\3026}\035}\017\263\343\347\2343\320\363=\337@C\017=\364\220!\303\0322\364\263\377\300\351\237p\336\313\272V\225dA\362MN7\261\252V\255\373z\327\273\336\373*\\\271re\212\376])\300\3777&'\257\\\231\234\374\334Y\014\232\205\311\302\225\253\327\246>\377\n\376}\306)\177(\\\2717=S\236\377a\276|\367\276S\252\373~\313\251\372\261_\211\375\2523\0229\215\240\331\211\375\310\361j\2413\356xQ\324\201\224\232\343my\017|\263\340N\024\373\r'\210\234\266\037\265\302f\024<\362\235\321\212\327t\036v\374\366\216\263\321\016\233q#\214b\307k\265\306\240\246H\025\350_U\204\275\301\326 \373\203\240E\217^%\016\036\005\361\216S\361\352\225N\335\213\203\260\351x\315\252\023\305a\333\253AE+\3637\352a\345\301}\007\2360W=rZ^'\202\341\374\367?\377\037\247\262S\251\373\316Hub\244\352\214>\366\333\241\2561l;A\025>\266\302V\247\305\311\376\330\327N\320\214\375\366#\017\252\211\274GPK\034:\2637\314f\352u#\217\327\366q\260\r\247\325\366\037\005a'r*a\007\277:\243\3150\206\031\305\301\343\323fX\257\302\200\214\212f\352\276\327\3061\302\264o\372\365*\367FV=\n%\373T\\\351\264\333~3\226\t\327\241\021\243\332b\273\r#\253l\372\225\007Xy\325\213\275u/\202^\312\361\252\316Oa\313\343PM3\206U\307\314[A\274i\014\256\036\300\002\206\315\372N\377\352\203\rc\336\243\315\260\003\343X\367\305\n`\003f\321\355J\275Se8\313\014\263\323\252\207\036\254\021\315\004v5ryu\374&\316\033\257\2229\3169\030}\325\3514#\234\nk`\360\000K\346\214\006U\234\032'\336\364bg\313\213\232\227b\374\222\032\036\000y\225\032\200u\246Q\031M\334\3425s&S\365\217\0323\017\025l\005\000\022\320\215\252\263\265\3517a\265\233\343v\376\r\352*\014\212Am\023\340\267\356Ws\032J5C\003\270l\254\363e\000{\257\035\323\023\264\367\213\267\217\013c\201\310/?\324Eo\233\241\203\267&\2640R\035\003,\342\301\344\363\226\005@\255`g\004D\300\272\340\026\240UnV\375\215\240\031\304>\2015\355)\234%\265\211q\243\211""\215l4\271\224\356%\001\035ut\224\207\225\335~\021\017\025@\231\340k\335\207^\371\331\361\232\340\275\002\243\322\375\206\3355\257;\206x\217\372\345\214\306\355\240V\363\3330X\217\360\203QCI\300\372`\204\220\332\376<\206~\0354k\357T*~\024mt\352\365\035\036U\277vpG\373\264\317y,\330\247\250\322\366\375&\354p,&7\366}\254\342\257\260z\200\365a/mxA]\357z\3611\016\032~\330\211\247+\204\272a\".\t\204\343_b|\363\000\260>\355u\027\263^/\267;>,\211\230&\332\025\215\206_\r<X\365h\247Y\231\346y\204s\005\366\253\327\254q\203\316\370\267\360wZ\340\366\031h\241\035\326\353~{\n&5\006\000\n\377\014G\234+6T\354E\017\344s\344\327\0320\027\256\334X\331*\n\256\2130\347\272\316h=h\372\316\344\347_\216\345\344\252\371q\t\353\200\036\227\3520K2\363\347\237\251\334\002\350\000\t\311C\310m\371\355\n4\017'\031!h\030\010\300;N\360\003\177g=\364\332\334\311\006\340\177\237\236\340H\302c\317\350\250cT\321\366+a\033\000\253\016\373\251\272\003@\201\323\007\013\347\341\351\216\365GuZ?n\244\340\224\3441[\205\205\016*8\305\224\033V\2520D\375\3766`\320h`\305\262:s\033\253\306\242\302\275\351ju)\214}y\256\300\221\213\245`\037\373\204\220\005\250K\330d\320\222E\346\010\3340\237\337\004\000\004\260\301\364\010\336b A\306\035Nkx8\021\016\202\275Q\264\336\2116\351\304k#6\341\234TQ\324i\373\251\363\275\0226\032A\014SX(\030\035^\300\001\304)\314\007\233~6\203\263\341(\343}\344\343j\352\032\226\3024\336\244\375 \367\265\231u\245\035\342\336M\367X\355\014\330\321\320{$Xh\356\254\216J\250\264r\344\317.~q\353~\263\026oZ=\265P\0075]\265\346\332\242\033`\n\354uZ\243~\213a\345}\202\016\302\356IW\000;\210\246\030v\252\363{gr\214\340\254\323\202\325 \244\240\020\234\254\353\21611-\236/\350\3468\017W\220&\315p\013\201\001v\240\244\213\240\270Sl\264\000\316\347\r\362\241\215\210\305\t7\000\ryL\3504\302\252?\345Lo\340\312\000njL)\312d\035@\374\201\356|\010;\264\356\265\"\265\033\350P\223\004\255\256\000G1\345\334\350S\230f\224\262!\204\003^\024]R\225\216\332\315\022J\0363)\347\266_\003z\271\255\353\226[1\335\205\325t""\306\027\350\204\310\3322W$\333\225,v1\321\201\250\003\351j\2030\214\354\303.B\350\207r\026=\262\005\307\250BF\r\257\375\000\017\325\310\221\233\355\336t\253\265\030\002\352\016\333\367\235\345\022v\3532\236\033@\223t\332u@\370q'\342\304-\240,\302-q\254\031\205V\375q\277\351\255\327\005e\302E\256\347Ts=UP\343?\342?\216,\354\214^q\256k`\253\006\021\267\272\216lJ\355k\246L\361\021&\"\306\315\0341\014G\233tH\214\331\215\307H\272\250:^\254\347\r~p\231\\q!w\304D\247\250i\340<\232x:\202Zem\232\351b<G\274\210\0047\005M\343\264\206\304\365Ir\351\210:d\321i\300\316\260\207\261\350\006p\"\3530\215\310\230b\267q\023W\201\203\252\370D\357\373M\277\035\001z4JH\264\230\355\220G;\305\337\256\370-\004\332\033Pm\255M\215#\005\221;U\300g\0003\324\254\370@\023T\207)\240i\246\243s\2730f\267\023\274h#\262\230\321\024p\2360\262\033m\034\367\2156\200\276\337\276G\250\350\276B\203\232\002\226\004\004\342E\337\253\217\023&`\224\037\271\204\206\020\210D\361\377\376_\377\267#\200\t'wfy\251<\277\264V,\001\022hkl\311\330\213i\260\261\024\016\264\276!\032a\232@6\250\216\3229\350#\320\323\262\2272\335\301S\243=\346|\373\255\200zG\234\301Hb\322V#\222\334\205\024\236\"\332\025\233^\344\242x\300\225P\226\323\261\024^\374E\221\262hJ\263\t\326$xD5\212\"\004\326\021\360\345\023\014\237\334&\003\373\250\346\017\271\002\371>f\357.\273\237G7N\344\235\032\277XC\213\346\313kP\254\034J\020D\231\026v2\323\376\224\252epO\326;\006\221\000\247o$\331\236>S\300,\362\021S\221^\222\027\350\202X\211\301\235x\261\306;\001s\342\022\014'\352a\re]-g#\000V\215\210\"$\211D~j\001\031f\337\305L\314A\231\230\030\361\373\330\177\377\317\2363\263:_\236\237\231^\230\002\302\325$[\221eVl\211\022\0261d!\nd<\t$\275\"\217\220\240\306R\353\006e|AW\017\207\024 \235\200\272\3628\004\026\010%{t\"\001\037\356\027\234\262L\2473-\242\352\0203]8\351\210\377\315\010Q\037\020\251\233>O(\341i\334p\004s\033\346i\320P\310\246\240jP\017\345Mh\275\341\307\233a\225\304\234m y\200j\305z\0011\266\303V\233\371JZ4\004t\024m`C\314\325`\276\215\240\035""\305\252\302\234f\365\\\342\324U\035\244n\240\234\244\\\250\333X5\260\275\033A\r\330\213\252\252M\225\004\344\310\\Wv\010\253~\334i7\243)\225@\343\002l\347\337\203\345\362\261\372\202|\270\354d\222\356O1\003\220\035\235U!\366\030\271\334\000\027X\017\r\247\273`eT/\305m\257\001\235\260\373\365-`\335\212\342\211\201\244\3112\312\014\300D\306]\237\034\313\224\246\245py0\320]z\202z\274-/\210\215\252\323\354\366h\266&X\333f<\272\361\221q\032\021I\371\027\335\304\337\020\353\374E6\363\267\217\306\014\030l\"\214\363\321\347\324\315-3%\372\2103,\321\214~\301\212\334j\260\261\001o\260[\325\253\363\315u\347\312\230\250\326\337\366+\035\250\267\021T\233Am\023P+0\331\004\000pd\000\253\337v\001r\020\312\000zq\327\210b$xS\362\340*l\034)\3764\017\034\221\271\323\302>\031\275\356_\257\220\264m\000y\200\023R\272\0060sM\301+\023\354\032O\340\306\300M\036T\255\3262U\320s5\004`\343!\003\3655\270\000W\212}\343\301\222\270\326\350u\377\222\251\241\221\030\360\021\340\024$\200y\357q\321u\024a\000C\343\243`\237\200Ab\274\031)\320\306\321\265\375\206\007\233!\303\333)T\217\270\026\210HU\210\231NAn\210<\244\010\261\370\",Q\367\275&\264\335i9\210W\303\266\007\334\263\302\272\225\260\265CS\204\271\2503\235&\213\315\350\\\240\276\tV\205\224\007~5\253\301p6\352^M\340o\222\2762\331\341\001\373Tk\302\341\243\245\365D8\001\225\334i\370\2626<lp^\251\023\270\317*\204y\211\002\020\334.A\\U\343A=7HG\303\243\217\247\031\357\030\331\026n~X\235\361\362N\313\247\347\355\230\301\203vL\025\010\365\353\330^\237\017\370\211y\367X\360A\262\361\005X\307:\036Q\355\000\316e\321\353\374\254N\235\362\262\250J+\275`n\363J\005\033\366\226W\332)\213dy\361R\324~\303kvH\312P\251w\242~\035\320t\256\004\253a\213\nM\0337\214es\347\005\225p|4\321\224\3544+t\010\303\351d\347\256\372u?\215\000\rY\260\346\221\220\303\017$\326\261\353\330\000\220\325@.d\210&\0138e`}\205Q\325\213\346\370\207\250\322\356(\200$wH\227\004\3649.P\243\235\227\346A\013\271y\340\366@\200ZC\026R\200\320\004\315aE\360\233\221\235\225H6\305\202\323D\213c""\325\316\007\333%\330@\341Ee\271DhLAln>+\207\363(\360H\016n\326,x5!\326\006\302\242\321\330\021R:\3227X\022\024\240\035Q\020\312*9\022,r\005\204{\220\3561\313g\316\275~2N\224\340K\272WH\331\2252\205T\252@\370\032\234\243j\361\005NYC\236a\036\2700l8\265\252\272\312\310\333\360m\374*\244\210\330U\232/A\245)\352\266\244\304\031NIC\203\372\274A\272\216f\205\226\307A\361\004\"\307\265\325\005\263\340\r\330GT\244\031\211\205\234rdC\204\260\t\036F?\375\364S\007H\363\377\367\340\377t\234\331\351\362\264S\272\2734\343\314M\317/\024g\235\351\271rq\025RJ\345\342\242SZ(\026W\000y\257,L\227\347\226W\027\205\346\366\316\364\367E\247<\277X\024\357\370\350\224\346\227f\212\364\211R\027\201\373.\003\373=\316M,-\227\251\031h\241\274\354\334)\336\300b\267\346K\316\342\364]gfz\255T\344|\013\313\245\222\352\034t\364\336l\361\306\332\315\373\314\345\323X\375\373i\341\345\270\275\346\306\022[\013\306:D\224<\330p\220\333D\211Y\310\027m\243?\354\210V\034\027{\340\222\300;\016Y\375dPQ\254\\\266\304\221R\376@b\004\006\361\354w\313\302\3402\263\2651t\273\323\014\036\242\274\336\322\035\316\002\302\335q\026\002`\241p\251f-0\215\202\307H\037F\r/\256l\322J>\212\314LD\376\330D\231\206j\225K\321\225\004r\300\233\000\373*y;\026!\022\232s\303:M\220\347\0024\273\006zW\025\261YG\237J$\031;\\nZ\033\240W\220\304\304\263h\270R\204l_\240\310\326&NP\215\245\245\016*\212_xX\242\260\313D\266\002\017UX\022\242J\254\226\372\202h\330P\234\210\034\276T[2\001jH?\201\026\023\335\255#L\360\031\302@=\013\264>2>(\202Q\366:Z\3579\353o\370m$\340Za\024\217G\000\212\025C\037#\220n\314\314\363:\302\213\327\336\2312\304V\226\205\001K\332\265\304b\226@\244Js(\331\271y-\205Ar:*X\231Z-)\263\315\373\274\334\256\315\230\254E\224\311\205\210\3348\211\345\254Z\331\204\236\334\310\207;\002i\354Y\226\366\2267Q/ ^\362\330v\234\336\226/sH\3410\223L\216)Z\033\247\254\256\022\037\263\254{\021u\262\202\350\346\224\357\205\312\326J\344lt|\007\274dFF39\325\217H\n\260\305\322\245d\331j@\343JSL'\021i\212\035R\254D)\245\027\020\367\265\314p""\315fL`}\341z\213\200\376`\306Zu\257))\326Y\237zI\364\010\226\256J h3\035S\325\337\007\227\276,\363\367/\337\254\264wZ\370\021z\3554:\021\361z\036\331C\370\244\335\213b\\\364bSh/\245\254\303\313j\271\361\264F\221\302\224!\333\224+\206i##bU\345\3134\353\344\32572\241\233\"=8?\023\202i\363\301'hO:-\240\361\216\331\0072j!\303\032\330\375m@;\005\326\212\257K\251`\313\333a\224c\353O\260-a\227\305Z\001b]m\275\200\221Gr\255\006\017g\3615}\262\245m\0252\372\222\274\262\320\272\342B\t\253\001\266A\2049\216\224\331X\266\304DE\222n9+\223\323\000v\204D\013}HVB\254\244\r\366\253J\213 \205\356\203\352\262d\323\302\360I\324cW\202\206~\315\361\n\020\317\001\360\002c9u*\271\271\227\322\274\376\254\232\033~#l#G\220?1\300\023e$C\251,9<B\316\202H\306\277\257P$\247f\333\320\322f\365Tf\271\320\031\361\007\177\257J,\237\306\3779YR\247\200\005\2139\231\246\230r\203\277\023\006Q0D\366\237\262\331Y\253\0050\032\204\325\240B\022\224\n\212o\200\300\241\345\333\200\336\327\r@\337\360\341l\2266.B\311\315\246\0241\362\2129\031\t\327\205\355\232\361IZ\257\250\2511\215B\030\312x/\244\026u\230\202).l\270\242B\346E}\036\262\314\317\350\225!e\030\276\006\245u1\355ws\2520\313\244L;\344\3064J\241\352\205\345\t\026\233\"lOuFI\210Z\233\202\252\037\027\350!g\316s\013U\007\321zG\224\225\266\034\375\263\333\363\034*j}\210\234H\241\037\221-\3739E\230g3\344I\2709\207:W\200+ \206\232L\026s\276\0332Ra\255n\364\023\3665s\177RFj}2\016Q\246\311a\327\002\305VI\201\201\251:\323\\\230\376\266\216<&\013G\355\017\022\331\000\332\210\0144\203\257;\331\\8YD#\220@6o\326(\267M \326\303\260\245>*\353\210\364\016\302oA\023\026\222IR\036 ,\276\337\262\362\004(\263\246\276(\363@\255\331a\334\3533)\2072`Ecj\271\265\252\211\035\rt7\211D\262\332\352k\310\220\227K\201:)\366\354\031Q\310\231\2673op\332\357V6\"\362\211\302\265\223w\232\025e\025\340\032\026wV.m(\2738=\243\226S~&Z3xLkh\330\360\350,\262\260e\341Cg\303\354\r3W\255FG\023\213x\001\230\303\016\340\037\243\036\026\020\327wXD\\\035\260\001%:\314\032\000\223\332W[Qe\213\244""\014\245\007\347=\252R\304b4\362\026\220\275[a\373\2012\365\262T\340\300\002Y\254\033 %\243\016m\035\211J\261\221Hhq\322\033Z\251dl\247\210\314\334\344\347\3533\221\202\177\242\354i\336j\000\3436d\005\372\0302\013\220\n\313\302\356Z\275\321\267\233\262\320\2041]9\345\007\220\365)\353\334\\\262E\222\213z3J\226\007J\024Q\243\32461\247\314N\250\303\020\250\240\025n\003:\211\314\306\320\005\005\003;\\\301\024\024C^TW\321\t\213\275\265\306-\212\220\330\337\365:\210\314Q6\223_\277e\257`\210\346\371\263i\327\256\316%\375y\010RBe1\250^CGdv\\c\245>D\266\316`\252S\345WV:d\017{\363\270\033\025\026\"HL[\335\324\205m\245\205E1Svi_\347\304;-_\244\240\243P\332.w\335\257x\021JQc\324\254\241\270\016\266U?K\335\242d\344r4\030G\351\2312&\333,\2237-\316I\t:$\354\rS|\000\314;\243s\363\253\245\262S\\*\257\336E\363!r\006\230D\333P\240\005\275N=\036\323\025W\224\355L\rH\312u?\336\362\375\246M=\031\231\221Q\221\272h\245\3705\276\263\365\203)\213\013\200\257\004x\336\031:#\301\344\006P.\000\003\272\200P+\246\3716Fw\232\2022-\374I\227\277\t\007^}\207\270\254\334\\0\306\016Y=\230\233;\225g\033!\005@\250\002S\2537L6\003\031\312\304\036\316\014\036\304\330\301\246\327\3603\371\211\351\021x\2365\252\230\035\221\311\252\2406/\233(\233Ou\261}\206\250e\230\302\254M\351\353\260\221\312hZ\035a\245\312\300\225\262\303\276M\255\256V\370\017\302\347\251\374\006\321\235B\021\227\235\371\225\031\264.i*)6\217QXK\240\370\275P(\364\257O\240\320<#\2659\242a\261~\201\021\307\221>5\033\242ol\246@v\3439]\037\200\346\331\253S\365\375\273\261t\321\316:\300t\300\263\351o\267\002\241}ao\252\3013F\253\216kSk\343*\016[\204l\3512\231\031R,&\300.\217\254 \231c\006\236\346\207\221`\021\276R\016s\226\\(eRM\270\316\007\3348'e\024\354\251a\223\257\312VF\234\207Vgp\201S\350\017\252\033\200O\211\0134\007\310\253_549\350\302jVA\247\231\250\332a\022\250\323F\353\233fH\032[\302L\022\351\351r)Ix\377/\372\270\264\363p\273i\325\017\344\211\311\355\017\017\256\224\007,\271\250VB\264\247#_\036\\[1}\376\306\206\317\014\220>\273\310""\345\217\353#y\334\216qva\353\017\310\364C\220\321&\211\003L5\360f\272\244a\330\264\223q\265\320u\276p\001&$-\267=]Gh\232\320\216\3469\264\3323\241 IJ\277\r$\211\023\201\026\347sY\336\265\345E\344\202l\373k\037\355T\202\036_Y_\222\271\264h9\327\t\256\237}\304`g\230l\335\322\342\336\206\241\227#^\346\264 \320\320\034.\205Z\324\315\207Dd\222u\371\205\204?\026\347/\010Kg\234\263o\214\241K\237ZC\000)\366*\236\035\224oN\033\235\010u\214!=\301:\242\001R\277\241\013\233\002\277\364\212\347r\257C\327\314R\2774\213\033\r(\317\2665jV\314\265\356\353\2316Lu\366\004)sl\"\261\206\255\346r\332\272\313\352\220\252sn\240\214\025\211@\312\231^.:\312\217**8RB\213\206\345[N\rY\277G^\022\245MX\037\340L2\207\353\346\224\360Lgk\035\207}H:M\244NW\240\2119\265\262\206\224TE\0220a\0053V5\352\253\207(T\224\372{\215\251B6\020\262g\370R\034^b\336\232\355L\006\333\306IG\345\276\273\237+\021\372\004\366\212\32209\340\333\224\352@\326\357\037z\247\214Fy\201\210(\220\336\323\203K*/S&\271\360\214u[^L\304\004\372\"\344X\327\034\215\227\331\207\300\300\314,\0306Y\206\0139\025cw\320\272\321\000\031\225\253\237J\013\217\344\214\273\321\025<\230<\241[\025>\035R`\250\t\262M\277\241\252O\213\256\217\036\244\025\323\002\265Gi\373ci2b\026\272\211\242\":.L\365\260\020b\3608\214\023\023\311\345\324\034\345W`\331\231S-v\031C\274\2371\006\276\031\2065\000\212\231M\350\256?rkjd\221\376L\215\224n\245\0318G:X\306\220\271S\333TB\316\230\3547\220\\\267H\356,\325\017\353\222\n\001\201\323W\310\245\364\263\325m\330a`ry\225t-y\354J\266\346t\024\033\223y\032\230;O\254`\352\035\206.,\205\n\351\302b<l\322\2124\314Q]\035T`\230\336\016[>\257\303\3670\214\306\254\264\326\276\357X\226\372\264r\271\272:\304A\303\026\265\n\001\266\027\376\337c/Y\336\224Le\352\240\240 *\342\222\025\347\202 0\235\037\203\004XE\206\036m\237\222\3312R\300v_)u\310\260~JY\275\\7\214^\256[6/\364\226\252\0041\274\341,&\361\365\374\354BQ\232;\240\025\352\272\346\351\004x\000F\013\352\251\3001v\325\031Wu\275V?\333\372\364\250\226\254U\375\205[c+\327\251L""\235\302e\265O\356#l\256S\345Wp^\245\315\256\242\203s\335\034\255\361X\376\253Y)\214Y\267r\334#g\267\010}\234\260j*D\007\0269\330\033\005\014\334 \334v\332\235f\223C\200U\014\237'\335\254\205\326\245'\342&N\260\264bC\257>\037\316\230\202\331\320\022\344R\201w\246\314\336\261\362\227\335\321\360`m\242\031\316\267\327\235\253cf\371\025\366\260\021,_&\224\217\353\261o':\310\313N\263\371SH\312\320\234\271*\t\230\347`A\316\215\205\345\231\357\213\263}\367\200,\305\376\034\302q\231\027=\325\213\3132\342\216K\032ktC3k(\363G\025qi\334AA\3278\013\272dM\227\365\212k\244$*@v\273,$p\031\241\314\350Uk\345\321\016h<\353*4\346\334\323\307\354}\253w)l8`\251.k\001m\n\304\275v\020\211\314T\311\350\030\021n4Xe\242\204~\002\001\233\237JA\225X4)^4%\370X\273\224\346\032\221\333x\235\204\305(\300)yS\261\212\254\335@\253\010i~\335\257\202\027\013\375\006\037R\025\335\032h\343\220\212\254Da\033\350p\240\307\001A\221\024\305.gV\267H\020H\232\2036Mh^\000\266\010\010\201\026t\236\002\260\220=#I\244\266\210j\247\025\020P\255\253]C\035Qe\023\270(\332@R\210\245\275%\264\333\364KD\3072\203\202\364m7\257\315\227h\313\214\033F\215\211\035\007\247kv\243\021\306@\327VIU\250\235D\371F\253\241t\236\214\235\026\360\247\200\202\302\246\377\265\214\260\3006\316\316\0261\354R:\033\304cv\273\212l\021\210a\312\361\321\034\221\244C\310\375[hB\225J\007\37230\277\254f$\267\210B~j\270\310E\2627\226)\313\266\313.\352\325M\261;\334(\353\013\231\361\243e\032M\037\177cS\212\033\375\275\342|\264/\206\254\025`<\"\257B\273\375\0221\223\003\272lgG\"\007\335m\226\327\312\316jqz\346V\221b\026Ext\340\317\270^\355\226\234\372\266]E\231\214\202\205\025\272SeIH\247)\260\276\305\224|qE\005\346\024\223\317K\274FS\001+\254\004?\351II3\375\022\205\310\2229\323>\312\033&]\023\n\"\214\211\223\025\030A\254\210\331\306]j\3567\333\271\200Co\360iiUC\250{\\,r\204\201DG\005\257\313\313\232\342\245\241\217Ft\275\212r\223\223D\345\270\251cBB\247\323T\016\301\005\347\016{\276\242\364\r=\233\375\355\330\244\224\211.\332\200\302a\275\032n5Q~""\030nE\005\243\275h\023\323\311?\272\335\340(=\372\004T\345\332~#|\344W\307\256_\277\316T\277\022\250H\371vu\312\006w\231!%\371%?\"\241\306\200\312\346kM\266\202AP\030W\236\026\2178Na\205b+J\305\220\013Xx\003\020M\263\202\032\343Q\021r!\334\330\030\233\267\244\363\312U7O]\0224\005\301\243C\375\344\2246M\353\346\363\"hE(f\010B\345b?/\315\242\374\234(\0012\024\232\351\202N~\010^\023\330\216v\224\023(a\272]KEI\320\221\006\220Q\210\001\222f\004\246F=\261/L\"E\367\200\343\255K\335\201@\245\221\035\372 \363\277\265\210E\255A\025}\3177vP\347\036\231\341\375r\203S\344\376\357\177WX\005\305\210\345\250+\362\374\177\216\210\333\245\371\272\200\r\210\202\252\355\177\255)\307B\241`4\217J\363A\372\013[ga\3523t<\242l\230\222Q\026\247\177>65\337\204,\320\231\265\362\334\370\227l$\t\031}\323-d\312\221\231\260\354\027\237\035\225\313J\306\tkxxt\222M\n[a\022?}\351\342\245\301%\344TAF\264{\300\323\326o\177\237u\256\321\246\220\022$7\275H\235\017\034A\304\300s\312o\247\340\334\r;f@\024\035\237\205\345\311X\272R\301]\344\003[\344,7\331\335\370\262S\203M\032\003,\2215\330zP\307\322\036Kp`ZD`\346\222\324\347\376\367\377\370\277\234\225v\360\310\253\3548\237@2\324\210\0050\331\252\242\340\224\221\344\223\344\310\235\260\375\200\021G\001\035^\027\346\027\347\313N\361\307\231bq\026\370\235q\224\005\314\317\315\317L\227\347\227\227\234\345\245\205\273\350nj\307\250\221\260+lJa\331\t\022\244\232\207|\342\t\265\221.p!\245\023\221X:\220\301\251\221J\257\307\312\367\"+\210pRu\300\271\000X1\032V\003\367\013\026V o\367\334\220R\216\331\005\244\252B:\344\327w\204\030ON\227>X\210P\373y\245\321\227\207m\003\372t\303\010k\031\207\200\245\320=I\340q\222\013)*A\362`i\007\374\374j\221\223@\020\017\232\"pM*\244\263%\030XG\013(\\\341\376u\311AR}\001p\204\350t\273\220\266y\323\237Pm\rDb\005&\351\301XV\355s\t\277\n\r\017\022\212vM\306\376\314\001I\0140\205]JY\362b\3476\234&Y]\014\010\340\324\027L&D\374f\301j \211\312\014\353\2704v\005|=t\305\343y\206\306AlFP\215/E\251m5l\355\227i\0162\274+\033\275\223nR\034""\025\254XGYb~oFUc8\241\354\005\233Q\353\020\221\254\2536\251\310\024LS\005/{\212\345T\325\247/\243\251\221\223\212r\354\310vY\\we\250vD\344<\202a\230\3538l\232\270\020\010:\240Z_\262A#2\210\330T\023\322m3\025)$\245'\026D\310\365\014Fc\275\237\006\227<\375\317\026\253\006\355\035Cv\242M\tU\251\315\217c\2071\302\261]kZ[\027U\263\026\347\250#\260\215\364\251\004\370\007i \254\321\027\323\277L_!\211(\372\304\314\245\312\226=\257\244K\260p\235\2144\261\303Qq\355\334\022\021\032\010\314k\356\010$5\236\301\343bc4\303-\252\206\301\343\305N\252\001 \036\254c8\243\211i\203\220.uZ\35002\241\211\200\341r\341\244G\023[\352\335%\003\267\002\244\016Y~+r\005\355]\250\256S\210\005gZ\205\373\341\367\262\2606\2467&\344'\257\\1\245\017Z\215zo\001\330\357m\276\374\001M\3074\247\310\301\345$\177\206\236\312D\353-\371[N\331[\277$\013\352B\320\022\306mA\036\260\355o\372|u\006\327B\275\341\3630\337\021D\262u8\333\"T\023\302\227\035d\313\020\336\362J\025\320%\205d3\252\320Q%\356-\026\027\227W\357\272w\246W\227\346\227n\336w\026\roSg3\250\221.\177\361\006F9\027\341+\026o\020\365\265(w\241W\345`\234\251x<\372\010\341\310\030\2265\302b\256\341\205\tdc\371JtC\340 \352@\004Qe\t\257\367\202\006`F]A\245\035F\341F\354\024\2535\1771\317eI\022\350\213\341c@B\2363\027\000\307\035n/ML/\3711\371\263\370\246\243\250i\263OA\227\254\250C8\007C\027[\364*\312\321h\350B\022\233d\013\r\010\365/\200y)\224\306\264\2010\235\326&\322\210\255R\021\347\260`\250e\035\203m2\244\2622Hq{\206\035\312\200,\312\340$\033R\0350\"KpU)\352V*\227\235&\016\203\310\n\235/0\201%\357\322\261W\220\014\255\301Nnr>\302\376\205\234\274V\220\315\230l\323\306\231\260\014P\310\005\010\233PDN\311>\223f\010\217\320\230Ey\377JkK\203\235\247f\252\036\025\203\2433\022\224\027]\267P\317e\270T\030u(\"c\222\220;S[\205\222\304\347fH\016N\336\016\316\216\222\014\310\236AZ\026\233\241\304h\264MQ\270\250^\254\021\301p\314\212\226.@\312\325\035\003\254\217\375W\232\021\375\205\314\234\324\2166\354\021\307\005N\226\254\312\024\257b\266\n\232g\211\301""\263\025\251r\302>\332\25736\207Y\\\331\001\364\335\244\256\333m\331J\226\202Sd\352XK\371\311\276\025\246\306\225\031\311\272\3124\235\326\276\207\2060i)\034\020\244\220\341\205\002\337o\312\000\327\320\016\225a\031\035E\007\010T\020D\301\366R\014\241\224\315\022\0242i:\366\343\2107\275\246\363\007Zpc\013\260\233j\330\304\316i\241_\205\245~\234o)\314\032E\351\336\r\262{\342V,\245\230X!\354\342\000\017#\212s\271\304\274bY\305W'P\215\375\t2\334V\367<\245\257G\262\257C\340 \321\":\341\022\371\300\241\331\366\014\257=n-\277\036\254\373,f\241x#\225XN\326Jqe\374\263/?\023<\027.4\352\310\326+u4RF\201,\305\370\210\003\366\201\302h\273\033\316N\330!\206\217\354\357 \237Y \336$\2366&\274s\2114\345D\n\271P\034\006xI\370\337 i\001\245\211\336/p\227\333\235f\205q\232\025}\250\262\351\241\323\213\337\216\226Wo\312\330\2111J\225\333Zq\273\\\022g\005\013\211r\242$\240\306l\271\231\027\344\033m_\245\021\2476E\265\300\000\357lR\276\272\224yl\271\305\007\370=\017q_\020\026\212(\346\276\257\222\263\341n\325'X\200\373$\006]n\303p\340\215\rxs$\263N\311\307P[\333\001\332q\362\374\262\375:\034\\\030 CD\346=\311\362\324M\350a\314X\214\205\264\343J\032\253\003\306-bmSf\004\271\212\327\212q\353\363A\211\307K\2520\031f\210rl\244\241\211L+\376\267v\337L\325\200J\006Q\301\274\245\316\270l\032\024@\271\313\\\241\005\355\251\272d\224fQ\237\n\332l\324I2O\217\237\031\373\242\316;xLI\351\256\211fd\367\344X\320\267\276E=\222\370\226\005\3748\355\\\353z\247\376@\035\310\251Z\321bW\324\210\217\023t>\242w\311e\200\245qT\277\231F\026\\\037InE\204\016^\322i)\2776\264\007\3755\007G\352\014\262\301\235E\r\312c>B\t\277\345\343\211n\346\034\271\320\031\025>}S\316\027W\256h9\276\336gn\272\336\034 \033\\\261\241\036\020^R\243\353a\210AJ\026=Sy\241\2218\345R\205\360\334qM\203\377\314v\274?&\243N\253\020\243*\034\266V\007\321\202\333\265\312@}}\352,J\242c\250\032\353a\305\253\3538\344\300\256\267\241\216\005L\325\236SBw\023\370:\0366\273\327\273\034\263\017#\022\213\222k\034\304O8i\033\005O\346*n^^i\203%3\001\257""\305\204S\343\212&\0305\"\037_6\"\030p]\313\375\\d\205*n%\377\006\033\214\266g\330\347\017\276\320&\023\302~\305o\243\346\203M;\323^9SFh\250\241\356{\311\367\3061\311\350B\241\260\202q\3359?,J\300\372\216\376\007\324\312\240\010\332\364]\205\213\312\270L\222hH\354\244\264\367\274P\341\323\021i\\\330\2245\2217\330\t;\237\274RHx90\221\256\351}\034\252\225_\323\200}J\244\203Qs\r\206\177\237\364\\`\262U\306\207\221~\201ZC(\016qi\340\246\243t\231JB\250\312Dk\210\223\205\031\267 \220\245\237\207\010=\315\014K\035\251\224\361\234\310|$\007\226E\344\245q\2214\021D\301\372m!7\026\212jSx\223fi\216\220\251\337\346\371\213\204~o\234\303\004\321tf\230\241\3339\321\276\031\324EP\021y\271\251;\277T.\256\3760\275@\324c\031\345\035\360\224[|\350\2029\027o\031\273\310\231\237\215r\234.VY\314\037(),\220\252\336\316\324K9b\254J+\0066%\243\313\377\200\330\214\014V\007-\362\245\221\2022z\020\227\004\036u\333\324\377\346[\246PD\265\332\227s\"T\200\322\271\264\203\307\252\037\205\365G\362F\004\343\206 [\253\216\333\243\355o\300ll\372F\214tr\032F\0340&\r\317\010\005\344\334:\311\213\245\r)V\207\213\rb(^\262\2477IQa\343\257\276\\\240\022*)c\346\037\025o\004M\340xj\340\274\324\267\026Z\227\031\352+\014u\275#\003\274^\224\271]\312RaU\230\nW\327\265\216I\245\245\202 \221\307\236\276\017Hf#\223:\336\361j\t\254o(_K%\340U,\352\302\025e\207J\30662\\/G\257\027t\213\235J)tB \253F\223 \252\307/\314w!\024\345\031\360\320\370\331\202gyI\r?s\200q%\243\376\266T\205e\316T$\253m\310\037+]\273\321\251<\360\343\"_\242\360Wb\233K\327`\257\320\256E\372\277\034\206\245\007\376\026\232t\211\000D\025\274X\0246\240\277\205\301\211\247\357\224\330VKYAo\206[rdDk\311\231\370Z\372{liC,\021\033\221\356x\0012\036\232\246h\326\345\351\305\225\342\352\374\322Mg\266X.\316\224\213\2639\322M\035\n\002\212\211\252\0079{\243EV\251X*\241\305\301\314\362\032\342Z\207\254\264\232P'\262\036,?\246\320\272d\324i\336\nMW\327*(\274G\241\271\311_\200B\303\373\"|\200\212\013/,md>}\343f:\354\254]\n\226\2114\007|\275\3558\337,\223\272\271@""\330}\222J)h\266\340\260\324\033\032N\270\260\215\"\200\372\316\330\275Ryz\265\274\266\222\266\351\234P:!\230\266uZ\376T\3047]\022E\300H.)\035\006\221\256|\324\010\370\222\0109\247V\266\343\322\265\225\312%D\322DA\343\234R\244\004a\r+\360\347\021\025` \016\354O\377n4C\243\274\020M\363Y\017\325\024\247\027\312\267\356\247\255\336\204\277Fl\336\311!%y9\205\2641\0044\316\326\364R\300\246s\317\340\0075\300Qm\":F\021\237\325X\rA\234.\314n\330\260\246^\035\316F\014l\243[\037\327\021\"\373\224\335\366\253\343T\206c\257I\311\354D \314\225\244\357}\233]\357\205\354\225)Aha\274J73\245\207\2172}{\260\372\256\025tF\260\002g\351b\342\022P.i\215\2108r\232\230oh^\206)#\233F\213\242Ryye\0051\004\"\214Ugv\255\210\241\355SvF\030\302\276\26463\003\273^\330\372\016\031}g@\251\001!\177\234Q\3009\024\002\270P\200\001Q\024\177w\265XZ^[\205\312\244:\r2\024\256n\240\026m\2440\271122v\331\231YY\303T|sF\331\002K\276\303W\266\367\026\024\336\034\223z%\344O\362\3350\245P-\035h\\\304\035fSt\2766J\330X\222\r\363X)\025\226G)\337\251\275A\037\211\277\312\313\201\375\226\201\302J)\275\224/CiZ*\255\376\271L\035V\377\\6\343\227\316\247\205W?\257\310\240\036\347\026\260:\237wIG\237\260\022x\372\353cG\336\024n\307\330\260\374wM\252^fo\210\336j\202I~\031x\253\224q/y~\3244\"\335\373\372\223\260i\375Q\361\203(\327\013\305\317)\311\353\325,\342b\350X8\303\026\347\274B\033\004,F\254\017\301\277\022{C\3764\360\334\252{1\212>\370\255\346\265\\a\264\177\035\2679f\200Iv9\314\t\274\241\335\271\212\262/\277\0321CD\016s\321cE\313\365\235lAHI\266\013\313\010\177D\266t\212\264n\212<s\322<\201fZ\004\265\034\013\037\023#x9L\201\272\352\3164\375\036\023\266\242x\360\nc\022\206y\203B\277W\3028Z\350pA\304\014F)\373\326\231\244\300^\210\006\257l\010)\003`\216zN\230>\0262\327w\220\216JQ\356\324\024\245G\252j\254\205\252\013\206\260\203V\264\031\036\257t*\321\246\322w\263\001Q\215-*\t\354\345\314N\271\234\271T\033\260i\226A]O_\234\"{\245\344*\271\266\331\303\324\324o\240A\023\217\202\334\341\352\332~\211\036e\242%\367\2675W""\245\263\021\310X\3546\236w)\2576\006\206MPC/3g\324{\024\006U\335\211\237W\2635c\375\253\316\304\242\323\201^\305Y\232s\343^\311\362\244\225\273\264aB\214\262z\311\206Fb\316\212\271\244\272\277!\243_T\352R\303\037\246\202$\031\253\234]\027\035\216^\2723\277\304\035\340\303\326\337~\351[\306\263-\214\376\2623\223\n\242c\202m\204\310\2060\311\250 \331\245\255\206\360\3604b\2512%Ew\017\332\367:\224\216\274\3757;\377\006z\0324%\203j4\245f\231|C\326o\013%\320\214C\035\2308P!\215\337\361\343>%\216\022c\314\315\215eK\346n\234{t^h'\370Yy\006\247n\330C\001\024\356L6w\226\301\006PU.\255\262\245\315\322\2605Z\324C\352\312\301\237\321\334B\372\252@o\340P\242#\240\325\020uJ\007L\014\310>.\3745\361\340\347\036\375\314~\2501\346\231\333\376B\2358\312\\\373\210^\214fCY\305Y/\217\261t\037\216\302\007y\032\205\314\\I\337\327\230\244'}\032H_\343\210R\327T=\3438\220\2273[7i\255>\035H\303\246q/\346\000$\313\024[\306G6\033\004@\321_\304\022\n\"xL\023|y\244\037\222\313BU}\035\311@\322`\324\255$\343Jq\233\362#\t1\331\2415\307M\254\327\022\027\245\003x\214>\n\242\000#\310\242\370@t\005`\275\216\324\003Y\350\210~\240\315(\331\235\031\334\017f&\n\010\330\360HDh0\027\234\310\032K/0\306\312o\"\226\205\255\034\023\316\202\010\220\367:\351\273\033Y\003Dt|IS\344lP\205\340\321/\364\177\201d\231\262\204\035\307]\007@\357\317-@qU\232\224\321xu7\311\227F\305\tGF\356*\017/\346\370\372\316x:\200?\252\251\t\364Y\274\317\326\261\252\234!\255U%\030\250\315{vhpQ\352\222\305u\274M10oS4\034QM\263D\343\335\027\342\010m\231H\\\\^hn\022\360\026\n\005\n\013\307\270+\0251\207\301Y\034\321|[\003:N\260\346N\321\307r y\365\014]\326\214.Z5\356L\313[z!\366k\371\025v\030\240@\354Q\301\252C\351,\007\0045\264\n\244\\\002\244\317F\232\210\266\313\344\004\2000C\220\261\220\240d\352\014\252\355`\303\230\237\365\035{I\244\006!Vj\346(\313\251\213\n\003\276T\020\327\010\327\270\354\265k\276\334z\033\226^\277\234\275qY\311\247\364u\321\372&\305r^@^-\000\027\352G\345\341\217\3726\230\254\371\305\305\342\354\374t\271\270p\227\274""\223\364\325\236T\237\2223p\320A\317\260\267R\303\227\241lL\nJ\032/\221NI\\!\030)\247\035\331+\252\0061:\033\377\232\311\030\364\245\357\355PlP\24383\016M\300\n\372(\035\242@\354\260m\016\001\314^0-\026\006\300\224\310\250\006\362\346:\226U\342\235\0340\000`\230\364\326\275l\355\375\313\316\034^\\Mw *\233E\306\352\376\226T]\225\365=j\302z@6\316X\271\252\257W\244KG\364E\031d\232uO\232\261\255\0005j\206c\217\303ZM\006\3750\"\366\247\362\347\256\021\357\020\244\2145\211\253b\3321\231;\270\032\341\336\233W\215\272?8\267\036\223\0327\350ku\275\344\010\273\354\362j\022\010\221\372G\275-JH\2345\240D\201\032\367\022\277\247\242\021\250\\\334\316\340M\254\225\320\024\010\013\006[\266CVg\210\207q\347H[\221Q\031\022\005*\036+g\004x\006\326-}?\317\252\201\314\321\226\216y*\2721{c\002P\325\240JM\0039\302\345Y\024\220-\255\003\214R\031\231a\302\232/\265\332\353$T\010\232\371Q\034\020\n\240\261\373\367x\236\356;\375ol\346\023\326\260\302\205c.S|\366\206e\355%.\204\316dS\241\276-[~\274=\311\315\265L\313V\320/\312q6\247\264\023\266\273\226\327\371y\240\t\252\276\323\360\322\313\222\311\271l\271 \370\004\327\005e\327*w\273U\004FJ0\243m\005\231|SZ\256\331\033\320\247r\210\"\363 \222\364Kl\032\231\223\375\032\354\300\360\201O&\342E\326\003\242!\272/}\021\356\225\031lt\370=u\213\003\211\234\221h\027\241\002E\315\201\302\3119e\r;\252\026\306\002\301\222w\374\365R(\025\251\322\201G\242w\226\314\353\232V\374vDzdu\255H \3316\263\023[\322-\223\345)\214\200/\321\313%\212\005\314\266\356\354gpt\355T\314\250^\240P]\220\343\216\211\257\253\305\322\332\"\205\017\310\273\3315=\242\2621q\244-\244\222f\330\245t\277\321\006HM\032\001^^]j\307\nY\371u\236%$\013\322\322tS\212\216\r\347T(\217\002\253m\223\363\347\000Pj\177\311\nr\027W\007\366\0338\320\262\265\232\322\306\316\361\244|\253\234\2720N,\266izD\254\340D\n\237J\372\233\270\241>\225H'\027\212\231\351\027j\005\243B&7\332\322\340j,[\031\335\027%\355\0249^\255e\327h\312\231\315\253\216\221\247f\036\255\014T\236\237\365 \320\226;\332\251`M9f\211cKQ""\356\375\356Fy\261\022\346%)\231\222U\237\242\212`Y\212O\222\3150\254k\341\213\2244\025\233\231rt\315\034\367\212\365c\231\034\003\274\t\327\232A\205\364\376>\375\364\251\021\303\353\330\312\225!\"a\257I7h\351=\3171\020]\264W\027f\360\322\373\214\371HN\\\223f\305\344\324\201]\324W9\350\327\354-Il!\244\277\"\243s\247$lN\254\344[~\374\030\255|\304'\016:Gq\360\234K\350\357\177\311Y\017\267e c\363NyM\373\344{\361SU\266\2444\207\"1r\321xl\037\265\224Q\337(Fm\024\022\025{W\233\006\316\\Gf\327\273R\316g\373\315qn\350R\3230\"d\317z\323\317\316\310\332Wb\261\021\266\315\243^\273\356\223\231h\033\310\001\334\362k\221y\303\255\270\252@T:A>v\222L\306\223\3200\301k\217\351N\230bh\232~\244\010\002q\221\014}\344\227\037\322\212~\016\272\235\006\374\037(\350T\037x\377A\371\375\017\270\256@\337C\320\366\363\243\375\253j\206/\202\007\253*\326\367\242\257!v\237\351\247\335\247B\251@\216\362\273r\357\316\364\367\305!\315\324\344u\243V\031\363NP\333\364+[\342\0271i\023U\205\026\254\330\302\204~]\021e\r\313\301LN\314\226\261$\314\024K\335\2772d\251\001\271^\326<O\224\376Y\266y\242\016f\334\251\217\330\252\032Z@\267\271\0103M\025\275/}5$\013%\200\373%\261\020\3762\331\202\201\207\002\024\207\261\000\273\002 \027\215\335SA\016n\330:\270u\237*\324\002x\305I]\271\340\224Q\017h\010\3377\275\026R$\342D\025\026\344\005\364\022\336(X\241\225)\305\210\257|GPg\223\205\317\225\257\226i($\357\325\200m\262\016\000E\0227)\314\316zw\250\332D]\303V\205E}\377\001$,\310\200\016\367\356\360\225\255bZ\346\202m9C\233\022\277\343\246\261\006'\355\346\r\0241\226W\317\274qdD\254-\201\232x4\222\n\204:\014\211\177\237 6\021\372\262c\254h\034\221\212\361:\250E\026\005\r\325\246\324\232\"\231\231\362\227\315\357\316\360\r\177{=3Wl>\027k\270j^R`\205\221\317L\021F^C/\022\372G\312\ru\374\255\035\253?\354D6l\014\240\274\336\254\344\315\0317*#\234\002\024\331Z\357\274zT\330V\355\032H7\016]\317\271r(\352k\213p\207/\226\225\324\000\333\360K\312a\212!\201\332\024r*\302\026\024^\rKB_i\273\343\016\301\3142\r9\177zo\207\320hY""j\323F\356\216\2174\306G\252\216\274\364B&\214\217\334\032\037Y\034\327\t\256L\020\021\374\330\343\024OG\306\227\244\327\224\321\306\205>\000\370\023\237\222<zA\"?c4\347W\307\n'W\352>\357\371f\214\327\031\356`\023@\300xMa\237\342x\325F\320\014\3103\232-\336PN\032\222\017\tJ\336\n\324)!B\305-O\201\324\210B\305\3113c\322nv\"\021\r\305\nY\330\211\303\0064\205\000\213n$f}J\246\242\"\321\260\244\014\375\331\315N^\212T\020P_\337w\247\006'\316\216\235T\315Z\322C\367\022\t\256V\312\026r\373\321\350D\262\017\264it,!\265.*/*X\331\273u\323\227$\266Y)\362\230R'As\325\300Y5\324\214\005\021\374W\315j\356\2249\237\010{\226\260\246b\214p\235\"\264\201.\216\233\275\340|\017\333\247\276\243\"/R\357\250\035s\026\320\035\010&\341\302\205\353_\377\004\2132\376\335\305\353\277\360\377\350\304\376\366\377'\377\003\2642\341U\253.\306\202\000\\\374\003\212\257\230b7\234\277'\376\034\205\315\314\245@\010\006\"\360<\305\333\253\205\371\356j)\323\037\323\244H\333S\350\354\322\003 \032\257H>A\372tJ\336D\271F#\243\023T\035L\225i\242\265T\316 \322\267LKra\"#\010)T\327\205\314\213\305sS\202\210 \245 \237\"\352V9\315\305\032\302\235\261Z\345\323\237\371?\014\302\0216\335\252\217\362+\327\026p\274|\245q\334\232\232\230\300\237\010~\203H\210\037\021\232m\335\301\314\362\342\312B\021\375\220\204c\300\334\332\302\302]G@\276\235\227\357\375\245\343%\367;\271\263@M\2439\201\372\311/W\277J~\330\344q\261\322q\224\321\024\342\355\370'|\330\271G\221]\357;\323\255\2260|\340\333\220\231\237]o\303\341\212\367\360 \205~i$\272\004\213\204n\025U\324\224\252\220etY\330D?\341\267\272p\313\n\314\243D\342\344s\317\202qf\2269J\t\211Q\230\033R\013f\004{F\302\\\177\300\2531Px\252,\004\2630\365\265\262\017\246A\346\032~L9\367Pbz_\366U\242\177W:;\020r\344\3738yP\223W\"\301m\020\256Td\247\355\2012\256\274V\2421\364?\201\201e\235M`u\000w\010<\255\032\034eA@d\273l\260U<\312%\321\250G\206\360\206%\331\"\272\"\266bo\220I\000P\275\304\367P\035\215\200\017\000\244\202/\221\025\020\227\263\354\326&\014\303\201\237\214g\203\210""\322\342#q\365\212\270\325\331\342\340\013\014\302&U\246\271\032\353\376K\243f[\301\256\352\307\361`\240\000\037\335\260\245]\245qmdA\200\255t\267g\177\322+i\272\017Hi\2336\034\007\312\346\317\035\206\030#3s=\2121\222\367\253\212\242\234QD\033\364\014EL]\222\32149V\274\0051\216\026\307\013\300\375\255\261\277\276t$\273\273\307$:\260\263\253Hi\343)<\261\201d\332&G\177\247b;\315\212\016\013e\270\373\353F\207\311\251\332\203\234\367~\352\\\275r\345\3068\375\314\376\324\231+\316\315\335\037\305\333:HJ6v/\265\341\357\333z@\212\010\021)\273\035\343\006$\000mS\361\317\300\242\340\017m{\214\0178?\222_\262]k-\373Q\031\355\322p\2701\220\311H\304\377d\256l,\252\321\r\364\215cS0\225\235^\257\017*F\033J\036\216\252\225\210bP\223)\202\240\026U\230\027\344\300\020\r`\374\335-#6e\2370\225\360\322\2026\275\232?\241\343~D\023j\371\214` \255\235L\250\000\225\260R\\\235).\225\247o\026\201R \261\030\374\n?^\014\324\335\2129\\\367,\205\312\310\206\037\312\206)\311\246\024\\\027\215\335]7\367S\256Bx\370\234\205o\350\024\211\276-\210\271\341/\220\001N\265_\246\032\027\366\276\333\t^\2462\276\326\301\245\023\303\2458\n/S\013\t7\031)\374\314\232\220\030\322^\345/S\003\t\327\253\270\313\2448\360ej1&\267\023\270/T'\363\221\032O\021\323\222\227\237\302\365\272q\250\317\237u\364<\364\332\2713G\301\002]$Cr\320H^\001S\002\302\253\202[\225H\372\274\354RK\357\273\206\361jnFZl$WY\364\301Z\251\027\311j\202\037\206\272E\215\026N*\306\317jV\007W$0wt\r!E8w\277@\t\224\301\346f'\352\300\025B\025\227\014;\\:\267\363r\253\263\336%\016\326e\277\271\274\234\024I%x\354\353\271\247\345\313\313Z\363\215\350\210\244\274r\021G+\350\350W\306\027\306F.\312C\3632\211\271\307\241\273B\272.\375\360\216\314~ML_~F\240-\232;\306\211\334\034\330Y\314\217\3328]\000\361\326\240\022\204Q\244\341on\206\210\266\250D\211x\234!P\324\375>\231E0\254H\030A\347\345\262\210\025\027\303\346ip\255\371\250\031n\017W\354E+\327!6\310N-\372\271\345\031\366rk\t\275*a\022I\3610\240U\327\3633\327\024\324\220\303\350\000h\307\330V\274h\212\267q=""-\257\315+\"\343\354\371\356\346f\243\021\345\216\032\030 \340\036\211\314q\221\256q9\004@nV\340\221\214]\024\346.1@\265\241\020rQW\343\nMPnv }HbB\270\332\032\335\221\331\205Db \224\013\\\353\222\321\221+\2271?'\3403\363h\022\274`\250\220@\337R\024A\211\027\302\025\006\220/\\N\004\026\030\252\234)\306u\205\030\227/0\354[\304\250\326\r6\\u!pn\001\276:\201l\302\324\206\210\206\332\251\371E\007\344\344#\264\351o\251}\220\315\334\207\240\030\220sh2\001\235\t]4\020r\205\201\220\353\351\000\273l\037\224_lG\237>\2550\222y]4A\032\010\217r\265q\345aM\242ky\231(\016\336\216K\034\244\032\003\353\013]\026\024\344\224J\337e\231\223E\222@\375\216I\203\324\344\353\327\304\025r}\2636(8\205K\261\336s2U\327i\214\344a\224\367\231\315\032r\277 \273\351\206\365*\037;\266\374.\017\236lw\353a`\325.\221\227\201\302d\245\021Z?L\006\307\355\226\327\206n\346\365\016H\211\031FV%\000\220\374\014\322\345\244\177\216\\\n&\367`\301\314\2543G\272\201B\363\016\032)f\257z;\206\206\261O\2460\242XT\260\253[}\206\211#p\331\327}`\213\030\315\3258\310\326w\344\376\327K\367M\335k\254W\275o\207+^\315\345\211\372\267\223\223Y\020g\006\374\313p\005Ce\246\273\376\372\347\0048\032\310|!\005\307\316\026F\177\221\252F\273\346\0014\245\262q\030\202\376\014\232\344\275\233\367\005U\264$\363\035\370q\230\215%n\223\036\264\374\220\245\0364\363\030=\213\010\313\373\216\024\023\023\232\2608a\247]\311%\346\032A\265\031\3246\3636\222P\232\230@\321\251?\030f`\371%_\242\t\267\0323!\231SVx\303\246\367P\224\2335v\355\310\265}2\231\021\343\361R\323\274l\3428~\020\264$\374@\247\033-8t\253\271gI.\236\033V\234#D\250:R\361\321ymqkn>)!\315\373\330O\272\231\2237%\277\354\237#\243&\310\204\327N\007\265\316\rr-\023\027\371\302J\365\312|W\352\025\232+\232\010d\305o#\312\200\202\034\217/\023\360\272O\304q\225\314\032\224\334`\336\306\3059\360(\370\300\351N\274\t\335`\235\373\215\265\205\357\335\265\225\331\351rq\006/lC\2012uof\023\316&\177\366\206\273\274R\\\245\013\373\\q\007\356l\361\207\371\231\242\2730_*\027\227\212\253\356lqz\026""\322\226\326\026\026f\27560\037\263p\340\213\251\230%@\232\237\345\337\005\021\262\256\210\222\003n\005\370\025\214\313\3176`\224$.U\241\220f\213\364\031\036\304 \321ml\256\035\334\364\343\271\260\355\263@\204\355Hn\315\317\312\013w\347\227\341\205+\374\343J\361&\205\326\303\2261\0304\016\231\247y!\254\335A\274\334v\027\247\177t\247W\346\335\225\351\265R\321\235\271;\263P,a\332\322r\031FY\\\272Y\276\265\350U\260+\\\022\326q1\362\2535\177i\356\373Y\314T\202?n\251X^\362\000(\225\343!\016K\334\272B\343\022w\023\370\3212\306\230\301\220\327\r\240=E\367\311oK\000\210\214\206\275\334\256\315\230w\242F\220\300=\200\207\371\331\225\345Rye\255t\313]X^^qY\375\270\342\305\233\"j\260\353\256\354l\303\177\263\001\240\215%\177;^\3657Va\n\036\254\272\313\337\013\tqQ\372z\346E~\264\243D\226\256\321\362\273*Fc\351\032\205n\234%w\227Ry\272\274V2{R\3626\200\234-y\261\241\352\313\321\006\3524\321\214~\30793@\236\341I'D%\"J\215\252\010\277\030\357\235f\t{H\200\300\301\324\312\233\035\341\035)~,'9\321D\271\343\223\267\000o\n7#{_k>h\002\231\200f\326\334g|\232\237\305\277\002J\265\2110\325\357\336\001\360\200\377\256\336\201\325&\273;2\273\003XP\241\262\031\010\004(\020X.\313@Dxs\225\353\261\225\016G\341e\016W\363\271\006\307\313\032\234\254t\366(y\255\371\275]\027o,F\210$\316\265\242b\030z\212\016\231\034\361\033QF\206\300\213qd&\001N\260\024!\234\246\213a\326P\316Ja\001Ly\205+\314\270\230\320\325\267\245\360\322\251\367\226\302\2519I\250\307\354\223,\205\r\371\237cc\026\314/\017\374\334\344\376\235\"\206\n\000%\367\2235\260\364\207L\007\311[\316\215\000\223\250\244t\345\222\250D\221\245W\255\242\201\213\265\370\256\353\371D-\270\370\264\215\232\036\226\275\323y\334_\014O_|6\022\204\252H\344&i\035|!KU|\340k\300D\304%dg0t)2\204\320\020\337f\342\343\023\320\006\355\266\267\243\344w\r\257\352\343\013Z00\247\004\260I\224\245\020NH\240\225\t\225\235J\335\217\360]R\375\000\320\323\315\352Z\273\036is\036\004r\022|s*\261\247\364\033D\255:\260P\330\034\276\007\025\316+\343\254\232\222T5\027r9\214o""4\035\360.\353\301\270\334)\305(\331yV\r\233\"\033\306;d\333\240\276\241(\222\355\342\322_\204\361\027\353>\252~\364\000\027\014\240q\2606D|m\3130\327,\362 \271\\+\204\272w\322r\010/\252\300\277 \240{Y$8\211KZ\344]-\225\020\016c`\035a\376\201\244\365\221\007\300V\351rBW\273\024\213{\034E\334\010\361\243F/\337\r\250w\351n\004\327]_\377\3423v\"2t!\204\311\"\276\341\031\377\342\224s\213\n\020Q\351\214\377\271*\250\004^\177a\211QX\023D\250K\3327\213_\271\312\3228\305NN\277\n5\022\t\244\370\2236U\307u\255\371\242^\355\3572H\013\2256\0316L\3160$Q\332\002\3155\022R\331\211i\325e\004\017!\370A\361\023\ta\003q\014\222}\000\020\243\260\204\3068\250?\025\227\255d\\a%\243\366\233\326\222\221\274\007\rL]\021+\304\225\213\233\253I\253\020\355\t\177\253xr\372h\373V\013ID\347\327\341+\034kM8\026\372(\314\216\320\177\rRv\361'is\244\3262_ck\244\252\270\314\375\004n\234.\372'\343'dEn\234\002\371[\262\010aM~$U\r\257ke\263\323|\240\270\024z\003\n\217n0B-\027^^\200\257\276\207\010\031\267\201\371\014\300\267\005;\212\357\301q\205\265\233|E\t\035\3122\243J\0355v\200\235c\351\260Lfi\3326\r7_\005I+\032xT\t\033\353P\202\335\014\030?U\010\006:\204\226iJ\010\220\320\224\001\240H\032\245V\302\326\016\376w\025\377\360\266\243'<\303\004\340UZ\035\211\003\006\250\036\305\027\002g\351q\351\346\234\234\221\376\252\366\252)\017\244i\226\232\010\371k\022U\331$<\033\362\322\021\327\253dq\266\230\357\2642\306\273\231_\342\236\364;\241g\325=1A\366\253\213\267\013\244\323\364X\305\007\332X\362Yz\243\24650\362\035\375\352\345\263\306W2E\256\206\306N\372\013\235\016\251\327t\277S\311D\357\241\334(\375=[\277@^\352\325\374$m\362\001\002\303\215\r\027\310\234\253U\0176\033\240\372\240\276C\177\324V\3447\332\237UbZq\251HR-\3106i\373\203S\245\236Y\020N6CB\017\245\324\212\004\310i%c\276\322\321\315\\\027P\365vPz\253\226\014_\220\356\300_A\361\332\322]\2147P]W\005\214GL\306\251\304\237\020\261\215\030\216!\310\207g\026Ir\220 \361\326\226\204c\325_\357\324\370\254\025\362}\361\343\263,_\230\350\311\037\340/\001;""\272>\241H\341\2670X\370/>\353\024 ]*\3223\217\367M\256\005\001K\245\346\253\374\213\214\221\220S\005\"I\321j\251W\256%\235\210\370_\244\241H\234\006\022\264q\213\002)X\361\332U\223\"t\201f\256\270D8W\343\311j|UI\000\3417\\\377s\225\244\352\325\255\207\370\337U\337\277\352ol\360\245|\310W\350\027v\245\262_iE}$0|\305\201Xf\013\254\350\260y$[\371\341\246^%\362`d\357r\370R&.Y\333\334\224+\n\344\2424\213\224\277\252\017\362}G\260F\322%\310o\022\344\210\037I\336\211W\250\273\035\020\321g\2508\005\020\013\205\014i`\360\024f\242c\200\232\306u\005k\3427;\r\272n\221\366\031_\252\201\260\305O\"*\273\276k\203\236\"\250z\033/:\334\256\300\314l\204*\264\225z\210\370\342\014ht\033\317-2v\247'_\222\004\2124\240\203'C(\340yY]W\311\0302\013\200\217\342m\272.\363Rp\364!\017\2507=\2612x\344\"\\\361e\004\214\010\245\2236B\214~\306\221l\310\034\030\313DJ\362\221\033\340\004R3\"\265\317ZI\372KOu!\362\242\027jN\336\024D\017x\344\346i\276\371FY\244\317\"\227Mg\025F\026\2374\321\253\256\036\301\251\220AzS\314\005\027R\303\224o\252\022\306\212\222\265\357c\024\004\311U\374\317\025W\033h|\037Q\262a\023\236G\005\220\2551\375\241\225\340'\242#\214Gy \231Ih\253\240\215+6\352^\355\352\006\3643\246\3409by\0321\007t\320\227\305\350'\356<\275\212if\222R\360\254\036f\005D\202\023)\236`\376h\255\224>\022!\006\376{\3547am;\300\203\321_$\237\001R\360\2070\202\021\204\334\240\254\351\021\261\214\320\212\000\265h\3532S\212K\245\245T\002 Ko\251\326,\253\315\354\257\337<\322x\213\276\013\272J<G\304\240\223\032T\203\273\213\306\331\256\334\033\203t\244\324d>=\232\325\225f\354\304\334aR\352\336\343\035J}$\t&|cPA\250\247\316\033\212@\003>I\207G\237\251\014\253\314\322S\314_\320Z=\017\236kRu\204\334=\277p\007\204\2067\255\354\025\357\217X\010\202o\342\002:\227n>\243\361q\314\006[\030a\221b\230IK\234\360M\204SP\255G\327xE\350Y\037\371\364\032{\342\201\265\177R4a$\221U\035S\002!B*\320,\270R[\276\377\000~9\001\250\365T\037\204W\236\3200a\212Q`\213$\256\"6H\323\220\271Jr\0072U\266\252\360\027\367\246\367\250&U\340""\222z\351\243\022\317W`\367\327V\323\027\023\351\325:A\265\277\276\272\217r:O\023-\323\014\343=;\211f5\327nq\220\361#\331/\346Ki\255O\206\260\306\372n\232>\016\262\205\264|\274\3729|\r\245Z\227\026\224YK\312\301\266\225\233>P&\355\010\231(\342\244RVl\234\244E\327v\002\277E\212\363\332\344\350/\233a\303G\252k\263\275\271\005\333,\270\032\007U\254V\352\r5:\242\247\034;\262L\2728\2359\035\216!\026\025\350W\026\263\332}OY\033\0028bVJ%\033<\304\251\006\2141\3427\022\326\221\207 $\241\323*!l\r\200Ee\231\227\225~\310O\346\227v\000[\253\355f\223\020\343\304\2661\253|3\211\010v\252\331D\252\020\332\357\037\365G\177i\032\317\351\217\330It\300\245#:\250n\323\035\206~\000\213\324@H\206y\t\0325\227\017d|B\361i\260\215O\017;\260z\361\016A0#r\021\216\032\362\320LG}\3559\220\010\225\316\024\342\376\000)\026\223\257\344\367$\214<\002\024\230\010p\221\340\207\030\311|\3613>\363V\002\016U'\020]\252^\t\266\032^\313\000m\343\221\370$\023\352\315g)\304\327i\332\214U\245\001g\241\236\005]\242\336\t\370\314\266\005\361\227~\327%\304\335%\346\233=\272\314\013\020\036\372=\024\030O\245<\022Ak\364VQ\273d\203x\213\035\235\000\245\321v\327J\260\253\213\304\273 q\003\324N\323\037!\333\013`oU\253H\032\243m\215\2129\325\337B[\006\\\220\277j\023kK\036xRF\240.\275\010\021|\200\024\274\"`\2051O\332\246\007\337[\025\227t2\302\230\007~\304q\216\266\340\327\364\212Fh\n\215\177\351:\027\027\257\257\247D\342\315\215\n\355\004\232G\016\177.D\260Y\023sHQ6\030B0i\202Rd\204?\010\204\334\000\036B\261/#\332qX\212h\230\340\021\272f\333\036x\000\204\362BJ\371+\260\234\375\n;Z%(\tA*\243J\227\260\243\276\3503P%\031y\"i\007g\020zR_\213\323\202\375\264M\327\263\206\354\"\305V3q>\206\017&\211\230)1\222\r\005\201j\006e\374\3722jW?J\213!/\2464@ \342\027\300H?\261L\200]C\263\370]\367K\343\360\016\321[\252}\2241o\3022\303\036\263\034L3\336\246v\002]<f'\005\351wFKvb\270\376g;AlU;q\313\213\350\024\247T-(\321\275&a\017?\0212\243G\206x\225'b\256\205\307/\225#r\035)\221(-=G6\213[\307\211'\202_O\t\275\262\\\201N:>\356\330\022""\200\237q\242\350\201\220\242|\244\030\023\264T\234\202\214\200\251.Ai\177\035Mc\350\017/\026\360\212\374\306\303\002(\2136;1\236\3658\253\375\035#\010S\263\035\233\0220\330fmR\020\201\023k*h\201\250i\000j\335\301\364\224\202\242\257kE\236\001!\246\341L\261\020\206\214Y\\A\326\031k\231>\216H)\327Fgz\374Ot\273YC^\206T&\r\257\202\275\200\2370R3\304o\231\031r]\272\324\336\265\256\266\247\027\355\226|\224\007\010\177\227\327\263\245(V\253\004\326\321\360\266\3356\335\252\033\341\243y\365\272L\227\272&\3063b\217\2134$F\304#CHc]\274\252\007\201\326\204tM\374\360!\0055\307\036\353\237`6+\355\220\t,i\265\t\023\214\361f\032\236f\032\350\275\323P\225\322\022\244\315\374\211\317\020\211d\362O\002\177\261\\R\360\243f\242\361\000\363\240X\206\374^\330B\003\037\353(\256k\301S\007\305a\372\267\217kh\216\353\251B\263\330<\322d\364G\3440\236\251A|K\035\032\251Dy\032p\262>.\370]~\205.\302\212#\222\305\265\023rg\361\327\3372\004\r\206\267\005=\306\250\233EU-\251k\001\2576C7\334\300\207\250\t\323\321\014\233)\250\323~E\372\311f\373\331\253#\345~d$\310\235\235M1L\r\324\307\252~\242\001!\375G4 \002\023{\003a\357\321<\216\376\310I\320/;\374H<\017?2\277\223\307\322\333i$\025@\223\255p\313\215\243f\247^o\002\030nT#\374\341X\275\0212\373b{\340#\354_\3741\004\030\266\347\255\272&\216\320j\210\302\327*\036\236;\351H\032\370\316`\311\0212\360/J$\024R\200\364\240F\342O \255jd\230\311\257(\334\010\243\220E\201B\220\243\3457B\230\304\323a\275\030V\0102\235'\312~\313fCr\314\224Q\211K\375r\222\362\313j\340\312M4\n\265<\224=F\375\034\327(\271J\336<h(\320\326\202^D\320\204\244\203u\301\037(\2311\036D\362\305\266T\212d\262Vc\312\024\241LT\257!\354L\370w\265E\222\334\006\212\371\000\2267\321n\344\221\357\032g\024\273\360(}<nh\014tm\322Cz\340\022\361i\211I\000\377\256\262\260M\210\334\010\034\200(k\262\025\243\274]R\376\022\020@\275\242j!}\361\371\225\226]I\217`m\263\334u+\214\002\266%\002\244\020\002U\321F\227'\030[\005-}\350,3\354\203p\003\343\032\321\303#\222\225\262\360\213^\345\300\3441%L\345\225""\305\274\266\314\3167\242W\327\224\010\362S\277K\342J\027\020K6_5\326N\033\317\000\332KyzY:\210\026\376\273\332\212:\3507\230\361|\314$D\224B\236d\222\3520\077\077t\211\363glLS.\266[\275\316\017B\266\242E\223\374\304\272Uo\013q\n\376\320J\267}\304:\244\240e\232F\n>\230\320\0237\257 \031$/a\021\367\310\013?\314\264\361V\260!\230\373\266\210\371)\350\023i\342\247\222\211\3744Ri\177e\354\234\322\037\262\t\306nn\373\264y\224,\232C\030\003:\344\007\354c\312PJ\1770\223R\201\026\000\004\353^\305\317s\201\027i\202\372\025\n}\221\310\370\\\220\200Pm\3043\345\213\037\323cA\331@\350\311d\3737E\234\312\007\225\200\247\2250\272Sg{\304\233N\242\325z]<\tx\240\033\357yH\021\337S\217\006Q4\3758\026D}D\335\000O\337\216\2426\036\345-\340\302\341\037)5H\033\031\266\361\225\035`e$\027\245=\225\242\\\\ZT\241\222%NJ\227*=L\007\270\366\302\247*R\315\210_\351\231P\275|`B\211\310THc\251d\033?#{{\315U\3443<\0333,Sv\232\025%N I\003\276A\361\310U\034\214|\344\300\231h\213h\355MO\320k\202,\243\250J\270\200\364\313\302\216L~\343`\031\350t<\310\203\231>I\365j\004\020\016g\023\375%\353F\230\023 \255|\221\316\003GcSz\240\021j\002B\317\212\021\357\305H\214\315\334\004h6\250\032oLP\030\t\254|4\022\202jd\276\031VO\"IX\205\030)\210\330\214W\302i\306\273\240\254\362\242\371\230\021\246\014\202\t\346\222\0056l\005\300\300\200\207\354\003\277)\r\014X~\234\357\341\035\3715\002\014_\020\243\226\315\021\333G` *\374/\370\301\340}(\001g\200\215\026\216r\t\037\312\217{('\361\243<\2733^\334\003\335\272\245\027\231\255l\220\251\231\204\264\263\031\276\261\265\217\to\234 \327R\362\326RHM\226~x&\311\024C\243l&)!\374\340\217bY-\005\242x\211\320\247\r1Qd\351O\263\356p.\312\032\004\013\204O\026\025\256\016\262<\0179H\023\026J\0216@\274\220\353\325\302\214\177{\276\303\273H\225\310\321\360\255S6\274\"p\343`\277\273\276^\362\"]\340\324M$R\350\314\346\203[\251&\370U\3163\275\310yU\242'6\202@\215s=ddJ\006\3354\337!\006n\346\277\006p\260\320\204\376\022cA\342\025\372\203b\241(zX'\033\330\306N\004\377c\263\374(R\n\205L\360/8""ic\"y\270M\266f6d\225,\225$cm%\0131\244\"r@:e'?\\\200;097d\200\370\244\014\230\373\372-*\367\212\\oE\255o\340!\242\035\002\351\263c\014\340\332\360\201q\253\322\273\234\020*\215&t\352Qm\302\030i\243\224t\020&[/\017.;\212\004\253\261\370\261\264\225\221\026\351\322\223\242C\350\315\034\251\220*\266\351\351\021^H\000\324\005\374\333\340q\000\222\202?-z\001\244\325Y\227f\235\021<\013\370\316\305f\220\310&M\271\214\236\300\214\022A\322\226\210:\033p\032G\235\206 \323\251M\244\n\3729u\322\007\266\215\212\000\364H\332'd~\206q\260H\t\"I\251\001\232\027it\234\361c\247\031\000\260\002N\210\275uh9\2063\211\214\3420KL7\010\362_>y\304\243\244\r\323\357prV2ib-\323\351[\"\301\020W\343\036\310\272_\t\234%~\220\257\241GD\211\350.A\007\217z\240\203\024\337\330\326\213\344\303$=a\322\227'\234\237\003\224(\000a\211\323m\206\333c\355X\260\261\241\036\324\031l`WD\014l\245\3120\305z\324\0009D\255[0\022Y\217\000C2\322\010I\031\357H\244\322\253\254\234%\223\274\322\372\235\314|\332\374B\346\256~\0357\032\251m\245\366\026\272\200>\010\n\001\252\007\267\272N\003F'>u\216\250\007\276^O\n\231U2\rY\275\t\362H\227\222\206\272\375\0234\377\314 \026\n\237)\262`\201?HY\306a\035\376\001cGS\3033\316\006-\346\375\267i\023\027~\267>\362\264J;}\333\376E\352\323\264^\215WS\276\"{\322`\361z\r&@&c\344C\257\035\204\303\004T\241,\320\023\276\236I\346K\275\"\331\\\0352\316\n@\003\366\3701\035\376\361cd\017;|s\020\022\302\360\270\355\332\266q\224\244V\274\323D\246\"M\002\tZ/#@Oy\207K\237\020M\272\312\024\223\340\354\3470.\325\276\246v\\\334\302\"(E\232~#hL*~\214\260\027\311\206\225!)\023\360\020h\242\301,%\362!3\3023\306|.#\300\031\301J]\363\031\217\016\334u\342\n\033\372\021\004 =K\000\206\276\323\021\301\347\204\245L \346UD\264\021\016\\\342\215A\353\350`7\344\303E\366\214\206}\027\033\035\341\241\251\224b\352\201\226u\313k\243\224\200-\270\204\035\227d\367M\263.\313\304\013\001\306J\240\333\314\2676aon\005\315kWk\235@\3305\212\037\245\330\221\357J\265#8}Ho\3735DI\332\310\204\365v&e\2534y[ta\2000T\243\306""\331\212-'\035\373\331'\031}\350H$\301eM3'~A:\235\237\020\367\353p\242\005!\000\260S$\355Q\310\t0zTN\223m\304\240\002G\345\027\276o\303d\245\251\037*\247\201x\207\251W+\372\206\310M\202\277A9s\231\367~y\323LW\277|i\272\320\310G[7\360\215.\362f\316\313bh\276\362>k\005D\336Wi\2559(KZ\356\220\227\311@8\346gef_\250\300\271\0246\\\235bd\203\203\250\300RR#Q\n(\314$T\354E\005t\304\261R%\301[P\224\260\264\\>\"[\376g\223\344\311\317\221\255\035\205\217\021}6\027\rS\217\314d\230O\246\362K6\2750\300\203|`\366AyH\007\317z\362\001\3312\276Ay\231X\302\326\377\273y\344\344}?\322B\327(Dlr\372\235FC\301\001H|\233\371l\032\220\253\303'\223\t\215\232HZ\230\371\224r\245\312\373n\370Se?k\307\354\3147\313\242<\373\225\245\034\310Ef\276\241\361\026\343\232\314'\024\200f\022\243k\331$\342\217\372$\333\266\330\231L6\315\231\371\314\010A\010i\210J\001\240\337F\004\216f\007\311\361+\311\225\271\247\336\277>x\345\265\363\335k]\257\033\367\246\366V\367\036>?qf\367\354\356\355\347'\336\355^\352\275\221\\\374b\177\375\340\330\363\023o\357\306\335/{\223\275\233\311\357\277>\370\303\323\217\237\376\224\334^}~\342\267O\036RM\225\244\322H\032\315\303\023o\355\326{\037\365\346\222O\277>\230|~\3427O\374\335\311\347\247^\247\177gwov\371\345\215\335\311\335\345\3367\320\030>&g?\3515\367\247e\362\327{\236J~\260\177&9>\272w\"\271r\353\3311\254\274\332\275\360\374\304\251'K\335\313\275\365=\350\326\251\344\324H\357\307\275\273\373\325\203\013\364\366\305\276\307\031F{c{\237\355\265\367\317\035\2349\270\374\324\243\217\237\356q\246\337\357M\362\370\316\364>IF\247\237\236y~\342\327\311\257\337\353\376\241w\341\371\251\367\272\337\356\235\335\273\235\352\374\351\335c\342\367T\367F\327;\204\221\307\320\307\223W\366\217\355\277{0y0\235\234\234\334?\323\233L\216\303\317\277N\275\362\332\233\273\267\272\263\275c=\254\373\311\324n\251\013\345\317uO\364\216\367\246{P\371\357vG\273\027a\326\037\342\347/w\257\355\302\240\337\332\335\354V{\027z\223\207'\316u\217'\347\013{\036\256\007\214:y\367\362\336\364\336\355C\310""\373m\367\215n\261\367Foa\377W\373\320;\254\347\302\363\323g\370\337!L\3347\335\207\330\273\177t\275\344\364\307\275\311\347gq\351>K>\374\022\226\361\334\007]\037\222\316\277\177x\356\235\303\263\347\222s\227\367\276\337\217`\3520S\362\336\370^i\0372\235O\316_\335\277\200\2317z\323\220\371_\377\376\312;\037v7{\036<?9vx\352tr\372\243\336\350\336\005\230\305S8\r\237\303\330\240\371\263\347\272\377\001\343y\373\003\230\236\263\357v?\241\301\237~{\367oP\t\277'\027JI\351\207\344\0077q\377\217\341*z\336\257\242\273\311\335\237\222\237\374\304\337H\316\216\002$\234{\257{\265[\352\375[\257\264\367\352\336\307\260|\347?\356]\205\027\370\362\016>_\003xyu\357\243\275\033{\315\203\331\247\277z:\371\374C\007\323a\301`\254\207'^\323Sy\010\377`\002\377\326\235\306\264O\272\307\222w\256\037\334N\216_\333\237:\270\215K\373n\367m\350\322[\311\245\342\323\333\010\224\233\335\032.\351\257\237|\263\033A\r\247\336H\336\230\334?\177PJ\376\263\234\224\327\354\017W\366O\035\314$\337\301<\224a\367$\277\275\274\267p\360\253\344\353\345g\017\223\223\237\355/<=\206\360~\014\027\372\263'\177\207\001\035\357\375\021\240\340\037\007\036\366e\242w&\371h\351Y\220\334\331L6\037$\017\352I\375q\362\370\257\311_\377F\003\270\320{\177\317\337\237\304\255\0045\177\324\273\010+v\372\255\335\260w;\371\344~r\177#\331\330\372\327+\257l\037+\276\n?\305Wo\342\317\315Wo\275zx\352\235\356\373=/\2714u\360\321\3014/\305\244*\311\323\374\010\362n\035\233\305\"\263\257\316\341\317\034T\200%\337\355}\326\203\215\374~\367\007@ \267\367\036\034\274\375\364\030m`\234\304\277wo\253I\234\0028\223\203\370\343\263\013\317>OV`\025\377\234\374y+\331\332Iv\036\323|\214\364t\201\231\247\223\252\300\374\2633\317F\236\355$?\006I\360(y\264\235l\357<O-\322w\007\017UvX\231\247\376\263\257\2222t\275\235\264\343$\356$\307\277\330\177\360\364\235g\027\304\356\232\330\243\275'\247yq\377\375\003F<Tor~\034\006\023\354\003z\033O\306\257\037\334\307r\277~\362\207\335\013\273_\210\236QVBj\335\271\344#\302wj\247\323\267\323\273'\272\257\365""\316\022H~\272\277\004Hs\365),\363\037\366\377\372\364\233d\031\272\025\341\013\245t\016\276\347O;\000\001'a\253&\307?\356}\2717\371\257\267^y\355\365\344\324\207\210'\000q\335x\312\010\354\233\203\351C\302r\374\nC\371\327\t\312x\261\207\037\222SN\357\267{\\\344\243\344\243k\004\023v\362\371\356\367\275\207\260\261\261\020=S\352\205\344\002\240/\211a\275T\031\376*\n\275\337\275-\236p2\3603\"\030\374\005\224H\277\243\204\240\237,\002\302\232\356\226{\357\356]E\254z\212:I\277P\031\301\355G\275O\366\216%c\177L\376\010P\n'I\225\340\027\367\254\277w-)\334\200\211\273\375\374\364'\010\315\324\325C(\301\003\277\272\377\361\376\355}\356\347\325\344\352\334\323\365g\334\366\245\336\243\275\333Ia\366)\267t\241\367V\357a2*{\3701\242\330S4\006\354\341B\227\223a\227\313\351\244_\300\271\364+k\271\365\314\316G\007\007\374\0020\313\361\030\003ON\001\020\322\357\315\247\017E\247\370\367\223\236}\034\311\t\203w\352\326\275\344\336Obn\021\017c\022\200\211\365\013]\021+Ng\031\037|\242\314\247{\243\373c\007_=\235\3063\032v\257\227x\353\242_'\366_;x\347\351\205\247\337<\373K\362'\304\302\342\004\275\335\253\355\335\331\277\t\007\373\245go'+re\001\314(\003\354\334C1\220C\331:\344x7y\207Z\377\365\223\357\272\037\343F\007|\356\364\216\341!\371\233.!\254\221\335\207]\306\3639\351\242\021\271\226\362\027r\036\362\232\021 \336\332\225\240{L\236\335\207\274\364\234\035\366\235\250H.\007L'\316\315o\222\327i\001\317w\347\340L\375f\357\357\007%@L\010op\206'\347\001\026\016 ?t\355B\357\374\236F:@\023\t,\362\3744@6,\375i\300q\311\307_\354\007\007\021L\335d\372l\000\324\255\n,<\233~v;]\200\272\007\033\n\317\261\017d7N=Y\356\362\302\341)\247\366\362\223?\356z\022DM:\346!m\024\350\354Ho\265\267\005\024\022\036\355\207\200\251\243\335O\2733\200\035N\237M\316\216\355\275\001TBy\377\315\375\312\301\357\016&\017\3554\271\233O\354\375\333\336\017\373_\022\021Wz\366\333\344\316\237\222?\001\304\th\020\363\375d~\367\366\241\234L\236\336\221d\344+\2301@m\237\355\302\210\337\334-w\341\r\211\213I\365\003\210""\025g\346\275\356g\320%\231\370!\220\226\360\343 \351\243\312\211\234L\321qN\002\350'\337\357>\352\376\330\343\215#\321\336\210z\377; e\t\347r\273\001\231thn3\231\376q\357\253\275\271}\206\\\271\365\240\246\177\235|\345\265\223\317O\001\221\363\031\235\224O`\362\336\330\375\022\210\277\217\211^\000\nc\004\332=\367\016\364\347\315\217\222\0138h\240!\220*\002x:\344\317\211\263\360\354VR\026;\365\314\007\311\373X\331\3317\237#Q\205\0078\234\236~w29?\367t\363Y-Y\373!\235\253\253\263\334I\356\300\344\303\351\\;<\375~~\026\240\231\376+\371/\244v\214C\017\250\225\344=\300=x^\234\300c\003z\232\234\245\356\342\002D\275\221^\264wq\257\002\323\201\204\016\021B\243{\277\0024\\\336\377\335\376g\373\177\177JT\322\024\021}\212\032\372\352\340\375d\016\260\306\375\303\023\257'\257\303\321qx\342\215\335?t/t\277H.\020\376|3y\023\366\336\376\244\006S\244o\266pc\277\235\274\r\213\361\\\236\223\335\017\367\376}\257\266\177[\3548\252\353\327O\276\332\235\331\355\000\314F\260+\261\355_1\305\362\372\241Mp\303\373\333Xkw\253\347\365\036%\343\323O\337Nn\375\230\374x\227\017\355\207\230\t\367\304o\237\374\205\220\317\351\363td?\347)\353N\037\236\346\005S\t\351\231#\222\353\253\2037\017\036<;\223\234\274~\340>\003\032~:\231\206\265\370\007\2207\377\371\352\364\253\377\344\303\024\026\005\311\3743O.\000H\274\36564{\010X\005*|\007 \031\377\374s\372_g_y\355\024w\213(\237\367\272_\000s\361{\230i\310A\304\300\273\330& \257=:\271\213\273o\356z@\024B\317q\342\270\253\300~\265!\377\251\017\223\017\341\010\332?\206\373;N\336@B$\204#\3474\221\305\200\006\201hF&\341\364\20747\017qR'\005{\005\343f\236\014\252\303\375d\366\3515$\322pkA\265\217\273g\222w\361\374\001\354w\266\367\003v\013\277\272{3\310\224\235\335-v\317t\013{\307\241Ow\001\231\274\201T\341\333\260j\323\335\377Bd\2044,\3426\334\2778\267K\000f\336\336_\016>&\334\006\255}\001g\376,\354\367yX\337\343\373\263\000\236Hq\247\020'\342k\354\031\314\336)\243\247_v\277\352\335\202\206\357\037\214>\035\301\003\007\370\321\344M8\212\016n3d]\352\236\021#b""\302\372b\367\301\336\233\204\025^\177\277{\023xT\340>\361\250>\205\344\347\235^\021\270\271\373\007#\320_\"#\210\321\201M\202\304(\240\262\344\355\317\201\202\000\356\3610\333\364?\247\237_\034\301V\276\330}cwZ\321\206\021\301\366[\335\207\n\022\351\303\251'7\201\177]\350\021\237\010G\300\271\336;{c\000\333s\007\027\017|\030=\264\374\250{\027\027\354\371\033g\221\315\301\205zr\341\360\315\267\236\237\300\275\016\244$\235V\323\002\244\020\306\200\330Af\200H\224C\240\323n\365\276\337\353\354\323R\335\3566\367n\342\326\241\005\307\354\357v\177\337\373\023,\316\t\346\327\333\3357\231\277\304\307\263\335\333\311\007_\036\034?\230F\344\371A\367\247\275\267\360L!6\033\020\373\227\007'\223\033\300\254\000\375UKj\017\223\207\314S\300\356\306\212\201\030\003\222\005\237^\303-\007\034\217\367\374\265\223\207'\010\321\"G\3726\360]\345\275\267a\217|\370\364\324\263i\304\356\2573G4\211{\377\337!\377i\342\256\201U\370\353\3765\200\2503\210s\277\202\361\314 \241\206\370\356\364\233\273w\210N\304\303\030>^\333\255u\327\000\205=\336\177c\277\010\0208s\320\006x9Kd\000\223\331\377\006\231\337g\374r\256{,\305f\277\306<<Q\233\363{?\302\032\327\221v&\326\006\326u\364\333\003\217\351\371\217wo\213\005D\260}\273\367*0\244c\200\035\243\203\302\263c0f\350\332\231\337\035\236\300S\372\265\223\010\250D\262|\014$S\270\177\357\351\177<}Lr\020:\234\"\2423\266\367\267\016\376\374\354\230\034}r\272\260\267\t\244@\374\324\222\207\220<\201\377$\247'\222\t\340o`\037\300\321\364\333'\033\273\323\273\267\341\3454\276l\356\006t|\302.\000\030\204\361\235D2\t\367\372U$^\177\373d\247\373jw\234f\351\346\001\255\326k\207\247\336\205=\261\331\253\003\205\004s\361\353\336\347\300\177\2140jy\037\346\354\334\336\207\007x\250\277\376\236\314\206/\037\001\211\374\327}$V^?\017\247\307\266|\371\r.\035\276o\003f8{\2617\207H\343\275.\020\037D\306\221\334\341=\304l\327\223/\027\236-\001-A\364\036\322\262\270\017\220\304F|\365\3744\036\346L\304\343\032\002%?}\230\307\300\021B d\325o\024\207\204\277~G4\306i\344\276\275""\344C`$\253I\025\270\342\000\367\331\303C\305\307\031\325#5K\202\245\323\310\200\234\305m\301\242\224\033\275\312\036\034\232\037v\333\360B\207\3579\\\314\217\340\003\n\r\n\260mf\240k\357\235\307\364\207\274L'qnN\0034\211\243q\n\220_9\231\206\003\ni\002\354\327\006@\363m\222\311\340@\010=\375\346\3604\236i!C\370g\273\177\351]8<\373^\367\033\330\345\307\223\313\310\342\342R\274\211\363\377\260w<\271\010\030\022\200\366\215\263X\014\010\244\356l\342\000\357\001lj\206\004\215\222Ul\227v+\236\031\237\3646Qx\364O:\365\350\375\301\376\231} \025\200\203\304?#\004\267\311\311\331d\026\330\003`\300\267\223\343\320\276)w\220\010\017V\002\350\310\213\275\205\375W\367\307\017\036?\373 \271\363c\272\003\310\001\321\324\236\234J\246\376\370l\034\262$'/\357-$_\002\"NN\002Y\234\034\207?\207\006\302D<t\n\205n_\001\016\370\033\3424\206\032%\313\"\222\026\017\314e e\031\337\223$\014\260\316\376\004\211\354\000\373\023f#\2422y\007?\\\220\325\354}\271\377\035\241\2645%\213x\270\177;9\336\207\000D\204\005\270\023Au\244\027\323q\010'\343\233\275*\n\247\220v;\013u\000\310<F\341\3025\240\236\201\234\372to\342\340]\340\007\316!\254\237\035\205\323\262\010[\354\354\245\344\322WH~C3o^\006\366\010\301\351\275\356\227\275?\354}\214\224\026T\366\376\207pb\001Q\006\004\321\363\367Gzw\340\320\215\200N=\377\376\363K\243\317\235K\275\355d\002yj\007\211\253\213(W\370\370\"\234\345f\251\367\316c\355\347`\373\261\220\016\220-\202&%&o\217\002\320J\361]2\262\236\254\223\250!\2129\317\277c\301\177H\220\027\3574\256\253\373\243p*\236\033\333\373`\377\361\3233\207\360p\006\307\374\017\022\265b\336\347y\333J\312B\222\343\304\027\303aq1\271\010\\\324\323G\317n\023<\254&\253\245\344$\377\375\356\340\357\317\326\222U f\343$\376\033\220Y\177?VFaR\371\325?\341\317\237^m\341O\353\325\277\340\317_^\375\353\253P$\371n\r\010\350'\027`\324\364\007\360\360\023\000b\230\365\336\005\330|\300\306=\361z^\327;\360\222\223@~&\307%C@\262`\211rE\362\331\335\331\344\\\001\210\342s\300\010_|\3521\n=\001\254\331yX\235Wa\006>\005""\306\371G\350z3LN~{\020\302S\013\010\305\257\017\276A\001\r\360\021\200\001\216\035\036\177-y\r\305\004\307\177\235\374\0320Yr\234\270W<x\376\243\367\360\271\020\323N\023.\022B\362\t\301\303\235I\316\000\236;<\365A\362\201\240B\220\212\004z\341w\260\301\227\367&\223\313\360\371\351o\2018]\271M\210\366\371\351\017\272\001\302dr\231\210T\304\251w\0210Q\022\377\3353\"\341\336A\002\014\241\346;\230e\314\360c\357\356^u\377\243\375?\002\262\370\335\033\202\220\004\262=\271\366\375\263\311\347\222\255\3005I/'`\322?\301\211\004\275%\301\361\265\256\337\273\006\255\241H\225@\000\301\371\"l\3316\034\260\253{\361\376\267O\t\216\036#\237)Qd\362\312\231\3353\377:\367\312\277\375\273\244\227\210E\024Sq\362?\223\377\004B\003!299\001\364\314\374\301\355\344\321\026\234\205\214y\267\340d\245\306\376A\362od\274p\252\317\263\302\342\271\203D\275\203\202\007x\372#,\261C\202\331\347\316W\270\033\237;@\313\000\322t\306\211\366v>\305\231a\244z}\357\230\332\024(\177=<G\242\001X\345\344[@\236\200\004%\335\377\377\001\374c\215\003";
    PyObject *data = __Pyx_DecompressString(cstring, 23450, 1);
    if (unlikely(!data)) __PYX_ERR(0, 1, __pyx_L1_error)
    const char* const bytes = __Pyx_PyBytes_AsString(data);
    #if !CYTHON_ASSUME_SAFE_MACROS
    if (likely(bytes)); else { Py_DECREF(data); __PYX_ERR(0, 1, __pyx_L1_error) }
    #endif
    #else /* compression: none (76260 bytes) */
const char* const bytes = ".000:00:000.0.0f1100115 Min.1.023:59:5945 Min.7.0[ACTIVITY] Sleep detected %s minutes ago - assuming awake[ACTIVITY] System is responsive (can query frontmost app) - system is awake[ACTIVITY] System is sleeping - skipping activity calculation and storage[APIBlock] API calls paused \342\200\224 cycle %d/%d (zero activity or idle popup active); intervals saved to DB[APIBlock] All intervals are from previous counter (not %s) - not holding[APIBlock] Clearing %s held idle interval(s) from previous counter (current counter=%s)[APIBlock] Error checking database for idle intervals: %s - continuing with intervals list only[APIBlock] Error checking if API calls should be paused: %s[APIBlock] Excluded %s interval(s) from upload (held or is_idle pending popup)[APIBlock] Found unsent idle interval in DB (id=%s) that wasn't in intervals list - adding to check[APIBlock] Holding 1 idle interval (counter=%s) - will send when non-idle interval found or popup handled[APIBlock] Holding idle interval (id=%s, counter=%s, start=%s, end=%s) - will send when non-idle interval found or popup handled[APIBlock] Holding %s idle intervals (counter=%s) - will send when non-idle interval found or popup handled[APIBlock] Max pause cycles (%d) reached \342\200\224 forcing upload to prevent indefinite data hold (idle popup not active)[APIBlock] Non-idle interval(s) found (%s) - held idle intervals will be sent before non-idle intervals[APIBlock] Pausing uploads: Idle popup is active (triggered at %s)[APIBlock] Sending %s held idle interval(s) from current counter (%s) before non-idle interval[APIBlock] Successfully sent %s held idle interval(s)API error uploading screenshot %s: %s[API] %s | request failed: %s[API] %s | timeoutAction is 'continue' with keep_idle_time=True - triggering immediate syncActive app changed: %s -> %sActivityController: Set project_id=%s, task_id=%s, segment_start=%sActivityController.__init__ (line 158)ActivityController.getStartingSlot (line 1554)Activity found in activity_""percentage for %s to %s: keyboard=%s, mouse=%s, average=%sActivity percentage record already being created for slot %s to %s. Skipping duplicate creation.Activity percentage record already exists for slot %s to %s. Skipping creation to prevent duplicates.[AddNote] Error saving note to current interval: %s[AddNote] Failed to enqueue Notes entry - queue may be full[AddNote] Flushing write queue to ensure intervals are committed...[AddNote] Latest interval found: ID=%s, counter=%s, is_uploaded=%s[AddNote] No interval found with counter %s[AddNote] Processing write queue immediately to save note...[AddNote] Starting to save note to current interval: note_length=%s[AddNote] Successfully queued Notes entry with interval ID: %s[AddNote] Using counter: %s[AddNote] Using target interval ID: %s (latest_id + 1) for upcoming interval[AddNote] Write queue processed - note should now be in databaseAdd Empty Interval in range of tracking mode: After trim: pending break interval overlaps %s to %s \342\200\224 skippingAfter trimming: Break interval overlaps with trimmed time range %s to %s (break intervals: %s) - skipping regular interval creationAfter trimming: Regular interval overlaps with trimmed time range %s to %s (overlapping intervals: %s) - skipping duplicate creation to prevent overlapAll %s intervals from current session (counter=%s) were already marked as uploaded[AppMonitor] OS: %s, appandurlstatus: %s, windows: %s[AppMonitor] Re-enabled \342\200\224 status=%s, appandurlstatus=%s[AppMonitor] Skipping cycle \342\200\224 status=%s, appandurlstatus=%s (0 = tracking disabled by org; check org settings in dashboard)[AppMonitor] Still disabled \342\200\224 status=%s, appandurlstatus=%s[AppMonitor] monitor_active_apps started \342\200\224 OS: %s, appandurlstatus: %s, interval: %ssApp monitor activity found for interval %s to %s - marking as activeApp monitor activity found for %s to %sAttempting fallback restart of device listeners...Attempting to save interval %s to %s after ""exceptionBackground task monitor_active_apps was cancelledBackground task monitor_active_apps failed: %sBackground task monitor_active_app_for_ui was cancelledBackground task monitor_active_app_for_ui failed: %sBearer Brave Browser[Break] Intervals will be created in real-time with is_break=%s[Break] \342\234\223 Monitoring CONTINUES during break (break_id=%s)Break interval (break_id=%s) - saving with is_uploaded=False (will be uploaded later) >> status %s, is_idle=%s (popup_is_active=%s, has_zero_activity=%s)Break interval overlaps with time range %s to %s (break intervals: %s) - skipping regular interval creationBreak is active (break_id=%s) and interval starts on/after break start (start=%s, break_start=%s) - marking as break intervalBreak is active (break_id=%s) and slot overlaps break (slot %s to %s, break_start=%s) - saving only break part as break interval: %s to %sBreak is active (break_id=%s) but interval ends before break start (start=%s, end=%s, break_start=%s) - marking as regular intervalBreak is active (break_id=%s) but interval starts before break start (start=%s, break_start=%s) - marking as regular intervalBuilding activity/log stop fields (last_interval=%s, force_stop_time=%s, intervals=%s)\342\232\240 CRITICAL: Last interval not found in database after %s attempts. Interval may not be committed!CRITICAL: org_api_timezone is still None. Timezone checks may fail!\n        Calculate the starting time slot for activity monitoring.\n        \n        This method determines the appropriate start and end times for the first\n        activity monitoring interval based on the current time and configured\n        interval duration.\n        \n        Returns:\n            Tuple[datetime.datetime, datetime.datetime]: Start and end times for\n            the initial monitoring slot.\n            \n        Example:\n            >>> controller = ActivityController(last_count=1)\n            >>> start_time, end_time = await controller.getStartingSlot()\n        ""    >>> print(f\"Monitoring from {start_time} to {end_time}\")\n        Cannot create last interval: start_date=%s, end_date=%s, time_diff=%ss (time_diff <= 0)Cannot execute midnight operations: user_entity is NoneCannot send previous day unsent intervals: %sCannot update interval: user_entity is NoneCannot upload file to S3: S3 configuration not found for org_id: %sCannot upload file to S3: file does not exist: %sCannot upload file to S3: org_id is not set in user_entityCannot upload file to S3: user_entity is not available and cannot be retrieved from databaseChecking for remaining break intervals before stop...Checking queue status before querying intervals...Cleaned up temporary database copy: %sCleaning function Build for windowsCleared idle popup active flag after handling reassign - API calls will resumeCleared log file: %sCollecting and sending unsend activity intervals to server in last API callContent-TypeContext: file=%s, dest=%sContext: file=%s, dest=%s%sCould not check activityLevel attribute: %sCould not check activity level for sleep detection: %sCould not check if last interval is sleep interval: %sCould not check if last interval is sleep interval for manual inclusion: %sCould not check is_uploaded status for manual inclusion: %sCould not check system sleep state: %sCould not check wake time for sync failure: %sCould not delete last interval screenshots after explicit update: %sCould not find database record for interval: start_time=%s, end_time=%s, counter=%sCould not find database record for last interval to updateCould not pre-update last interval for screenshot delete: %sCould not register sleep/wake callbacks: %sCould not stop disabled time monitor: %sCould not verify macOS user activity: %sCould not verify user activity via app monitor: %sCreated segment dummy entry at %s (counter=%s), flushed %s writesCreating first dummy entry: start_date=%s, counter=%s, is_uploaded=True, break_id=%s, will be saved as is_break=%sCreating last interval: start""_date=%s, end_date=%s, status=%s, time_diff=%s secondsCreating safe database copy for upload: %sCurrent Interval Status: %s Screenshot Interval frequency: %s App and URL Status: %s Blur Intensity: %s: Current idle time (*** \342\232\240\357\270\217  DATA SYNC FAILED AFTER SYSTEM SLEEP - PLATFORM: %s - WAKE TIME: %s - TIME SINCE WAKE: %s MINUTES - DATA NOT SYNCED TO WEB - THIS MAY CAUSE DATA LOSS \342\232\240\357\270\217  ***[DEBUG][Break State] Break interval - break_id=%s, is_break=%s, status=%s, will save as is_break=%s[DEBUG][Break State] Saving interval - break_id=%s, is_break=%s, status=%s, start_date=%s, end_date=%s[DEBUG] _save_note_to_idle_intervals: Found %s intervals with is_idle=True, %s intervals with zero activity, %s total unique idle intervalsDaily Limit: %sDatabase copy size mismatch: %s vs %sDatabase file not found for upload: %sDatabase operation timed out after %ss in delete_old_data_and_screenshotsDatabase query timed out after %ss in midnightDatabase query timed out after %ss in startup S3 checkDatabase query timed out after %ss in wake S3 checkDatabase query timed out after %ss while getting old screenshotsDatabase query timed out after %ss in getting_unsent_intervalDatabase upload failed: %sDatabase uploaded successfully: %sDate changed from %s to %s - resetting limit stop statusDay rollover detected: %s -> %sDeferred post-switch interval saved at slot boundary: %s to %s (counter=%s, session_start=%s)Deleted old ActivityInterval entries.Deleted old Appmonitor entries.Deleted old OrgConfigurations entries.Deleted %s screenshot database entries.Deleting %s screenshot files...Device ThreadDevice activity monitoring stoppedDevice listener state after break - stop_listeners: %s, Mouse active: %s, Keyboard active: %s, Mouse verified: %s, Keyboard verified: %sDevice listeners restarted at start of device activity - keyboard and mouse events should now be loggedDevice listeners restarted successfully - keyboard and mouse events should now be loggedEit""her plan status Deactivated use deleted or user deactivatedEither plan status Deactivated, user deleted or user deactivatedEncrypted key must be a non-empty stringEnqueued initial activity percentage%s: Slot: %s to %s, Keyboard: %s%%, Mouse: %s%%, Average: %s%%, Minute: %s. Minute timer will update with actual activity data when it runs.Error building payload for interval %s: %sError cancelling background task: %sError checking activity in interval: %sError checking activity_percentage for interval %s to %s: %sError checking and handling limits (fail-safe): %sError checking/creating activity percentage: %sError checking for existing first dummy entry: %s - proceeding with creationError checking for existing interval: %s - will proceed with creation (non-critical)Error checking for overlaps after trimming: %s - will proceed with creation (non-critical)Error checking memory usage: %sError checking recent intervals: %sError checking segment dummy entry: %sError checking/sending remaining break intervals: %sError checking zero activity for interval: %sError creating database copy: %sError deleting database entries: %sError deleting screenshot file %s: %sError deleting screenshot: %s in %s/screenshotsError deleting screenshot: %s in %s\\screenshotsError during periodic log cleanup (non-fatal): %sError fetching notes from Notes table: %sError fetching user org: %sError flushing database write queue after first entry: %sError flushing database write queue after last interval: %sError flushing database write queue before fetch: %sError flushing database write queue: %sError flushing database write queue after last interval update: %sError flushing database write queue after marking all intervals: %sError flushing queue after break interval creation: %sError force-updating interval (id=%s): %sError getting activity for break-overlap interval: %sError getting activity for deferred post-switch interval: %sError getting activity for trimmed interval: %sError getting last interv""al on startup: %sError getting last interval on wake: %sError getting last interval: %sError getting old screenshots: %sError getting unsent intervals: %sError handling S3 time error: %sError handling idle popup response: %sError in _idle_reassign: %sError in background limit notification: %sError in database upload: %sError in db_to_server: %sError in deleting logs: %s in %s\\logsyError in deleting old data and screenshots: %sError in device activity loopError in fallback update: %sError in final verification step: %sError in importing Activity Controller file either in listeners or windowsError in minute activity timer: %sError in monitor_active_app_for_ui: %sError in monitoring active apps: %sError in periodic break queue flush: %sError in stop_event: %sError in sync_activity_immediately: %sError in uploading MAC logs: %sError initializing org settings: %sError loading org settings from DB: %sError logging system resources: %sError manually including last interval: %sError marking held idle interval %s as uploaded: %sError marking idle intervals as uploaded: %sError marking interval %s as uploaded: %sError posting open work session activity/log at monitoring start: %sError processing day %s for reassign: %sError querying database for interval: %sError querying database for last interval: %sError restarting device listeners at start of device activity: %sError restarting device listeners after break: %sError retrieving activity level for last interval: %sError retrieving/processing activity level for interval %s to %s: %sError saving note to Notes table: %sError sending active app update to Electron: %sError sending file upload failure message to Electron: %sError sending file upload success message to Electron: %sError sending idle intervals to API for date %s: %sError sending sleep_auto_stop to Electron: %sError starting time monitor: %sError triggering idle popup: %sError updating interval (id=%s): %sError updating screenshot status for %s: %sError uploading da""tabase copy: %sError uploading file to S3: %sError verifying last interval in database (attempt %s/%s): %sError verifying user activity during period: %sException type: %sExclude Empty Interval becasue it is out of range of tracking mode: Existing dummy entry: start_time=%s, end_time=%s, counter=%s, is_uploaded=%s[FAILED] Failed to send file upload success message to Electron[FAILED] Failed to send file upload failure message to Electron (FIRST ENTRY - mouse=1 by default)Failed to calculate gap between intervals: %sFailed to clean up temp file: %sFailed to create screenshot directory: %sFailed to create screenshot directory for folder Failed to delete screenshot file after upload: %sFailed to enable hourly log upload: %sFailed to evaluate idle interval: %sFailed to extract icon for %s: %sFailed to extract timestamp from filename %s: %sFailed to fetch start time from API Response, retrieving from DatabaseFailed to fetch start time from API, retrieving from DatabaseFailed to save activity percentage recordFailed to save interval during exception recovery: %sFailed to send active app update to Electron: %sFailed to send idle popup (attempt %s/%s), IPC connected: %s, retrying in %ss...Failed to send idle popup trigger after %s attempts. Final IPC status - Connected: %s, IPC server ready: %sFailed to send sleep_auto_stop to Electron (not connected?)Failed to send subscription expiration error to Electron: %sFailed to send time integrity error to Electron: %sFailed to send timezone error to Electron from activity loop: %sFailed to trim partial interval at project switch: %sFallback restart succeededFetching latest org settings before starting activity loop...File upload failedFile upload success message sent to Electron after database queuingFile upload to S3 failed or returned no URL for file: %sFile uploaded successfullyFile uploaded successfully to S3: %sFile uploaded to S3 successfully: %sFiltered out %s interval(s) that completely end before effective_start_time (%s)""Filtering by counter=%s to keep session intervals togetherFiltering intervals by current session counter=%sFiltering intervals by current session counter=%s for immediate syncFiltering out interval (start=%s, end=%s) - completely ends before payload start time (%s)\342\234\223 Final verification passed: All intervals from current session (counter=%s) are marked as uploadedFirst dummy entry already exists for start_date=%s, counter=%s - skipping duplicate creationFirst dummy entry created successfully: start_time=%s, end_time=%s, counter=%s, is_uploaded=%sFirst entry detected: No existing records in databaseFirst entry detected: latest_record.start (%s) < start_date (%s) - first entry after app startFlushed %s queued database updates after last interval updateFlushed %s queued database updates after marking all current session intervals as uploadedFlushed %s queued database updates after force-marking intervalsFlushed %s queued database writes - first dummy entry should now be in databaseFlushed %s queued database writes - last interval committed to databaseFlushed %s queued database writes, last interval should now be committedFlushing database write queue to commit interval updates...Flushing database write queue to process %s is_uploaded updates...Flushing queue immediately after creating break interval (break_id=%s)Force Stop Status False under PushForce-marked interval (id=%s) as uploadedForced session close: setting payload stop and last interval 'to' to %sFound database record for interval: id=%s, start_time=%s, end_time=%sFound notes for %s intervalsFound notes for %s intervals: %sFound %s idle intervals to reassign to project %s, task %sFound %s idle intervals to save note: %s, file_path: %s\342\232\240 Found %s intervals from current session (counter=%s) still marked as unsent after upload!Found %s intervals to sync immediatelyFound %s remaining break interval(s) with is_uploaded=0 - calling break_stop_event to send themFound %s unsent intervals from curren""t session (counter=%s)Found unsent non-break intervals from %s (counter=%s)Generated payload for date %s with start time %s and %s intervalsGenerated payload for previous day with %s intervalsGetting last activity intervalGoogle Chrome%H:%M%H:%M:%SHourly log upload enabled through logging threadIPC not connected after %s attempts - idle popup not sent. IPC server ready: %sIPC not connected for idle popup (attempt %s/%s), IPC server ready: %s, retrying in %ss...IPC not connected - skipping active app updateIPC not connected - skipping file upload success notificationIPC not connected - skipping file upload failure notificationIPC server not ready - skipping active app updateIPC server not ready - skipping file upload success notificationIPC server not ready - skipping file upload failure notification[IdleDetection] Checking for idle after break interval save[IdleDetection] Checking for idle after interval save (in range)[IdleDetection] Checking for idle after interval save (out of range)[IdleDetection] Idle detected - triggering popup[IdleDetection] No idle detected after break interval save[IdleDetection] No idle detected after interval save[IdleInterval] ActivityLevel: Keyboard=%s%%, Mouse=%s%%, Average=%s%%[IdleInterval] \342\232\240 Interval marked as IDLE - will NOT be sent to server until popup handled[IdleInterval] Regular interval (in range) - break_id=%s, is_break=%s, status=%s, will save as is_break=%s[IdleInterval] Regular interval (out of range) - break_id=%s, is_break=%s, status=%s, will save as is_break=%s[IdleInterval] Saving: break_id=%s, is_idle=%s[IdleInterval] Saving: is_uploaded=True, break_id=%s, is_idle=%s[IdlePopup] Break session is active (break_id=%s, is_break=%s) - skipping idle popup trigger[IdlePopup] Calculated consecutive idle count: %s[IdlePopup] IPC server is not running - cannot send idle popup. IPC server may not have started properly.[IdlePopup] Not triggered: consecutive_idle_count=%s (need >= 2)[IdlePopup] Popup already active (tr""iggered_at=%s) \342\200\224 not sending another trigger[IdlePopup] Server uploads BLOCKED until popup handled[IdlePopup] State: active=True, triggered_at=%s, timeout_limit=%ss[IdlePopup] Timeout reached - auto-stop triggered, skipping popup[IdlePopup] \342\234\223 Trigger sent to Electron (2 consecutive zero-activity intervals) [attempt %s][IdlePopup] Triggering popup: consecutive_idle_count=%s, timestamp=%s[IdlePopup] arise_idle_popup() called - checking conditions before sending trigger to Electron[IdleResponse] Clearing popup state and resuming normal operation[IdleResponse] Clearing %s held idle interval(s) from previous counter(s)[IdleResponse] Handling idle popup response: keep_idle_time=%s, action=%s, project_id=%s, task_id=%s, file_path=%s[IdleResponse] State cleared - unsent idle intervals suppressed when keep was unchecked[IdleResponse] User chose not to keep idle time - marking %s held idle interval(s) from current counter (%s) as uploaded[IdleResponse] User chose to keep idle time - %s held idle interval(s) from current counter (%s) will be sent[IdleTimeout] Auto-stop triggered \342\200\224 waiting for Electron stop (do not exit push alone; MonitorThread would restart it)[IdleTimeout] Checking timeout: elapsed=%ss, limit=%ss[IdleTimeout] Error checking idle popup timeout: %s[IdleTimeout] Error sending auto-stop signal to Electron: %s[IdleTimeout] Marking %s intervals from popup period as unkeep (is_uploaded=True): %s idle + %s with activity, interval_ids=%s%s[IdleTimeout] Sent auto-stop signal to Electron[IdleTimeout] \342\232\240 TIMEOUT REACHED: %ss >= %ss - Auto-stopping timer[IdleTimeout] Timer stopped due to unhandled idle popup (60 minutes timeout)[IdleUnkeep] Committed is_uploaded=True for %s interval(s)[IdleUnkeep] Marking %s interval(s) as is_uploaded=True: ids=%s%s[IdleUnkeep] No intervals to mark as uploaded (counter=%s, popup_at=%s)[IdleUnkeep] Popup-period scan (from %s): %s unsent interval(s)Idle popup could not be sent - IPC connection una""vailable. Will retry on next idle detection if cooldown allows.Idle popup shown confirmed by Electron (cooldown removed)=== Idle reassign completed: %s intervals reassigned successfully, %s failed ===Ignoring time-monitor event because timezone_preference=1 (checks off)Immediate sync API call failed or returned inactive status: %sImmediate sync API response: %sIn range of tracking senerio\n        Initialize ActivityController with configuration and managers.\n        \n        Args:\n            last_count (int): Counter value for tracking application restarts.\n                             Used to identify gaps in activity monitoring.\n                             \n        Example:\n            >>> controller = ActivityController(last_count=1)\n        Interval already exists for %s to %s (counter=%s) - skipping duplicate creationInterval missing id attribute: %s, skipping...  Interval %s: start_time=%s, end_time=%s, is_uploaded=%s, counter=%sIntervals found in database (first 5):Invalid UTF-8 data in encrypted key: Invalid base64 data in encrypted key: Invalid encrypted key format: empty data after '$'Invalid encrypted key format: missing '$' delimiterKeyboard and mouse activity tracking has stopped and could not be restarted. Your activity may not be recorded accurately. On macOS, grant Accessibility access in System Settings \342\206\222 Privacy & Security \342\206\222 Accessibility. Then restart Workstatus.*** LIMIT EXCEEDED - NOTIFICATION ONLY ***Last interval already in list (found after manual check)\342\234\223 Last interval confirmed in query results - will be sent to server   Last interval details: start_time=%s, end_time=%s, counter=%sLast interval details: start_time=%s, end_time=%s, counter=%sLast interval found in query results (attempt %s)Last interval (id=%s) explicitly updated after successful sendLast interval (id=%s) explicitly updated after successful send (fallback)Last interval (id=%s) found with tolerance and marked uploaded before screensh""ot deleteLast interval (id=%s) was not in the intervals list - may not have been sentLast interval (id=%s) was updated in this batchLast interval in this batch (stop click): setting payload 'stop' to %s\342\232\240 Last interval may not be in query results - but was manually included if neededLast interval not found in query results (attempt %s/%s) - waiting %ss and re-querying...Last interval not found in query results - manually including it to ensure it's sent to serverLast interval not found in query results, but keep_idle_time=%s and should_upload=%s - NOT manually including it (interval was saved with is_uploaded=True and should not be sent)Last interval saved: start_time=%s, end_time=%s, is_uploaded=%s, counter=%sLast interval saved with is_uploaded=True (keep_idle_time=False): start_time=%s, end_time=%s, is_break=0Last interval saved with is_uploaded=False (stop button - will be synced): start_time=%s, end_time=%s, is_break=0Last interval screenshots updated/deleted after explicit interval update (count=%s)Last interval still not found after %s attempts - will manually include it in resultsLast interval (stop): aligning payload 'to' with activity/log stop %sLast interval (stop): extending screenshot range to %s to include stop screenshot\342\234\223 Last interval verified and has database ID: %sLast interval was not updated in any batch - explicitly updating it nowLast saved interval details: start_time=%s, end_time=%s, is_uploaded=%s, counter=%sLibrary/Application Support/WorkstatusLibrary/Application Support/Workstatus/logs/workstatus_error.logLibrary/Application Support/Workstatus/ws_monitor.dbLimit Action: %sLimit Type: %sLimited to 100 intervals for date %s[Linux] All URL detection methods failed, using 'New Tab'[Linux] URL detected via comprehensive method: %sLoaded org settings from DB: timezone=%sLog file %s does not exist, skipping upload.MAC ErrorLog file does not exist, skipping upload.[MEMORY_WARNING] Memory usage high: %sMB (limit: %sMB)\342""\234\223 Manually added last interval to results - total intervals: %sMarked interval (id=%s, counter=%s) from current session as uploadedMarked %s additional intervals from current session (counter=%s) as uploadedMicrosoft EdgeMinute activity timer stoppedMozilla FirefoxN/ANetwork error during screenshot sync for screenshot: %sNetwork error during screenshot sync for Mac logs: %sNetwork error during screenshot sync for database: %sNetwork error uploading screenshot %s: %sNew TabNo Connection for timestamp and update interval %sNo completed intervals to sync immediatelyNo idle intervals found to reassignNo idle intervals found to save noteNo interval found in held intervals %sNo interval found %sNo interval payloads created for date %sNo intervals found for the given date range.No intervals found in database at all - this is unexpectedNo intervals found to sync immediatelyNo intervals remain after filtering - skipping this dayNo items in queue - last interval already processedNo limit start or end time or no of daysNo missing intervalsNo org settings from API (rate limit or error) \342\200\224 skipping update_interval applyNo previous interval and no session start_date - using fallback: %sNo previous interval found, using session start_date: %sNo project selected in Python \342\200\224 using fallback project_id=%s. Ensure Electron sends set_project_task before start_activity_monitoring.No remaining break intervals found - nothing to sendNo response received from server for unsent intervalsNo screenshots older than 7 days found for deletion.No tracking scenerio foundNo unsent intervals to sendNo unsent non-break intervals found from previous sessionsNo user activity during period NoneNot in Tracking daysNote/File saved to idle intervals: note_length=%s, has_file=%sNote that Cython is deliberately stricter than PEP-484 and rejects subclasses of builtin types. If you need to pass subclasses then set the 'annotation_typing' directive to False.Note truncated from %s to %""s charactersORG check at every intervalOS error accessing screenshot: %s - %sOn break (break_id=%s) - flushing %s queued intervals to DB (periodic flush)Optional[asyncio.Event]Optional[datetime.datetime]Optional[str]\n    Orchestrates activity monitoring. See mixin classes for implementation.\n\n    Inherits from:\n    - ActivityScreenshotMixin: Screenshot capture and upload\n    - ActivityBreakMixin: Break detection and interval processing\n    - ActivityIdleMixin: Idle detection, popup handling, and idle intervals\n    - ActivityTimezoneMixin: Timezone detection, validation, and normalization\n    - ActivityIntervalMixin: Interval grouping, session management, and bulk payloads\n    - ActivityPushMixin: Push/sync loop, DB-to-server upload, and data cleanup\n\n    Attributes:\n        last_count (int): Counter for tracking application restarts\n        interval (int): Activity sampling interval in seconds (default: 600)\n        screenshot_interval (int): Screenshot capture interval in seconds (default: 1)\n        status (bool): Main activity tracking status\n        main_start_date (Optional[datetime]): Start time for current tracking session\n        main_end_date (Optional[datetime]): End time for current tracking session\n        local_timezone (str): Local timezone identifier\n        system_unique_id (str): Unique device identifier\n\n    Example:\n        >>> controller = ActivityController(last_count=1)\n        >>> await controller.start_device_activity(user_entity, stop_event)\n    Out of range of tracking senerioPending break interval in write queue overlaps %s to %s \342\200\224 skipping regular intervalPerforming final verification: checking all %s intervals from current session are marked as uploaded in database...Permission denied accessing screenshot: %s - %sPrevious day unsent intervals %sProceeding to save interval with default activity level due to errorProcessing %s idle intervals for date %sProcessing %s pending queue items immediately...Proce""ssing %s remaining queue items immediately before querying...Project switch close: using trimmed partial %s to %s (id=%s) \342\200\224 not creating a duplicate closing intervalPush threadPython process will remain alive - monitoring stopped but process continues running\342\232\240 Query returned 0 intervals - last interval was manually included if neededQueue is empty - all items already processedQueue status before final flush: ACTIVITY_INTERVAL=%s, Total=%sQueue status before flush: ACTIVITY_INTERVAL=%s, Total=%sQueued Notes entry with %s interval IDs: %s, file_path: %sRe-queried after delay: Found %s intervals from current session (counter=%s)Reassign action requires project_id - ignoring reassign requestRegular interval overlaps with time range %s to %s (overlapping intervals: %s) - skipping duplicate creation to prevent overlap\342\234\223 Remaining break intervals sent via break_stop_eventResolving slot %s to %s already exists \342\200\224 refreshed activity (not idle)Response for held idle intervals: %sResponse: %sRestarting device listeners after break to ensure activity tracking works...Restarting device listeners at start of device activity...Retrieved activity level for last interval (%s to %s): mouse=%s, keyboard=%s, average=%sRetrieved %d unsent non-break interval(s) from %s (counter=%s)Running db to serverRunning device activity force status %sRunning push empty intervalsRunning push logsRunning push loop force_stop=%s, timezone_mismatch=%s, datetime_mismatch=%s, time_error_type=%sRunning timecheck \342\200\224 timezone_preference=%s (checks ON)Running unsent intervals check (excluding current session and break intervals)S3BucketEntity | NoneS3 RequestTimeTooSkewed (system clock skew vs AWS): %s \342\200\224 not showing timezone mismatch; upload will retry after time syncS3 TIME TAMPERING DETECTED during screenshot upload: %sS3 upload returned no URL for file: %s=== SESSION COUNTER === Incremented %s -> %s (%s); intervals use counter=%s[SLEEP] Registe""red sleep callback for %s[SLEEP] Skipping device listener sleep callback on Linux (idle-based sleep detection would stop input listeners incorrectly)[STARTUP] Error checking/updating S3 bucket on startup: %s[STARTUP] New day detected (last: %s, current: %s) - updating S3 bucket config[STARTUP] STS credentials expired \342\200\224 refreshing S3 bucket config[STARTUP] Same day (last: %s, current: %s) - no S3 bucket update needed[STEALTH] API call failed, will try database fallback[STEALTH] API call successful, cached response[STEALTH] Cache expired (%ss >= %ss) - refreshing from server[STEALTH] First stealth mode API call - fetching from server[STEALTH] Fixed-mode window missing/invalid (start=%r end=%r) \342\200\224 using all-day fallback[STEALTH] No cached response available, trying database[STEALTH] Using cached stealth mode data (%ss < %ss)[STEALTH] Using cached stealth mode response*** STOPPING TIMER DUE TO LIMIT EXCEEDED ***[SUCCESS] Sent file upload failure message to Electron[SUCCESS] Sent file upload success message to Electron (URL: %s...)[SYSTEM_RESOURCES] Memory: %.2fMB (%.1f%%), CPU: %.1f%% (System: %.1f%%), Threads: %s, FDs: %sSave last activity interval to DB (from %s to %s - actual stop time, duration: %ss)Screenshot file not found: %sScreenshot file not found: %s - %sScreenshot file not readable: %sScreenshot sync error for Mac logs: %sScreenshot sync error for database: %sScreenshot sync error for screenshot: %sScreenshot sync validation error for screenshot: %sScreenshot sync validation error for Mac logs: %sScreenshot sync validation error for database: %sSegment dummy entry already exists for start=%s counter=%sSending immediate sync payload for %s intervalsSending mac logs to serverSending previous day unsent intervalsSending %s idle intervals to API with project_id=%s, task_id=%sSent active app update to Electron: %sSent subscription expiration error to Electron: %sSent timezone mismatch error to Electron from activity loop: %sSent timezone mism""atch error to Electron: %sSession split detected | reason=%s | platform=%s | gap_minutes=%.2f | prev_end=%s | next_start=%s | prev_counter=%s | next_counter=%sSet current project_id=%s, task_id=%s after reassignSet status=True as fallback when starting device activity (status thread will update it based on API response)Setting S3 details for db to server[Silent] Sleep gap > 1 hour (%.0fs) \342\200\224 filling idle intervals normallySkip empty interval for Skip sleep gap fill \342\200\224 interval already exists for %s to %sSkipping all data sync operations (empty_interval, unsent intervals, current intervals)Skipping duplicate break interval - already creating %s to %s (counter=%s)Skipping duplicate break interval - interval already exists in DB for %s to %sSkipping duplicate interval - already creating %s to %s (counter=%s)Skipping duplicate interval creation for %s to %s (counter=%s)Skipping exception recovery save - interval %s to %s already in progress (avoid duplicate)Skipping exception recovery save - interval %s to %s already exists in DB (avoid duplicate)Skipping hourly log upload initialization: user_entity is NoneSkipping idle reassignment interval (id=%s, start=%s, end=%s) \342\200\224 no time left after clipping to payload start %sSkipping interval creation after trim - break interval overlaps with trimmed time range %s to %sSkipping interval creation after trim - regular interval overlaps with trimmed time range %s to %sSkipping interval (start=%s, end=%s) \342\200\224 no time left after clipping to payload start %sSkipping last interval creation for small gap (%ss) - this is normal processing time, not actual activitySkipping regular interval creation - break interval exists for time range %s to %sSkipping regular interval creation - overlapping regular interval exists for time range %s to %sSkipping timecheck \342\200\224 org timezone not loaded yetSkipping timecheck \342\200\224 timezone_preference=%s (checks OFF)Skipping timecheck: user_entity is No""ne[SleepInterval] Detected sleep interval (%s hours) - will NOT set 'stop' timestamp[SleepInterval] Detected sleep interval from activityLevel attribute (%s hours) - will NOT set 'stop' timestamp[SleepInterval] Last interval is a sleep interval (%s hours) - skipping last interval creation to prevent sending wake-up time as 'stop'[SleepInterval] Last interval is a sleep interval (%s hours) - will NOT manually include it to prevent sending wake-up time as 'stop'[SleepInterval] Last interval was saved with is_uploaded=True - will NOT manually include it (interval should not be sent to server)[SleepInterval] Skipping last interval creation - last interval was a sleep interval ending at %s[SleepInterval] Skipping manual inclusion of sleep interval - it was saved with is_uploaded=True and should not be sent to server[SleepInterval] Skipping 'stop' timestamp for sleep interval (start=%s, end=%s)Sleep auto-stop signal sent to Electron (sleep gap: %s minutes)Sleep gap Sleep gap > 1 hour (gap_seconds=%.0f, fill_seconds=%.0f) - saving empty interval(s) for non-overlapping parts only (visible mode)Sleep is less than 1 hour adding up intervalsSleeping %.1fs until interval end %s (slot %s to %s)Start date or end date is NoneStarted app monitor flush taskStarting deletion of old data and screenshots.=== Starting idle interval reassign: project_id=%s, task_id=%s ===Starting last_api_call (normal stop)Starting minute-by-minute activity rolling average timerStarting screenshot activity with interval: %s and ss frequency: %s blur intensity: %s status: %s limit start: %s limit end: %s no of days: %sStarting time monitor (%s)...Stop event detected after sleep - breaking loop before creating intervalStop event detected - breaking loop before creating intervalSuccessfully deleted old data and screenshots from specified tables.Successfully processed %s queued database updatesSuccessfully saved interval after exception recoverySuccessfully sent idle intervals for date %s to APISystem clock ""drift detected by time monitor \342\200\224 not treating as timezone mismatchSystem is in sleep: %sTarget date of intervals %sTemporary database file not available for uploadTime integrity error detected (%s) - stopping tracker IMMEDIATELY - NO DATA SYNCTime mismatch under activityTime monitor started \342\200\224 timezone and datetime changes will be detectedTime tampering detectedTimeout checking recent intervals for counter=%sTimer remains stopped due to limit exceeded (stopped on %s)Timer started at: %s, appsandurlstatus: %s, interval: %s, Flag reset to False for new sessionTimer will remain stopped until date changes or system restarts[TimezonePref] Failed to toggle time monitor: %s[TimezonePref] Time monitor started after org preference enabled checks[TimezonePref] Time monitor stopped after org preference disabled checks[TimezonePref] org timezone_preference changed %s \342\206\222 %sTimezone ErrorTimezone Mismatch DetectedTimezone and Time matched successfullyTimezone change detected by time monitor \342\200\224 tracking will stopTimezone error sent to Electron - Python process will remain alive (not exiting)Timezone mismatch detected - SKIPPING last_api_call (no last interval sent to DB/API)Timezone mismatch detected in activity loop - stopping trackerTimezone mismatch under Push loopTimezone/time monitor disabled by login timezone_preference=1[Timing][Python] Creating first dummy entry with break_id=%s...[Timing][Python] DB write queue flushed[Timing][Python] Fetching org settings in __start_device_activity[Timing][Python] First dummy entry created[Timing][Python] Flushing DB write queue...[Timing][Python] Inside main activity loop[Timing][Python] Org settings fetched. Timezone: %s[Timing][Python] org_api_timezone is None, trying DB...Today is %s and tracking days are %sToken is ExpiredTraceback: %s[Tracker] Activity calculation skipped - tracking is stopped[Tracker] Activity monitoring paused - WebSocket connection remains active[Tracker] Persistent statu""s is 'stop' - tracking will not start until 'start' command received[Tracker] Persistent status is 'start' - tracking enabled[Tracker] \342\234\223 Tracking RESUMED - activity monitoring active[Tracker] Tracking is STOPPED - waiting for 'start' command via WebSocket...[Tracker] Tracking is disabled (status='stop') - device activity thread will wait[Tracker] Tracking stopped via WebSocket - skipping push activity[Tracker] WebSocket connection is active - waiting for 'start' commandTracking will continue as normalTrimmed interval start after break stop / last interval end: %s to %sTrimmed interval start before save (e.g. break stopped during slot): %s to %sTrimmed open partial for project switch (counter=%s): %s to %s (was to %s)Tuple[datetime.datetime, datetime.datetime]Unexpected error creating screenshot directory: %sUnexpected error creating screenshot directory for folder Unexpected error decrypting key: Unexpected error during screenshot sync for screenshot: %sUnexpected error during screenshot sync for Mac logs: %sUnexpected error in decryption: %sUnexpected error uploading screenshot %s: %sUnicode decode error in decryption: %s   Unsent interval: id=%s, start_time=%s, end_time=%sUpdated idle_time_limit_in_seconds from API: %s secondsUploaded from: %sUploaded to: %sUploading file to S3: %s -> %sUploading to AWS bucketUploading to Hetzner bucketUser checked 'keep' box - idle intervals will remain with is_uploaded=FalseUser entity is None - stopping trackerUser entity: %sUsing fallback activity level (zeros) for last interval due to errorUsing last interval end_time as start_date: %sUsing pinned activity/log session start: %sUsing project_id=%s, task_id=%s for activity log payload (override=%s)Using segment start (project/task changed on running timer): %sUsing user_entity with org_id: %s, user_id: %sValidation error with screenshot %s: %sValue error in decryption: %sVerified all current session interval updates are committed to databaseVerified interval updates ""are committed to database\342\234\223 Verified last interval in database: id=%s, start_time=%s, end_time=%s, counter=%sVerified last interval update is committed to database[WAKE] Error checking/updating S3 bucket on wake: %s[WAKE] Error handling S3 bucket update on wake: %s[WAKE] New day detected (last: %s, current: %s) - updating S3 bucket config[WAKE] No user_entity available for S3 bucket update on wake[WAKE] Registered S3 bucket update wake callback for %s[WAKE] Registered session counter wake callback for %s[WAKE] Registered wake callback for %s[WAKE] STS credentials expired \342\200\224 refreshing S3 bucket config[WAKE] Same day (last: %s, current: %s) - no S3 bucket update needed[WAKE] System wake \342\200\224 counter will increment on next monitoring start (stop\342\206\222sleep\342\206\222start and missed-stop cases)[WARNING] Break interval being saved with break_id=0! This should not happen during a break. self.break_id=%s, self.is_break=%sWaiting 1.5 seconds for database commit to be fully visible before querying...Waiting 1 second for database commit to be fully visible...Weekly Limit: %s[Windows Break Fix] Break has started (break_id=%s, break_start_time=%s)[Windows Break Fix] Interval ends at %s (before break start) - saving with is_uploaded=False so it can be uploaded[Windows Break Fix] Interval starts at %s (before break start) - saving regular part from %s to %s with is_uploaded=False[Windows Break Fix] Interval starts at %s >= break_start_time %s - this shouldn't happen in last_api_call[Windows Break Fix] Last interval saved with is_uploaded=False (will be uploaded by break_start_event): start_time=%s, end_time=%s, is_break=0[Windows Break Fix] Part from %s to %s will be handled as break interval[Windows Break Fix] interval_end_date (%s) <= start_date (%s) - skipping interval creationWork segment stop for payload: %s (break will start at %s)Worked This Week: %sWorked Today: %sWrong Timestamp%Y-%m-%d %H:%M:%S%Y-%m-%d-%H-%M-%S%Y-%m-%d_%H-%M-%SYour a""ccount is currently inactive (deleted, deactivated, or subscription expired).\nPlease contact your organization administrator to restore access.Your system has been idle for 60 minutes thus timer has stopped automatically...Your system timezone does not match the organization's configured timezone.\nPlease update your system time settings to continue trackingYour system timezone must match with Workstatus account timezone to start the trackerYour system was in sleep for more than 1 hour. Timer has been stopped automatically & time log for the sleep period has been saved. Kindly restart the timer to continue working!!=;\\...-?$================================================================================ \342\200\224 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - /add_noteappVersion: %sapplication/jsonbreak_stop_event was called %ss ago - skipping duplicate break interval processing to prevent duplicate API calls-ccurrent Project id: %s, current task id : %scurrent break id: %s, current is break: %sdatabase/datetime.datetime.dbdisableenable: fully covered by existing intervals (e.g. break)gc****************************************************************has_on_demand_screenshot: %s*********************************************************http://https://isenabled=== last_api_call COMPLETED SUCCESSFULLY ====== last_api_call FAILED: %s ====== last_api_call STARTED (keep_idle_time=%s, close_time=%s, project_override=%s) ===-logs.txt\\logsy[macOS] Apps only mode: Using browser name '%s' instead of 'New Tab'notes/org_api_timezone is None after update_interval, trying local DB...org_id set to: %s for ScreenshotController and ScreenshotService overlaps existing intervals; filling only non-overlapping parts: [push] update_tracking_duration timed out after 10s \342\200\224 continuing with cached stealth-mode datas)*** %s L""IMIT EXCEEDED ***s) >> period duration (%s: %ssave last active app as true because of wrong timezone deteceted so next last min save can't be wrong from activity/screenshots\\screenshotsstart_date is None - cannot create last interval. last_interval_end=%s, self.start_date=%sstart_date not available - cannot determine if this is first entry. Using default mouse=0start_date (%s) >= end_date (%s) - adjusting start_date to be 1 second before end_datestart_status_activity called with None user_entity, cannot proceed=== stop_event() called (keep_idle_time=%s) ====== stop_event() completed - last_api_call finished ====== sync_activity_immediately() called ====== sync_activity_immediately() completed ===[\\u200B-\\u200D\\uFEFF](unchanged)[update_interval] org settings \342\200\224 ssfrequencystatus=%s, appandurlstatus=%s, screenshotblurstatus=%s, timeInterval=%s, timezone_preference=%supdated Screenshot Controller %s %s %supdated tracking scenerio (fixed mode) %s %s %s mode=%supdated tracking scenerio from database%s %s %suser main status activity saved  >>  %s/workstatus/workstatus/ws_monitor.dbws_package/controllers/activity_controller.pyACTIVITY_INTERVALACTIVITY_PERCENTAGEAPIErrorAPIRequestAcceptAccessDeniedActivityBreakMixinActivityControllerActivityController.__init__ActivityController.__start_device_activityActivityController.__start_device_activity.<locals>.monitor_active_appsActivityController.__start_device_activity.<locals>.monitor_active_app_for_uiActivityController.__start_device_activity.<locals>.remove_after_delayActivityController.__start_device_activity.<locals>.check_idle_after_delayActivityController.__start_device_activity.<locals>._on_time_errorActivityController.__start_device_activity.<locals>.task_done_callbackActivityController.__start_device_activity.<locals>.active_app_ui_task_done_callbackActivityController.__start_minute_activity_timerActivityController._align_to_interval_boundaryActivityController._apply_org_timezone_preferenceActivityControlle""r._break_start_after_work_stopActivityController._calculate_gap_secondsActivityController._check_and_handle_limitsActivityController._check_and_handle_limits.<locals>.report_in_backgroundActivityController._check_and_update_s3_on_startupActivityController._check_and_update_s3_on_wakeActivityController._create_segment_dummy_entryActivityController._determine_sleep_reasonActivityController._finalize_work_stop_timeActivityController._get_activity_level_from_intervalActivityController._get_electron_commActivityController._handle_wake_session_counterActivityController._handle_wake_s3_updateActivityController._has_any_activity_in_intervalActivityController._has_zero_activity_for_intervalActivityController._idle_reassignActivityController._is_app_monitor_data_staleActivityController._is_system_sleepingActivityController._last_api_call_impl.<locals>.genexprActivityController._last_api_call_implActivityController._last_api_call_impl.<locals>.datetime_matchesActivityController._last_api_call_impl.<locals>.datetime_matches_finalActivityController._load_org_settings_from_dbActivityController._log_session_split_reasonActivityController._mark_idle_intervals_as_uploadedActivityController._normalize_hhmmssActivityController._parse_fixed_mode_windowActivityController._push_activity_logActivityController._s3_credentials_need_refreshActivityController._save_note_to_idle_intervalsActivityController._save_note_to_current_intervalActivityController._seconds_until_datetimeActivityController._send_active_app_update_to_electronActivityController._send_file_upload_success_to_electronActivityController._send_file_upload_failure_to_electronActivityController._send_subscription_expired_popupActivityController._send_to_electron_if_connectedActivityController._should_pause_api_calls.<locals>.genexprActivityController._should_pause_api_callsActivityController._should_start_new_session_ActivityController__start_device_activity_ActivityController__start_minute_activity_timerActivityController._trim_""open_partial_at_project_switchActivityController._try_finalize_post_switch_slot_intervalActivityController._upload_file_to_s3ActivityController._verify_user_activity_during_periodActivityController.arise_idle_popupActivityController.boundary_timeActivityController.check_idle_popup_timeoutActivityController.check_memory_usageActivityController.db_to_serverActivityController.decryptActivityController.delete_old_data_and_screenshotsActivityController.empty_interval.<locals>.genexprActivityController.empty_intervalActivityController.ensure_s3_credentials_freshActivityController.forward_ssActivityController.getCurrentSlotActivityController.getStartingSlotActivityController.get_activity_level_from_dbActivityController.get_bucket_in_every_intervalActivityController.get_day_start_timeActivityController.get_os_type_capsActivityController.getting_unsent_intervalActivityController.group_intervals_by_session.<locals>.<lambda>ActivityController.group_intervals_by_dayActivityController.group_intervals_by_sessionActivityController.handle_idle_popup_responseActivityController.handle_idle_popup_shownActivityController.handle_s3_time_errorActivityController.has_recent_intervals_on_write_counterActivityController.increment_session_counterActivityController.inrangeActivityController.is_browserActivityController.is_browser.<locals>.genexprActivityController.is_idle_intervalActivityController.is_linkActivityController.last_api_callActivityController.log_system_resourcesActivityController.midnightActivityController.process_intervals_bulk.<locals>.genexprActivityController.process_intervals_bulkActivityController.process_intervals_bulk.<locals>._dt_matchActivityController.sending_unsent_intervalsActivityController.set_local_timezoneActivityController.set_project_task_idsActivityController.should_skip_counter_bump_dedupActivityController.ssActivityController.start_device_activityActivityController.start_screenshot_activityActivityController.start_status_activityActivityController.stop_event""ActivityController.sync_activity_immediatelyActivityController.update_intervalActivityController.update_tracking_durationActivityIdleMixinActivityIntervalActivityIntervalMixinActivityManagerActivityMonitorActivityMonitoringErrorActivityPercentageEntityActivityPushMixinActivityScreenshotMixinActivityServiceActivityTimezoneMixinApplicationAppmonitorAuthorizationBULK_UPDATECancelledErrorChromeDB_OPERATION_TIMEOUTDEVICE_LISTENER_DEADDEVNULLDarwinDataManagerDeviceIDDeviceListenerEntryErrorCodeFileSystemErrorFirefoxFixedModeFixedServiceFlagFriGetForegroundWindowHIDIdleTimeIOHIDSystemJPEGLinuxListLocationEntityLogWriter_MAX_API_PAUSE_CYCLESMAX_NOTE_LENGTHMacModeEntityMonMsedgeNFKDNOTESNOT_SETNamedTemporaryFileNetworkErrorNoneNotesOperaOptimizedWindowsTimeMonitorOptionalOrgConfigurationsOrgEntityOrgIDPOSTPUSH_LOOP_FAILEDPathProcess__Pyx_PyDict_NextRefRLockR_OKRequestExceptionRequestTimeTooSkewedS3BucketEntityS3_TIME_TAMPERINGS3syncSDTokenSTATUS_LOOP_FAILEDSafariSatScreenshotScreenshotControllerScreenshotEntityScreenshotErrorScreenshotManagerScreenshotsServerControllerStatusControllerSunSyncSystemThreadThuTimeoutTimeoutErrorTimezoneManagerTueTupleUPDATE_ACTIVITY_INTERVALUnknownUserEntityUserIDUserServiceValidationError_WOT_WOT2WedWeeklyLimitNotificationWindowWindowsWriteOperationType_aaccessactionactiveactive_appactive_app_changeactive_app_ui_taskactive_app_ui_task_done_callbackactive_app_urlactive_windowsactivityactivityLevelactivity_countactivity_erroractivity_intervalactivity_interval_idactivity_level_activity_level_for_gap_fill_activity_log_payload_startactivity_manageractivity_percentageactivity_percentage_endactivity_percentage_end_secondsactivity_percentage_entityactivity_percentage_keyactivity_percentage_manageractivity_percentage_serviceactivity_percentage_startactivity_percentage_start_secondsactivity_queue_sizeactivity_serviceactivity_session_wakeaddadd_done_callback__aenter____aexit__align_stop_align_to_interval_boundaryaligned_timeallall_intervalsall_queryall_re""sultalready_in_listand___annotate__ans_arrayapi_call_madeapi_name_from_url_api_pause_active_api_pause_cyclesapi_responseappAndUrlsappVersionapp_and_urlsapp_dataapp_display_nameapp_iconapp_listenerapp_monitor_interval_secondsapp_monitor_timeapp_nameapp_pathappandurlstatusappendapplication_activity_log_urlapplication_org_config_urlapplication_restartapply_desktop_key_apply_org_timezone_preference_apply_resolving_slot_save_policyarise_idle_popupascasciiasync_sessionasyncioasyncio.coroutinesat_least_one_batch_successfulattemptaverageaverage_activityaverage_percentage__await__bb64decode_background_tasksbase64basenamebatch_intervalsblurblur_intensityboolboundary_timebreak_errorbreak_idbreak_interval_overlapsbreak_intervalsbreak_intervals_after_trim_break_monitoring_loggedbreak_project_id_break_start_after_work_stopbreak_start_timebreak_stop_attrbreak_stop_event_break_stop_timebreak_stop_time_attrbreak_task_idbrowserbrowsersbucket_bump_counter_on_next_monitoring_startc_cached_stealth_responsecalculate_and_store_rolling_average_calculate_gap_secondscancelcandidatecategory_fieldschannel_check_and_handle_limits_check_and_update_s3_on_startup_check_and_update_s3_on_wakecheck_existing_intervalcheck_idle_after_delaycheck_idle_detectioncheck_idle_popup_timeoutcheck_limits_exceededcheck_memory_usagecheck_outputcheck_querycheck_stale_breakchunk_durationchunks__class_getitem__cleaned_namecleaned_name_lowercleanup_enabledcleanup_old_filescline_in_tracebackcloseclose_timecodecollectionscombinecommitconfigconsecutive_idle_countcontextcontinuecopycopy2copy_errorcopy_sizecountercpu_percent_create_segment_dummy_entrycreate_task_creating_activity_percentages_creating_intervalscredentials_stalecurrent_current_active_app_current_active_app_icon_current_active_app_pathcurrent_app_datacurrent_app_namecurrent_app_pathcurrent_break_idcurrent_break_id_slotcurrent_countercurrent_counter_heldcurrent_counter_intervalscurrent_datecurrent_directorycurrent_intervalcurrent_loopcurrent_project_idcurrent_""segment_start_timecurrent_sessioncurrent_session_countercurrent_session_counter_for_lastcurrent_session_start_timecurrent_task_idcurrent_timecurrent_timestampcutoff_d_d2daemondailydaily_exceededdaily_limitdarwindatadata_managerdatabase_dirdatabase_serverdatedatetimedatetime_errordatetime_matchesdatetime_matches_final_datetime_mismatchdayday_intervalsday_listday_payloadday_start_timedaysdb_intervaldb_intervalsdb_lastdb_lock_managerdb_to_serverdb_write_queuedb_writer_servicedebugdecodedecryptdecrypted_datadefaultdefaultdictdel_edelaydeletedelete_old_data_and_screenshotsdelete_screenshotdescdetected_app_determine_sleep_reasondeviceIddeviceTypedevice_iddevice_listenerdevice_listener_sleepdevice_listener_wakedevice_typedictdirnamediscarddisplay_name__doc__donedt1dt2_dt_matchdt_objdtype_dwq_dwq2ee2effective_endeffective_starteffective_start_timeelapsed_secondselectron_commempty_activity_levelempty_interval_empty_interval_break_idenable_hourly_log_uploadencrypted_keyend_dateend_date_secondsend_date_yend_secend_timeenqueueenqueue_successenqueuedenrich_subscription_payloadensure_fresh_s3_bucketensure_s3_credentials_fresh__enter__enumerateerrorerror_dataerror_messageerror_typeerrorsetexactexc_infoexceptionexceptionsexcludedexecutableexecuteexistingexisting_dummyexisting_interval_in_dbexisting_recordexists__exit__extract_datetime_from_filenamefailed_countfallback_endfallback_errorfd_countfetch_browser_urlfetch_user_org__file__filefile_locationfile_namefile_pathfile_sizefile_upload_success_filter_gaps_before_session_filter_intervals_excluding_in_progress_resolving_slotfiltered_countfiltered_intervalsfinal_payload_finalize_work_stop_timefindfind_missing_timestampsfind_overlapping_activity_percentagefirstfirst_datefirst_entryfirst_entry_counterfirst_entry_notefixed_modeflag2floatflush_errorfmtfolderforce_stopforce_stop_timeforce_upload_after_pause_capformat_excformat_ss_nameforward_ssfromfrozen__func__funcgap_endgap_levelgap_minutesgap_secondsgap_startgenexprgetgetCurrentSlotgetS""tartingSlotget_active_windowsget_activity_intervalsget_activity_levelget_activity_level_from_db_get_activity_level_from_intervalget_app_iconget_apps_urlsget_browser_url_with_fallbackget_bucket_in_every_interval_get_consecutive_idle_countget_day_start_timeget_electron_comm_get_electron_comm_get_electron_comm_lazyget_event_loopget_fixed_slotsget_intervals_overlapping_rangeget_ipget_last_activity_intervalget_latest_activity_percentageget_localzoneget_loopget_os_typeget_os_type_capsget_os_versionget_pending_items_get_pinned_activity_log_session_startget_queue_sizeget_running_loopget_s3bucketget_screenshotsget_statsget_system_timezoneget_system_wake_detectorget_today_weekdayget_total_queue_sizeget_tracker_statusget_weekdayget_weekly_limit_notification_servicegetcwdgetloadavggetting_old_datagetting_unsent_intervalgroup_intervals_by_daygroup_intervals_by_sessiongrouped_intervalsguidhandle_idle_popup_responsehandle_idle_popup_shownhandle_s3_time_errorhandle_system_sleephandle_system_wake_handle_wake_s3_update_handle_wake_session_counterhas_activity_level_activityhas_activity_percentage_activityhas_any_activity_has_any_activity_in_intervalhas_on_demandhas_on_demand_screenshothas_recent_intervals_on_write_counterhas_zerohas_zero_activity_has_zero_activity_for_intervalheadersheld_held_idle_intervalsheld_interval_idsheld_intervalsheld_sent_counthetznerhomehourhrhwndii2tididleIntervalidle_countidle_file_upload_failureidle_file_upload_successidle_flag_queryidle_flag_resultidle_intervalsidle_intervals_by_flagidle_note_url_idle_popup_activeidle_popup_blocking_idle_popup_cooldown_seconds_idle_popup_timeout_secondsidle_popup_trigger_idle_popup_triggered_at_idle_reassign_idle_resolving_slotidle_thresholdidle_time_limit_in_secondsidle_time_nsidle_time_secondsidle_timeout_auto_stopidxignoreiidimage_urlimg_formatimg_prefiximg_qualityin_in_rangeinclude_printersincrement_session_counterinfo__init__initial_averageinitial_mouseinrangeintintervalinterval_datainterval_dateinterval_end_dateinte""rval_end_timeinterval_existsinterval_file_mapinterval_idinterval_id_listinterval_idsinterval_ids_in_listinterval_is_uploadedinterval_keyinterval_minutesinterval_note_mapinterval_payloadinterval_payloadsinterval_startinterval_start_timeinterval_timeinterval_time_dbinterval_to_updateinterval_verifiedintervalsintervals_for_dayintervals_to_markintervals_to_updateintervals_updated_countioregioreg_outputip_addressis_isUploaded_is_app_monitor_data_staleis_breakis_break_intervalis_browseris_connected_is_coroutineis_first_entryis_idleis_idle_intervalis_ipc_readyis_linkis_runningis_s3_uploadedis_setis_silent_buildis_sleep_intervalis_sleep_interval_for_manual_check_is_system_sleepingis_tracking_enabledis_uploadedisdeactivatedisdeletedisoformatisprintableitemsivjsonkeep_idle_timekeykeyboardkeyboard_activekeyboard_activitykeyboard_listener_activekeyboard_listener_verifiedkeyboard_percentagekeyboard_verifiedkeys<lambda>_last_active_app_check_timelast_api_call_last_api_call_impllast_app_monitor_time_last_break_queue_flush_last_break_stop_event_timelast_bumplast_count_last_counter_bump_atlast_endlast_entrylast_entry_date_last_idle_popup_trigger_time_last_idle_resolution_timelast_in_this_daylast_intervallast_interval_endlast_interval_foundlast_interval_idlast_interval_in_listlast_interval_objlast_interval_updatedlast_interval_was_sentlast_log_upload_timelast_matchlast_minutelast_sleep_timelast_ss_urls_last_stealth_api_calllast_wake_time_last_work_stop_timelatlatest_intervallatest_recordlimitlimit_actionlimit_endlimit_startlimit_stopped_datelimit_typelimits_checklinelinuxlinux_idle_gaplinux_sleep_or_shutdownlist_load_org_settings_from_dbloadslocal_file_pathlocal_timezonelocationlog_api_response_summarylog_cleanup_enabled_log_session_split_reasonlog_system_resourceslog_testing_request_headerslog_upload_interval_minutesloggerlogslogs_pathlonglooplowermac_logmacos_idle_gapmacos_sleep_or_shutdown__main__main_end_datemain_start_date_mark_idle_intervals_as_uploaded_mark_previous_zero_activ""ity_intervals_as_idlemax_retriesmax_verification_retries_memory_check_countermemory_infomemory_limit_mbmemory_mbmemory_percentmessagemessage_data__metaclass__microsecondmidnightminminimal_activityminimum_percentminuteminute_activity_levelminute_timer_taskminutesmissing_intervalsmktimemodemode_entitymodel_dumpmodule__module__monitor_active_app_for_uimonitor_active_appsmonitor_taskmousemouse_activemouse_activitymouse_listener_activemouse_listener_verifiedmouse_percentagemouse_verified__mro_entries__name__name__new_event_loopnew_sessionnew_stringnextnext_dayno_of_daysnodenon_idle_intervalsnormalize_normalize_activity_log_start_normalize_hhmmss_normalize_timezonenormalize_timezone_preferencenormalizednormalized_namenotenote_datanote_textnotesnotes_entriesnotes_entrynotes_querynotes_resultnotification_servicenotification_statusnownow_tsnullnum_fdsnum_threadsold_counterold_endold_screenshots_on_time_erroroperation_typeor_order_byorg_api_timezoneorg_entityorg_idorg_week_start_dayoriginal_lengthoriginal_sizeosos_nameos_typeos_versionoverlap_queryoverlap_query_after_trimoverlap_resultoverlap_result_after_trimoverlappingoverlapping_detailsoverlapping_details_after_trimoverlapping_intervalsoverlapping_intervals_after_trimparents_parse_fixed_mode_windowparsedparticular_timestamppathpathlibpayloadpayload_from_payload_interval_boundspayload_project_idpayload_task_idpayload_to_pe_pe2perform_comprehensive_log_cleanupperiod_duration_persist_idle_popup_intervals_minimum_activity_pi_pi2pinnedpinned_startplanStatusplatformplatform_namepoppopup_is_activepopup_querypopup_resultpopup_triggered_atposition_of_dollarpostprecise_sleeppreference__prepare__prev_day_unsentprev_intervalpreviousprocessprocess_immediatelyprocess_intervals_bulkprocessed_count_processed_last_min_intervalsprojectIdproject_idproject_id_str_project_switch_in_progress_ps_ps2psutil_push_activity_logpush_activity_logspush_open_session_activity_logq__qualname__queryquery_allquery_by_flagqueue_sizequeue_writeraw_endraw_start""reread_lockreasonreassignrecordrecoverablerecovery_error_refresh_resolving_slot_if_existsregister_sleep_callbackregister_wake_callbackregular_interval_overlapsregular_intervalsregular_intervals_after_trimreload_localzoneremainderremaining_break_intervalsremaining_intervalsremove_after_delayreplacereport_in_backgroundreport_limit_exceededreport_threadrequestsresresolveresolve_screenshot_directoryresolving_policyresponse_responseresponse_datarestart_listenersresultresult_allresult_by_flagretry_delaysreturnrollbackrounded_minuterowrssrstriprunrun_in_executorrun_until_completes3_bucket_update_wakes3_configs3_credentials_expired_s3_credentials_need_refreshs3_dest_paths3_details3_detail_for_uploads3_file_urls3_keys3_logs_paths3_screenshot_paths3_syncs3_upload_links3_urlss_limit_ends_limit_startsave_activity_logsave_app_monitorssave_dirsave_first_activity_logsave_fixed_mode_save_note_to_current_interval_save_note_to_idle_intervalssave_user_orgscalarscalar_one_or_nonescalarsscreenUrlscreen_urlscreenshotscreenshot_controllerscreenshot_ctrlscreenshot_datascreenshot_dirscreenshot_entityscreenshot_folderscreenshot_idsscreenshot_intervalscreenshot_managerscreenshot_namescreenshot_queryscreenshot_servicescreenshotblurstatusscreenshotsscreenshots_to_deletescript_pathsd_tokensecondseconds_seconds_until_datetimeseg_endseg_startsegment_startselectselfselfiVerificationselfi_idsend_send_active_app_update_to_electron_send_file_upload_failure_to_electron_send_file_upload_success_to_electron_send_subscription_expired_popupsend_to_electron_send_to_electron_if_connectedsending_held_intervalssending_intervalssending_unsent_intervalssentserver_controllerserver_servicesession_session_close_locksession_gap_minutessession_gap_threshold_minutessession_gap_threshold_secondssession_startsessionsset_credset_event_loopset_local_timezone__set_name__set_on_time_error_callbackset_project_task_idssetdefaultseven_days_agoshould_pause_api_should_pause_api_callsshould_refreshshould_skip_break_processingshou""ld_skip_counter_bump_dedup_should_start_new_sessionshould_uploadshutilsleepsleep_auto_stopsleep_minutessleep_secondssleep_timestampslotslot_endslot_startsortedsorted_intervalssourcesource_typesplitsplitlinessqlalchemyssss_arrayss_end_timessfrequencystatusstst_sizestartstart_app_monitor_flush_taskstart_datestart_date_secondsstart_date_ystart_device_activity__start_device_activity__start_minute_activity_timerstart_monitoringstart_screenshot_activitystart_secstart_status_activitystart_timestartswithstatstaticmethodstatsstatusstatus_codestatus_controllerstderr_stealth_api_cache_intervalstopstop_dtstop_dt_for_intervalsstop_eventstop_listenersstop_monitoringstop_timerstop_valuestrstrftimestripstrptimesubsub_segmentssubprocesssubscription_expired_subtract_overlapping_intervalssuccesssuccess_countsuffixsumswitch_timesyncsync_activity_immediatelysync_failedsyssystemsystem_cpu_percentsystem_is_responsivesystem_namesystem_unique_idtab_titletable_nametargettarget_datetarget_directorytarget_directory_mactarget_directory_stealthtarget_directorywtarget_interval_idtasktask_done_callbacktask_idtask_id_strtask_looptemp_filetemp_file_pathtempfile__test__textthread_countthreadingthrowtimetimeIntervaltime_difftime_diff_seconds_time_error_typetime_monitortime_since_break_stoptime_since_last_calltime_since_sleeptime_since_waketime_typetimecheck_failedtimecheck_with_rechecktimedeltatimeouttimeout_reachedtimestamptimestamp_dbtimetupletimezone_timezone_checks_enabledtimezone_errortimezone_manager_timezone_mismatchtimezone_mismatchtimezone_preferencetitleto_to_inttodaytodo_idtoltolerance_secondstotal_fill_secondstotal_queue_sizetotal_secondstotal_sleeptracebacktracker_statustrackingtracking_error_tracking_resumed_loggedtracking_scenario_trim_open_partial_at_project_switchtrim_totrimmed_partialtrimmed_partial_used_try_finalize_post_switch_slot_intervaltypingtzlocaltzmainunicodedataunix_format_ss_nameunix_timestampunlinkunsent_intervalsupdate_activity_intervalupdate_intervalupdate_screenshotsup""date_segment_startupdate_tracking_durationupdated_interval_idsupdatesupload_errorupload_fileupload_file_to_hetzner_upload_file_to_s3upperurlurl_resultuserCategoryuserCategoryTitleuser_entity_user_entity_for_wakeuser_iduser_serviceuser_timezonevalvaluevaluesverification_delayverify_attemptverify_error_verify_user_activity_during_periodwait_forwake_detectorwake_statswake_timewake_timestampwarningweeklyweekly_exceededweekly_limitweekly_limit_dataweekly_limit_hourswherewin32guiwindowswindows_idle_gapwindows_sleep_or_restartwinregwithin_secondswork_session_startwork_stopworked_total_hours_todayworked_total_hours_weekworked_total_hours_week_leaving_todaywrite_counterwrite_lockwrite_textws_package.configsws_package.controllers.activity_controllerws_package.controllers.activity_screenshot_mixinws_package.controllers.activity_break_mixinws_package.controllers.activity_idle_mixinws_package.controllers.activity_timezone_mixinws_package.controllers.activity_interval_mixinws_package.controllers.activity_push_mixinws_package.controllers.screenshot_controllerws_package.controllers.server_controllerws_package.controllers.status_controllerws_package.entities.activity_entityws_package.entities.mode_entityws_package.entities.org_entityws_package.entities.s3bucket_entityws_package.entities.screenshot_entityws_package.entities.user_entityws_package.exceptions.custom_exceptionsws_package.log.writerws_package.managersws_package.models.basews_package.monitoring.listeners_windowsws_package.monitoring.listenersws_package.monitoring.time_monitorws_package.monitoring.windowsws_package.repositories.activity_repows_package.repositories.activity_percentage_repows_package.services.activity_percentage_servicews_package.services.activity_servicews_package.services.api_request_servicews_package.services.db_writer_servicews_package.services.mode_servicews_package.services.user_servicews_package.services.weekly_limit_notification_servicews_package.utilsws_package.utils.api_log_policyws_package.utils.br""owser_url_detectorws_package.utils.build_modews_package.utils.db_lock_managerws_package.utils.db_write_queuews_package.utils.desktop_keyws_package.utils.electron_commws_package.utils.error_codesws_package.utils.ipc_serverws_package.utils.logsws_package.utils.s3ws_package.utils.systemws_package.utils.system_wake_detectorws_package.utils.tracker_statusws_package.utils.user_error_categoriesxzoneinfo\320\0040\3200F\300a\360\036\000\t\034\2303\230a\230t\240:\250R\250q\330\010\021\220\024\220Q\330\010\032\230'\240\023\320$6\260b\270\001\330\010\027\220t\2308\2401\240G\320+;\2707\300#\300\\\320QR\330\010\017\210q\320\0040\3200c\320cm\320mn\340\010\026\220l\240\"\240F\320*;\2701\330\010\016\210e\2201\330\014\r\330\014\r\330\014\024\220G\2301\330\014\r\330\014\023\2201\220O\240<\250q\330\014\023\2201\320\024&\240n\260A\330\014\023\2201\220O\240;\250a\330\014\023\2201\320\024&\240k\260\021\320\004(\250\010\3200H\310\001\340\010\026\220d\230!\330\010\014\210N\230,\240b\250\001\330\010\014\320\014%\240X\250Y\260d\270!\330\010\014\320\0146\260a\330\010\014\210N\230(\240)\2504\250r\260\030\270\021\270,\300a\330\010\014\320\014*\250!\330\010\014\320\014+\2501\330\010\032\230'\240\021\240&\320(A\300\021\330\010\013\320\013\033\2307\240!\330\014\033\230>\250\024\250Q\330\010\016\210e\2201\330\014\r\330\014\r\330\014\020\220\001\330\014\r\330\014\020\220\014\230B\230a\340\010\017\210t\2201\320\n0\260\001\260\032\2701\270A\320\n1\260\021\2401\320\0041\260\021\360\014\000\t\025\220H\230D\240\001\240\021\330\010\013\210:\220S\230\001\330\014\030\230\010\240\004\240A\240Q\330\010\022\220(\230$\230a\230q\330\010\013\2108\2203\220a\330\014\026\220h\230d\240!\2401\340\010\030\230\004\320\034.\250a\250q\330\010\026\220d\320\032,\250A\250Q\340\010\013\210>\230\023\230E\240\023\240L\260\003\2601\330\014\022\220(\230!\330\020\021\330\020\021\330\020\021\340\014\023\220<\230q\340\010\017\210\177\230a\320\020#\2401\330\024\027\220t\2304\320\0378\270\001\330\030\036\230e\2401\330\034\035\340\030""\031\340\024\030\320\030,\250K\260s\270!\330\024\027\220t\320\033-\250S\260\001\330\030\034\320\0342\260!\330\030\036\230f\240A\330\034\035\360\006\000\031\037\230h\240a\330\034\035\210\001\340\014\020\320\020\"\240(\250!\2501\330\014\017\210t\2205\230\001\330\020\021\330\024\030\230\007\230q\330\027\036\230a\340\024\032\230&\240\001\240\021\330\020\027\220}\240A\330\024\032\230&\240\001\320!S\320SV\320V_\320_`\210\001\340\014\020\320\020\"\240(\250!\2501\330\014\017\210t\2205\230\001\330\020\021\330\024\030\230\007\230q\330\027\036\230a\330\024\032\230&\240\001\240\021\330\020\027\220}\240A\330\024\032\230&\240\001\320!Y\320Y\\\320\\e\320ef\320\024(\250\001\330\030\033\2302\230S\240\005\240S\250\002\250#\250Q\330\034#\2402\240S\250\001\330\030\031\330\034#\2403\240b\250\002\250\"\250B\250n\270D\300\003\3001\330\037 \330\034#\2401\320\0042\260!\340\010\t\330\014\022\220(\230!\330\020\021\340\020\021\340\010\017\210}\230A\330\014\022\220&\230\001\320\031=\270Q\320\0043\260:\270Q\360\014\000\t\032\230\027\240\001\240\026\320'E\300Q\340\010\026\220h\230g\240Q\330\010\013\210<\220s\230!\330\014\023\320\0231\260\034\270S\320@T\320TU\330\010\013\210<\220s\230!\330\014\023\320\0230\260\014\270C\320?S\320ST\330\010\017\320\017,\250L\270\003\320;O\310q\320\n4\260L\300\001\320\004(\250\001\340\010\013\2104\210~\230S\240\004\240J\250a\250\177\270a\330\014\022\220/\240\021\320\"N\310i\320Wh\320hk\320kl\320lz\320z|\320|}\340\010\t\330\014!\240\035\250e\2601\260A\330\014\017\320\017\"\240$\240a\330\020\026\220o\240Q\320&]\320]f\320fw\360\000\000x\001E\002\360\000\000E\002G\002\360\000\000G\002H\002\340\014\031\230\035\240a\320':\270\"\270A\330\014\017\210t\2201\330\020\026\220o\240Q\320&\\\320\\e\320ev\360\000\000w\001D\002\360\000\000D\002F\002\360\000\000F\002G\002\340\014\031\230\032\2404\240q\330\014\035\230V\240:\250Q\250k\270\027\300\001\330\014\023\2201\340\010\017\210~\230Q\330\014\022\220&\230\001\320\031:\270!\330\014\022\220/\240\021\320\"J\310!\3105\320PY\320Yj\320jw""\320wy\320yz\330\010\017\320\017%\240Q\330\014\022\220&\230\001\320\031C\3001\330\014\022\220/\240\021\320\"I\310\021\310%\310y\320Xi\320iv\320vx\320xy\330\010\017\210}\230A\330\014\022\220&\230\001\320\031?\270q\330\014\022\220/\240\021\320\"E\300Q\300e\3109\320Te\320er\320rt\320tu\320\0046\260k\300\031\310!\340\010\030\230\004\320\034/\250q\330\010\013\2104\210~\230S\240\004\240M\260\035\270a\330\014\023\2201\330\010\017\210}\320\034-\250Q\250i\260q\320\004-\320-=\270]\310!\340\010\013\2107\220!\2206\320\031C\3001\330\014\023\2201\330\010\024\220G\2301\230F\320\";\2701\330\010\013\210:\220S\230\001\330\014\023\2201\330\010\020\220\010\230\t\240\024\240S\250\002\250*\260N\300#\300R\300q\320\n7\260|\300<\320Or\320rs\320\n7\260q\320\n7\260u\270K\300q\320\n7\260y\300\001\320\n8\270\001\320\004#\2408\2501\360\026\000\t\r\320\014\037\230q\330\010\014\320\014B\300!\330\010\014\320\014<\270A\340\010\014\210N\230!\330\010\014\320\014/\250q\360\010\000\t\r\320\014$\240A\340\010\014\320\014 \240\017\250q\330\010\014\320\014\"\320\"3\2601\260A\330\010\014\320\014 \240\017\250q\330\010\014\320\014\034\230K\240q\360\006\000\t\r\320\014\034\230K\240q\330\010\014\320\014!\320!1\260\021\330\010\014\210N\230,\240a\330\010\014\320\014 \240\017\250q\330\010\014\320\014!\320!1\260\021\360\006\000\t\r\320\014\035\230Q\360\006\000\t\r\320\014C\3001\330\010\014\320\0148\270\001\330\010\014\320\0140\260\001\330\010\014\320\014(\250\001\330\010\014\210M\230\023\230A\230T\240\032\2502\250Q\330\010\014\320\014$\240A\330\010\014\320\0141\260\021\340\010\t\330\014\"\240&\250\001\320)J\320J]\320]c\320cd\330\014\017\320\017#\2403\240e\2503\320.B\300#\300Q\330\020&\240a\330\020\034\230K\240q\340\014\"\240!\330\010\014\320\0142\260#\260Q\260a\330\010\014\320\0142\3202F\300b\310\001\330\010\014\320\014'\240v\250Q\320.D\300A\330\010\014\320\014!\240\026\240q\320(8\270\001\330\010\014\320\014#\2401\340\010\014\320\014\035\230Q\330\010\014\210L\230\001\330\010\014\320\014=\270Q\330\010\014\320\014/""\250q\330\010\014\320\014,\250A\330\010\014\320\014D\300A\330\010\014\320\014H\310\001\330\010\014\320\014=\270Q\330\010\014\320\014A\300\021\330\010\014\320\014J\310!\330\010\014\320\0141\260\021\330\010\014\320\014(\250\001\330\010\014\320\014E\300Q\330\010\014\320\014G\300q\330\010\014\320\014'\240q\330\010\014\320\014&\240a\330\010\014\320\014*\250!\330\010\014\320\0140\260\001\330\010\014\320\014*\250!\340\010\014\320\014[\320[\\\360\006\000\t\r\320\0142\260!\330\010\014\320\0147\260q\330\010\014\320\0147\260q\330\010\014\320\014H\310\001\360\010\000\t\r\320\014+\2501\330\010\014\320\0146\260a\360\006\000\t\r\320\014*\250(\260)\2709\300A\300\\\320Q\\\320\\a\320ab\330\010\014\320\014(\250\010\260\t\270\031\300!\300<\310{\320Z_\320_`\330\010\014\320\014%\240Q\240g\250W\260G\2707\300'\310\027\320PQ\360\006\000\t\r\320\014<\270A\330\010\014\320\014:\270!\340\010\014\320\014G\300q\340\010\014\320\014H\310\001\360\006\000\t\032\320\031+\2501\330\010\013\210?\230#\230Q\330\014\020\320\020 \240\001\330\014\020\220\016\230a\330\014\022\220%\220q\230\001\340\014\020\320\020 \240\001\330\014\020\220\016\230a\330\014\022\220%\220q\230\001\360\006\000\t\r\320\014\"\240!\330\010\014\320\014\"\240!\330\010\014\320\014 \240\001\340\010\014\320\014!\240\021\330\010\014\210H\220A\330\010\014\320\014 \240\001\330\010\014\320\014+\2501\340\010\014\320\0142\260!\330\010\014\320\014;\2701\360\006\000\t\r\320\014A\300\021\330\010\014\320\0140\260\001\360\010\000\t\016\320\r,\250A\330\010\034\230F\240!\240<\250~\270S\300\001\330\010\t\330\014\020\220\014\320\0348\270\001\270\021\330\010\020\320\020!\240\034\250Q\330\014\022\220&\230\001\320\031F\300a\330\014\022\220/\240\021\330\020C\3001\300A\330\020\031\230\032\320#6\260i\270s\300!\3001\340\010\017\210}\230A\330\014\022\220&\230\001\320\031O\310q\330\014\022\220/\240\021\330\020L\310A\310Q\330\020\031\230\032\320#6\260i\270s\300!\3001\360\006\000\t\r\210N\230&\240\001\240\036\250~\270S\300\001\330\010\014\210O\2301\330\010\014\320""\014\036\230a\330\010\014\210N\230!\330\010\014\210J\220a\330\010\014\320\014#\2401\330\010\014\210N\230(\240)\2504\250q\340\010\t\330\014\020\320\020%\240R\240w\250a\330\020#\2401\340\014\017\210s\220*\230C\230q\330\020\024\320\024)\250\023\250A\250T\260\025\260c\270\022\2701\340\020\024\320\024)\250\023\250A\250T\260\025\260a\330\010\014\320\014 \240\010\250\005\250V\2608\2707\300#\300S\310\017\320WZ\320Z[\320[_\320_`\330\010\014\210H\220A\330\010\014\210I\220Q\340\010\014\320\0140\260\001\360\006\000\t\r\320\014%\320%9\270\021\330\014\023\2204\220q\330\014\025\220T\230\021\330\014\027\220t\2301\330\014\027\220t\2301\330\014\030\230\004\230A\330\014\033\2304\230q\330\014\027\220t\2301\330\014\037\230t\2401\330\014 \240\004\240A\330\014\025\220T\230\021\330\014\030\230\004\230A\330\014\026\220d\230!\330\014\027\220t\2301\360\010\000\t\r\210K\220v\230X\240Q\330\010\014\320\014\037\230q\330\010\014\320\014%\240Q\330\010\014\320\014\037\230~\250Q\250a\360\006\000\t\r\320\0141\260\021\330\010\014\320\014.\250a\340\010\014\320\014G\300q\330\010\014\320\0141\260\021\330\010\014\320\014#\2409\250F\260!\340\010\014\320\014'\240q\330\010\014\320\014%\240Q\360\n\000\t\n\330\014\034\320\0344\260A\330\014\017\210q\330\020\023\2208\2307\240#\240S\250\001\330\024\032\230%\230q\330\030\031\360\010\000\025\"\320!9\270\021\330\030\031\330\030\034\320\034,\250A\340\024\032\230%\230q\320 L\310H\320T[\320[\\\360\006\000\021\036\320\0354\260A\330\024\025\330\024\030\320\030(\250\001\340\020\026\220e\2301\320\034F\300h\310g\320UV\360\006\000\021\036\320\0354\260A\330\024\025\330\024\030\230\001\340\020\026\220e\2301\320\034W\320W_\320_f\320fg\340\020\035\320\0354\260A\330\024\025\330\024\030\230\001\340\020\026\220e\2301\320\034V\320V^\320^e\320ef\330\010\017\210}\230A\330\014\022\220(\230!\320\033J\310!\320\n8\270\010\300\001\320\n9\270\021\320\0249\270\021\330\030\033\2304\230s\240%\240s\250$\250c\260\021\330\034#\2401\330\030\031\330\034(\250\003\2502\250T\260\022\2604\260~\300Q\330""\034#\240:\250S\260\001\330\037 \330\034#\2401\320\0049\270\035\320F\\\320\\]\340\010\r\320\r3\2601\340\010\023\2207\230!\2306\320!8\270\001\330\010\025\320\0252\260!\2601\330\010\014\320\014#\2401\330\010\013\210<\220w\230a\330\014\027\320\027.\250a\330\010\013\2107\220!\2206\230\037\250\006\250g\260Q\330\014\020\220\014\320\0343\2601\340\010\013\2109\220C\220u\230C\230s\240!\240:\250S\260\003\2601\260A\330\014\r\340\010\016\210e\2201\330\014\r\330\014\r\330\014\r\340\010\027\220w\230a\230w\240a\240v\320-A\300\027\320HX\320XY\330\010\013\2104\210q\330\014\r\330\010\t\330\014\017\210{\230#\230Q\330\020\034\320\034-\250Q\330\020\026\220e\2301\230A\340\020\034\320\034,\250A\330\020\026\220e\2301\230A\330\010\017\210}\230A\330\014\022\220(\230!\320\033O\310q\320\n9\270\025\270k\310\021\320\n=\270_\310A\320\nA\320A_\320_\177\360\000\000@\002A\002\200A\340\010\014\320\014\035\320\0350\260\001\260\021\210!\360\010\000\026\027\330\010\t\340\010\034\230A\330\010\031\230\021\330\010\031\230\021\200A\360\024\000\t\014\2104\210q\330\014\023\2201\340\010\033\2306\240\021\240+\250T\260\021\330\010\023\2201\330\010\032\230!\320\033+\2501\250A\340\010\014\210E\220\025\220a\220s\230#\230Q\230a\330\014\034\320\034,\250A\250R\250r\260\021\330\014\037\320\037/\250q\260\001\340\014\017\210t\320\023-\250Q\250o\270Q\330\020\030\230\007\230q\240\001\330\020\"\240!\2401\340\020\037\230w\240a\240q\340\010\013\2101\330\014\024\220G\2301\230A\340\010\017\210q\320\004,\250A\360\010\000\t\014\2104\210q\330\014\023\2201\340\010\t\330\014\035\230X\240Q\330\014\017\210z\230\021\320\032*\250!\330\020!\240\024\240V\2501\250A\330\014\035\230_\250C\250q\330\014\024\220E\230\021\230.\250\004\250A\250Y\260c\270\023\270A\330\014\027\220u\230A\230^\2504\250q\260\014\270C\270s\300!\330\014\026\220e\2301\230N\250$\250a\250{\270#\270S\300\001\330\014\023\2206\230\023\230D\240\004\240I\250S\260\004\260D\270\010\300\003\3001\330\010\017\210}\230A\330\014\022\220&\230\001\320\031A\300\021\330\014\023\2201\200A""\360\014\000\t\014\2104\210q\330\014\023\2208\2309\240H\250A\250]\270(\300%\300q\340\010\021\220\024\320\025<\270A\270Q\330\010\013\2107\220'\230\021\330\014\023\2201\340\010\013\210<\220s\230$\230k\250\025\250a\360\006\000\r\035\230G\2401\240F\320*H\310\001\330\014\017\210~\230W\240E\250\024\250]\270%\270s\300#\300Q\330\020\027\220t\320\0339\270\021\270!\330\014\023\2204\320\0275\260Q\260d\270!\340\014\023\2208\2309\240H\250A\250]\270(\300%\300q\200A\330$%\340\010\013\2106\220\023\220A\330\014\023\2201\330\010\017\210s\220!\2206\230\026\230q\330\010\013\2104\210q\330\014\023\2201\330\010\014\210G\2201\220L\240\001\330\014\r\330\020\031\230\030\240\031\250)\2601\260F\270$\270e\3001\330\020\027\220v\230Y\240a\240q\330\023\024\330\020\021\330\010\017\210q\210!\340\025\026\330\010\030\230\001\340\010\024\220A\330\010\034\230A\330\010\031\230\021\200A\340\010\034\230K\240q\250\001\340\010\014\210L\230\001\340\014\034\230H\240K\250u\260A\330\014\035\230Q\230n\250G\2601\260A\340\010\017\210q\200A\340\010\032\230+\240Z\250q\260\010\270\001\330\010\027\220r\230\025\230a\230q\330\010\027\220r\230\024\230Q\320\0368\270\004\270A\360\006\000\t\036\230\\\250\026\250q\340\010\023\2201\320\024%\320%8\270\n\320BT\320T]\320]g\320gq\320q|\320|}\340\010#\2401\200A\340\010\017\320\017&\240a\200A\340\010\t\330\010\t\330\010\026\220a\330\t\n\340\0101\260\021\330\010\013\210>\230\027\240\005\240T\250\027\260\001\260\037\300\014\310A\330\014\030\230\r\240Q\330\010\013\2101\330\014\020\220\006\220a\330\020\033\2307\240!\2404\240|\2603\260c\270\021\330\020\023\2209\230H\240C\240v\250Q\330\024\025\330\020\025\220W\230A\230T\240\034\250Q\330\020\023\2203\220g\230U\240%\240z\260\023\260E\270\023\270C\270r\300\021\330\024 \240\001\330\010\013\210:\220S\230\005\230T\240\035\250g\260Q\330\014\030\230\001\330\010\013\210:\220S\230\001\330\014\030\230\010\240\t\250\024\250Q\330\010\014\320\014$\240I\250X\260Q\260l\300!\330\010\017\210t\2201\200A\330(>\270a\340\010\013\2107\220#\220Q\330\014\023\2201""\330\010\023\2206\230\027\240\002\240(\250)\2604\260s\270.\310\001\200A\340\024\025\330\021\022\340\010\036\230a\330\t\n\360\014\000\t\r\320\014\"\240#\240Q\240o\260[\300\007\300z\320QR\330\010\014\320\014\037\230s\240!\240<\250x\260w\270j\310\001\330\010\013\2101\330\014\020\320\020.\250h\260i\270t\3001\330\010\016\210e\2201\330\014\r\330\014\020\220\001\330\014\020\220\001\330\014\020\320\020/\320/I\310\021\200A\360\n\000\t\017\210f\220A\220Q\200A\360\020\000\t\017\210h\220i\230t\2401\330\010\021\220\023\220A\220S\230\n\240!\330\010\024\220G\2302\230Q\330\010\017\210y\230\002\230-\240z\260\023\260G\2701\200A\340\010\t\340\014\032\230$\230h\240l\260!\330\014\030\230\013\2405\250\002\250%\250r\260\021\330\014\035\230T\240\030\250\037\270\001\360\006\000\r\033\230$\230h\240l\260!\360\006\000\r\"\240\026\240|\2601\360\006\000\r\034\2304\230x\240|\2601\360\006\000\r\016\330\020\033\2304\230x\240x\250q\330\024$\240F\250!\330\020\033\2301\340\014\022\220%\220q\330\020\021\330\020\033\320\033+\250=\3208L\310N\320Z[\340\014\020\320\020*\250!\340\014\r\330\020\035\230Q\330\020\"\240!\330\020\037\230q\330\020&\240a\330\020 \240\001\330\020\034\230A\340\010\017\210}\230A\330\014\022\220&\230\001\320\031?\270q\330\014\023\2201\200A\340\010\t\330\014\032\230$\230h\240l\260!\330\014\030\230\013\2405\250\002\250%\250r\260\021\340\014\017\210z\230\022\2304\230q\330\020\026\220h\230a\320\037Y\320Yd\320dh\320hi\330\020\027\220q\340\014\023\2201\330\010\017\210}\230A\330\014\022\220&\230\001\320\031<\270A\330\014\023\2201\320\020$\240A\330\024\027\220r\230\023\230E\240\023\240B\240c\250\021\330\030\037\230r\240\023\240A\330\024\025\330\030\037\230s\240\"\240B\240b\250\002\250.\270\004\270C\270q\330\033\034\330\030\037\230q\200A\360\n\000\t\n\360\006\000\r\020\210t\2207\230!\2306\320!:\270#\270T\320AX\320X[\320[\\\330\020\026\220f\230A\230Q\330\020\021\340\014\032\230$\230a\360\006\000\r\016\340\020\027\220w\230o\250Q\330\020\023\2204\220{\240!\340\024\033\230<\240q\250\004\320,I\310""\021\310!\360\006\000\025\034\2304\230q\240\004\320$A\300\021\300!\330\023\024\340\020\027\220t\2301\230D\320 =\270Q\270a\330\010\017\210}\230A\330\014\022\220&\230\001\320\031O\310s\320R[\320[\\\200A\340\010\017\210t\320\023&\240h\250a\250q\200A\330\010\017\210t\320\023&\240k\260\021\260!\320\nB\300!\320\nB\300%\300z\320QR\320\nD\320Da\320aw\320wx\320\004I\310\021\340\010\013\2104\210~\230S\240\004\240A\330\014\023\2201\330\010\t\330\014\024\320\024$\240L\260\002\260-\270z\310\036\320WX\330\010\017\210}\230A\330\014\022\220&\230\001\320\031J\310!\330\014\023\2201\320\n:\320:J\310-\320WX\320\n,\250L\3208H\310\001\320\nL\310A\320\004L\310A\340\010\013\2104\210q\330\014\023\2201\360\006\000\t\014\320\013\033\2309\240C\240}\260A\330\014\020\320\020*\250!\330\020\021\330\020\021\330\020\021\330\020\024\320\024+\2501\250O\2701\340\014\023\2201\340\010\026\220d\320\0321\260\021\260/\300\021\330\010\013\210<\220r\230\024\230Q\330\014\025\220T\320\0311\260\021\260!\330\014\020\320\020*\250!\2508\260?\320BT\320TU\330\014\023\2201\340\010\017\210q\260Q\320\004%\240Q\360\n\000\t\n\330\014\034\320\0344\260A\330\014\017\210q\330\020\030\230\r\240Z\250q\330\020\"\240%\240t\2501\250A\330\020!\240\025\240d\250!\2501\360\006\000\021\024\2201\340\024\027\220z\240\021\320\"3\2608\2701\330\030*\250/\270\032\3001\340\030*\250!\340\024(\250\004\250E\260\021\330\024'\320'9\270\022\2701\360\n\000\025,\2501\330\024\025\330\030\033\2308\2407\250#\250S\260\001\360\006\000\035\037\230k\250\021\330\0343\2601\330\035%\240W\250C\250s\260!\340\034\035\330'(\330 '\240x\320/C\3001\330 #\2401\330$;\2701\330#$\360\010\000\035\037\230k\250\021\330\0343\2601\330\033\034\360\n\000\025\030\220q\330\030\036\230f\240A\240Q\330\030\037\230q\360\n\000\025\030\320\027(\250\002\250!\330\030\036\230f\240A\320%b\320br\320rs\320st\330\030\037\230q\360\006\000\025\030\220\177\240c\250\021\330\030\037\230q\360\006\000\025\030\220z\240\021\320\"2\260(\270!\330\030)\250\036\260z\300\021\340\030)\250\021\340\024\027""\220\177\240b\250\001\330\030\037\230q\330\014\023\2201\330\010\017\210}\230A\330\014\022\220&\230\001\320\031C\3001\330\014\023\2201\320\004=\270Q\330\010\017\320\017$\320$F\300a\300v\310Q\320\n:\320:R\320RS\320\nR\320RS\320\n?\270~\310U\320R^\320^t\320t}\360\000\000~\001T\002\360\000\000T\002Z\002\360\000\000Z\002p\002\360\000\000p\002{\002\360\000\000{\002|\002\320\n?\320?U\320UV\210!\330\033\034\210!\330\033\034\330\t\n\210!\320\n*\250!\240!\230!\230\001\270\021\210a\240a\230a\270a\320\n.\250a\320\004.\250a\340\010\014\320\0146\260a\330\010\016\210e\2201\330\014\r\320\004.\250a\340\010\024\220D\320\030.\250c\260\030\270\031\300$\300a\330\010\017\210y\230\010\240\001\240\034\250S\260\002\260(\270*\300A\300X\310Q\320no\320\n>\270o\310Q\320pq\320\n;\270<\300q\320\n'\240q\230q\200\001\340\004\t\320\t/\250q\330\004\013\320\013\034\230A\320\004\"\240!\330\010\030\230\010\240\007\240q\330\010\013\210>\230\023\230A\330\020\027\220q\330\010\017\210q\320\004/\250q\340\010\t\330\014\021\320\021?\270q\340\014\036\320\0369\270\021\270!\330\014\031\230\021\330\020\031\230\022\2301\230O\2501\320,?\270q\300\017\310q\320PQ\330\020\033\2301\330\020\036\230i\240t\2501\320,=\270_\310A\330\020\035\230Y\240d\250!\320+;\270?\310!\330\020!\240\031\250$\250a\320/C\300?\320RS\330\020\035\230X\240Y\250d\260\"\260J\270a\330\022\023\340\014\017\210t\320\0232\260!\3203K\3101\330\020\026\220e\2301\320\034R\320RS\330\010\017\210}\230A\330\014\022\220&\230\001\320\031Y\320YZ\320\020/\250q\340\024\027\220t\2303\230e\2403\240d\250#\250Q\330\030\037\230q\330\024\025\330\030$\240C\240r\250\024\250R\250t\260>\300\021\330\030\037\230z\250\023\250A\330\033\034\330\030\037\230q\320\000\021\220\021\360\030\000\005\006\330\010\017\210s\220!\2201\330\014\027\220q\330\010\017\210q\320\n@\320@]\320]s\320st\320\n/\250u\260I\270Q\320vw\220\001\330\024\025\330\030\037\230w\240o\260Q\330\030\037\230\177\250a\250q\330\030\034\320\034/\250q\330\0340\3200F\300a\330 ,\250A\330 +\2501\330 ,\250J\260a\330 3\260:\270Q""\330 9\270\032\3001\330 8\270\n\300!\330 -\250T\260\021\330 *\250$\250a\360\006\000\025\034\230=\250\001\330\030\036\230f\240A\320%S\320ST\340\030\034\230F\240!\320\n>\320>[\320[w\320w\177\360\000\000@\002A\002";
    PyObject *data = NULL;
    CYTHON_UNUSED_VAR(__Pyx_DecompressString);
    #endif
    PyObject **stringtab = __pyx_mstate->__pyx_string_tab;
    Py_ssize_t pos = 0;
    for (int i = 0; i < 2159; i++) {
      Py_ssize_t bytes_length = index[i].length;
      PyObject *string = PyUnicode_DecodeUTF8(bytes + pos, bytes_length, NULL);
      if (likely(string) && i >= 779) PyUnicode_InternInPlace(&string);
      if (unlikely(!string)) {
        Py_XDECREF(data);
        __PYX_ERR(0, 1, __pyx_L1_error)
      }
      stringtab[i] = string;
      pos += bytes_length;
    }
    for (int i = 2159; i < 2257; i++) {
      Py_ssize_t bytes_length = index[i].length;
      PyObject *string = PyBytes_FromStringAndSize(bytes + pos, bytes_length);
      stringtab[i] = string;
      pos += bytes_length;
      if (unlikely(!string)) {
        Py_XDECREF(data);
        __PYX_ERR(0, 1, __pyx_L1_error)
      }
    }
    Py_XDECREF(data);
    for (Py_ssize_t i = 0; i < 2257; i++) {
      if (unlikely(PyObject_Hash(stringtab[i]) == -1)) {
        __PYX_ERR(0, 1, __pyx_L1_error)
      }
    }
    #if CYTHON_IMMORTAL_CONSTANTS
    {
      PyObject **table = stringtab + 2159;
      for (Py_ssize_t i=0; i<98; ++i) {
        #if PY_VERSION_HEX >= 0x030F0000
        PyUnstable_SetImmortal(table[i]);
        #elif CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
        if ((PY_SSIZE_T_MAX <= _Py_IMMORTAL_REFCNT_LOCAL)) break;
        #if PY_VERSION_HEX < 0x030E0000
        if (_Py_IsOwnedByCurrentThread(table[i]) && Py_REFCNT(table[i]) == 1)
        #else
        if (PyUnstable_Object_IsUniquelyReferenced(table[i]))
        #endif
        {
          Py_SET_REFCNT(table[i], ((Py_ssize_t)_Py_IMMORTAL_REFCNT_LOCAL + 1));
        }
        #else
        if ((PY_SSIZE_T_MAX < _Py_IMMORTAL_INITIAL_REFCNT)) break;
        Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT);
        #endif
      }
    }
    #endif
  }
  {
    PyObject **numbertab = __pyx_mstate->__pyx_number_tab;
    double const c_constants[] = {0.0,0.1,0.2,0.3,0.5,1.0,1.5,2.0,3.0,4.0,5.0,6.0,8.0,10.0,60.0,1000000000.0};
    for (int i = 0; i < 16; i++) {
      numbertab[i] = PyFloat_FromDouble(c_constants[i]);
      if (unlikely(!numbertab[i])) __PYX_ERR(0, 1, __pyx_L1_error)
    }
  }
  {
    PyObject **numbertab = __pyx_mstate->__pyx_number_tab + 16;
    int8_t const cint_constants_1[] = {0,-1,1,2,3,5,7,8,10,12,15,23,30,45,50,60,100};
    int16_t const cint_constants_2[] = {180,300,500,600,900,1024,1800,3600,14400};
    for (int i = 0; i < 26; i++) {
      numbertab[i] = PyLong_FromLong((i < 17 ? cint_constants_1[i - 0] : cint_constants_2[i - 17]));
      if (unlikely(!numbertab[i])) __PYX_ERR(0, 1, __pyx_L1_error)
    }
  }
  #if CYTHON_IMMORTAL_CONSTANTS
  {
    PyObject **table = __pyx_mstate->__pyx_number_tab;
    for (Py_ssize_t i=0; i<42; ++i) {
      #if PY_VERSION_HEX >= 0x030F0000
      PyUnstable_SetImmortal(table[i]);
      #elif CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
      if ((PY_SSIZE_T_MAX <= _Py_IMMORTAL_REFCNT_LOCAL)) break;
      #if PY_VERSION_HEX < 0x030E0000
      if (_Py_IsOwnedByCurrentThread(table[i]) && Py_REFCNT(table[i]) == 1)
      #else
      if (PyUnstable_Object_IsUniquelyReferenced(table[i]))
      #endif
      {
        Py_SET_REFCNT(table[i], ((Py_ssize_t)_Py_IMMORTAL_REFCNT_LOCAL + 1));
      }
      #else
      if ((PY_SSIZE_T_MAX < _Py_IMMORTAL_INITIAL_REFCNT)) break;
      Py_SET_REFCNT(table[i], _Py_IMMORTAL_INITIAL_REFCNT);
      #endif
    }
  }
  #endif
  return 0;
  __pyx_L1_error:;
  return -1;
}
/* #### Code section: init_codeobjects ### */
typedef struct {
    unsigned int argcount : 3;
    unsigned int num_posonly_args : 1;
    unsigned int num_kwonly_args : 2;
    unsigned int nlocals : 8;
    unsigned int flags : 10;
    unsigned int first_line : 13;
} __Pyx_PyCode_New_function_description;
/* NewCodeObj.proto */
static PyObject* __Pyx_PyCode_New(
        const __Pyx_PyCode_New_function_description descr,
        PyObject * const *varnames,
        PyObject *filename,
        PyObject *funcname,
        PyObject *line_table,
        PyObject *tuple_dedup_map
);


static int __Pyx_CreateCodeObjects(__pyx_mstatetype *__pyx_mstate) {
  PyObject* tuple_dedup_map = PyDict_New();
  if (unlikely(!tuple_dedup_map)) return -1;
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 9, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 554};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_within_seconds, __pyx_mstate->__pyx_n_u_DB_OPERATION_TIMEOUT, __pyx_mstate->__pyx_n_u_write_counter, __pyx_mstate->__pyx_n_u_cutoff, __pyx_mstate->__pyx_n_u_session, __pyx_mstate->__pyx_n_u_query, __pyx_mstate->__pyx_n_u_result, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[0] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_has_recent_intervals_on_write_co, __pyx_mstate->__pyx_kp_b_iso88591_J_WX, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[0])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 9, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 608};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_switch_time, __pyx_mstate->__pyx_n_u_write_counter, __pyx_mstate->__pyx_n_u_session, __pyx_mstate->__pyx_n_u_query, __pyx_mstate->__pyx_n_u_result, __pyx_mstate->__pyx_n_u_interval, __pyx_mstate->__pyx_n_u_old_end, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[1] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_trim_open_partial_at_project_sw, __pyx_mstate->__pyx_kp_b_iso88591__16, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[1])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 13, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 654};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_session_start, __pyx_mstate->__pyx_n_u_now, __pyx_mstate->__pyx_n_u_interval_minutes, __pyx_mstate->__pyx_n_u_slot_start, __pyx_mstate->__pyx_n_u_slot_end, __pyx_mstate->__pyx_n_u_last_end, __pyx_mstate->__pyx_n_u_interval_start, __pyx_mstate->__pyx_n_u_existing, __pyx_mstate->__pyx_n_u_current_break_id, __pyx_mstate->__pyx_n_u_activity_level, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[2] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_try_finalize_post_switch_slot_i, __pyx_mstate->__pyx_kp_b_iso88591__17, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[2])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 9, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 721};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_segment_start, __pyx_mstate->__pyx_n_u_empty_activity_level, __pyx_mstate->__pyx_n_u_current_break_id, __pyx_mstate->__pyx_n_u_session, __pyx_mstate->__pyx_n_u_query, __pyx_mstate->__pyx_n_u_result, __pyx_mstate->__pyx_n_u_e, __pyx_mstate->__pyx_n_u_processed_count};
    __pyx_mstate_global->__pyx_codeobj_tab[3] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_create_segment_dummy_entry, __pyx_mstate->__pyx_kp_b_iso88591_UUV, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[3])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 5, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 779};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_start_date, __pyx_mstate->__pyx_n_u_end_date, __pyx_mstate->__pyx_n_u_start_date_y, __pyx_mstate->__pyx_n_u_end_date_y};
    __pyx_mstate_global->__pyx_codeobj_tab[4] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_inrange, __pyx_mstate->__pyx_kp_b_iso88591__18, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[4])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 11, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 836};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_should_refresh, __pyx_mstate->__pyx_n_u_current_time, __pyx_mstate->__pyx_n_u_time_since_last_call, __pyx_mstate->__pyx_n_u_response, __pyx_mstate->__pyx_n_u_api_call_made, __pyx_mstate->__pyx_n_u_s_limit_start, __pyx_mstate->__pyx_n_u_s_limit_end, __pyx_mstate->__pyx_n_u_mode_entity, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[5] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_update_tracking_duration, __pyx_mstate->__pyx_kp_b_iso88591_9, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[5])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 9, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 941};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_last_count, __pyx_mstate->__pyx_n_u_DB_OPERATION_TIMEOUT, __pyx_mstate->__pyx_n_u_session, __pyx_mstate->__pyx_n_u_query, __pyx_mstate->__pyx_n_u_result, __pyx_mstate->__pyx_n_u_last_entry, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[6] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_midnight, __pyx_mstate->__pyx_kp_b_iso88591__19, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[6])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 11, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 1035};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_DB_OPERATION_TIMEOUT, __pyx_mstate->__pyx_n_u_session, __pyx_mstate->__pyx_n_u_query, __pyx_mstate->__pyx_n_u_result, __pyx_mstate->__pyx_n_u_last_entry, __pyx_mstate->__pyx_n_u_last_entry_date, __pyx_mstate->__pyx_n_u_e, __pyx_mstate->__pyx_n_u_current_date, __pyx_mstate->__pyx_n_u_credentials_stale};
    __pyx_mstate_global->__pyx_codeobj_tab[7] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_check_and_update_s3_on_startup, __pyx_mstate->__pyx_kp_b_iso88591__18, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[7])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 11, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 1080};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_DB_OPERATION_TIMEOUT, __pyx_mstate->__pyx_n_u_session, __pyx_mstate->__pyx_n_u_query, __pyx_mstate->__pyx_n_u_result, __pyx_mstate->__pyx_n_u_last_entry, __pyx_mstate->__pyx_n_u_last_entry_date, __pyx_mstate->__pyx_n_u_e, __pyx_mstate->__pyx_n_u_current_date, __pyx_mstate->__pyx_n_u_credentials_stale};
    __pyx_mstate_global->__pyx_codeobj_tab[8] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_check_and_update_s3_on_wake, __pyx_mstate->__pyx_kp_b_iso88591__18, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[8])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 1125};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_s3_credentials_expired, __pyx_mstate->__pyx_n_u_existing};
    __pyx_mstate_global->__pyx_codeobj_tab[9] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_s3_credentials_need_refresh, __pyx_mstate->__pyx_kp_b_iso88591_oQ, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[9])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 1134};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_user_entity};
    __pyx_mstate_global->__pyx_codeobj_tab[10] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_ensure_s3_credentials_fresh, __pyx_mstate->__pyx_kp_b_iso88591_A, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[10])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 1138};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_user_entity};
    __pyx_mstate_global->__pyx_codeobj_tab[11] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_get_bucket_in_every_interval, __pyx_mstate->__pyx_kp_b_iso88591_oQ, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[11])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 12, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 1149};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_sd_token, __pyx_mstate->__pyx_n_u_org_id, __pyx_mstate->__pyx_n_u_user_id, __pyx_mstate->__pyx_n_u_payload, __pyx_mstate->__pyx_n_u_loop, __pyx_mstate->__pyx_n_u_response_data, __pyx_mstate->__pyx_n_u_weekly_limit_data, __pyx_mstate->__pyx_n_u_normalize_timezone_preference, __pyx_mstate->__pyx_n_u_org_entity, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[12] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_update_interval, __pyx_mstate->__pyx_kp_b_iso88591_1_2, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[12])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 6, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 1301};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_session, __pyx_mstate->__pyx_n_u_query, __pyx_mstate->__pyx_n_u_result, __pyx_mstate->__pyx_n_u_record, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[13] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_load_org_settings_from_db, __pyx_mstate->__pyx_kp_b_iso88591__18, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[13])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 13, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 1342};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_org_entity, __pyx_mstate->__pyx_n_u_notification_service, __pyx_mstate->__pyx_n_u_limits_check, __pyx_mstate->__pyx_n_u_daily_exceeded, __pyx_mstate->__pyx_n_u_weekly_exceeded, __pyx_mstate->__pyx_n_u_limit_type, __pyx_mstate->__pyx_n_u_report_in_background, __pyx_mstate->__pyx_n_u_report_in_background, __pyx_mstate->__pyx_n_u_report_thread, __pyx_mstate->__pyx_n_u_today, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[14] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_check_and_handle_limits, __pyx_mstate->__pyx_kp_b_iso88591_RRS, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[14])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 1384};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_loop, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[15] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_report_in_background, __pyx_mstate->__pyx_kp_b_iso88591_woQ_aq_q_00Fa_A_1_Ja_3_Q_9_1_8, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[15])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 1466};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_stop_event};
    __pyx_mstate_global->__pyx_codeobj_tab[16] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_start_screenshot_activity, __pyx_mstate->__pyx_kp_b_iso88591_q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[16])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 8, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 1481};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_stop_event, __pyx_mstate->__pyx_n_u_minute_timer_task, __pyx_mstate->__pyx_n_u_current_loop, __pyx_mstate->__pyx_n_u_task, __pyx_mstate->__pyx_n_u_task_loop, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[17] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_start_device_activity, __pyx_mstate->__pyx_kp_b_iso88591_7_Orrs, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[17])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 7, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 1554};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_last_minute, __pyx_mstate->__pyx_n_u_start_time, __pyx_mstate->__pyx_n_u_minute, __pyx_mstate->__pyx_n_u_end_time, __pyx_mstate->__pyx_n_u_hr, __pyx_mstate->__pyx_n_u_next_day};
    __pyx_mstate_global->__pyx_codeobj_tab[18] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_getStartingSlot, __pyx_mstate->__pyx_kp_b_iso88591_q_2, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[18])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 5, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 1592};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_start_date, __pyx_mstate->__pyx_n_u_minute, __pyx_mstate->__pyx_n_u_rounded_minute, __pyx_mstate->__pyx_n_u_end_date};
    __pyx_mstate_global->__pyx_codeobj_tab[19] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_getCurrentSlot, __pyx_mstate->__pyx_kp_b_iso88591__18, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[19])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_GENERATOR), 1628};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_c_2};
    __pyx_mstate_global->__pyx_codeobj_tab[20] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_genexpr, __pyx_mstate->__pyx_kp_b_iso88591_q_3, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[20])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_GENERATOR), 1636};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_browser};
    __pyx_mstate_global->__pyx_codeobj_tab[21] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_genexpr, __pyx_mstate->__pyx_kp_b_iso88591_1_3, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[21])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 6, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 1638};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_stop_event, __pyx_mstate->__pyx_n_u_current_break_id, __pyx_mstate->__pyx_n_u_minute_activity_level, __pyx_mstate->__pyx_n_u__7, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[22] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_start_minute_activity_timer, __pyx_mstate->__pyx_kp_b_iso88591__18, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[22])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 146, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 1686};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_stop_event, __pyx_mstate->__pyx_n_u_e, __pyx_mstate->__pyx_n_u_on_time_error, __pyx_mstate->__pyx_n_u_on_time_error, __pyx_mstate->__pyx_n_u_work_session_start, __pyx_mstate->__pyx_n_u_enable_hourly_log_upload, __pyx_mstate->__pyx_n_u_app_listener, __pyx_mstate->__pyx_n_u_last_app_monitor_time, __pyx_mstate->__pyx_n_u_monitor_active_apps, __pyx_mstate->__pyx_n_u_monitor_active_apps, __pyx_mstate->__pyx_n_u_monitor_task, __pyx_mstate->__pyx_n_u_task_done_callback, __pyx_mstate->__pyx_n_u_task_done_callback, __pyx_mstate->__pyx_n_u_monitor_active_app_for_ui, __pyx_mstate->__pyx_n_u_monitor_active_app_for_ui, __pyx_mstate->__pyx_n_u_active_app_ui_task, __pyx_mstate->__pyx_n_u_active_app_ui_task_done_callback, __pyx_mstate->__pyx_n_u_active_app_ui_task_done_callback, __pyx_mstate->__pyx_n_u_empty_activity_level, __pyx_mstate->__pyx_n_u_current_break_id, __pyx_mstate->__pyx_n_u_session, __pyx_mstate->__pyx_n_u_query, __pyx_mstate->__pyx_n_u_result, __pyx_mstate->__pyx_n_u_existing_dummy, __pyx_mstate->__pyx_n_u_first_entry, __pyx_mstate->__pyx_n_u_processed_count, __pyx_mstate->__pyx_n_u_stop_listeners, __pyx_mstate->__pyx_n_u_mouse_active, __pyx_mstate->__pyx_n_u_keyboard_active, __pyx_mstate->__pyx_n_u_mouse_verified, __pyx_mstate->__pyx_n_u_keyboard_verified, __pyx_mstate->__pyx_n_u_fallback_error, __pyx_mstate->__pyx_n_u_ErrorCode, __pyx_mstate->__pyx_n_u_script_path, __pyx_mstate->__pyx_n_u_target_directory, __pyx_mstate->__pyx_n_u_target_directory_stealth, __pyx_mstate->__pyx_n_u_start_date, __pyx_mstate->__pyx_n_u_end_date, __pyx_mstate->__pyx_n_u_current_break_id_slot, __pyx_mstate->__pyx_n_u_trim_to, __pyx_mstate->__pyx_n_u_last_end, __pyx_mstate->__pyx_n_u_session_start, __pyx_mstate->__pyx_n_u_break_stop_time_attr, __pyx_mstate->__pyx_n_u_apply_desktop_key, __pyx_mstate->__pyx_n_u_url, __pyx_mstate->__pyx_n_u_headers, __pyx_mstate->__pyx_n_u_timecheck_failed, __pyx_mstate->__pyx_n_u_active_app_url, __pyx_mstate->__pyx_n_u_payload, __pyx_mstate->__pyx_n_u_response, __pyx_mstate->__pyx_n_u_error_data, __pyx_mstate->__pyx_n_u_activity_percentage_start, __pyx_mstate->__pyx_n_u_activity_percentage_end, __pyx_mstate->__pyx_n_u_activity_percentage_start_second, __pyx_mstate->__pyx_n_u_activity_percentage_end_seconds, __pyx_mstate->__pyx_n_u_activity_percentage_key, __pyx_mstate->__pyx_n_u_existing_record, __pyx_mstate->__pyx_n_u_latest_record, __pyx_mstate->__pyx_n_u_is_first_entry, __pyx_mstate->__pyx_n_u_initial_mouse, __pyx_mstate->__pyx_n_u_initial_average, __pyx_mstate->__pyx_n_u_activity_percentage_entity, __pyx_mstate->__pyx_n_u_enqueued, __pyx_mstate->__pyx_n_u_first_entry_note, __pyx_mstate->__pyx_n_u_remove_after_delay, __pyx_mstate->__pyx_n_u_remove_after_delay, __pyx_mstate->__pyx_n_u_today, __pyx_mstate->__pyx_n_u_slot_end, __pyx_mstate->__pyx_n_u_sleep_seconds, __pyx_mstate->__pyx_n_u_total_sleep, __pyx_mstate->__pyx_n_u_chunk_duration, __pyx_mstate->__pyx_n_u_chunks, __pyx_mstate->__pyx_n_u__7, __pyx_mstate->__pyx_n_u_activityLevel, __pyx_mstate->__pyx_n_u_in_range, __pyx_mstate->__pyx_n_u_has_any_activity, __pyx_mstate->__pyx_n_u_keyboard_activity, __pyx_mstate->__pyx_n_u_mouse_activity, __pyx_mstate->__pyx_n_u_average_activity, __pyx_mstate->__pyx_n_u_activity_error, __pyx_mstate->__pyx_n_u_break_start_time, __pyx_mstate->__pyx_n_u_is_break_interval, __pyx_mstate->__pyx_n_u_effective_start, __pyx_mstate->__pyx_n_u_effective_end, __pyx_mstate->__pyx_n_u_start_date_seconds, __pyx_mstate->__pyx_n_u_end_date_seconds, __pyx_mstate->__pyx_n_u_interval_key, __pyx_mstate->__pyx_n_u_existing_interval_in_db, __pyx_mstate->__pyx_n_u_popup_is_active, __pyx_mstate->__pyx_n_u_has_zero_activity, __pyx_mstate->__pyx_n_u_is_idle, __pyx_mstate->__pyx_n_u_flush_error, __pyx_mstate->__pyx_n_u_check_idle_after_delay, __pyx_mstate->__pyx_n_u_check_idle_after_delay, __pyx_mstate->__pyx_n_u_remove_after_delay, __pyx_mstate->__pyx_n_u_remove_after_delay, __pyx_mstate->__pyx_n_u_interval_exists, __pyx_mstate->__pyx_n_u_break_interval_overlaps, __pyx_mstate->__pyx_n_u_regular_interval_overlaps, __pyx_mstate->__pyx_n_u_dwq, __pyx_mstate->__pyx_n_u_WOT, __pyx_mstate->__pyx_n_u_pi, __pyx_mstate->__pyx_n_u_d, __pyx_mstate->__pyx_n_u_ps, __pyx_mstate->__pyx_n_u_pe, __pyx_mstate->__pyx_n_u_check_query, __pyx_mstate->__pyx_n_u_existing, __pyx_mstate->__pyx_n_u_overlap_query, __pyx_mstate->__pyx_n_u_overlap_result, __pyx_mstate->__pyx_n_u_overlapping_intervals, __pyx_mstate->__pyx_n_u_break_intervals, __pyx_mstate->__pyx_n_u_regular_intervals, __pyx_mstate->__pyx_n_u_overlapping_details, __pyx_mstate->__pyx_n_u_break_stop_attr, __pyx_mstate->__pyx_n_u_dwq2, __pyx_mstate->__pyx_n_u_WOT2, __pyx_mstate->__pyx_n_u_pi2, __pyx_mstate->__pyx_n_u_d2, __pyx_mstate->__pyx_n_u_ps2, __pyx_mstate->__pyx_n_u_pe2, __pyx_mstate->__pyx_n_u_overlap_query_after_trim, __pyx_mstate->__pyx_n_u_overlap_result_after_trim, __pyx_mstate->__pyx_n_u_overlapping_intervals_after_trim, __pyx_mstate->__pyx_n_u_break_intervals_after_trim, __pyx_mstate->__pyx_n_u_regular_intervals_after_trim, __pyx_mstate->__pyx_n_u_overlapping_details_after_trim, __pyx_mstate->__pyx_n_u_resolving_policy, __pyx_mstate->__pyx_n_u_remove_after_delay, __pyx_mstate->__pyx_n_u_remove_after_delay, __pyx_mstate->__pyx_n_u_check_idle_after_delay, __pyx_mstate->__pyx_n_u_now, __pyx_mstate->__pyx_n_u_queue_size, __pyx_mstate->__pyx_n_u_start_sec, __pyx_mstate->__pyx_n_u_end_sec, __pyx_mstate->__pyx_n_u_minimal_activity, __pyx_mstate->__pyx_n_u_recovery_error, __pyx_mstate->__pyx_n_u_iv, __pyx_mstate->__pyx_n_u_iv, __pyx_mstate->__pyx_n_u_iv, __pyx_mstate->__pyx_n_u_iv, __pyx_mstate->__pyx_n_u_iv, __pyx_mstate->__pyx_n_u_iv, __pyx_mstate->__pyx_n_u_iv, __pyx_mstate->__pyx_n_u_iv};
    __pyx_mstate_global->__pyx_codeobj_tab[23] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_start_device_activity_2, __pyx_mstate->__pyx_kp_b_iso88591_8, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[23])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 9, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 1810};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_active_app_url, __pyx_mstate->__pyx_n_u_app_name, __pyx_mstate->__pyx_n_u_url, __pyx_mstate->__pyx_n_u_url_result, __pyx_mstate->__pyx_n_u_row, __pyx_mstate->__pyx_n_u_i2t, __pyx_mstate->__pyx_n_u_display_name, __pyx_mstate->__pyx_n_u_detected_app, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[24] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_monitor_active_apps, __pyx_mstate->__pyx_kp_b_iso88591_a_2, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[24])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 6, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 1976};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_active_windows, __pyx_mstate->__pyx_n_u_current_app_data, __pyx_mstate->__pyx_n_u_current_app_name, __pyx_mstate->__pyx_n_u_current_app_path, __pyx_mstate->__pyx_n_u_app_icon, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[25] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_monitor_active_app_for_ui, __pyx_mstate->__pyx_kp_b_iso88591_a_2, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[25])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 0, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 2454};
    PyObject* const varnames[] = {0};
    __pyx_mstate_global->__pyx_codeobj_tab[26] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_remove_after_delay, __pyx_mstate->__pyx_kp_b_iso88591_a_3, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[26])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 0, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 2644};
    PyObject* const varnames[] = {0};
    __pyx_mstate_global->__pyx_codeobj_tab[27] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_check_idle_after_delay, __pyx_mstate->__pyx_kp_b_iso88591_a_4, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[27])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 0, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 2655};
    PyObject* const varnames[] = {0};
    __pyx_mstate_global->__pyx_codeobj_tab[28] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_remove_after_delay, __pyx_mstate->__pyx_kp_b_iso88591_a_4, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[28])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 0, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 2655};
    PyObject* const varnames[] = {0};
    __pyx_mstate_global->__pyx_codeobj_tab[29] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_remove_after_delay, __pyx_mstate->__pyx_kp_b_iso88591_a_4, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[29])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 0, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 2849};
    PyObject* const varnames[] = {0};
    __pyx_mstate_global->__pyx_codeobj_tab[30] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_remove_after_delay, __pyx_mstate->__pyx_kp_b_iso88591__20, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[30])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 0, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 2849};
    PyObject* const varnames[] = {0};
    __pyx_mstate_global->__pyx_codeobj_tab[31] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_remove_after_delay, __pyx_mstate->__pyx_kp_b_iso88591__20, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[31])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 0, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 2897};
    PyObject* const varnames[] = {0};
    __pyx_mstate_global->__pyx_codeobj_tab[32] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_check_idle_after_delay, __pyx_mstate->__pyx_kp_b_iso88591__21, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[32])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 1727};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_error_type};
    __pyx_mstate_global->__pyx_codeobj_tab[33] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_on_time_error, __pyx_mstate->__pyx_kp_b_iso88591_1_t4_8_e1_Ks_t_S_2_fA_ha, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[33])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 1961};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_task, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[34] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_task_done_callback, __pyx_mstate->__pyx_kp_b_iso88591_1_t5_q_a_A_SSVV, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[34])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 2029};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_task, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[35] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_active_app_ui_task_done_callback, __pyx_mstate->__pyx_kp_b_iso88591_1_t5_q_a_A_YY_eef, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[35])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_GENERATOR), 2997};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_s_2, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[36] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_genexpr, __pyx_mstate->__pyx_kp_b_iso88591_a_5, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[36])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 21, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 2969};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_current, __pyx_mstate->__pyx_n_u_missing_intervals, __pyx_mstate->__pyx_n_u_gap_start, __pyx_mstate->__pyx_n_u_gap_end, __pyx_mstate->__pyx_n_u_overlapping, __pyx_mstate->__pyx_n_u_sub_segments, __pyx_mstate->__pyx_n_u_gap_seconds, __pyx_mstate->__pyx_n_u_total_fill_seconds, __pyx_mstate->__pyx_n_u_seg_start, __pyx_mstate->__pyx_n_u_seg_end, __pyx_mstate->__pyx_n_u_break_id, __pyx_mstate->__pyx_n_u_gap_level, __pyx_mstate->__pyx_n_u_sleep_minutes, __pyx_mstate->__pyx_n_u_sent, __pyx_mstate->__pyx_n_u_e, __pyx_mstate->__pyx_n_u_start_time, __pyx_mstate->__pyx_n_u_interval_end_time, __pyx_mstate->__pyx_n_u_genexpr, __pyx_mstate->__pyx_n_u_genexpr};
    __pyx_mstate_global->__pyx_codeobj_tab[37] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_empty_interval, __pyx_mstate->__pyx_kp_b_iso88591_0_2, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[37])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 48, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 3086};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_stop_event, __pyx_mstate->__pyx_n_u_current_break_id, __pyx_mstate->__pyx_n_u_active_app_url, __pyx_mstate->__pyx_n_u_url, __pyx_mstate->__pyx_n_u_headers, __pyx_mstate->__pyx_n_u_apply_desktop_key, __pyx_mstate->__pyx_n_u_payload, __pyx_mstate->__pyx_n_u_response, __pyx_mstate->__pyx_n_u_e, __pyx_mstate->__pyx_n_u_error_data, __pyx_mstate->__pyx_n_u_prev_day_unsent, __pyx_mstate->__pyx_n_u_start, __pyx_mstate->__pyx_n_u_sd_token, __pyx_mstate->__pyx_n_u_org_id, __pyx_mstate->__pyx_n_u_user_id, __pyx_mstate->__pyx_n_u_appVersion, __pyx_mstate->__pyx_n_u_current_session_counter, __pyx_mstate->__pyx_n_u_intervals, __pyx_mstate->__pyx_n_u_timeout_reached, __pyx_mstate->__pyx_n_u_should_pause_api, __pyx_mstate->__pyx_n_u_idle_popup_blocking, __pyx_mstate->__pyx_n_u_force_upload_after_pause_cap, __pyx_mstate->__pyx_n_u_current_counter, __pyx_mstate->__pyx_n_u_current_counter_held, __pyx_mstate->__pyx_n_u_held_intervals, __pyx_mstate->__pyx_n_u_sending_held_intervals, __pyx_mstate->__pyx_n_u_held_sent_count, __pyx_mstate->__pyx_n_u_response_2, __pyx_mstate->__pyx_n_u_held_interval_ids, __pyx_mstate->__pyx_n_u_filtered_intervals, __pyx_mstate->__pyx_n_u_excluded, __pyx_mstate->__pyx_n_u_sending_intervals, __pyx_mstate->__pyx_n_u_sync_failed, __pyx_mstate->__pyx_n_u_wake_detector, __pyx_mstate->__pyx_n_u_wake_stats, __pyx_mstate->__pyx_n_u_last_wake_time, __pyx_mstate->__pyx_n_u_time_since_wake, __pyx_mstate->__pyx_n_u_os_type, __pyx_mstate->__pyx_n_u_interval, __pyx_mstate->__pyx_n_u_interval_payload, __pyx_mstate->__pyx_n_u_screen_url, __pyx_mstate->__pyx_n_u_ErrorCode, __pyx_mstate->__pyx_n_u_iv, __pyx_mstate->__pyx_n_u_iv, __pyx_mstate->__pyx_n_u_held, __pyx_mstate->__pyx_n_u_iv};
    __pyx_mstate_global->__pyx_codeobj_tab[38] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_push_activity_log, __pyx_mstate->__pyx_kp_b_iso88591_4L, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[38])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {4, 0, 0, 17, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 3414};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_interval_start_time, __pyx_mstate->__pyx_n_u_interval_end_time, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_ss_array, __pyx_mstate->__pyx_n_u_ans_array, __pyx_mstate->__pyx_n_u_ss, __pyx_mstate->__pyx_n_u_task, __pyx_mstate->__pyx_n_u_response, __pyx_mstate->__pyx_n_u_s3_upload_link, __pyx_mstate->__pyx_n_u_screenshot_dir, __pyx_mstate->__pyx_n_u_screenshot_name, __pyx_mstate->__pyx_n_u_del_e, __pyx_mstate->__pyx_n_u_e, __pyx_mstate->__pyx_n_u_error_message, __pyx_mstate->__pyx_n_u_particular_timestamp, __pyx_mstate->__pyx_n_u_screenshot_entity};
    __pyx_mstate_global->__pyx_codeobj_tab[39] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_ss, __pyx_mstate->__pyx_kp_b_iso88591_LA, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[39])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 14, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 3606};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_start_time, __pyx_mstate->__pyx_n_u_end_time, __pyx_mstate->__pyx_n_u_ioreg_output, __pyx_mstate->__pyx_n_u_line, __pyx_mstate->__pyx_n_u_idle_time_ns, __pyx_mstate->__pyx_n_u_idle_time_seconds, __pyx_mstate->__pyx_n_u_current_time, __pyx_mstate->__pyx_n_u_period_duration, __pyx_mstate->__pyx_n_u_e, __pyx_mstate->__pyx_n_u_session, __pyx_mstate->__pyx_n_u_query, __pyx_mstate->__pyx_n_u_result, __pyx_mstate->__pyx_n_u_app_data};
    __pyx_mstate_global->__pyx_codeobj_tab[40] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_verify_user_activity_during_per, __pyx_mstate->__pyx_kp_b_iso88591_DDaawwx, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[40])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 3724};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_x};
    __pyx_mstate_global->__pyx_codeobj_tab[41] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_lambda, __pyx_mstate->__pyx_kp_b_iso88591_1A, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[41])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 3769};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_start_time, __pyx_mstate->__pyx_n_u_end_time};
    __pyx_mstate_global->__pyx_codeobj_tab[42] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_get_activity_level_from_db, __pyx_mstate->__pyx_kp_b_iso88591__18, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[42])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 3772};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_app_monitor_time, __pyx_mstate->__pyx_n_u_wake_time, __pyx_mstate->__pyx_n_u_time_diff};
    __pyx_mstate_global->__pyx_codeobj_tab[43] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_is_app_monitor_data_stale, __pyx_mstate->__pyx_kp_b_iso88591_AA___A, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[43])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {4, 0, 0, 12, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 3790};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_start_time, __pyx_mstate->__pyx_n_u_end_time, __pyx_mstate->__pyx_n_u_counter, __pyx_mstate->__pyx_n_u_result, __pyx_mstate->__pyx_n_u_keyboard_activity, __pyx_mstate->__pyx_n_u_mouse_activity, __pyx_mstate->__pyx_n_u_average_activity, __pyx_mstate->__pyx_n_u_session, __pyx_mstate->__pyx_n_u_query, __pyx_mstate->__pyx_n_u_app_data, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[44] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_has_any_activity_in_interval, __pyx_mstate->__pyx_kp_b_iso88591_ww_A, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[44])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_GENERATOR), 4076};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_iv};
    __pyx_mstate_global->__pyx_codeobj_tab[45] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_genexpr, __pyx_mstate->__pyx_kp_b_iso88591__22, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[45])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {5, 0, 3, 56, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_ASYNC_GENERATOR), 3836};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_intervals, __pyx_mstate->__pyx_n_u_org_id, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_last_interval, __pyx_mstate->__pyx_n_u_payload_project_id, __pyx_mstate->__pyx_n_u_payload_task_id, __pyx_mstate->__pyx_n_u_force_stop_time, __pyx_mstate->__pyx_n_u_grouped_intervals, __pyx_mstate->__pyx_n_u_target_date, __pyx_mstate->__pyx_n_u_day_intervals, __pyx_mstate->__pyx_n_u_day_start_time, __pyx_mstate->__pyx_n_u_effective_start_time, __pyx_mstate->__pyx_n_u_pinned_start, __pyx_mstate->__pyx_n_u_filtered_intervals, __pyx_mstate->__pyx_n_u_filtered_count, __pyx_mstate->__pyx_n_u_interval, __pyx_mstate->__pyx_n_u_interval_payloads, __pyx_mstate->__pyx_n_u_interval_ids, __pyx_mstate->__pyx_n_u_interval_note_map, __pyx_mstate->__pyx_n_u_interval_file_map, __pyx_mstate->__pyx_n_u_session, __pyx_mstate->__pyx_n_u_notes_query, __pyx_mstate->__pyx_n_u_notes_result, __pyx_mstate->__pyx_n_u_notes_entries, __pyx_mstate->__pyx_n_u_notes_entry, __pyx_mstate->__pyx_n_u_interval_id, __pyx_mstate->__pyx_n_u_e, __pyx_mstate->__pyx_n_u_file_path, __pyx_mstate->__pyx_n_u_idle_note_url, __pyx_mstate->__pyx_n_u_ss_end_time, __pyx_mstate->__pyx_n_u_dt_match, __pyx_mstate->__pyx_n_u_dt_match, __pyx_mstate->__pyx_n_u_last_match, __pyx_mstate->__pyx_n_u_payload_from, __pyx_mstate->__pyx_n_u_payload_to, __pyx_mstate->__pyx_n_u_align_stop, __pyx_mstate->__pyx_n_u_interval_payload, __pyx_mstate->__pyx_n_u_project_id, __pyx_mstate->__pyx_n_u_task_id, __pyx_mstate->__pyx_n_u_stop_value, __pyx_mstate->__pyx_n_u_stop_dt_for_intervals, __pyx_mstate->__pyx_n_u_dt_match, __pyx_mstate->__pyx_n_u_is_sleep_interval, __pyx_mstate->__pyx_n_u_gap_seconds, __pyx_mstate->__pyx_n_u_activity_level, __pyx_mstate->__pyx_n_u_keyboard, __pyx_mstate->__pyx_n_u_mouse, __pyx_mstate->__pyx_n_u_average, __pyx_mstate->__pyx_n_u_e2, __pyx_mstate->__pyx_n_u_last_in_this_day, __pyx_mstate->__pyx_n_u_stop_dt, __pyx_mstate->__pyx_n_u_payload, __pyx_mstate->__pyx_n_u_interval, __pyx_mstate->__pyx_n_u_genexpr, __pyx_mstate->__pyx_n_u_genexpr};
    __pyx_mstate_global->__pyx_codeobj_tab[46] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_process_intervals_bulk, __pyx_mstate->__pyx_kp_b_iso88591_A_2, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[46])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 3941};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_a, __pyx_mstate->__pyx_n_u_b, __pyx_mstate->__pyx_n_u_tol};
    __pyx_mstate_global->__pyx_codeobj_tab[47] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_dt_match, __pyx_mstate->__pyx_kp_b_iso88591_2S_S_Q_2S_3b_BnD_1_1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[47])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 4033};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_a, __pyx_mstate->__pyx_n_u_b, __pyx_mstate->__pyx_n_u_tol};
    __pyx_mstate_global->__pyx_codeobj_tab[48] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_dt_match, __pyx_mstate->__pyx_kp_b_iso88591_A_r_E_Bc_r_A_s_Bb_Cq_q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[48])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 21, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 4132};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_DB_OPERATION_TIMEOUT, __pyx_mstate->__pyx_n_u_script_path, __pyx_mstate->__pyx_n_u_target_directory, __pyx_mstate->__pyx_n_u_target_directory_stealth, __pyx_mstate->__pyx_n_u_target_directoryw, __pyx_mstate->__pyx_n_u_target_directory_mac, __pyx_mstate->__pyx_n_u_seven_days_ago, __pyx_mstate->__pyx_n_u_screenshots_to_delete, __pyx_mstate->__pyx_n_u_session, __pyx_mstate->__pyx_n_u_screenshot_query, __pyx_mstate->__pyx_n_u_result, __pyx_mstate->__pyx_n_u_old_screenshots, __pyx_mstate->__pyx_n_u_screenshot, __pyx_mstate->__pyx_n_u_e, __pyx_mstate->__pyx_n_u_idx, __pyx_mstate->__pyx_n_u_screenshot_data, __pyx_mstate->__pyx_n_u_file_location, __pyx_mstate->__pyx_n_u_file_name, __pyx_mstate->__pyx_n_u_screenshot_ids, __pyx_mstate->__pyx_n_u_s_2};
    __pyx_mstate_global->__pyx_codeobj_tab[49] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_delete_old_data_and_screenshots, __pyx_mstate->__pyx_kp_b_iso88591__18, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[49])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 16, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 4291};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_stop_event, __pyx_mstate->__pyx_n_u_e, __pyx_mstate->__pyx_n_u_total_sleep, __pyx_mstate->__pyx_n_u_chunk_duration, __pyx_mstate->__pyx_n_u_chunks, __pyx_mstate->__pyx_n_u__7, __pyx_mstate->__pyx_n_u_perform_comprehensive_log_cleanu, __pyx_mstate->__pyx_n_u_cleanup_enabled, __pyx_mstate->__pyx_n_u_mac_log, __pyx_mstate->__pyx_n_u_timestamp, __pyx_mstate->__pyx_n_u_s3_key, __pyx_mstate->__pyx_n_u_task, __pyx_mstate->__pyx_n_u_logs_path, __pyx_mstate->__pyx_n_u_ErrorCode};
    __pyx_mstate_global->__pyx_codeobj_tab[50] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_start_status_activity, __pyx_mstate->__pyx_kp_b_iso88591_7q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[50])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 17, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 4400};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_script_path, __pyx_mstate->__pyx_n_u_target_directory, __pyx_mstate->__pyx_n_u_database_dir, __pyx_mstate->__pyx_n_u_timestamp_db, __pyx_mstate->__pyx_n_u_dt_obj, __pyx_mstate->__pyx_n_u_unix_timestamp, __pyx_mstate->__pyx_n_u_database_server, __pyx_mstate->__pyx_n_u_temp_file, __pyx_mstate->__pyx_n_u_temp_file_path, __pyx_mstate->__pyx_n_u_original_size, __pyx_mstate->__pyx_n_u_copy_size, __pyx_mstate->__pyx_n_u_copy_error, __pyx_mstate->__pyx_n_u_result, __pyx_mstate->__pyx_n_u_e, __pyx_mstate->__pyx_n_u_upload_error};
    __pyx_mstate_global->__pyx_codeobj_tab[51] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_db_to_server, __pyx_mstate->__pyx_kp_b_iso88591_a_6, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[51])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 13, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 4512};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_DB_OPERATION_TIMEOUT, __pyx_mstate->__pyx_n_u_today, __pyx_mstate->__pyx_n_u_current_counter, __pyx_mstate->__pyx_n_u_session, __pyx_mstate->__pyx_n_u_first_entry, __pyx_mstate->__pyx_n_u_first_date, __pyx_mstate->__pyx_n_u_first_entry_counter, __pyx_mstate->__pyx_n_u_query, __pyx_mstate->__pyx_n_u_result, __pyx_mstate->__pyx_n_u_intervals, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[52] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_getting_unsent_interval, __pyx_mstate->__pyx_kp_b_iso88591_9, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[52])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {4, 0, 0, 18, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 4608};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_start, __pyx_mstate->__pyx_n_u_prev_day_unsent, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_payload, __pyx_mstate->__pyx_n_u_interval, __pyx_mstate->__pyx_n_u_interval_id, __pyx_mstate->__pyx_n_u_interval_payload, __pyx_mstate->__pyx_n_u_project_id, __pyx_mstate->__pyx_n_u_task_id, __pyx_mstate->__pyx_n_u_final_payload, __pyx_mstate->__pyx_n_u_sd_token, __pyx_mstate->__pyx_n_u_org_id, __pyx_mstate->__pyx_n_u_user_id, __pyx_mstate->__pyx_n_u_response, __pyx_mstate->__pyx_n_u_response_2, __pyx_mstate->__pyx_n_u_screen_url, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[53] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_sending_unsent_intervals, __pyx_mstate->__pyx_kp_b_iso88591_RRS_2, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[53])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 3, 6, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 4831};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_keep_idle_time, __pyx_mstate->__pyx_n_u_close_time, __pyx_mstate->__pyx_n_u_payload_project_id, __pyx_mstate->__pyx_n_u_payload_task_id};
    __pyx_mstate_global->__pyx_codeobj_tab[54] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_last_api_call, __pyx_mstate->__pyx_kp_b_iso88591_A_A, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[54])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_GENERATOR), 5173};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_interval};
    __pyx_mstate_global->__pyx_codeobj_tab[55] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_genexpr, __pyx_mstate->__pyx_kp_b_iso88591_no, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[55])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_GENERATOR), 5258};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_interval};
    __pyx_mstate_global->__pyx_codeobj_tab[56] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_genexpr, __pyx_mstate->__pyx_kp_b_iso88591_vw, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[56])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_GENERATOR), 5299};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_interval};
    __pyx_mstate_global->__pyx_codeobj_tab[57] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_genexpr, __pyx_mstate->__pyx_kp_b_iso88591_pq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[57])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_GENERATOR), 5472};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_interval};
    __pyx_mstate_global->__pyx_codeobj_tab[58] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_genexpr, __pyx_mstate->__pyx_kp_b_iso88591_Q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[58])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 3, 86, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 4850};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_keep_idle_time, __pyx_mstate->__pyx_n_u_close_time, __pyx_mstate->__pyx_n_u_payload_project_id, __pyx_mstate->__pyx_n_u_payload_task_id, __pyx_mstate->__pyx_n_u_trimmed_partial, __pyx_mstate->__pyx_n_u_current_session_counter_for_last, __pyx_mstate->__pyx_n_u_last_interval_end, __pyx_mstate->__pyx_n_u_is_sleep_interval, __pyx_mstate->__pyx_n_u_session, __pyx_mstate->__pyx_n_u_query, __pyx_mstate->__pyx_n_u_result, __pyx_mstate->__pyx_n_u_last_interval_obj, __pyx_mstate->__pyx_n_u_gap_seconds, __pyx_mstate->__pyx_n_u_activity_level, __pyx_mstate->__pyx_n_u_keyboard, __pyx_mstate->__pyx_n_u_mouse, __pyx_mstate->__pyx_n_u_average, __pyx_mstate->__pyx_n_u_e, __pyx_mstate->__pyx_n_u_end_date, __pyx_mstate->__pyx_n_u_start_date, __pyx_mstate->__pyx_n_u_last_interval, __pyx_mstate->__pyx_n_u_last_interval_id, __pyx_mstate->__pyx_n_u_trimmed_partial_used, __pyx_mstate->__pyx_n_u_time_diff_seconds, __pyx_mstate->__pyx_n_u_current_break_id, __pyx_mstate->__pyx_n_u_break_start_time, __pyx_mstate->__pyx_n_u_should_upload, __pyx_mstate->__pyx_n_u_interval_end_date, __pyx_mstate->__pyx_n_u_activityLevel, __pyx_mstate->__pyx_n_u_popup_is_active, __pyx_mstate->__pyx_n_u_has_zero_activity, __pyx_mstate->__pyx_n_u_is_idle, __pyx_mstate->__pyx_n_u_activity_queue_size, __pyx_mstate->__pyx_n_u_total_queue_size, __pyx_mstate->__pyx_n_u_processed_count, __pyx_mstate->__pyx_n_u_max_verification_retries, __pyx_mstate->__pyx_n_u_verification_delay, __pyx_mstate->__pyx_n_u_interval_verified, __pyx_mstate->__pyx_n_u_verify_attempt, __pyx_mstate->__pyx_n_u_db_interval, __pyx_mstate->__pyx_n_u_verify_error, __pyx_mstate->__pyx_n_u_current_session_counter, __pyx_mstate->__pyx_n_u_intervals, __pyx_mstate->__pyx_n_u_max_retries, __pyx_mstate->__pyx_n_u_retry_delays, __pyx_mstate->__pyx_n_u_last_interval_found, __pyx_mstate->__pyx_n_u_datetime_matches, __pyx_mstate->__pyx_n_u_datetime_matches, __pyx_mstate->__pyx_n_u_attempt, __pyx_mstate->__pyx_n_u_idx, __pyx_mstate->__pyx_n_u_interval, __pyx_mstate->__pyx_n_u_interval_is_uploaded, __pyx_mstate->__pyx_n_u_is_sleep_interval_for_manual_che, __pyx_mstate->__pyx_n_u_already_in_list, __pyx_mstate->__pyx_n_u_datetime_matches_final, __pyx_mstate->__pyx_n_u_datetime_matches_final, __pyx_mstate->__pyx_n_u_last_interval_in_list, __pyx_mstate->__pyx_n_u_work_stop, __pyx_mstate->__pyx_n_u_sending_intervals, __pyx_mstate->__pyx_n_u_last_interval_updated, __pyx_mstate->__pyx_n_u_at_least_one_batch_successful, __pyx_mstate->__pyx_n_u_updated_interval_ids, __pyx_mstate->__pyx_n_u_response, __pyx_mstate->__pyx_n_u_response_2, __pyx_mstate->__pyx_n_u_intervals_to_update, __pyx_mstate->__pyx_n_u_st, __pyx_mstate->__pyx_n_u_et, __pyx_mstate->__pyx_n_u_tol, __pyx_mstate->__pyx_n_u_q_4, __pyx_mstate->__pyx_n_u_res, __pyx_mstate->__pyx_n_u_db_last, __pyx_mstate->__pyx_n_u_interval_payload, __pyx_mstate->__pyx_n_u_screen_url, __pyx_mstate->__pyx_n_u_last_interval_was_sent, __pyx_mstate->__pyx_n_u_fallback_error, __pyx_mstate->__pyx_n_u_last_ss_urls, __pyx_mstate->__pyx_n_u_intervals_updated_count, __pyx_mstate->__pyx_n_u_interval_to_update, __pyx_mstate->__pyx_n_u_unsent_intervals, __pyx_mstate->__pyx_n_u_genexpr, __pyx_mstate->__pyx_n_u_genexpr, __pyx_mstate->__pyx_n_u_genexpr, __pyx_mstate->__pyx_n_u_genexpr, __pyx_mstate->__pyx_n_u_genexpr};
    __pyx_mstate_global->__pyx_codeobj_tab[59] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_last_api_call_impl, __pyx_mstate->__pyx_kp_b_iso88591_A_A, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[59])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 5158};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_dt1, __pyx_mstate->__pyx_n_u_dt2, __pyx_mstate->__pyx_n_u_tolerance_seconds, __pyx_mstate->__pyx_n_u_time_diff};
    __pyx_mstate_global->__pyx_codeobj_tab[60] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_datetime_matches, __pyx_mstate->__pyx_kp_b_iso88591_q_t3e3d_Q_q_Cr_Rt_z_A_q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[60])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 5289};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_dt1, __pyx_mstate->__pyx_n_u_dt2, __pyx_mstate->__pyx_n_u_tolerance_seconds, __pyx_mstate->__pyx_n_u_time_diff};
    __pyx_mstate_global->__pyx_codeobj_tab[61] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_datetime_matches_final, __pyx_mstate->__pyx_kp_b_iso88591_9_4s_s_c_1_2T_4_Q_S_1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[61])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 11, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 5643};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_keep_idle_time, __pyx_mstate->__pyx_n_u_should_skip_break_processing, __pyx_mstate->__pyx_n_u_time_since_break_stop, __pyx_mstate->__pyx_n_u_session, __pyx_mstate->__pyx_n_u_query, __pyx_mstate->__pyx_n_u_result, __pyx_mstate->__pyx_n_u_remaining_break_intervals, __pyx_mstate->__pyx_n_u_break_error, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[62] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_stop_event, __pyx_mstate->__pyx_kp_b_iso88591_L8H, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[62])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 7, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 5716};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_app_name, __pyx_mstate->__pyx_n_u_app_icon, __pyx_mstate->__pyx_n_u_electron_comm, __pyx_mstate->__pyx_n_u_message_data, __pyx_mstate->__pyx_n_u_success, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[63] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_send_active_app_update_to_elect, __pyx_mstate->__pyx_kp_b_iso88591_B_zQR, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[63])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 6, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 5752};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_s3_url, __pyx_mstate->__pyx_n_u_electron_comm, __pyx_mstate->__pyx_n_u_message_data, __pyx_mstate->__pyx_n_u_success, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[64] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_send_file_upload_success_to_ele, __pyx_mstate->__pyx_kp_b_iso88591_B, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[64])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 5, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 5783};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_electron_comm, __pyx_mstate->__pyx_n_u_message_data, __pyx_mstate->__pyx_n_u_success, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[65] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_send_file_upload_failure_to_ele, __pyx_mstate->__pyx_kp_b_iso88591__18, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[65])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 13, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 5813};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_current_time, __pyx_mstate->__pyx_n_u_elapsed_seconds, __pyx_mstate->__pyx_n_u_session, __pyx_mstate->__pyx_n_u_query, __pyx_mstate->__pyx_n_u_result, __pyx_mstate->__pyx_n_u_all_intervals, __pyx_mstate->__pyx_n_u_interval_ids, __pyx_mstate->__pyx_n_u_idle_count, __pyx_mstate->__pyx_n_u_activity_count, __pyx_mstate->__pyx_n_u_interval, __pyx_mstate->__pyx_n_u_electron_comm, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[66] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_check_idle_popup_timeout, __pyx_mstate->__pyx_kp_b_iso88591_0_2, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[66])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 13, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 5906};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_timeout_reached, __pyx_mstate->__pyx_n_u_current_break_id, __pyx_mstate->__pyx_n_u_current_time, __pyx_mstate->__pyx_n_u_electron_comm, __pyx_mstate->__pyx_n_u_max_retries, __pyx_mstate->__pyx_n_u_retry_delays, __pyx_mstate->__pyx_n_u_success, __pyx_mstate->__pyx_n_u_attempt, __pyx_mstate->__pyx_n_u_is_connected, __pyx_mstate->__pyx_n_u_delay, __pyx_mstate->__pyx_n_u_consecutive_idle_count, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[67] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_arise_idle_popup, __pyx_mstate->__pyx_kp_b_iso88591__18, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[67])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 11, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 6021};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_start_date, __pyx_mstate->__pyx_n_u_end_date, __pyx_mstate->__pyx_n_u_activityLevel, __pyx_mstate->__pyx_n_u_keyboard, __pyx_mstate->__pyx_n_u_mouse, __pyx_mstate->__pyx_n_u_average, __pyx_mstate->__pyx_n_u_has_activity_level_activity, __pyx_mstate->__pyx_n_u_has_activity_percentage_activity, __pyx_mstate->__pyx_n_u_activity_percentage, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[68] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_has_zero_activity_for_interval, __pyx_mstate->__pyx_kp_b_iso88591_sst, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[68])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {7, 0, 0, 19, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 6062};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_keep_idle_time, __pyx_mstate->__pyx_n_u_action, __pyx_mstate->__pyx_n_u_project_id, __pyx_mstate->__pyx_n_u_task_id, __pyx_mstate->__pyx_n_u_note, __pyx_mstate->__pyx_n_u_file_path, __pyx_mstate->__pyx_n_u_s3_file_url, __pyx_mstate->__pyx_n_u_file_upload_success, __pyx_mstate->__pyx_n_u_e, __pyx_mstate->__pyx_n_u_note_text, __pyx_mstate->__pyx_n_u_MAX_NOTE_LENGTH, __pyx_mstate->__pyx_n_u_original_length, __pyx_mstate->__pyx_n_u_current_counter, __pyx_mstate->__pyx_n_u_current_counter_held, __pyx_mstate->__pyx_n_u_interval, __pyx_mstate->__pyx_n_u_iv, __pyx_mstate->__pyx_n_u_iv, __pyx_mstate->__pyx_n_u_iv};
    __pyx_mstate_global->__pyx_codeobj_tab[69] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_handle_idle_popup_response, __pyx_mstate->__pyx_kp_b_iso88591_UR_tt_T_T_Z_Z_p_p, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[69])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 14, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 6207};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_current_session_counter, __pyx_mstate->__pyx_n_u_intervals, __pyx_mstate->__pyx_n_u_org_id, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_response, __pyx_mstate->__pyx_n_u_payload, __pyx_mstate->__pyx_n_u_batch_intervals, __pyx_mstate->__pyx_n_u_api_response, __pyx_mstate->__pyx_n_u_interval, __pyx_mstate->__pyx_n_u_e, __pyx_mstate->__pyx_n_u_day_payload, __pyx_mstate->__pyx_n_u_interval_data, __pyx_mstate->__pyx_n_u_screen_url};
    __pyx_mstate_global->__pyx_codeobj_tab[70] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_sync_activity_immediately, __pyx_mstate->__pyx_kp_b_iso88591__18, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[70])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 17, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 6280};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_current_counter, __pyx_mstate->__pyx_n_u_interval_ids, __pyx_mstate->__pyx_n_u_popup_triggered_at, __pyx_mstate->__pyx_n_u_session, __pyx_mstate->__pyx_n_u_popup_query, __pyx_mstate->__pyx_n_u_popup_result, __pyx_mstate->__pyx_n_u_interval, __pyx_mstate->__pyx_n_u_idle_flag_query, __pyx_mstate->__pyx_n_u_idle_flag_result, __pyx_mstate->__pyx_n_u_all_query, __pyx_mstate->__pyx_n_u_all_result, __pyx_mstate->__pyx_n_u_has_zero, __pyx_mstate->__pyx_n_u_interval_id_list, __pyx_mstate->__pyx_n_u_updates, __pyx_mstate->__pyx_n_u_e, __pyx_mstate->__pyx_n_u_iid};
    __pyx_mstate_global->__pyx_codeobj_tab[71] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_mark_idle_intervals_as_uploaded, __pyx_mstate->__pyx_kp_b_iso88591__18, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[71])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 11, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 6380};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_local_file_path, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_org_id, __pyx_mstate->__pyx_n_u_s3_config, __pyx_mstate->__pyx_n_u_s3_sync, __pyx_mstate->__pyx_n_u_file_name, __pyx_mstate->__pyx_n_u_timestamp, __pyx_mstate->__pyx_n_u_s3_dest_path, __pyx_mstate->__pyx_n_u_s3_url, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[72] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_upload_file_to_s3, __pyx_mstate->__pyx_kp_b_iso88591_8_2, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[72])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 19, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 6447};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_note, __pyx_mstate->__pyx_n_u_file_path, __pyx_mstate->__pyx_n_u_current_counter, __pyx_mstate->__pyx_n_u_session, __pyx_mstate->__pyx_n_u_query_by_flag, __pyx_mstate->__pyx_n_u_result_by_flag, __pyx_mstate->__pyx_n_u_idle_intervals_by_flag, __pyx_mstate->__pyx_n_u_query_all, __pyx_mstate->__pyx_n_u_result_all, __pyx_mstate->__pyx_n_u_all_intervals, __pyx_mstate->__pyx_n_u_intervals_to_mark, __pyx_mstate->__pyx_n_u_interval, __pyx_mstate->__pyx_n_u_has_zero_activity, __pyx_mstate->__pyx_n_u_idle_intervals, __pyx_mstate->__pyx_n_u_interval_ids, __pyx_mstate->__pyx_n_u_note_data, __pyx_mstate->__pyx_n_u_e, __pyx_mstate->__pyx_n_u_interval};
    __pyx_mstate_global->__pyx_codeobj_tab[73] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_save_note_to_idle_intervals, __pyx_mstate->__pyx_kp_b_iso88591_7uKq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[73])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 12, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 6536};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_note, __pyx_mstate->__pyx_n_u_file_path, __pyx_mstate->__pyx_n_u_current_counter, __pyx_mstate->__pyx_n_u_session, __pyx_mstate->__pyx_n_u_query, __pyx_mstate->__pyx_n_u_result, __pyx_mstate->__pyx_n_u_latest_interval, __pyx_mstate->__pyx_n_u_target_interval_id, __pyx_mstate->__pyx_n_u_note_data, __pyx_mstate->__pyx_n_u_enqueue_success, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[74] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_save_note_to_current_interval, __pyx_mstate->__pyx_kp_b_iso88591_9_k, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[74])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_GENERATOR), 6707};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_held};
    __pyx_mstate_global->__pyx_codeobj_tab[75] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_genexpr, __pyx_mstate->__pyx_kp_b_iso88591__23, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[75])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 22, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 6606};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_intervals, __pyx_mstate->__pyx_n_u_current_counter, __pyx_mstate->__pyx_n_u_current_counter_intervals, __pyx_mstate->__pyx_n_u_session, __pyx_mstate->__pyx_n_u_query, __pyx_mstate->__pyx_n_u_result, __pyx_mstate->__pyx_n_u_db_intervals, __pyx_mstate->__pyx_n_u_interval_ids_in_list, __pyx_mstate->__pyx_n_u_db_interval, __pyx_mstate->__pyx_n_u_activity_level, __pyx_mstate->__pyx_n_u_keyboard, __pyx_mstate->__pyx_n_u_mouse, __pyx_mstate->__pyx_n_u_average, __pyx_mstate->__pyx_n_u_e, __pyx_mstate->__pyx_n_u_idle_intervals, __pyx_mstate->__pyx_n_u_non_idle_intervals, __pyx_mstate->__pyx_n_u_interval, __pyx_mstate->__pyx_n_u_iv, __pyx_mstate->__pyx_n_u_iv, __pyx_mstate->__pyx_n_u_genexpr, __pyx_mstate->__pyx_n_u_genexpr};
    __pyx_mstate_global->__pyx_codeobj_tab[76] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_should_pause_api_calls, __pyx_mstate->__pyx_kp_b_iso88591_7y, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[76])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 36, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS|CO_COROUTINE), 6729};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_project_id, __pyx_mstate->__pyx_n_u_task_id, __pyx_mstate->__pyx_n_u_task_id_str, __pyx_mstate->__pyx_n_u_project_id_str, __pyx_mstate->__pyx_n_u_idle_intervals, __pyx_mstate->__pyx_n_u_session, __pyx_mstate->__pyx_n_u_query, __pyx_mstate->__pyx_n_u_result, __pyx_mstate->__pyx_n_u_grouped_intervals, __pyx_mstate->__pyx_n_u_success_count, __pyx_mstate->__pyx_n_u_failed_count, __pyx_mstate->__pyx_n_u_target_date, __pyx_mstate->__pyx_n_u_day_intervals, __pyx_mstate->__pyx_n_u_day_start_time, __pyx_mstate->__pyx_n_u_effective_start_time, __pyx_mstate->__pyx_n_u_interval_payloads, __pyx_mstate->__pyx_n_u_interval_ids, __pyx_mstate->__pyx_n_u_interval_note_map, __pyx_mstate->__pyx_n_u_notes_query, __pyx_mstate->__pyx_n_u_notes_result, __pyx_mstate->__pyx_n_u_notes_entries, __pyx_mstate->__pyx_n_u_notes_entry, __pyx_mstate->__pyx_n_u_interval_id, __pyx_mstate->__pyx_n_u_e, __pyx_mstate->__pyx_n_u_interval, __pyx_mstate->__pyx_n_u_payload_from, __pyx_mstate->__pyx_n_u_payload_to, __pyx_mstate->__pyx_n_u_screen_url, __pyx_mstate->__pyx_n_u_activity_level, __pyx_mstate->__pyx_n_u_app_and_urls, __pyx_mstate->__pyx_n_u_interval_payload, __pyx_mstate->__pyx_n_u_payload, __pyx_mstate->__pyx_n_u_response, __pyx_mstate->__pyx_n_u_activity_manager, __pyx_mstate->__pyx_n_u_interval};
    __pyx_mstate_global->__pyx_codeobj_tab[77] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_idle_reassign, __pyx_mstate->__pyx_kp_b_iso88591_uIQ, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[77])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 100};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_val, __pyx_mstate->__pyx_n_u_default};
    __pyx_mstate_global->__pyx_codeobj_tab[78] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_to_int, __pyx_mstate->__pyx_kp_b_iso88591_s_1_q_q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[78])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {0, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 118};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_get_electron_comm};
    __pyx_mstate_global->__pyx_codeobj_tab[79] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_get_electron_comm_lazy, __pyx_mstate->__pyx_kp_b_iso88591_q_A, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[79])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 8, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 158};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_last_count, __pyx_mstate->__pyx_n_u_session_gap_minutes, __pyx_mstate->__pyx_n_u_tracker_status, __pyx_mstate->__pyx_n_u_resolve_screenshot_directory, __pyx_mstate->__pyx_n_u_screenshot_folder, __pyx_mstate->__pyx_n_u_e, __pyx_mstate->__pyx_n_u_wake_detector};
    __pyx_mstate_global->__pyx_codeobj_tab[80] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_init, __pyx_mstate->__pyx_kp_b_iso88591_81_q_B_A_N_q_A_q_31A_q_Kq_Kq_1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[80])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 406};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self};
    __pyx_mstate_global->__pyx_codeobj_tab[81] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_handle_wake_session_counter, __pyx_mstate->__pyx_kp_b_iso88591_a_6a_e1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[81])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 414};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self};
    __pyx_mstate_global->__pyx_codeobj_tab[82] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_get_electron_comm_2, __pyx_mstate->__pyx_kp_b_iso88591_A_a, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[82])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 418};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_channel, __pyx_mstate->__pyx_n_u_data, __pyx_mstate->__pyx_n_u_electron_comm};
    __pyx_mstate_global->__pyx_codeobj_tab[83] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_send_to_electron_if_connected, __pyx_mstate->__pyx_kp_b_iso88591_6k_q_4_S_M_a_1_Qiq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[83])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 13, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 425};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_wake_detector, __pyx_mstate->__pyx_n_u_stats, __pyx_mstate->__pyx_n_u_last_sleep_time, __pyx_mstate->__pyx_n_u_last_wake_time, __pyx_mstate->__pyx_n_u_sleep_timestamp, __pyx_mstate->__pyx_n_u_current_timestamp, __pyx_mstate->__pyx_n_u_time_since_sleep, __pyx_mstate->__pyx_n_u_system_is_responsive, __pyx_mstate->__pyx_n_u_win32gui, __pyx_mstate->__pyx_n_u_hwnd, __pyx_mstate->__pyx_n_u_wake_timestamp, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[84] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_is_system_sleeping, __pyx_mstate->__pyx_kp_b_iso88591_Q_4A_q_Zq_t1A_d_1_1_z_381_1_E_9, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[84])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 5, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 504};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_interval, __pyx_mstate->__pyx_n_u_now, __pyx_mstate->__pyx_n_u_now_ts, __pyx_mstate->__pyx_n_u_remainder};
    __pyx_mstate_global->__pyx_codeobj_tab[85] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_boundary_time, __pyx_mstate->__pyx_kp_b_iso88591_A_hit1_AS_G2Q_y_z_G1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[85])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 517};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_target};
    __pyx_mstate_global->__pyx_codeobj_tab[86] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_seconds_until_datetime, __pyx_mstate->__pyx_kp_b_iso88591_A_a_7_Q_1_6_4s, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[86])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 524};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_reason, __pyx_mstate->__pyx_n_u_old_counter, __pyx_mstate->__pyx_n_u_screenshot_ctrl};
    __pyx_mstate_global->__pyx_codeobj_tab[87] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_increment_session_counter, __pyx_mstate->__pyx_kp_b_iso88591_0H_d_N_b_XYd_6a_N_4r_a_1_A_7_Q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[87])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 545};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_within_seconds, __pyx_mstate->__pyx_n_u_last_bump};
    __pyx_mstate_global->__pyx_codeobj_tab[88] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_should_skip_counter_bump_dedup, __pyx_mstate->__pyx_kp_b_iso88591_7_6_C1_1_G1F_1_S_1_S_N_Rq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[88])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 1, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 585};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_project_id, __pyx_mstate->__pyx_n_u_task_id, __pyx_mstate->__pyx_n_u_update_segment_start};
    __pyx_mstate_global->__pyx_codeobj_tab[89] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_set_project_task_ids, __pyx_mstate->__pyx_kp_b_iso88591_A_a_Qo_zQR_s_xwj_1_hit1_e1_I, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[89])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 762};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_platform_name};
    __pyx_mstate_global->__pyx_codeobj_tab[90] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_get_os_type_caps, __pyx_mstate->__pyx_kp_b_iso88591_q_A_q_q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[90])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 3, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 768};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_error_message, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[91] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_handle_s3_time_error, __pyx_mstate->__pyx_kp_b_iso88591_2_A_Q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[91])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 794};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_value, __pyx_mstate->__pyx_n_u_text, __pyx_mstate->__pyx_n_u_fmt, __pyx_mstate->__pyx_n_u_parsed};
    __pyx_mstate_global->__pyx_codeobj_tab[92] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_normalize_hhmmss, __pyx_mstate->__pyx_kp_b_iso88591_A_6_A_1_s_6_q_4q_1_G1L_1F_e1_vYa, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[92])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 6, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 810};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_response, __pyx_mstate->__pyx_n_u_raw_start, __pyx_mstate->__pyx_n_u_raw_end, __pyx_mstate->__pyx_n_u_s_limit_start, __pyx_mstate->__pyx_n_u_s_limit_end};
    __pyx_mstate_global->__pyx_codeobj_tab[93] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_parse_fixed_mode_window, __pyx_mstate->__pyx_kp_b_iso88591_1_HD_S_AQ_aq_83a_hd_1_aq_d_AQ_E, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[93])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 6, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 977};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_encrypted_key, __pyx_mstate->__pyx_n_u_position_of_dollar, __pyx_mstate->__pyx_n_u_new_string, __pyx_mstate->__pyx_n_u_decrypted_data, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[94] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_decrypt, __pyx_mstate->__pyx_kp_b_iso88591_4_S_Ja_a_NiWhhkkllzz_e1A_a_oQ_f, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[94])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 1005};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_loop, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[95] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_handle_wake_s3_update, __pyx_mstate->__pyx_kp_b_iso88591_A_t7_6_TAXX_fAQ_a_woQ_4_q_I_4q_A, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[95])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 8, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 1268};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_preference, __pyx_mstate->__pyx_n_u_user_entity, __pyx_mstate->__pyx_n_u_normalize_timezone_preference, __pyx_mstate->__pyx_n_u_previous, __pyx_mstate->__pyx_n_u_normalized, __pyx_mstate->__pyx_n_u_time_monitor, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[96] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_apply_org_timezone_preference, __pyx_mstate->__pyx_kp_b_iso88591_9_F_31_7_6_8_2_1_1_wa_a_7_6_gQ, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[96])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 6, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 1446};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_response_2, __pyx_mstate->__pyx_n_u_enrich_subscription_payload, __pyx_mstate->__pyx_n_u_category_fields, __pyx_mstate->__pyx_n_u_error_data, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[97] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_send_subscription_expired_popup, __pyx_mstate->__pyx_kp_b_iso88591_q_q_9_1O1_q_qPQ_1_it1__A_Yd_a_C, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[97])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 6, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 1604};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_time, __pyx_mstate->__pyx_n_u_interval_minutes, __pyx_mstate->__pyx_n_u_minute, __pyx_mstate->__pyx_n_u_rounded_minute, __pyx_mstate->__pyx_n_u_aligned_time};
    __pyx_mstate_global->__pyx_codeobj_tab[98] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_align_to_interval_boundary, __pyx_mstate->__pyx_kp_b_iso88591_00Fa_3at_Rq_Q_6b_t81G_7_QR_q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[98])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 9, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 1625};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_app_name, __pyx_mstate->__pyx_n_u_normalized_name, __pyx_mstate->__pyx_n_u_cleaned_name, __pyx_mstate->__pyx_n_u_cleaned_name_lower, __pyx_mstate->__pyx_n_u_browsers, __pyx_mstate->__pyx_n_u_genexpr, __pyx_mstate->__pyx_n_u_genexpr, __pyx_mstate->__pyx_n_u_genexpr};
    __pyx_mstate_global->__pyx_codeobj_tab[99] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_is_browser, __pyx_mstate->__pyx_kp_b_iso88591_A_Zq_r_aq_r_Q_8_A_q_1_8_BTT_ggqq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[99])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 3407};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_url};
    __pyx_mstate_global->__pyx_codeobj_tab[100] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_is_link, __pyx_mstate->__pyx_kp_b_iso88591_A_t_haq, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[100])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 3411};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_ss};
    __pyx_mstate_global->__pyx_codeobj_tab[101] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_forward_ss, __pyx_mstate->__pyx_kp_b_iso88591_A_t_k, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[101])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 5, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 3533};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_intervals, __pyx_mstate->__pyx_n_u_grouped_intervals, __pyx_mstate->__pyx_n_u_interval, __pyx_mstate->__pyx_n_u_interval_date};
    __pyx_mstate_global->__pyx_codeobj_tab[102] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_group_intervals_by_day, __pyx_mstate->__pyx_kp_b_iso88591_A_Kq_L_HKuA_QnG1A_q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[102])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 3544};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_prev_interval, __pyx_mstate->__pyx_n_u_current_interval, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[103] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_calculate_gap_seconds, __pyx_mstate->__pyx_kp_b_iso88591_I_4_S_A_1_L_z_WX_A_J_1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[103])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 3554};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_gap_seconds, __pyx_mstate->__pyx_n_u_idle_threshold, __pyx_mstate->__pyx_n_u_system_name};
    __pyx_mstate_global->__pyx_codeobj_tab[104] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_determine_sleep_reason, __pyx_mstate->__pyx_kp_b_iso88591_3_Q_EQ_hgQ_s_1_S_TTU_s_0_C_SST, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[104])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {5, 0, 0, 6, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 3569};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_reason, __pyx_mstate->__pyx_n_u_prev_interval, __pyx_mstate->__pyx_n_u_current_interval, __pyx_mstate->__pyx_n_u_gap_seconds, __pyx_mstate->__pyx_n_u_gap_minutes};
    __pyx_mstate_global->__pyx_codeobj_tab[105] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_log_session_split_reason, __pyx_mstate->__pyx_kp_b_iso88591_00ccmmn_l_F_1_e1_G1_1O_q_1_nA_1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[105])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 5, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 3583};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_prev_interval, __pyx_mstate->__pyx_n_u_current_interval, __pyx_mstate->__pyx_n_u_gap_seconds, __pyx_mstate->__pyx_n_u_reason};
    __pyx_mstate_global->__pyx_codeobj_tab[106] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_should_start_new_session, __pyx_mstate->__pyx_kp_b_iso88591_LA_4q_1_9C_A_1O1_1_d_1_r_Q_T_1, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[106])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 7, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 3691};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_interval, __pyx_mstate->__pyx_n_u_activity_level, __pyx_mstate->__pyx_n_u_mouse, __pyx_mstate->__pyx_n_u_keyboard, __pyx_mstate->__pyx_n_u_average, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[107] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_is_idle_interval, __pyx_mstate->__pyx_kp_b_iso88591_A_4q_1_XQ_z_V1A__Cq_E_AYc_A_uA, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[107])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 8, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 3711};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_intervals, __pyx_mstate->__pyx_n_u_sorted_intervals, __pyx_mstate->__pyx_n_u_sessions, __pyx_mstate->__pyx_n_u_current_session, __pyx_mstate->__pyx_n_u_i, __pyx_mstate->__pyx_n_u_prev_interval, __pyx_mstate->__pyx_n_u_current_interval};
    __pyx_mstate_global->__pyx_codeobj_tab[108] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_group_intervals_by_session, __pyx_mstate->__pyx_kp_b_iso88591_A_4q_1_6_T_1_1A_E_as_Qa_ARr_q_t, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[108])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {3, 0, 0, 5, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 3743};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_target_date, __pyx_mstate->__pyx_n_u_intervals_for_day, __pyx_mstate->__pyx_n_u_pinned, __pyx_mstate->__pyx_n_u_session_start};
    __pyx_mstate_global->__pyx_codeobj_tab[109] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_get_day_start_time, __pyx_mstate->__pyx_kp_b_iso88591_A_4q_89HA_q_AQ_7_1_s_k_a_G1F_H_W, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[109])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 3766};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_interval};
    __pyx_mstate_global->__pyx_codeobj_tab[110] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_get_activity_level_from_interva, __pyx_mstate->__pyx_kp_b_iso88591_Q_FavQ, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[110])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {2, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 4396};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_user_entity};
    __pyx_mstate_global->__pyx_codeobj_tab[111] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_set_local_timezone, __pyx_mstate->__pyx_kp_b_iso88591_A_0, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[111])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 9, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 4745};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_memory_info, __pyx_mstate->__pyx_n_u_memory_mb, __pyx_mstate->__pyx_n_u_memory_percent, __pyx_mstate->__pyx_n_u_cpu_percent, __pyx_mstate->__pyx_n_u_system_cpu_percent, __pyx_mstate->__pyx_n_u_thread_count, __pyx_mstate->__pyx_n_u_fd_count, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[112] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_log_system_resources, __pyx_mstate->__pyx_kp_b_iso88591_A_hl_5_r_T_hl_1_4x_1_4xxq_F_1_q, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[112])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 4, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 4786};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_memory_info, __pyx_mstate->__pyx_n_u_memory_mb, __pyx_mstate->__pyx_n_u_e};
    __pyx_mstate_global->__pyx_codeobj_tab[113] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_check_memory_usage, __pyx_mstate->__pyx_kp_b_iso88591_A_hl_5_r_z_4q_ha_YYddhhi_q_1_A_A, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[113])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {4, 0, 0, 8, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 4801};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_last_interval, __pyx_mstate->__pyx_n_u_intervals, __pyx_mstate->__pyx_n_u_fallback_end, __pyx_mstate->__pyx_n_u_candidate, __pyx_mstate->__pyx_n_u_iv, __pyx_mstate->__pyx_n_u_is_break, __pyx_mstate->__pyx_n_u_et};
    __pyx_mstate_global->__pyx_codeobj_tab[114] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_finalize_work_stop_time, __pyx_mstate->__pyx_kp_b_iso88591_A_a_1_T_A_Q_1_a_7_4_3c_9HCvQ_WAT, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[114])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 2, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 4826};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self, __pyx_mstate->__pyx_n_u_work_stop};
    __pyx_mstate_global->__pyx_codeobj_tab[115] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_break_start_after_work_stop, __pyx_mstate->__pyx_kp_b_iso88591_a_D_c_a_y_S_AXQ, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[115])) goto bad;
  }
  {
    const __Pyx_PyCode_New_function_description descr = {1, 0, 0, 1, (unsigned int)(CO_OPTIMIZED|CO_NEWLOCALS), 6200};
    PyObject* const varnames[] = {__pyx_mstate->__pyx_n_u_self};
    __pyx_mstate_global->__pyx_codeobj_tab[116] = __Pyx_PyCode_New(descr, varnames, __pyx_mstate->__pyx_kp_u_ws_package_controllers_activity_8, __pyx_mstate->__pyx_n_u_handle_idle_popup_shown, __pyx_mstate->__pyx_kp_b_iso88591_A_fAQ, tuple_dedup_map); if (unlikely(!__pyx_mstate_global->__pyx_codeobj_tab[116])) goto bad;
  }
  Py_DECREF(tuple_dedup_map);
  return 0;
  bad:
  Py_DECREF(tuple_dedup_map);
  return -1;
}
/* #### Code section: init_globals ### */

static int __Pyx_InitGlobals(void) {
  /* PythonCompatibility.init */
  if (likely(__Pyx_init_co_variables() == 0)); else
  
  if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)

  /* CommonTypesMetaclass.init */
  if (likely(__pyx_CommonTypesMetaclass_init(__pyx_m) == 0)); else
  
  if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)

  /* Coroutine.init */
  if (likely(__pyx_Coroutine_init(__pyx_m) == 0)); else
  
  if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)

  /* Coro_CheckExact.init */
  #if CYTHON_COMPILING_IN_LIMITED_API
  {
      PyObject *typesModule=NULL;
      typesModule = PyImport_ImportModule("types");
      if (typesModule) {
          __pyx_mstate_global->__Pyx_CachedCoroType = PyObject_GetAttrString(typesModule, "CoroutineType");
          Py_DECREF(typesModule);
      }
  } // error handling follows
  #endif
  
  if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)

  /* CachedMethodType.init */
  #if CYTHON_COMPILING_IN_LIMITED_API
  {
      PyObject *typesModule=NULL;
      typesModule = PyImport_ImportModule("types");
      if (typesModule) {
          __pyx_mstate_global->__Pyx_CachedMethodType = PyObject_GetAttrString(typesModule, "MethodType");
          Py_DECREF(typesModule);
      }
  } // error handling follows
  #endif
  
  if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)

  /* CythonFunctionShared.init */
  if (likely(__pyx_CyFunction_init(__pyx_m) == 0)); else
  
  if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)

  /* Generator.init */
  if (likely(__pyx_Generator_init(__pyx_m) == 0)); else
  
  if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)

  /* AsyncGenerator.init */
  if (likely(__pyx_AsyncGen_init(__pyx_m) == 0)); else
  
  if (unlikely(PyErr_Occurred())) __PYX_ERR(0, 1, __pyx_L1_error)

  return 0;
  __pyx_L1_error:;
  return -1;
}
/* #### Code section: cleanup_globals ### */
/* #### Code section: cleanup_module ### */
/* #### Code section: main_method ### */
/* #### Code section: utility_code_pragmas ### */
#ifdef _MSC_VER
#pragma warning( push )
/* Warning 4127: conditional expression is constant
 * Cython uses constant conditional expressions to allow in inline functions to be optimized at
 * compile-time, so this warning is not useful
 */
#pragma warning( disable : 4127 )
#endif



/* #### Code section: utility_code_def ### */

/* --- Runtime support code --- */
/* Refnanny */
#if CYTHON_REFNANNY
static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
    PyObject *m = NULL, *p = NULL;
    void *r = NULL;
    m = PyImport_ImportModule(modname);
    if (!m) goto end;
    p = PyObject_GetAttrString(m, "RefNannyAPI");
    if (!p) goto end;
    r = PyLong_AsVoidPtr(p);
end:
    Py_XDECREF(p);
    Py_XDECREF(m);
    return (__Pyx_RefNannyAPIStruct *)r;
}
#endif

/* PyErrExceptionMatches (used by PyObjectGetAttrStrNoError) */
#if CYTHON_FAST_THREAD_STATE
static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    n = PyTuple_GET_SIZE(tuple);
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
    for (i=0; i<n; i++) {
        if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
    int result;
    PyObject *exc_type;
#if PY_VERSION_HEX >= 0x030C00A6
    PyObject *current_exception = tstate->current_exception;
    if (unlikely(!current_exception)) return 0;
    exc_type = (PyObject*) Py_TYPE(current_exception);
    if (exc_type == err) return 1;
#else
    exc_type = tstate->curexc_type;
    if (exc_type == err) return 1;
    if (unlikely(!exc_type)) return 0;
#endif
    #if CYTHON_AVOID_BORROWED_REFS
    Py_INCREF(exc_type);
    #endif
    if (unlikely(PyTuple_Check(err))) {
        result = __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
    } else {
        result = __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
    }
    #if CYTHON_AVOID_BORROWED_REFS
    Py_DECREF(exc_type);
    #endif
    return result;
}
#endif

/* PyErrFetchRestore (used by PyObjectGetAttrStrNoError) */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
#if PY_VERSION_HEX >= 0x030C00A6
    PyObject *tmp_value;
    assert(type == NULL || (value != NULL && type == (PyObject*) Py_TYPE(value)));
    if (value) {
        #if CYTHON_COMPILING_IN_CPYTHON
        if (unlikely(((PyBaseExceptionObject*) value)->traceback != tb))
        #endif
            PyException_SetTraceback(value, tb);
    }
    tmp_value = tstate->current_exception;
    tstate->current_exception = value;
    Py_XDECREF(tmp_value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
#else
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    tmp_type = tstate->curexc_type;
    tmp_value = tstate->curexc_value;
    tmp_tb = tstate->curexc_traceback;
    tstate->curexc_type = type;
    tstate->curexc_value = value;
    tstate->curexc_traceback = tb;
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#endif
}
static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
#if PY_VERSION_HEX >= 0x030C00A6
    PyObject* exc_value;
    exc_value = tstate->current_exception;
    tstate->current_exception = 0;
    *value = exc_value;
    *type = NULL;
    *tb = NULL;
    if (exc_value) {
        *type = (PyObject*) Py_TYPE(exc_value);
        Py_INCREF(*type);
        #if CYTHON_COMPILING_IN_CPYTHON
        *tb = ((PyBaseExceptionObject*) exc_value)->traceback;
        Py_XINCREF(*tb);
        #else
        *tb = PyException_GetTraceback(exc_value);
        #endif
    }
#else
    *type = tstate->curexc_type;
    *value = tstate->curexc_value;
    *tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
#endif
}
#endif

/* PyObjectGetAttrStr (used by PyObjectGetAttrStrNoError) */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro))
        return tp->tp_getattro(obj, attr_name);
    return PyObject_GetAttr(obj, attr_name);
}
#endif

/* PyObjectGetAttrStrNoError (used by GetBuiltinName) */
#if __PYX_LIMITED_VERSION_HEX < 0x030d0000
static void __Pyx_PyObject_GetAttrStr_ClearAttributeError(void) {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    if (likely(__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
        __Pyx_PyErr_Clear();
}
#endif
static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStrNoError(PyObject* obj, PyObject* attr_name) {
    PyObject *result;
#if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
    (void) PyObject_GetOptionalAttr(obj, attr_name, &result);
    return result;
#else
#if CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_TYPE_SLOTS
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_getattro == PyObject_GenericGetAttr)) {
        return _PyObject_GenericGetAttrWithDict(obj, attr_name, NULL, 1);
    }
#endif
    result = __Pyx_PyObject_GetAttrStr(obj, attr_name);
    if (unlikely(!result)) {
        __Pyx_PyObject_GetAttrStr_ClearAttributeError();
    }
    return result;
#endif
}

/* GetBuiltinName */
static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
    PyObject* result = __Pyx_PyObject_GetAttrStrNoError(__pyx_mstate_global->__pyx_b, name);
    if (unlikely(!result) && !PyErr_Occurred()) {
        PyErr_Format(PyExc_NameError,
            "name '%U' is not defined", name);
    }
    return result;
}

/* TupleAndListFromArray (used by fastcall) */
#if !CYTHON_COMPILING_IN_CPYTHON && CYTHON_METH_FASTCALL
static CYTHON_INLINE PyObject *
__Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n)
{
    PyObject *res;
    Py_ssize_t i;
    if (n <= 0) {
        return __Pyx_NewRef(__pyx_mstate_global->__pyx_empty_tuple);
    }
    res = PyTuple_New(n);
    if (unlikely(res == NULL)) return NULL;
    for (i = 0; i < n; i++) {
        Py_INCREF(src[i]);
        if (unlikely(__Pyx_PyTuple_SET_ITEM(res, i, src[i]) < (0))) {
            Py_DECREF(res);
            return NULL;
        }
    }
    return res;
}
#elif CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE void __Pyx_copy_object_array(PyObject *const *CYTHON_RESTRICT src, PyObject** CYTHON_RESTRICT dest, Py_ssize_t length) {
    PyObject *v;
    Py_ssize_t i;
    for (i = 0; i < length; i++) {
        v = dest[i] = src[i];
        Py_INCREF(v);
    }
}
static CYTHON_INLINE PyObject *
__Pyx_PyTuple_FromArray(PyObject *const *src, Py_ssize_t n)
{
    PyObject *res;
    if (n <= 0) {
        return __Pyx_NewRef(__pyx_mstate_global->__pyx_empty_tuple);
    }
    res = PyTuple_New(n);
    if (unlikely(res == NULL)) return NULL;
    __Pyx_copy_object_array(src, ((PyTupleObject*)res)->ob_item, n);
    return res;
}
static CYTHON_INLINE PyObject *
__Pyx_PyList_FromArray(PyObject *const *src, Py_ssize_t n)
{
    PyObject *res;
    if (n <= 0) {
        return PyList_New(0);
    }
    res = PyList_New(n);
    if (unlikely(res == NULL)) return NULL;
    __Pyx_copy_object_array(src, ((PyListObject*)res)->ob_item, n);
    return res;
}
#endif

/* BytesEquals (used by UnicodeEquals) */
static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL ||\
        !(CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS)
    return PyObject_RichCompareBool(s1, s2, equals);
#else
    if (s1 == s2) {
        return (equals == Py_EQ);
    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
        const char *ps1, *ps2;
        Py_ssize_t length = PyBytes_GET_SIZE(s1);
        if (length != PyBytes_GET_SIZE(s2))
            return (equals == Py_NE);
        ps1 = PyBytes_AS_STRING(s1);
        ps2 = PyBytes_AS_STRING(s2);
        if (ps1[0] != ps2[0]) {
            return (equals == Py_NE);
        } else if (length == 1) {
            return (equals == Py_EQ);
        } else {
            int result;
#if CYTHON_USE_UNICODE_INTERNALS && (PY_VERSION_HEX < 0x030B0000)
            Py_hash_t hash1, hash2;
            hash1 = ((PyBytesObject*)s1)->ob_shash;
            hash2 = ((PyBytesObject*)s2)->ob_shash;
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                return (equals == Py_NE);
            }
#endif
            result = memcmp(ps1, ps2, (size_t)length);
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
        return (equals == Py_NE);
    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
        return (equals == Py_NE);
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
#endif
}

/* UnicodeEquals (used by fastcall) */
static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL
    return PyObject_RichCompareBool(s1, s2, equals);
#else
    int s1_is_unicode, s2_is_unicode;
    if (s1 == s2) {
        goto return_eq;
    }
    s1_is_unicode = PyUnicode_CheckExact(s1);
    s2_is_unicode = PyUnicode_CheckExact(s2);
    if (s1_is_unicode & s2_is_unicode) {
        Py_ssize_t length, length2;
        int kind;
        void *data1, *data2;
        #if !CYTHON_COMPILING_IN_LIMITED_API
        if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
            return -1;
        #endif
        length = __Pyx_PyUnicode_GET_LENGTH(s1);
        #if !CYTHON_ASSUME_SAFE_SIZE
        if (unlikely(length < 0)) return -1;
        #endif
        length2 = __Pyx_PyUnicode_GET_LENGTH(s2);
        #if !CYTHON_ASSUME_SAFE_SIZE
        if (unlikely(length2 < 0)) return -1;
        #endif
        if (length != length2) {
            goto return_ne;
        }
#if CYTHON_USE_UNICODE_INTERNALS
        {
            Py_hash_t hash1, hash2;
            hash1 = ((PyASCIIObject*)s1)->hash;
            hash2 = ((PyASCIIObject*)s2)->hash;
            if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
                goto return_ne;
            }
        }
#endif
        kind = __Pyx_PyUnicode_KIND(s1);
        if (kind != __Pyx_PyUnicode_KIND(s2)) {
            goto return_ne;
        }
        data1 = __Pyx_PyUnicode_DATA(s1);
        data2 = __Pyx_PyUnicode_DATA(s2);
        if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
            goto return_ne;
        } else if (length == 1) {
            goto return_eq;
        } else {
            int result = memcmp(data1, data2, (size_t)(length * kind));
            return (equals == Py_EQ) ? (result == 0) : (result != 0);
        }
    } else if ((s1 == Py_None) & s2_is_unicode) {
        goto return_ne;
    } else if ((s2 == Py_None) & s1_is_unicode) {
        goto return_ne;
    } else {
        int result;
        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
        if (!py_result)
            return -1;
        result = __Pyx_PyObject_IsTrue(py_result);
        Py_DECREF(py_result);
        return result;
    }
return_eq:
    return (equals == Py_EQ);
return_ne:
    return (equals == Py_NE);
#endif
}

/* fastcall */
#if CYTHON_METH_FASTCALL
static CYTHON_INLINE PyObject * __Pyx_GetKwValue_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues, PyObject *s)
{
    Py_ssize_t i, n = __Pyx_PyTuple_GET_SIZE(kwnames);
    #if !CYTHON_ASSUME_SAFE_SIZE
    if (unlikely(n == -1)) return NULL;
    #endif
    for (i = 0; i < n; i++)
    {
        PyObject *namei = __Pyx_PyTuple_GET_ITEM(kwnames, i);
        #if !CYTHON_ASSUME_SAFE_MACROS
        if (unlikely(!namei)) return NULL;
        #endif
        if (s == namei) return kwvalues[i];
    }
    for (i = 0; i < n; i++)
    {
        PyObject *namei = __Pyx_PyTuple_GET_ITEM(kwnames, i);
        #if !CYTHON_ASSUME_SAFE_MACROS
        if (unlikely(!namei)) return NULL;
        #endif
        int eq = __Pyx_PyUnicode_Equals(s, namei, Py_EQ);
        if (unlikely(eq != 0)) {
            if (unlikely(eq < 0)) return NULL;
            return kwvalues[i];
        }
    }
    return NULL;
}
#if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030d0000 || CYTHON_COMPILING_IN_LIMITED_API
CYTHON_UNUSED static PyObject *__Pyx_KwargsAsDict_FASTCALL(PyObject *kwnames, PyObject *const *kwvalues) {
    Py_ssize_t i, nkwargs;
    PyObject *dict;
#if !CYTHON_ASSUME_SAFE_SIZE
    nkwargs = PyTuple_Size(kwnames);
    if (unlikely(nkwargs < 0)) return NULL;
#else
    nkwargs = PyTuple_GET_SIZE(kwnames);
#endif
    dict = PyDict_New();
    if (unlikely(!dict))
        return NULL;
    for (i=0; i<nkwargs; i++) {
#if !CYTHON_ASSUME_SAFE_MACROS
        PyObject *key = PyTuple_GetItem(kwnames, i);
        if (!key) goto bad;
#else
        PyObject *key = PyTuple_GET_ITEM(kwnames, i);
#endif
        if (unlikely(PyDict_SetItem(dict, key, kwvalues[i]) < 0))
            goto bad;
    }
    return dict;
bad:
    Py_DECREF(dict);
    return NULL;
}
#endif
#endif

/* PyObjectCall (used by PyObjectFastCall) */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
    PyObject *result;
    ternaryfunc call = Py_TYPE(func)->tp_call;
    if (unlikely(!call))
        return PyObject_Call(func, arg, kw);
    if (unlikely(Py_EnterRecursiveCall(" while calling a Python object")))
        return NULL;
    result = (*call)(func, arg, kw);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyObjectCallMethO (used by PyObjectFastCall) */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
    PyObject *self, *result;
    PyCFunction cfunc;
    cfunc = __Pyx_CyOrPyCFunction_GET_FUNCTION(func);
    self = __Pyx_CyOrPyCFunction_GET_SELF(func);
    if (unlikely(Py_EnterRecursiveCall(" while calling a Python object")))
        return NULL;
    result = cfunc(self, arg);
    Py_LeaveRecursiveCall();
    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
        PyErr_SetString(
            PyExc_SystemError,
            "NULL result without error in PyObject_Call");
    }
    return result;
}
#endif

/* PyObjectFastCall (used by PyObjectCallOneArg) */
#if PY_VERSION_HEX < 0x03090000 || CYTHON_COMPILING_IN_LIMITED_API
static PyObject* __Pyx_PyObject_FastCall_fallback(PyObject *func, PyObject * const*args, size_t nargs, PyObject *kwargs) {
    PyObject *argstuple;
    PyObject *result = 0;
    size_t i;
    argstuple = PyTuple_New((Py_ssize_t)nargs);
    if (unlikely(!argstuple)) return NULL;
    for (i = 0; i < nargs; i++) {
        Py_INCREF(args[i]);
        if (__Pyx_PyTuple_SET_ITEM(argstuple, (Py_ssize_t)i, args[i]) != (0)) goto bad;
    }
    result = __Pyx_PyObject_Call(func, argstuple, kwargs);
  bad:
    Py_DECREF(argstuple);
    return result;
}
#endif
#if CYTHON_VECTORCALL && !CYTHON_COMPILING_IN_LIMITED_API
  #if PY_VERSION_HEX < 0x03090000
    #define __Pyx_PyVectorcall_Function(callable) _PyVectorcall_Function(callable)
  #elif CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE vectorcallfunc __Pyx_PyVectorcall_Function(PyObject *callable) {
    PyTypeObject *tp = Py_TYPE(callable);
    #if defined(__Pyx_CyFunction_USED) && CYTHON_METH_FASTCALL
    if (__Pyx_CyFunction_CheckExact(callable)) {
        return __Pyx_CyFunction_func_vectorcall(callable);
    }
    #endif
    if (!PyType_HasFeature(tp, Py_TPFLAGS_HAVE_VECTORCALL)) {
        return NULL;
    }
    assert(PyCallable_Check(callable));
    Py_ssize_t offset = tp->tp_vectorcall_offset;
    assert(offset > 0);
    vectorcallfunc ptr;
    memcpy(&ptr, (char *) callable + offset, sizeof(ptr));
    return ptr;
}
  #else
    #define __Pyx_PyVectorcall_Function(callable) PyVectorcall_Function(callable)
  #endif
#endif
static CYTHON_INLINE PyObject* __Pyx_PyObject_FastCallDict(PyObject *func, PyObject *const *args, size_t _nargs, PyObject *kwargs) {
    Py_ssize_t nargs = __Pyx_PyVectorcall_NARGS(_nargs);
#if CYTHON_COMPILING_IN_CPYTHON
    if (nargs == 0 && kwargs == NULL) {
        if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_NOARGS))
            return __Pyx_PyObject_CallMethO(func, NULL);
    }
    else if (nargs == 1 && kwargs == NULL) {
        if (__Pyx_CyOrPyCFunction_Check(func) && likely( __Pyx_CyOrPyCFunction_GET_FLAGS(func) & METH_O))
            return __Pyx_PyObject_CallMethO(func, args[0]);
    }
#endif
    if (kwargs == NULL) {
        #if CYTHON_VECTORCALL
          #if CYTHON_COMPILING_IN_LIMITED_API
            return PyObject_Vectorcall(func, args, _nargs, NULL);
          #else
            vectorcallfunc f = __Pyx_PyVectorcall_Function(func);
            if (f) {
                return f(func, args, _nargs, NULL);
            }
          #endif
        #endif
    }
    if (nargs == 0) {
        return __Pyx_PyObject_Call(func, __pyx_mstate_global->__pyx_empty_tuple, kwargs);
    }
    #if PY_VERSION_HEX >= 0x03090000 && !CYTHON_COMPILING_IN_LIMITED_API
    return PyObject_VectorcallDict(func, args, (size_t)nargs, kwargs);
    #else
    return __Pyx_PyObject_FastCall_fallback(func, args, (size_t)nargs, kwargs);
    #endif
}

/* PyObjectCallOneArg (used by CallUnboundCMethod0) */
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
    PyObject *args[2] = {NULL, arg};
    return __Pyx_PyObject_FastCall(func, args+1, 1 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
}

/* UnpackUnboundCMethod (used by CallUnboundCMethod0) */
#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030C0000
static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject *args, PyObject *kwargs) {
    PyObject *result;
    PyObject *selfless_args = PyTuple_GetSlice(args, 1, PyTuple_Size(args));
    if (unlikely(!selfless_args)) return NULL;
    result = PyObject_Call(method, selfless_args, kwargs);
    Py_DECREF(selfless_args);
    return result;
}
#elif CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x03090000
static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject **args, Py_ssize_t nargs, PyObject *kwnames) {
        return _PyObject_Vectorcall
            (method, args ? args+1 : NULL, nargs ? nargs-1 : 0, kwnames);
}
#else
static PyObject *__Pyx_SelflessCall(PyObject *method, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) {
    return
#if PY_VERSION_HEX < 0x03090000
    _PyObject_Vectorcall
#else
    PyObject_Vectorcall
#endif
        (method, args ? args+1 : NULL, nargs ? (size_t) nargs-1 : 0, kwnames);
}
#endif
static PyMethodDef __Pyx_UnboundCMethod_Def = {
     "CythonUnboundCMethod",
     __PYX_REINTERPRET_FUNCION(PyCFunction, __Pyx_SelflessCall),
#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030C0000
     METH_VARARGS | METH_KEYWORDS,
#else
     METH_FASTCALL | METH_KEYWORDS,
#endif
     NULL
};
static int __Pyx_TryUnpackUnboundCMethod(__Pyx_CachedCFunction* target) {
    PyObject *method, *result=NULL;
    method = __Pyx_PyObject_GetAttrStr(target->type, *target->method_name);
    if (unlikely(!method))
        return -1;
    result = method;
#if CYTHON_COMPILING_IN_CPYTHON
    if (likely(__Pyx_TypeCheck(method, &PyMethodDescr_Type)))
    {
        PyMethodDescrObject *descr = (PyMethodDescrObject*) method;
        target->func = descr->d_method->ml_meth;
        target->flag = descr->d_method->ml_flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_STACKLESS);
    } else
#endif
#if CYTHON_COMPILING_IN_PYPY
#else
    if (PyCFunction_Check(method))
#endif
    {
        PyObject *self;
        int self_found;
#if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY
        self = PyObject_GetAttrString(method, "__self__");
        if (!self) {
            PyErr_Clear();
        }
#else
        self = PyCFunction_GET_SELF(method);
#endif
        self_found = (self && self != Py_None);
#if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY
        Py_XDECREF(self);
#endif
        if (self_found) {
            PyObject *unbound_method = PyCFunction_New(&__Pyx_UnboundCMethod_Def, method);
            if (unlikely(!unbound_method)) return -1;
            Py_DECREF(method);
            result = unbound_method;
        }
    }
#if !CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
    if (unlikely(target->method)) {
        Py_DECREF(result);
    } else
#endif
    target->method = result;
    return 0;
}

/* CallUnboundCMethod0 */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
    int was_initialized = __Pyx_CachedCFunction_GetAndSetInitializing(cfunc);
    if (likely(was_initialized == 2 && cfunc->func)) {
        if (likely(cfunc->flag == METH_NOARGS))
            return __Pyx_CallCFunction(cfunc, self, NULL);
        if (likely(cfunc->flag == METH_FASTCALL))
            return __Pyx_CallCFunctionFast(cfunc, self, NULL, 0);
        if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS))
            return __Pyx_CallCFunctionFastWithKeywords(cfunc, self, NULL, 0, NULL);
        if (likely(cfunc->flag == (METH_VARARGS | METH_KEYWORDS)))
            return __Pyx_CallCFunctionWithKeywords(cfunc, self, __pyx_mstate_global->__pyx_empty_tuple, NULL);
        if (cfunc->flag == METH_VARARGS)
            return __Pyx_CallCFunction(cfunc, self, __pyx_mstate_global->__pyx_empty_tuple);
        return __Pyx__CallUnboundCMethod0(cfunc, self);
    }
#if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
    else if (unlikely(was_initialized == 1)) {
        __Pyx_CachedCFunction tmp_cfunc = {
#ifndef __cplusplus
            0
#endif
        };
        tmp_cfunc.type = cfunc->type;
        tmp_cfunc.method_name = cfunc->method_name;
        return __Pyx__CallUnboundCMethod0(&tmp_cfunc, self);
    }
#endif
    PyObject *result = __Pyx__CallUnboundCMethod0(cfunc, self);
    __Pyx_CachedCFunction_SetFinishedInitializing(cfunc);
    return result;
}
#endif
static PyObject* __Pyx__CallUnboundCMethod0(__Pyx_CachedCFunction* cfunc, PyObject* self) {
    PyObject *result;
    if (unlikely(!cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
    result = __Pyx_PyObject_CallOneArg(cfunc->method, self);
    return result;
}

/* py_dict_items (used by OwnedDictNext) */
static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) {
    return __Pyx_CallUnboundCMethod0(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_items, d);
}

/* py_dict_values (used by OwnedDictNext) */
static CYTHON_INLINE PyObject* __Pyx_PyDict_Values(PyObject* d) {
    return __Pyx_CallUnboundCMethod0(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_values, d);
}

/* OwnedDictNext (used by ParseKeywordsImpl) */
#if CYTHON_AVOID_BORROWED_REFS
static int __Pyx_PyDict_NextRef(PyObject *p, PyObject **ppos, PyObject **pkey, PyObject **pvalue) {
    PyObject *next = NULL;
    if (!*ppos) {
        if (pvalue) {
            PyObject *dictview = pkey ? __Pyx_PyDict_Items(p) : __Pyx_PyDict_Values(p);
            if (unlikely(!dictview)) goto bad;
            *ppos = PyObject_GetIter(dictview);
            Py_DECREF(dictview);
        } else {
            *ppos = PyObject_GetIter(p);
        }
        if (unlikely(!*ppos)) goto bad;
    }
    next = PyIter_Next(*ppos);
    if (!next) {
        if (PyErr_Occurred()) goto bad;
        return 0;
    }
    if (pkey && pvalue) {
        *pkey = __Pyx_PySequence_ITEM(next, 0);
        if (unlikely(*pkey)) goto bad;
        *pvalue = __Pyx_PySequence_ITEM(next, 1);
        if (unlikely(*pvalue)) goto bad;
        Py_DECREF(next);
    } else if (pkey) {
        *pkey = next;
    } else {
        assert(pvalue);
        *pvalue = next;
    }
    return 1;
  bad:
    Py_XDECREF(next);
#if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d0000
    PyErr_FormatUnraisable("Exception ignored in __Pyx_PyDict_NextRef");
#else
    PyErr_WriteUnraisable(__pyx_mstate_global->__pyx_n_u_Pyx_PyDict_NextRef);
#endif
    if (pkey) *pkey = NULL;
    if (pvalue) *pvalue = NULL;
    return 0;
}
#else // !CYTHON_AVOID_BORROWED_REFS
static int __Pyx_PyDict_NextRef(PyObject *p, Py_ssize_t *ppos, PyObject **pkey, PyObject **pvalue) {
    int result = PyDict_Next(p, ppos, pkey, pvalue);
    if (likely(result == 1)) {
        if (pkey) Py_INCREF(*pkey);
        if (pvalue) Py_INCREF(*pvalue);
    }
    return result;
}
#endif

/* RaiseDoubleKeywords (used by ParseKeywordsImpl) */
static void __Pyx_RaiseDoubleKeywordsError(
    const char* func_name,
    PyObject* kw_name)
{
    PyErr_Format(PyExc_TypeError,
        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
}

/* CallUnboundCMethod2 */
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE PyObject *__Pyx_CallUnboundCMethod2(__Pyx_CachedCFunction *cfunc, PyObject *self, PyObject *arg1, PyObject *arg2) {
    int was_initialized = __Pyx_CachedCFunction_GetAndSetInitializing(cfunc);
    if (likely(was_initialized == 2 && cfunc->func)) {
        PyObject *args[2] = {arg1, arg2};
        if (cfunc->flag == METH_FASTCALL) {
            return __Pyx_CallCFunctionFast(cfunc, self, args, 2);
        }
        if (cfunc->flag == (METH_FASTCALL | METH_KEYWORDS))
            return __Pyx_CallCFunctionFastWithKeywords(cfunc, self, args, 2, NULL);
    }
#if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
    else if (unlikely(was_initialized == 1)) {
        __Pyx_CachedCFunction tmp_cfunc = {
#ifndef __cplusplus
            0
#endif
        };
        tmp_cfunc.type = cfunc->type;
        tmp_cfunc.method_name = cfunc->method_name;
        return __Pyx__CallUnboundCMethod2(&tmp_cfunc, self, arg1, arg2);
    }
#endif
    PyObject *result = __Pyx__CallUnboundCMethod2(cfunc, self, arg1, arg2);
    __Pyx_CachedCFunction_SetFinishedInitializing(cfunc);
    return result;
}
#endif
static PyObject* __Pyx__CallUnboundCMethod2(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg1, PyObject* arg2){
    if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
#if CYTHON_COMPILING_IN_CPYTHON
    if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
        PyObject *result = NULL;
        PyObject *args = PyTuple_New(2);
        if (unlikely(!args)) return NULL;
        Py_INCREF(arg1);
        PyTuple_SET_ITEM(args, 0, arg1);
        Py_INCREF(arg2);
        PyTuple_SET_ITEM(args, 1, arg2);
        if (cfunc->flag & METH_KEYWORDS)
            result = __Pyx_CallCFunctionWithKeywords(cfunc, self, args, NULL);
        else
            result = __Pyx_CallCFunction(cfunc, self, args);
        Py_DECREF(args);
        return result;
    }
#endif
    {
        PyObject *args[4] = {NULL, self, arg1, arg2};
        return __Pyx_PyObject_FastCall(cfunc->method, args+1, 3 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
    }
}

/* ParseKeywordsImpl (used by ParseKeywords) */
static int __Pyx_ValidateDuplicatePosArgs(
    PyObject *kwds,
    PyObject ** const argnames[],
    PyObject ** const *first_kw_arg,
    const char* function_name)
{
    PyObject ** const *name = argnames;
    while (name != first_kw_arg) {
        PyObject *key = **name;
        int found = PyDict_Contains(kwds, key);
        if (unlikely(found)) {
            if (found == 1) __Pyx_RaiseDoubleKeywordsError(function_name, key);
            goto bad;
        }
        name++;
    }
    return 0;
bad:
    return -1;
}
#if CYTHON_USE_UNICODE_INTERNALS
static CYTHON_INLINE int __Pyx_UnicodeKeywordsEqual(PyObject *s1, PyObject *s2) {
    int kind;
    Py_ssize_t len = PyUnicode_GET_LENGTH(s1);
    if (len != PyUnicode_GET_LENGTH(s2)) return 0;
    kind = PyUnicode_KIND(s1);
    if (kind != PyUnicode_KIND(s2)) return 0;
    const void *data1 = PyUnicode_DATA(s1);
    const void *data2 = PyUnicode_DATA(s2);
    return (memcmp(data1, data2, (size_t) len * (size_t) kind) == 0);
}
#endif
static int __Pyx_MatchKeywordArg_str(
    PyObject *key,
    PyObject ** const argnames[],
    PyObject ** const *first_kw_arg,
    size_t *index_found,
    const char *function_name)
{
    PyObject ** const *name;
    #if CYTHON_USE_UNICODE_INTERNALS
    Py_hash_t key_hash = ((PyASCIIObject*)key)->hash;
    if (unlikely(key_hash == -1)) {
        key_hash = PyObject_Hash(key);
        if (unlikely(key_hash == -1))
            goto bad;
    }
    #endif
    name = first_kw_arg;
    while (*name) {
        PyObject *name_str = **name;
        #if CYTHON_USE_UNICODE_INTERNALS
        if (key_hash == ((PyASCIIObject*)name_str)->hash && __Pyx_UnicodeKeywordsEqual(name_str, key)) {
            *index_found = (size_t) (name - argnames);
            return 1;
        }
        #else
        #if CYTHON_ASSUME_SAFE_SIZE
        if (PyUnicode_GET_LENGTH(name_str) == PyUnicode_GET_LENGTH(key))
        #endif
        {
            int cmp = PyUnicode_Compare(name_str, key);
            if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
            if (cmp == 0) {
                *index_found = (size_t) (name - argnames);
                return 1;
            }
        }
        #endif
        name++;
    }
    name = argnames;
    while (name != first_kw_arg) {
        PyObject *name_str = **name;
        #if CYTHON_USE_UNICODE_INTERNALS
        if (unlikely(key_hash == ((PyASCIIObject*)name_str)->hash)) {
            if (__Pyx_UnicodeKeywordsEqual(name_str, key))
                goto arg_passed_twice;
        }
        #else
        #if CYTHON_ASSUME_SAFE_SIZE
        if (PyUnicode_GET_LENGTH(name_str) == PyUnicode_GET_LENGTH(key))
        #endif
        {
            if (unlikely(name_str == key)) goto arg_passed_twice;
            int cmp = PyUnicode_Compare(name_str, key);
            if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
            if (cmp == 0) goto arg_passed_twice;
        }
        #endif
        name++;
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
bad:
    return -1;
}
static int __Pyx_MatchKeywordArg_nostr(
    PyObject *key,
    PyObject ** const argnames[],
    PyObject ** const *first_kw_arg,
    size_t *index_found,
    const char *function_name)
{
    PyObject ** const *name;
    if (unlikely(!PyUnicode_Check(key))) goto invalid_keyword_type;
    name = first_kw_arg;
    while (*name) {
        int cmp = PyObject_RichCompareBool(**name, key, Py_EQ);
        if (cmp == 1) {
            *index_found = (size_t) (name - argnames);
            return 1;
        }
        if (unlikely(cmp == -1)) goto bad;
        name++;
    }
    name = argnames;
    while (name != first_kw_arg) {
        int cmp = PyObject_RichCompareBool(**name, key, Py_EQ);
        if (unlikely(cmp != 0)) {
            if (cmp == 1) goto arg_passed_twice;
            else goto bad;
        }
        name++;
    }
    return 0;
arg_passed_twice:
    __Pyx_RaiseDoubleKeywordsError(function_name, key);
    goto bad;
invalid_keyword_type:
    PyErr_Format(PyExc_TypeError,
        "%.200s() keywords must be strings", function_name);
    goto bad;
bad:
    return -1;
}
static CYTHON_INLINE int __Pyx_MatchKeywordArg(
    PyObject *key,
    PyObject ** const argnames[],
    PyObject ** const *first_kw_arg,
    size_t *index_found,
    const char *function_name)
{
    return likely(PyUnicode_CheckExact(key)) ?
        __Pyx_MatchKeywordArg_str(key, argnames, first_kw_arg, index_found, function_name) :
        __Pyx_MatchKeywordArg_nostr(key, argnames, first_kw_arg, index_found, function_name);
}
static void __Pyx_RejectUnknownKeyword(
    PyObject *kwds,
    PyObject ** const argnames[],
    PyObject ** const *first_kw_arg,
    const char *function_name)
{
    #if CYTHON_AVOID_BORROWED_REFS
    PyObject *pos = NULL;
    #else
    Py_ssize_t pos = 0;
    #endif
    PyObject *key = NULL;
    __Pyx_BEGIN_CRITICAL_SECTION(kwds);
    while (
        #if CYTHON_AVOID_BORROWED_REFS
        __Pyx_PyDict_NextRef(kwds, &pos, &key, NULL)
        #else
        PyDict_Next(kwds, &pos, &key, NULL)
        #endif
    ) {
        PyObject** const *name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (!*name) {
            size_t index_found = 0;
            int cmp = __Pyx_MatchKeywordArg(key, argnames, first_kw_arg, &index_found, function_name);
            if (cmp != 1) {
                if (cmp == 0) {
                    PyErr_Format(PyExc_TypeError,
                        "%s() got an unexpected keyword argument '%U'",
                        function_name, key);
                }
                #if CYTHON_AVOID_BORROWED_REFS
                Py_DECREF(key);
                #endif
                break;
            }
        }
        #if CYTHON_AVOID_BORROWED_REFS
        Py_DECREF(key);
        #endif
    }
    __Pyx_END_CRITICAL_SECTION();
    #if CYTHON_AVOID_BORROWED_REFS
    Py_XDECREF(pos);
    #endif
    assert(PyErr_Occurred());
}
static int __Pyx_ParseKeywordDict(
    PyObject *kwds,
    PyObject ** const argnames[],
    PyObject *values[],
    Py_ssize_t num_pos_args,
    Py_ssize_t num_kwargs,
    const char* function_name,
    int ignore_unknown_kwargs)
{
    PyObject** const *name;
    PyObject** const *first_kw_arg = argnames + num_pos_args;
    Py_ssize_t extracted = 0;
#if !CYTHON_COMPILING_IN_PYPY || defined(PyArg_ValidateKeywordArguments)
    if (unlikely(!PyArg_ValidateKeywordArguments(kwds))) return -1;
#endif
    name = first_kw_arg;
    while (*name && num_kwargs > extracted) {
        PyObject * key = **name;
        PyObject *value;
        int found = 0;
        #if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
        found = PyDict_GetItemRef(kwds, key, &value);
        #else
        value = PyDict_GetItemWithError(kwds, key);
        if (value) {
            Py_INCREF(value);
            found = 1;
        } else {
            if (unlikely(PyErr_Occurred())) goto bad;
        }
        #endif
        if (found) {
            if (unlikely(found < 0)) goto bad;
            values[name-argnames] = value;
            extracted++;
        }
        name++;
    }
    if (num_kwargs > extracted) {
        if (ignore_unknown_kwargs) {
            if (unlikely(__Pyx_ValidateDuplicatePosArgs(kwds, argnames, first_kw_arg, function_name) == -1))
                goto bad;
        } else {
            __Pyx_RejectUnknownKeyword(kwds, argnames, first_kw_arg, function_name);
            goto bad;
        }
    }
    return 0;
bad:
    return -1;
}
static int __Pyx_ParseKeywordDictToDict(
    PyObject *kwds,
    PyObject ** const argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    const char* function_name)
{
    PyObject** const *name;
    PyObject** const *first_kw_arg = argnames + num_pos_args;
    Py_ssize_t len;
#if !CYTHON_COMPILING_IN_PYPY || defined(PyArg_ValidateKeywordArguments)
    if (unlikely(!PyArg_ValidateKeywordArguments(kwds))) return -1;
#endif
    if (PyDict_Update(kwds2, kwds) < 0) goto bad;
    name = first_kw_arg;
    while (*name) {
        PyObject *key = **name;
        PyObject *value;
#if !CYTHON_COMPILING_IN_LIMITED_API && (PY_VERSION_HEX >= 0x030d00A2 || defined(PyDict_Pop))
        int found = PyDict_Pop(kwds2, key, &value);
        if (found) {
            if (unlikely(found < 0)) goto bad;
            values[name-argnames] = value;
        }
#elif __PYX_LIMITED_VERSION_HEX >= 0x030d0000
        int found = PyDict_GetItemRef(kwds2, key, &value);
        if (found) {
            if (unlikely(found < 0)) goto bad;
            values[name-argnames] = value;
            if (unlikely(PyDict_DelItem(kwds2, key) < 0)) goto bad;
        }
#else
    #if CYTHON_COMPILING_IN_CPYTHON
        value = _PyDict_Pop(kwds2, key, kwds2);
    #else
        value = __Pyx_CallUnboundCMethod2(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_pop, kwds2, key, kwds2);
    #endif
        if (value == kwds2) {
            Py_DECREF(value);
        } else {
            if (unlikely(!value)) goto bad;
            values[name-argnames] = value;
        }
#endif
        name++;
    }
    len = PyDict_Size(kwds2);
    if (len > 0) {
        return __Pyx_ValidateDuplicatePosArgs(kwds, argnames, first_kw_arg, function_name);
    } else if (unlikely(len == -1)) {
        goto bad;
    }
    return 0;
bad:
    return -1;
}
static int __Pyx_ParseKeywordsTuple(
    PyObject *kwds,
    PyObject * const *kwvalues,
    PyObject ** const argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    Py_ssize_t num_kwargs,
    const char* function_name,
    int ignore_unknown_kwargs)
{
    PyObject *key = NULL;
    PyObject** const * name;
    PyObject** const *first_kw_arg = argnames + num_pos_args;
    for (Py_ssize_t pos = 0; pos < num_kwargs; pos++) {
#if CYTHON_AVOID_BORROWED_REFS
        key = __Pyx_PySequence_ITEM(kwds, pos);
#else
        key = __Pyx_PyTuple_GET_ITEM(kwds, pos);
#endif
#if !CYTHON_ASSUME_SAFE_MACROS
        if (unlikely(!key)) goto bad;
#endif
        name = first_kw_arg;
        while (*name && (**name != key)) name++;
        if (*name) {
            PyObject *value = kwvalues[pos];
            values[name-argnames] = __Pyx_NewRef(value);
        } else {
            size_t index_found = 0;
            int cmp = __Pyx_MatchKeywordArg(key, argnames, first_kw_arg, &index_found, function_name);
            if (cmp == 1) {
                PyObject *value = kwvalues[pos];
                values[index_found] = __Pyx_NewRef(value);
            } else {
                if (unlikely(cmp == -1)) goto bad;
                if (kwds2) {
                    PyObject *value = kwvalues[pos];
                    if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
                } else if (!ignore_unknown_kwargs) {
                    goto invalid_keyword;
                }
            }
        }
        #if CYTHON_AVOID_BORROWED_REFS
        Py_DECREF(key);
        key = NULL;
        #endif
    }
    return 0;
invalid_keyword:
    PyErr_Format(PyExc_TypeError,
        "%s() got an unexpected keyword argument '%U'",
        function_name, key);
    goto bad;
bad:
    #if CYTHON_AVOID_BORROWED_REFS
    Py_XDECREF(key);
    #endif
    return -1;
}

/* ParseKeywords */
static int __Pyx_ParseKeywords(
    PyObject *kwds,
    PyObject * const *kwvalues,
    PyObject ** const argnames[],
    PyObject *kwds2,
    PyObject *values[],
    Py_ssize_t num_pos_args,
    Py_ssize_t num_kwargs,
    const char* function_name,
    int ignore_unknown_kwargs)
{
    if (CYTHON_METH_FASTCALL && likely(PyTuple_Check(kwds)))
        return __Pyx_ParseKeywordsTuple(kwds, kwvalues, argnames, kwds2, values, num_pos_args, num_kwargs, function_name, ignore_unknown_kwargs);
    else if (kwds2)
        return __Pyx_ParseKeywordDictToDict(kwds, argnames, kwds2, values, num_pos_args, function_name);
    else
        return __Pyx_ParseKeywordDict(kwds, argnames, values, num_pos_args, num_kwargs, function_name, ignore_unknown_kwargs);
}

/* RaiseArgTupleInvalid */
static void __Pyx_RaiseArgtupleInvalid(
    const char* func_name,
    int exact,
    Py_ssize_t num_min,
    Py_ssize_t num_max,
    Py_ssize_t num_found)
{
    Py_ssize_t num_expected;
    const char *more_or_less;
    if (num_found < num_min) {
        num_expected = num_min;
        more_or_less = "at least";
    } else {
        num_expected = num_max;
        more_or_less = "at most";
    }
    if (exact) {
        more_or_less = "exactly";
    }
    PyErr_Format(PyExc_TypeError,
                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
                 func_name, more_or_less, num_expected,
                 (num_expected == 1) ? "" : "s", num_found);
}

/* GetTopmostException (used by SaveResetException) */
#if CYTHON_USE_EXC_INFO_STACK && CYTHON_FAST_THREAD_STATE
static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
{
    _PyErr_StackItem *exc_info = tstate->exc_info;
    while ((exc_info->exc_value == NULL || exc_info->exc_value == Py_None) &&
           exc_info->previous_item != NULL)
    {
        exc_info = exc_info->previous_item;
    }
    return exc_info;
}
#endif

/* SaveResetException */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
  #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
    _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
    PyObject *exc_value = exc_info->exc_value;
    if (exc_value == NULL || exc_value == Py_None) {
        *value = NULL;
        *type = NULL;
        *tb = NULL;
    } else {
        *value = exc_value;
        Py_INCREF(*value);
        *type = (PyObject*) Py_TYPE(exc_value);
        Py_INCREF(*type);
        *tb = PyException_GetTraceback(exc_value);
    }
  #elif CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
    *type = exc_info->exc_type;
    *value = exc_info->exc_value;
    *tb = exc_info->exc_traceback;
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
  #else
    *type = tstate->exc_type;
    *value = tstate->exc_value;
    *tb = tstate->exc_traceback;
    Py_XINCREF(*type);
    Py_XINCREF(*value);
    Py_XINCREF(*tb);
  #endif
}
static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
  #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
    _PyErr_StackItem *exc_info = tstate->exc_info;
    PyObject *tmp_value = exc_info->exc_value;
    exc_info->exc_value = value;
    Py_XDECREF(tmp_value);
    Py_XDECREF(type);
    Py_XDECREF(tb);
  #else
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    #if CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = tstate->exc_info;
    tmp_type = exc_info->exc_type;
    tmp_value = exc_info->exc_value;
    tmp_tb = exc_info->exc_traceback;
    exc_info->exc_type = type;
    exc_info->exc_value = value;
    exc_info->exc_traceback = tb;
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = type;
    tstate->exc_value = value;
    tstate->exc_traceback = tb;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
  #endif
}
#endif

/* FastTypeChecks */
#if CYTHON_COMPILING_IN_CPYTHON
static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
    while (a) {
        a = __Pyx_PyType_GetSlot(a, tp_base, PyTypeObject*);
        if (a == b)
            return 1;
    }
    return b == &PyBaseObject_Type;
}
static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
    PyObject *mro;
    if (a == b) return 1;
    mro = a->tp_mro;
    if (likely(mro)) {
        Py_ssize_t i, n;
        n = PyTuple_GET_SIZE(mro);
        for (i = 0; i < n; i++) {
            if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
                return 1;
        }
        return 0;
    }
    return __Pyx_InBases(a, b);
}
static CYTHON_INLINE int __Pyx_IsAnySubtype2(PyTypeObject *cls, PyTypeObject *a, PyTypeObject *b) {
    PyObject *mro;
    if (cls == a || cls == b) return 1;
    mro = cls->tp_mro;
    if (likely(mro)) {
        Py_ssize_t i, n;
        n = PyTuple_GET_SIZE(mro);
        for (i = 0; i < n; i++) {
            PyObject *base = PyTuple_GET_ITEM(mro, i);
            if (base == (PyObject *)a || base == (PyObject *)b)
                return 1;
        }
        return 0;
    }
    return __Pyx_InBases(cls, a) || __Pyx_InBases(cls, b);
}
static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
    if (exc_type1) {
        return __Pyx_IsAnySubtype2((PyTypeObject*)err, (PyTypeObject*)exc_type1, (PyTypeObject*)exc_type2);
    } else {
        return __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
    }
}
static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
    Py_ssize_t i, n;
    assert(PyExceptionClass_Check(exc_type));
    n = PyTuple_GET_SIZE(tuple);
    for (i=0; i<n; i++) {
        if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
    }
    for (i=0; i<n; i++) {
        PyObject *t = PyTuple_GET_ITEM(tuple, i);
        if (likely(PyExceptionClass_Check(t))) {
            if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
        } else {
        }
    }
    return 0;
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
    if (likely(err == exc_type)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        if (likely(PyExceptionClass_Check(exc_type))) {
            return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
        } else if (likely(PyTuple_Check(exc_type))) {
            return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
        } else {
        }
    }
    return PyErr_GivenExceptionMatches(err, exc_type);
}
static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
    assert(PyExceptionClass_Check(exc_type1));
    assert(PyExceptionClass_Check(exc_type2));
    if (likely(err == exc_type1 || err == exc_type2)) return 1;
    if (likely(PyExceptionClass_Check(err))) {
        return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
    }
    return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
}
#endif

/* HasAttr (used by ImportImpl) */
#if __PYX_LIMITED_VERSION_HEX < 0x030d0000
static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
    PyObject *r;
    if (unlikely(!PyUnicode_Check(n))) {
        PyErr_SetString(PyExc_TypeError,
                        "hasattr(): attribute name must be string");
        return -1;
    }
    r = __Pyx_PyObject_GetAttrStrNoError(o, n);
    if (!r) {
        return (unlikely(PyErr_Occurred())) ? -1 : 0;
    } else {
        Py_DECREF(r);
        return 1;
    }
}
#endif

/* ImportImpl (used by Import) */
static int __Pyx__Import_GetModule(PyObject *qualname, PyObject **module) {
    PyObject *imported_module = PyImport_GetModule(qualname);
    if (unlikely(!imported_module)) {
        *module = NULL;
        if (PyErr_Occurred()) {
            return -1;
        }
        return 0;
    }
    *module = imported_module;
    return 1;
}
static int __Pyx__Import_Lookup(PyObject *qualname, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject **module) {
    PyObject *imported_module;
    PyObject *top_level_package_name;
    Py_ssize_t i;
    int status, module_found;
    Py_ssize_t dot_index;
    module_found = __Pyx__Import_GetModule(qualname, &imported_module);
    if (unlikely(!module_found || module_found == -1)) {
        *module = NULL;
        return module_found;
    }
    if (imported_names) {
        for (i = 0; i < len_imported_names; i++) {
            PyObject *imported_name = imported_names[i];
#if __PYX_LIMITED_VERSION_HEX < 0x030d0000
            int has_imported_attribute = PyObject_HasAttr(imported_module, imported_name);
#else
            int has_imported_attribute = PyObject_HasAttrWithError(imported_module, imported_name);
            if (unlikely(has_imported_attribute == -1)) goto error;
#endif
            if (!has_imported_attribute) {
                goto not_found;
            }
        }
        *module = imported_module;
        return 1;
    }
    dot_index = PyUnicode_FindChar(qualname, '.', 0, PY_SSIZE_T_MAX, 1);
    if (dot_index == -1) {
        *module = imported_module;
        return 1;
    }
    if (unlikely(dot_index == -2)) goto error;
    top_level_package_name = PyUnicode_Substring(qualname, 0, dot_index);
    if (unlikely(!top_level_package_name)) goto error;
    Py_DECREF(imported_module);
    status = __Pyx__Import_GetModule(top_level_package_name, module);
    Py_DECREF(top_level_package_name);
    return status;
error:
    Py_DECREF(imported_module);
    *module = NULL;
    return -1;
not_found:
    Py_DECREF(imported_module);
    *module = NULL;
    return 0;
}
static PyObject *__Pyx__Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, PyObject *moddict, int level) {
    PyObject *module = 0;
    PyObject *empty_dict = 0;
    PyObject *from_list = 0;
    int module_found;
    if (!qualname) {
        qualname = name;
    }
    module_found = __Pyx__Import_Lookup(qualname, imported_names, len_imported_names, &module);
    if (likely(module_found == 1)) {
        return module;
    } else if (unlikely(module_found == -1)) {
        return NULL;
    }
    empty_dict = PyDict_New();
    if (unlikely(!empty_dict))
        goto bad;
    if (imported_names) {
#if CYTHON_COMPILING_IN_CPYTHON
        from_list = __Pyx_PyList_FromArray(imported_names, len_imported_names);
        if (unlikely(!from_list))
            goto bad;
#else
        from_list = PyList_New(len_imported_names);
        if (unlikely(!from_list)) goto bad;
        for (Py_ssize_t i=0; i<len_imported_names; ++i) {
            if (PyList_SetItem(from_list, i, __Pyx_NewRef(imported_names[i])) < 0) goto bad;
        }
#endif
    }
    if (level == -1) {
        const char* package_sep = strchr(__Pyx_MODULE_NAME, '.');
        if (package_sep != (0)) {
            module = PyImport_ImportModuleLevelObject(
                name, moddict, empty_dict, from_list, 1);
            if (unlikely(!module)) {
                if (unlikely(!PyErr_ExceptionMatches(PyExc_ImportError)))
                    goto bad;
                PyErr_Clear();
            }
        }
        level = 0;
    }
    if (!module) {
        module = PyImport_ImportModuleLevelObject(
            name, moddict, empty_dict, from_list, level);
    }
bad:
    Py_XDECREF(from_list);
    Py_XDECREF(empty_dict);
    return module;
}

/* Import */
static PyObject *__Pyx_Import(PyObject *name, PyObject *const *imported_names, Py_ssize_t len_imported_names, PyObject *qualname, int level) {
    return __Pyx__Import(name, imported_names, len_imported_names, qualname, __pyx_mstate_global->__pyx_d, level);
}

/* ImportFrom */
static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
        const char* module_name_str = 0;
        PyObject* module_name = 0;
        PyObject* module_dot = 0;
        PyObject* full_name = 0;
        PyErr_Clear();
        module_name_str = PyModule_GetName(module);
        if (unlikely(!module_name_str)) { goto modbad; }
        module_name = PyUnicode_FromString(module_name_str);
        if (unlikely(!module_name)) { goto modbad; }
        module_dot = PyUnicode_Concat(module_name, __pyx_mstate_global->__pyx_kp_u_);
        if (unlikely(!module_dot)) { goto modbad; }
        full_name = PyUnicode_Concat(module_dot, name);
        if (unlikely(!full_name)) { goto modbad; }
        #if (CYTHON_COMPILING_IN_PYPY && PYPY_VERSION_NUM  < 0x07030400) ||\
                CYTHON_COMPILING_IN_GRAAL
        {
            PyObject *modules = PyImport_GetModuleDict();
            if (unlikely(!modules))
                goto modbad;
            value = PyObject_GetItem(modules, full_name);
        }
        #else
        value = PyImport_GetModule(full_name);
        #endif
      modbad:
        Py_XDECREF(full_name);
        Py_XDECREF(module_dot);
        Py_XDECREF(module_name);
    }
    if (unlikely(!value)) {
        PyErr_Format(PyExc_ImportError, "cannot import name %S", name);
    }
    return value;
}

/* pybuiltin_invalid (used by pyint_simplify) */
static void __Pyx_PyBuiltin_Invalid(PyObject *obj, const char *type_name, const char *argname) {
    __Pyx_TypeName obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj));
    if (argname) {
        PyErr_Format(PyExc_TypeError,
            "Argument '%.200s' has incorrect type (expected %.200s, got " __Pyx_FMT_TYPENAME ")",
            argname, type_name, obj_type_name
        );
    } else {
        PyErr_Format(PyExc_TypeError,
            "Expected %.200s, got " __Pyx_FMT_TYPENAME,
            type_name, obj_type_name
        );
    }
    __Pyx_DECREF_TypeName(obj_type_name);
}

/* pyint_simplify */
static CYTHON_INLINE int __Pyx_PyInt_FromNumber(PyObject **number_var, const char *argname, int accept_none) {
    PyObject *number = *number_var;
    if (likely((accept_none && number == Py_None) || PyLong_CheckExact(number))) {
        return 0;
    }
    PyObject *int_object;
    if (likely(PyNumber_Check(number))) {
        int_object = PyNumber_Long(number);
        if (unlikely(!int_object)) goto bad;
    } else {
        __Pyx_PyBuiltin_Invalid(number, "int", argname);
        goto bad;
    }
    *number_var = int_object;
    Py_DECREF(number);
    return 0;
bad:
    *number_var = NULL;
    Py_DECREF(number);
    return -1;
}

/* ArgTypeTestFunc (used by ArgTypeTest) */
static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact)
{
    __Pyx_TypeName type_name;
    __Pyx_TypeName obj_type_name;
    PyObject *extra_info = __pyx_mstate_global->__pyx_empty_unicode;
    int from_annotation_subclass = 0;
    if (unlikely(!type)) {
        PyErr_SetString(PyExc_SystemError, "Missing type object");
        return 0;
    }
    else if (!exact) {
        if (likely(__Pyx_TypeCheck(obj, type))) return 1;
    } else if (exact == 2) {
        if (__Pyx_TypeCheck(obj, type)) {
            from_annotation_subclass = 1;
            extra_info = __pyx_mstate_global->__pyx_kp_u_Note_that_Cython_is_deliberately;
        }
    }
    type_name = __Pyx_PyType_GetFullyQualifiedName(type);
    obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj));
    PyErr_Format(PyExc_TypeError,
        "Argument '%.200s' has incorrect type (expected " __Pyx_FMT_TYPENAME
        ", got " __Pyx_FMT_TYPENAME ")"
#if __PYX_LIMITED_VERSION_HEX < 0x030C0000
        "%s%U"
#endif
        , name, type_name, obj_type_name
#if __PYX_LIMITED_VERSION_HEX < 0x030C0000
        , (from_annotation_subclass ? ". " : ""), extra_info
#endif
        );
#if __PYX_LIMITED_VERSION_HEX >= 0x030C0000
    if (exact == 2 && from_annotation_subclass) {
        PyObject *res;
        PyObject *vargs[2];
        vargs[0] = PyErr_GetRaisedException();
        vargs[1] = extra_info;
        res = PyObject_VectorcallMethod(__pyx_mstate_global->__pyx_kp_u_add_note, vargs, 2, NULL);
        Py_XDECREF(res);
        PyErr_SetRaisedException(vargs[0]);
    }
#endif
    __Pyx_DECREF_TypeName(type_name);
    __Pyx_DECREF_TypeName(obj_type_name);
    return 0;
}

/* PyObjectSetAttrStr */
#if CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
    PyTypeObject* tp = Py_TYPE(obj);
    if (likely(tp->tp_setattro))
        return tp->tp_setattro(obj, attr_name, value);
    return PyObject_SetAttr(obj, attr_name, value);
}
#endif

/* PyDictVersioning (used by GetModuleGlobalName) */
#if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
}
static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
    PyObject **dictptr = NULL;
    Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
    if (offset) {
#if CYTHON_COMPILING_IN_CPYTHON
        dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
#else
        dictptr = _PyObject_GetDictPtr(obj);
#endif
    }
    return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
}
static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
    PyObject *dict = Py_TYPE(obj)->tp_dict;
    if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
        return 0;
    return obj_dict_version == __Pyx_get_object_dict_version(obj);
}
#endif

/* GetModuleGlobalName */
#if CYTHON_USE_DICT_VERSIONS
static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
#else
static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
#endif
{
    PyObject *result;
#if CYTHON_COMPILING_IN_LIMITED_API
    if (unlikely(!__pyx_m)) {
        if (!PyErr_Occurred())
            PyErr_SetNone(PyExc_NameError);
        return NULL;
    }
    result = PyObject_GetAttr(__pyx_m, name);
    if (likely(result)) {
        return result;
    }
    PyErr_Clear();
#elif CYTHON_AVOID_BORROWED_REFS || CYTHON_AVOID_THREAD_UNSAFE_BORROWED_REFS
    if (unlikely(__Pyx_PyDict_GetItemRef(__pyx_mstate_global->__pyx_d, name, &result) == -1)) PyErr_Clear();
    __PYX_UPDATE_DICT_CACHE(__pyx_mstate_global->__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return result;
    }
#else
    result = _PyDict_GetItem_KnownHash(__pyx_mstate_global->__pyx_d, name, ((PyASCIIObject *) name)->hash);
    __PYX_UPDATE_DICT_CACHE(__pyx_mstate_global->__pyx_d, result, *dict_cached_value, *dict_version)
    if (likely(result)) {
        return __Pyx_NewRef(result);
    }
    PyErr_Clear();
#endif
    return __Pyx_GetBuiltinName(name);
}

/* PyLongBinop */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_Fallback___Pyx_PyLong_TrueDivideObjC(PyObject *op1, PyObject *op2, int inplace) {
    return (inplace ? PyNumber_InPlaceTrueDivide : PyNumber_TrueDivide)(op1, op2);
}
#if CYTHON_USE_PYLONG_INTERNALS
static PyObject* __Pyx_Unpacked___Pyx_PyLong_TrueDivideObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) {
    CYTHON_MAYBE_UNUSED_VAR(inplace);
    CYTHON_UNUSED_VAR(zerodivision_check);
    const long b = intval;
    long a;
    if (unlikely(__Pyx_PyLong_IsZero(op1))) {
    }
    const int is_positive = __Pyx_PyLong_IsPos(op1);
    const digit* digits = __Pyx_PyLong_Digits(op1);
    const Py_ssize_t size = __Pyx_PyLong_DigitCount(op1);
    if (likely(size == 1)) {
        a = (long) digits[0];
        if (!is_positive) a *= -1;
    } else {
        switch (size) {
            case 2:
                if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT && 1 * PyLong_SHIFT < 53) {
                    a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if (!is_positive) a *= -1;
                    goto calculate_long;
                }
                break;
            case 3:
                if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT && 2 * PyLong_SHIFT < 53) {
                    a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if (!is_positive) a *= -1;
                    goto calculate_long;
                }
                break;
            case 4:
                if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT && 3 * PyLong_SHIFT < 53) {
                    a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if (!is_positive) a *= -1;
                    goto calculate_long;
                }
                break;
        }
        return PyLong_Type.tp_as_number->nb_true_divide(op1, op2);
    }
    calculate_long:
        if ((8 * sizeof(long) <= 53 || likely(labs(a) <= ((PY_LONG_LONG)1 << 53)))
                || __Pyx_PyLong_DigitCount(op1) <= 52 / PyLong_SHIFT) {
            return PyFloat_FromDouble((double)a / (double)b);
        }
        return PyLong_Type.tp_as_number->nb_true_divide(op1, op2);
}
#endif
static PyObject* __Pyx_Float___Pyx_PyLong_TrueDivideObjC(PyObject *float_val, long intval, int zerodivision_check) {
    CYTHON_UNUSED_VAR(zerodivision_check);
    const long b = intval;
    double a = __Pyx_PyFloat_AS_DOUBLE(float_val);
        double result;
        
        result = ((double)a) / (double)b;
        return PyFloat_FromDouble(result);
}
static CYTHON_INLINE PyObject* __Pyx_PyLong_TrueDivideObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) {
    CYTHON_MAYBE_UNUSED_VAR(intval);
    CYTHON_UNUSED_VAR(zerodivision_check);
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        return __Pyx_Unpacked___Pyx_PyLong_TrueDivideObjC(op1, op2, intval, inplace, zerodivision_check);
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        return __Pyx_Float___Pyx_PyLong_TrueDivideObjC(op1, intval, zerodivision_check);
    }
    return __Pyx_Fallback___Pyx_PyLong_TrueDivideObjC(op1, op2, inplace);
}
#endif

/* PyLongBinop */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_Fallback___Pyx_PyLong_MultiplyObjC(PyObject *op1, PyObject *op2, int inplace) {
    return (inplace ? PyNumber_InPlaceMultiply : PyNumber_Multiply)(op1, op2);
}
#if CYTHON_USE_PYLONG_INTERNALS
static PyObject* __Pyx_Unpacked___Pyx_PyLong_MultiplyObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) {
    CYTHON_MAYBE_UNUSED_VAR(inplace);
    CYTHON_UNUSED_VAR(zerodivision_check);
    const long b = intval;
    long a;
    const PY_LONG_LONG llb = intval;
    PY_LONG_LONG lla;
    if (unlikely(__Pyx_PyLong_IsZero(op1))) {
        return __Pyx_NewRef(op1);
    }
    const int is_positive = __Pyx_PyLong_IsPos(op1);
    const digit* digits = __Pyx_PyLong_Digits(op1);
    const Py_ssize_t size = __Pyx_PyLong_DigitCount(op1);
    if (likely(size == 1)) {
        a = (long) digits[0];
        if (!is_positive) a *= -1;
    } else {
        switch (size) {
            case 2:
                if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT+30) {
                    a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if (!is_positive) a *= -1;
                    goto calculate_long;
                } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT+30) {
                    lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                    if (!is_positive) lla *= -1;
                    goto calculate_long_long;
                }
                break;
            case 3:
                if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT+30) {
                    a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if (!is_positive) a *= -1;
                    goto calculate_long;
                } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT+30) {
                    lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                    if (!is_positive) lla *= -1;
                    goto calculate_long_long;
                }
                break;
            case 4:
                if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT+30) {
                    a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if (!is_positive) a *= -1;
                    goto calculate_long;
                } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT+30) {
                    lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                    if (!is_positive) lla *= -1;
                    goto calculate_long_long;
                }
                break;
        }
        return PyLong_Type.tp_as_number->nb_multiply(op1, op2);
    }
    calculate_long:
        CYTHON_UNUSED_VAR(a);
        CYTHON_UNUSED_VAR(b);
        lla = a;
        goto calculate_long_long;
    calculate_long_long:
        {
            PY_LONG_LONG llx;
            llx = lla * llb;
            return PyLong_FromLongLong(llx);
        }
    
}
#endif
static PyObject* __Pyx_Float___Pyx_PyLong_MultiplyObjC(PyObject *float_val, long intval, int zerodivision_check) {
    CYTHON_UNUSED_VAR(zerodivision_check);
    const long b = intval;
    double a = __Pyx_PyFloat_AS_DOUBLE(float_val);
        double result;
        
        result = ((double)a) * (double)b;
        return PyFloat_FromDouble(result);
}
static CYTHON_INLINE PyObject* __Pyx_PyLong_MultiplyObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) {
    CYTHON_MAYBE_UNUSED_VAR(intval);
    CYTHON_UNUSED_VAR(zerodivision_check);
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        return __Pyx_Unpacked___Pyx_PyLong_MultiplyObjC(op1, op2, intval, inplace, zerodivision_check);
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        return __Pyx_Float___Pyx_PyLong_MultiplyObjC(op1, intval, zerodivision_check);
    }
    return __Pyx_Fallback___Pyx_PyLong_MultiplyObjC(op1, op2, inplace);
}
#endif

/* PyObjectFastCallMethod */
#if !CYTHON_VECTORCALL || PY_VERSION_HEX < 0x03090000
static PyObject *__Pyx_PyObject_FastCallMethod(PyObject *name, PyObject *const *args, size_t nargsf) {
    PyObject *result;
    PyObject *attr = PyObject_GetAttr(args[0], name);
    if (unlikely(!attr))
        return NULL;
    result = __Pyx_PyObject_FastCall(attr, args+1, nargsf - 1);
    Py_DECREF(attr);
    return result;
}
#endif

/* GetException */
#if CYTHON_FAST_THREAD_STATE
static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
#else
static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
#endif
{
    PyObject *local_type = NULL, *local_value, *local_tb = NULL;
#if CYTHON_FAST_THREAD_STATE
    PyObject *tmp_type, *tmp_value, *tmp_tb;
  #if PY_VERSION_HEX >= 0x030C0000
    local_value = tstate->current_exception;
    tstate->current_exception = 0;
  #else
    local_type = tstate->curexc_type;
    local_value = tstate->curexc_value;
    local_tb = tstate->curexc_traceback;
    tstate->curexc_type = 0;
    tstate->curexc_value = 0;
    tstate->curexc_traceback = 0;
  #endif
#elif __PYX_LIMITED_VERSION_HEX >= 0x030C0000
    local_value = PyErr_GetRaisedException();
#else
    PyErr_Fetch(&local_type, &local_value, &local_tb);
#endif
#if __PYX_LIMITED_VERSION_HEX >= 0x030C0000
    if (likely(local_value)) {
        local_type = (PyObject*) Py_TYPE(local_value);
        Py_INCREF(local_type);
        local_tb = PyException_GetTraceback(local_value);
    }
#else
    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
#if CYTHON_FAST_THREAD_STATE
    if (unlikely(tstate->curexc_type))
#else
    if (unlikely(PyErr_Occurred()))
#endif
        goto bad;
    if (local_tb) {
        if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
            goto bad;
    }
#endif // __PYX_LIMITED_VERSION_HEX >= 0x030C0000
    Py_XINCREF(local_tb);
    Py_XINCREF(local_type);
    Py_XINCREF(local_value);
    *type = local_type;
    *value = local_value;
    *tb = local_tb;
#if CYTHON_FAST_THREAD_STATE
    #if CYTHON_USE_EXC_INFO_STACK
    {
        _PyErr_StackItem *exc_info = tstate->exc_info;
      #if PY_VERSION_HEX >= 0x030B00a4
        tmp_value = exc_info->exc_value;
        exc_info->exc_value = local_value;
        tmp_type = NULL;
        tmp_tb = NULL;
        Py_XDECREF(local_type);
        Py_XDECREF(local_tb);
      #else
        tmp_type = exc_info->exc_type;
        tmp_value = exc_info->exc_value;
        tmp_tb = exc_info->exc_traceback;
        exc_info->exc_type = local_type;
        exc_info->exc_value = local_value;
        exc_info->exc_traceback = local_tb;
      #endif
    }
    #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = local_type;
    tstate->exc_value = local_value;
    tstate->exc_traceback = local_tb;
    #endif
    Py_XDECREF(tmp_type);
    Py_XDECREF(tmp_value);
    Py_XDECREF(tmp_tb);
#elif __PYX_LIMITED_VERSION_HEX >= 0x030b0000
    PyErr_SetHandledException(local_value);
    Py_XDECREF(local_value);
    Py_XDECREF(local_type);
    Py_XDECREF(local_tb);
#else
    PyErr_SetExcInfo(local_type, local_value, local_tb);
#endif
    return 0;
#if __PYX_LIMITED_VERSION_HEX < 0x030C0000
bad:
    *type = 0;
    *value = 0;
    *tb = 0;
    Py_XDECREF(local_type);
    Py_XDECREF(local_value);
    Py_XDECREF(local_tb);
    return -1;
#endif
}

/* PyObjectFormatAndDecref */
static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatSimpleAndDecref(PyObject* s, PyObject* f) {
    if (unlikely(!s)) return NULL;
    if (likely(PyUnicode_CheckExact(s))) return s;
    return __Pyx_PyObject_FormatAndDecref(s, f);
}
static CYTHON_INLINE PyObject* __Pyx_PyObject_FormatAndDecref(PyObject* s, PyObject* f) {
    PyObject *result;
    if (unlikely(!s)) return NULL;
    result = PyObject_Format(s, f);
    Py_DECREF(s);
    return result;
}

/* PyObjectVectorCallKwBuilder */
#if CYTHON_VECTORCALL
static int __Pyx_VectorcallBuilder_AddArg(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) {
    (void)__Pyx_PyObject_FastCallDict;
    Py_INCREF(key);
    if (__Pyx_PyTuple_SET_ITEM(builder, n, key) != (0)) return -1;
    args[n] = value;
    return 0;
}
CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, PyObject **args, int n) {
    (void)__Pyx_VectorcallBuilder_AddArgStr;
    if (unlikely(!PyUnicode_Check(key))) {
        PyErr_SetString(PyExc_TypeError, "keywords must be strings");
        return -1;
    }
    return __Pyx_VectorcallBuilder_AddArg(key, value, builder, args, n);
}
static int __Pyx_VectorcallBuilder_AddArgStr(const char *key, PyObject *value, PyObject *builder, PyObject **args, int n) {
    PyObject *pyKey = PyUnicode_FromString(key);
    if (!pyKey) return -1;
    return __Pyx_VectorcallBuilder_AddArg(pyKey, value, builder, args, n);
}
#else // CYTHON_VECTORCALL
CYTHON_UNUSED static int __Pyx_VectorcallBuilder_AddArg_Check(PyObject *key, PyObject *value, PyObject *builder, CYTHON_UNUSED PyObject **args, CYTHON_UNUSED int n) {
    if (unlikely(!PyUnicode_Check(key))) {
        PyErr_SetString(PyExc_TypeError, "keywords must be strings");
        return -1;
    }
    return PyDict_SetItem(builder, key, value);
}
#endif

/* RaiseException */
static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
    PyObject* owned_instance = NULL;
    if (tb == Py_None) {
        tb = 0;
    } else if (tb && !PyTraceBack_Check(tb)) {
        PyErr_SetString(PyExc_TypeError,
            "raise: arg 3 must be a traceback or None");
        goto bad;
    }
    if (value == Py_None)
        value = 0;
    if (PyExceptionInstance_Check(type)) {
        if (value) {
            PyErr_SetString(PyExc_TypeError,
                "instance exception may not have a separate value");
            goto bad;
        }
        value = type;
        type = (PyObject*) Py_TYPE(value);
    } else if (PyExceptionClass_Check(type)) {
        PyObject *instance_class = NULL;
        if (value && PyExceptionInstance_Check(value)) {
            instance_class = (PyObject*) Py_TYPE(value);
            if (instance_class != type) {
                int is_subclass = PyObject_IsSubclass(instance_class, type);
                if (!is_subclass) {
                    instance_class = NULL;
                } else if (unlikely(is_subclass == -1)) {
                    goto bad;
                } else {
                    type = instance_class;
                }
            }
        }
        if (!instance_class) {
            PyObject *args;
            if (!value)
                args = PyTuple_New(0);
            else if (PyTuple_Check(value)) {
                Py_INCREF(value);
                args = value;
            } else
                args = PyTuple_Pack(1, value);
            if (!args)
                goto bad;
            owned_instance = PyObject_Call(type, args, NULL);
            Py_DECREF(args);
            if (!owned_instance)
                goto bad;
            value = owned_instance;
            if (!PyExceptionInstance_Check(value)) {
                PyErr_Format(PyExc_TypeError,
                             "calling %R should have returned an instance of "
                             "BaseException, not %R",
                             type, Py_TYPE(value));
                goto bad;
            }
        }
    } else {
        PyErr_SetString(PyExc_TypeError,
            "raise: exception class must be a subclass of BaseException");
        goto bad;
    }
    if (cause) {
        PyObject *fixed_cause;
        if (cause == Py_None) {
            fixed_cause = NULL;
        } else if (PyExceptionClass_Check(cause)) {
            fixed_cause = PyObject_CallObject(cause, NULL);
            if (fixed_cause == NULL)
                goto bad;
        } else if (PyExceptionInstance_Check(cause)) {
            fixed_cause = cause;
            Py_INCREF(fixed_cause);
        } else {
            PyErr_SetString(PyExc_TypeError,
                            "exception causes must derive from "
                            "BaseException");
            goto bad;
        }
        PyException_SetCause(value, fixed_cause);
    }
    PyErr_SetObject(type, value);
    if (tb) {
#if PY_VERSION_HEX >= 0x030C00A6
        PyException_SetTraceback(value, tb);
#elif CYTHON_FAST_THREAD_STATE
        PyThreadState *tstate = __Pyx_PyThreadState_Current;
        PyObject* tmp_tb = tstate->curexc_traceback;
        if (tb != tmp_tb) {
            Py_INCREF(tb);
            tstate->curexc_traceback = tb;
            Py_XDECREF(tmp_tb);
        }
#else
        PyObject *tmp_type, *tmp_value, *tmp_tb;
        PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
        Py_INCREF(tb);
        PyErr_Restore(tmp_type, tmp_value, tb);
        Py_XDECREF(tmp_tb);
#endif
    }
bad:
    Py_XDECREF(owned_instance);
    return;
}

/* SwapException */
#if CYTHON_FAST_THREAD_STATE
static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
  #if CYTHON_USE_EXC_INFO_STACK && PY_VERSION_HEX >= 0x030B00a4
    _PyErr_StackItem *exc_info = tstate->exc_info;
    tmp_value = exc_info->exc_value;
    exc_info->exc_value = *value;
    if (tmp_value == NULL || tmp_value == Py_None) {
        Py_XDECREF(tmp_value);
        tmp_value = NULL;
        tmp_type = NULL;
        tmp_tb = NULL;
    } else {
        tmp_type = (PyObject*) Py_TYPE(tmp_value);
        Py_INCREF(tmp_type);
        #if CYTHON_COMPILING_IN_CPYTHON
        tmp_tb = ((PyBaseExceptionObject*) tmp_value)->traceback;
        Py_XINCREF(tmp_tb);
        #else
        tmp_tb = PyException_GetTraceback(tmp_value);
        #endif
    }
  #elif CYTHON_USE_EXC_INFO_STACK
    _PyErr_StackItem *exc_info = tstate->exc_info;
    tmp_type = exc_info->exc_type;
    tmp_value = exc_info->exc_value;
    tmp_tb = exc_info->exc_traceback;
    exc_info->exc_type = *type;
    exc_info->exc_value = *value;
    exc_info->exc_traceback = *tb;
  #else
    tmp_type = tstate->exc_type;
    tmp_value = tstate->exc_value;
    tmp_tb = tstate->exc_traceback;
    tstate->exc_type = *type;
    tstate->exc_value = *value;
    tstate->exc_traceback = *tb;
  #endif
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}
#else
static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
    PyObject *tmp_type, *tmp_value, *tmp_tb;
    PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
    PyErr_SetExcInfo(*type, *value, *tb);
    *type = tmp_type;
    *value = tmp_value;
    *tb = tmp_tb;
}
#endif

/* PyLongCompare */
static CYTHON_INLINE int __Pyx_PyLong_BoolNeObjC(PyObject *op1, PyObject *op2, long intval, long inplace) {
    CYTHON_MAYBE_UNUSED_VAR(intval);
    CYTHON_UNUSED_VAR(inplace);
    if (op1 == op2) {
        return 0;
    }
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        int unequal;
        unsigned long uintval;
        Py_ssize_t size = __Pyx_PyLong_DigitCount(op1);
        const digit* digits = __Pyx_PyLong_Digits(op1);
        if (intval == 0) {
            return (__Pyx_PyLong_IsZero(op1) != 1);
        } else if (intval < 0) {
            if (__Pyx_PyLong_IsNonNeg(op1))
                return 1;
            intval = -intval;
        } else {
            if (__Pyx_PyLong_IsNeg(op1))
                return 1;
        }
        uintval = (unsigned long) intval;
#if PyLong_SHIFT * 4 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 4)) {
            unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 3 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 3)) {
            unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 2 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 2)) {
            unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
#if PyLong_SHIFT * 1 < SIZEOF_LONG*8
        if (uintval >> (PyLong_SHIFT * 1)) {
            unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
        } else
#endif
            unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
        return (unequal != 0);
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        const long b = intval;
        double a = __Pyx_PyFloat_AS_DOUBLE(op1);
        return ((double)a != (double)b);
    }
    return __Pyx_PyObject_IsTrueAndDecref(
        PyObject_RichCompare(op1, op2, Py_NE));
}

/* PyLongBinop */
#if !CYTHON_COMPILING_IN_PYPY
static PyObject* __Pyx_Fallback___Pyx_PyLong_AddObjC(PyObject *op1, PyObject *op2, int inplace) {
    return (inplace ? PyNumber_InPlaceAdd : PyNumber_Add)(op1, op2);
}
#if CYTHON_USE_PYLONG_INTERNALS
static PyObject* __Pyx_Unpacked___Pyx_PyLong_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) {
    CYTHON_MAYBE_UNUSED_VAR(inplace);
    CYTHON_UNUSED_VAR(zerodivision_check);
    const long b = intval;
    long a;
    const PY_LONG_LONG llb = intval;
    PY_LONG_LONG lla;
    if (unlikely(__Pyx_PyLong_IsZero(op1))) {
        return __Pyx_NewRef(op2);
    }
    const int is_positive = __Pyx_PyLong_IsPos(op1);
    const digit* digits = __Pyx_PyLong_Digits(op1);
    const Py_ssize_t size = __Pyx_PyLong_DigitCount(op1);
    if (likely(size == 1)) {
        a = (long) digits[0];
        if (!is_positive) a *= -1;
    } else {
        switch (size) {
            case 2:
                if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                    a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if (!is_positive) a *= -1;
                    goto calculate_long;
                } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                    lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                    if (!is_positive) lla *= -1;
                    goto calculate_long_long;
                }
                break;
            case 3:
                if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                    a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if (!is_positive) a *= -1;
                    goto calculate_long;
                } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                    lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                    if (!is_positive) lla *= -1;
                    goto calculate_long_long;
                }
                break;
            case 4:
                if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                    a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                    if (!is_positive) a *= -1;
                    goto calculate_long;
                } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                    lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                    if (!is_positive) lla *= -1;
                    goto calculate_long_long;
                }
                break;
        }
        return PyLong_Type.tp_as_number->nb_add(op1, op2);
    }
    calculate_long:
        {
            long x;
            x = a + b;
            return PyLong_FromLong(x);
        }
    calculate_long_long:
        {
            PY_LONG_LONG llx;
            llx = lla + llb;
            return PyLong_FromLongLong(llx);
        }
    
}
#endif
static PyObject* __Pyx_Float___Pyx_PyLong_AddObjC(PyObject *float_val, long intval, int zerodivision_check) {
    CYTHON_UNUSED_VAR(zerodivision_check);
    const long b = intval;
    double a = __Pyx_PyFloat_AS_DOUBLE(float_val);
        double result;
        
        result = ((double)a) + (double)b;
        return PyFloat_FromDouble(result);
}
static CYTHON_INLINE PyObject* __Pyx_PyLong_AddObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) {
    CYTHON_MAYBE_UNUSED_VAR(intval);
    CYTHON_UNUSED_VAR(zerodivision_check);
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(PyLong_CheckExact(op1))) {
        return __Pyx_Unpacked___Pyx_PyLong_AddObjC(op1, op2, intval, inplace, zerodivision_check);
    }
    #endif
    if (PyFloat_CheckExact(op1)) {
        return __Pyx_Float___Pyx_PyLong_AddObjC(op1, intval, zerodivision_check);
    }
    return __Pyx_Fallback___Pyx_PyLong_AddObjC(op1, op2, inplace);
}
#endif

/* PyObjectVectorCallMethodKwBuilder */
#if !CYTHON_VECTORCALL || PY_VERSION_HEX < 0x03090000
static PyObject *__Pyx_Object_VectorcallMethod_CallFromBuilder(PyObject *name, PyObject *const *args, size_t nargsf, PyObject *kwnames) {
    PyObject *result;
    PyObject *obj = PyObject_GetAttr(args[0], name);
    if (unlikely(!obj))
        return NULL;
    result = __Pyx_Object_Vectorcall_CallFromBuilder(obj, args+1, nargsf-1, kwnames);
    Py_DECREF(obj);
    return result;
}
#endif

/* GetAttr3 */
#if __PYX_LIMITED_VERSION_HEX < 0x030d0000
static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
    __Pyx_PyThreadState_declare
    __Pyx_PyThreadState_assign
    if (unlikely(!__Pyx_PyErr_ExceptionMatches(PyExc_AttributeError)))
        return NULL;
    __Pyx_PyErr_Clear();
    Py_INCREF(d);
    return d;
}
#endif
static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, PyObject *d) {
    PyObject *r;
#if __PYX_LIMITED_VERSION_HEX >= 0x030d0000
    int res = PyObject_GetOptionalAttr(o, n, &r);
    return (res != 0) ? r : __Pyx_NewRef(d);
#else
  #if CYTHON_USE_TYPE_SLOTS
    if (likely(PyUnicode_Check(n))) {
        r = __Pyx_PyObject_GetAttrStrNoError(o, n);
        if (unlikely(!r) && likely(!PyErr_Occurred())) {
            r = __Pyx_NewRef(d);
        }
        return r;
    }
  #endif
    r = PyObject_GetAttr(o, n);
    return (likely(r)) ? r : __Pyx_GetAttr3Default(d);
#endif
}

/* PyObjectLookupSpecial */
#if CYTHON_USE_PYTYPE_LOOKUP && CYTHON_USE_TYPE_SLOTS
static CYTHON_INLINE PyObject* __Pyx__PyObject_LookupSpecial(PyObject* obj, PyObject* attr_name, int with_error) {
    PyObject *res;
    PyTypeObject *tp = Py_TYPE(obj);
    res = _PyType_Lookup(tp, attr_name);
    if (likely(res)) {
        descrgetfunc f = Py_TYPE(res)->tp_descr_get;
        if (!f) {
            Py_INCREF(res);
        } else {
            res = f(res, obj, (PyObject *)tp);
        }
    } else if (with_error) {
        PyErr_SetObject(PyExc_AttributeError, attr_name);
    }
    return res;
}
#endif

/* dict_setdefault (used by FetchCommonType) */
static CYTHON_INLINE PyObject *__Pyx_PyDict_SetDefault(PyObject *d, PyObject *key, PyObject *default_value) {
    PyObject* value;
#if __PYX_LIMITED_VERSION_HEX >= 0x030F0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4)
    PyDict_SetDefaultRef(d, key, default_value, &value);
#elif CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX >= 0x030C0000
    PyObject *args[] = {d, key, default_value};
    value = PyObject_VectorcallMethod(__pyx_mstate_global->__pyx_n_u_setdefault, args, 3 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
#elif CYTHON_COMPILING_IN_LIMITED_API
    value = PyObject_CallMethodObjArgs(d, __pyx_mstate_global->__pyx_n_u_setdefault, key, default_value, NULL);
#else
    value = PyDict_SetDefault(d, key, default_value);
    if (unlikely(!value)) return NULL;
    Py_INCREF(value);
#endif
    return value;
}

/* LimitedApiGetTypeDict (used by SetItemOnTypeDict) */
#if CYTHON_COMPILING_IN_LIMITED_API
static Py_ssize_t __Pyx_GetTypeDictOffset(void) {
    PyObject *tp_dictoffset_o;
    Py_ssize_t tp_dictoffset;
    tp_dictoffset_o = PyObject_GetAttrString((PyObject*)(&PyType_Type), "__dictoffset__");
    if (unlikely(!tp_dictoffset_o)) return -1;
    tp_dictoffset = PyLong_AsSsize_t(tp_dictoffset_o);
    Py_DECREF(tp_dictoffset_o);
    if (unlikely(tp_dictoffset == 0)) {
        PyErr_SetString(
            PyExc_TypeError,
            "'type' doesn't have a dictoffset");
        return -1;
    } else if (unlikely(tp_dictoffset < 0)) {
        PyErr_SetString(
            PyExc_TypeError,
            "'type' has an unexpected negative dictoffset. "
            "Please report this as Cython bug");
        return -1;
    }
    return tp_dictoffset;
}
static PyObject *__Pyx_GetTypeDict(PyTypeObject *tp) {
    static Py_ssize_t tp_dictoffset = 0;
    if (unlikely(tp_dictoffset == 0)) {
        tp_dictoffset = __Pyx_GetTypeDictOffset();
        if (unlikely(tp_dictoffset == -1 && PyErr_Occurred())) {
            tp_dictoffset = 0; // try again next time?
            return NULL;
        }
    }
    return *(PyObject**)((char*)tp + tp_dictoffset);
}
#endif

/* SetItemOnTypeDict (used by FixUpExtensionType) */
static int __Pyx__SetItemOnTypeDict(PyTypeObject *tp, PyObject *k, PyObject *v) {
    int result;
    PyObject *tp_dict;
#if CYTHON_COMPILING_IN_LIMITED_API
    tp_dict = __Pyx_GetTypeDict(tp);
    if (unlikely(!tp_dict)) return -1;
#else
    tp_dict = tp->tp_dict;
#endif
    result = PyDict_SetItem(tp_dict, k, v);
    if (likely(!result)) {
        PyType_Modified(tp);
        if (unlikely(PyObject_HasAttr(v, __pyx_mstate_global->__pyx_n_u_set_name))) {
            PyObject *setNameResult = PyObject_CallMethodObjArgs(v, __pyx_mstate_global->__pyx_n_u_set_name,  (PyObject *) tp, k, NULL);
            if (!setNameResult) return -1;
            Py_DECREF(setNameResult);
        }
    }
    return result;
}

/* FixUpExtensionType (used by FetchCommonType) */
static int __Pyx_fix_up_extension_type_from_spec(PyType_Spec *spec, PyTypeObject *type) {
#if __PYX_LIMITED_VERSION_HEX > 0x030900B1
    CYTHON_UNUSED_VAR(spec);
    CYTHON_UNUSED_VAR(type);
    CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict);
#else
    const PyType_Slot *slot = spec->slots;
    int changed = 0;
#if !CYTHON_COMPILING_IN_LIMITED_API
    while (slot && slot->slot && slot->slot != Py_tp_members)
        slot++;
    if (slot && slot->slot == Py_tp_members) {
#if !CYTHON_COMPILING_IN_CPYTHON
        const
#endif  // !CYTHON_COMPILING_IN_CPYTHON)
            PyMemberDef *memb = (PyMemberDef*) slot->pfunc;
        while (memb && memb->name) {
            if (memb->name[0] == '_' && memb->name[1] == '_') {
                if (strcmp(memb->name, "__weaklistoffset__") == 0) {
                    assert(memb->type == T_PYSSIZET);
                    assert(memb->flags == READONLY);
                    type->tp_weaklistoffset = memb->offset;
                    changed = 1;
                }
                else if (strcmp(memb->name, "__dictoffset__") == 0) {
                    assert(memb->type == T_PYSSIZET);
                    assert(memb->flags == READONLY);
                    type->tp_dictoffset = memb->offset;
                    changed = 1;
                }
#if CYTHON_METH_FASTCALL
                else if (strcmp(memb->name, "__vectorcalloffset__") == 0) {
                    assert(memb->type == T_PYSSIZET);
                    assert(memb->flags == READONLY);
                    type->tp_vectorcall_offset = memb->offset;
                    changed = 1;
                }
#endif  // CYTHON_METH_FASTCALL
#if !CYTHON_COMPILING_IN_PYPY
                else if (strcmp(memb->name, "__module__") == 0) {
                    PyObject *descr;
                    assert(memb->type == T_OBJECT);
                    assert(memb->flags == 0 || memb->flags == READONLY);
                    descr = PyDescr_NewMember(type, memb);
                    if (unlikely(!descr))
                        return -1;
                    int set_item_result = PyDict_SetItem(type->tp_dict, PyDescr_NAME(descr), descr);
                    Py_DECREF(descr);
                    if (unlikely(set_item_result < 0)) {
                        return -1;
                    }
                    changed = 1;
                }
#endif  // !CYTHON_COMPILING_IN_PYPY
            }
            memb++;
        }
    }
#endif  // !CYTHON_COMPILING_IN_LIMITED_API
#if !CYTHON_COMPILING_IN_PYPY
    slot = spec->slots;
    while (slot && slot->slot && slot->slot != Py_tp_getset)
        slot++;
    if (slot && slot->slot == Py_tp_getset) {
        PyGetSetDef *getset = (PyGetSetDef*) slot->pfunc;
        while (getset && getset->name) {
            if (getset->name[0] == '_' && getset->name[1] == '_' && strcmp(getset->name, "__module__") == 0) {
                PyObject *descr = PyDescr_NewGetSet(type, getset);
                if (unlikely(!descr))
                    return -1;
                #if CYTHON_COMPILING_IN_LIMITED_API
                PyObject *pyname = PyUnicode_FromString(getset->name);
                if (unlikely(!pyname)) {
                    Py_DECREF(descr);
                    return -1;
                }
                int set_item_result = __Pyx_SetItemOnTypeDict(type, pyname, descr);
                Py_DECREF(pyname);
                #else
                CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict);
                int set_item_result = PyDict_SetItem(type->tp_dict, PyDescr_NAME(descr), descr);
                #endif
                Py_DECREF(descr);
                if (unlikely(set_item_result < 0)) {
                    return -1;
                }
                changed = 1;
            }
            ++getset;
        }
    }
#else
    CYTHON_UNUSED_VAR(__Pyx__SetItemOnTypeDict);
#endif  // !CYTHON_COMPILING_IN_PYPY
    if (changed)
        PyType_Modified(type);
#endif  // PY_VERSION_HEX > 0x030900B1
    return 0;
}

/* AddModuleRef (used by FetchSharedCythonModule) */
#if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  static PyObject *__Pyx_PyImport_AddModuleObjectRef(PyObject *name) {
      PyObject *module_dict = PyImport_GetModuleDict();
      PyObject *m;
      if (PyMapping_GetOptionalItem(module_dict, name, &m) < 0) {
          return NULL;
      }
      if (m != NULL && PyModule_Check(m)) {
          return m;
      }
      Py_XDECREF(m);
      m = PyModule_NewObject(name);
      if (m == NULL)
          return NULL;
      if (PyDict_CheckExact(module_dict)) {
          PyObject *new_m;
          (void)PyDict_SetDefaultRef(module_dict, name, m, &new_m);
          Py_DECREF(m);
          return new_m;
      } else {
           if (PyObject_SetItem(module_dict, name, m) != 0) {
                Py_DECREF(m);
                return NULL;
            }
            return m;
      }
  }
  static PyObject *__Pyx_PyImport_AddModuleRef(const char *name) {
      PyObject *py_name = PyUnicode_FromString(name);
      if (!py_name) return NULL;
      PyObject *module = __Pyx_PyImport_AddModuleObjectRef(py_name);
      Py_DECREF(py_name);
      return module;
  }
#elif __PYX_LIMITED_VERSION_HEX >= 0x030d0000
  #define __Pyx_PyImport_AddModuleRef(name) PyImport_AddModuleRef(name)
#else
  static PyObject *__Pyx_PyImport_AddModuleRef(const char *name) {
      PyObject *module = PyImport_AddModule(name);
      Py_XINCREF(module);
      return module;
  }
#endif

/* FetchSharedCythonModule (used by FetchCommonType) */
static PyObject *__Pyx_FetchSharedCythonABIModule(void) {
    return __Pyx_PyImport_AddModuleRef(__PYX_ABI_MODULE_NAME);
}

/* FetchCommonType (used by CommonTypesMetaclass) */
#if __PYX_LIMITED_VERSION_HEX < 0x030C0000
static PyObject* __Pyx_PyType_FromMetaclass(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases) {
    PyObject *result = __Pyx_PyType_FromModuleAndSpec(module, spec, bases);
    if (result && metaclass) {
        PyObject *old_tp = (PyObject*)Py_TYPE(result);
    Py_INCREF((PyObject*)metaclass);
#if __PYX_LIMITED_VERSION_HEX >= 0x03090000
        Py_SET_TYPE(result, metaclass);
#else
        result->ob_type = metaclass;
#endif
        Py_DECREF(old_tp);
    }
    return result;
}
#else
#define __Pyx_PyType_FromMetaclass(me, mo, s, b) PyType_FromMetaclass(me, mo, s, b)
#endif
static int __Pyx_VerifyCachedType(PyObject *cached_type,
                               const char *name,
                               Py_ssize_t expected_basicsize) {
    Py_ssize_t basicsize;
    if (!PyType_Check(cached_type)) {
        PyErr_Format(PyExc_TypeError,
            "Shared Cython type %.200s is not a type object", name);
        return -1;
    }
    if (expected_basicsize == 0) {
        return 0; // size is inherited, nothing useful to check
    }
#if CYTHON_COMPILING_IN_LIMITED_API
    PyObject *py_basicsize;
    py_basicsize = PyObject_GetAttrString(cached_type, "__basicsize__");
    if (unlikely(!py_basicsize)) return -1;
    basicsize = PyLong_AsSsize_t(py_basicsize);
    Py_DECREF(py_basicsize);
    py_basicsize = NULL;
    if (unlikely(basicsize == (Py_ssize_t)-1) && PyErr_Occurred()) return -1;
#else
    basicsize = ((PyTypeObject*) cached_type)->tp_basicsize;
#endif
    if (basicsize != expected_basicsize) {
        PyErr_Format(PyExc_TypeError,
            "Shared Cython type %.200s has the wrong size, try recompiling",
            name);
        return -1;
    }
    return 0;
}
static PyTypeObject *__Pyx_FetchCommonTypeFromSpec(PyTypeObject *metaclass, PyObject *module, PyType_Spec *spec, PyObject *bases) {
    PyObject *abi_module = NULL, *cached_type = NULL, *abi_module_dict, *new_cached_type, *py_object_name;
    int get_item_ref_result;
    const char* object_name = strrchr(spec->name, '.');
    object_name = object_name ? object_name+1 : spec->name;
    py_object_name = PyUnicode_FromString(object_name);
    if (!py_object_name) return NULL;
    abi_module = __Pyx_FetchSharedCythonABIModule();
    if (!abi_module) goto done;
    abi_module_dict = PyModule_GetDict(abi_module);
    if (!abi_module_dict) goto done;
    get_item_ref_result = __Pyx_PyDict_GetItemRef(abi_module_dict, py_object_name, &cached_type);
    if (get_item_ref_result == 1) {
        if (__Pyx_VerifyCachedType(
              cached_type,
              object_name,
              spec->basicsize) < 0) {
            goto bad;
        }
        goto done;
    } else if (unlikely(get_item_ref_result == -1)) {
        goto bad;
    }
    cached_type = __Pyx_PyType_FromMetaclass(
        metaclass,
        CYTHON_USE_MODULE_STATE ? module : abi_module,
        spec, bases);
    if (unlikely(!cached_type)) goto bad;
    if (unlikely(__Pyx_fix_up_extension_type_from_spec(spec, (PyTypeObject *) cached_type) < 0)) goto bad;
    new_cached_type = __Pyx_PyDict_SetDefault(abi_module_dict, py_object_name, cached_type);
    if (unlikely(new_cached_type != cached_type)) {
        if (unlikely(!new_cached_type)) goto bad;
        Py_DECREF(cached_type);
        cached_type = new_cached_type;
        if (__Pyx_VerifyCachedType(
                cached_type,
                object_name,
                spec->basicsize) < 0) {
            goto bad;
        }
        goto done;
    } else {
        Py_DECREF(new_cached_type);
    }
done:
    Py_XDECREF(abi_module);
    Py_DECREF(py_object_name);
    assert(cached_type == NULL || PyType_Check(cached_type));
    return (PyTypeObject *) cached_type;
bad:
    Py_XDECREF(cached_type);
    cached_type = NULL;
    goto done;
}

/* CommonTypesMetaclass (used by CoroutineBase) */
static PyObject* __pyx_CommonTypesMetaclass_get_module(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED void* context) {
    return PyUnicode_FromString(__PYX_ABI_MODULE_NAME);
}
#if __PYX_LIMITED_VERSION_HEX < 0x030A0000
static PyObject* __pyx_CommonTypesMetaclass_call(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED PyObject *args, CYTHON_UNUSED PyObject *kwds) {
    PyErr_SetString(PyExc_TypeError, "Cannot instantiate Cython internal types");
    return NULL;
}
static int __pyx_CommonTypesMetaclass_setattr(CYTHON_UNUSED PyObject *self, CYTHON_UNUSED PyObject *attr, CYTHON_UNUSED PyObject *value) {
    PyErr_SetString(PyExc_TypeError, "Cython internal types are immutable");
    return -1;
}
#endif
static PyGetSetDef __pyx_CommonTypesMetaclass_getset[] = {
    {"__module__", __pyx_CommonTypesMetaclass_get_module, NULL, NULL, NULL},
    {0, 0, 0, 0, 0}
};
static PyType_Slot __pyx_CommonTypesMetaclass_slots[] = {
    {Py_tp_getset, (void *)__pyx_CommonTypesMetaclass_getset},
    #if __PYX_LIMITED_VERSION_HEX < 0x030A0000
    {Py_tp_call, (void*)__pyx_CommonTypesMetaclass_call},
    {Py_tp_new, (void*)__pyx_CommonTypesMetaclass_call},
    {Py_tp_setattro, (void*)__pyx_CommonTypesMetaclass_setattr},
    #endif
    {0, 0}
};
static PyType_Spec __pyx_CommonTypesMetaclass_spec = {
    __PYX_TYPE_MODULE_PREFIX "_common_types_metatype",
    0,
    0,
    Py_TPFLAGS_IMMUTABLETYPE |
    Py_TPFLAGS_DISALLOW_INSTANTIATION |
    Py_TPFLAGS_DEFAULT,
    __pyx_CommonTypesMetaclass_slots
};
static int __pyx_CommonTypesMetaclass_init(PyObject *module) {
    __pyx_mstatetype *mstate = __Pyx_PyModule_GetState(module);
    PyObject *bases = PyTuple_Pack(1, &PyType_Type);
    if (unlikely(!bases)) {
        return -1;
    }
    mstate->__pyx_CommonTypesMetaclassType = __Pyx_FetchCommonTypeFromSpec(NULL, module, &__pyx_CommonTypesMetaclass_spec, bases);
    Py_DECREF(bases);
    if (unlikely(mstate->__pyx_CommonTypesMetaclassType == NULL)) {
        return -1;
    }
    return 0;
}

/* CallTypeTraverse (used by CoroutineBase) */
#if !CYTHON_USE_TYPE_SPECS || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x03090000)
#else
static int __Pyx_call_type_traverse(PyObject *o, int always_call, visitproc visit, void *arg) {
    #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x03090000
    if (__Pyx_get_runtime_version() < 0x03090000) return 0;
    #endif
    if (!always_call) {
        PyTypeObject *base = __Pyx_PyObject_GetSlot(o, tp_base, PyTypeObject*);
        unsigned long flags = PyType_GetFlags(base);
        if (flags & Py_TPFLAGS_HEAPTYPE) {
            return 0;
        }
    }
    Py_VISIT((PyObject*)Py_TYPE(o));
    return 0;
}
#endif

/* IterNextPlain (used by CoroutineBase) */
#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
static PyObject *__Pyx_GetBuiltinNext_LimitedAPI(void) {
    if (unlikely(!__pyx_mstate_global->__Pyx_GetBuiltinNext_LimitedAPI_cache))
        __pyx_mstate_global->__Pyx_GetBuiltinNext_LimitedAPI_cache = __Pyx_GetBuiltinName(__pyx_mstate_global->__pyx_n_u_next);
    return __pyx_mstate_global->__Pyx_GetBuiltinNext_LimitedAPI_cache;
}
#endif
static CYTHON_INLINE PyObject *__Pyx_PyIter_Next_Plain(PyObject *iterator) {
#if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
    PyObject *result;
    PyObject *next = __Pyx_GetBuiltinNext_LimitedAPI();
    if (unlikely(!next)) return NULL;
    result = PyObject_CallFunctionObjArgs(next, iterator, NULL);
    return result;
#else
    (void)__Pyx_GetBuiltinName; // only for early limited API
    iternextfunc iternext = __Pyx_PyObject_GetIterNextFunc(iterator);
    assert(iternext);
    return iternext(iterator);
#endif
}

/* PyObjectCall2Args (used by PyObjectCallMethod1) */
static CYTHON_INLINE PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
    PyObject *args[3] = {NULL, arg1, arg2};
    return __Pyx_PyObject_FastCall(function, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
}

/* PyObjectGetMethod (used by PyObjectCallMethod1) */
#if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000)))
static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
    PyObject *attr;
#if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
    __Pyx_TypeName type_name;
    PyTypeObject *tp = Py_TYPE(obj);
    PyObject *descr;
    descrgetfunc f = NULL;
    PyObject **dictptr, *dict;
    int meth_found = 0;
    assert (*method == NULL);
    if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
        attr = __Pyx_PyObject_GetAttrStr(obj, name);
        goto try_unpack;
    }
    if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
        return 0;
    }
    descr = _PyType_Lookup(tp, name);
    if (likely(descr != NULL)) {
        Py_INCREF(descr);
#if defined(Py_TPFLAGS_METHOD_DESCRIPTOR) && Py_TPFLAGS_METHOD_DESCRIPTOR
        if (__Pyx_PyType_HasFeature(Py_TYPE(descr), Py_TPFLAGS_METHOD_DESCRIPTOR))
#else
        #ifdef __Pyx_CyFunction_USED
        if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
        #else
        if (likely(PyFunction_Check(descr) || __Pyx_IS_TYPE(descr, &PyMethodDescr_Type)))
        #endif
#endif
        {
            meth_found = 1;
        } else {
            f = Py_TYPE(descr)->tp_descr_get;
            if (f != NULL && PyDescr_IsData(descr)) {
                attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
                Py_DECREF(descr);
                goto try_unpack;
            }
        }
    }
    dictptr = _PyObject_GetDictPtr(obj);
    if (dictptr != NULL && (dict = *dictptr) != NULL) {
        Py_INCREF(dict);
        attr = __Pyx_PyDict_GetItemStr(dict, name);
        if (attr != NULL) {
            Py_INCREF(attr);
            Py_DECREF(dict);
            Py_XDECREF(descr);
            goto try_unpack;
        }
        Py_DECREF(dict);
    }
    if (meth_found) {
        *method = descr;
        return 1;
    }
    if (f != NULL) {
        attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
        Py_DECREF(descr);
        goto try_unpack;
    }
    if (likely(descr != NULL)) {
        *method = descr;
        return 0;
    }
    type_name = __Pyx_PyType_GetFullyQualifiedName(tp);
    PyErr_Format(PyExc_AttributeError,
                 "'" __Pyx_FMT_TYPENAME "' object has no attribute '%U'",
                 type_name, name);
    __Pyx_DECREF_TypeName(type_name);
    return 0;
#else
    attr = __Pyx_PyObject_GetAttrStr(obj, name);
    goto try_unpack;
#endif
try_unpack:
#if CYTHON_UNPACK_METHODS
    if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
        PyObject *function = PyMethod_GET_FUNCTION(attr);
        Py_INCREF(function);
        Py_DECREF(attr);
        *method = function;
        return 1;
    }
#endif
    *method = attr;
    return 0;
}
#endif

/* PyObjectCallMethod1 (used by CoroutineBase) */
#if !(CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000)))
static PyObject* __Pyx__PyObject_CallMethod1(PyObject* method, PyObject* arg) {
    PyObject *result = __Pyx_PyObject_CallOneArg(method, arg);
    Py_DECREF(method);
    return result;
}
#endif
static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
#if CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000))
    PyObject *args[2] = {obj, arg};
    (void) __Pyx_PyObject_CallOneArg;
    (void) __Pyx_PyObject_Call2Args;
    return PyObject_VectorcallMethod(method_name, args, 2 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
#else
    PyObject *method = NULL, *result;
    int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
    if (likely(is_method)) {
        result = __Pyx_PyObject_Call2Args(method, obj, arg);
        Py_DECREF(method);
        return result;
    }
    if (unlikely(!method)) return NULL;
    return __Pyx__PyObject_CallMethod1(method, arg);
#endif
}

/* PyObjectCallNoArg (used by CoroutineBase) */
static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
    PyObject *arg[2] = {NULL, NULL};
    return __Pyx_PyObject_FastCall(func, arg + 1, 0 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
}

/* ReturnWithStopIteration (used by CoroutineBase) */
static void __Pyx__ReturnWithStopIteration(PyObject* value, int async);
static CYTHON_INLINE void __Pyx_ReturnWithStopIteration(PyObject* value, int async, int iternext) {
    if (value == Py_None) {
        if (async || !iternext)
            PyErr_SetNone(async ? PyExc_StopAsyncIteration : PyExc_StopIteration);
        return;
    }
    __Pyx__ReturnWithStopIteration(value, async);
}
static void __Pyx__ReturnWithStopIteration(PyObject* value, int async) {
#if CYTHON_COMPILING_IN_CPYTHON
    __Pyx_PyThreadState_declare
#endif
    PyObject *exc;
    PyObject *exc_type = async ? PyExc_StopAsyncIteration : PyExc_StopIteration;
#if CYTHON_COMPILING_IN_CPYTHON
    if ((PY_VERSION_HEX >= (0x030C00A6)) || unlikely(PyTuple_Check(value) || PyExceptionInstance_Check(value))) {
        if (PY_VERSION_HEX >= (0x030e00A1)) {
            exc = __Pyx_PyObject_CallOneArg(exc_type, value);
        } else {
            PyObject *args_tuple = PyTuple_New(1);
            if (unlikely(!args_tuple)) return;
            Py_INCREF(value);
            PyTuple_SET_ITEM(args_tuple, 0, value);
            exc = PyObject_Call(exc_type, args_tuple, NULL);
            Py_DECREF(args_tuple);
        }
        if (unlikely(!exc)) return;
    } else {
        Py_INCREF(value);
        exc = value;
    }
    #if CYTHON_FAST_THREAD_STATE
    __Pyx_PyThreadState_assign
    #if CYTHON_USE_EXC_INFO_STACK
    if (!__pyx_tstate->exc_info->exc_value)
    #else
    if (!__pyx_tstate->exc_type)
    #endif
    {
        Py_INCREF(exc_type);
        __Pyx_ErrRestore(exc_type, exc, NULL);
        return;
    }
    #endif
#else
    exc = __Pyx_PyObject_CallOneArg(exc_type, value);
    if (unlikely(!exc)) return;
#endif
    PyErr_SetObject(exc_type, exc);
    Py_DECREF(exc);
}

/* CoroutineBase (used by Coroutine) */
#if !CYTHON_COMPILING_IN_LIMITED_API
#include <frameobject.h>
#if PY_VERSION_HEX >= 0x030b00a6 && !defined(PYPY_VERSION)
  #ifndef Py_BUILD_CORE
    #define Py_BUILD_CORE 1
  #endif
  #include "internal/pycore_frame.h"
#endif
#endif // CYTHON_COMPILING_IN_LIMITED_API
static CYTHON_INLINE void
__Pyx_Coroutine_Undelegate(__pyx_CoroutineObject *gen) {
#if CYTHON_USE_AM_SEND
    gen->yieldfrom_am_send = NULL;
#endif
    Py_CLEAR(gen->yieldfrom);
}
static int __Pyx_PyGen__FetchStopIterationValue(PyThreadState *__pyx_tstate, PyObject **pvalue) {
    PyObject *et, *ev, *tb;
    PyObject *value = NULL;
    CYTHON_UNUSED_VAR(__pyx_tstate);
    __Pyx_ErrFetch(&et, &ev, &tb);
    if (!et) {
        Py_XDECREF(tb);
        Py_XDECREF(ev);
        Py_INCREF(Py_None);
        *pvalue = Py_None;
        return 0;
    }
    if (likely(et == PyExc_StopIteration)) {
        if (!ev) {
            Py_INCREF(Py_None);
            value = Py_None;
        }
        else if (likely(__Pyx_IS_TYPE(ev, (PyTypeObject*)PyExc_StopIteration))) {
            #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL
            value = PyObject_GetAttr(ev, __pyx_mstate_global->__pyx_n_u_value);
            if (unlikely(!value)) goto limited_api_failure;
            #else
            value = ((PyStopIterationObject *)ev)->value;
            Py_INCREF(value);
            #endif
            Py_DECREF(ev);
        }
        else if (unlikely(PyTuple_Check(ev))) {
            Py_ssize_t tuple_size = __Pyx_PyTuple_GET_SIZE(ev);
            #if !CYTHON_ASSUME_SAFE_SIZE
            if (unlikely(tuple_size < 0)) {
                Py_XDECREF(tb);
                Py_DECREF(ev);
                Py_DECREF(et);
                return -1;
            }
            #endif
            if (tuple_size >= 1) {
#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                value = PyTuple_GET_ITEM(ev, 0);
                Py_INCREF(value);
#elif CYTHON_ASSUME_SAFE_MACROS
                value = PySequence_ITEM(ev, 0);
#else
                value = PySequence_GetItem(ev, 0);
                if (!value) goto limited_api_failure;
#endif
            } else {
                Py_INCREF(Py_None);
                value = Py_None;
            }
            Py_DECREF(ev);
        }
        else if (!__Pyx_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration)) {
            value = ev;
        }
        if (likely(value)) {
            Py_XDECREF(tb);
            Py_DECREF(et);
            *pvalue = value;
            return 0;
        }
    } else if (!__Pyx_PyErr_GivenExceptionMatches(et, PyExc_StopIteration)) {
        __Pyx_ErrRestore(et, ev, tb);
        return -1;
    }
    PyErr_NormalizeException(&et, &ev, &tb);
    if (unlikely(!PyObject_TypeCheck(ev, (PyTypeObject*)PyExc_StopIteration))) {
        __Pyx_ErrRestore(et, ev, tb);
        return -1;
    }
    Py_XDECREF(tb);
    Py_DECREF(et);
#if CYTHON_COMPILING_IN_LIMITED_API
    value = PyObject_GetAttr(ev, __pyx_mstate_global->__pyx_n_u_value);
#else
    value = ((PyStopIterationObject *)ev)->value;
    Py_INCREF(value);
#endif
    Py_DECREF(ev);
#if CYTHON_COMPILING_IN_LIMITED_API
    if (unlikely(!value)) return -1;
#endif
    *pvalue = value;
    return 0;
#if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_GRAAL || !CYTHON_ASSUME_SAFE_MACROS
  limited_api_failure:
    Py_XDECREF(et);
    Py_XDECREF(tb);
    Py_XDECREF(ev);
    return -1;
#endif
}
static CYTHON_INLINE
__Pyx_PySendResult __Pyx_Coroutine_status_from_result(PyObject **retval) {
    if (*retval) {
        return PYGEN_NEXT;
    } else if (likely(__Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, retval) == 0)) {
        return PYGEN_RETURN;
    } else {
        return PYGEN_ERROR;
    }
}
static CYTHON_INLINE
void __Pyx_Coroutine_ExceptionClear(__Pyx_ExcInfoStruct *exc_state) {
#if PY_VERSION_HEX >= 0x030B00a4
    Py_CLEAR(exc_state->exc_value);
#else
    PyObject *t, *v, *tb;
    t = exc_state->exc_type;
    v = exc_state->exc_value;
    tb = exc_state->exc_traceback;
    exc_state->exc_type = NULL;
    exc_state->exc_value = NULL;
    exc_state->exc_traceback = NULL;
    Py_XDECREF(t);
    Py_XDECREF(v);
    Py_XDECREF(tb);
#endif
}
#define __Pyx_Coroutine_AlreadyRunningError(gen)  (__Pyx__Coroutine_AlreadyRunningError(gen), (PyObject*)NULL)
static void __Pyx__Coroutine_AlreadyRunningError(__pyx_CoroutineObject *gen) {
    const char *msg;
    CYTHON_MAYBE_UNUSED_VAR(gen);
    if ((0)) {
    #ifdef __Pyx_Coroutine_USED
    } else if (__Pyx_Coroutine_Check((PyObject*)gen)) {
        msg = "coroutine already executing";
    #endif
    #ifdef __Pyx_AsyncGen_USED
    } else if (__Pyx_AsyncGen_CheckExact((PyObject*)gen)) {
        msg = "async generator already executing";
    #endif
    } else {
        msg = "generator already executing";
    }
    PyErr_SetString(PyExc_ValueError, msg);
}
static void __Pyx_Coroutine_AlreadyTerminatedError(PyObject *gen, PyObject *value, int closing) {
    CYTHON_MAYBE_UNUSED_VAR(gen);
    CYTHON_MAYBE_UNUSED_VAR(closing);
    #ifdef __Pyx_Coroutine_USED
    if (!closing && __Pyx_Coroutine_Check(gen)) {
        PyErr_SetString(PyExc_RuntimeError, "cannot reuse already awaited coroutine");
    } else
    #endif
    if (value) {
        #ifdef __Pyx_AsyncGen_USED
        if (__Pyx_AsyncGen_CheckExact(gen))
            PyErr_SetNone(PyExc_StopAsyncIteration);
        else
        #endif
        PyErr_SetNone(PyExc_StopIteration);
    }
}
static
__Pyx_PySendResult __Pyx_Coroutine_SendEx(__pyx_CoroutineObject *self, PyObject *value, PyObject **result, int closing) {
    __Pyx_PyThreadState_declare
    PyThreadState *tstate;
    __Pyx_ExcInfoStruct *exc_state;
    PyObject *retval;
    assert(__Pyx_Coroutine_get_is_running(self));  // Callers should ensure is_running
    if (unlikely(self->resume_label == -1)) {
        __Pyx_Coroutine_AlreadyTerminatedError((PyObject*)self, value, closing);
        return PYGEN_ERROR;
    }
#if CYTHON_FAST_THREAD_STATE
    __Pyx_PyThreadState_assign
    tstate = __pyx_tstate;
#else
    tstate = __Pyx_PyThreadState_Current;
#endif
    exc_state = &self->gi_exc_state;
    if (exc_state->exc_value) {
        #if CYTHON_COMPILING_IN_LIMITED_API || CYTHON_COMPILING_IN_PYPY
        #else
        PyObject *exc_tb;
        #if PY_VERSION_HEX >= 0x030B00a4 && !CYTHON_COMPILING_IN_CPYTHON
        exc_tb = PyException_GetTraceback(exc_state->exc_value);
        #elif PY_VERSION_HEX >= 0x030B00a4
        exc_tb = ((PyBaseExceptionObject*) exc_state->exc_value)->traceback;
        #else
        exc_tb = exc_state->exc_traceback;
        #endif
        if (exc_tb) {
            PyTracebackObject *tb = (PyTracebackObject *) exc_tb;
            PyFrameObject *f = tb->tb_frame;
            assert(f->f_back == NULL);
            #if PY_VERSION_HEX >= 0x030B00A1
            f->f_back = PyThreadState_GetFrame(tstate);
            #else
            Py_XINCREF(tstate->frame);
            f->f_back = tstate->frame;
            #endif
            #if PY_VERSION_HEX >= 0x030B00a4 && !CYTHON_COMPILING_IN_CPYTHON
            Py_DECREF(exc_tb);
            #endif
        }
        #endif
    }
#if CYTHON_USE_EXC_INFO_STACK
    exc_state->previous_item = tstate->exc_info;
    tstate->exc_info = exc_state;
#else
    if (exc_state->exc_type) {
        __Pyx_ExceptionSwap(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
    } else {
        __Pyx_Coroutine_ExceptionClear(exc_state);
        __Pyx_ExceptionSave(&exc_state->exc_type, &exc_state->exc_value, &exc_state->exc_traceback);
    }
#endif
    retval = self->body(self, tstate, value);
#if CYTHON_USE_EXC_INFO_STACK
    exc_state = &self->gi_exc_state;
    tstate->exc_info = exc_state->previous_item;
    exc_state->previous_item = NULL;
    __Pyx_Coroutine_ResetFrameBackpointer(exc_state);
#endif
    *result = retval;
    if (self->resume_label == -1) {
        return likely(retval) ? PYGEN_RETURN : PYGEN_ERROR;
    }
    return PYGEN_NEXT;
}
static CYTHON_INLINE void __Pyx_Coroutine_ResetFrameBackpointer(__Pyx_ExcInfoStruct *exc_state) {
#if CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API
    CYTHON_UNUSED_VAR(exc_state);
#else
    PyObject *exc_tb;
    #if PY_VERSION_HEX >= 0x030B00a4
    if (!exc_state->exc_value) return;
    exc_tb = PyException_GetTraceback(exc_state->exc_value);
    #else
    exc_tb = exc_state->exc_traceback;
    #endif
    if (likely(exc_tb)) {
        PyTracebackObject *tb = (PyTracebackObject *) exc_tb;
        PyFrameObject *f = tb->tb_frame;
        Py_CLEAR(f->f_back);
        #if PY_VERSION_HEX >= 0x030B00a4
        Py_DECREF(exc_tb);
        #endif
    }
#endif
}
#define __Pyx_Coroutine_MethodReturnFromResult(gen, result, retval, iternext)\
    ((result) == PYGEN_NEXT ? (retval) : __Pyx__Coroutine_MethodReturnFromResult(gen, result, retval, iternext))
static PyObject *
__Pyx__Coroutine_MethodReturnFromResult(PyObject* gen, __Pyx_PySendResult result, PyObject *retval, int iternext) {
    CYTHON_MAYBE_UNUSED_VAR(gen);
    if (likely(result == PYGEN_RETURN)) {
        int is_async = 0;
        #ifdef __Pyx_AsyncGen_USED
        is_async = __Pyx_AsyncGen_CheckExact(gen);
        #endif
        __Pyx_ReturnWithStopIteration(retval, is_async, iternext);
        Py_XDECREF(retval);
    }
    return NULL;
}
#if CYTHON_COMPILING_IN_CPYTHON
static CYTHON_INLINE
PyObject *__Pyx_PyGen_Send(PyGenObject *gen, PyObject *arg) {
#if PY_VERSION_HEX <= 0x030A00A1
    return _PyGen_Send(gen, arg);
#else
    PyObject *result;
    if (PyIter_Send((PyObject*)gen, arg ? arg : Py_None, &result) == PYGEN_RETURN) {
        if (PyAsyncGen_CheckExact(gen)) {
            assert(result == Py_None);
            PyErr_SetNone(PyExc_StopAsyncIteration);
        }
        else if (result == Py_None) {
            PyErr_SetNone(PyExc_StopIteration);
        }
        else {
#if PY_VERSION_HEX < 0x030d00A1
            _PyGen_SetStopIterationValue(result);
#else
            if (!PyTuple_Check(result) && !PyExceptionInstance_Check(result)) {
                PyErr_SetObject(PyExc_StopIteration, result);
            } else {
                PyObject *exc = __Pyx_PyObject_CallOneArg(PyExc_StopIteration, result);
                if (likely(exc != NULL)) {
                    PyErr_SetObject(PyExc_StopIteration, exc);
                    Py_DECREF(exc);
                }
            }
#endif
        }
        Py_DECREF(result);
        result = NULL;
    }
    return result;
#endif
}
#endif
static CYTHON_INLINE __Pyx_PySendResult
__Pyx_Coroutine_FinishDelegation(__pyx_CoroutineObject *gen, PyObject** retval) {
    __Pyx_PySendResult result;
    PyObject *val = NULL;
    assert(__Pyx_Coroutine_get_is_running(gen));
    __Pyx_Coroutine_Undelegate(gen);
    __Pyx_PyGen__FetchStopIterationValue(__Pyx_PyThreadState_Current, &val);
    result = __Pyx_Coroutine_SendEx(gen, val, retval, 0);
    Py_XDECREF(val);
    return result;
}
#if CYTHON_USE_AM_SEND
static __Pyx_PySendResult
__Pyx_Coroutine_SendToDelegate(__pyx_CoroutineObject *gen, __Pyx_pyiter_sendfunc gen_am_send, PyObject *value, PyObject **retval) {
    PyObject *ret = NULL;
    __Pyx_PySendResult delegate_result, result;
    assert(__Pyx_Coroutine_get_is_running(gen));
    delegate_result = gen_am_send(gen->yieldfrom, value, &ret);
    if (delegate_result == PYGEN_NEXT) {
        assert (ret != NULL);
        *retval = ret;
        return PYGEN_NEXT;
    }
    assert (delegate_result != PYGEN_ERROR || ret == NULL);
    __Pyx_Coroutine_Undelegate(gen);
    result = __Pyx_Coroutine_SendEx(gen, ret, retval, 0);
    Py_XDECREF(ret);
    return result;
}
#endif
static PyObject *__Pyx_Coroutine_Send(PyObject *self, PyObject *value) {
    PyObject *retval = NULL;
    __Pyx_PySendResult result = __Pyx_Coroutine_AmSend(self, value, &retval);
    return __Pyx_Coroutine_MethodReturnFromResult(self, result, retval, 0);
}
static __Pyx_PySendResult
__Pyx_Coroutine_AmSend(PyObject *self, PyObject *value, PyObject **retval) {
    __Pyx_PySendResult result;
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
    if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen))) {
        *retval = __Pyx_Coroutine_AlreadyRunningError(gen);
        return PYGEN_ERROR;
    }
    #if CYTHON_USE_AM_SEND
    if (gen->yieldfrom_am_send) {
        result = __Pyx_Coroutine_SendToDelegate(gen, gen->yieldfrom_am_send, value, retval);
    } else
    #endif
    if (gen->yieldfrom) {
        PyObject *yf = gen->yieldfrom;
        PyObject *ret;
      #if !CYTHON_USE_AM_SEND
        #ifdef __Pyx_Generator_USED
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Coroutine_Send(yf, value);
        } else
        #endif
        #ifdef __Pyx_Coroutine_USED
        if (__Pyx_Coroutine_Check(yf)) {
            ret = __Pyx_Coroutine_Send(yf, value);
        } else
        #endif
        #ifdef __Pyx_AsyncGen_USED
        if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
            ret = __Pyx_async_gen_asend_send(yf, value);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON
        if (PyGen_CheckExact(yf)) {
            ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
        } else
        if (PyCoro_CheckExact(yf)) {
            ret = __Pyx_PyGen_Send((PyGenObject*)yf, value == Py_None ? NULL : value);
        } else
        #endif
      #endif
        {
            #if !CYTHON_COMPILING_IN_LIMITED_API || __PYX_LIMITED_VERSION_HEX >= 0x03080000
            if (value == Py_None && PyIter_Check(yf))
                ret = __Pyx_PyIter_Next_Plain(yf);
            else
            #endif
                ret = __Pyx_PyObject_CallMethod1(yf, __pyx_mstate_global->__pyx_n_u_send, value);
        }
        if (likely(ret)) {
            __Pyx_Coroutine_unset_is_running(gen);
            *retval = ret;
            return PYGEN_NEXT;
        }
        result = __Pyx_Coroutine_FinishDelegation(gen, retval);
    } else {
        result = __Pyx_Coroutine_SendEx(gen, value, retval, 0);
    }
    __Pyx_Coroutine_unset_is_running(gen);
    return result;
}
static int __Pyx_Coroutine_CloseIter(__pyx_CoroutineObject *gen, PyObject *yf) {
    __Pyx_PySendResult result;
    PyObject *retval = NULL;
    CYTHON_UNUSED_VAR(gen);
    assert(__Pyx_Coroutine_get_is_running(gen));
    #ifdef __Pyx_Generator_USED
    if (__Pyx_Generator_CheckExact(yf)) {
        result = __Pyx_Coroutine_Close(yf, &retval);
    } else
    #endif
    #ifdef __Pyx_Coroutine_USED
    if (__Pyx_Coroutine_Check(yf)) {
        result = __Pyx_Coroutine_Close(yf, &retval);
    } else
    if (__Pyx_CoroutineAwait_CheckExact(yf)) {
        result = __Pyx_CoroutineAwait_Close((__pyx_CoroutineAwaitObject*)yf);
    } else
    #endif
    #ifdef __Pyx_AsyncGen_USED
    if (__pyx_PyAsyncGenASend_CheckExact(yf)) {
        retval = __Pyx_async_gen_asend_close(yf, NULL);
        result = PYGEN_RETURN;
    } else
    if (__pyx_PyAsyncGenAThrow_CheckExact(yf)) {
        retval = __Pyx_async_gen_athrow_close(yf, NULL);
        result = PYGEN_RETURN;
    } else
    #endif
    {
        PyObject *meth;
        result = PYGEN_RETURN;
        meth = __Pyx_PyObject_GetAttrStrNoError(yf, __pyx_mstate_global->__pyx_n_u_close);
        if (unlikely(!meth)) {
            if (unlikely(PyErr_Occurred())) {
                PyErr_WriteUnraisable(yf);
            }
        } else {
            retval = __Pyx_PyObject_CallNoArg(meth);
            Py_DECREF(meth);
            if (unlikely(!retval)) {
                result = PYGEN_ERROR;
            }
        }
    }
    Py_XDECREF(retval);
    return result == PYGEN_ERROR ? -1 : 0;
}
static PyObject *__Pyx_Generator_Next(PyObject *self) {
    __Pyx_PySendResult result;
    PyObject *retval = NULL;
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
    if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen))) {
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    }
    #if CYTHON_USE_AM_SEND
    if (gen->yieldfrom_am_send) {
        result = __Pyx_Coroutine_SendToDelegate(gen, gen->yieldfrom_am_send, Py_None, &retval);
    } else
    #endif
    if (gen->yieldfrom) {
        PyObject *yf = gen->yieldfrom;
        PyObject *ret;
        #ifdef __Pyx_Generator_USED
        if (__Pyx_Generator_CheckExact(yf)) {
            ret = __Pyx_Generator_Next(yf);
        } else
        #endif
        #ifdef __Pyx_Coroutine_USED
        if (__Pyx_Coroutine_CheckExact(yf)) {
            ret = __Pyx_Coroutine_Send(yf, Py_None);
        } else
        #endif
        #if CYTHON_COMPILING_IN_CPYTHON && (PY_VERSION_HEX < 0x030A00A3 || !CYTHON_USE_AM_SEND)
        if (PyGen_CheckExact(yf)) {
            ret = __Pyx_PyGen_Send((PyGenObject*)yf, NULL);
        } else
        #endif
            ret = __Pyx_PyIter_Next_Plain(yf);
        if (likely(ret)) {
            __Pyx_Coroutine_unset_is_running(gen);
            return ret;
        }
        result = __Pyx_Coroutine_FinishDelegation(gen, &retval);
    } else {
        result = __Pyx_Coroutine_SendEx(gen, Py_None, &retval, 0);
    }
    __Pyx_Coroutine_unset_is_running(gen);
    return __Pyx_Coroutine_MethodReturnFromResult(self, result, retval, 1);
}
static PyObject *__Pyx_Coroutine_Close_Method(PyObject *self, PyObject *arg) {
    PyObject *retval = NULL;
    __Pyx_PySendResult result;
    CYTHON_UNUSED_VAR(arg);
    result = __Pyx_Coroutine_Close(self, &retval);
    if (unlikely(result == PYGEN_ERROR))
        return NULL;
    Py_XDECREF(retval);
    Py_RETURN_NONE;
}
static __Pyx_PySendResult
__Pyx_Coroutine_Close(PyObject *self, PyObject **retval) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    __Pyx_PySendResult result;
    PyObject *yf;
    int err = 0;
    if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen))) {
        *retval = __Pyx_Coroutine_AlreadyRunningError(gen);
        return PYGEN_ERROR;
    }
    yf = gen->yieldfrom;
    if (yf) {
        Py_INCREF(yf);
        err = __Pyx_Coroutine_CloseIter(gen, yf);
        __Pyx_Coroutine_Undelegate(gen);
        Py_DECREF(yf);
    }
    if (err == 0)
        PyErr_SetNone(PyExc_GeneratorExit);
    result = __Pyx_Coroutine_SendEx(gen, NULL, retval, 1);
    if (result == PYGEN_ERROR) {
        __Pyx_PyThreadState_declare
        __Pyx_PyThreadState_assign
        __Pyx_Coroutine_unset_is_running(gen);
        if (!__Pyx_PyErr_Occurred()) {
            return PYGEN_RETURN;
        } else if (likely(__Pyx_PyErr_ExceptionMatches2(PyExc_GeneratorExit, PyExc_StopIteration))) {
            __Pyx_PyErr_Clear();
            return PYGEN_RETURN;
        }
        return PYGEN_ERROR;
    } else if (likely(result == PYGEN_RETURN && *retval == Py_None)) {
        __Pyx_Coroutine_unset_is_running(gen);
        return PYGEN_RETURN;
    } else {
        const char *msg;
        Py_DECREF(*retval);
        *retval = NULL;
        if ((0)) {
        #ifdef __Pyx_Coroutine_USED
        } else if (__Pyx_Coroutine_Check(self)) {
            msg = "coroutine ignored GeneratorExit";
        #endif
        #ifdef __Pyx_AsyncGen_USED
        } else if (__Pyx_AsyncGen_CheckExact(self)) {
            msg = "async generator ignored GeneratorExit";
        #endif
        } else {
            msg = "generator ignored GeneratorExit";
        }
        PyErr_SetString(PyExc_RuntimeError, msg);
        __Pyx_Coroutine_unset_is_running(gen);
        return PYGEN_ERROR;
    }
}
static PyObject *__Pyx__Coroutine_Throw(PyObject *self, PyObject *typ, PyObject *val, PyObject *tb,
                                        PyObject *args, int close_on_genexit) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject *yf;
    if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen)))
        return __Pyx_Coroutine_AlreadyRunningError(gen);
    yf = gen->yieldfrom;
    if (yf) {
        __Pyx_PySendResult result;
        PyObject *ret;
        Py_INCREF(yf);
        if (__Pyx_PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit) && close_on_genexit) {
            int err = __Pyx_Coroutine_CloseIter(gen, yf);
            Py_DECREF(yf);
            __Pyx_Coroutine_Undelegate(gen);
            if (err < 0)
                goto propagate_exception;
            goto throw_here;
        }
        if (0
        #ifdef __Pyx_Generator_USED
            || __Pyx_Generator_CheckExact(yf)
        #endif
        #ifdef __Pyx_Coroutine_USED
            || __Pyx_Coroutine_Check(yf)
        #endif
            ) {
            ret = __Pyx__Coroutine_Throw(yf, typ, val, tb, args, close_on_genexit);
        #ifdef __Pyx_Coroutine_USED
        } else if (__Pyx_CoroutineAwait_CheckExact(yf)) {
            ret = __Pyx__Coroutine_Throw(((__pyx_CoroutineAwaitObject*)yf)->coroutine, typ, val, tb, args, close_on_genexit);
        #endif
        } else {
            PyObject *meth = __Pyx_PyObject_GetAttrStrNoError(yf, __pyx_mstate_global->__pyx_n_u_throw);
            if (unlikely(!meth)) {
                Py_DECREF(yf);
                if (unlikely(PyErr_Occurred())) {
                    __Pyx_Coroutine_unset_is_running(gen);
                    return NULL;
                }
                __Pyx_Coroutine_Undelegate(gen);
                goto throw_here;
            }
            if (likely(args)) {
                ret = __Pyx_PyObject_Call(meth, args, NULL);
            } else {
                PyObject *cargs[4] = {NULL, typ, val, tb};
                size_t nargs = 1U + (val != NULL) + (tb != NULL);
                ret = __Pyx_PyObject_FastCall(meth, cargs+1, nargs | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET);
            }
            Py_DECREF(meth);
        }
        Py_DECREF(yf);
        if (ret) {
            __Pyx_Coroutine_unset_is_running(gen);
            return ret;
        }
        result = __Pyx_Coroutine_FinishDelegation(gen, &ret);
        __Pyx_Coroutine_unset_is_running(gen);
        return __Pyx_Coroutine_MethodReturnFromResult(self, result, ret, 0);
    }
throw_here:
    __Pyx_Raise(typ, val, tb, NULL);
propagate_exception:
    {
        PyObject *retval = NULL;
        __Pyx_PySendResult result = __Pyx_Coroutine_SendEx(gen, NULL, &retval, 0);
        __Pyx_Coroutine_unset_is_running(gen);
        return __Pyx_Coroutine_MethodReturnFromResult(self, result, retval, 0);
    }
}
static PyObject *__Pyx_Coroutine_Throw(PyObject *self, PyObject *args) {
    PyObject *typ;
    PyObject *val = NULL;
    PyObject *tb = NULL;
    if (unlikely(!PyArg_UnpackTuple(args, "throw", 1, 3, &typ, &val, &tb)))
        return NULL;
    return __Pyx__Coroutine_Throw(self, typ, val, tb, args, 1);
}
static CYTHON_INLINE int __Pyx_Coroutine_traverse_excstate(__Pyx_ExcInfoStruct *exc_state, visitproc visit, void *arg) {
#if PY_VERSION_HEX >= 0x030B00a4
    Py_VISIT(exc_state->exc_value);
#else
    Py_VISIT(exc_state->exc_type);
    Py_VISIT(exc_state->exc_value);
    Py_VISIT(exc_state->exc_traceback);
#endif
    return 0;
}
static int __Pyx_Coroutine_traverse(__pyx_CoroutineObject *gen, visitproc visit, void *arg) {
    {
        int e = __Pyx_call_type_traverse((PyObject*)gen, 1, visit, arg);
        if (e) return e;
    }
    Py_VISIT(gen->closure);
    Py_VISIT(gen->classobj);
    Py_VISIT(gen->yieldfrom);
    return __Pyx_Coroutine_traverse_excstate(&gen->gi_exc_state, visit, arg);
}
static int __Pyx_Coroutine_clear(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    Py_CLEAR(gen->closure);
    Py_CLEAR(gen->classobj);
    __Pyx_Coroutine_Undelegate(gen);
    __Pyx_Coroutine_ExceptionClear(&gen->gi_exc_state);
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        Py_CLEAR(((__pyx_PyAsyncGenObject*)gen)->ag_finalizer);
    }
#endif
    Py_CLEAR(gen->gi_code);
    Py_CLEAR(gen->gi_frame);
    Py_CLEAR(gen->gi_name);
    Py_CLEAR(gen->gi_qualname);
    Py_CLEAR(gen->gi_modulename);
    return 0;
}
static void __Pyx_Coroutine_dealloc(PyObject *self) {
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    PyObject_GC_UnTrack(gen);
    #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
    if (gen->gi_weakreflist != NULL)
    #endif
        PyObject_ClearWeakRefs(self);
    if (gen->resume_label >= 0) {
        PyObject_GC_Track(self);
#if CYTHON_USE_TP_FINALIZE
        if (unlikely(PyObject_CallFinalizerFromDealloc(self)))
#else
        {
            destructor del = __Pyx_PyObject_GetSlot(gen, tp_del, destructor);
            if (del) del(self);
        }
        if (unlikely(Py_REFCNT(self) > 0))
#endif
        {
            return;
        }
        PyObject_GC_UnTrack(self);
    }
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        /* We have to handle this case for asynchronous generators
           right here, because this code has to be between UNTRACK
           and GC_Del. */
        Py_CLEAR(((__pyx_PyAsyncGenObject*)self)->ag_finalizer);
    }
#endif
    __Pyx_Coroutine_clear(self);
    __Pyx_PyHeapTypeObject_GC_Del(gen);
}
#if CYTHON_USE_TP_FINALIZE
static void __Pyx_Coroutine_del(PyObject *self) {
    PyObject *error_type, *error_value, *error_traceback;
    __pyx_CoroutineObject *gen = (__pyx_CoroutineObject *) self;
    __Pyx_PyThreadState_declare
    if (gen->resume_label < 0) {
        return;
    }
    __Pyx_PyThreadState_assign
    __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
#ifdef __Pyx_AsyncGen_USED
    if (__Pyx_AsyncGen_CheckExact(self)) {
        __pyx_PyAsyncGenObject *agen = (__pyx_PyAsyncGenObject*)self;
        PyObject *finalizer = agen->ag_finalizer;
        if (finalizer && !agen->ag_closed) {
            PyObject *res = __Pyx_PyObject_CallOneArg(finalizer, self);
            if (unlikely(!res)) {
                PyErr_WriteUnraisable(self);
            } else {
                Py_DECREF(res);
            }
            __Pyx_ErrRestore(error_type, error_value, error_traceback);
            return;
        }
    }
#endif
    if (unlikely(gen->resume_label == 0 && !error_value)) {
#ifdef __Pyx_Coroutine_USED
#ifdef __Pyx_Generator_USED
    if (!__Pyx_Generator_CheckExact(self))
#endif
        {
        PyObject_GC_UnTrack(self);
        if (unlikely(PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "coroutine '%.50S' was never awaited", gen->gi_qualname) < 0))
            PyErr_WriteUnraisable(self);
        PyObject_GC_Track(self);
        }
#endif
    } else {
        PyObject *retval = NULL;
        __Pyx_PySendResult result = __Pyx_Coroutine_Close(self, &retval);
        if (result == PYGEN_ERROR) {
            PyErr_WriteUnraisable(self);
        } else {
            Py_XDECREF(retval);
        }
    }
    __Pyx_ErrRestore(error_type, error_value, error_traceback);
}
#endif
static PyObject *
__Pyx_Coroutine_get_name(__pyx_CoroutineObject *self, void *context)
{
    PyObject *name = self->gi_name;
    CYTHON_UNUSED_VAR(context);
    if (unlikely(!name)) name = Py_None;
    Py_INCREF(name);
    return name;
}
static int
__Pyx_Coroutine_set_name(__pyx_CoroutineObject *self, PyObject *value, void *context)
{
    CYTHON_UNUSED_VAR(context);
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
        PyErr_SetString(PyExc_TypeError,
                        "__name__ must be set to a string object");
        return -1;
    }
    Py_INCREF(value);
    __Pyx_Py_XDECREF_SET(self->gi_name, value);
    return 0;
}
static PyObject *
__Pyx_Coroutine_get_qualname(__pyx_CoroutineObject *self, void *context)
{
    PyObject *name = self->gi_qualname;
    CYTHON_UNUSED_VAR(context);
    if (unlikely(!name)) name = Py_None;
    Py_INCREF(name);
    return name;
}
static int
__Pyx_Coroutine_set_qualname(__pyx_CoroutineObject *self, PyObject *value, void *context)
{
    CYTHON_UNUSED_VAR(context);
    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
        PyErr_SetString(PyExc_TypeError,
                        "__qualname__ must be set to a string object");
        return -1;
    }
    Py_INCREF(value);
    __Pyx_Py_XDECREF_SET(self->gi_qualname, value);
    return 0;
}
#if !CYTHON_COMPILING_IN_LIMITED_API
static PyObject *
__Pyx__Coroutine_get_frame_locked(__pyx_CoroutineObject *self) {
    PyObject *frame;
    frame = self->gi_frame;
    if (!frame) {
        if (unlikely(!self->gi_code)) {
            Py_RETURN_NONE;
        }
        PyObject *globals = PyDict_New();
        if (unlikely(!globals)) return NULL;
        frame = (PyObject *) PyFrame_New(
            PyThreadState_Get(),            /*PyThreadState *tstate,*/
            (PyCodeObject*) self->gi_code,  /*PyCodeObject *code,*/
            globals,                        /*PyObject *globals,*/
            0                               /*PyObject *locals*/
        );
        Py_DECREF(globals);
        if (unlikely(!frame))
            return NULL;
        if (unlikely(self->gi_frame)) {
            Py_DECREF(frame);
            frame = self->gi_frame;
        } else {
            self->gi_frame = frame;
        }
    }
    Py_INCREF(frame);
    return frame;
}
#endif
static PyObject *
__Pyx__Coroutine_get_frame(__pyx_CoroutineObject *self)
{
#if !CYTHON_COMPILING_IN_LIMITED_API
    PyObject *frame;
    __Pyx_BEGIN_CRITICAL_SECTION((PyObject*)self);
    frame = __Pyx__Coroutine_get_frame_locked(self);
    __Pyx_END_CRITICAL_SECTION();
    return frame;
#else
    CYTHON_UNUSED_VAR(self);
    Py_RETURN_NONE;
#endif
}
static PyObject *
__Pyx_Coroutine_get_frame(__pyx_CoroutineObject *self, void *context) {
    CYTHON_UNUSED_VAR(context);
    PyObject *frame = self->gi_frame;
    if (frame)
        return __Pyx_NewRef(frame);
    return __Pyx__Coroutine_get_frame(self);
}
static __pyx_CoroutineObject *__Pyx__Coroutine_New(
            PyTypeObject* type, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name) {
    __pyx_CoroutineObject *gen = PyObject_GC_New(__pyx_CoroutineObject, type);
    if (unlikely(!gen))
        return NULL;
    return __Pyx__Coroutine_NewInit(gen, body, code, closure, name, qualname, module_name);
}
static __pyx_CoroutineObject *__Pyx__Coroutine_NewInit(
            __pyx_CoroutineObject *gen, __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
            PyObject *name, PyObject *qualname, PyObject *module_name) {
    gen->body = body;
    gen->closure = closure;
    Py_XINCREF(closure);
    gen->is_running = 0;
    gen->resume_label = 0;
    gen->classobj = NULL;
    gen->yieldfrom = NULL;
    gen->yieldfrom_am_send = NULL;
    #if PY_VERSION_HEX >= 0x030B00a4 && !CYTHON_COMPILING_IN_LIMITED_API
    gen->gi_exc_state.exc_value = NULL;
    #else
    gen->gi_exc_state.exc_type = NULL;
    gen->gi_exc_state.exc_value = NULL;
    gen->gi_exc_state.exc_traceback = NULL;
    #endif
#if CYTHON_USE_EXC_INFO_STACK
    gen->gi_exc_state.previous_item = NULL;
#endif
#if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
    gen->gi_weakreflist = NULL;
#endif
    Py_XINCREF(qualname);
    gen->gi_qualname = qualname;
    Py_XINCREF(name);
    gen->gi_name = name;
    Py_XINCREF(module_name);
    gen->gi_modulename = module_name;
    Py_XINCREF(code);
    gen->gi_code = code;
    gen->gi_frame = NULL;
#if CYTHON_USE_SYS_MONITORING && (CYTHON_PROFILE || CYTHON_TRACE)
    memset(gen->__pyx_pymonitoring_state, 0, sizeof(gen->__pyx_pymonitoring_state));
    gen->__pyx_pymonitoring_version = 0;
#endif
    PyObject_GC_Track(gen);
    return gen;
}
static char __Pyx_Coroutine_test_and_set_is_running(__pyx_CoroutineObject *gen) {
    char result;
    __Pyx_BEGIN_CRITICAL_SECTION((PyObject*)gen);
    result = gen->is_running;
    gen->is_running = 1;
    __Pyx_END_CRITICAL_SECTION();
    return result;
}
static void __Pyx_Coroutine_unset_is_running(__pyx_CoroutineObject *gen) {
    __Pyx_BEGIN_CRITICAL_SECTION((PyObject*)gen);
    assert(gen->is_running);
    gen->is_running = 0;
    __Pyx_END_CRITICAL_SECTION();
}
static char __Pyx_Coroutine_get_is_running(__pyx_CoroutineObject *gen) {
    char result;
    __Pyx_BEGIN_CRITICAL_SECTION((PyObject*)gen);
    result = gen->is_running;
    __Pyx_END_CRITICAL_SECTION();
    return result;
}
static PyObject *__Pyx_Coroutine_get_is_running_getter(PyObject *gen, void *closure) {
    CYTHON_UNUSED_VAR(closure);
    char result = __Pyx_Coroutine_get_is_running((__pyx_CoroutineObject*)gen);
    if (result) Py_RETURN_TRUE;
    else Py_RETURN_FALSE;
}
#if __PYX_HAS_PY_AM_SEND == 2
static void __Pyx_SetBackportTypeAmSend(PyTypeObject *type, __Pyx_PyAsyncMethodsStruct *static_amsend_methods, __Pyx_pyiter_sendfunc am_send) {
    Py_ssize_t ptr_offset = (char*)(type->tp_as_async) - (char*)type;
    if (ptr_offset < 0 || ptr_offset > type->tp_basicsize) {
        return;
    }
    memcpy((void*)static_amsend_methods, (void*)(type->tp_as_async), sizeof(*type->tp_as_async));
    static_amsend_methods->am_send = am_send;
    type->tp_as_async = __Pyx_SlotTpAsAsync(static_amsend_methods);
}
#endif
static PyObject *__Pyx_Coroutine_fail_reduce_ex(PyObject *self, PyObject *arg) {
    CYTHON_UNUSED_VAR(arg);
    __Pyx_TypeName self_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE((PyObject*)self));
    PyErr_Format(PyExc_TypeError, "cannot pickle '" __Pyx_FMT_TYPENAME "' object",
                         self_type_name);
    __Pyx_DECREF_TypeName(self_type_name);
    return NULL;
}

/* Coroutine (used by CoroutineYieldFrom) */
static void __Pyx_CoroutineAwait_dealloc(PyObject *self) {
    PyObject_GC_UnTrack(self);
    Py_CLEAR(((__pyx_CoroutineAwaitObject*)self)->coroutine);
    __Pyx_PyHeapTypeObject_GC_Del(self);
}
static int __Pyx_CoroutineAwait_traverse(__pyx_CoroutineAwaitObject *self, visitproc visit, void *arg) {
    {
        int e = __Pyx_call_type_traverse((PyObject*)self, 1, visit, arg);
        if (e) return e;
    }
    Py_VISIT(self->coroutine);
    return 0;
}
static int __Pyx_CoroutineAwait_clear(__pyx_CoroutineAwaitObject *self) {
    Py_CLEAR(self->coroutine);
    return 0;
}
static PyObject *__Pyx_CoroutineAwait_Next(__pyx_CoroutineAwaitObject *self) {
    return __Pyx_Generator_Next(self->coroutine);
}
static PyObject *__Pyx_CoroutineAwait_Send(__pyx_CoroutineAwaitObject *self, PyObject *value) {
    return __Pyx_Coroutine_Send(self->coroutine, value);
}
#if __PYX_HAS_PY_AM_SEND
static __Pyx_PySendResult __Pyx_CoroutineAwait_AmSend(PyObject *self, PyObject *value, PyObject **retval) {
    return __Pyx_Coroutine_AmSend(((__pyx_CoroutineAwaitObject*)self)->coroutine, value, retval);
}
#endif
static PyObject *__Pyx_CoroutineAwait_Throw(__pyx_CoroutineAwaitObject *self, PyObject *args) {
    return __Pyx_Coroutine_Throw(self->coroutine, args);
}
static __Pyx_PySendResult __Pyx_CoroutineAwait_Close(__pyx_CoroutineAwaitObject *self) {
    PyObject *retval = NULL;
    __Pyx_PySendResult result = __Pyx_Coroutine_Close(self->coroutine, &retval);
    Py_XDECREF(retval);
    return result;
}
static PyObject *__Pyx_CoroutineAwait_Close_Method(__pyx_CoroutineAwaitObject *self, PyObject *arg) {
    PyObject *retval = NULL;
    __Pyx_PySendResult result;
    CYTHON_UNUSED_VAR(arg);
    result = __Pyx_Coroutine_Close(self->coroutine, &retval);
    if (unlikely(result == PYGEN_ERROR))
        return NULL;
    Py_XDECREF(retval);
    Py_RETURN_NONE;
}
static PyObject *__Pyx_CoroutineAwait_self(PyObject *self) {
    Py_INCREF(self);
    return self;
}
#if !CYTHON_COMPILING_IN_PYPY
static PyObject *__Pyx_CoroutineAwait_no_new(PyTypeObject *type, PyObject *args, PyObject *kwargs) {
    CYTHON_UNUSED_VAR(type);
    CYTHON_UNUSED_VAR(args);
    CYTHON_UNUSED_VAR(kwargs);
    PyErr_SetString(PyExc_TypeError, "cannot instantiate type, use 'await coroutine' instead");
    return NULL;
}
#endif
static PyMethodDef __pyx_CoroutineAwait_methods[] = {
    {"send", (PyCFunction) __Pyx_CoroutineAwait_Send, METH_O,
     PyDoc_STR("send(arg) -> send 'arg' into coroutine,\nreturn next yielded value or raise StopIteration.")},
    {"throw", (PyCFunction) __Pyx_CoroutineAwait_Throw, METH_VARARGS,
     PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in coroutine,\nreturn next yielded value or raise StopIteration.")},
    {"close", (PyCFunction) __Pyx_CoroutineAwait_Close_Method, METH_NOARGS, PyDoc_STR("close() -> raise GeneratorExit inside coroutine.")},
    {"__reduce_ex__", (PyCFunction) __Pyx_Coroutine_fail_reduce_ex, METH_O, 0},
    {"__reduce__", (PyCFunction) __Pyx_Coroutine_fail_reduce_ex, METH_NOARGS, 0},
    {0, 0, 0, 0}
};
static PyType_Slot __pyx_CoroutineAwaitType_slots[] = {
    {Py_tp_dealloc, (void *)__Pyx_CoroutineAwait_dealloc},
    {Py_tp_traverse, (void *)__Pyx_CoroutineAwait_traverse},
    {Py_tp_clear, (void *)__Pyx_CoroutineAwait_clear},
#if !CYTHON_COMPILING_IN_PYPY
    {Py_tp_new, (void *)__Pyx_CoroutineAwait_no_new},
#endif
    {Py_tp_methods, (void *)__pyx_CoroutineAwait_methods},
    {Py_tp_iter, (void *)__Pyx_CoroutineAwait_self},
    {Py_tp_iternext, (void *)__Pyx_CoroutineAwait_Next},
#if __PYX_HAS_PY_AM_SEND == 1
    {Py_am_send, (void *)__Pyx_CoroutineAwait_AmSend},
#endif
    {0, 0},
};
static PyType_Spec __pyx_CoroutineAwaitType_spec = {
    __PYX_TYPE_MODULE_PREFIX "coroutine_wrapper",
    sizeof(__pyx_CoroutineAwaitObject),
    0,
    Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION |
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | __Pyx_TPFLAGS_HAVE_AM_SEND,
    __pyx_CoroutineAwaitType_slots
};
#if __PYX_HAS_PY_AM_SEND == 2 // backport
static __Pyx_PyAsyncMethodsStruct __pyx_CoroutineAwait_as_async;
#endif
static CYTHON_INLINE PyObject *__Pyx__Coroutine_await(PyObject *coroutine) {
    __pyx_CoroutineAwaitObject *await = PyObject_GC_New(__pyx_CoroutineAwaitObject, __pyx_mstate_global->__pyx_CoroutineAwaitType);
    if (unlikely(!await)) return NULL;
    Py_INCREF(coroutine);
    await->coroutine = coroutine;
    PyObject_GC_Track(await);
    return (PyObject*)await;
}
static PyObject *__Pyx_Coroutine_await(PyObject *coroutine) {
    if (unlikely(!coroutine || !__Pyx_Coroutine_Check(coroutine))) {
        PyErr_SetString(PyExc_TypeError, "invalid input, expected coroutine");
        return NULL;
    }
    return __Pyx__Coroutine_await(coroutine);
}
static PyMethodDef __pyx_Coroutine_methods[] = {
    {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
     PyDoc_STR("send(arg) -> send 'arg' into coroutine,\nreturn next iterated value or raise StopIteration.")},
    {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS,
     PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in coroutine,\nreturn next iterated value or raise StopIteration.")},
    {"close", (PyCFunction) __Pyx_Coroutine_Close_Method, METH_NOARGS, PyDoc_STR("close() -> raise GeneratorExit inside coroutine.")},
    {"__reduce_ex__", (PyCFunction) __Pyx_Coroutine_fail_reduce_ex, METH_O, 0},
    {"__reduce__", (PyCFunction) __Pyx_Coroutine_fail_reduce_ex, METH_NOARGS, 0},
    {0, 0, 0, 0}
};
static PyMemberDef __pyx_Coroutine_memberlist[] = {
    {"cr_await", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
     PyDoc_STR("object being awaited, or None")},
    {"cr_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL},
    {"__module__", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_modulename), 0, 0},
#if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
    {"__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CoroutineObject, gi_weakreflist), READONLY, 0},
#endif
    {0, 0, 0, 0, 0}
};
static PyGetSetDef __pyx_Coroutine_getsets[] = {
    {"__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
     PyDoc_STR("name of the coroutine"), 0},
    {"__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
     PyDoc_STR("qualified name of the coroutine"), 0},
    {"cr_frame", (getter)__Pyx_Coroutine_get_frame, NULL,
     PyDoc_STR("Frame of the coroutine"), 0},
    {"cr_running", __Pyx_Coroutine_get_is_running_getter, NULL, NULL, NULL},
    {0, 0, 0, 0, 0}
};
static PyType_Slot __pyx_CoroutineType_slots[] = {
    {Py_tp_dealloc, (void *)__Pyx_Coroutine_dealloc},
    {Py_am_await, (void *)&__Pyx_Coroutine_await},
    {Py_tp_traverse, (void *)__Pyx_Coroutine_traverse},
    {Py_tp_methods, (void *)__pyx_Coroutine_methods},
    {Py_tp_members, (void *)__pyx_Coroutine_memberlist},
    {Py_tp_getset, (void *)__pyx_Coroutine_getsets},
    {Py_tp_getattro, (void *) PyObject_GenericGetAttr},
#if CYTHON_USE_TP_FINALIZE
    {Py_tp_finalize, (void *)__Pyx_Coroutine_del},
#endif
#if __PYX_HAS_PY_AM_SEND == 1
    {Py_am_send, (void *)__Pyx_Coroutine_AmSend},
#endif
    {0, 0},
};
static PyType_Spec __pyx_CoroutineType_spec = {
    __PYX_TYPE_MODULE_PREFIX "coroutine",
    sizeof(__pyx_CoroutineObject),
    0,
#if PY_VERSION_HEX >= 0x030C0000 && !CYTHON_COMPILING_IN_LIMITED_API
    Py_TPFLAGS_MANAGED_WEAKREF |
#endif
    Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION |
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | __Pyx_TPFLAGS_HAVE_AM_SEND,
    __pyx_CoroutineType_slots
};
#if __PYX_HAS_PY_AM_SEND == 2
static __Pyx_PyAsyncMethodsStruct __pyx_Coroutine_as_async;
#endif
static int __pyx_Coroutine_init(PyObject *module) {
    __pyx_mstatetype *mstate;
    CYTHON_MAYBE_UNUSED_VAR(module);
    mstate = __Pyx_PyModule_GetState(module);
    mstate->__pyx_CoroutineType = __Pyx_FetchCommonTypeFromSpec(
        mstate->__pyx_CommonTypesMetaclassType, module, &__pyx_CoroutineType_spec, NULL);
    if (unlikely(!mstate->__pyx_CoroutineType))
        return -1;
#if __PYX_HAS_PY_AM_SEND == 2
    __Pyx_SetBackportTypeAmSend(mstate->__pyx_CoroutineType, &__pyx_Coroutine_as_async, &__Pyx_Coroutine_AmSend);
#endif
#ifdef __Pyx_IterableCoroutine_USED
    if (unlikely(__pyx_IterableCoroutine_init(module) == -1))
        return -1;
#endif
    mstate->__pyx_CoroutineAwaitType = __Pyx_FetchCommonTypeFromSpec(NULL, module, &__pyx_CoroutineAwaitType_spec, NULL);
    if (unlikely(!mstate->__pyx_CoroutineAwaitType))
        return -1;
#if __PYX_HAS_PY_AM_SEND == 2
    __Pyx_SetBackportTypeAmSend(mstate->__pyx_CoroutineAwaitType, &__pyx_CoroutineAwait_as_async, &__Pyx_CoroutineAwait_AmSend);
#endif
    return 0;
}

/* CoroutineSetYieldFrom (used by CoroutineYieldFrom) */
static void
__Pyx_Coroutine_Set_Owned_Yield_From(__pyx_CoroutineObject *gen, PyObject *yf) {
    assert (!gen->yieldfrom);
#if CYTHON_USE_AM_SEND
    assert (!gen->yieldfrom_am_send);
    #if PY_VERSION_HEX < 0x030A00F0
    if (__Pyx_PyType_HasFeature(Py_TYPE(yf), __Pyx_TPFLAGS_HAVE_AM_SEND))
    #endif
    {
        __Pyx_pyiter_sendfunc am_send;
        #if __PYX_LIMITED_VERSION_HEX >= 0x030A0000
        am_send = __Pyx_PyObject_TryGetSubSlot(yf, tp_as_async, am_send, __Pyx_pyiter_sendfunc);
        #else
        __Pyx_PyAsyncMethodsStruct* tp_as_async = (__Pyx_PyAsyncMethodsStruct*) Py_TYPE(yf)->tp_as_async;
        am_send = tp_as_async ? tp_as_async->am_send : NULL;
        #endif
        if (likely(am_send)) {
            gen->yieldfrom_am_send = am_send;
        }
    }
#endif
    gen->yieldfrom = yf;
}

/* Coro_CheckExact (used by GetAwaitIter) */
#if CYTHON_COMPILING_IN_LIMITED_API
static int __Pyx_PyCoro_CheckExact(PyObject *o) {
    return (PyObject*)Py_TYPE(o) == __pyx_mstate_global->__Pyx_CachedCoroType;
}
#endif

/* GetAwaitIter (used by CoroutineYieldFrom) */
static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAwaitableIter(PyObject *o) {
#ifdef __Pyx_Coroutine_USED
    if (__Pyx_Coroutine_Check(o)) {
        return __Pyx_NewRef(o);
    }
#endif
    return __Pyx__Coroutine_GetAwaitableIter(o);
}
static void __Pyx_Coroutine_AwaitableIterError(PyObject *source) {
#if (PY_VERSION_HEX < 0x030d0000 || defined(_PyErr_FormatFromCause)) && !CYTHON_COMPILING_IN_LIMITED_API
    __Pyx_TypeName source_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(source));
    _PyErr_FormatFromCause(PyExc_TypeError,
        "'async for' received an invalid object from __anext__: " __Pyx_FMT_TYPENAME, source_type_name);
    __Pyx_DECREF_TypeName(source_type_name);
#else
    PyObject *exc, *val, *val2, *tb;
    __Pyx_TypeName source_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(source));
    assert(PyErr_Occurred());
    PyErr_Fetch(&exc, &val, &tb);
    PyErr_NormalizeException(&exc, &val, &tb);
    if (tb != NULL) {
        PyException_SetTraceback(val, tb);
        Py_DECREF(tb);
    }
    Py_DECREF(exc);
    assert(!PyErr_Occurred());
    PyErr_Format(PyExc_TypeError,
        "'async for' received an invalid object from __anext__: " __Pyx_FMT_TYPENAME, source_type_name);
    __Pyx_DECREF_TypeName(source_type_name);
    PyErr_Fetch(&exc, &val2, &tb);
    PyErr_NormalizeException(&exc, &val2, &tb);
    Py_INCREF(val);
    PyException_SetCause(val2, val);
    PyException_SetContext(val2, val);
    PyErr_Restore(exc, val2, tb);
#endif
}
static PyObject *__Pyx__Coroutine_GetAwaitableIter(PyObject *obj) {
    PyObject *res;
    unaryfunc am_await;
    am_await = __Pyx_PyObject_TryGetSubSlot(obj, tp_as_async, am_await, unaryfunc);
    if (likely(am_await)) {
        res = (*am_await)(obj);
    } else
#if CYTHON_COMPILING_IN_CPYTHON && defined(CO_ITERABLE_COROUTINE)
#if PY_VERSION_HEX >= 0x030C00A6
    if (PyGen_CheckExact(obj) && (PyGen_GetCode((PyGenObject*)obj)->co_flags & CO_ITERABLE_COROUTINE)) {
#else
    if (PyGen_CheckExact(obj) && ((PyGenObject*)obj)->gi_code && ((PyCodeObject *)((PyGenObject*)obj)->gi_code)->co_flags & CO_ITERABLE_COROUTINE) {
#endif
        return __Pyx_NewRef(obj);
    } else
#endif
    {
#if CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000))
        PyObject *args[] = { obj };
        res = PyObject_VectorcallMethod(__pyx_mstate_global->__pyx_n_u_await, args, 1 |  PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
        if (unlikely(!res)) {
            if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
                PyObject *type, *value, *traceback;
                PyErr_Fetch(&type, &value, &traceback);
                int has_attr = PyObject_HasAttr(obj, __pyx_mstate_global->__pyx_n_u_await);
                PyErr_Restore(type, value, traceback);
                if (!has_attr) goto slot_error;
            }
        }
#else
        PyObject *method = NULL;
        int is_method = __Pyx_PyObject_GetMethod(obj, __pyx_mstate_global->__pyx_n_u_await, &method);
        if (likely(is_method)) {
            res = __Pyx_PyObject_CallOneArg(method, obj);
        } else if (likely(method)) {
            res = __Pyx_PyObject_CallNoArg(method);
        } else
            goto slot_error;
        Py_DECREF(method);
#endif
    }
    if (unlikely(!res)) {
        __Pyx_Coroutine_AwaitableIterError(obj);
        goto bad;
    }
    if (unlikely(!PyIter_Check(res))) {
        __Pyx_TypeName res_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(res));
        PyErr_Format(PyExc_TypeError,
            "__await__() returned non-iterator of type '" __Pyx_FMT_TYPENAME "'", res_type_name);
        __Pyx_DECREF_TypeName(res_type_name);
        Py_CLEAR(res);
    } else {
        int is_coroutine = 0;
        #ifdef __Pyx_Coroutine_USED
        is_coroutine |= __Pyx_Coroutine_Check(res);
        #endif
        is_coroutine |= __Pyx_PyCoro_CheckExact(res);
        if (unlikely(is_coroutine)) {
            /* __await__ must return an *iterator*, not
               a coroutine or another awaitable (see PEP 492) */
            PyErr_SetString(PyExc_TypeError,
                            "__await__() returned a coroutine");
            Py_CLEAR(res);
        }
    }
    return res;
slot_error:
    {
        __Pyx_TypeName obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj));
        PyErr_Format(PyExc_TypeError,
            "object " __Pyx_FMT_TYPENAME " can't be used in 'await' expression", obj_type_name);
        __Pyx_DECREF_TypeName(obj_type_name);
    }
bad:
    return NULL;
}

/* CoroutineYieldFrom */
  static __Pyx_PySendResult __Pyx_Coroutine_Yield_From_Coroutine(__pyx_CoroutineObject *gen, PyObject *source, PyObject **retval) {
      __Pyx_PySendResult result;
      if (unlikely(((__pyx_CoroutineObject*)source)->yieldfrom)) {
          PyErr_SetString(
              PyExc_RuntimeError,
              "coroutine is being awaited already");
          return PYGEN_ERROR;
      }
      result = __Pyx_Coroutine_AmSend(source, Py_None, retval);
      if (result == PYGEN_NEXT) {
          Py_INCREF(source);
          __Pyx_Coroutine_Set_Owned_Yield_From(gen, source);
      }
      return result;
  }
  static __Pyx_PySendResult __Pyx_Coroutine_Yield_From_Generic(__pyx_CoroutineObject *gen, PyObject *source, PyObject **retval) {
      __Pyx_PySendResult result;
      PyObject *source_gen = NULL;
      source_gen = __Pyx_Coroutine_GetAwaitableIter(source);
      if (unlikely(!source_gen)) return PYGEN_ERROR;
      if (__Pyx_Coroutine_Check(source_gen)) {
          result = __Pyx_Coroutine_Yield_From_Coroutine(gen, source_gen, retval);
          Py_DECREF(source_gen);
          return result;
      }
      *retval = __Pyx_PyIter_Next_Plain(source_gen);
      if (*retval) {
          __Pyx_Coroutine_Set_Owned_Yield_From(gen, source_gen);
          return PYGEN_NEXT;
      }
      result = __Pyx_Coroutine_status_from_result(retval);
      Py_XDECREF(source_gen);
      return result;
  }
  static CYTHON_INLINE __Pyx_PySendResult __Pyx_Coroutine_Yield_From(__pyx_CoroutineObject *gen, PyObject *source, PyObject **retval) {
      if (__Pyx_Coroutine_Check(source)) {
          return __Pyx_Coroutine_Yield_From_Coroutine(gen, source, retval);
      }
  #ifdef __Pyx_AsyncGen_USED
      if (__pyx_PyAsyncGenASend_CheckExact(source)) {
          *retval = __Pyx_async_gen_asend_iternext(source);
          if (*retval) {
              Py_INCREF(source);
              __Pyx_Coroutine_Set_Owned_Yield_From(gen, source);
              return PYGEN_NEXT;
          }
          return __Pyx_Coroutine_status_from_result(retval);
      }
  #endif
      return __Pyx_Coroutine_Yield_From_Generic(gen, source, retval);
  }
  
/* pep479 */
  static void __Pyx_Generator_Replace_StopIteration(int in_async_gen) {
      PyObject *exc, *val, *tb, *cur_exc, *new_exc;
      __Pyx_PyThreadState_declare
      int is_async_stopiteration = 0;
      CYTHON_MAYBE_UNUSED_VAR(in_async_gen);
      __Pyx_PyThreadState_assign
      cur_exc = __Pyx_PyErr_CurrentExceptionType();
      if (likely(!__Pyx_PyErr_GivenExceptionMatches(cur_exc, PyExc_StopIteration))) {
          if (in_async_gen && unlikely(__Pyx_PyErr_GivenExceptionMatches(cur_exc, PyExc_StopAsyncIteration))) {
              is_async_stopiteration = 1;
          } else {
              return;
          }
      }
      __Pyx_GetException(&exc, &val, &tb);
      Py_XDECREF(exc);
      Py_XDECREF(tb);
      new_exc = PyObject_CallFunction(PyExc_RuntimeError, "s",
          is_async_stopiteration ? "async generator raised StopAsyncIteration" :
          in_async_gen ? "async generator raised StopIteration" :
          "generator raised StopIteration");
      if (!new_exc) {
          Py_XDECREF(val);
          return;
      }
      PyException_SetCause(new_exc, val); // steals ref to val
      PyErr_SetObject(PyExc_RuntimeError, new_exc);
      Py_DECREF(new_exc);
  }
  
/* PyUnicode_Unicode */
  static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Unicode(PyObject *obj) {
      if (unlikely(obj == Py_None))
          obj = __pyx_mstate_global->__pyx_kp_u_None;
      return __Pyx_NewRef(obj);
  }
  
/* PyLongCompare */
  static CYTHON_INLINE PyObject* __Pyx_PyLong_EqObjC(PyObject *op1, PyObject *op2, long intval, long inplace) {
      CYTHON_MAYBE_UNUSED_VAR(intval);
      CYTHON_UNUSED_VAR(inplace);
      if (op1 == op2) {
          Py_RETURN_TRUE;
      }
      #if CYTHON_USE_PYLONG_INTERNALS
      if (likely(PyLong_CheckExact(op1))) {
          int unequal;
          unsigned long uintval;
          Py_ssize_t size = __Pyx_PyLong_DigitCount(op1);
          const digit* digits = __Pyx_PyLong_Digits(op1);
          if (intval == 0) {
              if (__Pyx_PyLong_IsZero(op1) == 1) Py_RETURN_TRUE; else Py_RETURN_FALSE;
          } else if (intval < 0) {
              if (__Pyx_PyLong_IsNonNeg(op1))
                  Py_RETURN_FALSE;
              intval = -intval;
          } else {
              if (__Pyx_PyLong_IsNeg(op1))
                  Py_RETURN_FALSE;
          }
          uintval = (unsigned long) intval;
  #if PyLong_SHIFT * 4 < SIZEOF_LONG*8
          if (uintval >> (PyLong_SHIFT * 4)) {
              unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                   | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
          } else
  #endif
  #if PyLong_SHIFT * 3 < SIZEOF_LONG*8
          if (uintval >> (PyLong_SHIFT * 3)) {
              unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                   | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
          } else
  #endif
  #if PyLong_SHIFT * 2 < SIZEOF_LONG*8
          if (uintval >> (PyLong_SHIFT * 2)) {
              unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                   | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
          } else
  #endif
  #if PyLong_SHIFT * 1 < SIZEOF_LONG*8
          if (uintval >> (PyLong_SHIFT * 1)) {
              unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                   | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
          } else
  #endif
              unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
          if (unequal == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
      }
      #endif
      if (PyFloat_CheckExact(op1)) {
          const long b = intval;
          double a = __Pyx_PyFloat_AS_DOUBLE(op1);
          if ((double)a == (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
      }
      return (
          PyObject_RichCompare(op1, op2, Py_EQ));
  }
  
/* RaiseUnexpectedTypeError */
  static int
  __Pyx_RaiseUnexpectedTypeError(const char *expected, PyObject *obj)
  {
      __Pyx_TypeName obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj));
      PyErr_Format(PyExc_TypeError, "Expected %s, got " __Pyx_FMT_TYPENAME,
                   expected, obj_type_name);
      __Pyx_DECREF_TypeName(obj_type_name);
      return 0;
  }
  
/* CallUnboundCMethod1 */
  #if CYTHON_COMPILING_IN_CPYTHON
  static CYTHON_INLINE PyObject* __Pyx_CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg) {
      int was_initialized =  __Pyx_CachedCFunction_GetAndSetInitializing(cfunc);
      if (likely(was_initialized == 2 && cfunc->func)) {
          int flag = cfunc->flag;
          if (flag == METH_O) {
              return __Pyx_CallCFunction(cfunc, self, arg);
          } else if (flag == METH_FASTCALL) {
              return __Pyx_CallCFunctionFast(cfunc, self, &arg, 1);
          } else if (flag == (METH_FASTCALL | METH_KEYWORDS)) {
              return __Pyx_CallCFunctionFastWithKeywords(cfunc, self, &arg, 1, NULL);
          }
      }
  #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
      else if (unlikely(was_initialized == 1)) {
          __Pyx_CachedCFunction tmp_cfunc = {
  #ifndef __cplusplus
              0
  #endif
          };
          tmp_cfunc.type = cfunc->type;
          tmp_cfunc.method_name = cfunc->method_name;
          return __Pyx__CallUnboundCMethod1(&tmp_cfunc, self, arg);
      }
  #endif
      PyObject* result = __Pyx__CallUnboundCMethod1(cfunc, self, arg);
      __Pyx_CachedCFunction_SetFinishedInitializing(cfunc);
      return result;
  }
  #endif
  static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObject* self, PyObject* arg){
      PyObject *result = NULL;
      if (unlikely(!cfunc->func && !cfunc->method) && unlikely(__Pyx_TryUnpackUnboundCMethod(cfunc) < 0)) return NULL;
  #if CYTHON_COMPILING_IN_CPYTHON
      if (cfunc->func && (cfunc->flag & METH_VARARGS)) {
          PyObject *args = PyTuple_New(1);
          if (unlikely(!args)) return NULL;
          Py_INCREF(arg);
          PyTuple_SET_ITEM(args, 0, arg);
          if (cfunc->flag & METH_KEYWORDS)
              result = __Pyx_CallCFunctionWithKeywords(cfunc, self, args, NULL);
          else
              result = __Pyx_CallCFunction(cfunc, self, args);
          Py_DECREF(args);
      } else
  #endif
      {
          result = __Pyx_PyObject_Call2Args(cfunc->method, self, arg);
      }
      return result;
  }
  
/* dict_getitem_default */
  static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) {
      PyObject* value;
  #if !CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM >= 0x07020000
      value = PyDict_GetItemWithError(d, key);
      if (unlikely(!value)) {
          if (unlikely(PyErr_Occurred()))
              return NULL;
          value = default_value;
      }
      Py_INCREF(value);
      if ((1));
  #else
      if (PyBytes_CheckExact(key) || PyUnicode_CheckExact(key) || PyLong_CheckExact(key)) {
          value = PyDict_GetItem(d, key);
          if (unlikely(!value)) {
              value = default_value;
          }
          Py_INCREF(value);
      }
  #endif
      else {
          if (default_value == Py_None)
              value = __Pyx_CallUnboundCMethod1(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_get, d, key);
          else
              value = __Pyx_CallUnboundCMethod2(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_get, d, key, default_value);
      }
      return value;
  }
  
/* RaiseTooManyValuesToUnpack */
  static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
      PyErr_Format(PyExc_ValueError,
                   "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
  }
  
/* RaiseNeedMoreValuesToUnpack */
  static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
      PyErr_Format(PyExc_ValueError,
                   "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
                   index, (index == 1) ? "" : "s");
  }
  
/* IterFinish */
  static CYTHON_INLINE int __Pyx_IterFinish(void) {
      PyObject* exc_type;
      __Pyx_PyThreadState_declare
      __Pyx_PyThreadState_assign
      exc_type = __Pyx_PyErr_CurrentExceptionType();
      if (unlikely(exc_type)) {
          if (unlikely(!__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)))
              return -1;
          __Pyx_PyErr_Clear();
          return 0;
      }
      return 0;
  }
  
/* UnpackItemEndCheck */
  static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
      if (unlikely(retval)) {
          Py_DECREF(retval);
          __Pyx_RaiseTooManyValuesError(expected);
          return -1;
      }
      return __Pyx_IterFinish();
  }
  
/* PyUnicode_Substring */
  static CYTHON_INLINE PyObject* __Pyx_PyUnicode_Substring(
              PyObject* text, Py_ssize_t start, Py_ssize_t stop) {
      Py_ssize_t length;
      #if !CYTHON_COMPILING_IN_LIMITED_API
      if (unlikely(__Pyx_PyUnicode_READY(text) == -1)) return NULL;
      #endif
      length = __Pyx_PyUnicode_GET_LENGTH(text);
      #if !CYTHON_ASSUME_SAFE_SIZE
      if (unlikely(length < 0)) return NULL;
      #endif
      if (start < 0) {
          start += length;
          if (start < 0)
              start = 0;
      }
      if (stop < 0)
          stop += length;
      else if (stop > length)
          stop = length;
      if (stop <= start)
          return __Pyx_NewRef(__pyx_mstate_global->__pyx_empty_unicode);
      if (start == 0 && stop == length)
          return __Pyx_NewRef(text);
  #if CYTHON_COMPILING_IN_LIMITED_API
      return PyUnicode_Substring(text, start, stop);
  #else
      return PyUnicode_FromKindAndData(PyUnicode_KIND(text),
          PyUnicode_1BYTE_DATA(text) + start*PyUnicode_KIND(text), stop-start);
  #endif
  }
  
/* PyLongCompare */
  static CYTHON_INLINE int __Pyx_PyLong_BoolEqObjC(PyObject *op1, PyObject *op2, long intval, long inplace) {
      CYTHON_MAYBE_UNUSED_VAR(intval);
      CYTHON_UNUSED_VAR(inplace);
      if (op1 == op2) {
          return 1;
      }
      #if CYTHON_USE_PYLONG_INTERNALS
      if (likely(PyLong_CheckExact(op1))) {
          int unequal;
          unsigned long uintval;
          Py_ssize_t size = __Pyx_PyLong_DigitCount(op1);
          const digit* digits = __Pyx_PyLong_Digits(op1);
          if (intval == 0) {
              return (__Pyx_PyLong_IsZero(op1) == 1);
          } else if (intval < 0) {
              if (__Pyx_PyLong_IsNonNeg(op1))
                  return 0;
              intval = -intval;
          } else {
              if (__Pyx_PyLong_IsNeg(op1))
                  return 0;
          }
          uintval = (unsigned long) intval;
  #if PyLong_SHIFT * 4 < SIZEOF_LONG*8
          if (uintval >> (PyLong_SHIFT * 4)) {
              unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                   | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
          } else
  #endif
  #if PyLong_SHIFT * 3 < SIZEOF_LONG*8
          if (uintval >> (PyLong_SHIFT * 3)) {
              unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                   | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
          } else
  #endif
  #if PyLong_SHIFT * 2 < SIZEOF_LONG*8
          if (uintval >> (PyLong_SHIFT * 2)) {
              unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                   | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
          } else
  #endif
  #if PyLong_SHIFT * 1 < SIZEOF_LONG*8
          if (uintval >> (PyLong_SHIFT * 1)) {
              unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                   | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
          } else
  #endif
              unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
          return (unequal == 0);
      }
      #endif
      if (PyFloat_CheckExact(op1)) {
          const long b = intval;
          double a = __Pyx_PyFloat_AS_DOUBLE(op1);
          return ((double)a == (double)b);
      }
      return __Pyx_PyObject_IsTrueAndDecref(
          PyObject_RichCompare(op1, op2, Py_EQ));
  }
  
/* SliceObject */
  static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
          Py_ssize_t cstart, Py_ssize_t cstop,
          PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
          int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
      __Pyx_TypeName obj_type_name;
  #if CYTHON_USE_TYPE_SLOTS
      PyMappingMethods* mp = Py_TYPE(obj)->tp_as_mapping;
      if (likely(mp && mp->mp_subscript))
  #endif
      {
          PyObject* result;
          PyObject *py_slice, *py_start, *py_stop;
          if (_py_slice) {
              py_slice = *_py_slice;
          } else {
              PyObject* owned_start = NULL;
              PyObject* owned_stop = NULL;
              if (_py_start) {
                  py_start = *_py_start;
              } else {
                  if (has_cstart) {
                      owned_start = py_start = PyLong_FromSsize_t(cstart);
                      if (unlikely(!py_start)) goto bad;
                  } else
                      py_start = Py_None;
              }
              if (_py_stop) {
                  py_stop = *_py_stop;
              } else {
                  if (has_cstop) {
                      owned_stop = py_stop = PyLong_FromSsize_t(cstop);
                      if (unlikely(!py_stop)) {
                          Py_XDECREF(owned_start);
                          goto bad;
                      }
                  } else
                      py_stop = Py_None;
              }
              py_slice = PySlice_New(py_start, py_stop, Py_None);
              Py_XDECREF(owned_start);
              Py_XDECREF(owned_stop);
              if (unlikely(!py_slice)) goto bad;
          }
  #if CYTHON_USE_TYPE_SLOTS
          result = mp->mp_subscript(obj, py_slice);
  #else
          result = PyObject_GetItem(obj, py_slice);
  #endif
          if (!_py_slice) {
              Py_DECREF(py_slice);
          }
          return result;
      }
      obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj));
      PyErr_Format(PyExc_TypeError,
          "'" __Pyx_FMT_TYPENAME "' object is unsliceable", obj_type_name);
      __Pyx_DECREF_TypeName(obj_type_name);
  bad:
      return NULL;
  }
  
/* GetItemInt */
  static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
      PyObject *r;
      if (unlikely(!j)) return NULL;
      r = PyObject_GetItem(o, j);
      Py_DECREF(j);
      return r;
  }
  static PyObject *__Pyx_GetItemInt_Generic_size(PyObject *o, Py_ssize_t i) {
      return __Pyx_GetItemInt_Generic(o, PyLong_FromSsize_t(i));
  }
  static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
                                                                int wraparound, int boundscheck, int unsafe_shared) {
      CYTHON_MAYBE_UNUSED_VAR(unsafe_shared);
  #if CYTHON_AVOID_BORROWED_REFS
      CYTHON_UNUSED_VAR(boundscheck);
      Py_ssize_t wrapped_i = i;
      if (wraparound & unlikely(i < 0)) {
          Py_ssize_t size = __Pyx_PyList_GET_SIZE(o);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely(size < 0)) return NULL;
          #endif
          wrapped_i += size;
      }
      return __Pyx_PyList_GetItemRef(o, wrapped_i);
  #elif CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS
      Py_ssize_t wrapped_i = i;
      Py_ssize_t size = (wraparound | boundscheck) ? PyList_GET_SIZE(o) : -1;
      if (wraparound & unlikely(i < 0)) {
          wrapped_i += size;
      }
      if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, size))) {
          return __Pyx_PyList_GET_ITEM_REF(o, wrapped_i, unsafe_shared);
      }
      return __Pyx_GetItemInt_Generic_size(o, i);
  #else
      (void)wraparound;
      (void)boundscheck;
      return PySequence_GetItem(o, i);
  #endif
  }
  static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
                                                                int wraparound, int boundscheck, int unsafe_shared) {
      CYTHON_MAYBE_UNUSED_VAR(unsafe_shared);
  #if CYTHON_AVOID_BORROWED_REFS
      CYTHON_UNUSED_VAR(boundscheck);
      Py_ssize_t wrapped_i = i;
      if (wraparound & unlikely(i < 0)) {
          Py_ssize_t size = __Pyx_PyTuple_GET_SIZE(o);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely(size < 0)) return NULL;
          #endif
          wrapped_i += size;
      }
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_COMPILING_IN_LIMITED_API
      return PySequence_ITEM(o, wrapped_i);
      #else
      if (unlikely(wrapped_i < 0)) {
          PyErr_SetString(PyExc_IndexError, "tuple index out of range");
          return NULL;
      }
      return PySequence_GetItem(o, wrapped_i);
      #endif
  #elif CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS
      Py_ssize_t wrapped_i = i;
      Py_ssize_t size = (wraparound | boundscheck) ? PyTuple_GET_SIZE(o) : -1;
      if (wraparound & unlikely(i < 0)) {
          wrapped_i += size;
      }
      if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, size))) {
          return __Pyx_NewRef(__Pyx_PyTuple_GET_ITEM(o, wrapped_i));
      }
      return __Pyx_GetItemInt_Generic_size(o, i);
  #else
      (void)wraparound;
      (void)boundscheck;
      return PySequence_GetItem(o, i);
  #endif
  }
  static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
                                                       int wraparound, int boundscheck, int unsafe_shared) {
      CYTHON_MAYBE_UNUSED_VAR(unsafe_shared);
  #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
      if (is_list || PyList_CheckExact(o)) {
          Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
          return boundscheck ? __Pyx_PyList_GetItemRef(o, n) : __Pyx_PyList_GET_ITEM_REF(o, n, unsafe_shared);
      } else
      #if !CYTHON_AVOID_BORROWED_REFS
      if (PyTuple_CheckExact(o)) {
          Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
          if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
              return __Pyx_NewRef(PyTuple_GET_ITEM(o, n));
          }
      } else
      #endif
  #else
      if ((!wraparound || i >= 0) & PyList_CheckExact(o)) {
          return boundscheck ? __Pyx_PyList_GetItemRef(o, i) : __Pyx_PyList_GET_ITEM_REF(o, i, unsafe_shared);
      } else
  #endif
  #if CYTHON_USE_TYPE_SLOTS && !CYTHON_COMPILING_IN_PYPY
      {
          PyMappingMethods *mm = Py_TYPE(o)->tp_as_mapping;
          PySequenceMethods *sm = Py_TYPE(o)->tp_as_sequence;
          if (!is_list && mm && mm->mp_subscript) {
              PyObject *r, *key = PyLong_FromSsize_t(i);
              if (unlikely(!key)) return NULL;
              r = mm->mp_subscript(o, key);
              Py_DECREF(key);
              return r;
          }
          if (is_list || likely(sm && sm->sq_item)) {
              if (wraparound && unlikely(i < 0) && likely(sm->sq_length)) {
                  Py_ssize_t l = sm->sq_length(o);
                  if (likely(l >= 0)) {
                      i += l;
                  } else {
                      if (!PyErr_ExceptionMatches(PyExc_OverflowError))
                          return NULL;
                      PyErr_Clear();
                  }
              }
              return sm->sq_item(o, i);
          }
      }
  #else
      if (is_list || !PyMapping_Check(o)) {
          return PySequence_GetItem(o, i);
      }
  #endif
      (void)wraparound;
      (void)boundscheck;
      return __Pyx_GetItemInt_Generic_size(o, i);
  }
  
/* ObjectGetItem */
  #if CYTHON_USE_TYPE_SLOTS
  static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject *index) {
      PyObject *runerr = NULL;
      Py_ssize_t key_value;
      key_value = __Pyx_PyIndex_AsSsize_t(index);
      if (likely(key_value != -1 || !(runerr = PyErr_Occurred()))) {
          return __Pyx_GetItemInt_Fast(obj, key_value, 0, 1, 1, 1);
      }
      if (PyErr_GivenExceptionMatches(runerr, PyExc_OverflowError)) {
          __Pyx_TypeName index_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(index));
          PyErr_Clear();
          PyErr_Format(PyExc_IndexError,
              "cannot fit '" __Pyx_FMT_TYPENAME "' into an index-sized integer", index_type_name);
          __Pyx_DECREF_TypeName(index_type_name);
      }
      return NULL;
  }
  static PyObject *__Pyx_PyObject_GetItem_Slow(PyObject *obj, PyObject *key) {
      __Pyx_TypeName obj_type_name;
      if (likely(PyType_Check(obj))) {
          #if __PYX_LIMITED_VERSION_HEX >= 0x03090000
          if ((PyTypeObject*)obj == &PyType_Type) {
              return Py_GenericAlias(obj, key);
          }
          #endif
          PyObject *meth = __Pyx_PyObject_GetAttrStrNoError(obj, __pyx_mstate_global->__pyx_n_u_class_getitem);
          if (!meth) {
              PyErr_Clear();
          } else {
              PyObject *result = __Pyx_PyObject_CallOneArg(meth, key);
              Py_DECREF(meth);
              return result;
          }
      }
      obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj));
      PyErr_Format(PyExc_TypeError,
          "'" __Pyx_FMT_TYPENAME "' object is not subscriptable", obj_type_name);
      __Pyx_DECREF_TypeName(obj_type_name);
      return NULL;
  }
  static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject *key) {
      PyTypeObject *tp = Py_TYPE(obj);
      PyMappingMethods *mm = tp->tp_as_mapping;
      PySequenceMethods *sm = tp->tp_as_sequence;
      if (likely(mm && mm->mp_subscript)) {
          return mm->mp_subscript(obj, key);
      }
      if (likely(sm && sm->sq_item)) {
          return __Pyx_PyObject_GetIndex(obj, key);
      }
      return __Pyx_PyObject_GetItem_Slow(obj, key);
  }
  #endif
  
/* RaiseUnboundLocalError */
  static void __Pyx_RaiseUnboundLocalError(const char *varname) {
      PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
  }
  
/* RaiseClosureNameError */
  static void __Pyx_RaiseClosureNameError(const char *varname) {
      PyErr_Format(PyExc_NameError, "free variable '%s' referenced before assignment in enclosing scope", varname);
  }
  
/* PyMethodNew (used by CythonFunctionShared) */
  #if CYTHON_COMPILING_IN_LIMITED_API
  static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) {
      PyObject *result;
      CYTHON_UNUSED_VAR(typ);
      if (!self)
          return __Pyx_NewRef(func);
      #if __PYX_LIMITED_VERSION_HEX >= 0x030C0000
      {
          PyObject *args[] = {func, self};
          result = PyObject_Vectorcall(__pyx_mstate_global->__Pyx_CachedMethodType, args, 2, NULL);
      }
      #else
      result = PyObject_CallFunctionObjArgs(__pyx_mstate_global->__Pyx_CachedMethodType, func, self, NULL);
      #endif
      return result;
  }
  #else
  static PyObject *__Pyx_PyMethod_New(PyObject *func, PyObject *self, PyObject *typ) {
      CYTHON_UNUSED_VAR(typ);
      if (!self)
          return __Pyx_NewRef(func);
      return PyMethod_New(func, self);
  }
  #endif
  
/* PyVectorcallFastCallDict (used by CythonFunctionShared) */
  #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL
  static PyObject *__Pyx_PyVectorcall_FastCallDict_kw(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw)
  {
      PyObject *res = NULL;
      PyObject *kwnames;
      PyObject **newargs;
      PyObject **kwvalues;
      Py_ssize_t i;
      #if CYTHON_AVOID_BORROWED_REFS
      PyObject *pos;
      #else
      Py_ssize_t pos;
      #endif
      size_t j;
      PyObject *key, *value;
      unsigned long keys_are_strings;
      #if !CYTHON_ASSUME_SAFE_SIZE
      Py_ssize_t nkw = PyDict_Size(kw);
      if (unlikely(nkw == -1)) return NULL;
      #else
      Py_ssize_t nkw = PyDict_GET_SIZE(kw);
      #endif
      newargs = (PyObject **)PyMem_Malloc((nargs + (size_t)nkw) * sizeof(args[0]));
      if (unlikely(newargs == NULL)) {
          PyErr_NoMemory();
          return NULL;
      }
      for (j = 0; j < nargs; j++) newargs[j] = args[j];
      kwnames = PyTuple_New(nkw);
      if (unlikely(kwnames == NULL)) {
          PyMem_Free(newargs);
          return NULL;
      }
      kwvalues = newargs + nargs;
      pos = 0;
      i = 0;
      keys_are_strings = Py_TPFLAGS_UNICODE_SUBCLASS;
      while (__Pyx_PyDict_NextRef(kw, &pos, &key, &value)) {
          keys_are_strings &=
          #if CYTHON_COMPILING_IN_LIMITED_API
              PyType_GetFlags(Py_TYPE(key));
          #else
              Py_TYPE(key)->tp_flags;
          #endif
          #if !CYTHON_ASSUME_SAFE_MACROS
          if (unlikely(PyTuple_SetItem(kwnames, i, key) < 0)) goto cleanup;
          #else
          PyTuple_SET_ITEM(kwnames, i, key);
          #endif
          kwvalues[i] = value;
          i++;
      }
      if (unlikely(!keys_are_strings)) {
          PyErr_SetString(PyExc_TypeError, "keywords must be strings");
          goto cleanup;
      }
      res = vc(func, newargs, nargs, kwnames);
  cleanup:
      #if CYTHON_AVOID_BORROWED_REFS
      Py_DECREF(pos);
      #endif
      Py_DECREF(kwnames);
      for (i = 0; i < nkw; i++)
          Py_DECREF(kwvalues[i]);
      PyMem_Free(newargs);
      return res;
  }
  static CYTHON_INLINE PyObject *__Pyx_PyVectorcall_FastCallDict(PyObject *func, __pyx_vectorcallfunc vc, PyObject *const *args, size_t nargs, PyObject *kw)
  {
      Py_ssize_t kw_size =
          likely(kw == NULL) ?
          0 :
  #if !CYTHON_ASSUME_SAFE_SIZE
          PyDict_Size(kw);
  #else
          PyDict_GET_SIZE(kw);
  #endif
      if (kw_size == 0) {
          return vc(func, args, nargs, NULL);
      }
  #if !CYTHON_ASSUME_SAFE_SIZE
      else if (unlikely(kw_size == -1)) {
          return NULL;
      }
  #endif
      return __Pyx_PyVectorcall_FastCallDict_kw(func, vc, args, nargs, kw);
  }
  #endif
  
/* CythonFunctionShared (used by CythonFunction) */
  #if CYTHON_COMPILING_IN_LIMITED_API
  static CYTHON_INLINE int __Pyx__IsSameCyOrCFunctionNoMethod(PyObject *func, void (*cfunc)(void)) {
      if (__Pyx_CyFunction_Check(func)) {
          return PyCFunction_GetFunction(((__pyx_CyFunctionObject*)func)->func) == (PyCFunction) cfunc;
      } else if (PyCFunction_Check(func)) {
          return PyCFunction_GetFunction(func) == (PyCFunction) cfunc;
      }
      return 0;
  }
  static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)) {
      if ((PyObject*)Py_TYPE(func) == __pyx_mstate_global->__Pyx_CachedMethodType) {
          int result;
          PyObject *newFunc = PyObject_GetAttr(func, __pyx_mstate_global->__pyx_n_u_func);
          if (unlikely(!newFunc)) {
              PyErr_Clear(); // It's only an optimization, so don't throw an error
              return 0;
          }
          result = __Pyx__IsSameCyOrCFunctionNoMethod(newFunc, cfunc);
          Py_DECREF(newFunc);
          return result;
      }
      return __Pyx__IsSameCyOrCFunctionNoMethod(func, cfunc);
  }
  #else
  static CYTHON_INLINE int __Pyx__IsSameCyOrCFunction(PyObject *func, void (*cfunc)(void)) {
      if (PyMethod_Check(func)) {
          func = PyMethod_GET_FUNCTION(func);
      }
      return __Pyx_CyOrPyCFunction_Check(func) && __Pyx_CyOrPyCFunction_GET_FUNCTION(func) == (PyCFunction) cfunc;
  }
  #endif
  static CYTHON_INLINE void __Pyx__CyFunction_SetClassObj(__pyx_CyFunctionObject* f, PyObject* classobj) {
  #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
      __Pyx_Py_XDECREF_SET(
          __Pyx_CyFunction_GetClassObj(f),
              ((classobj) ? __Pyx_NewRef(classobj) : NULL));
  #else
      __Pyx_Py_XDECREF_SET(
          ((PyCMethodObject *) (f))->mm_class,
          (PyTypeObject*)((classobj) ? __Pyx_NewRef(classobj) : NULL));
  #endif
  }
  static PyObject *
  __Pyx_CyFunction_get_doc_locked(__pyx_CyFunctionObject *op)
  {
      if (unlikely(op->func_doc == NULL)) {
  #if CYTHON_COMPILING_IN_LIMITED_API
          op->func_doc = PyObject_GetAttrString(op->func, "__doc__");
          if (unlikely(!op->func_doc)) return NULL;
  #else
          if (((PyCFunctionObject*)op)->m_ml->ml_doc) {
              op->func_doc = PyUnicode_FromString(((PyCFunctionObject*)op)->m_ml->ml_doc);
              if (unlikely(op->func_doc == NULL))
                  return NULL;
          } else {
              Py_INCREF(Py_None);
              return Py_None;
          }
  #endif
      }
      Py_INCREF(op->func_doc);
      return op->func_doc;
  }
  static PyObject *
  __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, void *closure) {
      PyObject *result;
      CYTHON_UNUSED_VAR(closure);
      __Pyx_BEGIN_CRITICAL_SECTION(op);
      result = __Pyx_CyFunction_get_doc_locked(op);
      __Pyx_END_CRITICAL_SECTION();
      return result;
  }
  static int
  __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, void *context)
  {
      CYTHON_UNUSED_VAR(context);
      if (value == NULL) {
          value = Py_None;
      }
      Py_INCREF(value);
      __Pyx_BEGIN_CRITICAL_SECTION(op);
      __Pyx_Py_XDECREF_SET(op->func_doc, value);
      __Pyx_END_CRITICAL_SECTION();
      return 0;
  }
  static PyObject *
  __Pyx_CyFunction_get_name_locked(__pyx_CyFunctionObject *op)
  {
      if (unlikely(op->func_name == NULL)) {
  #if CYTHON_COMPILING_IN_LIMITED_API
          op->func_name = PyObject_GetAttrString(op->func, "__name__");
  #else
          op->func_name = PyUnicode_InternFromString(((PyCFunctionObject*)op)->m_ml->ml_name);
  #endif
          if (unlikely(op->func_name == NULL))
              return NULL;
      }
      Py_INCREF(op->func_name);
      return op->func_name;
  }
  static PyObject *
  __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, void *context)
  {
      PyObject *result = NULL;
      CYTHON_UNUSED_VAR(context);
      __Pyx_BEGIN_CRITICAL_SECTION(op);
      result = __Pyx_CyFunction_get_name_locked(op);
      __Pyx_END_CRITICAL_SECTION();
      return result;
  }
  static int
  __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, void *context)
  {
      CYTHON_UNUSED_VAR(context);
      if (unlikely(value == NULL || !PyUnicode_Check(value))) {
          PyErr_SetString(PyExc_TypeError,
                          "__name__ must be set to a string object");
          return -1;
      }
      Py_INCREF(value);
      __Pyx_BEGIN_CRITICAL_SECTION(op);
      __Pyx_Py_XDECREF_SET(op->func_name, value);
      __Pyx_END_CRITICAL_SECTION();
      return 0;
  }
  static PyObject *
  __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, void *context)
  {
      CYTHON_UNUSED_VAR(context);
      PyObject *result;
      __Pyx_BEGIN_CRITICAL_SECTION(op);
      Py_INCREF(op->func_qualname);
      result = op->func_qualname;
      __Pyx_END_CRITICAL_SECTION();
      return result;
  }
  static int
  __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, void *context)
  {
      CYTHON_UNUSED_VAR(context);
      if (unlikely(value == NULL || !PyUnicode_Check(value))) {
          PyErr_SetString(PyExc_TypeError,
                          "__qualname__ must be set to a string object");
          return -1;
      }
      Py_INCREF(value);
      __Pyx_BEGIN_CRITICAL_SECTION(op);
      __Pyx_Py_XDECREF_SET(op->func_qualname, value);
      __Pyx_END_CRITICAL_SECTION();
      return 0;
  }
  #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  static PyObject *
  __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, void *context)
  {
      CYTHON_UNUSED_VAR(context);
      if (unlikely(op->func_dict == NULL)) {
          op->func_dict = PyDict_New();
          if (unlikely(op->func_dict == NULL))
              return NULL;
      }
      Py_INCREF(op->func_dict);
      return op->func_dict;
  }
  #endif
  static PyObject *
  __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, void *context)
  {
      CYTHON_UNUSED_VAR(context);
      Py_INCREF(op->func_globals);
      return op->func_globals;
  }
  static PyObject *
  __Pyx_CyFunction_get_closure(__pyx_CyFunctionObject *op, void *context)
  {
      CYTHON_UNUSED_VAR(op);
      CYTHON_UNUSED_VAR(context);
      Py_INCREF(Py_None);
      return Py_None;
  }
  static PyObject *
  __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, void *context)
  {
      PyObject* result = (op->func_code) ? op->func_code : Py_None;
      CYTHON_UNUSED_VAR(context);
      Py_INCREF(result);
      return result;
  }
  static int
  __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
      int result = 0;
      PyObject *res = op->defaults_getter((PyObject *) op);
      if (unlikely(!res))
          return -1;
      #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
      Py_INCREF(op->defaults_tuple);
      op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
      Py_INCREF(op->defaults_kwdict);
      #else
      op->defaults_tuple = __Pyx_PySequence_ITEM(res, 0);
      if (unlikely(!op->defaults_tuple)) result = -1;
      else {
          op->defaults_kwdict = __Pyx_PySequence_ITEM(res, 1);
          if (unlikely(!op->defaults_kwdict)) result = -1;
      }
      #endif
      Py_DECREF(res);
      return result;
  }
  static int
  __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
      CYTHON_UNUSED_VAR(context);
      if (!value) {
          value = Py_None;
      } else if (unlikely(value != Py_None && !PyTuple_Check(value))) {
          PyErr_SetString(PyExc_TypeError,
                          "__defaults__ must be set to a tuple object");
          return -1;
      }
      PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__defaults__ will not "
                   "currently affect the values used in function calls", 1);
      Py_INCREF(value);
      __Pyx_BEGIN_CRITICAL_SECTION(op);
      __Pyx_Py_XDECREF_SET(op->defaults_tuple, value);
      __Pyx_END_CRITICAL_SECTION();
      return 0;
  }
  static PyObject *
  __Pyx_CyFunction_get_defaults_locked(__pyx_CyFunctionObject *op) {
      PyObject* result = op->defaults_tuple;
      if (unlikely(!result)) {
          if (op->defaults_getter) {
              if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL;
              result = op->defaults_tuple;
          } else {
              result = Py_None;
          }
      }
      Py_INCREF(result);
      return result;
  }
  static PyObject *
  __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, void *context) {
      PyObject* result = NULL;
      CYTHON_UNUSED_VAR(context);
      __Pyx_BEGIN_CRITICAL_SECTION(op);
      result = __Pyx_CyFunction_get_defaults_locked(op);
      __Pyx_END_CRITICAL_SECTION();
      return result;
  }
  static int
  __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
      CYTHON_UNUSED_VAR(context);
      if (!value) {
          value = Py_None;
      } else if (unlikely(value != Py_None && !PyDict_Check(value))) {
          PyErr_SetString(PyExc_TypeError,
                          "__kwdefaults__ must be set to a dict object");
          return -1;
      }
      PyErr_WarnEx(PyExc_RuntimeWarning, "changes to cyfunction.__kwdefaults__ will not "
                   "currently affect the values used in function calls", 1);
      Py_INCREF(value);
      __Pyx_BEGIN_CRITICAL_SECTION(op);
      __Pyx_Py_XDECREF_SET(op->defaults_kwdict, value);
      __Pyx_END_CRITICAL_SECTION();
      return 0;
  }
  static PyObject *
  __Pyx_CyFunction_get_kwdefaults_locked(__pyx_CyFunctionObject *op) {
      PyObject* result = op->defaults_kwdict;
      if (unlikely(!result)) {
          if (op->defaults_getter) {
              if (unlikely(__Pyx_CyFunction_init_defaults(op) < 0)) return NULL;
              result = op->defaults_kwdict;
          } else {
              result = Py_None;
          }
      }
      Py_INCREF(result);
      return result;
  }
  static PyObject *
  __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, void *context) {
      PyObject* result;
      CYTHON_UNUSED_VAR(context);
      __Pyx_BEGIN_CRITICAL_SECTION(op);
      result = __Pyx_CyFunction_get_kwdefaults_locked(op);
      __Pyx_END_CRITICAL_SECTION();
      return result;
  }
  static int __Pyx_CyFunction_set_annotate_in_dict_if_exists(PyObject *op_in, PyObject *value);
  static int
  __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
      CYTHON_UNUSED_VAR(context);
      if (!value || value == Py_None) {
          value = NULL;
      } else if (unlikely(!PyDict_Check(value))) {
          PyErr_SetString(PyExc_TypeError,
                          "__annotations__ must be set to a dict object");
          return -1;
      }
      Py_XINCREF(value);
      __Pyx_BEGIN_CRITICAL_SECTION(op);
      __Pyx_Py_XDECREF_SET(op->func_annotations, value);
      __Pyx_END_CRITICAL_SECTION();
      if (unlikely(__Pyx_CyFunction_set_annotate_in_dict_if_exists((PyObject*) op, Py_None) < 0)) return -1;
      return 0;
  }
  static int
  __Pyx_CyFunction_get_dict_if_exists(PyObject *op_in, PyObject **dict) {
      /* Return 1 if the function dict exists, 0 otherwise.  This cannot fail:
       * _PyObject_GetDictPtr() may clear errors internally, but never reports them. */
  #if CYTHON_COMPILING_IN_PYPY
      *dict = PyObject_GenericGetDict(op_in, NULL);
  #elif CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX < 0x030C0000
      *dict = ((__pyx_CyFunctionObject*) op_in)->func_dict;
  #else
      PyObject **dictptr = _PyObject_GetDictPtr(op_in);
      *dict = likely(dictptr) ? *dictptr : NULL;
  #endif
      return *dict ? 1 : 0;
  }
  static int
  __Pyx_CyFunction_get_annotate_from_dict_if_exists(PyObject *op_in, PyObject **annotate) {
      PyObject *dict;
      int dict_found;
      *annotate = NULL;
      dict_found = __Pyx_CyFunction_get_dict_if_exists(op_in, &dict);
      if (!dict_found) return 0;
      return __Pyx_PyDict_GetItemRef(dict, __pyx_mstate_global->__pyx_n_u_annotate, annotate);
  }
  static int
  __Pyx_CyFunction_set_annotate_in_dict_if_exists(PyObject *op_in, PyObject *value) {
      PyObject *dict;
      int dict_found;
      dict_found = __Pyx_CyFunction_get_dict_if_exists(op_in, &dict);
      if (!dict_found) return 0;
      return PyDict_SetItem(dict, __pyx_mstate_global->__pyx_n_u_annotate, value);
  }
  static int
  __Pyx_CyFunction_set_annotate_in_dict(PyObject *op_in, PyObject *value) {
      PyObject *dict;
      int result;
  #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
      dict = __Pyx_CyFunction_get_dict((__pyx_CyFunctionObject*) op_in, NULL);
  #else
      dict = PyObject_GenericGetDict(op_in, NULL);
  #endif
      if (unlikely(!dict)) return -1;
      result = PyDict_SetItem(dict, __pyx_mstate_global->__pyx_n_u_annotate, value);
      Py_DECREF(dict);
      return result;
  }
  static PyObject *
  __Pyx_CyFunction_get_annotations_locked(__pyx_CyFunctionObject *op) {
      PyObject* result = op->func_annotations;
      if (unlikely(!result)) {
          result = PyDict_New();
          if (unlikely(!result)) return NULL;
          op->func_annotations = result;
      }
      Py_INCREF(result);
      return result;
  }
  static PyObject *
  __Pyx_CyFunction_get_annotations(PyObject *op_in, void *context) {
      PyObject *annotate = NULL;
      PyObject *result = NULL;
      __pyx_CyFunctionObject *op = (__pyx_CyFunctionObject*) op_in;
      CYTHON_UNUSED_VAR(context);
      __Pyx_BEGIN_CRITICAL_SECTION(op_in);
      result = __Pyx_XNewRef(op->func_annotations);
      __Pyx_END_CRITICAL_SECTION();
      if (result) return result;
      if (unlikely(__Pyx_CyFunction_get_annotate_from_dict_if_exists(op_in, &annotate) < 0)) return NULL;
      if (!annotate || annotate == Py_None) {
          Py_XDECREF(annotate);
          __Pyx_BEGIN_CRITICAL_SECTION(op_in);
          result = __Pyx_CyFunction_get_annotations_locked(op);
          __Pyx_END_CRITICAL_SECTION();
          return result;
      }
      PyObject *format = PyLong_FromLong(1L);  // annotationlib.Format.VALUE
      if (likely(format)) {
          result = __Pyx_PyObject_CallOneArg(annotate, format);
          Py_DECREF(format);
      }
      Py_DECREF(annotate);
      if (unlikely(!result)) return NULL;
      if (unlikely(!PyDict_Check(result))) {
          PyErr_SetString(PyExc_TypeError, "__annotate__ must return a dict");
          Py_DECREF(result);
          return NULL;
      }
      __Pyx_BEGIN_CRITICAL_SECTION(op_in);
      __Pyx_Py_XDECREF_SET(op->func_annotations, __Pyx_NewRef(result));
      __Pyx_END_CRITICAL_SECTION();
      return result;
  }
  static PyObject *__Pyx_CyFunction_annotate_impl(PyObject *self, PyObject *args) {
      CYTHON_UNUSED_VAR(args);
      if (unlikely(!self)) {
          PyErr_SetString(PyExc_SystemError, "cython __annotate__ called without 'self' argument");
      }
      Py_XINCREF(self);
      return self;
  }
  static PyMethodDef __Pyx_CyFunction_annotate_method = {
      "__annotate__",
      (PyCFunction)(void (*)(void))__Pyx_CyFunction_annotate_impl,
      METH_VARARGS,
      "Placeholder __annotate__ function to allow 'functools.wraps' to work "
      "on Cython functions."
  };
  static PyObject *
  __Pyx_CyFunction_get_annotate(PyObject *op_in, void *context) {
      PyObject *annotate = NULL;
      CYTHON_UNUSED_VAR(context);
      if (unlikely(__Pyx_CyFunction_get_annotate_from_dict_if_exists(op_in, &annotate) < 0)) return NULL;
      if (annotate) return annotate;
      PyObject *annotations = __Pyx_CyFunction_get_annotations(op_in, NULL);
      if (unlikely(!annotations)) return NULL;
      PyObject *method = PyCFunction_New(
          &__Pyx_CyFunction_annotate_method,
          annotations);
      Py_DECREF(annotations);
      return method;
  }
  static int
  __Pyx_CyFunction_set_annotate(PyObject *op_in, PyObject* value, void *context) {
      CYTHON_UNUSED_VAR(context);
      if (value == NULL) {
          PyErr_SetString(PyExc_TypeError, "__annotate__ cannot be deleted");
          return -1;
      }
      if (unlikely(value != Py_None && !PyCallable_Check(value))) {
          PyErr_SetString(PyExc_TypeError, "__annotate__ must be callable or None");
          return -1;
      }
      if (value != Py_None) {
          __pyx_CyFunctionObject *op = (__pyx_CyFunctionObject*) op_in;
          __Pyx_BEGIN_CRITICAL_SECTION(op_in);
          Py_CLEAR(op->func_annotations);
          __Pyx_END_CRITICAL_SECTION();
      }
      return __Pyx_CyFunction_set_annotate_in_dict(op_in, value);
  }
  static PyObject *
  __Pyx_CyFunction_get_is_coroutine_value(__pyx_CyFunctionObject *op) {
      int is_coroutine = op->flags & __Pyx_CYFUNCTION_COROUTINE;
      if (is_coroutine) {
          PyObject *is_coroutine_value, *module, *fromlist, *marker = __pyx_mstate_global->__pyx_n_u_is_coroutine;
          fromlist = PyList_New(1);
          if (unlikely(!fromlist)) return NULL;
          Py_INCREF(marker);
  #if CYTHON_ASSUME_SAFE_MACROS
          PyList_SET_ITEM(fromlist, 0, marker);
  #else
          if (unlikely(PyList_SetItem(fromlist, 0, marker) < 0)) {
              Py_DECREF(fromlist);
              return NULL;
          }
  #endif
          module = PyImport_ImportModuleLevelObject(__pyx_mstate_global->__pyx_n_u_asyncio_coroutines, NULL, NULL, fromlist, 0);
          Py_DECREF(fromlist);
          if (unlikely(!module)) goto ignore;
          is_coroutine_value = __Pyx_PyObject_GetAttrStr(module, marker);
          Py_DECREF(module);
          if (likely(is_coroutine_value)) {
              return is_coroutine_value;
          }
  ignore:
          PyErr_Clear();
      }
      return __Pyx_PyBool_FromLong(is_coroutine);
  }
  static PyObject *
  __Pyx_CyFunction_get_is_coroutine(__pyx_CyFunctionObject *op, void *context) {
      PyObject *result;
      CYTHON_UNUSED_VAR(context);
      if (op->func_is_coroutine) {
          return __Pyx_NewRef(op->func_is_coroutine);
      }
      result = __Pyx_CyFunction_get_is_coroutine_value(op);
      if (unlikely(!result))
          return NULL;
      __Pyx_BEGIN_CRITICAL_SECTION(op);
      if (op->func_is_coroutine) {
          Py_DECREF(result);
          result = __Pyx_NewRef(op->func_is_coroutine);
      } else {
          op->func_is_coroutine = __Pyx_NewRef(result);
      }
      __Pyx_END_CRITICAL_SECTION();
      return result;
  }
  static void __Pyx_CyFunction_raise_argument_count_error(__pyx_CyFunctionObject *func, const char* message, Py_ssize_t size) {
  #if CYTHON_COMPILING_IN_LIMITED_API
      PyObject *py_name = __Pyx_CyFunction_get_name(func, NULL);
      if (!py_name) return;
      PyErr_Format(PyExc_TypeError,
          "%.200S() %s (%" CYTHON_FORMAT_SSIZE_T "d given)",
          py_name, message, size);
      Py_DECREF(py_name);
  #else
      const char* name = ((PyCFunctionObject*)func)->m_ml->ml_name;
      PyErr_Format(PyExc_TypeError,
          "%.200s() %s (%" CYTHON_FORMAT_SSIZE_T "d given)",
          name, message, size);
  #endif
  }
  static void __Pyx_CyFunction_raise_type_error(__pyx_CyFunctionObject *func, const char* message) {
  #if CYTHON_COMPILING_IN_LIMITED_API
      PyObject *py_name = __Pyx_CyFunction_get_name(func, NULL);
      if (!py_name) return;
      PyErr_Format(PyExc_TypeError,
          "%.200S() %s",
          py_name, message);
      Py_DECREF(py_name);
  #else
      const char* name = ((PyCFunctionObject*)func)->m_ml->ml_name;
      PyErr_Format(PyExc_TypeError,
          "%.200s() %s",
          name, message);
  #endif
  }
  #if CYTHON_COMPILING_IN_LIMITED_API
  static PyObject *
  __Pyx_CyFunction_get_module(__pyx_CyFunctionObject *op, void *context) {
      CYTHON_UNUSED_VAR(context);
      return PyObject_GetAttrString(op->func, "__module__");
  }
  static int
  __Pyx_CyFunction_set_module(__pyx_CyFunctionObject *op, PyObject* value, void *context) {
      CYTHON_UNUSED_VAR(context);
      return PyObject_SetAttrString(op->func, "__module__", value);
  }
  #endif
  static PyGetSetDef __pyx_CyFunction_getsets[] = {
      {"func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
      {"__doc__",  (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
      {"func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
      {"__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
      {"__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
  #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
      {"func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)PyObject_GenericSetDict, 0, 0},
      {"__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)PyObject_GenericSetDict, 0, 0},
  #else
      {"func_dict", (getter)PyObject_GenericGetDict, (setter)PyObject_GenericSetDict, 0, 0},
      {"__dict__", (getter)PyObject_GenericGetDict, (setter)PyObject_GenericSetDict, 0, 0},
  #endif
      {"func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
      {"__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
      {"func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
      {"__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
      {"func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
      {"__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
      {"func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
      {"__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
      {"__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
      {"__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
      {"__annotate__", (getter)__Pyx_CyFunction_get_annotate, (setter)__Pyx_CyFunction_set_annotate, 0, 0},
      {"_is_coroutine", (getter)__Pyx_CyFunction_get_is_coroutine, 0, 0, 0},
  #if CYTHON_COMPILING_IN_LIMITED_API
      {"__module__", (getter)__Pyx_CyFunction_get_module, (setter)__Pyx_CyFunction_set_module, 0, 0},
  #endif
      {0, 0, 0, 0, 0}
  };
  static PyMemberDef __pyx_CyFunction_members[] = {
  #if !CYTHON_COMPILING_IN_LIMITED_API
      {"__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), 0, 0},
  #endif
  #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
      {"__dictoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_dict), READONLY, 0},
  #endif
  #if CYTHON_METH_FASTCALL
  #if CYTHON_COMPILING_IN_LIMITED_API
      {"__vectorcalloffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_vectorcall), READONLY, 0},
  #else
      {"__vectorcalloffset__", T_PYSSIZET, offsetof(PyCFunctionObject, vectorcall), READONLY, 0},
  #endif
  #if CYTHON_COMPILING_IN_LIMITED_API
      {"__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CyFunctionObject, func_weakreflist), READONLY, 0},
  #else
      {"__weaklistoffset__", T_PYSSIZET, offsetof(PyCFunctionObject, m_weakreflist), READONLY, 0},
  #endif
  #endif
      {0, 0, 0,  0, 0}
  };
  static PyObject *
  __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, PyObject *args)
  {
      PyObject *result = NULL;
      CYTHON_UNUSED_VAR(args);
      __Pyx_BEGIN_CRITICAL_SECTION(m);
      Py_INCREF(m->func_qualname);
      result = m->func_qualname;
      __Pyx_END_CRITICAL_SECTION();
      return result;
  }
  static PyMethodDef __pyx_CyFunction_methods[] = {
      {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
      {0, 0, 0, 0}
  };
  #if CYTHON_COMPILING_IN_LIMITED_API
  #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
  #else
  #define __Pyx_CyFunction_weakreflist(cyfunc) (((PyCFunctionObject*)cyfunc)->m_weakreflist)
  #endif
  static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname,
                                         PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
  #if !CYTHON_COMPILING_IN_LIMITED_API
      PyCFunctionObject *cf = (PyCFunctionObject*) op;
  #endif
      if (unlikely(op == NULL))
          return NULL;
  #if CYTHON_COMPILING_IN_LIMITED_API
      op->func = PyCFunction_NewEx(ml, (PyObject*)op, module);
      if (unlikely(!op->func)) return NULL;
  #endif
      op->flags = flags;
      __Pyx_CyFunction_weakreflist(op) = NULL;
  #if !CYTHON_COMPILING_IN_LIMITED_API
      cf->m_ml = ml;
      cf->m_self = (PyObject *) op;
  #endif
      Py_XINCREF(closure);
      op->func_closure = closure;
  #if !CYTHON_COMPILING_IN_LIMITED_API
      Py_XINCREF(module);
      cf->m_module = module;
  #endif
  #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
      op->func_dict = NULL;
  #endif
      op->func_name = NULL;
      Py_INCREF(qualname);
      op->func_qualname = qualname;
      op->func_doc = NULL;
  #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
      op->func_classobj = NULL;
  #else
      ((PyCMethodObject*)op)->mm_class = NULL;
  #endif
      op->func_globals = globals;
      Py_INCREF(op->func_globals);
      Py_XINCREF(code);
      op->func_code = code;
      op->defaults = NULL;
      op->defaults_tuple = NULL;
      op->defaults_kwdict = NULL;
      op->defaults_getter = NULL;
      op->func_annotations = NULL;
      op->func_is_coroutine = NULL;
  #if CYTHON_METH_FASTCALL
      switch (ml->ml_flags & (METH_VARARGS | METH_FASTCALL | METH_NOARGS | METH_O | METH_KEYWORDS | METH_METHOD)) {
      case METH_NOARGS:
          __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_NOARGS;
          break;
      case METH_O:
          __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_O;
          break;
      case METH_METHOD | METH_FASTCALL | METH_KEYWORDS:
          __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD;
          break;
      case METH_FASTCALL | METH_KEYWORDS:
          __Pyx_CyFunction_func_vectorcall(op) = __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS;
          break;
      case METH_VARARGS | METH_KEYWORDS:
          __Pyx_CyFunction_func_vectorcall(op) = NULL;
          break;
      default:
          PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction");
          Py_DECREF(op);
          return NULL;
      }
  #endif
      return (PyObject *) op;
  }
  static int
  __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
  {
      Py_CLEAR(m->func_closure);
  #if CYTHON_COMPILING_IN_LIMITED_API
      Py_CLEAR(m->func);
  #else
      Py_CLEAR(((PyCFunctionObject*)m)->m_module);
  #endif
  #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
      Py_CLEAR(m->func_dict);
  #elif PY_VERSION_HEX < 0x030d0000
      _PyObject_ClearManagedDict((PyObject*)m);
  #else
      PyObject_ClearManagedDict((PyObject*)m);
  #endif
      Py_CLEAR(m->func_name);
      Py_CLEAR(m->func_qualname);
      Py_CLEAR(m->func_doc);
      Py_CLEAR(m->func_globals);
      Py_CLEAR(m->func_code);
  #if PY_VERSION_HEX < 0x030900B1 || CYTHON_COMPILING_IN_LIMITED_API
      Py_CLEAR(__Pyx_CyFunction_GetClassObj(m));
  #else
      {
          PyObject *cls = (PyObject*) ((PyCMethodObject *) (m))->mm_class;
          ((PyCMethodObject *) (m))->mm_class = NULL;
          Py_XDECREF(cls);
      }
  #endif
      Py_CLEAR(m->defaults_tuple);
      Py_CLEAR(m->defaults_kwdict);
      Py_CLEAR(m->func_annotations);
      Py_CLEAR(m->func_is_coroutine);
      Py_CLEAR(m->defaults);
      return 0;
  }
  static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
  {
      if (__Pyx_CyFunction_weakreflist(m) != NULL)
          PyObject_ClearWeakRefs((PyObject *) m);
      __Pyx_CyFunction_clear(m);
      __Pyx_PyHeapTypeObject_GC_Del(m);
  }
  static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
  {
      PyObject_GC_UnTrack(m);
      __Pyx__CyFunction_dealloc(m);
  }
  static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
  {
      {
          int e = __Pyx_call_type_traverse((PyObject*)m, 1, visit, arg);
          if (e) return e;
      }
      Py_VISIT(m->func_closure);
  #if CYTHON_COMPILING_IN_LIMITED_API
      Py_VISIT(m->func);
  #else
      Py_VISIT(((PyCFunctionObject*)m)->m_module);
  #endif
  #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
      Py_VISIT(m->func_dict);
  #else
      {
          int e =
  #if PY_VERSION_HEX < 0x030d0000
              _PyObject_VisitManagedDict
  #else
              PyObject_VisitManagedDict
  #endif
                  ((PyObject*)m, visit, arg);
          if (e != 0) return e;
      }
  #endif
      __Pyx_VISIT_CONST(m->func_name);
      __Pyx_VISIT_CONST(m->func_qualname);
      Py_VISIT(m->func_doc);
      Py_VISIT(m->func_globals);
      __Pyx_VISIT_CONST(m->func_code);
      Py_VISIT(__Pyx_CyFunction_GetClassObj(m));
      Py_VISIT(m->defaults_tuple);
      Py_VISIT(m->defaults_kwdict);
      Py_VISIT(m->func_annotations);
      Py_VISIT(m->func_is_coroutine);
      Py_VISIT(m->defaults);
      return 0;
  }
  static PyObject*
  __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
  {
      PyObject *repr;
      __Pyx_BEGIN_CRITICAL_SECTION(op);
      repr = PyUnicode_FromFormat("<cyfunction %U at %p>",
                                  op->func_qualname, (void *)op);
      __Pyx_END_CRITICAL_SECTION();
      return repr;
  }
  static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
  #if CYTHON_COMPILING_IN_LIMITED_API
      PyObject *f = ((__pyx_CyFunctionObject*)func)->func;
      PyCFunction meth;
      int flags;
      meth = PyCFunction_GetFunction(f);
      if (unlikely(!meth)) return NULL;
      flags = PyCFunction_GetFlags(f);
      if (unlikely(flags < 0)) return NULL;
  #else
      PyCFunctionObject* f = (PyCFunctionObject*)func;
      PyCFunction meth = f->m_ml->ml_meth;
      int flags = f->m_ml->ml_flags;
  #endif
      Py_ssize_t size;
      switch (flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
      case METH_VARARGS:
          if (likely(kw == NULL || PyDict_Size(kw) == 0))
              return (*meth)(self, arg);
          break;
      case METH_VARARGS | METH_KEYWORDS:
          return (*(PyCFunctionWithKeywords)(void(*)(void))meth)(self, arg, kw);
      case METH_NOARGS:
          if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
  #if CYTHON_ASSUME_SAFE_SIZE
              size = PyTuple_GET_SIZE(arg);
  #else
              size = PyTuple_Size(arg);
              if (unlikely(size < 0)) return NULL;
  #endif
              if (likely(size == 0))
                  return (*meth)(self, NULL);
              __Pyx_CyFunction_raise_argument_count_error(
                  (__pyx_CyFunctionObject*)func,
                  "takes no arguments", size);
              return NULL;
          }
          break;
      case METH_O:
          if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
  #if CYTHON_ASSUME_SAFE_SIZE
              size = PyTuple_GET_SIZE(arg);
  #else
              size = PyTuple_Size(arg);
              if (unlikely(size < 0)) return NULL;
  #endif
              if (likely(size == 1)) {
                  PyObject *result, *arg0;
                  #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
                  arg0 = PyTuple_GET_ITEM(arg, 0);
                  #else
                  arg0 = __Pyx_PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
                  #endif
                  result = (*meth)(self, arg0);
                  #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
                  Py_DECREF(arg0);
                  #endif
                  return result;
              }
              __Pyx_CyFunction_raise_argument_count_error(
                  (__pyx_CyFunctionObject*)func,
                  "takes exactly one argument", size);
              return NULL;
          }
          break;
      default:
          PyErr_SetString(PyExc_SystemError, "Bad call flags for CyFunction");
          return NULL;
      }
      __Pyx_CyFunction_raise_type_error(
          (__pyx_CyFunctionObject*)func, "takes no keyword arguments");
      return NULL;
  }
  static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
      PyObject *self, *result;
  #if CYTHON_COMPILING_IN_LIMITED_API
      self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)func)->func);
      if (unlikely(!self) && PyErr_Occurred()) return NULL;
  #else
      self = ((PyCFunctionObject*)func)->m_self;
  #endif
      result = __Pyx_CyFunction_CallMethod(func, self, arg, kw);
      return result;
  }
  static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
      PyObject *result;
      __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
  #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL
       __pyx_vectorcallfunc vc = __Pyx_CyFunction_func_vectorcall(cyfunc);
      if (vc) {
  #if CYTHON_ASSUME_SAFE_MACROS && CYTHON_ASSUME_SAFE_SIZE
          return __Pyx_PyVectorcall_FastCallDict(func, vc, &PyTuple_GET_ITEM(args, 0), (size_t)PyTuple_GET_SIZE(args), kw);
  #else
          (void) &__Pyx_PyVectorcall_FastCallDict;
          return PyVectorcall_Call(func, args, kw);
  #endif
      }
  #endif
      if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
          Py_ssize_t argc;
          PyObject *new_args;
          PyObject *self;
  #if CYTHON_ASSUME_SAFE_SIZE
          argc = PyTuple_GET_SIZE(args);
  #else
          argc = PyTuple_Size(args);
          if (unlikely(argc < 0)) return NULL;
  #endif
          new_args = PyTuple_GetSlice(args, 1, argc);
          if (unlikely(!new_args))
              return NULL;
          self = PyTuple_GetItem(args, 0);
          if (unlikely(!self)) {
              Py_DECREF(new_args);
              PyErr_Format(PyExc_TypeError,
                           "unbound method %.200S() needs an argument",
                           cyfunc->func_qualname);
              return NULL;
          }
          result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
          Py_DECREF(new_args);
      } else {
          result = __Pyx_CyFunction_Call(func, args, kw);
      }
      return result;
  }
  #if CYTHON_METH_FASTCALL && CYTHON_VECTORCALL
  static CYTHON_INLINE int __Pyx_CyFunction_Vectorcall_CheckArgs(__pyx_CyFunctionObject *cyfunc, Py_ssize_t nargs, PyObject *kwnames)
  {
      int ret = 0;
      if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
          if (unlikely(nargs < 1)) {
              __Pyx_CyFunction_raise_type_error(
                  cyfunc, "needs an argument");
              return -1;
          }
          ret = 1;
      }
      if (unlikely(kwnames) && unlikely(__Pyx_PyTuple_GET_SIZE(kwnames))) {
          __Pyx_CyFunction_raise_type_error(
              cyfunc, "takes no keyword arguments");
          return -1;
      }
      return ret;
  }
  static PyObject * __Pyx_CyFunction_Vectorcall_NOARGS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
  {
      __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
      Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
      PyObject *self;
  #if CYTHON_COMPILING_IN_LIMITED_API
      PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
      if (unlikely(!meth)) return NULL;
  #else
      PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
  #endif
      switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) {
      case 1:
          self = args[0];
          args += 1;
          nargs -= 1;
          break;
      case 0:
  #if CYTHON_COMPILING_IN_LIMITED_API
          self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
          if (unlikely(!self) && PyErr_Occurred()) return NULL;
  #else
          self = ((PyCFunctionObject*)cyfunc)->m_self;
  #endif
          break;
      default:
          return NULL;
      }
      if (unlikely(nargs != 0)) {
          __Pyx_CyFunction_raise_argument_count_error(
              cyfunc, "takes no arguments", nargs);
          return NULL;
      }
      return meth(self, NULL);
  }
  static PyObject * __Pyx_CyFunction_Vectorcall_O(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
  {
      __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
      Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
      PyObject *self;
  #if CYTHON_COMPILING_IN_LIMITED_API
      PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
      if (unlikely(!meth)) return NULL;
  #else
      PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
  #endif
      switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, kwnames)) {
      case 1:
          self = args[0];
          args += 1;
          nargs -= 1;
          break;
      case 0:
  #if CYTHON_COMPILING_IN_LIMITED_API
          self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
          if (unlikely(!self) && PyErr_Occurred()) return NULL;
  #else
          self = ((PyCFunctionObject*)cyfunc)->m_self;
  #endif
          break;
      default:
          return NULL;
      }
      if (unlikely(nargs != 1)) {
          __Pyx_CyFunction_raise_argument_count_error(
              cyfunc, "takes exactly one argument", nargs);
          return NULL;
      }
      return meth(self, args[0]);
  }
  static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
  {
      __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
      Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
      PyObject *self;
  #if CYTHON_COMPILING_IN_LIMITED_API
      PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
      if (unlikely(!meth)) return NULL;
  #else
      PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
  #endif
      switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) {
      case 1:
          self = args[0];
          args += 1;
          nargs -= 1;
          break;
      case 0:
  #if CYTHON_COMPILING_IN_LIMITED_API
          self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
          if (unlikely(!self) && PyErr_Occurred()) return NULL;
  #else
          self = ((PyCFunctionObject*)cyfunc)->m_self;
  #endif
          break;
      default:
          return NULL;
      }
      return ((__Pyx_PyCFunctionFastWithKeywords)(void(*)(void))meth)(self, args, nargs, kwnames);
  }
  static PyObject * __Pyx_CyFunction_Vectorcall_FASTCALL_KEYWORDS_METHOD(PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
  {
      __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *)func;
      PyTypeObject *cls = (PyTypeObject *) __Pyx_CyFunction_GetClassObj(cyfunc);
      Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
      PyObject *self;
  #if CYTHON_COMPILING_IN_LIMITED_API
      PyCFunction meth = PyCFunction_GetFunction(cyfunc->func);
      if (unlikely(!meth)) return NULL;
  #else
      PyCFunction meth = ((PyCFunctionObject*)cyfunc)->m_ml->ml_meth;
  #endif
      switch (__Pyx_CyFunction_Vectorcall_CheckArgs(cyfunc, nargs, NULL)) {
      case 1:
          self = args[0];
          args += 1;
          nargs -= 1;
          break;
      case 0:
  #if CYTHON_COMPILING_IN_LIMITED_API
          self = PyCFunction_GetSelf(((__pyx_CyFunctionObject*)cyfunc)->func);
          if (unlikely(!self) && PyErr_Occurred()) return NULL;
  #else
          self = ((PyCFunctionObject*)cyfunc)->m_self;
  #endif
          break;
      default:
          return NULL;
      }
      #if PY_VERSION_HEX < 0x030e00A6
      size_t nargs_value = (size_t) nargs;
      #else
      Py_ssize_t nargs_value = nargs;
      #endif
      return ((__Pyx_PyCMethod)(void(*)(void))meth)(self, cls, args, nargs_value, kwnames);
  }
  #endif
  static PyType_Slot __pyx_CyFunctionType_slots[] = {
      {Py_tp_dealloc, (void *)__Pyx_CyFunction_dealloc},
      {Py_tp_repr, (void *)__Pyx_CyFunction_repr},
      {Py_tp_call, (void *)__Pyx_CyFunction_CallAsMethod},
      {Py_tp_traverse, (void *)__Pyx_CyFunction_traverse},
      {Py_tp_clear, (void *)__Pyx_CyFunction_clear},
      {Py_tp_methods, (void *)__pyx_CyFunction_methods},
      {Py_tp_members, (void *)__pyx_CyFunction_members},
      {Py_tp_getset, (void *)__pyx_CyFunction_getsets},
      {Py_tp_descr_get, (void *)__Pyx_PyMethod_New},
      {0, 0},
  };
  static PyType_Spec __pyx_CyFunctionType_spec = {
      __PYX_TYPE_MODULE_PREFIX "cython_function_or_method",
      sizeof(__pyx_CyFunctionObject),
      0,
  #ifdef Py_TPFLAGS_METHOD_DESCRIPTOR
      Py_TPFLAGS_METHOD_DESCRIPTOR |
  #endif
  #if CYTHON_METH_FASTCALL
  #if defined(Py_TPFLAGS_HAVE_VECTORCALL)
      Py_TPFLAGS_HAVE_VECTORCALL |
  #elif defined(_Py_TPFLAGS_HAVE_VECTORCALL)
      _Py_TPFLAGS_HAVE_VECTORCALL |
  #endif
  #endif // CYTHON_METH_FASTCALL
  #if PY_VERSION_HEX >= 0x030C0000 && !CYTHON_COMPILING_IN_LIMITED_API
      Py_TPFLAGS_MANAGED_DICT |
  #endif
      Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION |
      Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_BASETYPE,
      __pyx_CyFunctionType_slots
  };
  static int __pyx_CyFunction_init(PyObject *module) {
      __pyx_mstatetype *mstate = __Pyx_PyModule_GetState(module);
      mstate->__pyx_CyFunctionType = __Pyx_FetchCommonTypeFromSpec(
          mstate->__pyx_CommonTypesMetaclassType, module, &__pyx_CyFunctionType_spec, NULL);
      if (unlikely(mstate->__pyx_CyFunctionType == NULL)) {
          return -1;
      }
      return 0;
  }
  static CYTHON_INLINE PyObject *__Pyx_CyFunction_InitDefaults(PyObject *func, PyTypeObject *defaults_type) {
      __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
      m->defaults = PyObject_CallObject((PyObject*)defaults_type, NULL); // _PyObject_New(defaults_type);
      if (unlikely(!m->defaults))
          return NULL;
      return m->defaults;
  }
  static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
      __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
      m->defaults_tuple = tuple;
      Py_INCREF(tuple);
  }
  static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
      __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
      m->defaults_kwdict = dict;
      Py_INCREF(dict);
  }
  static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
      __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
      m->func_annotations = dict;
      Py_INCREF(dict);
  }
  
/* CythonFunction */
  static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname,
                                        PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
      PyObject *op = __Pyx_CyFunction_Init(
          PyObject_GC_New(__pyx_CyFunctionObject, __pyx_mstate_global->__pyx_CyFunctionType),
          ml, flags, qualname, closure, module, globals, code
      );
      if (likely(op)) {
          PyObject_GC_Track(op);
      }
      return op;
  }
  
/* DictGetItem */
  #if !CYTHON_COMPILING_IN_PYPY
  static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
      PyObject *value;
      if (unlikely(__Pyx_PyDict_GetItemRef(d, key, &value) == 0)) { // no value, no error
          if (unlikely(PyTuple_Check(key))) {
              PyObject* args = PyTuple_Pack(1, key);
              if (likely(args)) {
                  PyErr_SetObject(PyExc_KeyError, args);
                  Py_DECREF(args);
              }
          } else {
              PyErr_SetObject(PyExc_KeyError, key);
          }
      }
      return value;
  }
  #endif
  
/* JoinPyUnicode */
  static PyObject* __Pyx_PyUnicode_Join(PyObject** values, Py_ssize_t value_count, Py_ssize_t result_ulength,
                                        Py_UCS4 max_char) {
  #if CYTHON_USE_UNICODE_INTERNALS && CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
      PyObject *result_uval;
      int result_ukind, kind_shift;
      Py_ssize_t i, char_pos;
      void *result_udata;
      if (max_char > 1114111) max_char = 1114111;
      result_uval = PyUnicode_New(result_ulength, max_char);
      if (unlikely(!result_uval)) return NULL;
      result_ukind = (max_char <= 255) ? PyUnicode_1BYTE_KIND : (max_char <= 65535) ? PyUnicode_2BYTE_KIND : PyUnicode_4BYTE_KIND;
      kind_shift = (result_ukind == PyUnicode_4BYTE_KIND) ? 2 : result_ukind - 1;
      result_udata = PyUnicode_DATA(result_uval);
      assert(kind_shift == 2 || kind_shift == 1 || kind_shift == 0);
      if (unlikely((PY_SSIZE_T_MAX >> kind_shift) - result_ulength < 0))
          goto overflow;
      char_pos = 0;
      for (i=0; i < value_count; i++) {
          int ukind;
          Py_ssize_t ulength;
          void *udata;
          PyObject *uval = values[i];
          #if !CYTHON_COMPILING_IN_LIMITED_API
          if (__Pyx_PyUnicode_READY(uval) == (-1))
              goto bad;
          #endif
          ulength = __Pyx_PyUnicode_GET_LENGTH(uval);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely(ulength < 0)) goto bad;
          #endif
          if (unlikely(!ulength))
              continue;
          if (unlikely((PY_SSIZE_T_MAX >> kind_shift) - ulength < char_pos))
              goto overflow;
          ukind = __Pyx_PyUnicode_KIND(uval);
          udata = __Pyx_PyUnicode_DATA(uval);
          if (ukind == result_ukind) {
              memcpy((char *)result_udata + (char_pos << kind_shift), udata, (size_t) (ulength << kind_shift));
          } else {
              #if PY_VERSION_HEX >= 0x030d0000
              if (unlikely(PyUnicode_CopyCharacters(result_uval, char_pos, uval, 0, ulength) < 0)) goto bad;
              #elif CYTHON_COMPILING_IN_CPYTHON || defined(_PyUnicode_FastCopyCharacters)
              _PyUnicode_FastCopyCharacters(result_uval, char_pos, uval, 0, ulength);
              #else
              Py_ssize_t j;
              for (j=0; j < ulength; j++) {
                  Py_UCS4 uchar = __Pyx_PyUnicode_READ(ukind, udata, j);
                  __Pyx_PyUnicode_WRITE(result_ukind, result_udata, char_pos+j, uchar);
              }
              #endif
          }
          char_pos += ulength;
      }
      return result_uval;
  overflow:
      PyErr_SetString(PyExc_OverflowError, "join() result is too long for a Python string");
  bad:
      Py_DECREF(result_uval);
      return NULL;
  #else
      Py_ssize_t i;
      PyObject *result = NULL;
      PyObject *value_tuple = PyTuple_New(value_count);
      if (unlikely(!value_tuple)) return NULL;
      CYTHON_UNUSED_VAR(max_char);
      CYTHON_UNUSED_VAR(result_ulength);
      for (i=0; i<value_count; i++) {
          Py_INCREF(values[i]);
          if (__Pyx_PyTuple_SET_ITEM(value_tuple, i, values[i]) != (0)) goto bad;
      }
      result = PyUnicode_Join(__pyx_mstate_global->__pyx_empty_unicode, value_tuple);
  bad:
      Py_DECREF(value_tuple);
      return result;
  #endif
  }
  
/* RaiseMappingExpected */
  static void __Pyx_RaiseMappingExpectedError(PyObject* arg) {
      __Pyx_TypeName arg_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(arg));
      PyErr_Format(PyExc_TypeError,
          "'" __Pyx_FMT_TYPENAME "' object is not a mapping", arg_type_name);
      __Pyx_DECREF_TypeName(arg_type_name);
  }
  
/* pybytes_as_double (used by pynumber_float) */
  static double __Pyx_SlowPyString_AsDouble(PyObject *obj) {
      PyObject *float_value = PyFloat_FromString(obj);
      if (likely(float_value)) {
          double value = __Pyx_PyFloat_AS_DOUBLE(float_value);
          Py_DECREF(float_value);
          return value;
      }
      return (double)-1;
  }
  static const char* __Pyx__PyBytes_AsDouble_Copy(const char* start, char* buffer, Py_ssize_t length) {
      int last_was_punctuation = 1;
      int parse_error_found = 0;
      Py_ssize_t i;
      for (i=0; i < length; i++) {
          char chr = start[i];
          int is_punctuation = (chr == '_') | (chr == '.') | (chr == 'e') | (chr == 'E');
          *buffer = chr;
          buffer += (chr != '_');
          parse_error_found |= last_was_punctuation & is_punctuation;
          last_was_punctuation = is_punctuation;
      }
      parse_error_found |= last_was_punctuation;
      *buffer = '\0';
      return unlikely(parse_error_found) ? NULL : buffer;
  }
  static double __Pyx__PyBytes_AsDouble_inf_nan(const char* start, Py_ssize_t length) {
      int matches = 1;
      char sign = start[0];
      int is_signed = (sign == '+') | (sign == '-');
      start += is_signed;
      length -= is_signed;
      switch (start[0]) {
          #ifdef Py_NAN
          case 'n':
          case 'N':
              if (unlikely(length != 3)) goto parse_failure;
              matches &= (start[1] == 'a' || start[1] == 'A');
              matches &= (start[2] == 'n' || start[2] == 'N');
              if (unlikely(!matches)) goto parse_failure;
              return (sign == '-') ? -Py_NAN : Py_NAN;
          #endif
          case 'i':
          case 'I':
              if (unlikely(length < 3)) goto parse_failure;
              matches &= (start[1] == 'n' || start[1] == 'N');
              matches &= (start[2] == 'f' || start[2] == 'F');
              if (likely(length == 3 && matches))
                  return (sign == '-') ? -Py_HUGE_VAL : Py_HUGE_VAL;
              if (unlikely(length != 8)) goto parse_failure;
              matches &= (start[3] == 'i' || start[3] == 'I');
              matches &= (start[4] == 'n' || start[4] == 'N');
              matches &= (start[5] == 'i' || start[5] == 'I');
              matches &= (start[6] == 't' || start[6] == 'T');
              matches &= (start[7] == 'y' || start[7] == 'Y');
              if (unlikely(!matches)) goto parse_failure;
              return (sign == '-') ? -Py_HUGE_VAL : Py_HUGE_VAL;
          case '.': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9':
              break;
          default:
              goto parse_failure;
      }
      return 0.0;
  parse_failure:
      return -1.0;
  }
  static CYTHON_INLINE int __Pyx__PyBytes_AsDouble_IsSpace(char ch) {
      return (ch == 0x20) | !((ch < 0x9) | (ch > 0xd));
  }
  CYTHON_UNUSED static double __Pyx__PyBytes_AsDouble(PyObject *obj, const char* start, Py_ssize_t length) {
      double value;
      Py_ssize_t i, digits;
      const char *last = start + length;
      char *end;
      while (__Pyx__PyBytes_AsDouble_IsSpace(*start))
          start++;
      while (start < last - 1 && __Pyx__PyBytes_AsDouble_IsSpace(last[-1]))
          last--;
      length = last - start;
      if (unlikely(length <= 0)) goto fallback;
      value = __Pyx__PyBytes_AsDouble_inf_nan(start, length);
      if (unlikely(value == -1.0)) goto fallback;
      if (value != 0.0) return value;
      digits = 0;
      for (i=0; i < length; digits += start[i++] != '_');
      if (likely(digits == length)) {
          value = PyOS_string_to_double(start, &end, NULL);
      } else if (digits < 40) {
          char number[40];
          last = __Pyx__PyBytes_AsDouble_Copy(start, number, length);
          if (unlikely(!last)) goto fallback;
          value = PyOS_string_to_double(number, &end, NULL);
      } else {
          char *number = (char*) PyMem_Malloc((digits + 1) * sizeof(char));
          if (unlikely(!number)) goto fallback;
          last = __Pyx__PyBytes_AsDouble_Copy(start, number, length);
          if (unlikely(!last)) {
              PyMem_Free(number);
              goto fallback;
          }
          value = PyOS_string_to_double(number, &end, NULL);
          PyMem_Free(number);
      }
      if (likely(end == last) || (value == (double)-1 && PyErr_Occurred())) {
          return value;
      }
  fallback:
      return __Pyx_SlowPyString_AsDouble(obj);
  }
  
/* pynumber_float */
  static CYTHON_INLINE PyObject* __Pyx__PyNumber_Float(PyObject* obj) {
      double val;
      if (PyLong_CheckExact(obj)) {
  #if CYTHON_USE_PYLONG_INTERNALS
          if (likely(__Pyx_PyLong_IsCompact(obj))) {
              val = (double) __Pyx_PyLong_CompactValue(obj);
              goto no_error;
          }
  #endif
          val = PyLong_AsDouble(obj);
      } else if (PyUnicode_CheckExact(obj)) {
          val = __Pyx_PyUnicode_AsDouble(obj);
      } else if (PyBytes_CheckExact(obj)) {
          val = __Pyx_PyBytes_AsDouble(obj);
      } else if (PyByteArray_CheckExact(obj)) {
          val = __Pyx_PyByteArray_AsDouble(obj);
      } else {
          return PyNumber_Float(obj);
      }
      if (unlikely(val == -1 && PyErr_Occurred())) {
          return NULL;
      }
  #if CYTHON_USE_PYLONG_INTERNALS
  no_error:
  #endif
      return PyFloat_FromDouble(val);
  }
  
/* UnicodeConcatInPlace */
  # if CYTHON_COMPILING_IN_CPYTHON
  static int
  __Pyx_unicode_modifiable(PyObject *unicode, int unsafe_shared)
  {
      if (!__Pyx_IS_UNIQUELY_REFERENCED(unicode, unsafe_shared))
          return 0;
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX > 0x030F0000
      if (PyUnstable_Unicode_GET_CACHED_HASH(unicode) != -1)
          return 0;
  #endif
      if (!PyUnicode_CheckExact(unicode))
          return 0;
      if (PyUnicode_CHECK_INTERNED(unicode))
          return 0;
      return 1;
  }
  static CYTHON_INLINE PyObject *__Pyx_PyUnicode_ConcatInPlaceImpl(PyObject **p_left, PyObject *right, int unsafe_shared
          #if CYTHON_REFNANNY
          , void* __pyx_refnanny
          #endif
      ) {
      PyObject *left = *p_left;
      Py_ssize_t left_len, right_len, new_len;
      if (unlikely(__Pyx_PyUnicode_READY(left) == -1))
          return NULL;
      if (unlikely(__Pyx_PyUnicode_READY(right) == -1))
          return NULL;
      left_len = PyUnicode_GET_LENGTH(left);
      if (left_len == 0) {
          Py_INCREF(right);
          return right;
      }
      right_len = PyUnicode_GET_LENGTH(right);
      if (right_len == 0) {
          Py_INCREF(left);
          return left;
      }
      if (unlikely(left_len > PY_SSIZE_T_MAX - right_len)) {
          PyErr_SetString(PyExc_OverflowError,
                          "strings are too large to concat");
          return NULL;
      }
      new_len = left_len + right_len;
      if (left != right
              && __Pyx_unicode_modifiable(left, unsafe_shared)
              && PyUnicode_CheckExact(right)
              && PyUnicode_KIND(right) <= PyUnicode_KIND(left)
              && !(PyUnicode_IS_ASCII(left) && !PyUnicode_IS_ASCII(right))) {
          int ret;
          __Pyx_GIVEREF(*p_left);
          ret = PyUnicode_Resize(p_left, new_len);
          __Pyx_GOTREF(*p_left);
          if (unlikely(ret != 0))
              return NULL;
          #if PY_VERSION_HEX >= 0x030d0000
          if (unlikely(PyUnicode_CopyCharacters(*p_left, left_len, right, 0, right_len) < 0)) return NULL;
          #else
          _PyUnicode_FastCopyCharacters(*p_left, left_len, right, 0, right_len);
          #endif
          __Pyx_INCREF(*p_left);
          __Pyx_GIVEREF(*p_left);
          return *p_left;
      } else {
          return __Pyx_PyUnicode_Concat(left, right);
      }
    }
  #endif
  
/* pyobject_as_double */
  static double __Pyx__PyObject_AsDouble(PyObject* obj) {
      if (PyUnicode_CheckExact(obj)) {
          return __Pyx_PyUnicode_AsDouble(obj);
      } else if (PyBytes_CheckExact(obj)) {
          return __Pyx_PyBytes_AsDouble(obj);
      } else if (PyByteArray_CheckExact(obj)) {
          return __Pyx_PyByteArray_AsDouble(obj);
      } else {
          PyObject* float_value;
  #if !CYTHON_USE_TYPE_SLOTS
          float_value = PyNumber_Float(obj);  if ((0)) goto bad;
          (void)__Pyx_PyObject_CallOneArg;
  #else
          PyNumberMethods *nb = Py_TYPE(obj)->tp_as_number;
          if (likely(nb) && likely(nb->nb_float)) {
              float_value = nb->nb_float(obj);
              if (likely(float_value) && unlikely(!PyFloat_Check(float_value))) {
                  __Pyx_TypeName float_value_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(float_value));
                  PyErr_Format(PyExc_TypeError,
                      "__float__ returned non-float (type " __Pyx_FMT_TYPENAME ")",
                      float_value_type_name);
                  __Pyx_DECREF_TypeName(float_value_type_name);
                  Py_DECREF(float_value);
                  goto bad;
              }
          } else {
              float_value = __Pyx_PyObject_CallOneArg((PyObject*)&PyFloat_Type, obj);
          }
  #endif
          if (likely(float_value)) {
              double value = __Pyx_PyFloat_AS_DOUBLE(float_value);
              Py_DECREF(float_value);
              return value;
          }
      }
  bad:
      return (double)-1;
  }
  
/* AsyncIter */
  static PyObject *__Pyx_Coroutine_GetAsyncIter_Fail(PyObject *obj) {
      __Pyx_TypeName obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj));
      PyErr_Format(PyExc_TypeError,
                   "'async for' requires an object with __aiter__ method, got " __Pyx_FMT_TYPENAME, obj_type_name);
      __Pyx_DECREF_TypeName(obj_type_name);
      return NULL;
  }
  static CYTHON_INLINE PyObject *__Pyx_Coroutine_GetAsyncIter(PyObject *obj) {
  #ifdef __Pyx_AsyncGen_USED
      if (__Pyx_AsyncGen_CheckExact(obj)) {
          return __Pyx_NewRef(obj);
      }
  #endif
      {
          unaryfunc am_aiter = __Pyx_PyObject_TryGetSubSlot(obj, tp_as_async, am_aiter, unaryfunc);
          if (likely(am_aiter)) {
              return (*am_aiter)(obj);
          }
      }
      return __Pyx_Coroutine_GetAsyncIter_Fail(obj);
  }
  static PyObject *__Pyx_Coroutine_AsyncIterNext_Fail(PyObject *obj) {
      __Pyx_TypeName obj_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(obj));
      PyErr_Format(PyExc_TypeError,
          "'async for' requires an object with __anext__ method, got " __Pyx_FMT_TYPENAME, obj_type_name);
      __Pyx_DECREF_TypeName(obj_type_name);
      return NULL;
  }
  static CYTHON_INLINE PyObject *__Pyx_Coroutine_AsyncIterNext(PyObject *obj) {
  #ifdef __Pyx_AsyncGen_USED
      if (__Pyx_AsyncGen_CheckExact(obj)) {
          return __Pyx_async_gen_anext(obj);
      }
  #endif
      {
          unaryfunc am_anext = __Pyx_PyObject_TryGetSubSlot(obj, tp_as_async, am_anext, unaryfunc);
          if (likely(am_anext)) {
              return (*am_anext)(obj);
          }
      }
      return __Pyx_Coroutine_AsyncIterNext_Fail(obj);
  }
  
/* pyfrozenset_new (used by PySetContains) */
  static CYTHON_INLINE PyObject* __Pyx_PyFrozenSet_New(PyObject* it) {
      if (it) {
          PyObject* result;
  #if CYTHON_COMPILING_IN_PYPY
          PyObject* args;
          args = PyTuple_Pack(1, it);
          if (unlikely(!args))
              return NULL;
          result = PyObject_Call((PyObject*)&PyFrozenSet_Type, args, NULL);
          Py_DECREF(args);
          return result;
  #else
          if (PyFrozenSet_CheckExact(it)) {
              Py_INCREF(it);
              return it;
          }
          result = PyFrozenSet_New(it);
          if (unlikely(!result))
              return NULL;
          if ((__PYX_LIMITED_VERSION_HEX >= 0x030A0000)
  #if CYTHON_COMPILING_IN_LIMITED_API
              || __Pyx_get_runtime_version() >= 0x030A0000
  #endif
              )
              return result;
          {
              Py_ssize_t size = __Pyx_PySet_GET_SIZE(result);
              if (likely(size > 0))
                  return result;
  #if !CYTHON_ASSUME_SAFE_SIZE
              if (unlikely(size < 0)) {
                  Py_DECREF(result);
                  return NULL;
              }
  #endif
          }
          Py_DECREF(result);
  #endif
      }
      return __Pyx_PyObject_CallNoArg((PyObject*) &PyFrozenSet_Type);
  }
  
/* PySetContains */
  static int __Pyx_PySet_ContainsUnhashable(PyObject *set, PyObject *key) {
      int result = -1;
      if (PySet_Check(key) && PyErr_ExceptionMatches(PyExc_TypeError)) {
          PyObject *tmpkey;
          PyErr_Clear();
          tmpkey = __Pyx_PyFrozenSet_New(key);
          if (tmpkey != NULL) {
              result = PySet_Contains(set, tmpkey);
              Py_DECREF(tmpkey);
          }
      }
      return result;
  }
  static CYTHON_INLINE int __Pyx_PySet_ContainsTF(PyObject* key, PyObject* set, int eq) {
      int result = PySet_Contains(set, key);
      if (unlikely(result < 0)) {
          result = __Pyx_PySet_ContainsUnhashable(set, key);
      }
      return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
  }
  
/* append */
  static CYTHON_INLINE int __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
      if (likely(PyList_CheckExact(L))) {
          if (unlikely(__Pyx_PyList_Append(L, x) < 0)) return -1;
      } else {
          PyObject* retval = __Pyx_PyObject_CallMethod1(L, __pyx_mstate_global->__pyx_n_u_append, x);
          if (unlikely(!retval))
              return -1;
          Py_DECREF(retval);
      }
      return 0;
  }
  
/* PyFloatBinop */
  #if !CYTHON_COMPILING_IN_PYPY
  static PyObject* __Pyx_PyFloat_TrueDivideObjC(PyObject *op1, PyObject *op2, double floatval, int inplace, int zerodivision_check) {
      const double b = floatval;
      double a, result;
      CYTHON_UNUSED_VAR(inplace);
      CYTHON_UNUSED_VAR(zerodivision_check);
      if (likely(PyFloat_CheckExact(op1))) {
          a = __Pyx_PyFloat_AS_DOUBLE(op1);
          
      } else
      if (likely(PyLong_CheckExact(op1))) {
          #if CYTHON_USE_PYLONG_INTERNALS
          if (__Pyx_PyLong_IsZero(op1)) {
              a = 0.0;
              
          } else if (__Pyx_PyLong_IsCompact(op1)) {
              a = (double) __Pyx_PyLong_CompactValue(op1);
          } else {
              const digit* digits = __Pyx_PyLong_Digits(op1);
              const Py_ssize_t size = __Pyx_PyLong_SignedDigitCount(op1);
              switch (size) {
                  case -2:
                  case 2:
                      if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (1 * PyLong_SHIFT < 53))) {
                          a = (double) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                          if ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53) || (a < (double) ((PY_LONG_LONG)1 << 53))) {
                              if (size == -2)
                                  a = -a;
                              break;
                          }
                      }
                      CYTHON_FALLTHROUGH;
                  case -3:
                  case 3:
                      if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (2 * PyLong_SHIFT < 53))) {
                          a = (double) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                          if ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53) || (a < (double) ((PY_LONG_LONG)1 << 53))) {
                              if (size == -3)
                                  a = -a;
                              break;
                          }
                      }
                      CYTHON_FALLTHROUGH;
                  case -4:
                  case 4:
                      if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT && ((8 * sizeof(unsigned long) < 53) || (3 * PyLong_SHIFT < 53))) {
                          a = (double) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                          if ((8 * sizeof(unsigned long) < 53) || (4 * PyLong_SHIFT < 53) || (a < (double) ((PY_LONG_LONG)1 << 53))) {
                              if (size == -4)
                                  a = -a;
                              break;
                          }
                      }
                      CYTHON_FALLTHROUGH;
                  default:
          #endif
                      a = PyLong_AsDouble(op1);
                      if (unlikely(a == -1.0 && PyErr_Occurred())) return NULL;
          #if CYTHON_USE_PYLONG_INTERNALS
              }
          }
          #endif
      } else {
          return (inplace ? PyNumber_InPlaceTrueDivide : PyNumber_TrueDivide)(op1, op2);
      }
          result = a / b;
          return PyFloat_FromDouble(result);
  }
  #endif
  
/* PyObjectFormat */
  #if CYTHON_USE_UNICODE_WRITER
  static PyObject* __Pyx_PyObject_Format(PyObject* obj, PyObject* format_spec) {
      int ret;
      _PyUnicodeWriter writer;
      if (likely(PyFloat_CheckExact(obj))) {
          _PyUnicodeWriter_Init(&writer);
          ret = _PyFloat_FormatAdvancedWriter(
              &writer,
              obj,
              format_spec, 0, PyUnicode_GET_LENGTH(format_spec));
      } else if (likely(PyLong_CheckExact(obj))) {
          _PyUnicodeWriter_Init(&writer);
          ret = _PyLong_FormatAdvancedWriter(
              &writer,
              obj,
              format_spec, 0, PyUnicode_GET_LENGTH(format_spec));
      } else {
          return PyObject_Format(obj, format_spec);
      }
      if (unlikely(ret == -1)) {
          _PyUnicodeWriter_Dealloc(&writer);
          return NULL;
      }
      return _PyUnicodeWriter_Finish(&writer);
  }
  #endif
  
/* PyLongBinop */
  #if !CYTHON_COMPILING_IN_PYPY
  static PyObject* __Pyx_Fallback___Pyx_PyLong_SubtractObjC(PyObject *op1, PyObject *op2, int inplace) {
      return (inplace ? PyNumber_InPlaceSubtract : PyNumber_Subtract)(op1, op2);
  }
  #if CYTHON_USE_PYLONG_INTERNALS
  static PyObject* __Pyx_Unpacked___Pyx_PyLong_SubtractObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) {
      CYTHON_MAYBE_UNUSED_VAR(inplace);
      CYTHON_UNUSED_VAR(zerodivision_check);
      const long b = intval;
      long a;
      const PY_LONG_LONG llb = intval;
      PY_LONG_LONG lla;
      if (unlikely(__Pyx_PyLong_IsZero(op1))) {
          return PyLong_FromLong(-intval);
      }
      const int is_positive = __Pyx_PyLong_IsPos(op1);
      const digit* digits = __Pyx_PyLong_Digits(op1);
      const Py_ssize_t size = __Pyx_PyLong_DigitCount(op1);
      if (likely(size == 1)) {
          a = (long) digits[0];
          if (!is_positive) a *= -1;
      } else {
          switch (size) {
              case 2:
                  if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
                      a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                      if (!is_positive) a *= -1;
                      goto calculate_long;
                  } else if (8 * sizeof(PY_LONG_LONG) - 1 > 2 * PyLong_SHIFT) {
                      lla = (PY_LONG_LONG) (((((unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                      if (!is_positive) lla *= -1;
                      goto calculate_long_long;
                  }
                  break;
              case 3:
                  if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
                      a = (long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                      if (!is_positive) a *= -1;
                      goto calculate_long;
                  } else if (8 * sizeof(PY_LONG_LONG) - 1 > 3 * PyLong_SHIFT) {
                      lla = (PY_LONG_LONG) (((((((unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                      if (!is_positive) lla *= -1;
                      goto calculate_long_long;
                  }
                  break;
              case 4:
                  if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
                      a = (long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0]));
                      if (!is_positive) a *= -1;
                      goto calculate_long;
                  } else if (8 * sizeof(PY_LONG_LONG) - 1 > 4 * PyLong_SHIFT) {
                      lla = (PY_LONG_LONG) (((((((((unsigned PY_LONG_LONG)digits[3]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[2]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[1]) << PyLong_SHIFT) | (unsigned PY_LONG_LONG)digits[0]));
                      if (!is_positive) lla *= -1;
                      goto calculate_long_long;
                  }
                  break;
          }
          return PyLong_Type.tp_as_number->nb_subtract(op1, op2);
      }
      calculate_long:
          {
              long x;
              x = a - b;
              return PyLong_FromLong(x);
          }
      calculate_long_long:
          {
              PY_LONG_LONG llx;
              llx = lla - llb;
              return PyLong_FromLongLong(llx);
          }
      
  }
  #endif
  static PyObject* __Pyx_Float___Pyx_PyLong_SubtractObjC(PyObject *float_val, long intval, int zerodivision_check) {
      CYTHON_UNUSED_VAR(zerodivision_check);
      const long b = intval;
      double a = __Pyx_PyFloat_AS_DOUBLE(float_val);
          double result;
          
          result = ((double)a) - (double)b;
          return PyFloat_FromDouble(result);
  }
  static CYTHON_INLINE PyObject* __Pyx_PyLong_SubtractObjC(PyObject *op1, PyObject *op2, long intval, int inplace, int zerodivision_check) {
      CYTHON_MAYBE_UNUSED_VAR(intval);
      CYTHON_UNUSED_VAR(zerodivision_check);
      #if CYTHON_USE_PYLONG_INTERNALS
      if (likely(PyLong_CheckExact(op1))) {
          return __Pyx_Unpacked___Pyx_PyLong_SubtractObjC(op1, op2, intval, inplace, zerodivision_check);
      }
      #endif
      if (PyFloat_CheckExact(op1)) {
          return __Pyx_Float___Pyx_PyLong_SubtractObjC(op1, intval, zerodivision_check);
      }
      return __Pyx_Fallback___Pyx_PyLong_SubtractObjC(op1, op2, inplace);
  }
  #endif
  
/* py_abs */
  #if CYTHON_USE_PYLONG_INTERNALS
  static PyObject *__Pyx_PyLong_AbsNeg(PyObject *n) {
  #if PY_VERSION_HEX >= 0x030C00A7
      if (likely(__Pyx_PyLong_IsCompact(n))) {
          return PyLong_FromSize_t(__Pyx_PyLong_CompactValueUnsigned(n));
      }
  #else
      if (likely(Py_SIZE(n) == -1)) {
          return PyLong_FromUnsignedLong(__Pyx_PyLong_Digits(n)[0]);
      }
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON
      {
          PyObject *copy = _PyLong_Copy((PyLongObject*)n);
          if (likely(copy)) {
              #if PY_VERSION_HEX >= 0x030C00A7
              ((PyLongObject*)copy)->long_value.lv_tag ^= ((PyLongObject*)copy)->long_value.lv_tag & _PyLong_SIGN_MASK;
              #else
              __Pyx_SET_SIZE(copy, -Py_SIZE(copy));
              #endif
          }
          return copy;
      }
  #else
      return PyNumber_Negative(n);
  #endif
  }
  #endif
  
/* PyObjectCallMethod0 (used by dict_iter) */
  static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
  #if CYTHON_VECTORCALL && (__PYX_LIMITED_VERSION_HEX >= 0x030C0000 || (!CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x03090000))
      PyObject *args[1] = {obj};
      (void) __Pyx_PyObject_CallOneArg;
      (void) __Pyx_PyObject_CallNoArg;
      return PyObject_VectorcallMethod(method_name, args, 1 | PY_VECTORCALL_ARGUMENTS_OFFSET, NULL);
  #else
      PyObject *method = NULL, *result = NULL;
      int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
      if (likely(is_method)) {
          result = __Pyx_PyObject_CallOneArg(method, obj);
          Py_DECREF(method);
          return result;
      }
      if (unlikely(!method)) goto bad;
      result = __Pyx_PyObject_CallNoArg(method);
      Py_DECREF(method);
  bad:
      return result;
  #endif
  }
  
/* RaiseNoneIterError (used by UnpackTupleError) */
  static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
  }
  
/* UnpackTupleError (used by UnpackTuple2) */
  static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) {
      if (t == Py_None) {
        __Pyx_RaiseNoneNotIterableError();
      } else {
        Py_ssize_t size = __Pyx_PyTuple_GET_SIZE(t);
   #if !CYTHON_ASSUME_SAFE_SIZE
        if (unlikely(size < 0)) return;
   #endif
        if (size < index) {
          __Pyx_RaiseNeedMoreValuesError(size);
        } else {
          __Pyx_RaiseTooManyValuesError(index);
        }
      }
  }
  
/* UnpackTuple2 (used by dict_iter) */
  static CYTHON_INLINE int __Pyx_unpack_tuple2(
          PyObject* tuple, PyObject** value1, PyObject** value2, int is_tuple, int has_known_size, int decref_tuple) {
      if (likely(is_tuple || PyTuple_Check(tuple))) {
          Py_ssize_t size;
          if (has_known_size) {
              return __Pyx_unpack_tuple2_exact(tuple, value1, value2, decref_tuple);
          }
          size = __Pyx_PyTuple_GET_SIZE(tuple);
          if (likely(size == 2)) {
              return __Pyx_unpack_tuple2_exact(tuple, value1, value2, decref_tuple);
          }
          if (size >= 0) {
              __Pyx_UnpackTupleError(tuple, 2);
          }
          return -1;
      } else {
          return __Pyx_unpack_tuple2_generic(tuple, value1, value2, has_known_size, decref_tuple);
      }
  }
  static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
          PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, int decref_tuple) {
      PyObject *value1 = NULL, *value2 = NULL;
  #if CYTHON_AVOID_BORROWED_REFS || !CYTHON_ASSUME_SAFE_MACROS
      value1 = __Pyx_PySequence_ITEM(tuple, 0);  if (unlikely(!value1)) goto bad;
      value2 = __Pyx_PySequence_ITEM(tuple, 1);  if (unlikely(!value2)) goto bad;
  #else
      value1 = PyTuple_GET_ITEM(tuple, 0);  Py_INCREF(value1);
      value2 = PyTuple_GET_ITEM(tuple, 1);  Py_INCREF(value2);
  #endif
      if (decref_tuple) {
          Py_DECREF(tuple);
      }
      *pvalue1 = value1;
      *pvalue2 = value2;
      return 0;
  #if CYTHON_AVOID_BORROWED_REFS || !CYTHON_ASSUME_SAFE_MACROS
  bad:
      Py_XDECREF(value1);
      Py_XDECREF(value2);
      if (decref_tuple) { Py_XDECREF(tuple); }
      return -1;
  #endif
  }
  static int __Pyx_unpack_tuple2_generic(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2,
                                         int has_known_size, int decref_tuple) {
      Py_ssize_t index;
      PyObject *value1 = NULL, *value2 = NULL, *iter = NULL;
      iternextfunc iternext;
      iter = PyObject_GetIter(tuple);
      if (unlikely(!iter)) goto bad;
      if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; }
      iternext = __Pyx_PyObject_GetIterNextFunc(iter);
      value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; }
      value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; }
      if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad;
      Py_DECREF(iter);
      *pvalue1 = value1;
      *pvalue2 = value2;
      return 0;
  unpacking_failed:
      if (!has_known_size && __Pyx_IterFinish() == 0)
          __Pyx_RaiseNeedMoreValuesError(index);
  bad:
      Py_XDECREF(iter);
      Py_XDECREF(value1);
      Py_XDECREF(value2);
      if (decref_tuple) { Py_XDECREF(tuple); }
      return -1;
  }
  
/* dict_iter */
  #if CYTHON_AVOID_BORROWED_REFS
  #include <string.h>
  #endif
  static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_dict, PyObject* method_name,
                                                     Py_ssize_t* p_orig_length, int* p_source_is_dict) {
      is_dict = is_dict || likely(PyDict_CheckExact(iterable));
      *p_source_is_dict = is_dict;
      if (is_dict) {
  #if !CYTHON_AVOID_BORROWED_REFS
          *p_orig_length = PyDict_Size(iterable);
          Py_INCREF(iterable);
          return iterable;
  #else
          static PyObject *py_items = NULL, *py_keys = NULL, *py_values = NULL;
          PyObject **pp = NULL;
          if (method_name) {
              const char *name = PyUnicode_AsUTF8(method_name);
              if (strcmp(name, "iteritems") == 0) pp = &py_items;
              else if (strcmp(name, "iterkeys") == 0) pp = &py_keys;
              else if (strcmp(name, "itervalues") == 0) pp = &py_values;
              if (pp) {
                  if (!*pp) {
                      *pp = PyUnicode_FromString(name + 4);
                      if (!*pp)
                          return NULL;
                  }
                  method_name = *pp;
              }
          }
  #endif
      }
      *p_orig_length = 0;
      if (method_name) {
          PyObject* iter;
          iterable = __Pyx_PyObject_CallMethod0(iterable, method_name);
          if (!iterable)
              return NULL;
  #if !CYTHON_AVOID_BORROWED_REFS
          if (PyTuple_CheckExact(iterable) || PyList_CheckExact(iterable))
              return iterable;
  #endif
          iter = PyObject_GetIter(iterable);
          Py_DECREF(iterable);
          return iter;
      }
      return PyObject_GetIter(iterable);
  }
  #if !CYTHON_AVOID_BORROWED_REFS
  static CYTHON_INLINE int __Pyx_dict_iter_next_source_is_dict(
          PyObject* iter_obj, CYTHON_NCP_UNUSED Py_ssize_t orig_length, CYTHON_NCP_UNUSED Py_ssize_t* ppos,
          PyObject** pkey, PyObject** pvalue, PyObject** pitem) {
      PyObject *key, *value;
      if (unlikely(orig_length != PyDict_Size(iter_obj))) {
          PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration");
          return -1;
      }
      if (unlikely(!PyDict_Next(iter_obj, ppos, &key, &value))) {
          return 0;
      }
      if (pitem) {
          PyObject* tuple = PyTuple_New(2);
          if (unlikely(!tuple)) {
              return -1;
          }
          Py_INCREF(key);
          Py_INCREF(value);
          #if CYTHON_ASSUME_SAFE_MACROS
          PyTuple_SET_ITEM(tuple, 0, key);
          PyTuple_SET_ITEM(tuple, 1, value);
          #else
          if (unlikely(PyTuple_SetItem(tuple, 0, key) < 0)) {
              Py_DECREF(value);
              Py_DECREF(tuple);
              return -1;
          }
          if (unlikely(PyTuple_SetItem(tuple, 1, value) < 0)) {
              Py_DECREF(tuple);
              return -1;
          }
          #endif
          *pitem = tuple;
      } else {
          if (pkey) {
              Py_INCREF(key);
              *pkey = key;
          }
          if (pvalue) {
              Py_INCREF(value);
              *pvalue = value;
          }
      }
      return 1;
  }
  #endif
  static CYTHON_INLINE int __Pyx_dict_iter_next(
          PyObject* iter_obj, CYTHON_NCP_UNUSED Py_ssize_t orig_length, CYTHON_NCP_UNUSED Py_ssize_t* ppos,
          PyObject** pkey, PyObject** pvalue, PyObject** pitem, int source_is_dict) {
      PyObject* next_item;
  #if !CYTHON_AVOID_BORROWED_REFS
      if (source_is_dict) {
          int result;
  #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
          Py_BEGIN_CRITICAL_SECTION(iter_obj);
  #endif
          result = __Pyx_dict_iter_next_source_is_dict(iter_obj, orig_length, ppos, pkey, pvalue, pitem);
  #if PY_VERSION_HEX >= 0x030d0000 && !CYTHON_COMPILING_IN_LIMITED_API
          Py_END_CRITICAL_SECTION();
  #endif
          return result;
      } else if (PyTuple_CheckExact(iter_obj)) {
          Py_ssize_t pos = *ppos;
          Py_ssize_t tuple_size = __Pyx_PyTuple_GET_SIZE(iter_obj);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely(tuple_size < 0)) return -1;
          #endif
          if (unlikely(pos >= tuple_size)) return 0;
          *ppos = pos + 1;
          #if CYTHON_ASSUME_SAFE_MACROS
          next_item = PyTuple_GET_ITEM(iter_obj, pos);
          #else
          next_item = PyTuple_GetItem(iter_obj, pos);
          if (unlikely(!next_item)) return -1;
          #endif
          Py_INCREF(next_item);
      } else if (PyList_CheckExact(iter_obj)) {
          Py_ssize_t pos = *ppos;
          Py_ssize_t list_size = __Pyx_PyList_GET_SIZE(iter_obj);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely(list_size < 0)) return -1;
          #endif
          if (unlikely(pos >= list_size)) return 0;
          *ppos = pos + 1;
          next_item = __Pyx_PyList_GET_ITEM_REF(iter_obj, pos, __Pyx_ReferenceSharing_OwnStrongReference);
          if (unlikely(!next_item)) return -1;
      } else
  #endif
      {
          next_item = PyIter_Next(iter_obj);
          if (unlikely(!next_item)) {
              return __Pyx_IterFinish();
          }
      }
      if (pitem) {
          *pitem = next_item;
      } else if (pkey && pvalue) {
          if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1))
              return -1;
      } else if (pkey) {
          *pkey = next_item;
      } else {
          *pvalue = next_item;
      }
      return 1;
  }
  
/* PyLongCompare */
  static CYTHON_INLINE PyObject* __Pyx_PyLong_NeObjC(PyObject *op1, PyObject *op2, long intval, long inplace) {
      CYTHON_MAYBE_UNUSED_VAR(intval);
      CYTHON_UNUSED_VAR(inplace);
      if (op1 == op2) {
          Py_RETURN_FALSE;
      }
      #if CYTHON_USE_PYLONG_INTERNALS
      if (likely(PyLong_CheckExact(op1))) {
          int unequal;
          unsigned long uintval;
          Py_ssize_t size = __Pyx_PyLong_DigitCount(op1);
          const digit* digits = __Pyx_PyLong_Digits(op1);
          if (intval == 0) {
              if (__Pyx_PyLong_IsZero(op1) != 1) Py_RETURN_TRUE; else Py_RETURN_FALSE;
          } else if (intval < 0) {
              if (__Pyx_PyLong_IsNonNeg(op1))
                  Py_RETURN_TRUE;
              intval = -intval;
          } else {
              if (__Pyx_PyLong_IsNeg(op1))
                  Py_RETURN_TRUE;
          }
          uintval = (unsigned long) intval;
  #if PyLong_SHIFT * 4 < SIZEOF_LONG*8
          if (uintval >> (PyLong_SHIFT * 4)) {
              unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                   | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
          } else
  #endif
  #if PyLong_SHIFT * 3 < SIZEOF_LONG*8
          if (uintval >> (PyLong_SHIFT * 3)) {
              unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                   | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
          } else
  #endif
  #if PyLong_SHIFT * 2 < SIZEOF_LONG*8
          if (uintval >> (PyLong_SHIFT * 2)) {
              unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                   | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
          } else
  #endif
  #if PyLong_SHIFT * 1 < SIZEOF_LONG*8
          if (uintval >> (PyLong_SHIFT * 1)) {
              unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
                   | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
          } else
  #endif
              unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
          if (unequal != 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
      }
      #endif
      if (PyFloat_CheckExact(op1)) {
          const long b = intval;
          double a = __Pyx_PyFloat_AS_DOUBLE(op1);
          if ((double)a != (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
      }
      return (
          PyObject_RichCompare(op1, op2, Py_NE));
  }
  
/* SliceTupleAndList */
  #if CYTHON_COMPILING_IN_CPYTHON
  static CYTHON_INLINE void __Pyx_crop_slice(Py_ssize_t* _start, Py_ssize_t* _stop, Py_ssize_t* _length) {
      Py_ssize_t start = *_start, stop = *_stop, length = *_length;
      if (start < 0) {
          start += length;
          if (start < 0)
              start = 0;
      }
      if (stop < 0)
          stop += length;
      else if (stop > length)
          stop = length;
      *_length = stop - start;
      *_start = start;
      *_stop = stop;
  }
  static CYTHON_INLINE PyObject* __Pyx_PyTuple_GetSlice(
              PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
      Py_ssize_t length = PyTuple_GET_SIZE(src);
      __Pyx_crop_slice(&start, &stop, &length);
      return __Pyx_PyTuple_FromArray(((PyTupleObject*)src)->ob_item + start, length);
  }
  static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice_locked(
              PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
      Py_ssize_t length = PyList_GET_SIZE(src);
      __Pyx_crop_slice(&start, &stop, &length);
      if (length <= 0) {
          return PyList_New(0);
      }
      return __Pyx_PyList_FromArray(((PyListObject*)src)->ob_item + start, length);
  }
  static CYTHON_INLINE PyObject* __Pyx_PyList_GetSlice(
              PyObject* src, Py_ssize_t start, Py_ssize_t stop) {
      PyObject *result;
      __Pyx_BEGIN_CRITICAL_SECTION(src);
      result = __Pyx_PyList_GetSlice_locked(src, start, stop);
      __Pyx_END_CRITICAL_SECTION();
      return result;
  }
  #endif // CYTHON_COMPILING_IN_CPYTHON
  
/* py_dict_keys */
  static CYTHON_INLINE PyObject* __Pyx_PyDict_Keys(PyObject* d) {
      return __Pyx_CallUnboundCMethod0(&__pyx_mstate_global->__pyx_umethod_PyDict_Type_keys, d);
  }
  
/* AllocateExtensionType */
  static PyObject *__Pyx_AllocateExtensionType(PyTypeObject *t, int is_final) {
      if (is_final || likely(!__Pyx_PyType_HasFeature(t, Py_TPFLAGS_IS_ABSTRACT))) {
          allocfunc alloc_func = __Pyx_PyType_GetSlot(t, tp_alloc, allocfunc);
          return alloc_func(t, 0);
      } else {
          newfunc tp_new = __Pyx_PyType_TryGetSlot(&PyBaseObject_Type, tp_new, newfunc);
      #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
          if (!tp_new) {
              PyObject *new_str = PyUnicode_FromString("__new__");
              if (likely(new_str)) {
                  PyObject *o = PyObject_CallMethodObjArgs((PyObject *)&PyBaseObject_Type, new_str, t, NULL);
                  Py_DECREF(new_str);
                  return o;
              } else
                  return NULL;
          } else
      #endif
          return tp_new(t, __pyx_mstate_global->__pyx_empty_tuple, 0);
      }
  }
  
/* ValidateBasesTuple (used by PyType_Ready) */
  #if CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_LIMITED_API || CYTHON_USE_TYPE_SPECS
  static int __Pyx_validate_bases_tuple(const char *type_name, Py_ssize_t dictoffset, PyObject *bases) {
      Py_ssize_t i, n;
  #if CYTHON_ASSUME_SAFE_SIZE
      n = PyTuple_GET_SIZE(bases);
  #else
      n = PyTuple_Size(bases);
      if (unlikely(n < 0)) return -1;
  #endif
      for (i = 1; i < n; i++)
      {
          PyTypeObject *b;
  #if CYTHON_AVOID_BORROWED_REFS
          PyObject *b0 = PySequence_GetItem(bases, i);
          if (!b0) return -1;
  #elif CYTHON_ASSUME_SAFE_MACROS
          PyObject *b0 = PyTuple_GET_ITEM(bases, i);
  #else
          PyObject *b0 = PyTuple_GetItem(bases, i);
          if (!b0) return -1;
  #endif
          b = (PyTypeObject*) b0;
          if (!__Pyx_PyType_HasFeature(b, Py_TPFLAGS_HEAPTYPE))
          {
              __Pyx_TypeName b_name = __Pyx_PyType_GetFullyQualifiedName(b);
              PyErr_Format(PyExc_TypeError,
                  "base class '" __Pyx_FMT_TYPENAME "' is not a heap type", b_name);
              __Pyx_DECREF_TypeName(b_name);
  #if CYTHON_AVOID_BORROWED_REFS
              Py_DECREF(b0);
  #endif
              return -1;
          }
          if (dictoffset == 0)
          {
              Py_ssize_t b_dictoffset = 0;
  #if CYTHON_USE_TYPE_SLOTS
              b_dictoffset = b->tp_dictoffset;
  #else
              PyObject *py_b_dictoffset = PyObject_GetAttrString((PyObject*)b, "__dictoffset__");
              if (!py_b_dictoffset) goto dictoffset_return;
              b_dictoffset = PyLong_AsSsize_t(py_b_dictoffset);
              Py_DECREF(py_b_dictoffset);
              if (b_dictoffset == -1 && PyErr_Occurred()) goto dictoffset_return;
  #endif
              if (b_dictoffset) {
                  {
                      __Pyx_TypeName b_name = __Pyx_PyType_GetFullyQualifiedName(b);
                      PyErr_Format(PyExc_TypeError,
                          "extension type '%.200s' has no __dict__ slot, "
                          "but base type '" __Pyx_FMT_TYPENAME "' has: "
                          "either add 'cdef dict __dict__' to the extension type "
                          "or add '__slots__ = [...]' to the base type",
                          type_name, b_name);
                      __Pyx_DECREF_TypeName(b_name);
                  }
  #if !CYTHON_USE_TYPE_SLOTS
                dictoffset_return:
  #endif
  #if CYTHON_AVOID_BORROWED_REFS
                  Py_DECREF(b0);
  #endif
                  return -1;
              }
          }
  #if CYTHON_AVOID_BORROWED_REFS
          Py_DECREF(b0);
  #endif
      }
      return 0;
  }
  #endif
  
/* PyType_Ready */
  CYTHON_UNUSED static int __Pyx_PyType_HasMultipleInheritance(PyTypeObject *t) {
      while (t) {
          PyObject *bases = __Pyx_PyType_GetSlot(t, tp_bases, PyObject*);
          if (bases) {
              return 1;
          }
          t = __Pyx_PyType_GetSlot(t, tp_base, PyTypeObject*);
      }
      return 0;
  }
  static int __Pyx_PyType_Ready(PyTypeObject *t) {
  #if CYTHON_USE_TYPE_SPECS || !CYTHON_COMPILING_IN_CPYTHON || defined(PYSTON_MAJOR_VERSION)
      (void)__Pyx_PyObject_CallMethod0;
  #if CYTHON_USE_TYPE_SPECS
      (void)__Pyx_validate_bases_tuple;
  #endif
      return PyType_Ready(t);
  #else
      int r;
      if (!__Pyx_PyType_HasMultipleInheritance(t)) {
          return PyType_Ready(t);
      }
      PyObject *bases = __Pyx_PyType_GetSlot(t, tp_bases, PyObject*);
      if (bases && unlikely(__Pyx_validate_bases_tuple(t->tp_name, t->tp_dictoffset, bases) == -1))
          return -1;
  #if !defined(PYSTON_MAJOR_VERSION)
      {
          int gc_was_enabled;
      #if PY_VERSION_HEX >= 0x030A00b1
          gc_was_enabled = PyGC_Disable();
          (void)__Pyx_PyObject_CallMethod0;
      #else
          PyObject *ret, *py_status;
          PyObject *gc = NULL;
          #if (!CYTHON_COMPILING_IN_PYPY || PYPY_VERSION_NUM+0 >= 0x07030400) &&\
                  !CYTHON_COMPILING_IN_GRAAL
          gc = PyImport_GetModule(__pyx_mstate_global->__pyx_kp_u_gc);
          #endif
          if (unlikely(!gc)) gc = PyImport_Import(__pyx_mstate_global->__pyx_kp_u_gc);
          if (unlikely(!gc)) return -1;
          py_status = __Pyx_PyObject_CallMethod0(gc, __pyx_mstate_global->__pyx_kp_u_isenabled);
          if (unlikely(!py_status)) {
              Py_DECREF(gc);
              return -1;
          }
          gc_was_enabled = __Pyx_PyObject_IsTrue(py_status);
          Py_DECREF(py_status);
          if (gc_was_enabled > 0) {
              ret = __Pyx_PyObject_CallMethod0(gc, __pyx_mstate_global->__pyx_kp_u_disable);
              if (unlikely(!ret)) {
                  Py_DECREF(gc);
                  return -1;
              }
              Py_DECREF(ret);
          } else if (unlikely(gc_was_enabled == -1)) {
              Py_DECREF(gc);
              return -1;
          }
      #endif
          t->tp_flags |= Py_TPFLAGS_HEAPTYPE;
  #if PY_VERSION_HEX >= 0x030A0000
          t->tp_flags |= Py_TPFLAGS_IMMUTABLETYPE;
  #endif
  #else
          (void)__Pyx_PyObject_CallMethod0;
  #endif
      r = PyType_Ready(t);
  #if !defined(PYSTON_MAJOR_VERSION)
          t->tp_flags &= ~Py_TPFLAGS_HEAPTYPE;
      #if PY_VERSION_HEX >= 0x030A00b1
          if (gc_was_enabled)
              PyGC_Enable();
      #else
          if (gc_was_enabled) {
              PyObject *tp, *v, *tb;
              PyErr_Fetch(&tp, &v, &tb);
              ret = __Pyx_PyObject_CallMethod0(gc, __pyx_mstate_global->__pyx_kp_u_enable);
              if (likely(ret || r == -1)) {
                  Py_XDECREF(ret);
                  PyErr_Restore(tp, v, tb);
              } else {
                  Py_XDECREF(tp);
                  Py_XDECREF(v);
                  Py_XDECREF(tb);
                  r = -1;
              }
          }
          Py_DECREF(gc);
      #endif
      }
  #endif
      return r;
  #endif
  }
  
/* Py3UpdateBases */
  static PyObject*
  __Pyx_PEP560_update_bases(PyObject *bases)
  {
      Py_ssize_t i, j, size_bases;
      PyObject *base = NULL, *meth, *new_base, *result, *new_bases = NULL;
  #if CYTHON_ASSUME_SAFE_SIZE
      size_bases = PyTuple_GET_SIZE(bases);
  #else
      size_bases = PyTuple_Size(bases);
      if (size_bases < 0) return NULL;
  #endif
      for (i = 0; i < size_bases; i++) {
  #if CYTHON_AVOID_BORROWED_REFS
          Py_CLEAR(base);
  #endif
  #if CYTHON_ASSUME_SAFE_MACROS
          base = PyTuple_GET_ITEM(bases, i);
  #else
          base = PyTuple_GetItem(bases, i);
          if (!base) goto error;
  #endif
  #if CYTHON_AVOID_BORROWED_REFS
          Py_INCREF(base);
  #endif
          if (PyType_Check(base)) {
              if (new_bases) {
                  if (PyList_Append(new_bases, base) < 0) {
                      goto error;
                  }
              }
              continue;
          }
          meth = __Pyx_PyObject_GetAttrStrNoError(base, __pyx_mstate_global->__pyx_n_u_mro_entries);
          if (!meth && PyErr_Occurred()) {
              goto error;
          }
          if (!meth) {
              if (new_bases) {
                  if (PyList_Append(new_bases, base) < 0) {
                      goto error;
                  }
              }
              continue;
          }
          new_base = __Pyx_PyObject_CallOneArg(meth, bases);
          Py_DECREF(meth);
          if (!new_base) {
              goto error;
          }
          if (!PyTuple_Check(new_base)) {
              PyErr_SetString(PyExc_TypeError,
                              "__mro_entries__ must return a tuple");
              Py_DECREF(new_base);
              goto error;
          }
          if (!new_bases) {
              if (!(new_bases = PyList_New(i))) {
                  goto error;
              }
              for (j = 0; j < i; j++) {
                  PyObject *base_from_list;
  #if CYTHON_ASSUME_SAFE_MACROS
                  base_from_list = PyTuple_GET_ITEM(bases, j);
                  PyList_SET_ITEM(new_bases, j, base_from_list);
                  Py_INCREF(base_from_list);
  #else
                  base_from_list = PyTuple_GetItem(bases, j);
                  if (!base_from_list) goto error;
                  Py_INCREF(base_from_list);
                  if (PyList_SetItem(new_bases, j, base_from_list) < 0) goto error;
  #endif
              }
          }
  #if CYTHON_ASSUME_SAFE_SIZE
          j = PyList_GET_SIZE(new_bases);
  #else
          j = PyList_Size(new_bases);
          if (j < 0) goto error;
  #endif
          if (PyList_SetSlice(new_bases, j, j, new_base) < 0) {
              goto error;
          }
          Py_DECREF(new_base);
      }
      if (!new_bases) {
          Py_INCREF(bases);
          return bases;
      }
      result = PyList_AsTuple(new_bases);
      Py_DECREF(new_bases);
  #if CYTHON_AVOID_BORROWED_REFS
      Py_XDECREF(base);
  #endif
      return result;
  error:
      Py_XDECREF(new_bases);
  #if CYTHON_AVOID_BORROWED_REFS
      Py_XDECREF(base);
  #endif
      return NULL;
  }
  
/* CalculateMetaclass */
  static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
      Py_ssize_t i, nbases;
  #if CYTHON_ASSUME_SAFE_SIZE
      nbases = PyTuple_GET_SIZE(bases);
  #else
      nbases = PyTuple_Size(bases);
      if (nbases < 0) return NULL;
  #endif
      for (i=0; i < nbases; i++) {
          PyTypeObject *tmptype;
  #if CYTHON_ASSUME_SAFE_MACROS
          PyObject *tmp = PyTuple_GET_ITEM(bases, i);
  #else
          PyObject *tmp = PyTuple_GetItem(bases, i);
          if (!tmp) return NULL;
  #endif
          tmptype = Py_TYPE(tmp);
          if (!metaclass) {
              metaclass = tmptype;
              continue;
          }
          if (PyType_IsSubtype(metaclass, tmptype))
              continue;
          if (PyType_IsSubtype(tmptype, metaclass)) {
              metaclass = tmptype;
              continue;
          }
          PyErr_SetString(PyExc_TypeError,
                          "metaclass conflict: "
                          "the metaclass of a derived class "
                          "must be a (non-strict) subclass "
                          "of the metaclasses of all its bases");
          return NULL;
      }
      if (!metaclass) {
          metaclass = &PyType_Type;
      }
      Py_INCREF((PyObject*) metaclass);
      return (PyObject*) metaclass;
  }
  
/* Py3ClassCreate */
  static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
                                             PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
      PyObject *ns;
      if (metaclass) {
          PyObject *prep = __Pyx_PyObject_GetAttrStrNoError(metaclass, __pyx_mstate_global->__pyx_n_u_prepare);
          if (prep) {
              PyObject *pargs[3] = {NULL, name, bases};
              ns = __Pyx_PyObject_FastCallDict(prep, pargs+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, mkw);
              Py_DECREF(prep);
          } else {
              if (unlikely(PyErr_Occurred()))
                  return NULL;
              ns = PyDict_New();
          }
      } else {
          ns = PyDict_New();
      }
      if (unlikely(!ns))
          return NULL;
      if (unlikely(PyObject_SetItem(ns, __pyx_mstate_global->__pyx_n_u_module_2, modname) < 0)) goto bad;
      if (unlikely(PyObject_SetItem(ns, __pyx_mstate_global->__pyx_n_u_qualname, qualname) < 0)) goto bad;
      if (unlikely(doc && PyObject_SetItem(ns, __pyx_mstate_global->__pyx_n_u_doc, doc) < 0)) goto bad;
      return ns;
  bad:
      Py_DECREF(ns);
      return NULL;
  }
  static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
                                        PyObject *dict, PyObject *mkw,
                                        int calculate_metaclass, int allow_py2_metaclass) {
      PyObject *result;
      PyObject *owned_metaclass = NULL;
      PyObject *margs[4] = {NULL, name, bases, dict};
      if (allow_py2_metaclass) {
          owned_metaclass = PyObject_GetItem(dict, __pyx_mstate_global->__pyx_n_u_metaclass);
          if (owned_metaclass) {
              metaclass = owned_metaclass;
          } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
              PyErr_Clear();
          } else {
              return NULL;
          }
      }
      if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
          metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
          Py_XDECREF(owned_metaclass);
          if (unlikely(!metaclass))
              return NULL;
          owned_metaclass = metaclass;
      }
      result = __Pyx_PyObject_FastCallDict(metaclass, margs+1, 3 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, mkw);
      Py_XDECREF(owned_metaclass);
      return result;
  }
  
/* CLineInTraceback (used by AddTraceback) */
  #if CYTHON_CLINE_IN_TRACEBACK && CYTHON_CLINE_IN_TRACEBACK_RUNTIME
  #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030A0000
  #define __Pyx_PyProbablyModule_GetDict(o) __Pyx_XNewRef(PyModule_GetDict(o))
  #elif !CYTHON_COMPILING_IN_CPYTHON || CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
  #define __Pyx_PyProbablyModule_GetDict(o) PyObject_GenericGetDict(o, NULL);
  #else
  PyObject* __Pyx_PyProbablyModule_GetDict(PyObject *o) {
      PyObject **dict_ptr = _PyObject_GetDictPtr(o);
      return dict_ptr ? __Pyx_XNewRef(*dict_ptr) : NULL;
  }
  #endif
  static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) {
      PyObject *use_cline = NULL;
      PyObject *ptype, *pvalue, *ptraceback;
      PyObject *cython_runtime_dict;
      CYTHON_MAYBE_UNUSED_VAR(tstate);
      if (unlikely(!__pyx_mstate_global->__pyx_cython_runtime)) {
          return c_line;
      }
      __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
      cython_runtime_dict = __Pyx_PyProbablyModule_GetDict(__pyx_mstate_global->__pyx_cython_runtime);
      if (likely(cython_runtime_dict)) {
          __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
              use_cline, cython_runtime_dict,
              __Pyx_PyDict_SetDefault(cython_runtime_dict, __pyx_mstate_global->__pyx_n_u_cline_in_traceback, Py_False))
      }
      if (use_cline == NULL || use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
          c_line = 0;
      }
      Py_XDECREF(use_cline);
      Py_XDECREF(cython_runtime_dict);
      __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
      return c_line;
  }
  #endif
  
/* CodeObjectCache (used by AddTraceback) */
  static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
      int start = 0, mid = 0, end = count - 1;
      if (end >= 0 && code_line > entries[end].code_line) {
          return count;
      }
      while (start < end) {
          mid = start + (end - start) / 2;
          if (code_line < entries[mid].code_line) {
              end = mid;
          } else if (code_line > entries[mid].code_line) {
               start = mid + 1;
          } else {
              return mid;
          }
      }
      if (code_line <= entries[mid].code_line) {
          return mid;
      } else {
          return mid + 1;
      }
  }
  static __Pyx_CachedCodeObjectType *__pyx__find_code_object(struct __Pyx_CodeObjectCache *code_cache, int code_line) {
      __Pyx_CachedCodeObjectType* code_object;
      int pos;
      if (unlikely(!code_line) || unlikely(!code_cache->entries)) {
          return NULL;
      }
      pos = __pyx_bisect_code_objects(code_cache->entries, code_cache->count, code_line);
      if (unlikely(pos >= code_cache->count) || unlikely(code_cache->entries[pos].code_line != code_line)) {
          return NULL;
      }
      code_object = code_cache->entries[pos].code_object;
      Py_INCREF(code_object);
      return code_object;
  }
  static __Pyx_CachedCodeObjectType *__pyx_find_code_object(int code_line) {
  #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && !CYTHON_ATOMICS
      (void)__pyx__find_code_object;
      return NULL; // Most implementation should have atomics. But otherwise, don't make it thread-safe, just miss.
  #else
      struct __Pyx_CodeObjectCache *code_cache = &__pyx_mstate_global->__pyx_code_cache;
  #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
      __pyx_nonatomic_int_type old_count = __pyx_atomic_incr_acq_rel(&code_cache->accessor_count);
      if (old_count < 0) {
          __pyx_atomic_decr_acq_rel(&code_cache->accessor_count);
          return NULL;
      }
  #endif
      __Pyx_CachedCodeObjectType *result = __pyx__find_code_object(code_cache, code_line);
  #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
      __pyx_atomic_decr_acq_rel(&code_cache->accessor_count);
  #endif
      return result;
  #endif
  }
  static void __pyx__insert_code_object(struct __Pyx_CodeObjectCache *code_cache, int code_line, __Pyx_CachedCodeObjectType* code_object)
  {
      int pos, i;
      __Pyx_CodeObjectCacheEntry* entries = code_cache->entries;
      if (unlikely(!code_line)) {
          return;
      }
      if (unlikely(!entries)) {
          entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
          if (likely(entries)) {
              code_cache->entries = entries;
              code_cache->max_count = 64;
              code_cache->count = 1;
              entries[0].code_line = code_line;
              entries[0].code_object = code_object;
              Py_INCREF(code_object);
          }
          return;
      }
      pos = __pyx_bisect_code_objects(code_cache->entries, code_cache->count, code_line);
      if ((pos < code_cache->count) && unlikely(code_cache->entries[pos].code_line == code_line)) {
          __Pyx_CachedCodeObjectType* tmp = entries[pos].code_object;
          entries[pos].code_object = code_object;
          Py_INCREF(code_object);
          Py_DECREF(tmp);
          return;
      }
      if (code_cache->count == code_cache->max_count) {
          int new_max = code_cache->max_count + 64;
          entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
              code_cache->entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
          if (unlikely(!entries)) {
              return;
          }
          code_cache->entries = entries;
          code_cache->max_count = new_max;
      }
      for (i=code_cache->count; i>pos; i--) {
          entries[i] = entries[i-1];
      }
      entries[pos].code_line = code_line;
      entries[pos].code_object = code_object;
      code_cache->count++;
      Py_INCREF(code_object);
  }
  static void __pyx_insert_code_object(int code_line, __Pyx_CachedCodeObjectType* code_object) {
  #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING && !CYTHON_ATOMICS
      (void)__pyx__insert_code_object;
      return; // Most implementation should have atomics. But otherwise, don't make it thread-safe, just fail.
  #else
      struct __Pyx_CodeObjectCache *code_cache = &__pyx_mstate_global->__pyx_code_cache;
  #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
      __pyx_nonatomic_int_type expected = 0;
      if (!__pyx_atomic_int_cmp_exchange(&code_cache->accessor_count, &expected, INT_MIN)) {
          return;
      }
  #endif
      __pyx__insert_code_object(code_cache, code_line, code_object);
  #if CYTHON_COMPILING_IN_CPYTHON_FREETHREADING
      __pyx_atomic_sub(&code_cache->accessor_count, INT_MIN);
  #endif
  #endif
  }
  
/* AddTraceback */
  #include "compile.h"
  #include "frameobject.h"
  #include "traceback.h"
  #if PY_VERSION_HEX >= 0x030b00a6 && !CYTHON_COMPILING_IN_LIMITED_API && !defined(PYPY_VERSION)
    #ifndef Py_BUILD_CORE
      #define Py_BUILD_CORE 1
    #endif
    #include "internal/pycore_frame.h"
  #endif
  #if CYTHON_COMPILING_IN_LIMITED_API
  static PyObject *__Pyx_PyCode_Replace_For_AddTraceback(PyObject *code, PyObject *scratch_dict,
                                                         PyObject *firstlineno, PyObject *name) {
      PyObject *replace = NULL;
      if (unlikely(PyDict_SetItemString(scratch_dict, "co_firstlineno", firstlineno))) return NULL;
      if (unlikely(PyDict_SetItemString(scratch_dict, "co_name", name))) return NULL;
      replace = PyObject_GetAttrString(code, "replace");
      if (likely(replace)) {
          PyObject *result = PyObject_Call(replace, __pyx_mstate_global->__pyx_empty_tuple, scratch_dict);
          Py_DECREF(replace);
          return result;
      }
      PyErr_Clear();
      return NULL;
  }
  static void __Pyx_AddTraceback(const char *funcname, int c_line,
                                 int py_line, const char *filename) {
      PyObject *code_object = NULL, *py_py_line = NULL, *py_funcname = NULL, *dict = NULL;
      PyObject *replace = NULL, *getframe = NULL, *frame = NULL;
      PyObject *exc_type, *exc_value, *exc_traceback;
      int success = 0;
      if (c_line) {
          c_line = __Pyx_CLineForTraceback(__Pyx_PyThreadState_Current, c_line);
      }
      PyErr_Fetch(&exc_type, &exc_value, &exc_traceback);
      code_object = __pyx_find_code_object(c_line ? -c_line : py_line);
      if (!code_object) {
          code_object = Py_CompileString("_getframe()", filename, Py_eval_input);
          if (unlikely(!code_object)) goto bad;
          py_py_line = PyLong_FromLong(py_line);
          if (unlikely(!py_py_line)) goto bad;
          if (c_line) {
              py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
          } else {
              py_funcname = PyUnicode_FromString(funcname);
          }
          if (unlikely(!py_funcname)) goto bad;
          dict = PyDict_New();
          if (unlikely(!dict)) goto bad;
          {
              PyObject *old_code_object = code_object;
              code_object = __Pyx_PyCode_Replace_For_AddTraceback(code_object, dict, py_py_line, py_funcname);
              Py_DECREF(old_code_object);
          }
          if (unlikely(!code_object)) goto bad;
          __pyx_insert_code_object(c_line ? -c_line : py_line, code_object);
      } else {
          dict = PyDict_New();
      }
      getframe = PySys_GetObject("_getframe");
      if (unlikely(!getframe)) goto bad;
      if (unlikely(PyDict_SetItemString(dict, "_getframe", getframe))) goto bad;
      frame = PyEval_EvalCode(code_object, dict, dict);
      if (unlikely(!frame) || frame == Py_None) goto bad;
      success = 1;
    bad:
      PyErr_Restore(exc_type, exc_value, exc_traceback);
      Py_XDECREF(code_object);
      Py_XDECREF(py_py_line);
      Py_XDECREF(py_funcname);
      Py_XDECREF(dict);
      Py_XDECREF(replace);
      if (success) {
          PyTraceBack_Here(
              (struct _frame*)frame);
      }
      Py_XDECREF(frame);
  }
  #else
  static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
              const char *funcname, int c_line,
              int py_line, const char *filename) {
      PyCodeObject *py_code = NULL;
      PyObject *py_funcname = NULL;
      if (c_line) {
          py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
          if (!py_funcname) goto bad;
          funcname = PyUnicode_AsUTF8(py_funcname);
          if (!funcname) goto bad;
      }
      py_code = PyCode_NewEmpty(filename, funcname, py_line);
      Py_XDECREF(py_funcname);
      return py_code;
  bad:
      Py_XDECREF(py_funcname);
      return NULL;
  }
  static void __Pyx_AddTraceback(const char *funcname, int c_line,
                                 int py_line, const char *filename) {
      PyCodeObject *py_code = 0;
      PyFrameObject *py_frame = 0;
      PyThreadState *tstate = __Pyx_PyThreadState_Current;
      PyObject *ptype, *pvalue, *ptraceback;
      if (c_line) {
          c_line = __Pyx_CLineForTraceback(tstate, c_line);
      }
      py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
      if (!py_code) {
          __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
          py_code = __Pyx_CreateCodeObjectForTraceback(
              funcname, c_line, py_line, filename);
          if (!py_code) {
              /* If the code object creation fails, then we should clear the
                 fetched exception references and propagate the new exception */
              Py_XDECREF(ptype);
              Py_XDECREF(pvalue);
              Py_XDECREF(ptraceback);
              goto bad;
          }
          __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
          __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
      }
      py_frame = PyFrame_New(
          tstate,            /*PyThreadState *tstate,*/
          py_code,           /*PyCodeObject *code,*/
          __pyx_mstate_global->__pyx_d,    /*PyObject *globals,*/
          0                  /*PyObject *locals*/
      );
      if (!py_frame) goto bad;
      __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
      PyTraceBack_Here(py_frame);
  bad:
      Py_XDECREF(py_code);
      Py_XDECREF(py_frame);
  }
  #endif
  
/* CIntToPy */
  static CYTHON_INLINE PyObject* __Pyx_PyLong_From_long(long value) {
  #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  #pragma GCC diagnostic push
  #pragma GCC diagnostic ignored "-Wconversion"
  #endif
      const long neg_one = (long) -1, const_zero = (long) 0;
  #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  #pragma GCC diagnostic pop
  #endif
      const int is_unsigned = neg_one > const_zero;
      if (is_unsigned) {
          if (sizeof(long) < sizeof(long)) {
              return PyLong_FromLong((long) value);
          } else if (sizeof(long) <= sizeof(unsigned long)) {
              return PyLong_FromUnsignedLong((unsigned long) value);
  #if !CYTHON_COMPILING_IN_PYPY
          } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
              return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
  #endif
          }
      } else {
          if (sizeof(long) <= sizeof(long)) {
              return PyLong_FromLong((long) value);
          } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
              return PyLong_FromLongLong((PY_LONG_LONG) value);
          }
      }
      {
          unsigned char *bytes = (unsigned char *)&value;
  #if !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d00A4
          if (is_unsigned) {
              return PyLong_FromUnsignedNativeBytes(bytes, sizeof(value), -1);
          } else {
              return PyLong_FromNativeBytes(bytes, sizeof(value), -1);
          }
  #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX < 0x030d0000
          int one = 1; int little = (int)*(unsigned char *)&one;
          return _PyLong_FromByteArray(bytes, sizeof(long),
                                       little, !is_unsigned);
  #else
          int one = 1; int little = (int)*(unsigned char *)&one;
          PyObject *from_bytes, *result = NULL, *kwds = NULL;
          PyObject *py_bytes = NULL, *order_str = NULL;
          from_bytes = PyObject_GetAttrString((PyObject*)&PyLong_Type, "from_bytes");
          if (!from_bytes) return NULL;
          py_bytes = PyBytes_FromStringAndSize((char*)bytes, sizeof(long));
          if (!py_bytes) goto limited_bad;
          order_str = PyUnicode_FromString(little ? "little" : "big");
          if (!order_str) goto limited_bad;
          {
              PyObject *args[3+(CYTHON_VECTORCALL ? 1 : 0)] = { NULL, py_bytes, order_str };
              if (!is_unsigned) {
                  kwds = __Pyx_MakeVectorcallBuilderKwds(1);
                  if (!kwds) goto limited_bad;
                  if (__Pyx_VectorcallBuilder_AddArgStr("signed", __Pyx_NewRef(Py_True), kwds, args+3, 0) < 0) goto limited_bad;
              }
              result = __Pyx_Object_Vectorcall_CallFromBuilder(from_bytes, args+1, 2 | __Pyx_PY_VECTORCALL_ARGUMENTS_OFFSET, kwds);
          }
          limited_bad:
          Py_XDECREF(kwds);
          Py_XDECREF(order_str);
          Py_XDECREF(py_bytes);
          Py_XDECREF(from_bytes);
          return result;
  #endif
      }
  }
  
/* FormatTypeName */
  #if CYTHON_COMPILING_IN_LIMITED_API && __PYX_LIMITED_VERSION_HEX < 0x030d0000
  static __Pyx_TypeName
  __Pyx_PyType_GetFullyQualifiedName(PyTypeObject* tp)
  {
      PyObject *module = NULL, *name = NULL, *result = NULL;
      #if __PYX_LIMITED_VERSION_HEX < 0x030b0000
      name = __Pyx_PyObject_GetAttrStr((PyObject *)tp,
                                                 __pyx_mstate_global->__pyx_n_u_qualname);
      #else
      name = PyType_GetQualName(tp);
      #endif
      if (unlikely(name == NULL) || unlikely(!PyUnicode_Check(name))) goto bad;
      module = __Pyx_PyObject_GetAttrStr((PyObject *)tp,
                                                 __pyx_mstate_global->__pyx_n_u_module_2);
      if (unlikely(module == NULL) || unlikely(!PyUnicode_Check(module))) goto bad;
      if (PyUnicode_CompareWithASCIIString(module, "builtins") == 0) {
          result = name;
          name = NULL;
          goto done;
      }
      result = PyUnicode_FromFormat("%U.%U", module, name);
      if (unlikely(result == NULL)) goto bad;
    done:
      Py_XDECREF(name);
      Py_XDECREF(module);
      return result;
    bad:
      PyErr_Clear();
      if (name) {
          result = name;
          name = NULL;
      } else {
          result = __Pyx_NewRef(__pyx_mstate_global->__pyx_kp_u__15);
      }
      goto done;
  }
  #endif
  
/* CIntFromPyVerify (used by CIntFromPy) */
  #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
      __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
  #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
      __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
  #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
      {\
          func_type value = func_value;\
          if (sizeof(target_type) < sizeof(func_type)) {\
              if (unlikely(value != (func_type) (target_type) value)) {\
                  func_type zero = 0;\
                  if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
                      return (target_type) -1;\
                  if (is_unsigned && unlikely(value < zero))\
                      goto raise_neg_overflow;\
                  else\
                      goto raise_overflow;\
              }\
          }\
          return (target_type) value;\
      }
  
/* CIntFromPy */
  static CYTHON_INLINE long __Pyx_PyLong_As_long(PyObject *x) {
  #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  #pragma GCC diagnostic push
  #pragma GCC diagnostic ignored "-Wconversion"
  #endif
      const long neg_one = (long) -1, const_zero = (long) 0;
  #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  #pragma GCC diagnostic pop
  #endif
      const int is_unsigned = neg_one > const_zero;
      if (unlikely(!PyLong_Check(x))) {
          long val;
          PyObject *tmp = __Pyx_PyNumber_Long(x);
          if (!tmp) return (long) -1;
          val = __Pyx_PyLong_As_long(tmp);
          Py_DECREF(tmp);
          return val;
      }
      if (is_unsigned) {
  #if CYTHON_USE_PYLONG_INTERNALS
          if (unlikely(__Pyx_PyLong_IsNeg(x))) {
              goto raise_neg_overflow;
          } else if (__Pyx_PyLong_IsCompact(x)) {
              __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
          } else {
              const digit* digits = __Pyx_PyLong_Digits(x);
              assert(__Pyx_PyLong_DigitCount(x) > 1);
              switch (__Pyx_PyLong_DigitCount(x)) {
                  case 2:
                      if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) {
                          if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
                              __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                          } else if ((8 * sizeof(long) >= 2 * PyLong_SHIFT)) {
                              return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                          }
                      }
                      break;
                  case 3:
                      if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) {
                          if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
                              __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                          } else if ((8 * sizeof(long) >= 3 * PyLong_SHIFT)) {
                              return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                          }
                      }
                      break;
                  case 4:
                      if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) {
                          if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
                              __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                          } else if ((8 * sizeof(long) >= 4 * PyLong_SHIFT)) {
                              return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
                          }
                      }
                      break;
              }
          }
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
          if (unlikely(Py_SIZE(x) < 0)) {
              goto raise_neg_overflow;
          }
  #else
          {
              int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
              if (unlikely(result < 0))
                  return (long) -1;
              if (unlikely(result == 1))
                  goto raise_neg_overflow;
          }
  #endif
          if ((sizeof(long) <= sizeof(unsigned long))) {
              __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
          } else if ((sizeof(long) <= sizeof(unsigned PY_LONG_LONG))) {
              __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
          }
      } else {
  #if CYTHON_USE_PYLONG_INTERNALS
          if (__Pyx_PyLong_IsCompact(x)) {
              __PYX_VERIFY_RETURN_INT(long, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
          } else {
              const digit* digits = __Pyx_PyLong_Digits(x);
              assert(__Pyx_PyLong_DigitCount(x) > 1);
              switch (__Pyx_PyLong_SignedDigitCount(x)) {
                  case -2:
                      if ((8 * sizeof(long) - 1 > 1 * PyLong_SHIFT)) {
                          if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
                              __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                          } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
                              return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                          }
                      }
                      break;
                  case 2:
                      if ((8 * sizeof(long) > 1 * PyLong_SHIFT)) {
                          if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
                              __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                          } else if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
                              return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                          }
                      }
                      break;
                  case -3:
                      if ((8 * sizeof(long) - 1 > 2 * PyLong_SHIFT)) {
                          if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
                              __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                          } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
                              return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                          }
                      }
                      break;
                  case 3:
                      if ((8 * sizeof(long) > 2 * PyLong_SHIFT)) {
                          if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
                              __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                          } else if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
                              return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                          }
                      }
                      break;
                  case -4:
                      if ((8 * sizeof(long) - 1 > 3 * PyLong_SHIFT)) {
                          if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
                              __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                          } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) {
                              return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                          }
                      }
                      break;
                  case 4:
                      if ((8 * sizeof(long) > 3 * PyLong_SHIFT)) {
                          if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
                              __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                          } else if ((8 * sizeof(long) - 1 > 4 * PyLong_SHIFT)) {
                              return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
                          }
                      }
                      break;
              }
          }
  #endif
          if ((sizeof(long) <= sizeof(long))) {
              __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
          } else if ((sizeof(long) <= sizeof(PY_LONG_LONG))) {
              __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
          }
      }
      {
          long val;
          int ret = -1;
  #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
          Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
              x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
          if (unlikely(bytes_copied == -1)) {
          } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
              goto raise_overflow;
          } else {
              ret = 0;
          }
  #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
          int one = 1; int is_little = (int)*(unsigned char *)&one;
          unsigned char *bytes = (unsigned char *)&val;
          ret = _PyLong_AsByteArray((PyLongObject *)x,
                                      bytes, sizeof(val),
                                      is_little, !is_unsigned);
  #else
          PyObject *v;
          PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
          int bits, remaining_bits, is_negative = 0;
          int chunk_size = (sizeof(long) < 8) ? 30 : 62;
          if (likely(PyLong_CheckExact(x))) {
              v = __Pyx_NewRef(x);
          } else {
              v = PyNumber_Long(x);
              if (unlikely(!v)) return (long) -1;
              assert(PyLong_CheckExact(v));
          }
          {
              int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
              if (unlikely(result < 0)) {
                  Py_DECREF(v);
                  return (long) -1;
              }
              is_negative = result == 1;
          }
          if (is_unsigned && unlikely(is_negative)) {
              Py_DECREF(v);
              goto raise_neg_overflow;
          } else if (is_negative) {
              stepval = PyNumber_Invert(v);
              Py_DECREF(v);
              if (unlikely(!stepval))
                  return (long) -1;
          } else {
              stepval = v;
          }
          v = NULL;
          val = (long) 0;
          mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
          shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
          for (bits = 0; bits < (int) sizeof(long) * 8 - chunk_size; bits += chunk_size) {
              PyObject *tmp, *digit;
              long idigit;
              digit = PyNumber_And(stepval, mask);
              if (unlikely(!digit)) goto done;
              idigit = PyLong_AsLong(digit);
              Py_DECREF(digit);
              if (unlikely(idigit < 0)) goto done;
              val |= ((long) idigit) << bits;
              tmp = PyNumber_Rshift(stepval, shift);
              if (unlikely(!tmp)) goto done;
              Py_DECREF(stepval); stepval = tmp;
          }
          Py_DECREF(shift); shift = NULL;
          Py_DECREF(mask); mask = NULL;
          {
              long idigit = PyLong_AsLong(stepval);
              if (unlikely(idigit < 0)) goto done;
              remaining_bits = ((int) sizeof(long) * 8) - bits - (is_unsigned ? 0 : 1);
              if (unlikely(idigit >= (1L << remaining_bits)))
                  goto raise_overflow;
              val |= ((long) idigit) << bits;
          }
          if (!is_unsigned) {
              if (unlikely(val & (((long) 1) << (sizeof(long) * 8 - 1))))
                  goto raise_overflow;
              if (is_negative)
                  val = ~val;
          }
          ret = 0;
      done:
          Py_XDECREF(shift);
          Py_XDECREF(mask);
          Py_XDECREF(stepval);
  #endif
          if (unlikely(ret))
              return (long) -1;
          return val;
      }
  raise_overflow:
      PyErr_SetString(PyExc_OverflowError,
          "value too large to convert to long");
      return (long) -1;
  raise_neg_overflow:
      PyErr_SetString(PyExc_OverflowError,
          "can't convert negative value to long");
      return (long) -1;
  }
  
/* CIntFromPy */
  static CYTHON_INLINE int __Pyx_PyLong_As_int(PyObject *x) {
  #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  #pragma GCC diagnostic push
  #pragma GCC diagnostic ignored "-Wconversion"
  #endif
      const int neg_one = (int) -1, const_zero = (int) 0;
  #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
  #pragma GCC diagnostic pop
  #endif
      const int is_unsigned = neg_one > const_zero;
      if (unlikely(!PyLong_Check(x))) {
          int val;
          PyObject *tmp = __Pyx_PyNumber_Long(x);
          if (!tmp) return (int) -1;
          val = __Pyx_PyLong_As_int(tmp);
          Py_DECREF(tmp);
          return val;
      }
      if (is_unsigned) {
  #if CYTHON_USE_PYLONG_INTERNALS
          if (unlikely(__Pyx_PyLong_IsNeg(x))) {
              goto raise_neg_overflow;
          } else if (__Pyx_PyLong_IsCompact(x)) {
              __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_upylong, __Pyx_PyLong_CompactValueUnsigned(x))
          } else {
              const digit* digits = __Pyx_PyLong_Digits(x);
              assert(__Pyx_PyLong_DigitCount(x) > 1);
              switch (__Pyx_PyLong_DigitCount(x)) {
                  case 2:
                      if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) {
                          if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
                              __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                          } else if ((8 * sizeof(int) >= 2 * PyLong_SHIFT)) {
                              return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                          }
                      }
                      break;
                  case 3:
                      if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) {
                          if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
                              __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                          } else if ((8 * sizeof(int) >= 3 * PyLong_SHIFT)) {
                              return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                          }
                      }
                      break;
                  case 4:
                      if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) {
                          if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
                              __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                          } else if ((8 * sizeof(int) >= 4 * PyLong_SHIFT)) {
                              return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
                          }
                      }
                      break;
              }
          }
  #endif
  #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030C00A7
          if (unlikely(Py_SIZE(x) < 0)) {
              goto raise_neg_overflow;
          }
  #else
          {
              int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
              if (unlikely(result < 0))
                  return (int) -1;
              if (unlikely(result == 1))
                  goto raise_neg_overflow;
          }
  #endif
          if ((sizeof(int) <= sizeof(unsigned long))) {
              __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
          } else if ((sizeof(int) <= sizeof(unsigned PY_LONG_LONG))) {
              __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
          }
      } else {
  #if CYTHON_USE_PYLONG_INTERNALS
          if (__Pyx_PyLong_IsCompact(x)) {
              __PYX_VERIFY_RETURN_INT(int, __Pyx_compact_pylong, __Pyx_PyLong_CompactValue(x))
          } else {
              const digit* digits = __Pyx_PyLong_Digits(x);
              assert(__Pyx_PyLong_DigitCount(x) > 1);
              switch (__Pyx_PyLong_SignedDigitCount(x)) {
                  case -2:
                      if ((8 * sizeof(int) - 1 > 1 * PyLong_SHIFT)) {
                          if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
                              __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                          } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
                              return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                          }
                      }
                      break;
                  case 2:
                      if ((8 * sizeof(int) > 1 * PyLong_SHIFT)) {
                          if ((8 * sizeof(unsigned long) > 2 * PyLong_SHIFT)) {
                              __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                          } else if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
                              return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                          }
                      }
                      break;
                  case -3:
                      if ((8 * sizeof(int) - 1 > 2 * PyLong_SHIFT)) {
                          if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
                              __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                          } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
                              return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                          }
                      }
                      break;
                  case 3:
                      if ((8 * sizeof(int) > 2 * PyLong_SHIFT)) {
                          if ((8 * sizeof(unsigned long) > 3 * PyLong_SHIFT)) {
                              __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                          } else if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
                              return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                          }
                      }
                      break;
                  case -4:
                      if ((8 * sizeof(int) - 1 > 3 * PyLong_SHIFT)) {
                          if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
                              __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                          } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) {
                              return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                          }
                      }
                      break;
                  case 4:
                      if ((8 * sizeof(int) > 3 * PyLong_SHIFT)) {
                          if ((8 * sizeof(unsigned long) > 4 * PyLong_SHIFT)) {
                              __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
                          } else if ((8 * sizeof(int) - 1 > 4 * PyLong_SHIFT)) {
                              return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
                          }
                      }
                      break;
              }
          }
  #endif
          if ((sizeof(int) <= sizeof(long))) {
              __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
          } else if ((sizeof(int) <= sizeof(PY_LONG_LONG))) {
              __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
          }
      }
      {
          int val;
          int ret = -1;
  #if PY_VERSION_HEX >= 0x030d00A6 && !CYTHON_COMPILING_IN_LIMITED_API
          Py_ssize_t bytes_copied = PyLong_AsNativeBytes(
              x, &val, sizeof(val), Py_ASNATIVEBYTES_NATIVE_ENDIAN | (is_unsigned ? Py_ASNATIVEBYTES_UNSIGNED_BUFFER | Py_ASNATIVEBYTES_REJECT_NEGATIVE : 0));
          if (unlikely(bytes_copied == -1)) {
          } else if (unlikely(bytes_copied > (Py_ssize_t) sizeof(val))) {
              goto raise_overflow;
          } else {
              ret = 0;
          }
  #elif PY_VERSION_HEX < 0x030d0000 && !(CYTHON_COMPILING_IN_PYPY || CYTHON_COMPILING_IN_LIMITED_API) || defined(_PyLong_AsByteArray)
          int one = 1; int is_little = (int)*(unsigned char *)&one;
          unsigned char *bytes = (unsigned char *)&val;
          ret = _PyLong_AsByteArray((PyLongObject *)x,
                                      bytes, sizeof(val),
                                      is_little, !is_unsigned);
  #else
          PyObject *v;
          PyObject *stepval = NULL, *mask = NULL, *shift = NULL;
          int bits, remaining_bits, is_negative = 0;
          int chunk_size = (sizeof(long) < 8) ? 30 : 62;
          if (likely(PyLong_CheckExact(x))) {
              v = __Pyx_NewRef(x);
          } else {
              v = PyNumber_Long(x);
              if (unlikely(!v)) return (int) -1;
              assert(PyLong_CheckExact(v));
          }
          {
              int result = PyObject_RichCompareBool(v, Py_False, Py_LT);
              if (unlikely(result < 0)) {
                  Py_DECREF(v);
                  return (int) -1;
              }
              is_negative = result == 1;
          }
          if (is_unsigned && unlikely(is_negative)) {
              Py_DECREF(v);
              goto raise_neg_overflow;
          } else if (is_negative) {
              stepval = PyNumber_Invert(v);
              Py_DECREF(v);
              if (unlikely(!stepval))
                  return (int) -1;
          } else {
              stepval = v;
          }
          v = NULL;
          val = (int) 0;
          mask = PyLong_FromLong((1L << chunk_size) - 1); if (unlikely(!mask)) goto done;
          shift = PyLong_FromLong(chunk_size); if (unlikely(!shift)) goto done;
          for (bits = 0; bits < (int) sizeof(int) * 8 - chunk_size; bits += chunk_size) {
              PyObject *tmp, *digit;
              long idigit;
              digit = PyNumber_And(stepval, mask);
              if (unlikely(!digit)) goto done;
              idigit = PyLong_AsLong(digit);
              Py_DECREF(digit);
              if (unlikely(idigit < 0)) goto done;
              val |= ((int) idigit) << bits;
              tmp = PyNumber_Rshift(stepval, shift);
              if (unlikely(!tmp)) goto done;
              Py_DECREF(stepval); stepval = tmp;
          }
          Py_DECREF(shift); shift = NULL;
          Py_DECREF(mask); mask = NULL;
          {
              long idigit = PyLong_AsLong(stepval);
              if (unlikely(idigit < 0)) goto done;
              remaining_bits = ((int) sizeof(int) * 8) - bits - (is_unsigned ? 0 : 1);
              if (unlikely(idigit >= (1L << remaining_bits)))
                  goto raise_overflow;
              val |= ((int) idigit) << bits;
          }
          if (!is_unsigned) {
              if (unlikely(val & (((int) 1) << (sizeof(int) * 8 - 1))))
                  goto raise_overflow;
              if (is_negative)
                  val = ~val;
          }
          ret = 0;
      done:
          Py_XDECREF(shift);
          Py_XDECREF(mask);
          Py_XDECREF(stepval);
  #endif
          if (unlikely(ret))
              return (int) -1;
          return val;
      }
  raise_overflow:
      PyErr_SetString(PyExc_OverflowError,
          "value too large to convert to int");
      return (int) -1;
  raise_neg_overflow:
      PyErr_SetString(PyExc_OverflowError,
          "can't convert negative value to int");
      return (int) -1;
  }
  
/* GetRuntimeVersion */
  #if __PYX_LIMITED_VERSION_HEX < 0x030b0000
  void __Pyx_init_runtime_version(void) {
      if (__Pyx_cached_runtime_version == 0) {
          const char* rt_version = Py_GetVersion();
          unsigned long version = 0;
          unsigned long factor = 0x01000000UL;
          unsigned int digit = 0;
          int i = 0;
          while (factor) {
              while ('0' <= rt_version[i] && rt_version[i] <= '9') {
                  digit = digit * 10 + (unsigned int) (rt_version[i] - '0');
                  ++i;
              }
              version += factor * digit;
              if (rt_version[i] != '.')
                  break;
              digit = 0;
              factor >>= 8;
              ++i;
          }
          __Pyx_cached_runtime_version = version;
      }
  }
  #endif
  static unsigned long __Pyx_get_runtime_version(void) {
  #if __PYX_LIMITED_VERSION_HEX >= 0x030b0000
      return Py_Version & ~0xFFUL;
  #else
      return __Pyx_cached_runtime_version;
  #endif
  }
  
/* Generator */
  static PyMethodDef __pyx_Generator_methods[] = {
      {"send", (PyCFunction) __Pyx_Coroutine_Send, METH_O,
       PyDoc_STR("send(arg) -> send 'arg' into generator,\nreturn next yielded value or raise StopIteration.")},
      {"throw", (PyCFunction) __Pyx_Coroutine_Throw, METH_VARARGS,
       PyDoc_STR("throw(typ[,val[,tb]]) -> raise exception in generator,\nreturn next yielded value or raise StopIteration.")},
      {"close", (PyCFunction) __Pyx_Coroutine_Close_Method, METH_NOARGS,
       PyDoc_STR("close() -> raise GeneratorExit inside generator.")},
      {"__reduce_ex__", (PyCFunction) __Pyx_Coroutine_fail_reduce_ex, METH_O, 0},
      {"__reduce__", (PyCFunction) __Pyx_Coroutine_fail_reduce_ex, METH_NOARGS, 0},
      {0, 0, 0, 0}
  };
  static PyMemberDef __pyx_Generator_memberlist[] = {
      {"gi_yieldfrom", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
       PyDoc_STR("object being iterated by 'yield from', or None")},
      {"gi_code", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_code), READONLY, NULL},
      {"__module__", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_modulename), 0, 0},
  #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
      {"__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CoroutineObject, gi_weakreflist), READONLY, 0},
  #endif
      {0, 0, 0, 0, 0}
  };
  static PyGetSetDef __pyx_Generator_getsets[] = {
      {"__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
       PyDoc_STR("name of the generator"), 0},
      {"__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
       PyDoc_STR("qualified name of the generator"), 0},
      {"gi_frame", (getter)__Pyx_Coroutine_get_frame, NULL,
       PyDoc_STR("Frame of the generator"), 0},
      {"gi_running", __Pyx_Coroutine_get_is_running_getter, NULL, NULL, NULL},
      {0, 0, 0, 0, 0}
  };
  static PyType_Slot __pyx_GeneratorType_slots[] = {
      {Py_tp_dealloc, (void *)__Pyx_Coroutine_dealloc},
      {Py_tp_traverse, (void *)__Pyx_Coroutine_traverse},
      {Py_tp_iter, (void *)PyObject_SelfIter},
      {Py_tp_iternext, (void *)__Pyx_Generator_Next},
      {Py_tp_methods, (void *)__pyx_Generator_methods},
      {Py_tp_members, (void *)__pyx_Generator_memberlist},
      {Py_tp_getset, (void *)__pyx_Generator_getsets},
      {Py_tp_getattro, (void *) PyObject_GenericGetAttr},
  #if CYTHON_USE_TP_FINALIZE
      {Py_tp_finalize, (void *)__Pyx_Coroutine_del},
  #endif
  #if __PYX_HAS_PY_AM_SEND == 1
      {Py_am_send, (void *)__Pyx_Coroutine_AmSend},
  #endif
      {0, 0},
  };
  static PyType_Spec __pyx_GeneratorType_spec = {
      __PYX_TYPE_MODULE_PREFIX "generator",
      sizeof(__pyx_CoroutineObject),
      0,
  #if PY_VERSION_HEX >= 0x030C0000 && !CYTHON_COMPILING_IN_LIMITED_API
      Py_TPFLAGS_MANAGED_WEAKREF |
  #endif
      Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION |
      Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | __Pyx_TPFLAGS_HAVE_AM_SEND,
      __pyx_GeneratorType_slots
  };
  #if __PYX_HAS_PY_AM_SEND == 2
  static __Pyx_PyAsyncMethodsStruct __pyx_Generator_as_async;
  #endif
  static int __pyx_Generator_init(PyObject *module) {
      __pyx_mstatetype *mstate = __Pyx_PyModule_GetState(module);
      mstate->__pyx_GeneratorType = __Pyx_FetchCommonTypeFromSpec(
          mstate->__pyx_CommonTypesMetaclassType, module, &__pyx_GeneratorType_spec, NULL);
      if (unlikely(!mstate->__pyx_GeneratorType)) {
          return -1;
      }
  #if __PYX_HAS_PY_AM_SEND == 2
      __Pyx_SetBackportTypeAmSend(mstate->__pyx_GeneratorType, &__pyx_Generator_as_async, &__Pyx_Coroutine_AmSend);
  #endif
      return 0;
  }
  static PyObject *__Pyx_Generator_GetInlinedResult(PyObject *self) {
      __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*) self;
      PyObject *retval = NULL;
      if (unlikely(__Pyx_Coroutine_test_and_set_is_running(gen))) {
          return __Pyx_Coroutine_AlreadyRunningError(gen);
      }
      __Pyx_PySendResult result = __Pyx_Coroutine_SendEx(gen, Py_None, &retval, 0);
      __Pyx_Coroutine_unset_is_running(gen);
      (void) result;
      assert (result == PYGEN_RETURN || result == PYGEN_ERROR);
      assert ((result == PYGEN_RETURN && retval != NULL) || (result == PYGEN_ERROR && retval == NULL));
      return retval;
  }
  
/* AsyncGenerator (used by AsyncGen) */
  PyDoc_STRVAR(__Pyx_async_gen_send_doc,
  "send(arg) -> send 'arg' into generator,\n\
  return next yielded value or raise StopIteration.");
  PyDoc_STRVAR(__Pyx_async_gen_close_doc,
  "close() -> raise GeneratorExit inside generator.");
  PyDoc_STRVAR(__Pyx_async_gen_throw_doc,
  "throw(typ[,val[,tb]]) -> raise exception in generator,\n\
  return next yielded value or raise StopIteration.");
  PyDoc_STRVAR(__Pyx_async_gen_await_doc,
  "__await__() -> return a representation that can be passed into the 'await' expression.");
  static __pyx_CoroutineObject *__Pyx_AsyncGen_New(
              __pyx_coroutine_body_t body, PyObject *code, PyObject *closure,
              PyObject *name, PyObject *qualname, PyObject *module_name) {
      __pyx_PyAsyncGenObject *gen = PyObject_GC_New(__pyx_PyAsyncGenObject, __pyx_mstate_global->__pyx_AsyncGenType);
      if (unlikely(!gen))
          return NULL;
      gen->ag_finalizer = NULL;
      gen->ag_closed = 0;
      gen->ag_hooks_inited = 0;
      gen->ag_running_async = 0;
      return __Pyx__Coroutine_NewInit((__pyx_CoroutineObject*)gen, body, code, closure, name, qualname, module_name);
  }
  static PyObject *__Pyx_async_gen_asend_new(__pyx_PyAsyncGenObject *, PyObject *);
  static PyObject *__Pyx_async_gen_athrow_new(__pyx_PyAsyncGenObject *, PyObject *);
  static const char *__Pyx_NON_INIT_CORO_MSG = "can't send non-None value to a just-started coroutine";
  static const char *__Pyx_ASYNC_GEN_IGNORED_EXIT_MSG = "async generator ignored GeneratorExit";
  static const char *__Pyx_ASYNC_GEN_CANNOT_REUSE_SEND_MSG = "cannot reuse already awaited __anext__()/asend()";
  static const char *__Pyx_ASYNC_GEN_CANNOT_REUSE_CLOSE_MSG = "cannot reuse already awaited aclose()/athrow()";
  typedef enum {
      __PYX_AWAITABLE_STATE_INIT,
      __PYX_AWAITABLE_STATE_ITER,
      __PYX_AWAITABLE_STATE_CLOSED,
  } __pyx_AwaitableState;
  typedef struct __pyx_PyAsyncGenASend {
      PyObject_HEAD
      __pyx_PyAsyncGenObject *ags_gen;
      PyObject *ags_sendval;
      __pyx_AwaitableState ags_state;
  } __pyx_PyAsyncGenASend;
  typedef struct {
      PyObject_HEAD
      __pyx_PyAsyncGenObject *agt_gen;
      PyObject *agt_args;
      __pyx_AwaitableState agt_state;
  } __pyx_PyAsyncGenAThrow;
  typedef struct __pyx__PyAsyncGenWrappedValue {
      PyObject_HEAD
      PyObject *agw_val;
  } __pyx__PyAsyncGenWrappedValue;
  #define __pyx__PyAsyncGenWrappedValue_CheckExact(o)\
                      __Pyx_IS_TYPE(o, __pyx_mstate_global->__pyx__PyAsyncGenWrappedValueType)
  static int
  __Pyx_async_gen_traverse(__pyx_PyAsyncGenObject *gen, visitproc visit, void *arg)
  {
      Py_VISIT(gen->ag_finalizer);
      return __Pyx_Coroutine_traverse((__pyx_CoroutineObject*)gen, visit, arg);
  }
  static PyObject *
  __Pyx_async_gen_repr(__pyx_CoroutineObject *o)
  {
      return PyUnicode_FromFormat("<async_generator object %S at %p>",
                                  o->gi_qualname ? o->gi_qualname : Py_None, o);
  }
  static int
  __Pyx_async_gen_init_hooks_firstiter(__pyx_PyAsyncGenObject *o, PyObject *firstiter)
  {
      PyObject *res;
  #if CYTHON_UNPACK_METHODS
      PyObject *self;
      if (likely(PyMethod_Check(firstiter)) && likely((self = PyMethod_GET_SELF(firstiter)) != NULL)) {
          PyObject *function = PyMethod_GET_FUNCTION(firstiter);
          res = __Pyx_PyObject_Call2Args(function, self, (PyObject*)o);
      } else
  #endif
      res = __Pyx_PyObject_CallOneArg(firstiter, (PyObject*)o);
      Py_DECREF(firstiter);
      if (unlikely(res == NULL))
          return 1;
      Py_DECREF(res);
      return 0;
  }
  static CYTHON_INLINE int
  __Pyx_async_gen_init_hooks_done(__pyx_PyAsyncGenObject *o) {
      return o->ag_hooks_inited != 0;
  }
  static int
  __Pyx_async_gen_init_hooks(__pyx_PyAsyncGenObject *o)
  {
  #if !CYTHON_COMPILING_IN_PYPY && !CYTHON_COMPILING_IN_LIMITED_API
      PyThreadState *tstate;
  #endif
      PyObject *finalizer;
      PyObject *firstiter;
      assert (!__Pyx_async_gen_init_hooks_done(o));
      o->ag_hooks_inited = 1;
  #if CYTHON_COMPILING_IN_LIMITED_API
      {
          PyObject *hooks_func = PySys_GetObject("get_asyncgen_hooks");
          if (unlikely(!hooks_func)) {
              PyErr_SetString(
                  PyExc_AttributeError,
                  "Failed to get 'get_asyncgen_hooks' from sys"
              );
              return 1;
          }
          PyObject *async_gen_hooks = PyObject_CallFunctionObjArgs(hooks_func, NULL);
          if (unlikely(!async_gen_hooks)) return 1;
          firstiter = PySequence_GetItem(async_gen_hooks, 0);
          if (unlikely(!firstiter)) {
              Py_DECREF(async_gen_hooks);
              return 1;
          }
          if (firstiter == Py_None) {
              Py_CLEAR(firstiter);
          }
          finalizer = PySequence_GetItem(async_gen_hooks, 1);
          Py_DECREF(async_gen_hooks);
          if (unlikely(!finalizer)) {
              Py_XDECREF(firstiter);
              return 1;
          }
          if (finalizer == Py_None) {
              Py_CLEAR(finalizer);
          }
      }
  #endif
  #if CYTHON_COMPILING_IN_PYPY
      finalizer = _PyEval_GetAsyncGenFinalizer();
  #elif !CYTHON_COMPILING_IN_LIMITED_API
      tstate = __Pyx_PyThreadState_Current;
      finalizer = tstate->async_gen_finalizer;
  #endif
      if (finalizer) {
  #if !CYTHON_COMPILING_IN_LIMITED_API
          Py_INCREF(finalizer);
  #endif
          o->ag_finalizer = finalizer;
      }
  #if CYTHON_COMPILING_IN_PYPY
      firstiter = _PyEval_GetAsyncGenFirstiter();
  #elif !CYTHON_COMPILING_IN_LIMITED_API
      firstiter = tstate->async_gen_firstiter;
  #endif
      if (firstiter) {
  #if !CYTHON_COMPILING_IN_LIMITED_API
          Py_INCREF(firstiter);
  #endif
          if (unlikely(__Pyx_async_gen_init_hooks_firstiter(o, firstiter)))
              return 1;
      }
      return 0;
  }
  static PyObject *
  __Pyx_async_gen_anext(PyObject *g)
  {
      __pyx_PyAsyncGenObject *o = (__pyx_PyAsyncGenObject*) g;
      if (!__Pyx_async_gen_init_hooks_done(o) && unlikely(__Pyx_async_gen_init_hooks(o))) {
          return NULL;
      }
      return __Pyx_async_gen_asend_new(o, NULL);
  }
  static PyObject *
  __Pyx_async_gen_anext_method(PyObject *g, PyObject *arg) {
      CYTHON_UNUSED_VAR(arg);
      return __Pyx_async_gen_anext(g);
  }
  static PyObject *
  __Pyx_async_gen_asend(__pyx_PyAsyncGenObject *o, PyObject *arg)
  {
      if (!__Pyx_async_gen_init_hooks_done(o) && unlikely(__Pyx_async_gen_init_hooks(o))) {
          return NULL;
      }
      return __Pyx_async_gen_asend_new(o, arg);
  }
  static PyObject *
  __Pyx_async_gen_aclose(__pyx_PyAsyncGenObject *o, PyObject *arg)
  {
      CYTHON_UNUSED_VAR(arg);
      if (!__Pyx_async_gen_init_hooks_done(o) && unlikely(__Pyx_async_gen_init_hooks(o))) {
          return NULL;
      }
      return __Pyx_async_gen_athrow_new(o, NULL);
  }
  static PyObject *
  __Pyx_async_gen_athrow(__pyx_PyAsyncGenObject *o, PyObject *args)
  {
      if (!__Pyx_async_gen_init_hooks_done(o) && unlikely(__Pyx_async_gen_init_hooks(o))) {
          return NULL;
      }
      return __Pyx_async_gen_athrow_new(o, args);
  }
  static PyObject *
  __Pyx_async_gen_self_method(PyObject *g, PyObject *arg) {
      CYTHON_UNUSED_VAR(arg);
      return __Pyx_NewRef(g);
  }
  static PyObject *
  __Pyx_async_gen_get_running(__pyx_PyAsyncGenObject *o, void *context) {
      CYTHON_UNUSED_VAR(context);
      return __Pyx_NewRef(o->ag_running_async ? Py_True : Py_False);
  }
  static PyGetSetDef __Pyx_async_gen_getsetlist[] = {
      {"__name__", (getter)__Pyx_Coroutine_get_name, (setter)__Pyx_Coroutine_set_name,
       PyDoc_STR("name of the async generator"), 0},
      {"__qualname__", (getter)__Pyx_Coroutine_get_qualname, (setter)__Pyx_Coroutine_set_qualname,
       PyDoc_STR("qualified name of the async generator"), 0},
      {"ag_running", (getter)__Pyx_async_gen_get_running, NULL, NULL, 0},
      {0, 0, 0, 0, 0}
  };
  static PyMemberDef __Pyx_async_gen_memberlist[] = {
      {"ag_await", T_OBJECT, offsetof(__pyx_CoroutineObject, yieldfrom), READONLY,
       PyDoc_STR("object being awaited on, or None")},
      {"__module__", T_OBJECT, offsetof(__pyx_CoroutineObject, gi_modulename), 0, 0},
  #if PY_VERSION_HEX < 0x030C0000 || CYTHON_COMPILING_IN_LIMITED_API
      {"__weaklistoffset__", T_PYSSIZET, offsetof(__pyx_CoroutineObject, gi_weakreflist), READONLY, 0},
  #endif
      {0, 0, 0, 0, 0}
  };
  PyDoc_STRVAR(__Pyx_async_aclose_doc,
  "aclose() -> raise GeneratorExit inside generator.");
  PyDoc_STRVAR(__Pyx_async_asend_doc,
  "asend(v) -> send 'v' in generator.");
  PyDoc_STRVAR(__Pyx_async_athrow_doc,
  "athrow(typ[,val[,tb]]) -> raise exception in generator.");
  PyDoc_STRVAR(__Pyx_async_aiter_doc,
  "__aiter__(v) -> return an asynchronous iterator.");
  PyDoc_STRVAR(__Pyx_async_anext_doc,
  "__anext__(v) -> continue asynchronous iteration and return the next element.");
  static PyMethodDef __Pyx_async_gen_methods[] = {
      {"asend", (PyCFunction)__Pyx_async_gen_asend, METH_O, __Pyx_async_asend_doc},
      {"athrow",(PyCFunction)__Pyx_async_gen_athrow, METH_VARARGS, __Pyx_async_athrow_doc},
      {"aclose", (PyCFunction)__Pyx_async_gen_aclose, METH_NOARGS, __Pyx_async_aclose_doc},
      {"__aiter__", (PyCFunction)__Pyx_async_gen_self_method, METH_NOARGS, __Pyx_async_aiter_doc},
      {"__anext__", (PyCFunction)__Pyx_async_gen_anext_method, METH_NOARGS, __Pyx_async_anext_doc},
      {"__reduce_ex__", (PyCFunction) __Pyx_Coroutine_fail_reduce_ex, METH_O, 0},
      {"__reduce__", (PyCFunction) __Pyx_Coroutine_fail_reduce_ex, METH_NOARGS, 0},
      {0, 0, 0, 0}
  };
  static PyType_Slot __pyx_AsyncGenType_slots[] = {
      {Py_tp_dealloc, (void *)__Pyx_Coroutine_dealloc},
      {Py_am_aiter, (void *)PyObject_SelfIter},
      {Py_am_anext, (void *)__Pyx_async_gen_anext},
      {Py_tp_repr, (void *)__Pyx_async_gen_repr},
      {Py_tp_traverse, (void *)__Pyx_async_gen_traverse},
      {Py_tp_methods, (void *)__Pyx_async_gen_methods},
      {Py_tp_members, (void *)__Pyx_async_gen_memberlist},
      {Py_tp_getset, (void *)__Pyx_async_gen_getsetlist},
  #if CYTHON_USE_TP_FINALIZE
      {Py_tp_finalize, (void *)__Pyx_Coroutine_del},
  #endif
      {0, 0},
  };
  static PyType_Spec __pyx_AsyncGenType_spec = {
      __PYX_TYPE_MODULE_PREFIX "async_generator",
      sizeof(__pyx_PyAsyncGenObject),
      0,
  #if PY_VERSION_HEX >= 0x030C0000 && !CYTHON_COMPILING_IN_LIMITED_API
      Py_TPFLAGS_MANAGED_WEAKREF |
  #endif
      Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION |
      Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
      __pyx_AsyncGenType_slots
  };
  static int
  __Pyx_PyAsyncGen_ClearFreeLists(void)
  {
      #if CYTHON_USE_FREELISTS
      int ret = __pyx_mstate_global->__Pyx_ag_value_freelist_free + __pyx_mstate_global->__Pyx_ag_asend_freelist_free;
      while (__pyx_mstate_global->__Pyx_ag_value_freelist_free) {
          __pyx__PyAsyncGenWrappedValue *o;
          o = __pyx_mstate_global->__Pyx_ag_value_freelist[--__pyx_mstate_global->__Pyx_ag_value_freelist_free];
          assert(__pyx__PyAsyncGenWrappedValue_CheckExact((PyObject*)o));
          __Pyx_PyHeapTypeObject_GC_Del(o);
      }
      while (__pyx_mstate_global->__Pyx_ag_asend_freelist_free) {
          __pyx_PyAsyncGenASend *o;
          o = __pyx_mstate_global->__Pyx_ag_asend_freelist[--__pyx_mstate_global->__Pyx_ag_asend_freelist_free];
          assert(__Pyx_IS_TYPE((PyObject*)o, __pyx_mstate_global->__pyx__PyAsyncGenASendType));
          __Pyx_PyHeapTypeObject_GC_Del(o);
      }
      return ret;
      #else
      return 0;
      #endif
  }
  static void
  __Pyx_PyAsyncGen_Fini(void)
  {
      __Pyx_PyAsyncGen_ClearFreeLists();
  }
  static PyObject *
  __Pyx_async_gen_unwrap_value(__pyx_PyAsyncGenObject *gen, PyObject *result, int iternext)
  {
      if (result == NULL) {
          PyObject *exc_type = PyErr_Occurred();
          if (!exc_type) {
              PyErr_SetNone(PyExc_StopAsyncIteration);
              gen->ag_closed = 1;
          } else if (__Pyx_PyErr_GivenExceptionMatches2(exc_type, PyExc_StopAsyncIteration, PyExc_GeneratorExit)) {
              gen->ag_closed = 1;
          }
          gen->ag_running_async = 0;
          return NULL;
      }
      if (__pyx__PyAsyncGenWrappedValue_CheckExact(result)) {
          __Pyx_ReturnWithStopIteration(((__pyx__PyAsyncGenWrappedValue*)result)->agw_val, 0, iternext);
          Py_DECREF(result);
          gen->ag_running_async = 0;
          return NULL;
      }
      return result;
  }
  static void
  __Pyx_async_gen_asend_dealloc(__pyx_PyAsyncGenASend *o)
  {
      PyObject_GC_UnTrack((PyObject *)o);
      Py_CLEAR(o->ags_gen);
      Py_CLEAR(o->ags_sendval);
      #if CYTHON_USE_FREELISTS
      if (likely(__pyx_mstate_global->__Pyx_ag_asend_freelist_free < _PyAsyncGen_MAXFREELIST)) {
          assert(__pyx_PyAsyncGenASend_CheckExact((PyObject*)o));
          __pyx_mstate_global->__Pyx_ag_asend_freelist[__pyx_mstate_global->__Pyx_ag_asend_freelist_free++] = o;
      } else
      #endif
      {
          __Pyx_PyHeapTypeObject_GC_Del(o);
      }
  }
  static int
  __Pyx_async_gen_asend_traverse(__pyx_PyAsyncGenASend *o, visitproc visit, void *arg)
  {
      {
          int e = __Pyx_call_type_traverse((PyObject*)o, 1, visit, arg);
          if (e) return e;
      }
      Py_VISIT(o->ags_gen);
      Py_VISIT(o->ags_sendval);
      return 0;
  }
  static PyObject *
  __Pyx_async_gen_asend_send_impl(PyObject *g, PyObject *arg, int iternext)
  {
      __pyx_PyAsyncGenASend *o = (__pyx_PyAsyncGenASend*) g;
      PyObject *retval;
      if (unlikely(o->ags_state == __PYX_AWAITABLE_STATE_CLOSED)) {
          PyErr_SetString(PyExc_RuntimeError, __Pyx_ASYNC_GEN_CANNOT_REUSE_SEND_MSG);
          return NULL;
      }
      if (o->ags_state == __PYX_AWAITABLE_STATE_INIT) {
          if (unlikely(o->ags_gen->ag_running_async)) {
              PyErr_SetString(
                  PyExc_RuntimeError,
                  "anext(): asynchronous generator is already running");
              return NULL;
          }
          if (arg == NULL || arg == Py_None) {
              arg = o->ags_sendval ? o->ags_sendval : Py_None;
          }
          o->ags_state = __PYX_AWAITABLE_STATE_ITER;
      }
      o->ags_gen->ag_running_async = 1;
      retval = __Pyx_Coroutine_Send((PyObject*)o->ags_gen, arg);
      retval = __Pyx_async_gen_unwrap_value(o->ags_gen, retval, iternext);
      if (!retval) {
          o->ags_state = __PYX_AWAITABLE_STATE_CLOSED;
      }
      return retval;
  }
  static PyObject *
  __Pyx_async_gen_asend_send(PyObject *g, PyObject *arg)
  {
      return __Pyx_async_gen_asend_send_impl(g, arg, 0);
  }
  static CYTHON_INLINE PyObject *
  __Pyx_async_gen_asend_iternext(PyObject *o)
  {
      return __Pyx_async_gen_asend_send_impl(o, Py_None, 1);
  }
  static PyObject *
  __Pyx_async_gen_asend_throw(__pyx_PyAsyncGenASend *o, PyObject *args)
  {
      PyObject *result;
      if (unlikely(o->ags_state == __PYX_AWAITABLE_STATE_CLOSED)) {
          PyErr_SetString(PyExc_RuntimeError, __Pyx_ASYNC_GEN_CANNOT_REUSE_SEND_MSG);
          return NULL;
      }
      result = __Pyx_Coroutine_Throw((PyObject*)o->ags_gen, args);
      result = __Pyx_async_gen_unwrap_value(o->ags_gen, result, 0);
      if (result == NULL) {
          o->ags_state = __PYX_AWAITABLE_STATE_CLOSED;
      }
      return result;
  }
  static PyObject *
  __Pyx_async_gen_asend_close(PyObject *g, PyObject *args)
  {
      __pyx_PyAsyncGenASend *o = (__pyx_PyAsyncGenASend*) g;
      CYTHON_UNUSED_VAR(args);
      o->ags_state = __PYX_AWAITABLE_STATE_CLOSED;
      Py_RETURN_NONE;
  }
  static PyMethodDef __Pyx_async_gen_asend_methods[] = {
      {"send", (PyCFunction)__Pyx_async_gen_asend_send, METH_O, __Pyx_async_gen_send_doc},
      {"throw", (PyCFunction)__Pyx_async_gen_asend_throw, METH_VARARGS, __Pyx_async_gen_throw_doc},
      {"close", (PyCFunction)__Pyx_async_gen_asend_close, METH_NOARGS, __Pyx_async_gen_close_doc},
      {"__await__", (PyCFunction)__Pyx_async_gen_self_method, METH_NOARGS, __Pyx_async_gen_await_doc},
      {0, 0, 0, 0}
  };
  static PyType_Slot __pyx__PyAsyncGenASendType_slots[] = {
      {Py_tp_dealloc, (void *)__Pyx_async_gen_asend_dealloc},
      {Py_am_await, (void *)PyObject_SelfIter},
      {Py_tp_traverse, (void *)__Pyx_async_gen_asend_traverse},
      {Py_tp_methods, (void *)__Pyx_async_gen_asend_methods},
      {Py_tp_iter, (void *)PyObject_SelfIter},
      {Py_tp_iternext, (void *)__Pyx_async_gen_asend_iternext},
      {0, 0},
  };
  static PyType_Spec __pyx__PyAsyncGenASendType_spec = {
      __PYX_TYPE_MODULE_PREFIX "async_generator_asend",
      sizeof(__pyx_PyAsyncGenASend),
      0,
      Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION |
      Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
      __pyx__PyAsyncGenASendType_slots
  };
  static PyObject *
  __Pyx_async_gen_asend_new(__pyx_PyAsyncGenObject *gen, PyObject *sendval)
  {
      __pyx_PyAsyncGenASend *o;
      #if CYTHON_USE_FREELISTS
      if (likely(__pyx_mstate_global->__Pyx_ag_asend_freelist_free)) {
          __pyx_mstate_global->__Pyx_ag_asend_freelist_free--;
          o = __pyx_mstate_global->__Pyx_ag_asend_freelist[__pyx_mstate_global->__Pyx_ag_asend_freelist_free];
          #if CYTHON_COMPILING_IN_LIMITED_API
          Py_DECREF(Py_TYPE((PyObject*)o)); // PyObject_Init resets and increfs the type
          (void) PyObject_Init((PyObject *)o, __pyx_mstate_global->__pyx__PyAsyncGenASendType);
          #else
          _Py_NewReference((PyObject *)o);
          #endif
      } else
      #endif
      {
          o = PyObject_GC_New(__pyx_PyAsyncGenASend, __pyx_mstate_global->__pyx__PyAsyncGenASendType);
          if (unlikely(o == NULL)) {
              return NULL;
          }
      }
      Py_INCREF((PyObject*)gen);
      o->ags_gen = gen;
      Py_XINCREF(sendval);
      o->ags_sendval = sendval;
      o->ags_state = __PYX_AWAITABLE_STATE_INIT;
      PyObject_GC_Track((PyObject*)o);
      return (PyObject*)o;
  }
  static void
  __Pyx_async_gen_wrapped_val_dealloc(__pyx__PyAsyncGenWrappedValue *o)
  {
      PyObject_GC_UnTrack((PyObject *)o);
      Py_CLEAR(o->agw_val);
      #if CYTHON_USE_FREELISTS
      if (likely(__pyx_mstate_global->__Pyx_ag_value_freelist_free < _PyAsyncGen_MAXFREELIST)) {
          assert(__pyx__PyAsyncGenWrappedValue_CheckExact((PyObject*)o));
          __pyx_mstate_global->__Pyx_ag_value_freelist[__pyx_mstate_global->__Pyx_ag_value_freelist_free++] = o;
      } else
      #endif
      {
          __Pyx_PyHeapTypeObject_GC_Del(o);
      }
  }
  static int
  __Pyx_async_gen_wrapped_val_traverse(__pyx__PyAsyncGenWrappedValue *o,
                                       visitproc visit, void *arg)
  {
      {
          int e = __Pyx_call_type_traverse((PyObject*)o, 1, visit, arg);
          if (e) return e;
      }
      Py_VISIT(o->agw_val);
      return 0;
  }
  static PyType_Slot __pyx__PyAsyncGenWrappedValueType_slots[] = {
      {Py_tp_dealloc, (void *)__Pyx_async_gen_wrapped_val_dealloc},
      {Py_tp_traverse, (void *)__Pyx_async_gen_wrapped_val_traverse},
      {0, 0},
  };
  static PyType_Spec __pyx__PyAsyncGenWrappedValueType_spec = {
      __PYX_TYPE_MODULE_PREFIX "async_generator_wrapped_value",
      sizeof(__pyx__PyAsyncGenWrappedValue),
      0,
      Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION |
      Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
      __pyx__PyAsyncGenWrappedValueType_slots
  };
  static PyObject *
  __Pyx__PyAsyncGenValueWrapperNew(PyObject *val)
  {
      __pyx__PyAsyncGenWrappedValue *o;
      assert(val);
      #if CYTHON_USE_FREELISTS
      if (likely(__pyx_mstate_global->__Pyx_ag_value_freelist_free)) {
          __pyx_mstate_global->__Pyx_ag_value_freelist_free--;
          o = __pyx_mstate_global->__Pyx_ag_value_freelist[__pyx_mstate_global->__Pyx_ag_value_freelist_free];
          assert(__pyx__PyAsyncGenWrappedValue_CheckExact((PyObject*)o));
          #if CYTHON_COMPILING_IN_LIMITED_API
          Py_DECREF(Py_TYPE((PyObject*)o)); // PyObject_Init resets and increfs the type
          (void) PyObject_Init((PyObject*)o, __pyx_mstate_global->__pyx__PyAsyncGenWrappedValueType);
          #else
          _Py_NewReference((PyObject*)o);
          #endif
      } else
      #endif
      {
          o = PyObject_GC_New(__pyx__PyAsyncGenWrappedValue, __pyx_mstate_global->__pyx__PyAsyncGenWrappedValueType);
          if (unlikely(!o)) {
              Py_DECREF(val);
              return NULL;
          }
      }
      o->agw_val = val;
      PyObject_GC_Track((PyObject*)o);
      return (PyObject*)o;
  }
  static void
  __Pyx_async_gen_athrow_dealloc(__pyx_PyAsyncGenAThrow *o)
  {
      PyObject_GC_UnTrack((PyObject *)o);
      Py_CLEAR(o->agt_gen);
      Py_CLEAR(o->agt_args);
      __Pyx_PyHeapTypeObject_GC_Del(o);
  }
  static int
  __Pyx_async_gen_athrow_traverse(__pyx_PyAsyncGenAThrow *o, visitproc visit, void *arg)
  {
      {
          int e = __Pyx_call_type_traverse((PyObject*)o, 1, visit, arg);
          if (e) return e;
      }
      Py_VISIT(o->agt_gen);
      Py_VISIT(o->agt_args);
      return 0;
  }
  static PyObject *
  __Pyx_async_gen_athrow_send_impl(__pyx_PyAsyncGenAThrow *o, PyObject *arg, int iternext)
  {
      __pyx_CoroutineObject *gen = (__pyx_CoroutineObject*)o->agt_gen;
      PyObject *retval, *exc_type;
      if (unlikely(o->agt_state == __PYX_AWAITABLE_STATE_CLOSED)) {
          PyErr_SetString(PyExc_RuntimeError, __Pyx_ASYNC_GEN_CANNOT_REUSE_CLOSE_MSG);
          return NULL;
      }
      if (unlikely(gen->resume_label == -1)) {
          o->agt_state = __PYX_AWAITABLE_STATE_CLOSED;
          PyErr_SetNone(PyExc_StopIteration);
          return NULL;
      }
      if (o->agt_state == __PYX_AWAITABLE_STATE_INIT) {
          if (unlikely(o->agt_gen->ag_running_async)) {
              o->agt_state = __PYX_AWAITABLE_STATE_CLOSED;
              if (o->agt_args == NULL) {
                  PyErr_SetString(
                      PyExc_RuntimeError,
                      "aclose(): asynchronous generator is already running");
              } else {
                  PyErr_SetString(
                      PyExc_RuntimeError,
                      "athrow(): asynchronous generator is already running");
              }
              return NULL;
          }
          if (unlikely(o->agt_gen->ag_closed)) {
              o->agt_state = __PYX_AWAITABLE_STATE_CLOSED;
              PyErr_SetNone(PyExc_StopAsyncIteration);
              return NULL;
          }
          if (unlikely(arg != Py_None)) {
              PyErr_SetString(PyExc_RuntimeError, __Pyx_NON_INIT_CORO_MSG);
              return NULL;
          }
          o->agt_state = __PYX_AWAITABLE_STATE_ITER;
          o->agt_gen->ag_running_async = 1;
          if (o->agt_args == NULL) {
              o->agt_gen->ag_closed = 1;
              retval = __Pyx__Coroutine_Throw((PyObject*)gen,
                  PyExc_GeneratorExit, NULL, NULL, NULL, 0);
              if (retval && __pyx__PyAsyncGenWrappedValue_CheckExact(retval)) {
                  Py_DECREF(retval);
                  goto yield_close;
              }
          } else {
              PyObject *typ;
              PyObject *tb = NULL;
              PyObject *val = NULL;
              if (unlikely(!PyArg_UnpackTuple(o->agt_args, "athrow", 1, 3, &typ, &val, &tb))) {
                  return NULL;
              }
              retval = __Pyx__Coroutine_Throw((PyObject*)gen,
                  typ, val, tb, o->agt_args, 0);
              retval = __Pyx_async_gen_unwrap_value(o->agt_gen, retval, iternext);
          }
          if (retval == NULL) {
              goto check_error;
          }
          return retval;
      }
      assert (o->agt_state == __PYX_AWAITABLE_STATE_ITER);
      retval = __Pyx_Coroutine_Send((PyObject *)gen, arg);
      if (o->agt_args) {
          return __Pyx_async_gen_unwrap_value(o->agt_gen, retval, iternext);
      } else {
          if (retval) {
              if (unlikely(__pyx__PyAsyncGenWrappedValue_CheckExact(retval))) {
                  Py_DECREF(retval);
                  goto yield_close;
              }
              else {
                  return retval;
              }
          }
          else {
              goto check_error;
          }
      }
  yield_close:
      o->agt_gen->ag_running_async = 0;
      o->agt_state = __PYX_AWAITABLE_STATE_CLOSED;
      PyErr_SetString(
          PyExc_RuntimeError, __Pyx_ASYNC_GEN_IGNORED_EXIT_MSG);
      return NULL;
  check_error:
      o->agt_gen->ag_running_async = 0;
      o->agt_state = __PYX_AWAITABLE_STATE_CLOSED;
      exc_type = PyErr_Occurred();
      if (__Pyx_PyErr_GivenExceptionMatches2(exc_type, PyExc_StopAsyncIteration, PyExc_GeneratorExit)) {
          if (o->agt_args == NULL) {
              PyErr_Clear();
              PyErr_SetNone(PyExc_StopIteration);
          }
      }
      return NULL;
  }
  static PyObject *
  __Pyx_async_gen_athrow_send(__pyx_PyAsyncGenAThrow *o, PyObject *arg)
  {
      return __Pyx_async_gen_athrow_send_impl(o, arg, 0);
  }
  static PyObject *
  __Pyx_async_gen_athrow_throw(__pyx_PyAsyncGenAThrow *o, PyObject *args)
  {
      PyObject *retval;
      if (unlikely(o->agt_state == __PYX_AWAITABLE_STATE_CLOSED)) {
          PyErr_SetString(PyExc_RuntimeError, __Pyx_ASYNC_GEN_CANNOT_REUSE_CLOSE_MSG);
          return NULL;
      }
      retval = __Pyx_Coroutine_Throw((PyObject*)o->agt_gen, args);
      if (o->agt_args) {
          return __Pyx_async_gen_unwrap_value(o->agt_gen, retval, 0);
      } else {
          PyObject *exc_type;
          if (unlikely(retval && __pyx__PyAsyncGenWrappedValue_CheckExact(retval))) {
              o->agt_gen->ag_running_async = 0;
              o->agt_state = __PYX_AWAITABLE_STATE_CLOSED;
              Py_DECREF(retval);
              PyErr_SetString(PyExc_RuntimeError, __Pyx_ASYNC_GEN_IGNORED_EXIT_MSG);
              return NULL;
          }
          exc_type = PyErr_Occurred();
          if (__Pyx_PyErr_GivenExceptionMatches2(exc_type, PyExc_StopAsyncIteration, PyExc_GeneratorExit)) {
              PyErr_Clear();
              PyErr_SetNone(PyExc_StopIteration);
          }
          return retval;
      }
  }
  static PyObject *
  __Pyx_async_gen_athrow_iternext(__pyx_PyAsyncGenAThrow *o)
  {
      return __Pyx_async_gen_athrow_send_impl(o, Py_None, 1);
  }
  static PyObject *
  __Pyx_async_gen_athrow_close(PyObject *g, PyObject *args)
  {
      __pyx_PyAsyncGenAThrow *o = (__pyx_PyAsyncGenAThrow*) g;
      CYTHON_UNUSED_VAR(args);
      o->agt_state = __PYX_AWAITABLE_STATE_CLOSED;
      Py_RETURN_NONE;
  }
  static PyMethodDef __Pyx_async_gen_athrow_methods[] = {
      {"send", (PyCFunction)__Pyx_async_gen_athrow_send, METH_O, __Pyx_async_gen_send_doc},
      {"throw", (PyCFunction)__Pyx_async_gen_athrow_throw, METH_VARARGS, __Pyx_async_gen_throw_doc},
      {"close", (PyCFunction)__Pyx_async_gen_athrow_close, METH_NOARGS, __Pyx_async_gen_close_doc},
      {"__await__", (PyCFunction)__Pyx_async_gen_self_method, METH_NOARGS, __Pyx_async_gen_await_doc},
      {0, 0, 0, 0}
  };
  static PyType_Slot __pyx__PyAsyncGenAThrowType_slots[] = {
      {Py_tp_dealloc, (void *)__Pyx_async_gen_athrow_dealloc},
      {Py_am_await, (void *)PyObject_SelfIter},
      {Py_tp_traverse, (void *)__Pyx_async_gen_athrow_traverse},
      {Py_tp_iter, (void *)PyObject_SelfIter},
      {Py_tp_iternext, (void *)__Pyx_async_gen_athrow_iternext},
      {Py_tp_methods, (void *)__Pyx_async_gen_athrow_methods},
      {Py_tp_getattro, (void *)PyObject_GenericGetAttr},
      {0, 0},
  };
  static PyType_Spec __pyx__PyAsyncGenAThrowType_spec = {
      __PYX_TYPE_MODULE_PREFIX "async_generator_athrow",
      sizeof(__pyx_PyAsyncGenAThrow),
      0,
      Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION |
      Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
      __pyx__PyAsyncGenAThrowType_slots
  };
  static PyObject *
  __Pyx_async_gen_athrow_new(__pyx_PyAsyncGenObject *gen, PyObject *args)
  {
      __pyx_PyAsyncGenAThrow *o;
      o = PyObject_GC_New(__pyx_PyAsyncGenAThrow, __pyx_mstate_global->__pyx__PyAsyncGenAThrowType);
      if (unlikely(o == NULL)) {
          return NULL;
      }
      o->agt_gen = gen;
      o->agt_args = args;
      o->agt_state = __PYX_AWAITABLE_STATE_INIT;
      Py_INCREF((PyObject*)gen);
      Py_XINCREF(args);
      PyObject_GC_Track((PyObject*)o);
      return (PyObject*)o;
  }
  static int __pyx_AsyncGen_init(PyObject *module) {
      __pyx_mstatetype *mstate = __Pyx_PyModule_GetState(module);
      mstate->__pyx_AsyncGenType = __Pyx_FetchCommonTypeFromSpec(
          mstate->__pyx_CommonTypesMetaclassType, module, &__pyx_AsyncGenType_spec, NULL);
      if (unlikely(!mstate->__pyx_AsyncGenType))
          return -1;
      mstate->__pyx__PyAsyncGenAThrowType = __Pyx_FetchCommonTypeFromSpec(NULL, module, &__pyx__PyAsyncGenAThrowType_spec, NULL);
      if (unlikely(!mstate->__pyx__PyAsyncGenAThrowType))
          return -1;
      mstate->__pyx__PyAsyncGenWrappedValueType = __Pyx_FetchCommonTypeFromSpec(NULL, module, &__pyx__PyAsyncGenWrappedValueType_spec, NULL);
      if (unlikely(!mstate->__pyx__PyAsyncGenWrappedValueType))
          return -1;
      mstate->__pyx__PyAsyncGenASendType = __Pyx_FetchCommonTypeFromSpec(NULL, module, &__pyx__PyAsyncGenASendType_spec, NULL);
      if (unlikely(!mstate->__pyx__PyAsyncGenASendType))
          return -1;
      return 0;
  }
  
/* AsyncGen */
  
  
/* CheckBinaryVersion */
  static int __Pyx_check_binary_version(unsigned long ct_version, unsigned long rt_version, int allow_newer) {
      const unsigned long MAJOR_MINOR = 0xFFFF0000UL;
      if ((rt_version & MAJOR_MINOR) == (ct_version & MAJOR_MINOR))
          return 0;
      if (likely(allow_newer && (rt_version & MAJOR_MINOR) > (ct_version & MAJOR_MINOR)))
          return 1;
      {
          char message[200];
          PyOS_snprintf(message, sizeof(message),
                        "compile time Python version %d.%d "
                        "of module '%.100s' "
                        "%s "
                        "runtime version %d.%d",
                         (int) (ct_version >> 24), (int) ((ct_version >> 16) & 0xFF),
                         __Pyx_MODULE_NAME,
                         (allow_newer) ? "was newer than" : "does not match",
                         (int) (rt_version >> 24), (int) ((rt_version >> 16) & 0xFF)
         );
          return PyErr_WarnEx(NULL, message, 1);
      }
  }
  
/* NewCodeObj */
  #if CYTHON_COMPILING_IN_LIMITED_API
      static PyObject* __Pyx__PyCode_New(int a, int p, int k, int l, int s, int f,
                                         PyObject *code, PyObject *c, PyObject* n, PyObject *v,
                                         PyObject *fv, PyObject *cell, PyObject* fn,
                                         PyObject *name, int fline, PyObject *lnos) {
          PyObject *exception_table = NULL;
          PyObject *types_module=NULL, *code_type=NULL, *result=NULL;
          #if __PYX_LIMITED_VERSION_HEX < 0x030b0000
          PyObject *version_info;
          PyObject *py_minor_version = NULL;
          #endif
          long minor_version = 0;
          PyObject *type, *value, *traceback;
          PyErr_Fetch(&type, &value, &traceback);
          #if __PYX_LIMITED_VERSION_HEX >= 0x030b0000
          minor_version = 11;
          #else
          if (!(version_info = PySys_GetObject("version_info"))) goto end;
          if (!(py_minor_version = PySequence_GetItem(version_info, 1))) goto end;
          minor_version = PyLong_AsLong(py_minor_version);
          Py_DECREF(py_minor_version);
          if (minor_version == -1 && PyErr_Occurred()) goto end;
          #endif
          if (!(types_module = PyImport_ImportModule("types"))) goto end;
          if (!(code_type = PyObject_GetAttrString(types_module, "CodeType"))) goto end;
          if (minor_version <= 7) {
              (void)p;
              result = PyObject_CallFunction(code_type, "iiiiiOOOOOOiOOO", a, k, l, s, f, code,
                            c, n, v, fn, name, fline, lnos, fv, cell);
          } else if (minor_version <= 10) {
              result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOiOOO", a,p, k, l, s, f, code,
                            c, n, v, fn, name, fline, lnos, fv, cell);
          } else {
              if (!(exception_table = PyBytes_FromStringAndSize(NULL, 0))) goto end;
              result = PyObject_CallFunction(code_type, "iiiiiiOOOOOOOiOOOO", a,p, k, l, s, f, code,
                            c, n, v, fn, name, name, fline, lnos, exception_table, fv, cell);
          }
      end:
          Py_XDECREF(code_type);
          Py_XDECREF(exception_table);
          Py_XDECREF(types_module);
          if (type) {
              PyErr_Restore(type, value, traceback);
          }
          return result;
      }
  #elif PY_VERSION_HEX >= 0x030B0000
    static PyCodeObject* __Pyx__PyCode_New(int a, int p, int k, int l, int s, int f,
                                           PyObject *code, PyObject *c, PyObject* n, PyObject *v,
                                           PyObject *fv, PyObject *cell, PyObject* fn,
                                           PyObject *name, int fline, PyObject *lnos) {
      PyCodeObject *result;
      result =
        #if PY_VERSION_HEX >= 0x030C0000
          PyUnstable_Code_NewWithPosOnlyArgs
        #else
          PyCode_NewWithPosOnlyArgs
        #endif
          (a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, name, fline, lnos, __pyx_mstate_global->__pyx_empty_bytes);
      #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030c00A1
      if (likely(result))
          result->_co_firsttraceable = 0;
      #endif
      return result;
    }
  #elif !CYTHON_COMPILING_IN_PYPY
    #define __Pyx__PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
            PyCode_NewWithPosOnlyArgs(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #else
    #define __Pyx__PyCode_New(a, p, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
            PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
  #endif
  static PyObject* __Pyx_PyCode_New(
          const __Pyx_PyCode_New_function_description descr,
          PyObject * const *varnames,
          PyObject *filename,
          PyObject *funcname,
          PyObject *line_table,
          PyObject *tuple_dedup_map
  ) {
      PyObject *code_obj = NULL, *varnames_tuple_dedup = NULL, *code_bytes = NULL;
      Py_ssize_t var_count = (Py_ssize_t) descr.nlocals;
      PyObject *varnames_tuple = PyTuple_New(var_count);
      if (unlikely(!varnames_tuple)) return NULL;
      for (Py_ssize_t i=0; i < var_count; i++) {
          Py_INCREF(varnames[i]);
          if (__Pyx_PyTuple_SET_ITEM(varnames_tuple, i, varnames[i]) != (0)) goto done;
      }
      #if CYTHON_COMPILING_IN_LIMITED_API
      varnames_tuple_dedup = PyDict_GetItem(tuple_dedup_map, varnames_tuple);
      if (!varnames_tuple_dedup) {
          if (unlikely(PyDict_SetItem(tuple_dedup_map, varnames_tuple, varnames_tuple) < 0)) goto done;
          varnames_tuple_dedup = varnames_tuple;
      }
      #else
      varnames_tuple_dedup = PyDict_SetDefault(tuple_dedup_map, varnames_tuple, varnames_tuple);
      if (unlikely(!varnames_tuple_dedup)) goto done;
      #endif
      #if CYTHON_AVOID_BORROWED_REFS
      Py_INCREF(varnames_tuple_dedup);
      #endif
      if (__PYX_LIMITED_VERSION_HEX >= (0x030b0000) && line_table != NULL && !CYTHON_COMPILING_IN_GRAAL) {
          Py_ssize_t line_table_length = __Pyx_PyBytes_GET_SIZE(line_table);
          #if !CYTHON_ASSUME_SAFE_SIZE
          if (unlikely(line_table_length == -1)) goto done;
          #endif
          Py_ssize_t code_len = (line_table_length * 2 + 4) & ~3LL;
          code_bytes = PyBytes_FromStringAndSize(NULL, code_len);
          if (unlikely(!code_bytes)) goto done;
          char* c_code_bytes = PyBytes_AsString(code_bytes);
          if (unlikely(!c_code_bytes)) goto done;
          memset(c_code_bytes, 0, (size_t) code_len);
      }
      code_obj = (PyObject*) __Pyx__PyCode_New(
          (int) descr.argcount,
          (int) descr.num_posonly_args,
          (int) descr.num_kwonly_args,
          (int) descr.nlocals,
          0,
          (int) descr.flags,
          code_bytes ? code_bytes : __pyx_mstate_global->__pyx_empty_bytes,
          __pyx_mstate_global->__pyx_empty_tuple,
          __pyx_mstate_global->__pyx_empty_tuple,
          varnames_tuple_dedup,
          __pyx_mstate_global->__pyx_empty_tuple,
          __pyx_mstate_global->__pyx_empty_tuple,
          filename,
          funcname,
          (int) descr.first_line,
          (__PYX_LIMITED_VERSION_HEX >= (0x030b0000) && line_table) ? line_table : __pyx_mstate_global->__pyx_empty_bytes
      );
  done:
      Py_XDECREF(code_bytes);
      #if CYTHON_AVOID_BORROWED_REFS
      Py_XDECREF(varnames_tuple_dedup);
      #endif
      Py_DECREF(varnames_tuple);
      return code_obj;
  }
  
/* DecompressString */
  static PyObject *__Pyx_DecompressString(const char *s, Py_ssize_t length, int algo) {
      PyObject *module = NULL, *decompress, *compressed_bytes, *decompressed;
      const char* module_name = algo == 3 ? "compression.zstd" : algo == 2 ? "bz2" : "zlib";
      PyObject *methodname = PyUnicode_FromString("decompress");
      if (unlikely(!methodname)) return NULL;
      #if __PYX_LIMITED_VERSION_HEX >= 0x030e0000
      if (algo == 3) {
          PyObject *fromlist = Py_BuildValue("[O]", methodname);
          if (unlikely(!fromlist)) goto bad;
          module = PyImport_ImportModuleLevel("compression.zstd", NULL, NULL, fromlist, 0);
          Py_DECREF(fromlist);
      } else
      #endif
          module = PyImport_ImportModule(module_name);
      if (unlikely(!module)) goto import_failed;
      decompress = PyObject_GetAttr(module, methodname);
      if (unlikely(!decompress)) goto import_failed;
      {
          #ifdef __cplusplus
              char *memview_bytes = const_cast<char*>(s);
          #else
              #if defined(__clang__)
                #pragma clang diagnostic push
                #pragma clang diagnostic ignored "-Wcast-qual"
              #elif !defined(__INTEL_COMPILER) && defined(__GNUC__)
                #pragma GCC diagnostic push
                #pragma GCC diagnostic ignored "-Wcast-qual"
              #endif
              char *memview_bytes = (char*) s;
              #if defined(__clang__)
                #pragma clang diagnostic pop
              #elif !defined(__INTEL_COMPILER) && defined(__GNUC__)
                #pragma GCC diagnostic pop
              #endif
          #endif
          #if CYTHON_COMPILING_IN_LIMITED_API && !defined(PyBUF_READ)
          int memview_flags = 0x100;
          #else
          int memview_flags = PyBUF_READ;
          #endif
          compressed_bytes = PyMemoryView_FromMemory(memview_bytes, length, memview_flags);
      }
      if (unlikely(!compressed_bytes)) {
          Py_DECREF(decompress);
          goto bad;
      }
      decompressed = PyObject_CallFunctionObjArgs(decompress, compressed_bytes, NULL);
      Py_DECREF(compressed_bytes);
      Py_DECREF(decompress);
      Py_DECREF(module);
      Py_DECREF(methodname);
      return decompressed;
  import_failed:
      PyErr_Format(PyExc_ImportError,
          "Failed to import '%.20s.decompress' - cannot initialise module strings. "
          "String compression was configured with the C macro 'CYTHON_COMPRESS_STRINGS=%d'.",
          module_name, algo);
  bad:
      Py_XDECREF(module);
      Py_DECREF(methodname);
      return NULL;
  }
  
#include <string.h>
static CYTHON_INLINE Py_ssize_t __Pyx_ssize_strlen(const char *s) {
    size_t len = strlen(s);
    if (unlikely(len > (size_t) PY_SSIZE_T_MAX)) {
        PyErr_SetString(PyExc_OverflowError, "byte string is too long");
        return -1;
    }
    return (Py_ssize_t) len;
}
static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
    Py_ssize_t len = __Pyx_ssize_strlen(c_str);
    if (unlikely(len < 0)) return NULL;
    return __Pyx_PyUnicode_FromStringAndSize(c_str, len);
}
static CYTHON_INLINE PyObject* __Pyx_PyByteArray_FromString(const char* c_str) {
    Py_ssize_t len = __Pyx_ssize_strlen(c_str);
    if (unlikely(len < 0)) return NULL;
    return PyByteArray_FromStringAndSize(c_str, len);
}
static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
    Py_ssize_t ignore;
    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
}
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_UTF8
static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
    if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
#if CYTHON_COMPILING_IN_LIMITED_API
    {
        const char* result;
        Py_ssize_t unicode_length;
        CYTHON_MAYBE_UNUSED_VAR(unicode_length); // only for __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        #if __PYX_LIMITED_VERSION_HEX < 0x030A0000
        if (unlikely(PyArg_Parse(o, "s#", &result, length) < 0)) return NULL;
        #else
        result = PyUnicode_AsUTF8AndSize(o, length);
        #endif
        #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
        unicode_length = PyUnicode_GetLength(o);
        if (unlikely(unicode_length < 0)) return NULL;
        if (unlikely(unicode_length != *length)) {
            PyUnicode_AsASCIIString(o);
            return NULL;
        }
        #endif
        return result;
    }
#else
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
    if (likely(PyUnicode_IS_ASCII(o))) {
        *length = PyUnicode_GET_LENGTH(o);
        return PyUnicode_AsUTF8(o);
    } else {
        PyUnicode_AsASCIIString(o);
        return NULL;
    }
#else
    return PyUnicode_AsUTF8AndSize(o, length);
#endif
#endif
}
#endif
static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_UTF8
    if (PyUnicode_Check(o)) {
        return __Pyx_PyUnicode_AsStringAndSize(o, length);
    } else
#endif
    if (PyByteArray_Check(o)) {
#if (CYTHON_ASSUME_SAFE_SIZE && CYTHON_ASSUME_SAFE_MACROS) || (CYTHON_COMPILING_IN_PYPY && (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)))
        *length = PyByteArray_GET_SIZE(o);
        return PyByteArray_AS_STRING(o);
#else
        *length = PyByteArray_Size(o);
        if (*length == -1) return NULL;
        return PyByteArray_AsString(o);
#endif
    } else
    {
        char* result;
        int r = PyBytes_AsStringAndSize(o, &result, length);
        if (unlikely(r < 0)) {
            return NULL;
        } else {
            return result;
        }
    }
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
   int is_true = x == Py_True;
   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
   else return PyObject_IsTrue(x);
}
static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
    int retval;
    if (unlikely(!x)) return -1;
    retval = __Pyx_PyObject_IsTrue(x);
    Py_DECREF(x);
    return retval;
}
static PyObject* __Pyx_PyNumber_LongWrongResultType(PyObject* result) {
    __Pyx_TypeName result_type_name = __Pyx_PyType_GetFullyQualifiedName(Py_TYPE(result));
    if (PyLong_Check(result)) {
        if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
                "__int__ returned non-int (type " __Pyx_FMT_TYPENAME ").  "
                "The ability to return an instance of a strict subclass of int is deprecated, "
                "and may be removed in a future version of Python.",
                result_type_name)) {
            __Pyx_DECREF_TypeName(result_type_name);
            Py_DECREF(result);
            return NULL;
        }
        __Pyx_DECREF_TypeName(result_type_name);
        return result;
    }
    PyErr_Format(PyExc_TypeError,
                 "__int__ returned non-int (type " __Pyx_FMT_TYPENAME ")",
                 result_type_name);
    __Pyx_DECREF_TypeName(result_type_name);
    Py_DECREF(result);
    return NULL;
}
static CYTHON_INLINE PyObject* __Pyx_PyNumber_Long(PyObject* x) {
#if CYTHON_USE_TYPE_SLOTS
  PyNumberMethods *m;
#endif
  PyObject *res = NULL;
  if (likely(PyLong_Check(x)))
      return __Pyx_NewRef(x);
#if CYTHON_USE_TYPE_SLOTS
  m = Py_TYPE(x)->tp_as_number;
  if (likely(m && m->nb_int)) {
      res = m->nb_int(x);
  }
#else
  if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
      res = PyNumber_Long(x);
  }
#endif
  if (likely(res)) {
      if (unlikely(!PyLong_CheckExact(res))) {
          return __Pyx_PyNumber_LongWrongResultType(res);
      }
  }
  else if (!PyErr_Occurred()) {
      PyErr_SetString(PyExc_TypeError,
                      "an integer is required");
  }
  return res;
}
static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
  Py_ssize_t ival;
  PyObject *x;
  if (likely(PyLong_CheckExact(b))) {
    #if CYTHON_USE_PYLONG_INTERNALS
    if (likely(__Pyx_PyLong_IsCompact(b))) {
        return __Pyx_PyLong_CompactValue(b);
    } else {
      const digit* digits = __Pyx_PyLong_Digits(b);
      const Py_ssize_t size = __Pyx_PyLong_SignedDigitCount(b);
      switch (size) {
         case 2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -2:
           if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -3:
           if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case 4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
         case -4:
           if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
             return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
           }
           break;
      }
    }
    #endif
    return PyLong_AsSsize_t(b);
  }
  x = PyNumber_Index(b);
  if (!x) return -1;
  ival = PyLong_AsSsize_t(x);
  Py_DECREF(x);
  return ival;
}
static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject* o) {
  if (sizeof(Py_hash_t) == sizeof(Py_ssize_t)) {
    return (Py_hash_t) __Pyx_PyIndex_AsSsize_t(o);
  } else {
    Py_ssize_t ival;
    PyObject *x;
    x = PyNumber_Index(o);
    if (!x) return -1;
    ival = PyLong_AsLong(x);
    Py_DECREF(x);
    return ival;
  }
}
static CYTHON_INLINE PyObject *__Pyx_Owned_Py_None(int b) {
    CYTHON_UNUSED_VAR(b);
    return __Pyx_NewRef(Py_None);
}
static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
  return __Pyx_NewRef(b ? Py_True: Py_False);
}
static CYTHON_INLINE PyObject * __Pyx_PyLong_FromSize_t(size_t ival) {
    return PyLong_FromSize_t(ival);
}


  /* MultiPhaseInitModuleState */
  #if CYTHON_PEP489_MULTI_PHASE_INIT && CYTHON_USE_MODULE_STATE
  #ifndef CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  #if (CYTHON_COMPILING_IN_LIMITED_API || PY_VERSION_HEX >= 0x030C0000)
    #define CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE 1
  #else
    #define CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE 0
  #endif
  #endif
  #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE && !CYTHON_ATOMICS
  #error "Module state with PEP489 requires atomics. Currently that's one of\
   C11, C++11, gcc atomic intrinsics or MSVC atomic intrinsics"
  #endif
  #if !CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  #define __Pyx_ModuleStateLookup_Lock()
  #define __Pyx_ModuleStateLookup_Unlock()
  #elif !CYTHON_COMPILING_IN_LIMITED_API && PY_VERSION_HEX >= 0x030d0000
  static PyMutex __Pyx_ModuleStateLookup_mutex = {0};
  #define __Pyx_ModuleStateLookup_Lock() PyMutex_Lock(&__Pyx_ModuleStateLookup_mutex)
  #define __Pyx_ModuleStateLookup_Unlock() PyMutex_Unlock(&__Pyx_ModuleStateLookup_mutex)
  #elif defined(__cplusplus) && __cplusplus >= 201103L
  #include <mutex>
  static std::mutex __Pyx_ModuleStateLookup_mutex;
  #define __Pyx_ModuleStateLookup_Lock() __Pyx_ModuleStateLookup_mutex.lock()
  #define __Pyx_ModuleStateLookup_Unlock() __Pyx_ModuleStateLookup_mutex.unlock()
  #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ > 201112L) && !defined(__STDC_NO_THREADS__)
  #include <threads.h>
  static mtx_t __Pyx_ModuleStateLookup_mutex;
  static once_flag __Pyx_ModuleStateLookup_mutex_once_flag = ONCE_FLAG_INIT;
  static void __Pyx_ModuleStateLookup_initialize_mutex(void) {
      mtx_init(&__Pyx_ModuleStateLookup_mutex, mtx_plain);
  }
  #define __Pyx_ModuleStateLookup_Lock()\
    call_once(&__Pyx_ModuleStateLookup_mutex_once_flag, __Pyx_ModuleStateLookup_initialize_mutex);\
    mtx_lock(&__Pyx_ModuleStateLookup_mutex)
  #define __Pyx_ModuleStateLookup_Unlock() mtx_unlock(&__Pyx_ModuleStateLookup_mutex)
  #elif defined(HAVE_PTHREAD_H)
  #include <pthread.h>
  static pthread_mutex_t __Pyx_ModuleStateLookup_mutex = PTHREAD_MUTEX_INITIALIZER;
  #define __Pyx_ModuleStateLookup_Lock() pthread_mutex_lock(&__Pyx_ModuleStateLookup_mutex)
  #define __Pyx_ModuleStateLookup_Unlock() pthread_mutex_unlock(&__Pyx_ModuleStateLookup_mutex)
  #elif defined(_WIN32)
  #include <Windows.h>  // synchapi.h on its own doesn't work
  static SRWLOCK __Pyx_ModuleStateLookup_mutex = SRWLOCK_INIT;
  #define __Pyx_ModuleStateLookup_Lock() AcquireSRWLockExclusive(&__Pyx_ModuleStateLookup_mutex)
  #define __Pyx_ModuleStateLookup_Unlock() ReleaseSRWLockExclusive(&__Pyx_ModuleStateLookup_mutex)
  #else
  #error "No suitable lock available for CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE.\
   Requires C standard >= C11, or C++ standard >= C++11,\
   or pthreads, or the Windows 32 API, or Python >= 3.13."
  #endif
  typedef struct {
      int64_t id;
      PyObject *module;
  } __Pyx_InterpreterIdAndModule;
  typedef struct {
      char interpreter_id_as_index;
      Py_ssize_t count;
      Py_ssize_t allocated;
      __Pyx_InterpreterIdAndModule table[1];
  } __Pyx_ModuleStateLookupData;
  #define __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE 32
  #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  static __pyx_atomic_int_type __Pyx_ModuleStateLookup_read_counter = 0;
  #endif
  #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  static __pyx_atomic_ptr_type __Pyx_ModuleStateLookup_data = 0;
  #else
  static __Pyx_ModuleStateLookupData* __Pyx_ModuleStateLookup_data = NULL;
  #endif
  static __Pyx_InterpreterIdAndModule* __Pyx_State_FindModuleStateLookupTableLowerBound(
          __Pyx_InterpreterIdAndModule* table,
          Py_ssize_t count,
          int64_t interpreterId) {
      __Pyx_InterpreterIdAndModule* begin = table;
      __Pyx_InterpreterIdAndModule* end = begin + count;
      if (begin->id == interpreterId) {
          return begin;
      }
      while ((end - begin) > __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE) {
          __Pyx_InterpreterIdAndModule* halfway = begin + (end - begin)/2;
          if (halfway->id == interpreterId) {
              return halfway;
          }
          if (halfway->id < interpreterId) {
              begin = halfway;
          } else {
              end = halfway;
          }
      }
      for (; begin < end; ++begin) {
          if (begin->id >= interpreterId) return begin;
      }
      return begin;
  }
  static PyObject *__Pyx_State_FindModule(CYTHON_UNUSED void* dummy) {
      int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get());
      if (interpreter_id == -1) return NULL;
  #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
      __Pyx_ModuleStateLookupData* data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_relaxed(&__Pyx_ModuleStateLookup_data);
      {
          __pyx_atomic_incr_acq_rel(&__Pyx_ModuleStateLookup_read_counter);
          if (likely(data)) {
              __Pyx_ModuleStateLookupData* new_data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_acquire(&__Pyx_ModuleStateLookup_data);
              if (likely(data == new_data)) {
                  goto read_finished;
              }
          }
          __pyx_atomic_decr_acq_rel(&__Pyx_ModuleStateLookup_read_counter);
          __Pyx_ModuleStateLookup_Lock();
          __pyx_atomic_incr_relaxed(&__Pyx_ModuleStateLookup_read_counter);
          data = (__Pyx_ModuleStateLookupData*)__pyx_atomic_pointer_load_relaxed(&__Pyx_ModuleStateLookup_data);
          __Pyx_ModuleStateLookup_Unlock();
      }
    read_finished:;
  #else
      __Pyx_ModuleStateLookupData* data = __Pyx_ModuleStateLookup_data;
  #endif
      __Pyx_InterpreterIdAndModule* found = NULL;
      if (unlikely(!data)) goto end;
      if (data->interpreter_id_as_index) {
          if (interpreter_id < data->count) {
              found = data->table+interpreter_id;
          }
      } else {
          found = __Pyx_State_FindModuleStateLookupTableLowerBound(
              data->table, data->count, interpreter_id);
      }
    end:
      {
          PyObject *result=NULL;
          if (found && found->id == interpreter_id) {
              result = found->module;
          }
  #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
          __pyx_atomic_decr_acq_rel(&__Pyx_ModuleStateLookup_read_counter);
  #endif
          return result;
      }
  }
  #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
  static void __Pyx_ModuleStateLookup_wait_until_no_readers(void) {
      while (__pyx_atomic_load(&__Pyx_ModuleStateLookup_read_counter) != 0);
  }
  #else
  #define __Pyx_ModuleStateLookup_wait_until_no_readers()
  #endif
  static int __Pyx_State_AddModuleInterpIdAsIndex(__Pyx_ModuleStateLookupData **old_data, PyObject* module, int64_t interpreter_id) {
      Py_ssize_t to_allocate = (*old_data)->allocated;
      while (to_allocate <= interpreter_id) {
          if (to_allocate == 0) to_allocate = 1;
          else to_allocate *= 2;
      }
      __Pyx_ModuleStateLookupData *new_data = *old_data;
      if (to_allocate != (*old_data)->allocated) {
           new_data = (__Pyx_ModuleStateLookupData *)realloc(
              *old_data,
              sizeof(__Pyx_ModuleStateLookupData)+(to_allocate-1)*sizeof(__Pyx_InterpreterIdAndModule));
          if (!new_data) {
              PyErr_NoMemory();
              return -1;
          }
          for (Py_ssize_t i = new_data->allocated; i < to_allocate; ++i) {
              new_data->table[i].id = i;
              new_data->table[i].module = NULL;
          }
          new_data->allocated = to_allocate;
      }
      new_data->table[interpreter_id].module = module;
      if (new_data->count < interpreter_id+1) {
          new_data->count = interpreter_id+1;
      }
      *old_data = new_data;
      return 0;
  }
  static void __Pyx_State_ConvertFromInterpIdAsIndex(__Pyx_ModuleStateLookupData *data) {
      __Pyx_InterpreterIdAndModule *read = data->table;
      __Pyx_InterpreterIdAndModule *write = data->table;
      __Pyx_InterpreterIdAndModule *end = read + data->count;
      for (; read<end; ++read) {
          if (read->module) {
              write->id = read->id;
              write->module = read->module;
              ++write;
          }
      }
      data->count = write - data->table;
      for (; write<end; ++write) {
          write->id = 0;
          write->module = NULL;
      }
      data->interpreter_id_as_index = 0;
  }
  static int __Pyx_State_AddModule(PyObject* module, CYTHON_UNUSED void* dummy) {
      int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get());
      if (interpreter_id == -1) return -1;
      int result = 0;
      __Pyx_ModuleStateLookup_Lock();
  #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
      __Pyx_ModuleStateLookupData *old_data = (__Pyx_ModuleStateLookupData *)
              __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, 0);
  #else
      __Pyx_ModuleStateLookupData *old_data = __Pyx_ModuleStateLookup_data;
  #endif
      __Pyx_ModuleStateLookupData *new_data = old_data;
      if (!new_data) {
          new_data = (__Pyx_ModuleStateLookupData *)calloc(1, sizeof(__Pyx_ModuleStateLookupData));
          if (!new_data) {
              result = -1;
              PyErr_NoMemory();
              goto end;
          }
          new_data->allocated = 1;
          new_data->interpreter_id_as_index = 1;
      }
      __Pyx_ModuleStateLookup_wait_until_no_readers();
      if (new_data->interpreter_id_as_index) {
          if (interpreter_id < __PYX_MODULE_STATE_LOOKUP_SMALL_SIZE) {
              result = __Pyx_State_AddModuleInterpIdAsIndex(&new_data, module, interpreter_id);
              goto end;
          }
          __Pyx_State_ConvertFromInterpIdAsIndex(new_data);
      }
      {
          Py_ssize_t insert_at = 0;
          {
              __Pyx_InterpreterIdAndModule* lower_bound = __Pyx_State_FindModuleStateLookupTableLowerBound(
                  new_data->table, new_data->count, interpreter_id);
              assert(lower_bound);
              insert_at = lower_bound - new_data->table;
              if (unlikely(insert_at < new_data->count && lower_bound->id == interpreter_id)) {
                  lower_bound->module = module;
                  goto end;  // already in table, nothing more to do
              }
          }
          if (new_data->count+1 >= new_data->allocated) {
              Py_ssize_t to_allocate = (new_data->count+1)*2;
              new_data =
                  (__Pyx_ModuleStateLookupData*)realloc(
                      new_data,
                      sizeof(__Pyx_ModuleStateLookupData) +
                      (to_allocate-1)*sizeof(__Pyx_InterpreterIdAndModule));
              if (!new_data) {
                  result = -1;
                  new_data = old_data;
                  PyErr_NoMemory();
                  goto end;
              }
              new_data->allocated = to_allocate;
          }
          ++new_data->count;
          int64_t last_id = interpreter_id;
          PyObject *last_module = module;
          for (Py_ssize_t i=insert_at; i<new_data->count; ++i) {
              int64_t current_id = new_data->table[i].id;
              new_data->table[i].id = last_id;
              last_id = current_id;
              PyObject *current_module = new_data->table[i].module;
              new_data->table[i].module = last_module;
              last_module = current_module;
          }
      }
    end:
  #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
      __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, new_data);
  #else
      __Pyx_ModuleStateLookup_data = new_data;
  #endif
      __Pyx_ModuleStateLookup_Unlock();
      return result;
  }
  static int __Pyx_State_RemoveModule(CYTHON_UNUSED void* dummy) {
      int64_t interpreter_id = PyInterpreterState_GetID(__Pyx_PyInterpreterState_Get());
      if (interpreter_id == -1) return -1;
      __Pyx_ModuleStateLookup_Lock();
  #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
      __Pyx_ModuleStateLookupData *data = (__Pyx_ModuleStateLookupData *)
              __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, 0);
  #else
      __Pyx_ModuleStateLookupData *data = __Pyx_ModuleStateLookup_data;
  #endif
      if (data->interpreter_id_as_index) {
          if (interpreter_id < data->count) {
              data->table[interpreter_id].module = NULL;
          }
          goto done;
      }
      {
          __Pyx_ModuleStateLookup_wait_until_no_readers();
          __Pyx_InterpreterIdAndModule* lower_bound = __Pyx_State_FindModuleStateLookupTableLowerBound(
              data->table, data->count, interpreter_id);
          if (!lower_bound) goto done;
          if (lower_bound->id != interpreter_id) goto done;
          __Pyx_InterpreterIdAndModule *end = data->table+data->count;
          for (;lower_bound<end-1; ++lower_bound) {
              lower_bound->id = (lower_bound+1)->id;
              lower_bound->module = (lower_bound+1)->module;
          }
      }
      --data->count;
      if (data->count == 0) {
          free(data);
          data = NULL;
      }
    done:
  #if CYTHON_MODULE_STATE_LOOKUP_THREAD_SAFE
      __pyx_atomic_pointer_exchange(&__Pyx_ModuleStateLookup_data, data);
  #else
      __Pyx_ModuleStateLookup_data = data;
  #endif
      __Pyx_ModuleStateLookup_Unlock();
      return 0;
  }
  #endif
  
/* #### Code section: utility_code_pragmas_end ### */
#ifdef _MSC_VER
#pragma warning( pop )
#endif



/* #### Code section: end ### */
#endif /* Py_PYTHON_H */
